1 |
- !function(t){function i(o){if(e[o])return e[o].exports;var s=e[o]={exports:{},id:o,loaded:!1};return t[o].call(s.exports,s,s.exports,i),s.loaded=!0,s.exports}var e={};return i.m=t,i.c=e,i.p="",i(0)}([function(t,i,e){if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");var o=THREE.Math.degToRad,s=e(1);AFRAME.registerComponent("lerp",{schema:{properties:{default:["position","rotation","scale"]}},init:function(){var t=this.el;this.lastPosition=t.getAttribute("position"),this.lastRotation=t.getAttribute("rotation"),this.lastScale=t.getAttribute("scale"),this.lerpingPosition=!1,this.lerpingRotation=!1,this.lerpingScale=!1,this.timeOfLastUpdate=0},tick:function(t,i){var e,o=this.now(),s=this.el.object3D;this.checkForComponentChanged(),this.lerpingPosition&&(e=(o-this.startLerpTimePosition)/this.duration,s.position.lerpVectors(this.startPosition,this.targetPosition,e),e>=1&&(this.lerpingPosition=!1)),this.lerpingRotation&&(e=(o-this.startLerpTimeRotation)/this.duration,THREE.Quaternion.slerp(this.startRotation,this.targetRotation,s.quaternion,e),e>=1&&(this.lerpingRotation=!1)),this.lerpingScale&&(e=(o-this.startLerpTimeScale)/this.duration,s.scale.lerpVectors(this.startScale,this.targetScale,e),e>=1&&(this.lerpingScale=!1))},checkForComponentChanged:function(){var t=this.el,i=!1,e=t.getAttribute("position");this.isLerpable("position")&&!this.almostEqualVec3(this.lastPosition,e)&&(this.toPosition(this.lastPosition,e),this.lastPosition=e,i=!0);var o=t.getAttribute("rotation");this.isLerpable("rotation")&&!this.almostEqualVec3(this.lastRotation,o)&&(this.toRotation(this.lastRotation,o),this.lastRotation=o,i=!0);var s=t.getAttribute("scale");this.isLerpable("scale")&&!this.almostEqualVec3(this.lastScale,s)&&(this.toScale(this.lastScale,s),this.lastScale=s,i=!0),i&&this.updateDuration()},isLerpable:function(t){return this.data.properties.indexOf(t)!=-1},updateDuration:function(){var t=this.now();this.duration=t-this.timeOfLastUpdate,this.timeOfLastUpdate=t},toPosition:function(t,i){this.lerpingPosition=!0,this.startLerpTimePosition=this.now(),this.startPosition=new THREE.Vector3(t.x,t.y,t.z),this.targetPosition=new THREE.Vector3(i.x,i.y,i.z)},toRotation:function(t,i){this.lerpingRotation=!0,this.startLerpTimeRotation=this.now(),this.startRotation=new THREE.Quaternion,this.startRotation.setFromEuler(new THREE.Euler(o(t.x),o(t.y),o(t.z),"YXZ")),this.targetRotation=new THREE.Quaternion,this.targetRotation.setFromEuler(new THREE.Euler(o(i.x),o(i.y),o(i.z),"YXZ"))},toScale:function(t,i){this.lerpingScale=!0,this.startLerpTimeScale=this.now(),this.startScale=new THREE.Vector3(t.x,t.y,t.z),this.targetScale=new THREE.Vector3(i.x,i.y,i.z)},almostEqualVec3:function(t,i){return s(t.x,i.x)&&s(t.y,i.y)&&s(t.z,i.z)},now:function(){return Date.now()}})},function(t,i){"use strict";function e(t,i,n,a){var r=o(t-i);return null==n&&(n=e.DBL_EPSILON),null==a&&(a=n),r<=n||(r<=a*s(o(t),o(i))||t===i)}var o=Math.abs,s=Math.min;e.FLT_EPSILON=1.1920929e-7,e.DBL_EPSILON=2.220446049250313e-16,t.exports=e}]);
|