diff --git a/css3d.min.js b/css3d.min.js index a3c5a07..e632fdc 100644 --- a/css3d.min.js +++ b/css3d.min.js @@ -6,4 +6,4 @@ * @author: Shrek.wang, shrekshrek@gmail.com **/ -!function(t){var i="object"==typeof self&&self.self==self&&self||"object"==typeof global&&global.global==global&&global;"function"==typeof define&&define.amd?define(["exports"],function(e){i.C3D=t(i,e)}):"undefined"!=typeof exports?t(i,exports):i.C3D=t(i,{})}(function(t,i){function e(t){return Math.round(t)}function s(t){return Math.round(100*t)/100}function n(t){return t.replace(/\b(\w)|\s(\w)/g,function(t){return t.toUpperCase()})}function r(t){var e;switch(t.type){case"sprite":e=new i.Sprite(t.el?{el:t.el}:void 0);break;case"plane":e=new i.Plane(t.el?{el:t.el}:void 0);break;case"box":e=new i.Box(t.el?{el:t.el}:void 0);break;case"skybox":e=new i.Skybox(t.el?{el:t.el}:void 0)}if(void 0!=t.size&&e.size.apply(e,t.size),void 0!=t.position&&e.position.apply(e,t.position),void 0!=t.rotation&&e.rotation.apply(e,t.rotation),void 0!=t.scale&&e.scale.apply(e,t.scale),void 0!=t.origin&&e.origin.apply(e,t.origin),void 0!=t.visibility&&e.visibility.apply(e,t.visibility),void 0!=t.material&&e.material.apply(e,t.material),void 0!=t.filter&&e.filter.apply(e,t.filter),void 0!=t.name&&e.name.apply(e,[t.name]),e.update(),t.children)for(var s=0,n=t.children.length;n>s;s++){var h=t.children[s],a=r(h);e.addChild(a)}return e}var h=function(t){var i=[];for(var e in t)i.push(e);return i},a=function(t){var i=arguments.length;if(2>i||null==t)return t;for(var e=1;i>e;e++)for(var s=arguments[e],n=h(s),r=n.length,a=0;r>a;a++){var o=n[a];t[o]=s[o]}return t},o=function(t,i){var e,s=this;e=t&&Object.prototype.hasOwnProperty.call(t,"constructor")?t.constructor:function(){return s.apply(this,arguments)},a(e,s,i);var n=function(){this.constructor=e};return n.prototype=s.prototype,e.prototype=new n,t&&a(e.prototype,t),e.__super__=s.prototype,e},l="";return function(){var t=document.createElement("div"),i=["Webkit","Moz","Ms","O"];for(var e in i)if(i[e]+"Transform"in t.style){l=i[e];break}}(),i.getRandomColor=function(){return"#"+("00000"+(16777216*Math.random()<<0).toString(16)).slice(-6)},i.rgb2hex=function(t,i,e){return(t<<16|i<<8|e).toString(16)},i.hex2rgb=function(t){var i=Math.floor("0x"+t),e=i>>16&255,s=i>>8&255,n=255&i;return[e,s,n]},i.Object=function(){this.initialize.apply(this,arguments)},a(i.Object.prototype,{x:0,y:0,z:0,position:function(t,i,e){switch(arguments.length){case 1:this.x=t,this.y=t,this.z=t;break;case 2:this.x=t,this.y=i;break;case 3:this.x=t,this.y=i,this.z=e}return this},move:function(t,i,e){switch(arguments.length){case 1:this.x+=t,this.y+=t,this.z+=t;break;case 2:this.x+=t,this.y+=i;break;case 3:this.x+=t,this.y+=i,this.z+=e}return this},rotationX:0,rotationY:0,rotationZ:0,rotation:function(t,i,e){switch(arguments.length){case 1:this.rotationX=t,this.rotationY=t,this.rotationZ=t;break;case 2:this.rotationX=t,this.rotationY=i;break;case 3:this.rotationX=t,this.rotationY=i,this.rotationZ=e}return this},rotate:function(t,i,e){switch(arguments.length){case 1:this.rotationX+=t,this.rotationY+=t,this.rotationZ+=t;break;case 2:this.rotationX+=t,this.rotationY+=i;break;case 3:this.rotationX+=t,this.rotationY+=i,this.rotationZ+=e}return this},scaleX:1,scaleY:1,scaleZ:1,scale:function(t,i,e){switch(arguments.length){case 1:this.scaleX=t,this.scaleY=t,this.scaleZ=t;break;case 2:this.scaleX=t,this.scaleY=i;break;case 3:this.scaleX=t,this.scaleY=i,this.scaleZ=e}return this},width:0,height:0,depth:0,size:function(t,i,e){switch(arguments.length){case 1:this.width=t,this.height=t,this.depth=t;break;case 2:this.width=t,this.height=i;break;case 3:this.width=t,this.height=i,this.depth=e}return this},originX:0,originY:0,originZ:0,__orgO:{x:0,y:0,z:0},__orgT:{x:0,y:0,z:0},__orgF:{x:0,y:0,z:0},origin:function(t,i,e){switch(arguments.length){case 1:this.originX=t,this.originY=t,this.originZ=t;break;case 2:this.originX=t,this.originY=i;break;case 3:this.originX=t,this.originY=i,this.originZ=e}return this},__name:"",name:function(t){return this.__name=t,""==t?delete this.el.dataset.name:this.el.dataset.name=t,this},__sort:["X","Y","Z"],sort:function(t,i,e){if(arguments.length>3)throw"sort arguments is wrong!";return this.__sort=[t,i,e],this},initialize:function(){this.x=0,this.y=0,this.z=0,this.rotationX=0,this.rotationY=0,this.rotationZ=0,this.scaleX=1,this.scaleY=1,this.scaleZ=1,this.width=0,this.height=0,this.depth=0,this.originX="50%",this.originY="50%",this.originZ="0px",this.__orgO={x:"50%",y:"50%",z:"0px"},this.__orgT={x:"-50%",y:"-50%",z:"0px"},this.__orgF={x:0,y:0,z:0},this.children=[],this.__name=""},parent:null,children:null,addChild:function(t){if(null!=t.parent&&t.parent.removeChild(t),""!=t.__name){if(void 0!==this[t.__name])throw t.__name+" already exist!";this[t.__name]=t}return this.children.push(t),t.parent=this,this},removeChild:function(t){for(var i=this.children.length-1;i>=0;i--)if(this.children[i]===t)return""!=t.__name&&delete this[t.__name],this.children.splice(i,1),t.parent=null,this;return this},removeAllChild:function(){for(var t=this.children.length-1;t>=0;t--){var i=this.children[t];""!=i.__name&&delete this[i.__name],i.parent=null}return this.children=[],this},remove:function(){return null!=this.parent&&this.parent.removeChild(this),this}}),i.Object.extend=o,i.Sprite=i.Object.extend({el:null,alpha:1,visible:!0,initialize:function(t){i.Sprite.__super__.initialize.apply(this,[t]),this.alpha=1,this.visible=!0;var e;if(t&&t.el)switch(typeof t.el){case"string":e=document.createElement("div"),e.innerHTML=t.el;break;case"object":1===t.el.nodeType&&(e=t.el)}e||(e=document.createElement("div")),e.style.position="absolute",e.style[l+"Transform"]="translateZ(0px)",e.style[l+"TransformStyle"]="preserve-3d",this.el=e,e.le=this},update:function(){return this.updateS(),this.updateM(),this.updateO(),this.updateT(),this.updateV(),this},updateS:function(){return this},updateM:function(){if(!this.__mat)return this;for(var t in this.__mat)switch(t){case"bothsides":this.el.style[l+"BackfaceVisibility"]=this.__mat[t]?"visible":"hidden";break;case"image":this.el.style["background"+n(t)]=""!==this.__mat[t]?"url("+this.__mat[t]+")":"";break;default:this.el.style["background"+n(t)]=this.__mat[t]}return this},updateO:function(){if("number"==typeof this.originX){var t=e(this.originX-this.__orgF.x);this.__orgO.x=t+"px",this.__orgT.x=-t+"px"}else this.__orgO.x=this.originX,this.__orgT.x="-"+this.originX;if("number"==typeof this.originY){var i=e(this.originY-this.__orgF.y);this.__orgO.y=i+"px",this.__orgT.y=-i+"px"}else this.__orgO.y=this.originY,this.__orgT.y="-"+this.originY;if("number"==typeof this.originZ){var s=e(this.originZ-this.__orgF.z);this.__orgO.z=s+"px",this.__orgT.z=-s+"px"}else this.__orgO.z=this.__orgT.z="0px";return this.el.style[l+"TransformOrigin"]=this.__orgO.x+" "+this.__orgO.y+" "+this.__orgO.z,this},updateT:function(){var t=this.__sort[0],i=this.__sort[1],e=this.__sort[2];return this.el.style[l+"Transform"]="translate3d("+this.__orgT.x+", "+this.__orgT.y+", "+this.__orgT.z+") translate3d("+s(this.x)+"px,"+s(this.y)+"px,"+s(this.z)+"px) rotate"+t+"("+s(this["rotation"+t])%360+"deg) rotate"+i+"("+s(this["rotation"+i])%360+"deg) rotate"+e+"("+s(this["rotation"+e])%360+"deg) scale3d("+s(this.scaleX)+", "+s(this.scaleY)+", "+s(this.scaleZ)+") ",this},updateV:function(){return this.el.style.opacity=this.alpha,this.el.style.display=this.visible?"block":"none",this},addChild:function(t){return i.Sprite.__super__.addChild.apply(this,[t]),this.el&&t.el&&this.el.appendChild(t.el),this},removeChild:function(t){for(var i=this.children.length-1;i>=0;i--)if(this.children[i]===t)return""!=t.__name&&delete this[t.__name],this.children.splice(i,1),t.parent=null,this.el.removeChild(t.el),this;return this},removeAllChild:function(){for(var t=this.children.length-1;t>=0;t--){var i=this.children[t];""!=i.__name&&delete this[i.__name],i.parent=null,this.el.removeChild(i.el)}return this.children=[],this},on:function(t){if("object"==typeof t)for(var i in t)this.el.addEventListener(i,t[i],!1);else 2===arguments.length?this.el.addEventListener(arguments[0],arguments[1],!1):3===arguments.length&&this.el.addEventListener(arguments[0],arguments[1],arguments[2]);return this},off:function(t){if("object"==typeof t)for(var i in t)this.el.removeEventListener(i,t[i],!1);else 2===arguments.length&&this.el.removeEventListener(arguments[0],arguments[1],!1);return this},buttonMode:function(t){return this.el.style.cursor=t?"pointer":"auto",this},__mat:null,material:function(t){return this.__mat=t,this},visibility:function(t){return void 0!==t.visible&&(this.visible=t.visible),void 0!==t.alpha&&(this.alpha=t.alpha),this}}),i.Stage=i.Sprite.extend({camera:null,fov:null,__rfix:null,__pfix:null,initialize:function(t){i.Stage.__super__.initialize.apply(this,[t]),t&&t.el||(this.el.style.top="0px",this.el.style.left="0px",this.el.style.width="0px",this.el.style.height="0px"),this.el.style[l+"Perspective"]="800px",this.el.style[l+"TransformStyle"]="flat",this.el.style[l+"Transform"]="",this.el.style.overflow="hidden",this.__rfix=new i.Sprite,this.el.appendChild(this.__rfix.el),this.__pfix=new i.Sprite,this.__rfix.el.appendChild(this.__pfix.el),this.setCamera(new i.Camera)},updateS:function(){return this.el.style.width=e(this.width)+"px",this.el.style.height=e(this.height)+"px",this},updateT:function(){return this.fov=e(.5/Math.tan(.5*this.camera.fov/180*Math.PI)*this.height),this.el.style[l+"Perspective"]=this.fov+"px",this.__rfix.position(e(this.width/2),e(this.height/2),this.fov).rotation(-this.camera.rotationX,-this.camera.rotationY,-this.camera.rotationZ).updateT(),this.__pfix.position(-this.camera.x,-this.camera.y,-this.camera.z).updateT(),this},addChild:function(t){return this.__pfix.addChild(t),this},removeChild:function(t){return this.__pfix.removeChild(t),this},setCamera:function(t){return this.camera&&(this.camera.stage=null),this.camera=t,this.camera.stage=this,this}}),i.Camera=i.Object.extend({fov:null,stage:null,initialize:function(t){i.Camera.__super__.initialize.apply(this,[t]),this.fov=75},update:function(){return this.updateT(),this},updateS:function(){return this},updateM:function(){return this},updateT:function(){return this.stage&&this.stage.updateT(),this},updateV:function(){return this}}),i.Plane=i.Sprite.extend({initialize:function(t){i.Plane.__super__.initialize.apply(this,[t])},update:function(){return i.Plane.__super__.update.apply(this),this.updateF(),this},updateS:function(){return this.el.style.width=e(this.width)+"px",this.el.style.height=e(this.height)+"px",this},updateF:function(){if(!this.__flt)return this;var t="";for(var i in this.__flt)t+=""!==this.__flt[i]?i+"("+this.__flt[i].join(",")+")":"";return""!==t&&(this.el.style[l+"Filter"]=t),this},__flt:null,filter:function(t){return this.__flt=t,this}}),i.Box=i.Sprite.extend({front:null,back:null,left:null,right:null,up:null,down:null,initialize:function(t){i.Box.__super__.initialize.apply(this,[t]),this.front=new i.Plane,this.front.name="front",this.addChild(this.front),this.back=new i.Plane,this.back.name="back",this.addChild(this.back),this.left=new i.Plane,this.left.name="left",this.addChild(this.left),this.right=new i.Plane,this.right.name="right",this.addChild(this.right),this.up=new i.Plane,this.up.name="up",this.addChild(this.up),this.down=new i.Plane,this.down.name="down",this.addChild(this.down)},update:function(){return i.Box.__super__.update.apply(this),this.updateF(),this},updateS:function(){var t=e(this.width),i=e(this.height),s=e(this.depth);return this.__orgF.x=this.width/2,this.__orgF.y=this.height/2,this.__orgF.z=this.depth/2,this.front.size(t,i,0).position(0,0,s/2).rotation(0,0,0).updateS().updateT(),this.back.size(t,i,0).position(0,0,-s/2).rotation(0,180,0).updateS().updateT(),this.left.size(s,i,0).position(-t/2,0,0).rotation(0,-90,0).updateS().updateT(),this.right.size(s,i,0).position(t/2,0,0).rotation(0,90,0).updateS().updateT(),this.up.size(t,s,0).position(0,-i/2,0).rotation(90,0,0).updateS().updateT(),this.down.size(t,s,0).position(0,i/2,0).rotation(-90,0,0).updateS().updateT(),this},updateM:function(){if(!this.__mat)return this;for(var t in this.__mat)switch(t){case"front":case"back":case"left":case"right":case"up":case"down":this[t].material({image:this.__mat[t],bothsides:!1}).updateM();break;default:this.front.material(this.__mat).updateM(),this.back.material(this.__mat).updateM(),this.left.material(this.__mat).updateM(),this.right.material(this.__mat).updateM(),this.up.material(this.__mat).updateM(),this.down.material(this.__mat).updateM()}return this},updateF:function(){return this.__flt?(this.front.filter(this.__flt).updateF(),this.back.filter(this.__flt).updateF(),this.left.filter(this.__flt).updateF(),this.right.filter(this.__flt).updateF(),this.up.filter(this.__flt).updateF(),this.down.filter(this.__flt).updateF(),this):this},__flt:null,filter:function(t){return this.__flt=t,this}}),i.Skybox=i.Box.extend({updateS:function(){var t=e(this.width),i=e(this.height),s=e(this.depth);return this.__orgF.x=this.width/2,this.__orgF.y=this.height/2,this.__orgF.z=this.depth/2,this.front.size(t,i,0).position(0,0,-s/2).rotation(0,0,0).updateS().updateT(),this.back.size(t,i,0).position(0,0,s/2).rotation(0,180,0).updateS().updateT(),this.left.size(s,i,0).position(-t/2,0,0).rotation(0,90,0).updateS().updateT(),this.right.size(s,i,0).position(t/2,0,0).rotation(0,-90,0).updateS().updateT(),this.up.size(t,s,0).position(0,-i/2,0).rotation(-90,0,0).updateS().updateT(),this.down.size(t,s,0).position(0,i/2,0).rotation(90,0,0).updateS().updateT(),this}}),i.create=function(t){var i;switch(typeof t){case"array":i={type:"sprite",children:t};break;case"object":i=t;break;default:return}return r(i)},i}); +!function(t){var i="object"==typeof selfdsadasdasdasdasdasd&&self.self==self&&self||"object"==typeof global&&global.global==global&&global;"function"==typeof define&&define.amd?define(["exports"],function(e){i.C3D=t(i,e)}):"undefined"!=typeof exports?t(i,exports):i.C3D=t(i,{})}(function(t,i){function e(t){return Math.round(t)}function s(t){return Math.round(100*t)/100}function n(t){return t.replace(/\b(\w)|\s(\w)/g,function(t){return t.toUpperCase()})}function r(t){var e;switch(t.type){case"sprite":e=new i.Sprite(t.el?{el:t.el}:void 0);break;case"plane":e=new i.Plane(t.el?{el:t.el}:void 0);break;case"box":e=new i.Box(t.el?{el:t.el}:void 0);break;case"skybox":e=new i.Skybox(t.el?{el:t.el}:void 0)}if(void 0!=t.size&&e.size.apply(e,t.size),void 0!=t.position&&e.position.apply(e,t.position),void 0!=t.rotation&&e.rotation.apply(e,t.rotation),void 0!=t.scale&&e.scale.apply(e,t.scale),void 0!=t.origin&&e.origin.apply(e,t.origin),void 0!=t.visibility&&e.visibility.apply(e,t.visibility),void 0!=t.material&&e.material.apply(e,t.material),void 0!=t.filter&&e.filter.apply(e,t.filter),void 0!=t.name&&e.name.apply(e,[t.name]),e.update(),t.children)for(var s=0,n=t.children.length;n>s;s++){var h=t.children[s],a=r(h);e.addChild(a)}return e}var h=function(t){var i=[];for(var e in t)i.push(e);return i},a=function(t){var i=arguments.length;if(2>i||null==t)return t;for(var e=1;i>e;e++)for(var s=arguments[e],n=h(s),r=n.length,a=0;r>a;a++){var o=n[a];t[o]=s[o]}return t},o=function(t,i){var e,s=this;e=t&&Object.prototype.hasOwnProperty.call(t,"constructor")?t.constructor:function(){return s.apply(this,arguments)},a(e,s,i);var n=function(){this.constructor=e};return n.prototype=s.prototype,e.prototype=new n,t&&a(e.prototype,t),e.__super__=s.prototype,e},l="";return function(){var t=document.createElement("div"),i=["Webkit","Moz","Ms","O"];for(var e in i)if(i[e]+"Transform"in t.style){l=i[e];break}}(),i.getRandomColor=function(){return"#"+("00000"+(16777216*Math.random()<<0).toString(16)).slice(-6)},i.rgb2hex=function(t,i,e){return(t<<16|i<<8|e).toString(16)},i.hex2rgb=function(t){var i=Math.floor("0x"+t),e=i>>16&255,s=i>>8&255,n=255&i;return[e,s,n]},i.Object=function(){this.initialize.apply(this,arguments)},a(i.Object.prototype,{x:0,y:0,z:0,position:function(t,i,e){switch(arguments.length){case 1:this.x=t,this.y=t,this.z=t;break;case 2:this.x=t,this.y=i;break;case 3:this.x=t,this.y=i,this.z=e}return this},move:function(t,i,e){switch(arguments.length){case 1:this.x+=t,this.y+=t,this.z+=t;break;case 2:this.x+=t,this.y+=i;break;case 3:this.x+=t,this.y+=i,this.z+=e}return this},rotationX:0,rotationY:0,rotationZ:0,rotation:function(t,i,e){switch(arguments.length){case 1:this.rotationX=t,this.rotationY=t,this.rotationZ=t;break;case 2:this.rotationX=t,this.rotationY=i;break;case 3:this.rotationX=t,this.rotationY=i,this.rotationZ=e}return this},rotate:function(t,i,e){switch(arguments.length){case 1:this.rotationX+=t,this.rotationY+=t,this.rotationZ+=t;break;case 2:this.rotationX+=t,this.rotationY+=i;break;case 3:this.rotationX+=t,this.rotationY+=i,this.rotationZ+=e}return this},scaleX:1,scaleY:1,scaleZ:1,scale:function(t,i,e){switch(arguments.length){case 1:this.scaleX=t,this.scaleY=t,this.scaleZ=t;break;case 2:this.scaleX=t,this.scaleY=i;break;case 3:this.scaleX=t,this.scaleY=i,this.scaleZ=e}return this},width:0,height:0,depth:0,size:function(t,i,e){switch(arguments.length){case 1:this.width=t,this.height=t,this.depth=t;break;case 2:this.width=t,this.height=i;break;case 3:this.width=t,this.height=i,this.depth=e}return this},originX:0,originY:0,originZ:0,__orgO:{x:0,y:0,z:0},__orgT:{x:0,y:0,z:0},__orgF:{x:0,y:0,z:0},origin:function(t,i,e){switch(arguments.length){case 1:this.originX=t,this.originY=t,this.originZ=t;break;case 2:this.originX=t,this.originY=i;break;case 3:this.originX=t,this.originY=i,this.originZ=e}return this},__name:"",name:function(t){return this.__name=t,""==t?delete this.el.dataset.name:this.el.dataset.name=t,this},__sort:["X","Y","Z"],sort:function(t,i,e){if(arguments.length>3)throw"sort arguments is wrong!";return this.__sort=[t,i,e],this},initialize:function(){this.x=0,this.y=0,this.z=0,this.rotationX=0,this.rotationY=0,this.rotationZ=0,this.scaleX=1,this.scaleY=1,this.scaleZ=1,this.width=0,this.height=0,this.depth=0,this.originX="50%",this.originY="50%",this.originZ="0px",this.__orgO={x:"50%",y:"50%",z:"0px"},this.__orgT={x:"-50%",y:"-50%",z:"0px"},this.__orgF={x:0,y:0,z:0},this.children=[],this.__name=""},parent:null,children:null,addChild:function(t){if(null!=t.parent&&t.parent.removeChild(t),""!=t.__name){if(void 0!==this[t.__name])throw t.__name+" already exist!";this[t.__name]=t}return this.children.push(t),t.parent=this,this},removeChild:function(t){for(var i=this.children.length-1;i>=0;i--)if(this.children[i]===t)return""!=t.__name&&delete this[t.__name],this.children.splice(i,1),t.parent=null,this;return this},removeAllChild:function(){for(var t=this.children.length-1;t>=0;t--){var i=this.children[t];""!=i.__name&&delete this[i.__name],i.parent=null}return this.children=[],this},remove:function(){return null!=this.parent&&this.parent.removeChild(this),this}}),i.Object.extend=o,i.Sprite=i.Object.extend({el:null,alpha:1,visible:!0,initialize:function(t){i.Sprite.__super__.initialize.apply(this,[t]),this.alpha=1,this.visible=!0;var e;if(t&&t.el)switch(typeof t.el){case"string":e=document.createElement("div"),e.innerHTML=t.el;break;case"object":1===t.el.nodeType&&(e=t.el)}e||(e=document.createElement("div")),e.style.position="absolute",e.style[l+"Transform"]="translateZ(0px)",e.style[l+"TransformStyle"]="preserve-3d",this.el=e,e.le=this},update:function(){return this.updateS(),this.updateM(),this.updateO(),this.updateT(),this.updateV(),this},updateS:function(){return this},updateM:function(){if(!this.__mat)return this;for(var t in this.__mat)switch(t){case"bothsides":this.el.style[l+"BackfaceVisibility"]=this.__mat[t]?"visible":"hidden";break;case"image":this.el.style["background"+n(t)]=""!==this.__mat[t]?"url("+this.__mat[t]+")":"";break;default:this.el.style["background"+n(t)]=this.__mat[t]}return this},updateO:function(){if("number"==typeof this.originX){var t=e(this.originX-this.__orgF.x);this.__orgO.x=t+"px",this.__orgT.x=-t+"px"}else this.__orgO.x=this.originX,this.__orgT.x="-"+this.originX;if("number"==typeof this.originY){var i=e(this.originY-this.__orgF.y);this.__orgO.y=i+"px",this.__orgT.y=-i+"px"}else this.__orgO.y=this.originY,this.__orgT.y="-"+this.originY;if("number"==typeof this.originZ){var s=e(this.originZ-this.__orgF.z);this.__orgO.z=s+"px",this.__orgT.z=-s+"px"}else this.__orgO.z=this.__orgT.z="0px";return this.el.style[l+"TransformOrigin"]=this.__orgO.x+" "+this.__orgO.y+" "+this.__orgO.z,this},updateT:function(){var t=this.__sort[0],i=this.__sort[1],e=this.__sort[2];return this.el.style[l+"Transform"]="translate3d("+this.__orgT.x+", "+this.__orgT.y+", "+this.__orgT.z+") translate3d("+s(this.x)+"px,"+s(this.y)+"px,"+s(this.z)+"px) rotate"+t+"("+s(this["rotation"+t])%360+"deg) rotate"+i+"("+s(this["rotation"+i])%360+"deg) rotate"+e+"("+s(this["rotation"+e])%360+"deg) scale3d("+s(this.scaleX)+", "+s(this.scaleY)+", "+s(this.scaleZ)+") ",this},updateV:function(){return this.el.style.opacity=this.alpha,this.el.style.display=this.visible?"block":"none",this},addChild:function(t){return i.Sprite.__super__.addChild.apply(this,[t]),this.el&&t.el&&this.el.appendChild(t.el),this},removeChild:function(t){for(var i=this.children.length-1;i>=0;i--)if(this.children[i]===t)return""!=t.__name&&delete this[t.__name],this.children.splice(i,1),t.parent=null,this.el.removeChild(t.el),this;return this},removeAllChild:function(){for(var t=this.children.length-1;t>=0;t--){var i=this.children[t];""!=i.__name&&delete this[i.__name],i.parent=null,this.el.removeChild(i.el)}return this.children=[],this},on:function(t){if("object"==typeof t)for(var i in t)this.el.addEventListener(i,t[i],!1);else 2===arguments.length?this.el.addEventListener(arguments[0],arguments[1],!1):3===arguments.length&&this.el.addEventListener(arguments[0],arguments[1],arguments[2]);return this},off:function(t){if("object"==typeof t)for(var i in t)this.el.removeEventListener(i,t[i],!1);else 2===arguments.length&&this.el.removeEventListener(arguments[0],arguments[1],!1);return this},buttonMode:function(t){return this.el.style.cursor=t?"pointer":"auto",this},__mat:null,material:function(t){return this.__mat=t,this},visibility:function(t){return void 0!==t.visible&&(this.visible=t.visible),void 0!==t.alpha&&(this.alpha=t.alpha),this}}),i.Stage=i.Sprite.extend({camera:null,fov:null,__rfix:null,__pfix:null,initialize:function(t){i.Stage.__super__.initialize.apply(this,[t]),t&&t.el||(this.el.style.top="0px",this.el.style.left="0px",this.el.style.width="0px",this.el.style.height="0px"),this.el.style[l+"Perspective"]="800px",this.el.style[l+"TransformStyle"]="flat",this.el.style[l+"Transform"]="",this.el.style.overflow="hidden",this.__rfix=new i.Sprite,this.el.appendChild(this.__rfix.el),this.__pfix=new i.Sprite,this.__rfix.el.appendChild(this.__pfix.el),this.setCamera(new i.Camera)},updateS:function(){return this.el.style.width=e(this.width)+"px",this.el.style.height=e(this.height)+"px",this},updateT:function(){return this.fov=e(.5/Math.tan(.5*this.camera.fov/180*Math.PI)*this.height),this.el.style[l+"Perspective"]=this.fov+"px",this.__rfix.position(e(this.width/2),e(this.height/2),this.fov).rotation(-this.camera.rotationX,-this.camera.rotationY,-this.camera.rotationZ).updateT(),this.__pfix.position(-this.camera.x,-this.camera.y,-this.camera.z).updateT(),this},addChild:function(t){return this.__pfix.addChild(t),this},removeChild:function(t){return this.__pfix.removeChild(t),this},setCamera:function(t){return this.camera&&(this.camera.stage=null),this.camera=t,this.camera.stage=this,this}}),i.Camera=i.Object.extend({fov:null,stage:null,initialize:function(t){i.Camera.__super__.initialize.apply(this,[t]),this.fov=75},update:function(){return this.updateT(),this},updateS:function(){return this},updateM:function(){return this},updateT:function(){return this.stage&&this.stage.updateT(),this},updateV:function(){return this}}),i.Plane=i.Sprite.extend({initialize:function(t){i.Plane.__super__.initialize.apply(this,[t])},update:function(){return i.Plane.__super__.update.apply(this),this.updateF(),this},updateS:function(){return this.el.style.width=e(this.width)+"px",this.el.style.height=e(this.height)+"px",this},updateF:function(){if(!this.__flt)return this;var t="";for(var i in this.__flt)t+=""!==this.__flt[i]?i+"("+this.__flt[i].join(",")+")":"";return""!==t&&(this.el.style[l+"Filter"]=t),this},__flt:null,filter:function(t){return this.__flt=t,this}}),i.Box=i.Sprite.extend({front:null,back:null,left:null,right:null,up:null,down:null,initialize:function(t){i.Box.__super__.initialize.apply(this,[t]),this.front=new i.Plane,this.front.name="front",this.addChild(this.front),this.back=new i.Plane,this.back.name="back",this.addChild(this.back),this.left=new i.Plane,this.left.name="left",this.addChild(this.left),this.right=new i.Plane,this.right.name="right",this.addChild(this.right),this.up=new i.Plane,this.up.name="up",this.addChild(this.up),this.down=new i.Plane,this.down.name="down",this.addChild(this.down)},update:function(){return i.Box.__super__.update.apply(this),this.updateF(),this},updateS:function(){var t=e(this.width),i=e(this.height),s=e(this.depth);return this.__orgF.x=this.width/2,this.__orgF.y=this.height/2,this.__orgF.z=this.depth/2,this.front.size(t,i,0).position(0,0,s/2).rotation(0,0,0).updateS().updateT(),this.back.size(t,i,0).position(0,0,-s/2).rotation(0,180,0).updateS().updateT(),this.left.size(s,i,0).position(-t/2,0,0).rotation(0,-90,0).updateS().updateT(),this.right.size(s,i,0).position(t/2,0,0).rotation(0,90,0).updateS().updateT(),this.up.size(t,s,0).position(0,-i/2,0).rotation(90,0,0).updateS().updateT(),this.down.size(t,s,0).position(0,i/2,0).rotation(-90,0,0).updateS().updateT(),this},updateM:function(){if(!this.__mat)return this;for(var t in this.__mat)switch(t){case"front":case"back":case"left":case"right":case"up":case"down":this[t].material({image:this.__mat[t],bothsides:!1}).updateM();break;default:this.front.material(this.__mat).updateM(),this.back.material(this.__mat).updateM(),this.left.material(this.__mat).updateM(),this.right.material(this.__mat).updateM(),this.up.material(this.__mat).updateM(),this.down.material(this.__mat).updateM()}return this},updateF:function(){return this.__flt?(this.front.filter(this.__flt).updateF(),this.back.filter(this.__flt).updateF(),this.left.filter(this.__flt).updateF(),this.right.filter(this.__flt).updateF(),this.up.filter(this.__flt).updateF(),this.down.filter(this.__flt).updateF(),this):this},__flt:null,filter:function(t){return this.__flt=t,this}}),i.Skybox=i.Box.extend({updateS:function(){var t=e(this.width),i=e(this.height),s=e(this.depth);return this.__orgF.x=this.width/2,this.__orgF.y=this.height/2,this.__orgF.z=this.depth/2,this.front.size(t,i,0).position(0,0,-s/2).rotation(0,0,0).updateS().updateT(),this.back.size(t,i,0).position(0,0,s/2).rotation(0,180,0).updateS().updateT(),this.left.size(s,i,0).position(-t/2,0,0).rotation(0,90,0).updateS().updateT(),this.right.size(s,i,0).position(t/2,0,0).rotation(0,-90,0).updateS().updateT(),this.up.size(t,s,0).position(0,-i/2,0).rotation(-90,0,0).updateS().updateT(),this.down.size(t,s,0).position(0,i/2,0).rotation(90,0,0).updateS().updateT(),this}}),i.create=function(t){var i;switch(typeof t){case"array":i={type:"sprite",children:t};break;case"object":i=t;break;default:return}return r(i)},i});