1 | /* |
---|
2 | Copyright (c) 2013 Humu humu2009@gmail.com |
---|
3 | jsc3d is freely distributable under the terms of the MIT license. |
---|
4 | */ |
---|
5 | var a,JSC3D=JSC3D||{}; |
---|
6 | JSC3D.Viewer=function(b,c){this.params=c?{SceneUrl:c.SceneUrl||"",InitRotationX:c.InitRotationX||0,InitRotationY:c.InitRotationY||0,InitRotationZ:c.InitRotationZ||0,ModelColor:c.ModelColor||"#caa618",BackgroundColor1:c.BackgroundColor1||"#ffffff",BackgroundColor2:c.BackgroundColor2||"#383840",BackgroundImageUrl:c.BackgroundImageUrl||"",RenderMode:c.RenderMode||"flat",Definition:c.Definition||"standard",MipMapping:c.MipMapping||"off",CreaseAngle:c.parameters||-180,SphereMapUrl:c.SphereMapUrl||""}: |
---|
7 | {SceneUrl:"",InitRotationX:0,InitRotationY:0,InitRotationZ:0,ModelColor:"#caa618",BackgroundColor1:"#ffffff",BackgroundColor2:"#383840",BackgroundImageUrl:"",RenderMode:"flat",Definition:"standard",MipMapping:"off",CreaseAngle:-180,SphereMapUrl:""};this.canvas=b;this.selectionBuffer=this.zBuffer=this.colorBuffer=this.bkgColorBuffer=this.canvasData=this.ctx=null;this.frameWidth=b.width;this.frameHeight=b.height;this.sphereMap=this.defaultMaterial=this.scene=null;this.isFailed=this.isLoaded=false;this.errorMsg= |
---|
8 | "";this.needRepaint=this.needUpdate=false;this.initRotZ=this.initRotY=this.initRotX=0;this.zoomFactor=1;this.panning=[0,0];this.rotMatrix=new JSC3D.Matrix3x4;this.transformMatrix=new JSC3D.Matrix3x4;this.sceneUrl="";this.modelColor=13280792;this.bkgColor1=16777215;this.bkgColor2=3684416;this.bkgImageUrl="";this.bkgImage=null;this.renderMode="flat";this.definition="standard";this.isMipMappingOn=false;this.creaseAngle=-180;this.sphereMapUrl="";this.buttonStates={};this.keyStates={};this.mouseY=this.mouseX= |
---|
9 | 0;this.afterupdate=this.beforeupdate=this.onmousewheel=this.onmousemove=this.onmouseup=this.onmousedown=null;this.mouseUsage="default";this.isDefaultInputHandlerEnabled=true;var d=this;if(JSC3D.PlatformInfo.isTouchDevice){this.canvas.addEventListener("touchstart",function(e){d.touchStartHandler(e)},false);this.canvas.addEventListener("touchend",function(e){d.touchEndHandler(e)},false);this.canvas.addEventListener("touchmove",function(e){d.touchMoveHandler(e)},false)}else{this.canvas.addEventListener("mousedown", |
---|
10 | function(e){d.mouseDownHandler(e)},false);this.canvas.addEventListener("mouseup",function(e){d.mouseUpHandler(e)},false);this.canvas.addEventListener("mousemove",function(e){d.mouseMoveHandler(e)},false);this.canvas.addEventListener(JSC3D.PlatformInfo.browser=="firefox"?"DOMMouseScroll":"mousewheel",function(e){d.mouseWheelHandler(e)},false);document.addEventListener("keydown",function(e){d.keyDownHandler(e)},false);document.addEventListener("keyup",function(e){d.keyUpHandler(e)},false)}};a=JSC3D.Viewer.prototype; |
---|
11 | a.setParameter=function(b,c){this.params[b]=c}; |
---|
12 | a.init=function(){this.sceneUrl=this.params.SceneUrl;this.initRotX=parseFloat(this.params.InitRotationX);this.initRotY=parseFloat(this.params.InitRotationY);this.initRotZ=parseFloat(this.params.InitRotationZ);this.modelColor=parseInt("0x"+this.params.ModelColor.substring(1));this.bkgColor1=parseInt("0x"+this.params.BackgroundColor1.substring(1));this.bkgColor2=parseInt("0x"+this.params.BackgroundColor2.substring(1));this.bkgImageUrl=this.params.BackgroundImageUrl;this.renderMode=this.params.RenderMode.toLowerCase(); |
---|
13 | this.definition=this.params.Definition.toLowerCase();this.creaseAngle=parseFloat(this.params.CreaseAngle);this.isMipMappingOn=this.params.MipMapping.toLowerCase()=="on";this.sphereMapUrl=this.params.SphereMapUrl;try{this.ctx=this.canvas.getContext("2d");this.canvasData=this.ctx.getImageData(0,0,this.canvas.width,this.canvas.height)}catch(b){this.canvasData=this.ctx=null}if(this.canvas.width<=2||this.canvas.height<=2)this.definition="standard";switch(this.definition){case "low":this.frameWidth=~~((this.canvas.width+ |
---|
14 | 1)/2);this.frameHeight=~~((this.canvas.height+1)/2);break;case "high":this.frameWidth=this.canvas.width*2;this.frameHeight=this.canvas.height*2;break;case "standard":default:this.frameWidth=this.canvas.width;this.frameHeight=this.canvas.height;break}this.zoomFactor=1;this.panning=[0,0];this.rotMatrix.identity();this.transformMatrix.identity();this.isFailed=this.isLoaded=false;this.errorMsg="";this.needRepaint=this.needUpdate=false;this.scene=null;this.colorBuffer=new Array(this.frameWidth*this.frameHeight); |
---|
15 | this.zBuffer=new Array(this.frameWidth*this.frameHeight);this.selectionBuffer=new Array(this.frameWidth*this.frameHeight);this.bkgColorBuffer=new Array(this.frameWidth*this.frameHeight);this.generateBackground();this.defaultMaterial=new JSC3D.Material;this.defaultMaterial.ambientColor=0;this.defaultMaterial.diffuseColor=this.modelColor;this.defaultMaterial.transparency=0;this.defaultMaterial.simulateSpecular=true;this.drawBackground();var c=this;(function d(){c.doUpdate();setTimeout(d,30)})();this.setBackgroudImageFromUrl(this.bkgImageUrl); |
---|
16 | this.loadScene();this.setSphereMapFromUrl(this.sphereMapUrl)};a.update=function(b){if(this.isFailed)this.reportError(this.errorMsg);else if(b)this.needRepaint=true;else this.needUpdate=true};a.rotate=function(b,c,d){this.rotMatrix.rotateAboutXAxis(b);this.rotMatrix.rotateAboutYAxis(c);this.rotMatrix.rotateAboutZAxis(d)};a.setRenderMode=function(b){this.renderMode=this.params.RenderMode=b}; |
---|
17 | a.setDefinition=function(b){if(this.canvas.width<=2||this.canvas.height<=2)b="standard";if(b!=this.definition){this.definition=this.params.Definition=b;b=this.frameWidth;switch(this.definition){case "low":this.frameWidth=~~((this.canvas.width+1)/2);this.frameHeight=~~((this.canvas.height+1)/2);break;case "high":this.frameWidth=this.canvas.width*2;this.frameHeight=this.canvas.height*2;break;case "standard":default:this.frameWidth=this.canvas.width;this.frameHeight=this.canvas.height;break}var c=this.frameWidth* |
---|
18 | this.frameHeight;if(this.colorBuffer.length<c)this.colorBuffer=new Array(c);if(this.zBuffer.length<c)this.zBuffer=new Array(c);if(this.selectionBuffer.length<c)this.selectionBuffer=new Array(c);if(this.bkgColorBuffer.length<c)this.bkgColorBuffer=new Array(c);this.generateBackground();b=this.frameWidth/b;this.zoomFactor*=b;this.panning[0]*=b;this.panning[1]*=b}}; |
---|
19 | a.setBackgroudImageFromUrl=function(b){this.bkgImageUrl=this.params.BackgroundImageUrl=b;if(b=="")this.bkgImage=null;else{var c=this,d=new Image;d.onload=function(){c.bkgImage=this;c.generateBackground()};d.src=b}};a.setSphereMapFromUrl=function(b){this.sphereMapUrl=this.params.SphereMapUrl=b;if(b=="")this.sphereMap=null;else{var c=this,d=new JSC3D.Texture;d.onready=function(){c.sphereMap=d;c.update()};d.createFromUrl(this.sphereMapUrl)}}; |
---|
20 | a.enableDefaultInputHandler=function(b){this.isDefaultInputHandlerEnabled=b};a.setMouseUsage=function(b){this.mouseUsage=b};a.replaceSceneFromUrl=function(b){this.sceneUrl=this.params.SceneUrl=b;this.isFailed=this.isLoaded=false;this.loadScene()};a.replaceScene=function(b){this.sceneUrl=this.params.SceneUrl="";this.isFailed=false;this.isLoaded=true;this.errorMsg="";this.setupScene(b)}; |
---|
21 | a.resetScene=function(){var b=!this.scene||this.scene.isEmpty()?0:this.scene.aabb.lengthOfDiagonal();this.zoomFactor=b==0?1:(this.frameWidth<this.frameHeight?this.frameWidth:this.frameHeight)/b;this.panning=[0,0];this.rotMatrix.identity();this.rotMatrix.rotateAboutXAxis(this.initRotX);this.rotMatrix.rotateAboutYAxis(this.initRotY);this.rotMatrix.rotateAboutZAxis(this.initRotZ)};a.getScene=function(){return this.scene}; |
---|
22 | a.pick=function(b,c){var d=new JSC3D.PickInfo,e=this.canvas.getBoundingClientRect();b=b-e.left;c=c-e.top;e=b;var f=c;if(this.selectionBuffer!=null&&b>=0&&b<this.canvas.width&&c>=0&&c<this.canvas.height){switch(this.definition){case "low":e=~~(e/2);f=~~(f/2);break;case "high":e*=2;f*=2;break;case "standard":default:break}var g=this.selectionBuffer[f*this.frameWidth+e];if(g>0)for(var h=this.scene.getChildren(),i=0;i<h.length;i++)if(h[i].internalId==g){d.mesh=h[i];break}}d.canvasX=b;d.canvasY=c;if(d.mesh)d.depth= |
---|
23 | this.zBuffer[f*this.frameWidth+e];return d};a.doUpdate=function(){if(this.needUpdate||this.needRepaint){this.beforeupdate!=null&&typeof this.beforeupdate=="function"&&this.beforeupdate();if(this.scene){if(this.needUpdate&&this.colorBuffer!=null){this.beginScene();this.render();this.endScene()}this.paint()}else this.drawBackground();this.needUpdate=this.needRepaint=false;this.afterupdate!=null&&typeof this.afterupdate=="function"&&this.afterupdate()}}; |
---|
24 | a.paint=function(){this.canvasData&&this.ctx.putImageData(this.canvasData,0,0)};a.mouseDownHandler=function(b){if(this.isLoaded){if(this.onmousedown){var c=this.pick(b.clientX,b.clientY);this.onmousedown(c.canvasX,c.canvasY,b.button,c.depth,c.mesh)}b.preventDefault();b.stopPropagation();if(this.isDefaultInputHandlerEnabled){this.buttonStates[b.button]=true;this.mouseX=b.clientX;this.mouseY=b.clientY}}}; |
---|
25 | a.mouseUpHandler=function(b){if(this.isLoaded){if(this.onmouseup){var c=this.pick(b.clientX,b.clientY);this.onmouseup(c.canvasX,c.canvasY,b.button,c.depth,c.mesh)}b.preventDefault();b.stopPropagation();if(this.isDefaultInputHandlerEnabled)this.buttonStates[b.button]=false}}; |
---|
26 | a.mouseMoveHandler=function(b){if(this.isLoaded){if(this.onmousemove){var c=this.pick(b.clientX,b.clientY);this.onmousemove(c.canvasX,c.canvasY,b.button,c.depth,c.mesh)}b.preventDefault();b.stopPropagation();if(this.isDefaultInputHandlerEnabled){c=this.keyStates[16]==true;var d=this.keyStates[17]==true;if(this.buttonStates[0]==true){if(c&&this.mouseUsage=="default"||this.mouseUsage=="zoom")this.zoomFactor*=this.mouseY<=b.clientY?1.04:0.96;else if(d&&this.mouseUsage=="default"||this.mouseUsage=="pan"){c= |
---|
27 | this.definition=="low"?0.5:this.definition=="high"?2:1;this.panning[0]+=c*(b.clientX-this.mouseX);this.panning[1]+=c*(b.clientY-this.mouseY)}else if(this.mouseUsage=="default"||this.mouseUsage=="rotate"){c=(b.clientX-this.mouseX)*360/this.canvas.height;this.rotMatrix.rotateAboutXAxis((b.clientY-this.mouseY)*360/this.canvas.width);this.rotMatrix.rotateAboutYAxis(c)}this.mouseX=b.clientX;this.mouseY=b.clientY;this.update()}}}}; |
---|
28 | a.mouseWheelHandler=function(b){if(this.isLoaded){if(this.onmousewheel){var c=this.pick(b.clientX,b.clientY);this.onmousewheel(c.canvasX,c.canvasY,b.button,c.depth,c.mesh)}b.preventDefault();b.stopPropagation();if(this.isDefaultInputHandlerEnabled){this.zoomFactor*=(JSC3D.PlatformInfo.browser=="firefox"?-b.detail:b.wheelDelta)<0?1.1:0.91;this.update()}}}; |
---|
29 | a.touchStartHandler=function(b){if(this.isLoaded)if(b.touches.length>0){var c=b.touches[0].clientX,d=b.touches[0].clientY;if(this.onmousedown){var e=this.pick(c,d);this.onmousedown(e.canvasX,e.canvasY,0,e.depth,e.mesh)}b.preventDefault();b.stopPropagation();if(this.isDefaultInputHandlerEnabled){this.buttonStates[0]=true;this.mouseX=c;this.mouseY=d}}}; |
---|
30 | a.touchEndHandler=function(b){if(this.isLoaded){if(this.onmouseup){var c=this.pick(this.mouseX,this.mouseY);this.onmouseup(c.canvasX,c.canvasY,0,c.depth,c.mesh)}b.preventDefault();b.stopPropagation();if(this.isDefaultInputHandlerEnabled)this.buttonStates[0]=false}}; |
---|
31 | a.touchMoveHandler=function(b){if(this.isLoaded)if(b.touches.length>0){var c=b.touches[0].clientX,d=b.touches[0].clientY;if(this.onmousemove){var e=this.pick(c,d);this.onmousemove(e.canvasX,e.canvasY,0,e.depth,e.mesh)}b.preventDefault();b.stopPropagation();if(this.isDefaultInputHandlerEnabled){if(this.mouseUsage=="zoom")this.zoomFactor*=this.mouseY<=d?1.04:0.96;else if(this.mouseUsage=="pan"){b=this.definition=="low"?0.5:this.definition=="high"?2:1;this.panning[0]+=b*(c-this.mouseX);this.panning[1]+= |
---|
32 | b*(d-this.mouseY)}else if(this.mouseUsage=="default"||this.mouseUsage=="rotate"){b=(c-this.mouseX)*360/this.canvas.height;this.rotMatrix.rotateAboutXAxis((d-this.mouseY)*360/this.canvas.width);this.rotMatrix.rotateAboutYAxis(b)}this.mouseX=c;this.mouseY=d;this.update()}}};a.keyDownHandler=function(b){if(this.isDefaultInputHandlerEnabled)this.keyStates[b.keyCode]=true};a.keyUpHandler=function(b){if(this.isDefaultInputHandlerEnabled)this.keyStates[b.keyCode]=false}; |
---|
33 | a.loadScene=function(){this.scene=null;this.isLoaded=false;if(this.sceneUrl=="")return false;var b=this.sceneUrl.lastIndexOf("/");if(b==-1)b=this.sceneUrl.lastIndexOf("\\");b=this.sceneUrl.substring(b+1);var c=b.lastIndexOf(".");if(c==-1)return false;b=b.substring(c+1);b=JSC3D.LoaderSelector.getLoader(b);if(!b)return false;var d=this;b.onload=function(e){d.setupScene(e)};b.onerror=function(e){d.scene=null;d.isLoaded=false;d.isFailed=true;d.errorMsg=e;d.update()};b.onprogress=function(e,f){d.reportProgress(e, |
---|
34 | f)};b.onresource=function(e){e instanceof JSC3D.Texture&&d.isMipMappingOn&&!e.hasMipmap()&&e.generateMipmaps();d.update()};b.loadFromUrl(this.sceneUrl);return true}; |
---|
35 | a.setupScene=function(b){if(this.creaseAngle>=0){var c=this.creaseAngle;b.forEachChild(function(g){g.creaseAngle=c})}b.init();if(!b.isEmpty()){var d=b.aabb.lengthOfDiagonal(),e=this.frameWidth,f=this.frameHeight;this.zoomFactor=d==0?1:(e<f?e:f)/d;this.panning=[0,0]}this.rotMatrix.identity();this.rotMatrix.rotateAboutXAxis(this.initRotX);this.rotMatrix.rotateAboutYAxis(this.initRotY);this.rotMatrix.rotateAboutZAxis(this.initRotZ);this.scene=b;this.isLoaded=true;this.isFailed=false;this.errorMsg=""; |
---|
36 | this.needRepaint=this.needUpdate=false;this.update()}; |
---|
37 | a.reportProgress=function(b,c){if(this.ctx){this.drawBackground();this.ctx.save();var d=255-((this.bkgColor1&65280)>>8),e=255-(this.bkgColor1&255);d="#"+(255-((this.bkgColor1&16711680)>>16)).toString(16)+d.toString(16)+e.toString(16);this.ctx.strokeStyle=d;this.ctx.fillStyle=d;d=this.canvas.height*0.38;e=this.canvas.width-80;this.ctx.strokeRect(40,d,e,20);this.ctx.fillRect(42,d+2,(e-4)*c,16);this.ctx.font="12px Courier New";this.ctx.textAlign="left";this.ctx.fillText(b,40,d-4,e);this.ctx.restore()}}; |
---|
38 | a.reportError=function(b){if(this.ctx){this.drawBackground();this.ctx.save();var c=this.canvas.height*0.38-4,d=255-((this.bkgColor1&65280)>>8),e=255-(this.bkgColor1&255);this.ctx.fillStyle="#"+(255-((this.bkgColor1&16711680)>>16)).toString(16)+d.toString(16)+e.toString(16);this.ctx.font="16px Courier New";this.ctx.textAlign="left";this.ctx.fillText(b,40,c);this.ctx.restore()}};a.generateBackground=function(){this.bkgImage?this.fillBackgroundWithImage():this.fillGradientBackground()}; |
---|
39 | a.fillGradientBackground=function(){for(var b=this.frameWidth,c=this.frameHeight,d=this.bkgColorBuffer,e=(this.bkgColor1&16711680)>>16,f=(this.bkgColor1&65280)>>8,g=this.bkgColor1&255,h=(this.bkgColor2&16711680)>>16,i=(this.bkgColor2&65280)>>8,l=this.bkgColor2&255,o=0,u=0;u<c;u++)for(var j=e+u*(h-e)/c&255,B=f+u*(i-f)/c&255,n=g+u*(l-g)/c&255,M=0;M<b;M++)d[o++]=j<<16|B<<8|n}; |
---|
40 | a.fillBackgroundWithImage=function(){var b=this.frameWidth,c=this.frameHeight;if(!(this.bkgImage.width<=0||this.bkgImage.height<=0)){var d=false,e=JSC3D.Texture.cv;if(!e)try{e=document.createElement("canvas");JSC3D.Texture.cv=e;d=true}catch(f){return}if(e.width!=b||e.height!=c){e.width=b;e.height=c;d=true}var g=null;try{var h=e.getContext("2d");d||h.clearRect(0,0,b,c);h.drawImage(this.bkgImage,0,0,b,c);g=h.getImageData(0,0,b,c).data}catch(i){return}d=this.bkgColorBuffer;b=b*c;for(e=c=0;c<b;c++,e+= |
---|
41 | 4)d[c]=g[e]<<16|g[e+1]<<8|g[e+2]}};a.drawBackground=function(){if(this.canvasData){this.beginScene();this.endScene();this.paint()}};a.beginScene=function(){for(var b=this.colorBuffer,c=this.zBuffer,d=this.selectionBuffer,e=this.bkgColorBuffer,f=this.frameWidth*this.frameHeight,g=-Number.MAX_VALUE,h=0;h<f;h++){b[h]=e[h];c[h]=g;d[h]=0}}; |
---|
42 | a.endScene=function(){var b=this.canvasData.data,c=this.canvas.width,d=this.canvas.height,e=this.colorBuffer,f=this.frameWidth,g=f*this.frameHeight;switch(this.definition){case "low":var h=c>>1,i=f-h,l=0,o=0;for(g=0;g<d;g++){for(var u=0;u<c;u++){f=e[l];b[o]=(f&16711680)>>16;b[o+1]=(f&65280)>>8;b[o+2]=f&255;b[o+3]=255;l+=u&1;o+=4}l+=g&1?i:-h}break;case "high":for(g=o=l=0;g<d;g++){for(u=0;u<c;u++){h=e[l];i=e[l+1];var j=e[l+f],B=e[l+f+1];b[o]=(h&16711680)+(i&16711680)+(j&16711680)+(B&16711680)>>18;b[o+ |
---|
43 | 1]=(h&65280)+(i&65280)+(j&65280)+(B&65280)>>10;b[o+2]=(h&255)+(i&255)+(j&255)+(B&255)>>2;b[o+3]=255;l+=2;o+=4}l+=f}break;case "standard":default:for(o=l=0;l<g;l++,o+=4){f=e[l];b[o]=(f&16711680)>>16;b[o+1]=(f&65280)>>8;b[o+2]=f&255;b[o+3]=255}break}}; |
---|
44 | a.render=function(){if(!this.scene.isEmpty()){var b=this.scene.aabb;this.transformMatrix.identity();this.transformMatrix.translate(-(b.minX+b.maxX)/2,-(b.minY+b.maxY)/2,-(b.minZ+b.maxZ)/2);this.transformMatrix.multiply(this.rotMatrix);this.transformMatrix.scale(this.zoomFactor,-this.zoomFactor,this.zoomFactor);this.transformMatrix.translate(this.frameWidth/2+this.panning[0],this.frameHeight/2+this.panning[1],0);b=this.sortScene(this.transformMatrix);for(var c=0;c<b.length;c++){var d=b[c];if(!d.isTrivial()){JSC3D.Math3D.transformVectors(this.transformMatrix, |
---|
45 | d.vertexBuffer,d.transformedVertexBuffer);if(d.visible)switch(this.renderMode){case "point":this.renderPoint(d);break;case "wireframe":this.renderWireframe(d);break;case "flat":this.renderSolidFlat(d);break;case "smooth":this.renderSolidSmooth(d);break;case "texture":d.hasTexture()?this.renderSolidTexture(d):this.renderSolidFlat(d);break;case "textureflat":d.hasTexture()?this.renderTextureFlat(d):this.renderSolidFlat(d);break;case "texturesmooth":if(d.isEnvironmentCast&&this.sphereMap!=null&&this.sphereMap.hasData())this.renderSolidSphereMapped(d); |
---|
46 | else d.hasTexture()?this.renderTextureSmooth(d):this.renderSolidSmooth(d);break;default:this.renderSolidFlat(d);break}}}}}; |
---|
47 | a.sortScene=function(b){for(var c=[],d=this.scene.getChildren(),e=0;e<d.length;e++){var f=d[e];if(!f.isTrivial()){c.push(f);var g=f.aabb.center();JSC3D.Math3D.transformVectors(b,g,g);f.sortKey={depth:g[2],isTransparnt:(f.material?f.material:this.defaultMaterial).transparency>0||(f.hasTexture()?f.texture.hasTransparency:false)}}}c.sort(function(h,i){if(!h.sortKey.isTransparnt&&i.sortKey.isTransparnt)return-1;if(h.sortKey.isTransparnt&&!i.sortKey.isTransparnt)return 1;if(h.sortKey.isTransparnt)return h.sortKey.depth- |
---|
48 | i.sortKey.depth;return i.sortKey.depth-h.sortKey.depth});return c}; |
---|
49 | a.renderPoint=function(b){var c=this.frameWidth,d=c-1,e=this.frameHeight-1,f=b.transformedVertexBuffer,g=this.colorBuffer,h=this.zBuffer,i=this.selectionBuffer,l=f.length/3,o=b.internalId;b=b.material?b.material.diffuseColor:this.defaultMaterial.diffuseColor;for(var u=0,j=0;u<l;u++,j+=3){var B=~~(f[j]+0.5),n=~~(f[j+1]+0.5),M=f[j+2];if(B>=0&&B<d&&n>=0&&n<e){B=n*c+B;if(M>h[B]){h[B]=M;g[B]=b;i[B]=o}B++;if(M>h[B]){h[B]=M;g[B]=b;i[B]=o}B+=d;if(M>h[B]){h[B]=M;g[B]=b;i[B]=o}B++;if(M>h[B]){h[B]=M;g[B]=b; |
---|
50 | i[B]=o}}}}; |
---|
51 | a.renderWireframe=function(b){var c=this.frameWidth,d=c-1,e=this.frameHeight-1,f=b.indexBuffer,g=b.transformedVertexBuffer,h=b.transformedFaceNormalZBuffer,i=this.colorBuffer,l=this.zBuffer,o=this.selectionBuffer,u=b.faceCount,j=b.internalId,B=b.material?b.material.diffuseColor:this.defaultMaterial.diffuseColor;if(!h||h.length<u){b.transformedFaceNormalZBuffer=new Array(u);h=b.transformedFaceNormalZBuffer}JSC3D.Math3D.transformVectorZs(this.rotMatrix,b.faceNormalBuffer,h);for(var n=0,M=0;n<u;){var J= |
---|
52 | h[n++];if(b.isDoubleSided)J=J>0?J:-J;if(J<0){do;while(f[M++]!=-1)}else{var x,K;x=f[M++]*3;K=f[M++]*3;J=x;for(var H=false;!H;){var F=~~(g[x]+0.5),p=~~(g[x+1]+0.5),r=g[x+2],w=~~(g[K]+0.5),s=~~(g[K+1]+0.5),v=g[K+2],k=w-F,D=s-p,A=v-r,t,m,T;if(Math.abs(k)>Math.abs(D)){t=k;m=k>0?1:-1;T=k!=0?m*D/k:0;k=k!=0?m*A/k:0}else{t=D;T=D>0?1:-1;m=D!=0?T*k/D:0;k=D!=0?T*A/D:0}F=F;p=p;r=r;if(t<0){F=w;p=s;r=v;t=-t;m=-m;T=-T;k=-k}for(w=0;w<t;w++){if(F>=0&&F<d&&p>=0&&p<e){s=~~p*c+~~F;if(r>l[s]){l[s]=r;i[s]=B;o[s]=j}}F+= |
---|
53 | m;p+=T;r+=k}if(K==J)H=true;else{x=K;K=f[M]!=-1?f[M++]*3:J}}M++}}}; |
---|
54 | a.renderSolidFlat=function(b){var c=this.frameWidth,d=this.frameHeight,e=b.indexBuffer,f=b.transformedVertexBuffer,g=b.transformedFaceNormalZBuffer,h=this.colorBuffer,i=this.zBuffer,l=this.selectionBuffer,o=b.faceCount,u=b.internalId,j=b.material?b.material:this.defaultMaterial,B=j.getPalette(),n=j.transparency==0,M=j.transparency*255,J=255-M;var fixForMacSafari=1*null;if(j.transparency!=1){if(!g||g.length<o){b.transformedFaceNormalZBuffer=new Array(o);g=b.transformedFaceNormalZBuffer}JSC3D.Math3D.transformVectorZs(this.rotMatrix,b.faceNormalBuffer, |
---|
55 | g);j=new Array(3);for(var x=new Array(3),K=new Array(3),H=0,F=0;H<o;){var p=g[H++];if(b.isDoubleSided)p=p>0?p:-p;if(p<0){do;while(e[F++]!=-1)}else{p=B[~~(p*255)];var r,w,s;r=e[F++]*3;w=e[F++]*3;do{s=e[F++]*3;j[0]=~~(f[r]+0.5);x[0]=~~(f[r+1]+0.5);K[0]=f[r+2];j[1]=~~(f[w]+0.5);x[1]=~~(f[w+1]+0.5);K[1]=f[w+2];j[2]=~~(f[s]+0.5);x[2]=~~(f[s+1]+0.5);K[2]=f[s+2];w=x[0]<x[1]?0:1;w=x[w]<x[2]?w:2;var v=x[0]>x[1]?0:1;v=x[v]>x[2]?v:2;var k=3-v-w;if(w!=v){var D=j[v],A=K[v],t=x[v]-x[w];t=t!=0?t:1;var m=(j[v]-j[w])/ |
---|
56 | t;t=(K[v]-K[w])/t;var T=j[v],y=K[v],E=x[v]-x[k];E=E!=0?E:1;var C=(j[v]-j[k])/E;E=(K[v]-K[k])/E;var q=j[k],la=K[k],z=x[k]-x[w];z=z!=0?z:1;var ra=(j[k]-j[w])/z;z=(K[k]-K[w])/z;var ma=x[v]*c;for(v=x[v];v>x[w];v--){if(v>=0&&v<d){var Q=~~D,V=A,G,sa;if(v>x[k]){G=~~T;sa=y}else{G=~~q;sa=la}if(Q>G){var da;da=Q;Q=G;G=da;da=V;V=sa;sa=da}if(Q<0)Q=0;if(G>=c)G=c-1;sa=Q!=G?(sa-V)/(G-Q):1;da=ma+Q;if(n){Q=Q;for(V=V;Q<=G;Q++,V+=sa){if(V>i[da]){i[da]=V;h[da]=p;l[da]=u}da++}}else{Q=Q;for(V=V;Q<G;Q++,V+=sa){if(V>i[da]){var ya= |
---|
57 | h[da];h[da]=(ya&16711680)*M+(p&16711680)*J>>8&16711680|(ya&65280)*M+(p&65280)*J>>8&65280|(ya&255)*M+(p&255)*J>>8&255;l[da]=u}da++}}}D-=m;A-=t;if(v>x[k]){T-=C;y-=E}else{q-=ra;la-=z}ma-=c}}w=s}while(e[F]!=-1);F++}}}}; |
---|
58 | a.renderSolidSmooth=function(b){var c=this.frameWidth,d=this.frameHeight,e=b.indexBuffer,f=b.transformedVertexBuffer,g=b.transformedVertexNormalZBuffer,h=b.vertexNormalIndexBuffer?b.vertexNormalIndexBuffer:b.indexBuffer,i=b.transformedFaceNormalZBuffer,l=this.colorBuffer,o=this.zBuffer,u=this.selectionBuffer,j=b.faceCount,B=b.internalId,n=b.material?b.material:this.defaultMaterial,M=n.getPalette(),J=n.transparency==0,x=n.transparency*255,K=255-x;var fixForMacSafari=1*null;if(n.transparency!=1){if(!g||g.length<b.vertexNormalBuffer.length/ |
---|
59 | 3){b.transformedVertexNormalZBuffer=new Array(b.vertexNormalBuffer.length/3);g=b.transformedVertexNormalZBuffer}if(!i||i.length<j){b.transformedFaceNormalZBuffer=new Array(j);i=b.transformedFaceNormalZBuffer}JSC3D.Math3D.transformVectorZs(this.rotMatrix,b.vertexNormalBuffer,g);JSC3D.Math3D.transformVectorZs(this.rotMatrix,b.faceNormalBuffer,i);b=b.isDoubleSided;n=new Array(3);for(var H=new Array(3),F=new Array(3),p=new Array(3),r=0,w=0;r<j;){var s=i[r++];if(b)s=s>0?s:-s;if(s<0){do;while(e[w++]!=-1) |
---|
60 | }else{var v,k,D,A,t;s=e[w]*3;D=h[w];w++;k=e[w]*3;A=h[w];w++;do{v=e[w];v=v*3;t=h[w];w++;n[0]=~~(f[s]+0.5);H[0]=~~(f[s+1]+0.5);F[0]=f[s+2];n[1]=~~(f[k]+0.5);H[1]=~~(f[k+1]+0.5);F[1]=f[k+2];n[2]=~~(f[v]+0.5);H[2]=~~(f[v+1]+0.5);F[2]=f[v+2];p[0]=g[D];p[1]=g[A];p[2]=g[t];if(b){if(p[0]<0)p[0]=-p[0];if(p[1]<0)p[1]=-p[1];if(p[2]<0)p[2]=-p[2]}k=H[0]<H[1]?0:1;k=H[k]<H[2]?k:2;var m=H[0]>H[1]?0:1;m=H[m]>H[2]?m:2;A=3-m-k;if(k!=m){var T=n[m],y=F[m],E=p[m]*255,C=H[m]-H[k];C=C!=0?C:1;var q=(n[m]-n[k])/C,la=(F[m]- |
---|
61 | F[k])/C;C=(p[m]-p[k])*255/C;var z=n[m],ra=F[m],ma=p[m]*255,Q=H[m]-H[A];Q=Q!=0?Q:1;var V=(n[m]-n[A])/Q,G=(F[m]-F[A])/Q;Q=(p[m]-p[A])*255/Q;var sa=n[A],da=F[A],ya=p[A]*255,ta=H[A]-H[k];ta=ta!=0?ta:1;var ea=(n[A]-n[k])/ta,Ea=(F[A]-F[k])/ta;ta=(p[A]-p[k])*255/ta;var Da=H[m]*c;for(m=H[m];m>H[k];m--){if(m>=0&&m<d){var S=~~T,Y=y,na=E,oa,ua,ja;if(m>H[A]){oa=~~z;ua=ra;ja=ma}else{oa=~~sa;ua=da;ja=ya}if(S>oa){var fa;fa=S;S=oa;oa=fa;fa=Y;Y=ua;ua=fa;fa=na;na=ja;ja=fa}ua=S!=oa?(ua-Y)/(oa-S):1;ja=S!=oa?(ja-na)/ |
---|
62 | (oa-S):1;if(S<0){Y-=S*ua;na-=S*ja;S=0}if(oa>=c)oa=c-1;fa=Da+S;if(J){S=S;Y=Y;for(na=na;S<=oa;S++,Y+=ua,na+=ja){if(Y>o[fa]){o[fa]=Y;l[fa]=M[na>0?~~na:0];u[fa]=B}fa++}}else{S=S;Y=Y;for(na=na;S<oa;S++,Y+=ua,na+=ja){if(Y>o[fa]){var pa=M[na>0?~~na:0],va=l[fa];l[fa]=(va&16711680)*x+(pa&16711680)*K>>8&16711680|(va&65280)*x+(pa&65280)*K>>8&65280|(va&255)*x+(pa&255)*K>>8&255;u[fa]=B}fa++}}}T-=q;y-=la;E-=C;if(m>H[A]){z-=V;ra-=G;ma-=Q}else{sa-=ea;da-=Ea;ya-=ta}Da-=c}}k=v;A=t}while(e[w]!=-1);w++}}}}; |
---|
63 | a.renderSolidTexture=function(b){var c=this.frameWidth,d=this.frameHeight,e=b.indexBuffer,f=b.transformedVertexBuffer,g=b.transformedFaceNormalZBuffer,h=this.colorBuffer,i=this.zBuffer,l=this.selectionBuffer,o=b.faceCount,u=b.internalId,j=b.texture,B=!j.hasTransparency,n=b.texCoordBuffer,M=b.texCoordIndexBuffer?b.texCoordIndexBuffer:b.indexBuffer,J=j.data,x=j.width,K=x-1,H=j.hasMipmap()?j.mipmaps:null,F=H?j.mipentries:null;var fixForMacSafari=1*null;if(!g||g.length<o){b.transformedFaceNormalZBuffer=new Array(o);g=b.transformedFaceNormalZBuffer}JSC3D.Math3D.transformVectorZs(this.rotMatrix, |
---|
64 | b.faceNormalBuffer,g);for(var p=new Array(3),r=new Array(3),w=new Array(3),s=new Array(3),v=new Array(3),k=0,D=0;k<o;){var A=g[k++];if(b.isDoubleSided)A=A>0?A:-A;if(A<0){do;while(e[D++]!=-1)}else{var t,m,T,y,E;A=e[D]*3;T=M[D]*2;D++;t=e[D]*3;y=M[D]*2;D++;if(H){m=e[D]*3;E=M[D]*2;x=j.width;p[0]=f[A];r[0]=f[A+1];p[1]=f[t];r[1]=f[t+1];p[2]=f[m];r[2]=f[m+1];s[0]=n[T]*x;v[0]=n[T+1]*x;s[1]=n[y]*x;v[1]=n[y+1]*x;s[2]=n[E]*x;v[2]=n[E+1]*x;J=(p[1]-p[0])*(r[2]-r[0])-(r[1]-r[0])*(p[2]-p[0]);if(J<0)J=-J;J+=1;K= |
---|
65 | (s[1]-s[0])*(v[2]-v[0])-(v[1]-v[0])*(s[2]-s[0]);if(K<0)K=-K;J=K/J;K=0;if(J<F[1])K=0;else if(J>=F[F.length-1]){K=F.length-1;x=1}else for(;J>=F[K+1];){K++;x/=2}J=H[K];K=x-1}do{m=e[D]*3;E=M[D]*2;D++;p[0]=~~(f[A]+0.5);r[0]=~~(f[A+1]+0.5);w[0]=f[A+2];p[1]=~~(f[t]+0.5);r[1]=~~(f[t+1]+0.5);w[1]=f[t+2];p[2]=~~(f[m]+0.5);r[2]=~~(f[m+1]+0.5);w[2]=f[m+2];s[0]=n[T]*x;v[0]=n[T+1]*x;s[1]=n[y]*x;v[1]=n[y+1]*x;s[2]=n[E]*x;v[2]=n[E+1]*x;t=r[0]<r[1]?0:1;t=r[t]<r[2]?t:2;var C=r[0]>r[1]?0:1;C=r[C]>r[2]?C:2;y=3-C-t;if(t!= |
---|
66 | C){var q=p[C],la=w[C],z=s[C],ra=v[C],ma=r[C]-r[t];ma=ma!=0?ma:1;var Q=(p[C]-p[t])/ma,V=(w[C]-w[t])/ma,G=(s[C]-s[t])/ma;ma=(v[C]-v[t])/ma;var sa=p[C],da=w[C],ya=s[C],ta=v[C],ea=r[C]-r[y];ea=ea!=0?ea:1;var Ea=(p[C]-p[y])/ea,Da=(w[C]-w[y])/ea,S=(s[C]-s[y])/ea;ea=(v[C]-v[y])/ea;var Y=p[y],na=w[y],oa=s[y],ua=v[y],ja=r[y]-r[t];ja=ja!=0?ja:1;var fa=(p[y]-p[t])/ja,pa=(w[y]-w[t])/ja,va=(s[y]-s[t])/ja;ja=(v[y]-v[t])/ja;var Fa=r[C]*c;for(C=r[C];C>r[t];C--){if(C>=0&&C<d){var aa=~~q,ga=la,wa=z,O=ra,U,ka,ha,I; |
---|
67 | if(C>r[y]){U=~~sa;ka=da;ha=ya;I=ta}else{U=~~Y;ka=na;ha=oa;I=ua}if(aa>U){var L;L=aa;aa=U;U=L;L=ga;ga=ka;ka=L;L=wa;wa=ha;ha=L;L=O;O=I;I=L}ka=aa!=U?(ka-ga)/(U-aa):1;ha=aa!=U?(ha-wa)/(U-aa):1;I=aa!=U?(I-O)/(U-aa):1;if(aa<0){ga-=aa*ka;wa-=aa*ha;O-=aa*I;aa=0}if(U>=c)U=c-1;L=Fa+aa;if(B){aa=aa;ga=ga;wa=wa;for(O=O;aa<=U;aa++,ga+=ka,wa+=ha,O+=I){if(ga>i[L]){i[L]=ga;h[L]=J[(O&K)*x+(wa&K)];l[L]=u}L++}}else{aa=aa;ga=ga;wa=wa;for(O=O;aa<U;aa++,ga+=ka,wa+=ha,O+=I){if(ga>i[L]){var Z=J[(O&K)*x+(wa&K)],ca=h[L],P=Z>> |
---|
68 | 24&255,X=255-P;h[L]=(ca&16711680)*X+(Z&16711680)*P>>8&16711680|(ca&65280)*X+(Z&65280)*P>>8&65280|(ca&255)*X+(Z&255)*P>>8&255;l[L]=u}L++}}}q-=Q;la-=V;z-=G;ra-=ma;if(C>r[y]){sa-=Ea;da-=Da;ya-=S;ta-=ea}else{Y-=fa;na-=pa;oa-=va;ua-=ja}Fa-=c}}t=m;y=E}while(e[D]!=-1);D++}}}; |
---|
69 | a.renderTextureFlat=function(b){var c=this.frameWidth,d=this.frameHeight,e=b.indexBuffer,f=b.transformedVertexBuffer,g=b.transformedFaceNormalZBuffer,h=this.colorBuffer,i=this.zBuffer,l=this.selectionBuffer,o=b.faceCount,u=b.internalId,j=b.material?b.material:this.defaultMaterial,B=j.getPalette(),n=b.texture,M=j.transparency==0&&!n.hasTransparency,J=~~((1-j.transparency)*255),x=b.texCoordBuffer,K=b.texCoordIndexBuffer?b.texCoordIndexBuffer:b.indexBuffer,H=n.data,F=n.width,p=F-1,r=n.hasMipmap()?n.mipmaps: |
---|
70 | null,w=r?n.mipentries:null;var fixForMacSafari=1*null;if(j.transparency!=1){if(!g||g.length<o){b.transformedFaceNormalZBuffer=new Array(o);g=b.transformedFaceNormalZBuffer}JSC3D.Math3D.transformVectorZs(this.rotMatrix,b.faceNormalBuffer,g);j=new Array(3);for(var s=new Array(3),v=new Array(3),k=new Array(3),D=new Array(3),A=0,t=0;A<o;){var m=g[A++];if(b.isDoubleSided)m=m>0?m:-m;if(m<0){do;while(e[t++]!=-1)}else{m=B[~~(m*255)];var T,y,E,C,q,la;T=e[t]*3;C=K[t]*2;t++;y=e[t]*3;q=K[t]*2;t++;if(r){E=e[t]*3;la=K[t]*2;F=n.width;j[0]= |
---|
71 | f[T];s[0]=f[T+1];j[1]=f[y];s[1]=f[y+1];j[2]=f[E];s[2]=f[E+1];k[0]=x[C]*F;D[0]=x[C+1]*F;k[1]=x[q]*F;D[1]=x[q+1]*F;k[2]=x[la]*F;D[2]=x[la+1]*F;H=(j[1]-j[0])*(s[2]-s[0])-(s[1]-s[0])*(j[2]-j[0]);if(H<0)H=-H;H+=1;p=(k[1]-k[0])*(D[2]-D[0])-(D[1]-D[0])*(k[2]-k[0]);if(p<0)p=-p;H=p/H;p=0;if(H<w[1])p=0;else if(H>=w[w.length-1]){p=w.length-1;F=1}else for(;H>=w[p+1];){p++;F/=2}H=r[p];p=F-1}do{E=e[t]*3;la=K[t]*2;t++;j[0]=~~(f[T]+0.5);s[0]=~~(f[T+1]+0.5);v[0]=f[T+2];j[1]=~~(f[y]+0.5);s[1]=~~(f[y+1]+0.5);v[1]=f[y+ |
---|
72 | 2];j[2]=~~(f[E]+0.5);s[2]=~~(f[E+1]+0.5);v[2]=f[E+2];k[0]=x[C]*F;D[0]=x[C+1]*F;k[1]=x[q]*F;D[1]=x[q+1]*F;k[2]=x[la]*F;D[2]=x[la+1]*F;y=s[0]<s[1]?0:1;y=s[y]<s[2]?y:2;var z=s[0]>s[1]?0:1;z=s[z]>s[2]?z:2;q=3-z-y;if(y!=z){var ra=j[z],ma=v[z],Q=k[z],V=D[z],G=s[z]-s[y];G=G!=0?G:1;var sa=(j[z]-j[y])/G,da=(v[z]-v[y])/G,ya=(k[z]-k[y])/G;G=(D[z]-D[y])/G;var ta=j[z],ea=v[z],Ea=k[z],Da=D[z],S=s[z]-s[q];S=S!=0?S:1;var Y=(j[z]-j[q])/S,na=(v[z]-v[q])/S,oa=(k[z]-k[q])/S;S=(D[z]-D[q])/S;var ua=j[q],ja=v[q],fa=k[q], |
---|
73 | pa=D[q],va=s[q]-s[y];va=va!=0?va:1;var Fa=(j[q]-j[y])/va,aa=(v[q]-v[y])/va,ga=(k[q]-k[y])/va;va=(D[q]-D[y])/va;var wa=s[z]*c;for(z=s[z];z>s[y];z--){if(z>=0&&z<d){var O=~~ra,U=ma,ka=Q,ha=V,I,L,Z,ca;if(z>s[q]){I=~~ta;L=ea;Z=Ea;ca=Da}else{I=~~ua;L=ja;Z=fa;ca=pa}if(O>I){var P;P=O;O=I;I=P;P=U;U=L;L=P;P=ka;ka=Z;Z=P;P=ha;ha=ca;ca=P}L=O!=I?(L-U)/(I-O):1;Z=O!=I?(Z-ka)/(I-O):1;ca=O!=I?(ca-ha)/(I-O):1;if(O<0){U-=O*L;ka-=O*Z;ha-=O*ca;O=0}if(I>=c)I=c-1;P=wa+O;if(M){O=O;U=U;ka=ka;for(ha=ha;O<=I;O++,U+=L,ka+=Z, |
---|
74 | ha+=ca){if(U>i[P]){i[P]=U;var X=H[(ha&p)*F+(ka&p)],N=((m&16711680)>>16)*((X&16711680)>>8),ba=((m&65280)>>8)*((X&65280)>>8),W=(m&255)*(X&255)>>8;h[P]=N&16711680|ba&65280|W&255;l[P]=u}P++}}else{O=O;U=U;ka=ka;for(ha=ha;O<I;O++,U+=L,ka+=Z,ha+=ca){if(U>i[P]){W=H[(ha&p)*F+(ka&p)];X=h[P];var ia=(W>>24&255)*(J&255)>>8;N=((m&16711680)>>16)*((W&16711680)>>8);ba=((m&65280)>>8)*((W&65280)>>8);W=(m&255)*(W&255)>>8;if(ia>250)i[P]=U;else{var R=255-ia;N=N*ia+(X&16711680)*R>>8;ba=ba*ia+(X&65280)*R>>8;W=W*ia+(X&255)* |
---|
75 | R>>8}h[P]=N&16711680|ba&65280|W&255;l[P]=u}P++}}}ra-=sa;ma-=da;Q-=ya;V-=G;if(z>s[q]){ta-=Y;ea-=na;Ea-=oa;Da-=S}else{ua-=Fa;ja-=aa;fa-=ga;pa-=va}wa-=c}}y=E;q=la}while(e[t]!=-1);t++}}}}; |
---|
76 | a.renderTextureSmooth=function(b){var c=this.frameWidth,d=this.frameHeight,e=b.indexBuffer,f=b.transformedVertexBuffer,g=b.transformedVertexNormalZBuffer,h=b.vertexNormalIndexBuffer?b.vertexNormalIndexBuffer:b.indexBuffer,i=b.transformedFaceNormalZBuffer,l=this.colorBuffer,o=this.zBuffer,u=this.selectionBuffer,j=b.faceCount,B=b.internalId,n=b.material?b.material:this.defaultMaterial,M=n.getPalette(),J=b.texture,x=n.transparency==0&&!J.hasTransparency,K=~~((1-n.transparency)*255),H=b.texCoordBuffer, |
---|
77 | F=b.texCoordIndexBuffer?b.texCoordIndexBuffer:b.indexBuffer,p=J.data,r=J.width,w=r-1,s=J.hasMipmap()?J.mipmaps:null,v=s?J.mipentries:null;var fixForMacSafari=1*null;if(n.transparency!=1){if(!g||g.length<b.vertexNormalBuffer.length/3){b.transformedVertexNormalZBuffer=new Array(b.vertexNormalBuffer.length/3);g=b.transformedVertexNormalZBuffer}if(!i||i.length<j){b.transformedFaceNormalZBuffer=new Array(j);i=b.transformedFaceNormalZBuffer}JSC3D.Math3D.transformVectorZs(this.rotMatrix,b.vertexNormalBuffer,g);JSC3D.Math3D.transformVectorZs(this.rotMatrix, |
---|
78 | b.faceNormalBuffer,i);b=b.isDoubleSided;n=new Array(3);for(var k=new Array(3),D=new Array(3),A=new Array(3),t=new Array(3),m=new Array(3),T=0,y=0;T<j;){var E=i[T++];if(b)E=E>0?E:-E;if(E<0){do;while(e[y++]!=-1)}else{var C,q,la,z,ra,ma,Q,V;E=e[y]*3;la=F[y]*2;ma=h[y];y++;q=e[y]*3;z=F[y]*2;Q=h[y];y++;if(s){C=e[y]*3;ra=F[y]*2;r=J.width;n[0]=f[E];k[0]=f[E+1];n[1]=f[q];k[1]=f[q+1];n[2]=f[C];k[2]=f[C+1];t[0]=H[la]*r;m[0]=H[la+1]*r;t[1]=H[z]*r;m[1]=H[z+1]*r;t[2]=H[ra]*r;m[2]=H[ra+1]*r;p=(n[1]-n[0])*(k[2]- |
---|
79 | k[0])-(k[1]-k[0])*(n[2]-n[0]);if(p<0)p=-p;p+=1;w=(t[1]-t[0])*(m[2]-m[0])-(m[1]-m[0])*(t[2]-t[0]);if(w<0)w=-w;p=w/p;w=0;if(p<v[1])w=0;else if(p>=v[v.length-1]){w=v.length-1;r=1}else for(;p>=v[w+1];){w++;r/=2}p=s[w];w=r-1}do{C=e[y];C=C*3;ra=F[y]*2;V=h[y];y++;n[0]=~~(f[E]+0.5);k[0]=~~(f[E+1]+0.5);D[0]=f[E+2];n[1]=~~(f[q]+0.5);k[1]=~~(f[q+1]+0.5);D[1]=f[q+2];n[2]=~~(f[C]+0.5);k[2]=~~(f[C+1]+0.5);D[2]=f[C+2];t[0]=H[la]*r;m[0]=H[la+1]*r;t[1]=H[z]*r;m[1]=H[z+1]*r;t[2]=H[ra]*r;m[2]=H[ra+1]*r;A[0]=g[ma];A[1]= |
---|
80 | g[Q];A[2]=g[V];if(b){if(A[0]<0)A[0]=-A[0];if(A[1]<0)A[1]=-A[1];if(A[2]<0)A[2]=-A[2]}q=k[0]<k[1]?0:1;q=k[q]<k[2]?q:2;var G=k[0]>k[1]?0:1;G=k[G]>k[2]?G:2;z=3-G-q;if(q!=G){Q=n[G];var sa=D[G],da=t[G],ya=m[G],ta=A[G]*255,ea=k[G]-k[q];ea=ea!=0?ea:1;var Ea=(n[G]-n[q])/ea,Da=(D[G]-D[q])/ea,S=(t[G]-t[q])/ea,Y=(m[G]-m[q])/ea;ea=(A[G]-A[q])*255/ea;var na=n[G],oa=D[G],ua=t[G],ja=m[G],fa=A[G]*255,pa=k[G]-k[z];pa=pa!=0?pa:1;var va=(n[G]-n[z])/pa,Fa=(D[G]-D[z])/pa,aa=(t[G]-t[z])/pa,ga=(m[G]-m[z])/pa;pa=(A[G]-A[z])* |
---|
81 | 255/pa;var wa=n[z],O=D[z],U=t[z],ka=m[z],ha=A[z]*255,I=k[z]-k[q];I=I!=0?I:1;var L=(n[z]-n[q])/I,Z=(D[z]-D[q])/I,ca=(t[z]-t[q])/I,P=(m[z]-m[q])/I;I=(A[z]-A[q])*255/I;var X=k[G]*c;for(G=k[G];G>k[q];G--){if(G>=0&&G<d){var N=~~Q,ba=sa,W=da,ia=ya,R=ta,$,xa,za,Aa,Ba;if(G>k[z]){$=~~na;xa=oa;za=ua;Aa=ja;Ba=fa}else{$=~~wa;xa=O;za=U;Aa=ka;Ba=ha}if(N>$){var qa;qa=N;N=$;$=qa;qa=ba;ba=xa;xa=qa;qa=W;W=za;za=qa;qa=ia;ia=Aa;Aa=qa;qa=R;R=Ba;Ba=qa}xa=N!=$?(xa-ba)/($-N):1;za=N!=$?(za-W)/($-N):1;Aa=N!=$?(Aa-ia)/($-N): |
---|
82 | 1;Ba=N!=$?(Ba-R)/($-N):0;if(N<0){ba-=N*xa;W-=N*za;ia-=N*Aa;R-=N*Ba;N=0}if($>=c)$=c-1;qa=X+N;if(x){N=N;ba=ba;R=R;W=W;for(ia=ia;N<=$;N++,ba+=xa,R+=Ba,W+=za,ia+=Aa){if(ba>o[qa]){o[qa]=ba;var Ca=M[R>0?~~R:0],Ha=p[(ia&w)*r+(W&w)],Ia=((Ca&16711680)>>16)*((Ha&16711680)>>8),Ja=((Ca&65280)>>8)*((Ha&65280)>>8);Ca=(Ca&255)*(Ha&255)>>8;l[qa]=Ia&16711680|Ja&65280|Ca&255;u[qa]=B}qa++}}else{N=N;ba=ba;R=R;W=W;for(ia=ia;N<$;N++,ba+=xa,R+=Ba,W+=za,ia+=Aa){if(ba>o[qa]){Ca=M[R>0?~~R:0];var Ga=p[(ia&w)*r+(W&w)];Ha=l[qa]; |
---|
83 | var Ka=(Ga>>24&255)*(K&255)>>8;Ia=((Ca&16711680)>>16)*((Ga&16711680)>>8);Ja=((Ca&65280)>>8)*((Ga&65280)>>8);Ca=(Ca&255)*(Ga&255)>>8;if(Ka>250)o[qa]=ba;else{Ga=255-Ka;Ia=Ia*Ka+(Ha&16711680)*Ga>>8;Ja=Ja*Ka+(Ha&65280)*Ga>>8;Ca=Ca*Ka+(Ha&255)*Ga>>8}l[qa]=Ia&16711680|Ja&65280|Ca&255;u[qa]=B}qa++}}}Q-=Ea;sa-=Da;da-=S;ya-=Y;ta-=ea;if(G>k[z]){na-=va;oa-=Fa;ua-=aa;ja-=ga;fa-=pa}else{wa-=L;O-=Z;U-=ca;ka-=P;ha-=I}X-=c}}q=C;z=ra;Q=V}while(e[y]!=-1);y++}}}}; |
---|
84 | a.renderSolidSphereMapped=function(b){var c=this.frameWidth,d=this.frameHeight,e=b.indexBuffer,f=b.transformedVertexBuffer,g=b.transformedVertexNormalBuffer,h=b.vertexNormalIndexBuffer?b.vertexNormalIndexBuffer:b.indexBuffer,i=b.transformedFaceNormalZBuffer,l=this.colorBuffer,o=this.zBuffer,u=this.selectionBuffer,j=b.faceCount,B=b.internalId,n=b.material?b.material:this.defaultMaterial,M=n.getPalette(),J=this.sphereMap,x=J.data;J=J.width;var K=J-1,H=n.transparency==0,F=n.transparency*255,p=255-F;var fixForMacSafari=1*null; |
---|
85 | if(n.transparency!=1){if(!g||g.length<b.vertexNormalBuffer.length){b.transformedVertexNormalBuffer=new Array(b.vertexNormalBuffer.length);g=b.transformedVertexNormalBuffer}if(!i||i.length<j){b.transformedFaceNormalZBuffer=new Array(j);i=b.transformedFaceNormalZBuffer}JSC3D.Math3D.transformVectors(this.rotMatrix,b.vertexNormalBuffer,g);JSC3D.Math3D.transformVectorZs(this.rotMatrix,b.faceNormalBuffer,i);b=b.isDoubleSided;n=new Array(3);for(var r=new Array(3),w=new Array(3),s=new Array(3),v=new Array(3), |
---|
86 | k=new Array(3),D=0,A=0;D<j;){var t=i[D++];if(b)t=t>0?t:-t;if(t<0){do;while(e[A++]!=-1)}else{var m,T,y,E,C;t=e[A]*3;y=h[A]*3;A++;m=e[A]*3;E=h[A]*3;A++;do{T=e[A]*3;C=h[A]*3;A++;n[0]=~~(f[t]+0.5);r[0]=~~(f[t+1]+0.5);w[0]=f[t+2];n[1]=~~(f[m]+0.5);r[1]=~~(f[m+1]+0.5);w[1]=f[m+2];n[2]=~~(f[T]+0.5);r[2]=~~(f[T+1]+0.5);w[2]=f[T+2];s[0]=g[y];v[0]=g[y+1];k[0]=g[y+2];s[1]=g[E];v[1]=g[E+1];k[1]=g[E+2];s[2]=g[C];v[2]=g[C+1];k[2]=g[C+2];if(b){if(k[0]<0)k[0]=-k[0];if(k[1]<0)k[1]=-k[1];if(k[2]<0)k[2]=-k[2]}m=r[0]< |
---|
87 | r[1]?0:1;m=r[m]<r[2]?m:2;var q=r[0]>r[1]?0:1;q=r[q]>r[2]?q:2;E=3-q-m;if(m!=q){var la=n[q],z=w[q],ra=k[q]*255,ma=(s[q]/2+0.5)*J&K,Q=(0.5-v[q]/2)*J&K,V=r[q]-r[m];V=V!=0?V:1;var G=(n[q]-n[m])/V,sa=(w[q]-w[m])/V,da=(k[q]-k[m])*255/V,ya=(s[q]-s[m])/2*J/V;V=(v[m]-v[q])/2*J/V;var ta=n[q],ea=w[q],Ea=k[q]*255,Da=(s[q]/2+0.5)*J&K,S=(0.5-v[q]/2)*J&K,Y=r[q]-r[E];Y=Y!=0?Y:1;var na=(n[q]-n[E])/Y,oa=(w[q]-w[E])/Y,ua=(k[q]-k[E])*255/Y,ja=(s[q]-s[E])/2*J/Y;Y=(v[E]-v[q])/2*J/Y;var fa=n[E],pa=w[E],va=k[E]*255,Fa=(s[E]/ |
---|
88 | 2+0.5)*J&K,aa=(0.5-v[E]/2)*J&K,ga=r[E]-r[m];ga=ga!=0?ga:1;var wa=(n[E]-n[m])/ga,O=(w[E]-w[m])/ga,U=(k[E]-k[m])*255/ga,ka=(s[E]-s[m])/2*J/ga;ga=(v[m]-v[E])/2*J/ga;var ha=r[q]*c;for(q=r[q];q>r[m];q--){if(q>=0&&q<d){var I=~~la,L=z,Z=ra,ca=ma,P=Q,X,N,ba,W,ia;if(q>r[E]){X=~~ta;N=ea;ba=Ea;W=Da;ia=S}else{X=~~fa;N=pa;ba=va;W=Fa;ia=aa}if(I>X){var R;R=I;I=X;X=R;R=L;L=N;N=R;R=Z;Z=ba;ba=R;R=ca;ca=W;W=R;R=P;P=ia;ia=R}N=I!=X?(N-L)/(X-I):1;ba=I!=X?(ba-Z)/(X-I):1;W=I!=X?(W-ca)/(X-I):1;ia=I!=X?(ia-P)/(X-I):1;if(I< |
---|
89 | 0){L-=I*N;Z-=I*ba;ca-=ca*W;P-=P*ia;I=0}if(X>=c)X=c-1;R=ha+I;if(H){I=I;L=L;Z=Z;ca=ca;for(P=P;I<=X;I++,L+=N,Z+=ba,ca+=W,P+=ia){if(L>o[R]){o[R]=L;var $=M[Z>0?~~Z:0],xa=x[(P&K)*J+(ca&K)],za=(($&16711680)>>16)*((xa&16711680)>>8),Aa=(($&65280)>>8)*((xa&65280)>>8);$=($&255)*(xa&255)>>8;l[R]=za&16711680|Aa&65280|$&255;u[R]=B}R++}}else{I=I;L=L;Z=Z;ca=ca;for(P=P;I<X;I++,L+=N,Z+=ba,ca+=W,P+=ia){if(L>o[R]){$=M[Z>0?~~Z:0];var Ba=x[(P&K)*J+(ca&K)];xa=l[R];za=(($&16711680)>>16)*((Ba&16711680)>>8);Aa=(($&65280)>> |
---|
90 | 8)*((Ba&65280)>>8);$=($&255)*(Ba&255)>>8;za=za*p+(xa&16711680)*F>>8;Aa=Aa*p+(xa&65280)*F>>8;$=$*p+(xa&255)*F>>8;l[R]=za&16711680|Aa&65280|$&255;u[R]=B}R++}}}la-=G;z-=sa;ra-=da;ma-=ya;Q-=V;if(q>r[E]){ta-=na;ea-=oa;Ea-=ua;Da-=ja;S-=Y}else{fa-=wa;pa-=O;va-=U;Fa-=ka;aa-=ga}ha-=c}}m=T;E=C}while(e[A]!=-1);A++}}}};a.params=null;a.canvas=null;a.ctx=null;a.canvasData=null;a.bkgColorBuffer=null;a.colorBuffer=null;a.zBuffer=null;a.selectionBuffer=null;a.frameWidth=0;a.frameHeight=0;a.scene=null; |
---|
91 | a.defaultMaterial=null;a.sphereMap=null;a.isLoaded=false;a.isFailed=false;a.errorMsg="";a.needUpdate=false;a.needRepaint=false;a.initRotX=0;a.initRotY=0;a.initRotZ=0;a.zoomFactor=1;a.panning=[0,0];a.rotMatrix=null;a.transformMatrix=null;a.sceneUrl="";a.modelColor=13280792;a.bkgColor1=16777215;a.bkgColor2=16777088;a.renderMode="flat";a.definition="standard";a.isMipMappingOn=false;a.creaseAngle=-180;a.sphereMapUrl="";a.buttonStates=null;a.keyStates=null;a.mouseX=0;a.mouseY=0;a.onmousedown=null; |
---|
92 | a.onmouseup=null;a.onmousemove=null;a.onmousewheel=null;a.beforeupdate=null;a.afterupdate=null;a.mouseUsage="default";a.isDefaultInputHandlerEnabled=false;JSC3D.PickInfo=function(){this.canvasY=this.canvasX=0;this.depth=-Infinity;this.mesh=null};JSC3D.Scene=function(b){this.name=b||"";this.aabb=null;this.children=[];this.maxChildId=1};a=JSC3D.Scene.prototype; |
---|
93 | a.init=function(){if(!this.isEmpty()){for(var b=0;b<this.children.length;b++)this.children[b].init();if(!this.aabb){this.aabb=new JSC3D.AABB;this.calcAABB()}}};a.isEmpty=function(){return this.children.length==0};a.addChild=function(b){b.internalId=this.maxChildId++;this.children.push(b)};a.removeChild=function(b){for(var c=0;c<this.children.length;c++)if(this.children[c]==b){this.children.splice(c,1);break}};a.getChildren=function(){return this.children.slice(0)}; |
---|
94 | a.forEachChild=function(b){if(typeof b=="function")for(var c=0;c<this.children.length;c++)if(b.call(null,this.children[c]))break}; |
---|
95 | a.calcAABB=function(){this.aabb.minX=this.aabb.minY=this.aabb.minZ=Number.MAX_VALUE;this.aabb.maxX=this.aabb.maxY=this.aabb.maxZ=-Number.MAX_VALUE;for(var b=0;b<this.children.length;b++){var c=this.children[b];if(!c.isTrivial()){var d=c.aabb.minX,e=c.aabb.minY,f=c.aabb.minZ,g=c.aabb.maxX,h=c.aabb.maxY;c=c.aabb.maxZ;if(this.aabb.minX>d)this.aabb.minX=d;if(this.aabb.minY>e)this.aabb.minY=e;if(this.aabb.minZ>f)this.aabb.minZ=f;if(this.aabb.maxX<g)this.aabb.maxX=g;if(this.aabb.maxY<h)this.aabb.maxY=h; |
---|
96 | if(this.aabb.maxZ<c)this.aabb.maxZ=c}}};a.name="";a.aabb=null;a.children=null;a.maxChildId=1; |
---|
97 | JSC3D.Mesh=function(b,c,d,e,f,g,h,i,l,o,u){this.name=b||"";this.metadata="";this.visible=c!=undefined?c:true;this.aabb=null;this.vertexBuffer=i||null;this.indexBuffer=l||null;this.faceNormalBuffer=this.vertexNormalIndexBuffer=this.vertexNormalBuffer=null;this.material=d||null;this.texture=e||null;this.faceCount=0;this.creaseAngle=f>=0?f:-180;this.isDoubleSided=g||false;this.isEnvironmentCast=h||false;this.internalId=0;this.texCoordBuffer=o||null;this.texCoordIndexBuffer=u||null;this.transformedVertexNormalBuffer= |
---|
98 | this.transformedFaceNormalZBuffer=this.transformedVertexNormalZBuffer=this.transformedVertexBuffer=null};a=JSC3D.Mesh.prototype; |
---|
99 | a.init=function(){if(!this.isTrivial()){if(this.faceCount==0){this.calcFaceCount();if(this.faceCount==0)return}if(!this.aabb){this.aabb=new JSC3D.AABB;this.calcAABB()}if(!this.faceNormalBuffer){this.faceNormalBuffer=new Array(this.faceCount*3);this.calcFaceNormals()}if(!this.vertexNormalBuffer)if(this.creaseAngle>=0)this.calcCreasedVertexNormals();else{this.vertexNormalBuffer=new Array(this.vertexBuffer.length);this.calcVertexNormals()}this.normalizeFaceNormals();this.transformedVertexBuffer=new Array(this.vertexBuffer.length)}}; |
---|
100 | a.isTrivial=function(){return!this.vertexBuffer||this.vertexBuffer.length<3||!this.indexBuffer||this.indexBuffer.length<3};a.setMaterial=function(b){this.material=b};a.setTexture=function(b){this.texture=b};a.hasTexture=function(){return this.texture!=null&&this.texture.hasData()&&this.texCoordBuffer!=null&&this.texCoordBuffer.length>=2&&(this.texCoordIndexBuffer==null||this.texCoordIndexBuffer.length>=3&&this.texCoordIndexBuffer.length>=this.indexBuffer.length)}; |
---|
101 | a.calcFaceCount=function(){this.faceCount=0;var b=this.indexBuffer;b[b.length-1]!=-1&&b.push(-1);for(var c=0;c<b.length;c++)b[c]==-1&&this.faceCount++}; |
---|
102 | a.calcAABB=function(){for(var b=minY=minZ=Number.MAX_VALUE,c=maxY=maxZ=-Number.MAX_VALUE,d=this.vertexBuffer,e=0;e<d.length;e+=3){var f=d[e],g=d[e+1],h=d[e+2];if(f<b)b=f;if(f>c)c=f;if(g<minY)minY=g;if(g>maxY)maxY=g;if(h<minZ)minZ=h;if(h>maxZ)maxZ=h}this.aabb.minX=b;this.aabb.minY=minY;this.aabb.minZ=minZ;this.aabb.maxX=c;this.aabb.maxY=maxY;this.aabb.maxZ=maxZ}; |
---|
103 | a.calcFaceNormals=function(){for(var b=this.vertexBuffer,c=this.indexBuffer,d=this.faceNormalBuffer,e=0,f=0;e<c.length;){var g=c[e++]*3,h=b[g],i=b[g+1],l=b[g+2];g=c[e++]*3;var o=b[g],u=b[g+1],j=b[g+2];g=c[e++]*3;o=o-h;u=u-i;j=j-l;h=b[g]-h;i=b[g+1]-i;l=b[g+2]-l;g=u*l-j*i;l=j*h-o*l;o=o*i-u*h;d[f++]=g;d[f++]=l;d[f++]=o;do;while(c[e++]!=-1)}};a.normalizeFaceNormals=function(){JSC3D.Math3D.normalizeVectors(this.faceNormalBuffer,this.faceNormalBuffer)}; |
---|
104 | a.calcVertexNormals=function(){if(!this.faceNormalBuffer){this.faceNormalBuffer=new Array(this.faceCount*3);this.calcFaceNormals()}for(var b=this.indexBuffer,c=this.faceNormalBuffer,d=this.vertexNormalBuffer,e=0;e<d.length;e++)d[e]=0;this.vertexNormalIndexBuffer=null;for(var f=e=0,g=0;e<b.length;){g=b[e++];if(g==-1)f+=3;else{g=g*3;d[g]+=c[f];d[g+1]+=c[f+1];d[g+2]+=c[f+2]}}JSC3D.Math3D.normalizeVectors(d,d)}; |
---|
105 | a.calcCreasedVertexNormals=function(){if(!this.faceNormalBuffer){this.faceNormalBuffer=new Array(this.faceCount*3);this.calcFaceNormals()}for(var b=this.indexBuffer,c=new Array(this.vertexBuffer.length/3),d=0,e=0,f=0,g=0;e<b.length;e++){g=b[e];if(g>=0){d+=3;var h=c[g];if(h)h.push(f);else c[g]=[f]}else f++}f=this.faceNormalBuffer;var i=new Array(f.length);JSC3D.Math3D.normalizeVectors(f,i);if(!this.vertexNormalBuffer||this.vertexNormalBuffer.length<d)this.vertexNormalBuffer=new Array(d);d=this.vertexNormalBuffer; |
---|
106 | for(e=0;e<d.length;e++)d[e]=0;for(var l=this.vertexNormalIndexBuffer=[],o=Math.cos(this.creaseAngle*Math.PI/180),u=e=0,j=0;e<b.length;e++){g=b[e];if(g>=0){var B=u*3;h=j*3;d[B]+=f[h];d[B+1]+=f[h+1];d[B+2]+=f[h+2];var n=i[h],M=i[h+1],J=i[h+2];h=c[g];for(g=0;g<h.length;g++){var x=h[g];if(j!=x){x=x*3;if(n*i[x]+M*i[x+1]+J*i[x+2]>o){d[B]+=f[x];d[B+1]+=f[x+1];d[B+2]+=f[x+2]}}}l.push(u++)}else{j++;l.push(-1)}}JSC3D.Math3D.normalizeVectors(d,d)};a.checkValid=function(){};a.name="";a.metadata=""; |
---|
107 | a.visible=false;a.aabb=null;a.vertexBuffer=null;a.indexBuffer=null;a.vertexNormalBuffer=null;a.vertexNormalIndexBuffer=null;a.faceNormalBuffer=null;a.texCoordBuffer=null;a.texCoordIndexBuffer=null;a.material=null;a.texture=null;a.faceCount=0;a.creaseAngle=-180;a.isDoubleSided=false;a.isEnvironmentCast=false;a.internalId=0;a.transformedVertexBuffer=null;a.transformedVertexNormalZBuffer=null;a.transformedFaceNormalZBuffer=null;a.transformedVertexNormalBuffer=null; |
---|
108 | JSC3D.Material=function(b,c,d,e,f){this.name=b||"";this.ambientColor=c||0;this.diffuseColor=d||8355711;this.transparency=e||0;this.simulateSpecular=f||false;this.palette=null};a=JSC3D.Material.prototype;a.getPalette=function(){if(!this.palette){this.palette=new Array(256);this.generatePalette()}return this.palette}; |
---|
109 | a.generatePalette=function(){var b=(this.ambientColor&16711680)>>16,c=(this.ambientColor&65280)>>8,d=this.ambientColor&255,e=(this.diffuseColor&16711680)>>16,f=(this.diffuseColor&65280)>>8,g=this.diffuseColor&255;if(this.simulateSpecular){for(var h=0;h<204;){var i=b+h*e/204,l=c+h*f/204,o=d+h*g/204;if(i>255)i=255;if(l>255)l=255;if(o>255)o=255;this.palette[h++]=i<<16|l<<8|o}for(;h<256;){i=b+e+(h-204)*(255-e)/82;l=c+f+(h-204)*(255-f)/82;o=d+g+(h-204)*(255-g)/82;if(i>255)i=255;if(l>255)l=255;if(o>255)o= |
---|
110 | 255;this.palette[h++]=i<<16|l<<8|o}}else for(h=0;h<256;){i=b+h*e/256;l=c+h*f/256;o=d+h*g/256;if(i>255)i=255;if(l>255)l=255;if(o>255)o=255;this.palette[h++]=i<<16|l<<8|o}};a.name="";a.ambientColor=0;a.diffuseColor=8355711;a.transparency=0;a.simulateSpecular=false;a.palette=null;JSC3D.Texture=function(b,c){this.name=b||"";this.height=this.width=0;this.mipentries=this.mipmaps=this.data=null;this.hasTransparency=false;this.srcUrl="";this.onready=c&&typeof c=="function"?c:null};a=JSC3D.Texture.prototype; |
---|
111 | a.createFromUrl=function(b,c){var d=this,e=new Image;e.onload=function(){d.data=null;d.mipmaps=null;d.mipentries=null;d.width=0;d.height=0;d.hasTransparency=false;d.srcUrl="";d.createFromImage(this,c);JSC3D.console&&JSC3D.console.logInfo('Finished loading texture image file "'+this.src+'".')};e.onerror=function(){d.data=null;d.mipmaps=null;d.mipentries=null;d.width=0;d.height=0;d.hasTransparency=false;d.srcUrl="";JSC3D.console&&JSC3D.console.logWarning('Failed to load texture image file "'+this.src+ |
---|
112 | '". This texture will be discarded.')};e.src=b}; |
---|
113 | a.createFromImage=function(b,c){if(!(b.width<=0||b.height<=0)){var d=false,e=JSC3D.Texture.cv;if(!e)try{e=document.createElement("canvas");JSC3D.Texture.cv=e;d=true}catch(f){return}var g=b.width>b.height?b.width:b.height;g=g<=32?32:g<=64?64:g<=128?128:g<=256?256:512;if(e.width!=g||e.height!=g){e.width=e.height=g;d=true}var h;try{var i=e.getContext("2d");d||i.clearRect(0,0,g,g);i.drawImage(b,0,0,g,g);h=i.getImageData(0,0,g,g).data}catch(l){return}d=h.length/4;this.data=new Array(d);for(var o=i=0;i< |
---|
114 | d;i++,o+=4){e=h[o+3];this.data[i]=e<<24|h[o]<<16|h[o+1]<<8|h[o+2];if(e<255)this.hasTransparency=true}this.height=this.width=g;this.mipmaps=null;c&&this.generateMipmaps();this.srcUrl=b.src;this.onready!=null&&typeof this.onready=="function"&&this.onready()}};a.hasData=function(){return this.data!=null}; |
---|
115 | a.generateMipmaps=function(){if(!(this.width<=1||this.data==null||this.mipmaps!=null)){this.mipmaps=[this.data];this.mipentries=[1];for(var b=1+~~(0.1+Math.log(this.width)*Math.LOG2E),c=this.width>>1,d=1;d<b;d++){for(var e=new Array(c*c),f=this.mipmaps[d-1],g=c<<1,h=0,i=0,l=0;l<c;l++){for(var o=0;o<c;o++){var u=f[h],j=f[h+1],B=f[h+g],n=f[h+g+1];e[i]=(((u&4278190080)>>>2)+((j&4278190080)>>>2)+((B&4278190080)>>>2)+((n&4278190080)>>>2)&4278190080)+((u&16711680)+(j&16711680)+(B&16711680)+(n&16711680)>> |
---|
116 | 2&16711680)+((u&65280)+(j&65280)+(B&65280)+(n&65280)>>2&65280)+((u&255)+(j&255)+(B&255)+(n&255)>>2&255);h+=2;i++}h+=g}this.mipmaps.push(e);this.mipentries.push(Math.pow(4,d));c>>=1}}};a.hasMipmap=function(){return this.mipmaps!=null};a.name="";a.data=null;a.mipmaps=null;a.mipentries=null;a.width=0;a.height=0;a.hasTransparency=false;a.srcUrl="";a.onready=null;JSC3D.Texture.cv=null;JSC3D.AABB=function(){this.minZ=this.maxZ=this.minY=this.maxY=this.minX=this.maxX=0}; |
---|
117 | JSC3D.AABB.prototype.center=function(){return[(this.minX+this.maxX)/2,(this.minY+this.maxY)/2,(this.minZ+this.maxZ)/2]};JSC3D.AABB.prototype.lengthOfDiagonal=function(){var b=this.maxX-this.minX,c=this.maxY-this.minY,d=this.maxZ-this.minZ;return Math.sqrt(b*b+c*c+d*d)};JSC3D.Matrix3x4=function(){this.m00=1;this.m10=this.m03=this.m02=this.m01=0;this.m11=1;this.m21=this.m20=this.m13=this.m12=0;this.m22=1;this.m23=0};a=JSC3D.Matrix3x4.prototype; |
---|
118 | a.identity=function(){this.m00=1;this.m10=this.m03=this.m02=this.m01=0;this.m11=1;this.m21=this.m20=this.m13=this.m12=0;this.m22=1;this.m23=0};a.scale=function(b,c,d){this.m00*=b;this.m01*=b;this.m02*=b;this.m03*=b;this.m10*=c;this.m11*=c;this.m12*=c;this.m13*=c;this.m20*=d;this.m21*=d;this.m22*=d;this.m23*=d};a.translate=function(b,c,d){this.m03+=b;this.m13+=c;this.m23+=d}; |
---|
119 | a.rotateAboutXAxis=function(b){if(b!=0){b*=Math.PI/180;var c=Math.cos(b);b=Math.sin(b);var d=c*this.m11-b*this.m21,e=c*this.m12-b*this.m22,f=c*this.m13-b*this.m23,g=c*this.m20+b*this.m10,h=c*this.m21+b*this.m11,i=c*this.m22+b*this.m12,l=c*this.m23+b*this.m13;this.m10=c*this.m10-b*this.m20;this.m11=d;this.m12=e;this.m13=f;this.m20=g;this.m21=h;this.m22=i;this.m23=l}}; |
---|
120 | a.rotateAboutYAxis=function(b){if(b!=0){b*=Math.PI/180;var c=Math.cos(b);b=Math.sin(b);var d=c*this.m01+b*this.m21,e=c*this.m02+b*this.m22,f=c*this.m03+b*this.m23,g=c*this.m20-b*this.m00,h=c*this.m21-b*this.m01,i=c*this.m22-b*this.m02,l=c*this.m23-b*this.m03;this.m00=c*this.m00+b*this.m20;this.m01=d;this.m02=e;this.m03=f;this.m20=g;this.m21=h;this.m22=i;this.m23=l}}; |
---|
121 | a.rotateAboutZAxis=function(b){if(b!=0){b*=Math.PI/180;var c=Math.cos(b);b=Math.sin(b);var d=c*this.m10+b*this.m00,e=c*this.m11+b*this.m01,f=c*this.m12+b*this.m02,g=c*this.m13+b*this.m03,h=c*this.m01-b*this.m11,i=c*this.m02-b*this.m12,l=c*this.m03-b*this.m13;this.m00=c*this.m00-b*this.m10;this.m01=h;this.m02=i;this.m03=l;this.m10=d;this.m11=e;this.m12=f;this.m13=g}}; |
---|
122 | a.multiply=function(b){var c=b.m00*this.m01+b.m01*this.m11+b.m02*this.m21,d=b.m00*this.m02+b.m01*this.m12+b.m02*this.m22,e=b.m00*this.m03+b.m01*this.m13+b.m02*this.m23+b.m03,f=b.m10*this.m00+b.m11*this.m10+b.m12*this.m20,g=b.m10*this.m01+b.m11*this.m11+b.m12*this.m21,h=b.m10*this.m02+b.m11*this.m12+b.m12*this.m22,i=b.m10*this.m03+b.m11*this.m13+b.m12*this.m23+b.m13,l=b.m20*this.m00+b.m21*this.m10+b.m22*this.m20,o=b.m20*this.m01+b.m21*this.m11+b.m22*this.m21,u=b.m20*this.m02+b.m21*this.m12+b.m22*this.m22, |
---|
123 | j=b.m20*this.m03+b.m21*this.m13+b.m22*this.m23+b.m23;this.m00=b.m00*this.m00+b.m01*this.m10+b.m02*this.m20;this.m01=c;this.m02=d;this.m03=e;this.m10=f;this.m11=g;this.m12=h;this.m13=i;this.m20=l;this.m21=o;this.m22=u;this.m23=j}; |
---|
124 | JSC3D.Math3D={transformVectors:function(b,c,d){for(var e=0;e<c.length;e+=3){var f=c[e],g=c[e+1],h=c[e+2];d[e]=b.m00*f+b.m01*g+b.m02*h+b.m03;d[e+1]=b.m10*f+b.m11*g+b.m12*h+b.m13;d[e+2]=b.m20*f+b.m21*g+b.m22*h+b.m23}},transformVectorZs:function(b,c,d){for(var e=c.length/3,f=0,g=0;f<e;){d[f]=b.m20*c[g]+b.m21*c[g+1]+b.m22*c[g+2]+b.m23;f++;g+=3}},normalizeVectors:function(b,c){for(var d=b.length,e=0;e<d;e+=3){var f=b[e],g=b[e+1],h=b[e+2],i=Math.sqrt(f*f+g*g+h*h);if(i>0){i=1/i;f*=i;g*=i;h*=i}c[e]=f;c[e+ |
---|
125 | 1]=g;c[e+2]=h}}};JSC3D.PlatformInfo=function(){for(var b={browser:"other",version:"0.0.0",isTouchDevice:document.createTouch!=undefined},c=[["firefox",/Firefox[\/\s](\d+(?:.\d+)*)/],["chrome",/Chrome[\/\s](\d+(?:.\d+)*)/],["opera",/Opera[\/\s](\d+(?:.\d+)*)/],["safari",/Safari[\/\s](\d+(?:.\d+)*)/],["webkit",/AppleWebKit[\/\s](\d+(?:.\d+)*)/],["ie",/MSIE[\/\s](\d+(?:.\d+)*)/]],d,e=0;e<c.length;e++)if(d=c[e][1].exec(window.navigator.userAgent)){b.browser=c[e][0];b.version=d[1];break}return b}(); |
---|
126 | JSC3D.BinaryStream=function(b,c){if(c)throw"JSC3D.BinaryStream constructor failed: Big endian is not supported yet!";this.data=b;this.offset=0};a=JSC3D.BinaryStream.prototype;a.size=function(){return this.data.length};a.tell=function(){return this.offset};a.seek=function(b){if(b<0||b>=this.data.length)return false;this.offset=b;return true};a.reset=function(){this.offset=0};a.skip=function(b){if(this.offset+b>this.data.length)this.offset=this.data.length;else this.offset+=b}; |
---|
127 | a.available=function(){return this.data.length-this.offset};a.eof=function(){return!(this.offset<this.data.length)};a.readUInt8=function(){return this.decodeInt(1,false)};a.readInt8=function(){return this.decodeInt(1,true)};a.readUInt16=function(){return this.decodeInt(2,false)};a.readInt16=function(){return this.decodeInt(2,true)};a.readUInt32=function(){return this.decodeInt(4,false)};a.readInt32=function(){return this.decodeInt(4,true)};a.readFloat32=function(){return this.decodeFloat(4,23)}; |
---|
128 | a.readFloat64=function(){return this.decodeFloat(8,52)};a.readBytes=function(b,c){var d=c;if(this.offset+c>this.data.length)d=this.data.length-this.offset;for(c=0;c<d;c++)b[c]=this.data[this.offset++].charCodeAt(0)&255;return d};a.decodeInt=function(b,c){if(this.offset+b>this.data.length){this.offset=this.data.length;return NaN}for(var d=0,e=1,f=0;f<b;f++){d+=(this.data[this.offset++].charCodeAt(0)&255)*e;e*=256}if(c&&d&Math.pow(2,b*8-1))d-=Math.pow(2,b*8);return d}; |
---|
129 | a.decodeFloat=function(b,c){if(this.offset+b>this.data.length){this.offset=this.data.length;return NaN}var d=b*8-c-1,e=(1<<d)-1,f=e>>1,g=b-1,h=this.data[this.offset+g].charCodeAt(0)&255;g+=-1;var i=-7,l=h&(1<<-i)-1;h>>=-i;for(i+=d;i>0;){l=l*256+(this.data[this.offset+g].charCodeAt(0)&255);g+=-1;i-=8}d=l&(1<<-i)-1;l>>=-i;for(i+=c;i>0;){d=d*256+(this.data[this.offset+g].charCodeAt(0)&255);g+=-1;i-=8}this.offset+=b;switch(l){case 0:l=1-f;break;case e:return d?NaN:(h?-1:1)*Infinity;default:d+=Math.pow(2, |
---|
130 | c);l-=f;break}return(h?-1:1)*d*Math.pow(2,l-c)};JSC3D.LoaderSelector={registerLoader:function(b,c){if(typeof c=="function")JSC3D.LoaderSelector.loaderTable[b]=c},getLoader:function(b){b=JSC3D.LoaderSelector.loaderTable[b.toLowerCase()];if(!b)return null;var c;try{c=new b}catch(d){c=null}return c},loaderTable:{}}; |
---|
131 | JSC3D.ObjLoader=function(b,c,d,e){this.onload=b&&typeof b=="function"?b:null;this.onerror=c&&typeof c=="function"?c:null;this.onprogress=d&&typeof d=="function"?d:null;this.onresource=e&&typeof e=="function"?e:null;this.requestCount=0};a=JSC3D.ObjLoader.prototype;a.loadFromUrl=function(b){var c="",d=b,e=b.lastIndexOf("/");if(e==-1)e=b.lastIndexOf("\\");if(e!=-1){c=b.substring(0,e+1);d=b.substring(e+1)}this.requestCount=0;this.loadObjFile(c,d)}; |
---|
132 | a.loadObjFile=function(b,c){var d=b+c,e=this;c=new XMLHttpRequest;c.open("GET",d,true);c.onreadystatechange=function(){if(this.readyState==4)if(this.status==200||this.status==0){if(e.onload){e.onprogress&&e.onprogress("Loading obj file ...",1);JSC3D.console&&JSC3D.console.logInfo('Finished loading obj file "'+d+'".');var f=new JSC3D.Scene,g=e.parseObj(f,this.responseText);if(g.length>0)for(var h=0;h<g.length;h++)e.loadMtlFile(f,b,g[h]);--e.requestCount==0&&e.onload(f)}}else{JSC3D.console&&JSC3D.console.logError('Failed to load obj file "'+ |
---|
133 | d+'".');if(e.onerror){e.requestCount--;e.onerror('Failed to load obj file "'+d+'".')}}};if(this.onprogress){this.onprogress("Loading obj file ...",0);c.onprogress=function(f){e.onprogress("Loading obj file ...",f.position/f.totalSize)}}this.requestCount++;c.send()}; |
---|
134 | a.loadMtlFile=function(b,c,d){var e=c+d,f=this,g=new XMLHttpRequest;g.open("GET",e,true);g.onreadystatechange=function(){if(this.readyState==4){if(this.status==200||this.status==0){f.onprogress&&f.onprogress("Loading mtl file ...",1);JSC3D.console&&JSC3D.console.logInfo('Finished loading mtl file "'+e+'".');for(var h=f.parseMtl(this.responseText),i={},l=b.getChildren(),o=0;o<l.length;o++){var u=l[o];if(u.mtl!=null&&u.mtllib!=null&&u.mtllib==d){var j=h[u.mtl];if(j!=null){j.material!=null&&u.setMaterial(j.material); |
---|
135 | if(j.textureFileName!="")if(i[j.textureFileName])i[j.textureFileName].push(u);else i[j.textureFileName]=[u]}}}for(var B in i)f.setupTexture(i[B],c+B)}else JSC3D.console&&JSC3D.console.logWarning('Failed to load mtl file "'+e+'". A default material will be applied.');--f.requestCount==0&&f.onload(b)}};if(this.onprogress){this.onprogress("Loading mtl file ...",0);g.onprogress=function(h){f.onprogress("Loading mtl file ...",h.position/h.totalSize)}}this.requestCount++;g.send()}; |
---|
136 | a.parseObj=function(b,c){var d={},e=[],f=0,g=null,h="",i="",l=[],o=[];g="obj-"+f++;var u=new JSC3D.Mesh;u.name=g;u.indexBuffer=[];g=d.nomtl=u;var j=c.split(/[ \t]*\r?\n[ \t]*/);for(c=0;c<j.length;c++){i=j[c].split(/[ \t]+/);if(i.length>0)switch(i[0]){case "v":if(i.length>3)for(var B=1;B<4;B++)l.push(parseFloat(i[B]));break;case "vn":break;case "vt":if(i.length>2){o.push(parseFloat(i[1]));o.push(1-parseFloat(i[2]))}break;case "f":if(i.length>3){for(B=1;B<i.length;B++){var n=i[B].split("/");g.indexBuffer.push(parseInt(n[0])- |
---|
137 | 1);if(n.length>1&&n[1]!=""){if(!g.texCoordIndexBuffer)g.texCoordIndexBuffer=[];g.texCoordIndexBuffer.push(parseInt(n[1])-1)}}g.indexBuffer.push(-1);g.texCoordIndexBuffer&&g.texCoordIndexBuffer.push(-1)}break;case "mtllib":if(i.length>1){h=i[1];e.push(h)}else h="";break;case "usemtl":if(i.length>1&&i[1]!=""&&h!=""){i=i[1];B=h+"-"+i;g=d[B];if(!g){g=new JSC3D.Mesh;g.name="obj-"+f++;g.indexBuffer=[];g.mtllib=h;g.mtl=i;d[B]=g}g=g}else g=u;break;case "#":default:break}}f=l.length>=3?new Array(l.length/ |
---|
138 | 3):null;h=o.length>=2?new Array(o.length/2):null;for(var M in d){g=d[M];if(l.length>=3&&g.indexBuffer.length>0){for(c=0;c<f.length;c++)f[c]=-1;g.vertexBuffer=[];for(c=j=u=0;c<g.indexBuffer.length;c++){u=g.indexBuffer[c];if(u!=-1)if(f[u]==-1){i=u*3;g.vertexBuffer.push(l[i]);g.vertexBuffer.push(l[i+1]);g.vertexBuffer.push(l[i+2]);g.indexBuffer[c]=j;f[u]=j;j++}else g.indexBuffer[c]=f[u]}}if(o.length>=2&&g.texCoordIndexBuffer!=null&&g.texCoordIndexBuffer.length>0){for(c=0;c<h.length;c++)h[c]=-1;g.texCoordBuffer= |
---|
139 | [];for(c=j=u=0;c<g.texCoordIndexBuffer.length;c++){u=g.texCoordIndexBuffer[c];if(u!=-1)if(h[u]==-1){i=u*2;g.texCoordBuffer.push(o[i]);g.texCoordBuffer.push(o[i+1]);g.texCoordIndexBuffer[c]=j;h[u]=j;j++}else g.texCoordIndexBuffer[c]=h[u]}}g.isTrivial()||b.addChild(g)}return e}; |
---|
140 | a.parseMtl=function(b){var c={},d="";b=b.split(/[ \t]*\r?\n[ \t]*/);for(var e=0;e<b.length;e++){var f=b[e].split(/[ \t]+/);if(f.length>0)switch(f[0]){case "newmtl":d=f[1];f={};f.material=new JSC3D.Material;f.textureFileName="";c[d]=f;break;case "Ka":break;case "Kd":if(f.length==4&&!isNaN(f[1])){var g=parseFloat(f[1])*255&255,h=parseFloat(f[2])*255&255,i=parseFloat(f[3])*255&255;f=c[d];if(f!=null)f.material.diffuseColor=g<<16|h<<8|i}break;case "Ks":break;case "d":if(f.length==2&&!isNaN(f[1])){g=parseFloat(f[1]); |
---|
141 | f=c[d];if(f!=null)f.material.transparency=1-g}break;case "illum":break;case "map_Kd":if(f.length==2){g=f[1];f=c[d];if(f!=null)f.textureFileName=g}break;case "#":default:break}}return c};a.setupTexture=function(b,c){var d=this,e=new JSC3D.Texture;e.onready=function(){for(var f=0;f<b.length;f++)b[f].setTexture(this);d.onresource&&d.onresource(this)};e.createFromUrl(c)};a.onload=null;a.onerror=null;a.onprogress=null;a.onresource=null;a.requestCount=0;JSC3D.LoaderSelector.registerLoader("obj",JSC3D.ObjLoader); |
---|
142 | JSC3D.StlLoader=function(b,c,d,e){this.onload=b&&typeof b=="function"?b:null;this.onerror=c&&typeof c=="function"?c:null;this.onprogress=d&&typeof d=="function"?d:null;this.onresource=e&&typeof e=="function"?e:null;this.decimalPrecision=3};a=JSC3D.StlLoader.prototype; |
---|
143 | a.loadFromUrl=function(b){var c=this,d=JSC3D.PlatformInfo.browser=="ie",e=new XMLHttpRequest;e.open("GET",b,true);d?e.setRequestHeader("Accept-Charset","x-user-defined"):e.overrideMimeType("text/plain; charset=x-user-defined");e.onreadystatechange=function(){if(this.readyState==4)if(this.status==200||this.status==0){JSC3D.console&&JSC3D.console.logInfo('Finished loading STL file "'+b+'".');if(c.onload){c.onprogress&&c.onprogress("Loading STL file ...",1);if(d){var f=new JSC3D.Scene;try{c.parseStl(f, |
---|
144 | function(h){for(var i="",l=0;l<h.length-65536;l+=65536)i+=String.fromCharCode.apply(null,h.slice(l,l+65536));return i+String.fromCharCode.apply(null,h.slice(l))}((new VBArray(this.responseBody)).toArray()))}catch(g){}}else{f=new JSC3D.Scene;c.parseStl(f,this.responseText)}c.onload(f)}}else{JSC3D.console&&JSC3D.console.logError('Failed to load STL file "'+b+'".');c.onerror&&c.onerror('Failed to load STL file "'+b+'".')}};if(this.onprogress){this.onprogress("Loading STL file ...",0);e.onprogress=function(f){c.onprogress("Loading STL file ...", |
---|
145 | f.position/f.totalSize)}}e.send()};a.setDecimalPrecision=function(b){this.decimalPrecision=b}; |
---|
146 | a.parseStl=function(b,c){var d=new JSC3D.Mesh;d.vertexBuffer=[];d.indexBuffer=[];d.faceNormalBuffer=[];var e=false,f=new JSC3D.BinaryStream(c);f.skip(84);for(var g=0;g<256&&!f.eof();g++)if(f.readUInt8()>127){e=true;break}if(JSC3D.console)JSC3D.console.logInfo("This is recognised as "+(e?"a binary":"an ASCII")+" STL file.");if(e){f.reset();f.skip(80);e=f.readUInt32();c=84+50*e;if(f.size()<c){JSC3D.console&&JSC3D.console.logError("Failed to parse contents of the file. It seems not complete.");return}d.faceCount= |
---|
147 | e;h={};for(g=0;g<e;g++){d.faceNormalBuffer.push(f.readFloat32());d.faceNormalBuffer.push(f.readFloat32());d.faceNormalBuffer.push(f.readFloat32());for(c=0;c<3;c++){i=f.readFloat32();l=f.readFloat32();o=f.readFloat32();u=i.toFixed(this.decimalPrecision)+"-"+l.toFixed(this.decimalPrecision)+"-"+o.toFixed(this.decimalPrecision);j=h[u];if(j==undefined){j=d.vertexBuffer.length/3;h[u]=j;d.vertexBuffer.push(i);d.vertexBuffer.push(l);d.vertexBuffer.push(o)}d.indexBuffer.push(j)}d.indexBuffer.push(-1);f.skip(2)}}else{f= |
---|
148 | new RegExp("facet\\s+normal\\s+([-+]?\\b(?:[0-9]*\\.)?[0-9]+(?:[eE][-+]?[0-9]+)?\\b)\\s+([-+]?\\b(?:[0-9]*\\.)?[0-9]+(?:[eE][-+]?[0-9]+)?\\b)\\s+([-+]?\\b(?:[0-9]*\\.)?[0-9]+(?:[eE][-+]?[0-9]+)?\\b)\\s+outer\\s+loop\\s+vertex\\s+([-+]?\\b(?:[0-9]*\\.)?[0-9]+(?:[eE][-+]?[0-9]+)?\\b)\\s+([-+]?\\b(?:[0-9]*\\.)?[0-9]+(?:[eE][-+]?[0-9]+)?\\b)\\s+([-+]?\\b(?:[0-9]*\\.)?[0-9]+(?:[eE][-+]?[0-9]+)?\\b)\\s+vertex\\s+([-+]?\\b(?:[0-9]*\\.)?[0-9]+(?:[eE][-+]?[0-9]+)?\\b)\\s+([-+]?\\b(?:[0-9]*\\.)?[0-9]+(?:[eE][-+]?[0-9]+)?\\b)\\s+([-+]?\\b(?:[0-9]*\\.)?[0-9]+(?:[eE][-+]?[0-9]+)?\\b)\\s+vertex\\s+([-+]?\\b(?:[0-9]*\\.)?[0-9]+(?:[eE][-+]?[0-9]+)?\\b)\\s+([-+]?\\b(?:[0-9]*\\.)?[0-9]+(?:[eE][-+]?[0-9]+)?\\b)\\s+([-+]?\\b(?:[0-9]*\\.)?[0-9]+(?:[eE][-+]?[0-9]+)?\\b)\\s+endloop\\s+endfacet", |
---|
149 | "ig");if(g=c.match(f)){e=g.length;d.faceCount=e;var h={};f.lastIndex=0;f.global=false;for(e=f.exec(c);e!=null;e=f.exec(c)){d.faceNormalBuffer.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]));for(g=0;g<3;g++){var i=parseFloat(e[4+g*3]),l=parseFloat(e[5+g*3]),o=parseFloat(e[6+g*3]),u=i.toFixed(this.decimalPrecision)+"-"+l.toFixed(this.decimalPrecision)+"-"+o.toFixed(this.decimalPrecision),j=h[u];if(j===undefined){j=d.vertexBuffer.length/3;h[u]=j;d.vertexBuffer.push(i);d.vertexBuffer.push(l); |
---|
150 | d.vertexBuffer.push(o)}d.indexBuffer.push(j)}d.indexBuffer.push(-1)}}}if(!d.isTrivial()){if(Math.abs(d.faceNormalBuffer[0])<1.0E-6&&Math.abs(d.faceNormalBuffer[1])<1.0E-6&&Math.abs(d.faceNormalBuffer[2])<1.0E-6)d.faceNormalBuffer=null;b.addChild(d)}};a.onload=null;a.onerror=null;a.onprogress=null;a.onresource=null;a.decimalPrecision=3;JSC3D.LoaderSelector.registerLoader("stl",JSC3D.StlLoader); |
---|