text: ﻿(function(){"use strict";var n=function(n){THREE.MeshLambertMaterial.call(this);this.depthTest=!1;this.depthWrite=!1;this.side=THREE.FrontSide;this.transparent=!0;this.setValues(n);this.oldColor=this.color.clone();this.oldOpacity=this.opacity;this.highlight=function(n){n?this.color.setRGB(1,1,0):(this.color.copy(this.oldColor),this.opacity=this.oldOpacity)}};n.prototype=Object.create(THREE.MeshLambertMaterial.prototype);n.prototype.constructor=n;THREE.TransformGizmo=function(){var n=this,t=!1,i=!1;this.init=function(){var r,i,t,n,u;THREE.Object3D.call(this);this.handles=new THREE.Object3D;this.pickers=new THREE.Object3D;this.planes=new THREE.Object3D;this.add(this.handles);this.add(this.pickers);this.add(this.planes);r=new THREE.PlaneBufferGeometry(50,50,2,2);i=new THREE.MeshBasicMaterial({wireframe:!0});i.side=THREE.DoubleSide;t={XY:new THREE.Mesh(r,i),YZ:new THREE.Mesh(r,i),XZ:new THREE.Mesh(r,i),XYZE:new THREE.Mesh(r,i)};this.activePlane=t.XYZE;t.YZ.rotation.set(0,Math.PI/2,0);t.XZ.rotation.set(-Math.PI/2,0,0);for(n in t)t[n].name=n,this.planes.add(t[n]),this.planes[n]=t[n],t[n].visible=!1;u=function(t,i){for(var r in t)for(n=t[r].length;n--;){var u=t[r][n][0],f=t[r][n][1],e=t[r][n][2];u.name=r;f&&u.position.set(f[0],f[1],f[2]);e&&u.rotation.set(e[0],e[1],e[2]);i.add(u)}};u(this.handleGizmos,this.handles);u(this.pickerGizmos,this.pickers);this.traverse(function(n){if(n instanceof THREE.Mesh){n.updateMatrix();var t=n.geometry.clone();t.applyMatrix(n.matrix);n.geometry=t;n.position.set(0,0,0);n.rotation.set(0,0,0);n.scale.set(1,1,1)}})};this.hide=function(){this.traverse(function(n){n.visible=!1})};this.show=function(){this.traverse(function(i){i.visible=!0;i.parent==n.pickers&&(i.visible=t);i.parent==n.planes&&(i.visible=!1)});this.activePlane.visible=i};this.highlight=function(n){this.traverse(function(t){t.material&&t.material.highlight&&(t.name==n?t.material.highlight(!0):t.material.highlight(!1))})}};THREE.TransformGizmo.prototype=Object.create(THREE.Object3D.prototype);THREE.TransformGizmo.prototype.constructor=THREE.TransformGizmo;THREE.TransformGizmo.prototype.update=function(n,t){var i=new THREE.Vector3(0,0,0),r=new THREE.Vector3(0,1,0),u=new THREE.Matrix4;this.traverse(function(f){f.name.search("E")!=-1?f.quaternion.setFromRotationMatrix(u.lookAt(t,i,r)):(f.name.search("X")!=-1||f.name.search("Y")!=-1||f.name.search("Z")!=-1)&&f.quaternion.setFromEuler(n)})};THREE.TransformGizmoRotate=function(){THREE.TransformGizmo.call(this);this.handleGizmos={Y:[[new THREE.Mesh(new THREE.TorusGeometry(1.5,.25,8,16,2*Math.PI),new n({color:65280,opacity:.5})),[0,0,0],[Math.PI/2,0,0]]]};this.pickerGizmos={Y:[[new THREE.Mesh(new THREE.TorusGeometry(1.5,.5,4,12,2*Math.PI),new n({color:65280,opacity:.25})),[0,0,0],[Math.PI/2,0,0]]]};this.setActivePlane=function(n){n=="E"&&(this.activePlane=this.planes.XYZE);n=="X"&&(this.activePlane=this.planes.YZ);n=="Y"&&(this.activePlane=this.planes.XZ);n=="Z"&&(this.activePlane=this.planes.XY);this.hide();this.show()};this.update=function(n,t){THREE.TransformGizmo.prototype.update.apply(this,arguments);var u=new THREE.Matrix4,f=new THREE.Euler(0,0,1),i=new THREE.Quaternion,h=new THREE.Vector3(1,0,0),c=new THREE.Vector3(0,1,0),l=new THREE.Vector3(0,0,1),e=new THREE.Quaternion,o=new THREE.Quaternion,s=new THREE.Quaternion,r=t.clone();f.copy(this.planes.XY.rotation);i.setFromEuler(f);u.makeRotationFromQuaternion(i).getInverse(u);r.applyMatrix4(u);this.traverse(function(n){i.setFromEuler(f);n.name=="X"&&(e.setFromAxisAngle(h,Math.atan2(-r.y,r.z)),i.multiplyQuaternions(i,e),n.quaternion.copy(i));n.name=="Y"&&(o.setFromAxisAngle(c,Math.atan2(r.x,r.z)),i.multiplyQuaternions(i,o),n.quaternion.copy(i));n.name=="Z"&&(s.setFromAxisAngle(l,Math.atan2(r.y,r.x)),i.multiplyQuaternions(i,s),n.quaternion.copy(i))})};this.init()};THREE.TransformGizmoRotate.prototype=Object.create(THREE.TransformGizmo.prototype);THREE.TransformGizmoRotate.prototype.constructor=THREE.TransformGizmoRotate;THREE.TransformControls=function(n,t){function g(n){if(i.object!==undefined&&s!==!0){n.preventDefault();var f=n.changedTouches?n.changedTouches[0]:n,u=b(f,i.gizmo[r].pickers.children),t=null;u&&(t=u.object.name);i.axis!==t&&(i.axis=t,i.update(),i.dispatchEvent(c))}}function ht(n){var t,u,f;i.object!==undefined&&s!==!0&&(n.preventDefault(),n.stopPropagation(),t=n.changedTouches?n.changedTouches[0]:n,(t.button===0||t.button===undefined)&&(u=b(t,i.gizmo[r].pickers.children),u&&(i.dispatchEvent(lt),i.axis=u.object.name,i.update(),l.copy(h).sub(o).normalize(),i.gizmo[r].setActivePlane(i.axis,l),f=b(t,[i.gizmo[r].activePlane]),wt.copy(i.object.position),bt.copy(i.object.scale),et.extractRotation(i.object.matrix),st.extractRotation(i.object.matrixWorld),kt.extractRotation(i.object.parent.matrixWorld),d.setFromMatrixScale(a.getInverse(i.object.parent.matrixWorld)),it.copy(f.point))),s=!0)}function ct(n){if(i.object!==undefined&&i.axis!==null&&s!==!1){n.preventDefault();n.stopPropagation();var t=n.changedTouches?n.changedTouches[0]:n,h=b(t,[i.gizmo[r].activePlane]);u.copy(h.point);r=="rotate"&&(u.sub(o),u.multiply(d),f.copy(it).sub(o),f.multiply(d),i.space=="local"&&(u.applyMatrix4(a.getInverse(st)),f.applyMatrix4(a),y.set(Math.atan2(u.z,u.y),Math.atan2(u.x,u.z),Math.atan2(u.y,u.x)),p.set(Math.atan2(f.z,f.y),Math.atan2(f.x,f.z),Math.atan2(f.y,f.x)),e.setFromRotationMatrix(et),rt.setFromAxisAngle(vt,y.x-p.x),ut.setFromAxisAngle(yt,y.y-p.y),ft.setFromAxisAngle(pt,y.z-p.z),i.axis=="X"&&e.multiplyQuaternions(e,rt),i.axis=="Y"&&e.multiply(ut),i.axis=="Z"&&e.multiplyQuaternions(e,ft),i.object.quaternion.copy(e)));i.update();i.dispatchEvent(c);i.dispatchEvent(at)}}function v(n){s&&i.axis!==null&&(nt.mode=r,i.dispatchEvent(nt));s=!1;g(n)}function b(i,r){var u=t.getBoundingClientRect(),e=(i.clientX-u.left)/u.width,o=(i.clientY-u.top)/u.height,f;return k.set(e*2-1,-(o*2)+1,.5),k.unproject(n),tt.set(h,k.sub(h).normalize()),f=tt.intersectObjects(r,!0),f[0]?f[0]:!1}THREE.Object3D.call(this);t=t!==undefined?t:document;this.gizmo={};this.gizmo.rotate=new THREE.TransformGizmoRotate;this.add(this.gizmo.rotate);this.gizmo.rotate.hide();this.object=undefined;this.snap=null;this.space="world";this.size=1;this.axis=null;var i=this,s=!1,r="translate",c={type:"change"},lt={type:"mouseDown"},nt={type:"mouseUp",mode:r},at={type:"objectChange"},tt=new THREE.Raycaster,k=new THREE.Vector3,u=new THREE.Vector3,it=new THREE.Vector3,y=new THREE.Vector3,p=new THREE.Vector3,w=1,gt=new THREE.Matrix4,l=new THREE.Vector3,a=new THREE.Matrix4,f=new THREE.Vector3,ni=new THREE.Quaternion,vt=new THREE.Vector3(1,0,0),yt=new THREE.Vector3(0,1,0),pt=new THREE.Vector3(0,0,1),e=new THREE.Quaternion,rt=new THREE.Quaternion,ut=new THREE.Quaternion,ft=new THREE.Quaternion,ti=new THREE.Quaternion,wt=new THREE.Vector3,bt=new THREE.Vector3,et=new THREE.Matrix4,kt=new THREE.Matrix4,d=new THREE.Vector3,o=new THREE.Vector3,ot=new THREE.Euler,st=new THREE.Matrix4,h=new THREE.Vector3,dt=new THREE.Euler;t.addEventListener("mousedown",ht,!1);t.addEventListener("touchstart",ht,!1);t.addEventListener("mousemove",g,!1);t.addEventListener("touchmove",g,!1);t.addEventListener("mousemove",ct,!1);t.addEventListener("touchmove",ct,!1);t.addEventListener("mouseup",v,!1);t.addEventListener("mouseout",v,!1);t.addEventListener("touchend",v,!1);t.addEventListener("touchcancel",v,!1);t.addEventListener("touchleave",v,!1);this.attach=function(n){i.object=n;this.gizmo.rotate.hide();this.gizmo[r].show();i.update()};this.detach=function(){i.object=undefined;this.axis=null;this.gizmo.rotate.hide()};this.setMode=function(n){r=n?n:r;r=="scale"&&(i.space="local");this.gizmo.rotate.hide();this.gizmo[r].show();this.update();i.dispatchEvent(c)};this.setSnap=function(n){i.snap=n};this.setSize=function(n){i.size=n;this.update();i.dispatchEvent(c)};this.setSpace=function(n){i.space=n;this.update();i.dispatchEvent(c)};this.update=function(){i.object!==undefined&&(i.object.updateMatrixWorld(),o.setFromMatrixPosition(i.object.matrixWorld),ot.setFromRotationMatrix(a.extractRotation(i.object.matrixWorld)),n.updateMatrixWorld(),h.setFromMatrixPosition(n.matrixWorld),dt.setFromRotationMatrix(a.extractRotation(n.matrixWorld)),w=o.distanceTo(h)/6*i.size,this.position.copy(o),this.scale.set(w,w,w),l.copy(h).sub(o).normalize(),i.space=="local"?this.gizmo[r].update(ot,l):i.space=="world"&&this.gizmo[r].update(new THREE.Euler,l),this.gizmo[r].highlight(i.axis))}};THREE.TransformControls.prototype=Object.create(THREE.Object3D.prototype);THREE.TransformControls.prototype.constructor=THREE.TransformControls})();
  //# sourceMappingURL=TransformControls.fixed.min.js.map
  