/** * animation-utilities - Animation utilities for Jibo's coordinated expression output * @version v2.8.3 * * IFR components: Copyright (c) 2011-2017, IF Robots LLC. All rights reserved. * Other components: Copyright (c) 2012-2017, Jibo, Inc. All rights reserved. * * IFR components provided to Jibo, Inc. by IF Robots LLC for use only in the Jibo SDK. * * All use of the Jibo SDK is subject to the Jibo SDK End User License Agreement (EULA) * distributed herewith. If you did not receive a copy of the EULA, you may view a * copy at https://developers.jibo.com/license. */ !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.animationUtilities=t()}}(function(){return function t(e,o,i){function n(s,a){if(!o[s]){if(!e[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(r)return r(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=o[s]={exports:{}};e[s][0].call(u.exports,function(t){var o=e[s][1][t];return n(o?o:t)},u,u.exports,t,e,o,i)}return o[s].exports}for(var r="function"==typeof require&&require,s=0;sg&&(g=D)}this.minTransitionTime&&this.minTransitionTime>g&&(g=this.minTransitionTime);var O={};for(h=0;h1e-10?O[a]=this.planner.computeWithFixedTime(c,0,u-l,g):O[a]=null);var L;for(h=0;h-1?n.set(o[r],i.get(o[r],0)*e,0):n.set(o[r],i.get(o[r],0)*t,0);var s=this.timeline.getClock().currentTime();this.timeline.add(new d(this,"eye scale motion",s,n,.5),"default"),this.globalAnimationDelegate&&this.globalAnimationDelegate("ADDED",null,{dofs:n.getDOFNames(),layer:"default",instant:"setEyeScaleXY instant"})},b.prototype.setEyePosition=function(t,e){var o=this.robotInfo.getDOFSet("EYE_TRANSLATE").getDOFs(),i=this.robotInfo.getDOFSet("OVERLAY_TRANSLATE").getDOFs(),n=new a("eye pose",o.concat(i));n.set(o[0],t,0),n.set(o[1],e,0),n.set(i[0],t,0),n.set(i[1],e,0);var r=this.timeline.getClock().currentTime();this.timeline.add(new d(this,"eye position motion",r,n,.5),"default"),this.globalAnimationDelegate&&this.globalAnimationDelegate("ADDED",null,{dofs:n.getDOFNames(),layer:"default",instant:"setEyePosition instant"})},b.prototype.setLEDColor=function(t){var e=null;e=Array.isArray(t)?t:t.toArray();for(var o=this.robotInfo.getDOFSet("LED").getDOFs(),i=new a("LED pose",o),n=0;n<3;n++)i.set(o[n],e[n],0);var r=this.timeline.getClock().currentTime();this.timeline.add(new d(this,"LED motion",r,i,.5),"default"),this.globalAnimationDelegate&&this.globalAnimationDelegate("ADDED",null,{dofs:i.getDOFNames(),layer:"default",instant:"setLEDColor instant"})},b.prototype.centerRobot=function(t,e,o){void 0!==t&&null!==t||(t=this.dofs.ALL),void 0!==e&&null!==e||(e=!1);var i=r.createFromPose("center motion",this.robotInfo.getKinematicInfo().getDefaultPose(),1/30,t.getDOFs()),n=new P(this,this.timeline,new s(i),this.defaultTransition.clone(),this.robotInfo,"default",this.globalAnimationDelegate),a=1,l=e&&t.hasDOF(this.dofs.BASE.getDOFs()[0]),c=null;if(l&&(c=this.createLookatBuilder(),c.setDOFs(this.dofs.BASE),a++),o){var u=function(){a--,0===a&&o()};n.on(I.AnimationEventType.CANCELLED,u),n.on(I.AnimationEventType.STOPPED,u),c&&(c.on(I.LookatEventType.CANCELLED,u),c.on(I.LookatEventType.STOPPED,u))}n.play(),c&&c.startLookat(new T.Vector3(1,0,0))},b.prototype.getKinematicFeatures=function(){var t=this.timeline.getCurrentState();return(null===this.kinematicFeatureGenerationTime||t.getTime().isGreater(this.kinematicFeatureGenerationTime))&&(this.kinematicFeatureGenerationTime=t.getTime(),this.kinematicFeatureComputed=this.kinematicFeaturesReporter.computeFeatures(t.getPose())),this.kinematicFeatureComputed},b.prototype.setDefaultTransition=function(t){this.defaultTransition=t},b.prototype.getDefaultTransition=function(){return this.defaultTransition},b.prototype.createLinearTransitionBuilder=function(){return I.trajectory.createLinearTransitionBuilder(this.robotInfo)},b.prototype.createAccelerationTransitionBuilder=function(t,e){return I.trajectory.createAccelerationTransitionBuilder(this.robotInfo,t,e)},b.prototype.installRenderPlugin=function(t){for(var e=i(this.timeline),o=0;o0?function(n){var r;if(e&&e(I.AnimationEventType.EVENT,t,{eventName:n.getEventName(),payload:n.getPayload()}),o)for(r=0;r-1&&this.dofNames.push(t[e])},P.prototype.getDOFs=function(){return this.dofNames},P.prototype.setPlayBounds=function(t,e){null!==t&&void 0!==t||(t=0),null!==e&&void 0!==e||(e=this.getSourceAnimationDuration()),this.clip=new l(t,e,this.clip.getSpeed())},P.prototype.getSourceAnimationDuration=function(){return this.motion.getMotion().getDuration()},P.prototype.getConfiguredAnimationDuration=function(){return this.clip.getDuration()},P.prototype.setTransitionIn=function(t){this.transition=t},P.prototype.getTransitionIn=function(){return this.transition},P.prototype.setStopOrient=function(t){this.stopOrient=t},P.prototype.setLayer=function(t){null===this.timeline.getDOFsForLayer(t)?_.error("AnimationBuilder: ignoring setLayer with unknown layer name: "+t):(this.layer=t,this.layerDOFs=this.timeline.getDOFsForLayer(t),this.setDOFs(this.dofNames.slice(0)))};var N={};N.prototype={stop:function(){},updateTarget:function(t){},getTarget:function(){},getBuilder:function(){},getName:function(){}};var E={};E.prototype={startLookat:function(t){},on:function(t,e){},off:function(t,e){},setDOFs:function(t){},getDOFs:function(){},setOrientFully:function(t){},setContinuousMode:function(t){}};var I={MODALITY_NAME:"MOTION",createAnimationUtilities:function(t,e){var o=new b;return t&&e&&o.init(t,e),o}};I.trajectory={getAnimation:function(t,e,o){var i;o||(i=F[t]),i?e&&e(new s(i.motion,i.events)):w.load(t,function(){var o=w.getResult();o.success?(F[t]=o,e&&e(new s(o.motion,o.events))):(_.error("animation load failed, "+o.message+' with URL:"'+t+'"'),e&&e(null))})},parseAnimation:function(t,e,o){var i=null;if(o&&(i=F[o]),i)return new s(i.motion,i.events);var r=new n;if(e){var a=e.slice(-1);"/"!==a&&"\\"!==a&&(e+="/"),r.resolvePaths=!0}else r.resolvePaths=!1;r.parseData(t,e);var l=r.getResult();return l.success?(o&&(F[o]=l),new s(l.motion,l.events)):(_.error("animation parse failed: "+l.message),null)},createLinearTransitionBuilder:function(t){return new u(t)},createAccelerationTransitionBuilder:function(t,e,o){return new h(t,e,o)}};var R={STARTED:"STARTED",STOPPED:"STOPPED",CANCELLED:"CANCELLED",EVENT:"EVENT"};I.AnimationEventType=R;var M={STARTED:"STARTED",TARGET_REACHED:"TARGET_REACHED",TARGET_SUPERSEDED:"TARGET_SUPERSEDED",STOPPED:"STOPPED",CANCELLED:"CANCELLED"};I.LookatEventType=M,e.exports=I},{"../animation-visualize/RendererOutput":41,"../geometry-info/DOFSet":43,"../ifr-core/SLog":55,"../ifr-motion/base/AnnotatedMotion":66,"../ifr-motion/base/Motion":72,"../ifr-motion/base/MotionEventIterator":74,"../ifr-motion/base/Pose":76,"../ifr-motion/base/RelativeTimeClip":77,"../ifr-motion/loaders/AnimationLoader":94,"../ifr-motion/lookat/KinematicFeaturesReporter":98,"../ifr-motion/lookat/PlaneDisplacementLookatDOF":108,"./AccelerationTransitionBuilder":1,"./LinearTransitionBuilderImpl":3,"./SingleLookatBuilder":4,"./timeline/LoopedMotionGenerator":13,"./timeline/PoseMotionGenerator":17,"./timeline/SimpleMotionGenerator":21,"./timeline/TimelineEventDispatcher":22,"./timeline/VariableSpeedMotionGenerator":23,three:void 0}],3:[function(t,e,o){"use strict";var i=t("../ifr-motion/base/Motion"),n=t("../ifr-motion/base/MotionTrack"),r=t("../ifr-motion/base/TimestampedBuffer"),s=t("./TransitionBuilder"),a=function(t){s.call(this),this._transitionTime=1,this._defaultMaxVelocity=null,this._maxVelocityByDOF=null,this._robotInfo=t};a.prototype=Object.create(s.prototype),a.prototype.constructor=a,a.prototype.setTransitionTime=function(t){this._transitionTime=t,this._defaultMaxVelocity=null,this._maxVelocityByDOF=null},a.prototype.setMaxVelocity=function(t,e){this._defaultMaxVelocity=t,this._maxVelocityByDOF=e,this._transitionTime=null},a.prototype.generateTransition=function(t,e,o,s){var a,l,c,u;for(u=0;um&&(m=T)}for(u=0;u.001;){f(S,"Creating lookat pose at time "+b.subtract(s)+" with remaining:"+P),c.generatePose(D,Y,r,b),P=c.getDistanceRemaining();var N=new h("Pose "+b,Y.getDOFNames());N.setPose(Y),k.push(N),C.push(b.subtract(s)),D.setPose(Y),b=b.add(1/30)}var I=p.createFromPoses("ToLook",k,C,b.subtract(s));L=new m(t,I,s,o)}else{c.reset();var M,x=e.getCurrentState().getPose(),A=x.getCopy();for(n=0;n0){if(j){var G=p.createFromPose("zero motion",o.getKinematicInfo().getDefaultPose().getCopy(),1,y);e.add(new m(t,G,s,o,y),"default")}B=F.createGenerator(y),e.add(B,"lookat")}return V.setClip(L,B),E&&E("ADDED",V,{dofs:v}),q=F,V},this.on=function(t,e){var o=H[t];o||(o=[],H[t]=o),o.indexOf(e)===-1&&o.push(e)},this.off=function(t,e){var o=H[t];if(o){var i=o.indexOf(e);i!==-1&&o.splice(i,1)}},this.setDOFs=function(t){t?t instanceof _&&(t=t.getDOFs()):t=z;for(var e=z,o=[],i=0;i-1&&o.push(t[i]);Y=new h("LookPose",o)},this.getDOFs=function(){return Y.getDOFNames().slice(0)},this.setOrientFully=function(t){j=t},this.setContinuousMode=function(t){W=t},this.setTransitionIn=function(t){N=t},this.getLookatNodeConfig=function(t){if(M.hasOwnProperty(t))return M[t];throw new Error("Cannot get config for unknown node: "+t+" (valid nodes:"+Object.keys(M)+")")},this.setLookatNodeConfig=function(t,e){if(!M.hasOwnProperty(t))throw new Error("Cannot set config for unknown node: "+t+" (valid nodes:"+Object.keys(M)+")");M[t]=e},this.getLookatDOFConfig=function(t){if(x.hasOwnProperty(t))return x[t];throw new Error("Cannot get config for unknown DOF: "+t+" (valid DOFS:"+Object.keys(x)+")")},this.setLookatDOFConfig=function(t,e){if(!x.hasOwnProperty(t))throw new Error("Cannot set config for unknown DOF: "+t+" (valid DOFS:"+Object.keys(x)+")");x[t]=e};var J=function(t){var e=H[b.STARTED];if(E||e){var o=null;return e&&(o=e.slice(0)),function(){if(E&&E(b.STARTED,t,{}),o)for(var e=0;e=0?u.push(l[p]):r(s,"Rejecting dof "+l[p]+" from lookat set as it is covered by no lookat nodes")}else u=h;i.call(this,t,"SingleLookGenerator",o),this._initWithDOFNames(u,null),this._motionLookat=e,this._target=a.clone(),this._generatedPose=new n("LMG generated pose",h),this._frozenPose=new n("LMG frozen pose",u),this._motionLookat.getPose(this._frozenPose),this._multiLayerLookatStatus=c};a.prototype=Object.create(i.prototype),a.prototype.constructor=a,a.prototype.setTarget=function(t){this._target.copy(t)},a.prototype.notifyUpdateFinished=function(t){if(t.isGreaterOrEqual(this._startTime)){var e=this._multiLayerLookatStatus.handleUpdateFinishedForGenerator(this,t);e&&(this.cropEnd(t,this.getDOFIndices()),this._interrupted=!1)}i.prototype.notifyUpdateFinished.call(this,t)},a.prototype.getDOFState=function(t,e,o){var i=this._dofEndTimes[t],n=null;return null===i||i.isGreater(this._currentTime)?(this._motionLookat.generatePoseIncremental(e.getPose(),this._generatedPose,this._target,this._currentTime,t),n=this._generatedPose.getByIndex(t),null!==n&&this._frozenPose.setByIndex(t,n)):n=this._frozenPose.getByIndex(t),null!=n?n.slice(0):null},e.exports=a},{"../../ifr-core/SLog":55,"../../ifr-motion/base/Pose":76,"./BaseMotionGenerator":8}],12:[function(t,e,o){"use strict";var i=t("../../ifr-core/SLog"),n=t("./LookatMotionGenerator"),r=t("./TimelineEventDispatcher"),s=(t("../../ifr-motion/base/Pose"),"LOOKAT"),a=function(t){this.generator=t,this.layerHasStarted=!1,this.layerHasStopped=!1,this.layerHasRemoved=!1},l=function(t,e,o,i,n){this._animUtils=t,this._layerStatuses=new Map,this._clipStartedHandler=null,this._clipStoppedHandler=null,this._clipRemovedHandler=null,this._targetReachedHandler=null,this._targetSupersededHandler=null,this._waitingToNotifyOnTarget=null,this._lookat=e,this._startTime=o,this._target=null,this._continuous=n,this._haveSentStart=!1;var r=this._animUtils.dofIndicesToNames.length;this._activeDOFMask=new Array(r).fill(!1),this.setTarget(i)};l.prototype.createGenerator=function(t){var e=new n(this._animUtils,this._lookat,this._startTime,this._target,t,this);return this._layerStatuses.set(e,new a(e)),e.setHandlers(this.handleStarted.bind(this,e),this.handleStopped.bind(this,e),this.handleRemoved.bind(this,e),null),e},l.prototype.setHandlers=function(t,e,o,i,n){this._clipStartedHandler=t,this._clipStoppedHandler=e,this._clipRemovedHandler=o,this._targetReachedHandler=i,this._targetSupersededHandler=n},l.prototype.setTarget=function(t){for(var e,o=this._layerStatuses.keys();!(e=o.next()).done;)e.value.setTarget(t);null!=this._waitingToNotifyOnTarget&&null!=this._targetSupersededHandler&&r.queueEvent(this._targetSupersededHandler,[this._waitingToNotifyOnTarget]),this._waitingToNotifyOnTarget=t.clone(),this._target=this._waitingToNotifyOnTarget},l.prototype.handleUpdateFinishedForGenerator=function(t,e){if(this._continuous&&null===this._waitingToNotifyOnTarget)return!1;for(var o,i=this._layerStatuses.keys();!(o=i.next()).done;)for(var n=o.value,s=n.getDOFIndices(),a=0;athis._durationList[l];)c-=this._durationList[l],l++;var u=this._clipList[l].getSourceTime(c),h=this._motionTracksList[l][t].getDataAtTime(u,this._interpolators[t]);return this._sourceTimeReportingFlags&&this._sourceTimeReportingFlags[l]&&(o.sourceTimes||(o.sourceTimes={}),o.sourceTimes[this._nameList[l]]=u),h},r.prototype.queueCustomEvents=function(){if(this._clipEventHandler&&this._customEvents){var t=this._currentTime;null!==this._endTime&&t.isGreater(this._endTime)&&(t=this._endTime);var e=t.subtract(this._startTime);e=Math.max(e,0);var o=Math.floor(e/this._loopDuration);for(0!==this._numLoops&&(o=Math.min(o,this._numLoops-1));this._eventLoopIndex=0;){for(;this._customEvents[s].hasNext(a);)n.queueEvent(this._clipEventHandler,[this._customEvents[s].next(a)]);a-=this._durationList[s],s++}}},e.exports=r},{"./BaseMotionGenerator":8,"./TimelineEventDispatcher":22}],14:[function(t,e,o){"use strict";var i=t("./SampleCombiner"),n=function(t){i.call(this);var e=t.getKinematicInfo().getDefaultPose().getDOFIndicesToNames().length;this._dofNamesToIndices=t.getKinematicInfo().getDefaultPose().getDOFNamesToIndices(),this._combinerList=new Array(e).fill(null)};n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.addCombiner=function(t,e){for(var o=0;o=this._minimumUpdateDelay&&(a=this._previousLayerStates),null!==a){var l=[];for(e=0;e-1&&this._outputs.splice(e,1)},c.prototype.getOutputs=function(){return this._outputs},c.prototype.computeVelocity=function(t,e){for(var o=e.getTime().subtract(t.getTime()),i=t.getPose(),n=e.getPose(),s=n.getDOFIndices(),a=0;a0},a.prototype.hasStatus=function(t){return null!==this.status&&(this.status&t)===t},a.prototype.getIndexCount=function(){return this.index_count},a.prototype.hasFault=function(){return null!==this.fault_status&&0!==this.fault_status},a.prototype.getFault=function(){return this.fault_status},a.prototype.setFromJson=function(t){for(var e=Object.keys(t),o=0;oa&&(a=Math.abs(this.initialStates[t].pos));a=Math.max(0,Math.min(Math.PI,a));var l=s*(a/Math.PI);n=e.subtract(this.startTime)/l,n=Math.max(0,Math.min(1,n))}for(t=0;tthis.movingEpsilon||n<1)&&(this.lastMovingCommandTime[t]=r.currentTime());var h,p;if(this.idleModeSwitchTime>0&&r.currentTime().subtract(this.lastMovingCommandTime[t])>this.idleModeSwitchTime)this.motionInterface.setCommand(this.dofNames[t],this.enabledArray[t]?i.AxisCommandMode.VELOCITY:i.AxisCommandMode.BRAKE,0,null,u,null),h=0,p=.25;else{var d=this.enabledArray[t]?i.AxisCommandMode.POS_VEL:i.AxisCommandMode.BRAKE;this.motionInterface.setCommand(this.dofNames[t],d,d===i.AxisCommandMode.POS_VEL?c:0,null,u,null),h=c[0],p=c[1]}if(this.infoListeners.length>0)for(var m=this.motionInterface.getState(this.dofNames[t]),f={dofName:this.dofNames[t],timestamp:e,observedPosition:m.pos,targetPosition:p,observedVelocity:m.vel,commandVelocity:h,refVelocity:m.ref},g=0;g.2||Math.abs(h.velocity)>.2){u=!1;break}}if(u){this.controlState=s.RESUMING,this.startTime=o,this.initialDeltas=[];var p=0;for(t=0;tp&&(p=Math.abs(m))}this.fadeSeconds=this.fadeSecondsMax*(p/Math.PI)}}var f=1;for(this.controlState===s.RESUMING&&(this.fadeSeconds<.01?f=1:(f=o.subtract(this.startTime)/this.fadeSeconds,f=Math.max(0,Math.min(1,f))),f>=1&&(this.controlState=s.RUNNING,e=!0)),t=0;t0)for(var T=this.motionInterface.getState(this.dofNames[t]),D={dofName:this.dofNames[t],timestamp:o,observedPosition:T.pos,targetPosition:_[1],observedVelocity:T.vel,commandVelocity:_[0],refVelocity:T.ref},O=0;O0;)this.unPauseCallbacks.shift()()},e.exports=a},{"../ifr-motion/base/CyclicMath":68,"./BodyData":24,"./BodyOutput":25}],28:[function(t,e,o){"use strict";var i=t("./BodyOutput"),n=function(t,e,o,n,r,s){i.call(this,t,e,o,n,r,s)};n.prototype=Object.create(i.prototype),n.prototype.constructor=i,n.prototype.update=function(){var t=this.clock.currentTime(),e=this.computeTargetsForTime(t.add(this.reactionTime));if(null!==e&&this.motionInterface.isConnected()&&!this.isPaused()){for(var o=0;o0)for(var l=this.motionInterface.getState(this.dofNames[o]),c={dofName:this.dofNames[o],timestamp:t,observedPosition:l.pos,targetPosition:e[o].position,observedVelocity:l.vel,commandVelocity:e[o].velocity},u=0;u0)for(var l={dofName:this.dofNames[o],timestamp:t,observedPosition:a.pos,targetPosition:e[o].position,observedVelocity:a.vel,commandVelocity:n},c=0;c=0&&r.push(JSON.parse(s[a].substring(l+e.length)))}for(var c=0;c0&&this.motionInterface.isConnected())for(o=0;o-1&&(h.clearInterval(d[e]),p.splice(e,1),d.splice(e,1))},g={createTimeline:function(t,e,o,p){void 0!==p&&(h.setInterval=function(t,e){return p.setInterval(t,e,!1)}),o=void 0!==o?o:20;var d=new r,f=new n("Motion Timeline",t,u,d,i.MODALITY_NAME);f.createLayer("default"),d.addSampleCombiner("default",null),f.createLayer("lookat",[t.getDOFSet("BODY").getDOFs()[0]]),d.addSampleCombiner("lookat",new a),f.createLayer("posture",t.getDOFSet("BODY").plus("EYE_ROOT").plus("OVERLAY_ROOT").getDOFs()),d.addSampleCombiner("posture",new a);var g=t.getDOFSet("BODY").plus("EYE_ROOT").plus("OVERLAY_ROOT"),_=t.getDOFSet("EYE_DEFORM").plus("OVERLAY_DEFORM");f.createLayer("beat",g.plus(_).getDOFs());var y=new l(t);y.addCombiner(g.getDOFs(),new a);var v=new s(t,t.getKinematicInfo().getDefaultPose().getCopy(),null,_.getDOFs());y.addCombiner(_.getDOFs(),v),d.addSampleCombiner("beat",y);var T=t.getDOFSet("EYE_DEFORM").getDOFs();f.createLayer("blink",T);var D=new s(t,t.getKinematicInfo().getDefaultPose().getCopy(),null,T);d.addSampleCombiner("blink",D);var O=new c(u);O.setKinematicInfo(t.getKinematicInfo()),f.addOutput(O);var L=[f,O];return m(f,o,L),e&&e(f),f},connectRenderer:function(t,e){for(var o=t.getOutputs(),i=0;i-1&&this.renderers.splice(e,1)},i.prototype.getRenderers=function(){return this.renderers.slice(0)},i.prototype.handleOutput=function(t,e,o){ this.outputTime=t,this.outputPose=e},i.prototype.update=function(){if(null!==this.kinematicInfo&&null!==this.outputPose){for(var t=this.outputPose,e={},o=t.getDOFNames(),i=0;ii&&(o=!0,this.dofLastValues[n]=r):(o=!0,this.dofLastValues[n]=r))}o?this.scene.markDirty():e=!1}if(e){var a;for(a=0;a=0)throw new Error("JiboKinematicInfo:Cannot queue 2 loads with the same identifier ("+t+")");return o.push(t),function(){var i=o.indexOf(t);i===-1?g(_,'JiboKinematicInfo:Error, callback "'+t+'" called but not currently pending.'):o.splice(i,1),e&&e.apply(this,arguments),0===o.length&&c()}};c=function(){if(y)e.loadSucceeded=!1;else{e.loadSucceeded=!0,e._dofNames=e._bodyDOFNames.concat(e._eyeDOFNames),m.hasOwnProperty("__globalSetup")&&m.__globalSetup(e._dofNames),e._bodyKinematicGroup=new l(e._bodyControlGroup.getCopy(),v);var o=e._eyeControlGroup.getControlList().concat(e._bodyControlGroup.getControlList());e._fullControlGroup=new h,e._fullControlGroup.setControlList(o),e._fullKinematicGroup=new l(e._fullControlGroup.getCopy(),T),e._defaultPose=new m("default pose",e._dofNames),e._defaultAnimation.getPoseAtTime(e._defaultAnimation.getDuration()/2,e._interpolatorSet,e._defaultPose);for(var i=0;i1&&(n=o.slice(0,o.length-1));var r=this._getScope(n);r[i]=e},e.exports=r},{"./FileTools":52,"./SLog":55}],54:[function(t,e,o){"use strict";var i=t("./SLog"),n=function(t,e,o,i){this._url=t,this._protocolInfo=e||null,this._channelName=i||"SOCKET",this._reconnectDelayMillis=3e3,null!==o&&void 0!==o&&(this._reconnectDelayMillis=o),this._socket=null,this._listenerMap={},this._shouldClose=!1,this._connect()};n.prototype.isConnected=function(){return null!==this._socket&&this._socket.readyState===WebSocket.OPEN},n.prototype.on=function(t,e){this._listenerMap.hasOwnProperty(t)||(this._listenerMap[t]=[]),this._listenerMap[t].push(e)},n.prototype.off=function(t,e){var o=this._listenerMap[t];o&&o.indexOf(e)!==-1&&o.splice(o.indexOf(e),1)},n.prototype.send=function(t){this.isConnected()&&this._socket.send(t)},n.prototype.close=function(){this._shouldClose=!0,this._reconnectDelayMillis=-1,null!==this._socket&&this._socket.close()},n.prototype._connect=function(){this._shouldClose||(this._protocolInfo?this._socket=new WebSocket(this._url,this._protocolInfo):this._socket=new WebSocket(this._url),this._socket.onopen=this._openHappened.bind(this),this._socket.onclose=this._closeHappened.bind(this),this._socket.onerror=this._errorHappened.bind(this),this._socket.onmessage=this._messageHappened.bind(this))},n.prototype._considerReconnect=function(){this._reconnectDelayMillis>=0&&null!==this._socket&&(i(this._channelName,"Scheduling reconnect: "+this._url),this._socket.onopen=null,this._socket.onclose=null,this._socket.onerror=null,this._socket.onmessage=null,this._socket=null,setTimeout(this._connect.bind(this),this._reconnectDelayMillis))},n.prototype._fireEvent=function(t,e){var o=this._listenerMap[t];if(o)for(var i=0;i=0&&t[1]>=0&&t[1]<1e6&&t[0]===Math.round(t[0])&&t[1]===Math.round(t[1]);return e||(t[0]===+t[0]&&t[1]===+t[1]||console.log("InvalidTime: At least one element of timestamp is not a number"),(t[0]<0||t[1]<0)&&console.log("InvalidTime: At least one element of timestamp is negative"),t[1]>=1e6&&console.log("InvalidTime: Microseconds portion is over one second"),t[0]===Math.round(t[0])&&t[1]===Math.round(t[1])||console.log("InvalidTime: At least one element is not an integer")),e},n=function(t,e){if(this._timestamp=[t,e],!i(this._timestamp))throw new Error("new Time() given invalid time values: (INVALID "+this._timestamp[0]+", "+this._timestamp[1]+")")};n.createFromTimestamp=function(t){if(!Array.isArray(t))throw new Error("new Time() given invalid Timestamp: (INVALID: not array)");return new n(t[0],t[1])},n.prototype.subtract=function(t){var e,o,i;this.isGreaterOrEqual(t)?(e=this._timestamp,o=t._timestamp,i=1):(e=t._timestamp,o=this._timestamp,i=-1);var n=e[1]-o[1],r=e[0]-o[0];n<0&&(n+=1e6,r-=1);var s=i*(r+n/1e6);return Math.round(1e6*s)/1e6},n.prototype.add=function(t){var e,o;if(t<0){var i=Math.floor(-t),r=-t-i;if(e=this._timestamp[0]-i,o=this._timestamp[1]-1e6*r,o=Math.round(o),o<0&&(o+=1e6,e-=1),e<0)throw new Error("Error, "+this.toString()+"+"+t+" is a negative timestamp! (not allowed)")}else{var s=Math.floor(t),a=t-s;e=this._timestamp[0]+s,o=this._timestamp[1]+1e6*a,o=Math.round(o),o>=1e6&&(o-=1e6,e+=1)}return new n(e,o)},n.prototype.isGreater=function(t){return this._timestamp[0]>t._timestamp[0]||this._timestamp[0]===t._timestamp[0]&&this._timestamp[1]>t._timestamp[1]},n.prototype.isGreaterOrEqual=function(t){return this._timestamp[0]>t._timestamp[0]||this._timestamp[0]===t._timestamp[0]&&this._timestamp[1]>=t._timestamp[1]},n.prototype.equals=function(t){return this._timestamp[0]===t._timestamp[0]&&this._timestamp[1]===t._timestamp[1]},n.prototype.toString=function(){for(var t=""+this._timestamp[1];t.length<6;)t="0"+t;return this._timestamp[0]+"."+t},e.exports=n},{}],57:[function(t,e,o){"use strict";var i=function(t,e){var o=setInterval(t,e);this.stop=function(){clearInterval(o)}},n="var timerHandles = {};\nself.onmessage = function(event)\n{\n\tvar command = event.data.command;\n\tvar callbackID = event.data.callbackID;\n\tvar callbackInterval = event.data.callbackInterval;\n\tvar timerHandle = null;\n\n\tif (command === 'start')\n\t{\n\t\ttimerHandle = setInterval(function()\n\t\t{\n\t\t\tself.postMessage({callbackID: callbackID});\n\t\t}, callbackInterval);\n\t\ttimerHandles[callbackID] = timerHandle;\n\t}\n\telse if (command === 'stop')\n\t{\n\t\ttimerHandle = timerHandles[callbackID];\n\t\tif (timerHandle !== undefined && timerHandle !== null)\n\t\t{\n\t\t\tclearInterval(timerHandle);\n\t\t}\n\t}\n};\n",r=function(){var t=new Blob([n],{type:"text/javascript"}),e=URL.createObjectURL(t),o=new Worker(e),i={},r=0;this.createTimer=function(t,e){var n=r;i[n]=t,r++,o.postMessage({command:"start",callbackID:n,callbackInterval:e});var s={};return s.stop=function(){i[n]=null,o.postMessage({command:"stop",callbackID:n})},s},o.onmessage=function(t){var e=t.data.callbackID,o=i[e];o&&o()}},s=null,a=!0,l={};l.setInterval=function(t,e){if(e<1e3&&"undefined"!=typeof Worker&&a){if(null===s)try{s=new r}catch(o){return console.log("TimerTools: Worker blobs don't seem to be allowed, falling back to standard setInterval timing."),a=!1,new i(t,e)}return s.createTimer(t,e)}return new i(t,e)},l.clearInterval=function(t){t&&t.stop()},l.WebWorkerTimerFactory=r,e.exports=l},{}],58:[function(t,e,o){"use strict";var i=t("three"),n=function(t,e,o){this.name=t||"",this.position=e||new i.Vector3,this.orientation=o||new i.Quaternion};n.prototype.setFromJson=function(t){return this.name=t.name,this.position.copy(n.vector3FromJson(t.xyzTranslation)),this.orientation.copy(n.quaternionFromJson(t.wxyzRotation)),this},n.prototype.toMatrix4=function(){return(new i.Matrix4).compose(this.position,this.orientation,new i.Vector3(1,1,1))},n.vector3FromJson=function(t){return(new i.Vector3).fromArray(t)},n.quaternionFromJson=function(t){var e=t,o=new i.Quaternion(e[1],e[2],e[3],e[0]);return o.inverse(),o},e.exports=n},{three:void 0}],59:[function(t,e,o){"use strict";var i=function(){this.name=null,this.skeletonFrameName=null,this.mesh=null,this.boneFrameNames=null,this.bones=null};e.exports=i},{}],60:[function(t,e,o){"use strict";var i=t("three"),n={};n.convertDirectionLocalToWorld=function(){var t=null;return function(e,o,n){return null===t&&(t=new i.Quaternion),void 0!==n&&null!==n||(n=new i.Vector3),e.getWorldQuaternion(t),n.copy(o).applyQuaternion(t)}}(),n.findOrthogonal=function(t,e){void 0!==e&&null!==e||(e=new i.Vector3);var o=Math.abs(t.x),n=Math.abs(t.y),r=Math.abs(t.z);return o>=n&&o>=r?e.set(t.y,-t.x,0):e.set(0,t.z,-t.y),e},n.quatFromAxisAngle=function(){var t=null;return function(e,o,n){return null===t&&(t=new i.Vector3),null===n&&(n=new i.Quaternion),t.copy(e).normalize(),n.setFromAxisAngle(t,o)}}(),n.toString=function(t){return null!=t?"("+t.x+", "+t.y+", "+t.z+")":"null"},e.exports=n},{three:void 0}],61:[function(t,e,o){"use strict";var i=t("./ModelLoader"),n=t("./SkeletonLoader"),r=t("three"),s=function(){this.modelUrl=null,this.skeletonUrl=null,this.success=!1,this.message="",this.modelResult=null,this.skeletonResult=null,this.modelRoot=null},a=function(t,e){this.modelLoader=t||new i,this.skeletonLoader=e||new n,this._result=null};a.prototype.getResult=function(){return this._result},a.prototype.load=function(t,e,o,i){if(o){var n=this;this.skeletonLoader.load(o,function(){var r=n.skeletonLoader.getResult();if(r.success)n._loadModel(t,e,r,i);else{var a=new s;a.modelUrl=e,a.skeletonUrl=o,a.skeletonResult=r,a.success=!1,a.message="skeleton load failed with message: "+r.message,n._result=a,i()}})}else this._loadModel(t,e,null,i)},a.prototype._loadModel=function(t,e,o,i){var n=this;this.modelLoader.load(e,function(){n._result=new s,n._result.modelUrl=e,n._result.skeletonUrl=o?o.url:null,n._result.skeletonResult=o;var a=n.modelLoader.getResult();if(n._result.modelResult=a,!a.success)return n._result.success=!1,n._result.message="model load failed with message: "+a.message,void i();var l=new r.Object3D;l.name=t||"";var c;if(o){var u=o.skeletonRoot;for(l.add(u),c=0;c0){var o=Math.min(t,this._accelerateTime);e+=(this._initialVelocity+this._acceleration*o/2)*o,t-=o}if(t>0){var i=Math.min(t,this._decelerateTime);e+=(this._initialVelocity+this._acceleration*this._accelerateTime-this._acceleration*i/2)*i,t-=i}return t>0&&(e+=this._targetVelocity*t),e},r.prototype.velocityAtTime=function(t){var e=this._initialVelocity;if(t>0){var o=Math.min(t,this._accelerateTime);e+=this._acceleration*o,t-=o}if(t>0){var i=Math.min(t,this._decelerateTime);e-=this._acceleration*i,t-=i}return e},r.prototype.isConsistent=function(){if(isNaN(this._accelerateTime)||isNaN(this._decelerateTime))return i(n,"Plan has NaN times! accelerationTime:"+this._accelerateTime+" decelerationTime:"+this._decelerateTime),!1;if(!isFinite(this._accelerateTime)||!isFinite(this._decelerateTime))return i(n,"Plan has non-finite times! accelerationTime:"+this._accelerateTime+" decelerationTime:"+this._decelerateTime),!1;if(isNaN(this._acceleration))return i(n,"Plan has NaN acceleration!: "+this._acceleration),!1;if(!isFinite(this._acceleration))return i(n,"Plan has non-finite acceleration!: "+this._acceleration),!1;var t=this._accelerateTime+this._decelerateTime,e=this._distance+this._targetVelocity*t,o=(this._initialVelocity+this._acceleration*this._accelerateTime/2)*this._accelerateTime+(this._initialVelocity+this._acceleration*this._accelerateTime-this._acceleration*this._decelerateTime/2)*this._decelerateTime,r=this._initialVelocity+this._acceleration*this._accelerateTime-this._acceleration*this._decelerateTime;return this._accelerateTime<0||this._decelerateTime<0?(i(n,"Plan has negative times! accelerationTime:"+this._accelerateTime+" decelerationTime:"+this._decelerateTime),!1):Math.abs(this._accelerateTime+this._decelerateTime-this._totalTime)>1e-7?(i(n,"Plan time segments are not equal to target time! segments:"+(this._accelerateTime+this._decelerateTime)+" target:"+this._totalTime),!1):Math.abs(o-e)>1e-6?(i(n,"Plan has incorrect integral! ourDisplacement:"+o+" pDelta:"+e),!1):!(Math.abs(r-this._targetVelocity)>1e-7)||(i(n,"Plan has incorrect final velocity resultV:"+r+" pDelta:"+this._targetVelocity),!1)},r.prototype.getTotalTime=function(){return this._totalTime};var s=function(){};s.prototype.computeWithFixedTime=function(t,e,o,s){if(s<1e-10)return i(n,"Asked for fixed time plan with time of "+s+", returning null"),null;var a,l,c=(e-t)*s/2+o,u=Math.pow((t-e)*s/2-o,2)-Math.pow(s,2)*(e*t/2-Math.pow(t,2)/4-Math.pow(e,2)/4);if(u<0){if(!(u>-1e-10))return i(n,"Inconsistent CWFT Plan for vCurrent:"+t+", vTarget:"+e+", pDelta:"+o+", totalTime:"+s+", tsqrt:"+u),null;u=0}var h=Math.sqrt(u),p=Math.pow(s,2)/2,d=1;o<.5*s*(t-e)&&(d=-1);var m=(c+d*h)/p;if(0===m?(a=s,l=0):Math.abs(m)<1e-10?(m=0,a=s,l=0):(a=s/2+(e-t)/(2*m),l=s/2+(t-e)/(2*m)),a<0){if(!(a>-1e-10))return i(n,"Inconsistent CWFTaT1 Plan for vCurrent:"+t+", vTarget:"+e+", pDelta:"+o+", totalTime:"+s+", aChoiceT1:"+a),null;a=0}if(l<0){if(!(l>-1e-10))return i(n,"Inconsistent CWFTaT2 Plan for vCurrent:"+t+", vTarget:"+e+", pDelta:"+o+", totalTime:"+s+", aChoiceT2:"+l),null;l=0}var f=new r(t,e,m,a,l,s,o);return f},s.prototype.computeWithFixedAccel=function(t,e,o,s){if(s<1e-10)return i(n,"Asked for fixed acceleration plan with acceleration of "+s+", returning null"),null;var a=s,l=1;(t-e)*Math.abs(e-t)/(2*s)>o&&(a=-s,l=-1);var c=2*e-2*t,u=2*Math.pow(t-e,2)+4*a*o;if(u<0){if(!(u>-1e-10))return i(n,"Inconsistent CWFA Plan for vCurrent:"+t+", vTarget:"+e+", pDelta:"+o+", acceleration:"+s+", tsqrt:"+u),null;u=0}var h=Math.sqrt(u),p=2*a,d=(c+l*h)/p,m=t/a+d-e/a;if(d<0){if(!(d>-1e-10))return i(n,"Inconsistent CWFAt1 Plan for vCurrent:"+t+", vTarget:"+e+", pDelta:"+o+", acceleration:"+s+", t1Choice:"+d),null;d=0}if(m<0){if(!(m>-1e-10))return i(n,"Inconsistent CWFAt2 Plan for vCurrent:"+t+", vTarget:"+e+", pDelta:"+o+", acceleration:"+s+", t2Choice:"+m),null;m=0}return new r(t,e,a,d,m,d+m,o)},s.prototype.computeWithZeroAccel=function(t){var e=new r(t,t,0,1,0,1,0);return e},s.prototype.computeWithMaxAccel=function(t,e,o,i,n){if(i<1e-6)return this.computeWithZeroAccel(t);var r=this.computeWithFixedTime(t,e,o,n);if(Math.abs(r._acceleration)<=i)return r;var s=this.computeWithFixedAccel(t,e,o,i);return s},s.prototype.createPlanWithFixedAccelForever=function(t,e){return new r(t,NaN,e,1/0,0,1/0,1/0)},e.exports=s},{"../../ifr-core/SLog":55}],66:[function(t,e,o){"use strict";var i=t("./Motion"),n=t("./MotionEvent"),r=function(t,e){var o={};o.motion=t,e=e||[],o.events=e,o.speed=1,this.getMotion=function(){return o.motion},this.getEventCount=function(){return o.events.length},this.getEvent=function(t){return o.events[t]},this.getEvents=function(){return o.events},this.getSpeed=function(){return o.speed},this.setSpeed=function(r){if(r<=0)throw new Error("invalid speed: "+r);if(r!==o.speed)if(o.speed=r,1===o.speed)o.motion=t,o.events=e;else{for(var s=new i(t.getName()),a=Object.keys(t.getTracks()),l=0;lthis.length&&(this.length=t.getLength())},s.prototype.getDOFs=function(){return Object.keys(this.tracks)},s.prototype.hasDOF=function(t){return this.tracks.hasOwnProperty(t)},s.prototype.getDOFDataAtTime=function(t,e,o){return this.tracks.hasOwnProperty(t)?this.tracks[t].getDataAtTime(e,o):null},s.prototype.getPoseAtTime=function(t,e,o){if(void 0!==o&&null!==o||(o=new i(this.getName()+" pose sample",Object.keys(this.tracks))),"number"!=typeof t)throw new Error("getPoseAtTime expects time as a number value in seconds");for(var n=o.getDOFNames(),r=0;r0?n[0]=i[0]:n.length>1?n[0]=null:n.length=0}}},c.prototype.getPose=function(t){t.setPose(this)},c.prototype.set=function(t,e,o){var n=i[t];this.dofPresent[n]&&(void 0!==o?this.dofVals[n][o]=e:this.dofVals[n]=e)},c.prototype.setByIndex=function(t,e,o){this.dofPresent[t]&&(void 0!==o?this.dofVals[t][o]=e:this.dofVals[t]=e)},c.prototype.get=function(t,e){var o=i[t];if(this.dofPresent[o]){var n=this.dofVals[o];return void 0!==e?e>=n.length?null:n[e]:n}return null},c.prototype.getByIndex=function(t,e){if(this.dofPresent[t]){var o=this.dofVals[t];return void 0!==e?e>=o.length?null:o[e]:o}return null},c.prototype.hasDOFIndex=function(t){return this.dofPresent[t]},c.prototype.hasValueForDOFIndex=function(t,e){return this.dofPresent[t]&&this.dofVals[t].length>e},c.prototype.getName=function(){return this.name},c.prototype.getDOFNames=function(){return this.dofNames},c.prototype.getDOFIndices=function(){return this.dofIndices},c.prototype.clear=function(){if(null!==this.dofNames)for(var t=0;t0&&n.length>0){if(i[0]!==n[0])return!1}else if(i.length!==n.length)return!1}return!0},c.prototype.equalsNoChange=function(t){var e,o;for(e=0;e0&&n.length>0){if(i[0]!==n[0])return!1}else if(i.length!==n.length)return!1}}return!0},c.prototype.getDOFNamesToIndices=function(){return Object.assign({},i)},c.prototype.getDOFIndicesToNames=function(){return n.slice()},c.prototype.getDOFIndexForName=function(t){return i[t]},c.prototype.getDOFNameForIndex=function(t){return n[t]},c.computeBinary=function(t,e,o,i,s){var a,u;if(null==s||null==s.dofNames){null==s&&(s=new c(t.getName()+" x "+e.getName()));var h=[];for(u=0;u0?e[0]:0,r=o.length>0?o[0]:0;i[0]=n-r;for(var s=1;s0?e[0]:0,r=o.length>0?o[0]:0;i[0]=n+r;for(var s=1;s0){null==o&&(o=1);var n=0;e.length>=2&&(n=e[1]),i[0]=n*o+e[0];for(var r=1;re&&(n=e),n}};e.exports=i},{}],78:[function(t,e,o){"use strict";var i=t("./CyclicDOFTargetSelector"),n=t("./CyclicMath"),r=function(t,e,o){i.call(this,t),this._alignedParents=e,this._parentDirections=o};r.prototype=Object.create(i.prototype),r.prototype.constructor=r,r.prototype.closestEquivalentRotation=function(t,e){for(var o=0,i=0;i0&&t-1?this.dataList[e]:null},i.prototype.getDataForRange=function(t,e,o,i){for(var n=null,r=this.getLeftIndexForTime(t),s=this.getLeftIndexForTime(o)+1,a=r;a<=s;a++)if(a>=0&&at||l===t&&e,u=l=0&&this.timestampList[o]===t)this.dataList[o]=e;else{var i=o+1;this.timestampList.splice(i,0,t),this.dataList.splice(i,0,e)}},i.prototype.getLeftIndexForTime=function(t){if(0===this.size()||t=this.getEndTime())return this.size()-1;if(this._lastReturnedLeftIndext)return this._lastReturnedLeftIndex;if(this._lastReturnedLeftIndex++,this._lastReturnedLeftIndext)return this._lastReturnedLeftIndex;for(var e,o=0,i=this.size()-1;i!==o+1;)e=Math.floor((o+i)/2),this.timestampList[e]<=t?o=e:i=e;return this._lastReturnedLeftIndex=o,o},i.prototype.toString=function(){for(var t="",e="",o=0;o0){var e=new s.Color(0,0,0),o=new s.Color(0,0,0);t?o.copy(this._meshes[0].material.color):e.copy(this._meshes[0].material.emissive);for(var i=0;i0&&(i.call(this,o[0],o[1],o[2],o[3]),!0)},a.prototype.updateFromPose=function(t){var e,o=[];for(e=0;e0&&(i.call(this,o[0],o[1],o[2],o[3]),!0)},a.prototype.getCopy=function(t){return t||(t=new a),n.prototype.getCopy.call(this,t),t._meshNames=this._meshNames?this._meshNames.slice(0):null,t._ledNames=this._ledNames?this._ledNames.slice(0):null,t},a.Factory=function(){},a.Factory.prototype=Object.create(r.prototype),a.Factory.prototype.constructor=a.Factory,a.Factory.prototype._controlType=a.prototype._controlType,a.Factory.prototype._controlConstructor=a,e.exports=a},{"./ModelControl":83,"./ModelControlFactory":84,three:void 0}],81:[function(t,e,o){"use strict";var i=function(t,e){this._dofName=t,this._controlType=null,this._isMetric=!1,this._isCyclic=!1,this._min=void 0,this._max=void 0,this._limitData={},this.setFromModelControl(e)};i.prototype.setFromModelControl=function(t){if(this._controlType=t.getControlType(),this._isMetric="TEXTURE"!==this._controlType&&"VISIBILITY"!==this._controlType,this._isCyclic="ROTATION"===this._controlType&&t.isCyclic(),"ROTATION"===this._controlType)this._min=this._isCyclic?-Math.PI:t.getMin(),this._max=this._isCyclic?Math.PI:t.getMax();else if("TRANSLATION"===this._controlType){var e=t.getDOFNames().indexOf(this._dofName);e>-1&&(this._min=t._minList[e],this._max=t._maxList[e])}else"COLOR"===this._controlType&&(this._min=0,this._max=1)},i.prototype.getDOFName=function(){return this._dofName},i.prototype.getControlType=function(){return this._controlType},i.prototype.isMetric=function(){return this._isMetric},i.prototype.isCyclic=function(){return this._isCyclic},i.prototype.getMin=function(){return this._min},i.prototype.getMax=function(){return this._max},i.prototype.setLimitData=function(t){for(var e=Object.keys(t),o=0;o0;){var i=o.shift();if(i.name&&(e[i.name]=i),i.children)for(var n=0;n"},i.prototype.attachToModel=function(t){return!1},i.prototype.attachToControlGroup=function(t){},i.prototype.updateFromDOFValues=function(t){return!1},i.prototype.updateFromPose=function(t){return!1},i.prototype.getCopy=function(t){t||(t=new i),t._controlNames=this._controlNames?this._controlNames.slice(0):null,t._dofNames=this._dofNames?this._dofNames.slice(0):null,t._controlType=this._controlType},e.exports=i},{}],84:[function(t,e,o){"use strict";var i=function(){this._controlType=null,this._controlConstructor=null};i.prototype.getControlType=function(){return this._controlType},i.prototype.constructFromJson=function(t){if(t.controlType!==this._controlType)return console.warn("ModelControlFactory<"+this._controlType+">: don't know how to construct for control type: "+t.controlType),null;var e=new this._controlConstructor;return e.setFromJson(t),e},i.prototype.postProcessControlList=function(t){return t},e.exports=i},{}],85:[function(t,e,o){"use strict";var i=t("./KinematicGroup"),n=t("./DOFInfo"),r=function(){this._controlList=[],this._dofNames=[],this._dofNameToControlMap={},this._dofInfos={}};r.prototype.setControlList=function(t){var e;for(this._controlList=t,this._dofNames=[],this._dofNameToControlMap={},this._dofInfos={},e=0;e0&&t.hasOwnProperty(this._dofNames[0])){var e=t[this._dofNames[0]];return i.call(this,e)}return!1},a.prototype.updateFromPose=function(t){var e=t.get(this._dofNames[0],0);return this._meshes.length>0&&null!=e&&i.call(this,e)},a.prototype.getCopy=function(t){return t||(t=new a),n.prototype.getCopy.call(this,t),t._meshNames=this._meshNames?this._meshNames.slice(0):null,t},a.Factory=function(){},a.Factory.prototype=Object.create(r.prototype),a.Factory.prototype.constructor=a.Factory,a.Factory.prototype._controlType=a.prototype._controlType,a.Factory.prototype._controlConstructor=a,e.exports=a},{"../../ifr-core/SLog":55,"./ModelControl":83,"./ModelControlFactory":84}],90:[function(t,e,o){"use strict";var i=t("../../ifr-core/Bakery"),n=t("../base/CyclicMath"),r=function(){this._targetTime=null,this._targetPosition=null,this._targetVelocity=null,this._lastObservationTime=null,this._lastObservedPosition=null,this._lastObservedVelocity=null,this._lastReportedTargetVelocity=null,this._commandVelocity=0,this._commandAcceleration=1,this._lastError=0,this._window="FeedbackController"};r.prototype.setTarget=function(t,e,o){this._targetTime=t,this._targetPosition=e,this._targetVelocity=o},r.prototype.acceptFeedback=function(t,e,o,i){this._lastObservationTime=t,this._lastObservedPosition=e,this._lastObservedVelocity=o,this._lastReportedTargetVelocity=i},r.prototype.calculateForTime=function(t){if(null!==this._lastObservationTime&&null!==this._targetTime){var e=t.subtract(this._targetTime),o=this._targetPosition+this._targetVelocity*e,r=i.getFloat("P Gain",0,10,2,this._window),s=i.getFloat("D Gain",0,10,0,this._window),a=this.predictedPosition(t);a=n.closestEquivalentRotation(a,o);var l=o-a,c=l-this._lastError,u=r*l+s*c;this._lastError=l;var h=i.getFloat("P Gain Vel Cap",0,100,100,this._window);u=Math.max(-h,Math.min(h,u)),this._commandVelocity=u,this._commandAcceleration=i.getFloat("Advertise Accel Limit",0,50,30,this._window)}},r.prototype.predictedPosition=function(t){return this._lastObservedPosition},r.prototype.getCommandVelocity=function(){return this._commandVelocity},r.prototype.getCommandAcceleration=function(){return this._commandAcceleration},r.prototype.noteCommandSent=function(t,e,o){},e.exports=r},{"../../ifr-core/Bakery":50,"../base/CyclicMath":68}],91:[function(t,e,o){"use strict";var i=t("../../ifr-core/Bakery"),n=t("./PController"),r=function(){n.call(this),this._commandVelocityPVC=0};r.prototype=Object.create(n.prototype),r.prototype.constructor=r,r.prototype.calculateForTime=function(t){null!==this._lastObservationTime&&null!==this._targetTime&&(n.prototype.calculateForTime.call(this,t),i.getBoolean("Use Velocity",!0,this._window)?this._commandVelocityPVC=this._commandVelocity+this._targetVelocity:this._commandVelocityPVC=this._commandVelocity)},r.prototype.getCommandVelocity=function(){return this._commandVelocityPVC},e.exports=r},{"../../ifr-core/Bakery":50,"./PController":90}],92:[function(t,e,o){"use strict";var i=t("./TrajectoryControllerSim"),n=function(t,e,o){i.call(this,t,e,o)};n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.updateCommand=function(t,e,o,n,r){var s=.1;i.prototype.updateCommand.call(this,t,e,s,o,n,r)},e.exports=n},{"./TrajectoryControllerSim":93}],93:[function(t,e,o){"use strict";var i=t("../base/AccelPlanner"),n=t("../../ifr-core/Clock"),r=t("../base/CyclicMath"),s=t("../../ifr-core/SLog"),a=function(t,e,o){null==t&&(t=0),null==e&&(e=0),null==o&&(o=n.currentTime()),this._planner=new i,this._plan=this._planner.computeWithZeroAccel(e),this._planStartTime=o,this._planStartPosition=t};a.prototype.updateCommand=function(t,e,o,i,a,l){null==l&&(l=n.currentTime());var c=l.subtract(this._planStartTime),u=this._plan.displacementAtTime(c)+this._planStartPosition,h=this._plan.velocityAtTime(c);t=r.closestEquivalentRotation(t,u),this._plan=this._planner.computeWithMaxAccel(h,e,t-u,i,o),this._plan.isConsistent()||(s.error("Inconsistent plan with inputs: \n\tcurrentVelocity:"+h+" \n\ttargetVelocity:"+e+" \n\tpDelta:"+(t-u)+" \n\tmaxAcceleration:"+i+" \n\tmaxVelocity:"+a),this.plan=this._planner.computeWithMaxAccel(0,0,0,1,1)),this._planStartTime=l,this._planStartPosition=u},a.prototype.getPosition=function(t){null==t&&(t=n.currentTime());var e=t.subtract(this._planStartTime),o=this._plan.displacementAtTime(e)+this._planStartPosition;return o},a.prototype.getVelocity=function(t){null==t&&(t=n.currentTime());var e=t.subtract(this._planStartTime),o=this._plan.velocityAtTime(e);return o},e.exports=a},{"../../ifr-core/Clock":51,"../../ifr-core/SLog":55,"../base/AccelPlanner":65,"../base/CyclicMath":68}],94:[function(t,e,o){"use strict";var i=t("../base/TimestampedBuffer"),n=t("../base/MotionTrack"),r=t("../base/Motion"),s=t("../base/MotionEvent"),a=t("../../ifr-core/FileTools"),l=t("../../ifr-core/SLog"),c="MODEL_LOADING",u=function(){this.url=null,this.success=!1,this.message="",this.motion=null,this.defaultDOFNames=null,this.enumMaps=null,this.events=null},h=function(){this._result=null,this.flattenEnums=!0,this.resolvePaths=!0};h.prototype.getResult=function(){return this._result},h.prototype.load=function(t,e){var o=this;a.loadJSON(t,function(i,n){if(null===i)o.parseData(n,t),e&&e();else{var r=new u;r.url=t,r.success=!1,r.message=i,o._result=r,e&&e()}})},h.prototype.parseData=function(t,e){if(this._result=new u,this._result.url=e,"DOFAnimation"!==t.header.fileType&&"Animation"!==t.header.fileType)return this._result.success=!1,void(this._result.message="don't know how to handle file type: "+t.header.fileType);for(var o=t.content,a=new r(o.name),h=0;ha.getDuration())l(c,"AnimationLoader: skipping event with time property: "+T.time+" outside of animation bounds, animation duration = "+a.getDuration());else if(void 0===T.eventName||null===T.eventName||""===T.eventName)l(c,"AnimationLoader: skipping event with empty, null, or undefined eventName property");else if("string"!=typeof T.eventName)l(c,"AnimationLoader: skipping event with non-string eventName property: "+T.eventName);else{var D=void 0!==T.payload?T.payload:null;this._result.events.push(new s(T.time,T.eventName,D))}}this._result.events.sort(function(t,e){return t.getTimestamp()-e.getTimestamp()})}this._result.success=!0};var p=function(t,e){for(var o=t.getTracks(),i=Object.keys(o),n=0;nr&&(i.error("Clamping DST application of unfiltered offset (Velocity) of "+a+" to "+l+" as it is greater than "+r),a=a<0?-r:r),e.set(l,t.get(l,1)+a,1)},this.reset=function(){s=!1}};e.exports=s},{"../../ifr-core/SLog":55,"../base/CyclicMath":68,"../base/Pose":76}],98:[function(t,e,o){"use strict";var i=t("three"),n=t("../../ifr-geometry/ExtraMath"),r=t("./PlaneDisplacementLookatDOF"),s=t("../../ifr-core/SLog"),a=function(t){this.name=t};a.prototype.connectToGroup=function(t){},a.prototype.computeFeature=function(t){},a.prototype.getRequiredTransforms=function(t){};var l=function(t,e,o,i){a.call(this,t),this._transformName=e,this._position=o,this._direction=i,this._transform=null};l.prototype=Object.create(a.prototype),l.prototype.constructor=l,l.prototype.connectToGroup=function(t){this._transform=null,null!==t&&(this._transform=t.getTransform(this._transformName),null==this._transform&&s.error("VectorFeatureReporter: error initting, did not find transform "+this._transformName+" for feature "+this.name))},l.prototype.computeFeature=function(t){if(null!==this._transform){var e=null,o=null;return null!==this._position&&(e=(new i.Vector3).copy(this._position),this._transform.localToWorld(e)),null!==this._direction&&(o=n.convertDirectionLocalToWorld(this._transform,this._direction,new i.Vector3)),{position:e,direction:o}}return null},l.prototype.getRequiredTransforms=function(t){return[this._transformName]};var c=function(t,e,o){a.call(this,t),this._planeDisplacementDOF1=e,this._planeDisplacementDOF2=o};c.prototype=Object.create(a.prototype),c.prototype.constructor=c,c.prototype.connectToGroup=function(t){this._planeDisplacementDOF1.connectToGroup(t),this._planeDisplacementDOF2.connectToGroup(t)},c.prototype.computeFeature=function(t){if(null!==this._planeDisplacementDOF1._controlledTransform){var e=new i.Vector3,o=new i.Vector3;return r.getVectorFromOrthogonalPDLDs(this._planeDisplacementDOF1,this._planeDisplacementDOF2,t,e,o),{position:e,direction:o}}return null},c.prototype.getRequiredTransforms=function(t){var e=[this._planeDisplacementDOF1._centralTransformName,this._planeDisplacementDOF2._centralTransformName];return e=e.concat(t.getModelControlGroup().getRequiredTransformNamesForDOFs([this._planeDisplacementDOF1.getControlledDOFName(),this._planeDisplacementDOF2.getControlledDOFName()]))};var u=function(t,e){var o,i=[];for(o=0;o=this.minRetriggerTimeAcrossTrajectories||!this.achievedZeroSinceLastBlink&&n.subtract(this.lastTriggerTime)>=this.minRetriggerTimeSameTrajectory)&&t.highestDistanceOptimalToFiltered>=this.triggerAtDelta&&(null===this.onlyAtOrAfterWindupPhase||null===o||o>=this.onlyAtOrAfterWindupPhase)&&(this.blinkDelegate.blink(),this.lastTriggerTime=n,this.achievedZeroSinceLastBlink=!1),!this.achievedZeroSinceLastBlink&&t.highestDistanceOptimalToFilteredo&&(o=l)}return o},l.prototype.getName=function(){return this._name},l.prototype.suggestForwardTarget=function(t,e){return this._kinematicGroup.setFromPose(t),this._kinematicGroup.updateWorldCoordinateFrames(),this._lookatDOFs[0].suggestForwardTarget(e)},e.exports=l},{"../../ifr-core/SLog":55,"./PointADOF":109}],103:[function(t,e,o){"use strict";var i=function(){this.highestDistanceHoldToFiltered=0,this.highestDistanceHoldToOptimal=0,this.highestDistanceOptimalToFiltered=0,this.highestVelocityFiltered=0};i.prototype.compute=function(t,e,o){this.highestDistanceHoldToFiltered=0,this.highestDistanceHoldToOptimal=0,this.highestDistanceOptimalToFiltered=0,this.highestVelocityFiltered=0;for(var i=t.getDOFIndices(),n=0;nthis.highestDistanceHoldToFiltered&&(this.highestDistanceHoldToFiltered=s),a>this.highestDistanceHoldToOptimal&&(this.highestDistanceHoldToOptimal=a),l>this.highestDistanceOptimalToFiltered&&(this.highestDistanceOptimalToFiltered=l),c>this.highestVelocityFiltered&&(this.highestVelocityFiltered=c)}},e.exports=i},{}],104:[function(t,e,o){"use strict";var i=t("../base/Pose"),n=function(t){this._undershootTarget=0,null!=t&&(this._undershootTarget=t),this._currentDesiredDelta=new i("LNTA Delta");var e=this;this._absMaxValue=function(t,o){var i=e._undershootTarget,n=[];return o.length>0&&(n[0]=Math.max(-i,Math.min(i,o[0]))),n},this._lastWorldTarget=null};n.prototype.reComputeDelta=function(t,e,o,n){null!=n&&n.refineToLocallyClosestTargetPose(e,t),i.subtract(e,t,!1,o),i.computeUnary(o,this._absMaxValue,!1,o)},n.prototype.setMaxDelta=function(t){this._undershootTarget=t,this._lastWorldTarget=null},n.prototype.adjustTarget=function(t,e,o,n,r){0!==this._undershootTarget?(null===this._lastWorldTarget?(this._lastWorldTarget=o.clone(),this.reComputeDelta(t,e,this._currentDesiredDelta,n)):this._lastWorldTarget.distanceToSquared(o)>.001&&(this._lastWorldTarget.copy(o),this.reComputeDelta(t,e,this._currentDesiredDelta,n)),i.add(t,this._currentDesiredDelta,!1,r)):t!==r&&r.setPose(t)},e.exports=n},{"../base/Pose":76}],105:[function(t,e,o){"use strict";var i=function(t,e,o,i,n,r,s,a,l,c){this._lastTarget=null,this._targetChangedWindupThreshold=t,this._trajectoryParams={maxAllowedTriggerSpeed:e,minAllowedTriggerDistance:o,maxAllowedTriggerDistance:i,windupDistanceRatio:n,windupMinDistance:r,windupMaxDistance:s,overshootDistanceRatio:a,overshootMinDistance:l,overshootMaxDistance:c}};i.prototype.configureFilter=function(t){t.configure(this._trajectoryParams)},i.prototype.shouldWindup=function(t,e,o,i){var n=!1;return(null===this._lastTarget||this._lastTarget.distanceTo(i)>this._targetChangedWindupThreshold)&&(n=!0),null===this._lastTarget?this._lastTarget=i.clone():this._lastTarget.copy(i),n},e.exports=i},{}],106:[function(t,e,o){"use strict";var i=t("../base/Pose"),n=function(t,e){var o,n,r=[];for(this._lookatNodes=t,o=0;oi&&(i=o);else{var n={};for(e=0;ei&&(i=o),n[s.getName()]=!0)}}}return i},n.prototype.getHoldReached=function(t){var e,o,i=!0,n=this._lookatNodes;if(null==t){for(e=0;ea&&(i.error("Clamping OST application of stabilization velocity of "+_+" to "+h.getDOFNameForIndex(m)+" as it is greater than "+a),_=_<0?-a:a),r.setByIndex(m,f-_,1)}},this.reset=function(){o=!1}};e.exports=a},{"../../ifr-core/SLog":55,"../base/Pose":76,"./LookatNode":102,three:void 0}],108:[function(t,e,o){"use strict";var i=t("./PointADOF"),n=t("./LookatDOF"),r=function(t,e,o,i,r,s,a,l){n.call(this,t,e),this._control=null,this._forwardDir=i,this._centralTransformName=o,this._internalDistance=s,this._planeNormal=r,this._controlledTransform=null,this._centralTransform=null,this._dofMin=a,this._dofMax=l};r.prototype=Object.create(n.prototype),r.prototype.constructor=r,r.prototype.connectToGroup=function(t){n.prototype.connectToGroup.call(this,t),this._kinematicGroup?(this._control=this._kinematicGroup.getModelControlGroup().getControlForDOF(this._controlledDOFName),this._controlledTransform=this._kinematicGroup.getTransform(this._control.getTransformName()),this._centralTransform=this._kinematicGroup.getTransform(this._centralTransformName)):(this._control=null,this._controlledTransform=null,this._centralTransform=null)},r.prototype.valToPointAtTarget=function(t,e,o){var n=i.planeIntersectFromRear(this._centralTransform,t,null,this._forwardDir,this._planeNormal,this._internalDistance,e);return Math.max(Math.min(n,this._dofMax),this._dofMin)},r.prototype.errorRatio=function(t){return Math.abs(t/(this._dofMax-this._dofMin))},r.prototype.suggestForwardTarget=function(t){return null==this._centralTransform?null:(t.copy(this._forwardDir),t.multiplyScalar(10),this._centralTransform.localToWorld(t),t)},r.getVectorFromOrthogonalPDLDs=function(t,e,o,n,r){return i.vectorFromPlaneIntersections(t._centralTransform,null,t._forwardDir,o.get(t._controlledDOFName,0),t._planeNormal,t._internalDistance,o.get(e._controlledDOFName,0),e._planeNormal,e._internalDistance,n,r)},e.exports=r},{"./LookatDOF":100,"./PointADOF":109}],109:[function(t,e,o){"use strict";var i=t("three"),n=t("../../ifr-core/SLog"),r=t("../../ifr-geometry/ExtraMath"),s="LOOKAT",a=.001,l=a*a,c=null,u=function(){this._angleToAxis=null,this._distanceToTarget=null},h={name:"PointADOF"};h.PointReport=u,h.setVisHelper=function(t){c=t};var p=function(t){return t=Math.abs(t%Math.PI),t=Math.abs(Math.PI/2-t),t=Math.PI/2-t},d=function(t,e){var o=(new i.Vector3).copy(t),r=o.angleTo(e),l=o.multiplyScalar(-1).angleTo(e);return r<=l?r>.1&&p(t.w)>a?(n(s,"Error, computed axis ("+o.x+", "+o.y+", "+o.z+") not so close ("+r+") to references axis ("+e.x+", "+e.y+", "+e.z+"), angle = "+t.w),null):t.w:l>.1&&p(t.w)>a?(n(s,"Error, computed axis ("+o.x+", "+o.y+", "+o.z+") not so close ("+r+") to references axis ("+e.x+", "+e.y+", "+e.z+"), angle = "+t.w),null):-t.w};h.getRelativeAngle=function(t,e,o,r,a,u){null==o&&(o=new i.Vector3(0,0,0));var h=t.worldToLocal((new i.Vector3).copy(e)),m=(new i.Vector3).copy(h).sub(o);u&&(u._angleToAxis=p(m.angleTo(a)),u._distanceToTarget=m.length());var f=(new i.Vector3).copy(r).projectOnPlane(a),g=(new i.Vector3).copy(m).projectOnPlane(a);if(f.lengthSq()=Math.PI/2?Number.POSITIVE_INFINITY:d<=-Math.PI/2?Number.NEGATIVE_INFINITY:Math.tan(d)*l,null!==c&&c.shouldDraw(this)){var f=t.worldToLocal((new i.Vector3).copy(e));c.drawLineLocal(this,"PlaneIntersectFromRear:InternalToTarget",t,p,f,new i.Color(1,1,0))}return m}return n(s,"Plane intersect error, could not get angle"),null},h.vectorFromPlaneIntersections=function(t,e,o,a,c,u,h,p,d,m,f){null==e&&(e=new i.Vector3(0,0,0));var g=(new i.Vector3).crossVectors(c,o);if(g.lengthSq()Math.PI/2&&(o=(new i.Vector3).copy(o).multiplyScalar(-1)),0!==r){var T=(new i.Vector3).copy(v);T.multiplyScalar(r/T.length()),f.sub(T)}if(0!==u){var D=(new i.Vector3).crossVectors(v,f).normalize();f.applyAxisAngle(D,u)}if(null!==c&&c.shouldDraw(this)){var O=(new i.Vector3).copy(y).setLength(r);c.drawRayLocal(this,"Plane:Normal",e,O,o,new i.Color(1,1,1));var L=(new i.Vector3).copy(y).setLength(r);c.drawConeLocal(this,"Plane:Surface",e,L,o,u,new i.Color(1,0,1))}var F=(new i.Vector3).copy(o).applyQuaternion(_),w=v.angleTo(F);if(wp&&(p=m)}return p},a.prototype._advanceFixedTimeMode=function(t,e,o,n,r,a){var l,c,u,h,p;if(e>this._epsilon)for(var d=0;ds&&(i.error("PoseOffsetFilter:Clamping application of unfiltered offset of "+c+" to "+a.getDOFNameForIndex(o)+" as it is greater than "+s),c=c<0?-s:s);var u=a.getByIndex(o,0);null!==u&&(u+=c),a.setByIndex(o,u,0)}},e.exports=a},{"../../ifr-core/SLog":55,"../base/AccelPlanner":65,"../base/Pose":76}],111:[function(t,e,o){"use strict";var i=t("../../ifr-core/SLog"),n=t("../base/Pose"),r=t("./PoseOffsetFilter"),s="LOOKAT",a={NONE:4,WINDING_ACCEL:1,WINDING_DECEL:2,WINDING_RESTORING:3},l=function(t){r.call(this,t),this._shouldStartWindup=!1,this._windupTimeRemaining=0,this._windupTimeToZeroVRemaining=0,this._windupTimeToZeroPRemaining=0,this._windupAccel=new n("windup accel",t),this._targetOvershootDelta=new n("target overshoot delta",t),this._overshootModifiedTarget=new n("target for overshoot",t),this._weAreOvershooting=!1,this._maxAllowedTriggerSpeed=.005,this._minAllowedTriggerDistance=.01,this._maxAllowedTriggerDistance=1/0,this._windupDistanceRatio=.05,this._windupMaxDistance=.002,this._windupMinDistance=.001,this._overshootDistanceRatio=.05,this._overshootMaxDistance=.002,this._overshootMinDistance=.001};l.prototype=Object.create(r.prototype),l.prototype.constructor=l,l.WindupState=a,l.prototype.configure=function(t){(this._windupTimeRemaining>0||this._weAreOvershooting)&&(i(s,"PoseOffsetFilterWindup: cancelling running windup/overshoot because we are being reconfigured during execution"),this._windupTimeRemaining=0,this._windupTimeToZeroPRemaining=0,this._windupTimeToZeroVRemaining=0,this._weAreOvershooting=!1),null!=t.maxAllowedTriggerSpeed&&(this._maxAllowedTriggerSpeed=t.maxAllowedTriggerSpeed),null!=t.minAllowedTriggerDistance&&(this._minAllowedTriggerDistance=t.minAllowedTriggerDistance),null!=t.maxAllowedTriggerDistance&&(this._maxAllowedTriggerDistance=t.maxAllowedTriggerDistance),null!=t.windupDistanceRatio&&(this._windupDistanceRatio=t.windupDistanceRatio),null!=t.windupMinDistance&&(this._windupMinDistance=t.windupMinDistance),null!=t.windupMaxDistance&&(this._windupMaxDistance=t.windupMaxDistance),null!=t.overshootDistanceRatio&&(this._overshootDistanceRatio=t.overshootDistanceRatio),null!=t.overshootMinDistance&&(this._overshootMinDistance=t.overshootMinDistance),null!=t.overshootMaxDistance&&(this._overshootMaxDistance=t.overshootMaxDistance)},l.prototype.startWindupIfPossible=function(){0===this._windupDistanceRatio&&0===this._overshootDistanceRatio||(this._shouldStartWindup=!0)};var c=function(t,e,o,i,n,r){for(var s=0,a=0,l=0;ls&&(s=u),h>a&&(a=h)}return s<=i&&a>=n&&a<=r},u=function(t,e,o,i,n,r){var s,a,l=0;for(a=0;al){var h=o.getByIndex(c,0),p=o.getByIndex(c,1),d=e.getByIndex(c,0),m=n.computeWithFixedTime(p,0,d-h,t);if(m&&m.isConsistent()){var f=m._acceleration;r.setByIndex(c,-f,0)}else i(s,"PoseOffsetFilter(cwa) for "+o.getDOFNameForIndex(c)+" got invalid plan, dof will have no windup! (currentVel:"+p+", target:"+d+", currentPos:"+h+", totalTransitTime:"+t+")"),r.setByIndex(c,0,0)}else r.setByIndex(c,0,0)},d=function(t,e,o,i,n,r,s){var a,l;if(e>s&&0!==i){var c=i;for(e*cr&&(c=1/e*r),l=0;l0&&(this._windupTimeToZeroVRemaining=Math.max(0,this._windupTimeToZeroVRemaining-t),this._windupTimeToZeroPRemaining=Math.max(0,this._windupTimeToZeroPRemaining-t)),this._windupTimeRemaining>0){var u=Math.min(t,this._windupTimeRemaining); for(this._windupTimeRemaining=Math.max(0,this._windupTimeRemaining-t),t-=u,l=0;lthis._epsilon&&this._advanceFixedTimeMode(t,e,o,i,n,s)},l.prototype.getWindupState=function(){return this._windupTimeToZeroPRemaining>0?this._windupTimeRemaining>0?a.WINDING_ACCEL:this._windupTimeToZeroVRemaining>0?a.WINDING_DECEL:a.WINDING_RESTORING:a.NONE},l.prototype.updateByTime=function(t){var e,o=this._dofIndices,n=this._dofIndices.length,r=this._targetPose;if(this._shouldStartWindup&&(this._weAreOvershooting||this._windupTimeRemaining>0)&&(this._weAreOvershooting=!1,this._windupTimeRemaining=0,this._windupTimeToZeroVRemaining=0,this._windupTimeToZeroPRemaining=0,i(s,"PoseOffsetFilterWindup: cancelling existing windup/overshoot plan, asked for a new one during execution")),this._weAreOvershooting){for(var a=!1,l=0;l0&&m>0||_<0&&m<0?(a=!0,this._overshootModifiedTarget.setByIndex(e,f+m,0)):this._overshootModifiedTarget.setByIndex(e,f,0)}a?r=this._overshootModifiedTarget:this._weAreOvershooting=!1}var y=this._timeForLongestDOF(r,this._filteredPose,this._accelPlanner,this._accLimit,o);if(this._shouldStartWindup){this._shouldStartWindup=!1;var v=c(this._targetPose,this._filteredPose,o,this._maxAllowedTriggerSpeed,this._minAllowedTriggerDistance,this._maxAllowedTriggerDistance);if(v){var T=h(this._targetPose,this._filteredPose,this._targetOvershootDelta,o,this._epsilon);this._overshootDistanceRatio>0&&(d(this._targetOvershootDelta,T,o,this._overshootDistanceRatio,this._overshootMinDistance,this._overshootMaxDistance,this._epsilon),this._weAreOvershooting=!0),0!==this._windupDistanceRatio&&(p(y,this._targetPose,this._filteredPose,this._accelPlanner,this._windupAccel,o,this._epsilon),this._windupTimeRemaining=u(this._windupAccel,T,this._windupDistanceRatio,this._windupMinDistance,this._windupMaxDistance,o),this._windupTimeToZeroVRemaining=2*this._windupTimeRemaining,this._windupTimeToZeroPRemaining=this._windupTimeRemaining*Math.sqrt(2)+this._windupTimeToZeroVRemaining)}else this._weAreOvershooting=!1,this._windupTimeRemaining=0,this._windupTimeToZeroVRemaining=0,this._windupTimeToZeroPRemaining=0}this._advanceFixedTimeModeWindup(t,y,r,this._filteredPose,this._accelPlanner,this._windupAccel,o)},e.exports=l},{"../../ifr-core/SLog":55,"../base/Pose":76,"./PoseOffsetFilter":110}],112:[function(t,e,o){"use strict";var i=t("three"),n=t("./PointADOF"),r=t("./LookatDOF"),s=function(t,e,o){r.call(this,t,e),this._control=null,this._forwardDir=o,this._transform=null,this._axis=null};s.prototype=Object.create(r.prototype),s.prototype.constructor=s,s.prototype.connectToGroup=function(t){r.prototype.connectToGroup.call(this,t),this._kinematicGroup?(this._control=this._kinematicGroup.getModelControlGroup().getControlForDOF(this._controlledDOFName),this._transform=this._kinematicGroup.getTransform(this._control.getTransformName()),this._axis=new i.Vector3,this._control.getRotationalAxis(this._axis)):(this._transform=null,this._control=null,this._axis=null)},s.prototype.valToPointAtTarget=function(t,e,o){return n.pointDOF(this._control,this._transform,this._forwardDir,t,e)},s.prototype.errorRatio=function(t){return this._control.isCyclic()?Math.abs(t/(2*Math.PI)):Math.abs(t/(this._control.getMax()-this._control.getMin()))},s.prototype.suggestForwardTarget=function(t){return null==this._transform?null:(t.copy(this._forwardDir),t.multiplyScalar(10),this._transform.localToWorld(t),t)},e.exports=s},{"./LookatDOF":100,"./PointADOF":109,three:void 0}],113:[function(t,e,o){"use strict";var i=t("three"),n=t("./PointADOF"),r=t("./LookatDOF"),s=t("../../ifr-geometry/ExtraMath"),a=t("../../ifr-motion/base/CyclicMath"),l=function(t,e,o,i,n,s){r.call(this,t,e),this._control=null,this._planeNormal=o,this._distanceAlongDOFAxisToPlane=i,this._angleAbovePlane=n,this._transform=null,this._chooseCloserSolution=s};l.prototype=Object.create(r.prototype),l.prototype.constructor=l,l.prototype.connectToGroup=function(t){r.prototype.connectToGroup.call(this,t),t?(this._control=this._kinematicGroup.getModelControlGroup().getControlForDOF(this._controlledDOFName),this._transform=this._kinematicGroup.getTransform(this._control.getTransformName())):(this._transform=null,this._control=null)},l.prototype.valToPointAtTarget=function(t,e,o){var i=n.pointDOFToIntersectConeWithPoint(this._control,this._transform,this._planeNormal,this._distanceAlongDOFAxisToPlane,t,this._angleAbovePlane,!0,e);if(i&&i.length>0){var r=i[0];if(i.length>1&&this._chooseCloserSolution){var s=a.closestEquivalentRotation(o.get(this._controlledDOFName,0),0),l=a.closestEquivalentRotation(i[0],s),c=a.closestEquivalentRotation(i[1],s);r=Math.abs(l-s)<=Math.abs(c-s)?l:c}return r}},l.prototype.errorRatio=function(t){return this._control.isCyclic()?Math.abs(t/(2*Math.PI)):Math.abs(t/(this._control.getMax()-this._control.getMin()))},l.prototype.suggestForwardTarget=function(t){if(null==this._transform)return null;var e=new i.Vector3;this._control.getRotationalAxis(e);var o=new i.Vector3;s.findOrthogonal(this._planeNormal,o);var n=new i.Vector3;n.crossVectors(o,this._planeNormal);var r=new i.Quaternion;return s.quatFromAxisAngle(n,this._angleAbovePlane,r),o.applyQuaternion(r),e.setLength(this._distanceAlongDOFAxisToPlane),o.setLength(10),t.copy(o),t.add(e),this._transform.localToWorld(o),t},e.exports=l},{"../../ifr-geometry/ExtraMath":60,"../../ifr-motion/base/CyclicMath":68,"./LookatDOF":100,"./PointADOF":109,three:void 0}],114:[function(t,e,o){"use strict";var i=t("./TrackPolicyTrigger"),n={TRACK:"TRACK",TRACK_SACCADE:"TRACK_SACCADE",HOLD:"HOLD",DELAY:"DELAY"},r=function(t){this._currentMode=n.HOLD,this._checkers=t,this._lastTime=null,this._trackPolicyListeners=null};r.TrackMode=n,r.prototype.addListener=function(t){null===this._trackPolicyListeners&&(this._trackPolicyListeners=[]),this._trackPolicyListeners.indexOf(t)===-1&&this._trackPolicyListeners.push(t)},r.prototype.removeListener=function(t){if(null!==this._trackPolicyListeners){var e=this._trackPolicyListeners.indexOf(t);e!==-1&&this._trackPolicyListeners.splice(e,1),0===this._trackPolicyListeners.length&&(this._trackPolicyListeners=null)}},r.prototype.computeMode=function(t,e){var o,r=!1,s=0;if(null!==this._lastTime&&(s=e.subtract(this._lastTime)),this._lastTime=e,this._currentMode===n.HOLD){var a=!1;for(o=0;o=this._limitOuter&&this._moveImmediatelyPastOuter)this._accumValueCurrent=1,o=i.StartStatus.YES;else if(this._limitOuter>this._limitInner){n=Math.max(this._limitInner,Math.min(this._limitOuter,n));var r=(n-this._limitInner)/(this._limitOuter-this._limitInner),s=(1-r)*this._accumValueInner+r*this._accumValueOuter;this._accumValueCurrent+=s*e,o=this._accumValueCurrent>1?i.StartStatus.YES:i.StartStatus.LATER}return o},n.prototype.reset=function(){this._accumValueCurrent=0},e.exports=n},{"./TrackPolicyTrigger":115}],118:[function(t,e,o){"use strict";var i=t("./TrackPolicyTrigger"),n=function(t,e,o){i.call(this),this._deadZone=t,this._deadTime=e,this._deadVelocity=o,this._deadTimeAccumulated=0};n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.shouldStopTracking=function(t,e){var o=t.highestDistanceOptimalToFiltered,i=t.highestVelocityFiltered;return o<=this._deadZone&&i<=this._deadVelocity?this._deadTimeAccumulated+=e:this._deadTimeAccumulated=0,this._deadTimeAccumulated>this._deadTime},n.prototype.reset=function(){this._deadTimeAccumulated=0},e.exports=n},{"./TrackPolicyTrigger":115}],119:[function(t,e,o){"use strict";var i=t("./TrackPolicyTrigger"),n=function(){i.call(this),this._otherNodeIsTracking=!1,this._triggerThisNodeWhenOtherTracks=!0};n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.setTriggerThisNodeOnOtherNode=function(t){this._triggerThisNodeWhenOtherTracks=t},n.prototype.shouldStartTracking=function(t,e){var o=null;return o=this._otherNodeIsTracking&&this._triggerThisNodeWhenOtherTracks?i.StartStatus.YES:i.StartStatus.NO,this._otherNodeIsTracking=!1,o},n.prototype.notifyTrackStarted=function(){},n.prototype.notifyTrackStopped=function(){},n.prototype.notifyTrackMode=function(t){"TRACK"===t&&(this._otherNodeIsTracking=!0)},e.exports=n},{"./TrackPolicyTrigger":115}],120:[function(t,e,o){"use strict";var i=t("three"),n=t("./GLLinePool"),r=function(t){this._groundPlaneNormal=t,this._target=null,this._linePool=null,this._renderCallback=null,this._lineWidth=1,this._brightness=1,this._baseColor=new i.Color(1,0,1)};r.prototype.setPosition=function(t){null===this._target&&null!==t?this._target=new i.Vector3(t.x,t.y,t.z):null==t?this._target=null:this._target.copy(t)},r.prototype.installRendererIntoScene=function(t){if(null!=this._linePool||null!=this._renderCallback)throw new Error("Remove VTP renderer from existing scene before installing in another!");this._linePool=new n(t,10);var e=this;this._renderCallback=function(){if(null!=e._target){var t=e._target,o=e._brightness,n=e._baseColor;e._linePool.setLineWidth(e._lineWidth);var r=.05;e._linePool.drawOnce((new i.Vector3).copy(t).add(new i.Vector3(r,0,0)),(new i.Vector3).copy(t).sub(new i.Vector3(r,0,0)),new i.Color(1*o,0,0)),e._linePool.drawOnce((new i.Vector3).copy(t).add(new i.Vector3(0,r,0)),(new i.Vector3).copy(t).sub(new i.Vector3(0,r,0)),new i.Color(0,1*o,0)),e._linePool.drawOnce((new i.Vector3).copy(t).add(new i.Vector3(0,0,r)),(new i.Vector3).copy(t).sub(new i.Vector3(0,0,r)),new i.Color(.2*o,.2*o,1*o));var s=(new i.Vector3).copy(t).projectOnPlane(e._groundPlaneNormal);e._linePool.drawOnce((new i.Vector3).copy(s).add(new i.Vector3(r,r,0)),(new i.Vector3).copy(s).sub(new i.Vector3(r,r,0)),new i.Color(n.r*o,n.g*o,n.b*o)),e._linePool.drawOnce((new i.Vector3).copy(s).add(new i.Vector3(r,-r,0)),(new i.Vector3).copy(s).sub(new i.Vector3(r,-r,0)),new i.Color(n.r*o,n.g*o,n.b*o)),e._linePool.drawOnce(s,t,new i.Color(n.r*o,n.g*o,n.b*o))}},t.addRenderCallback(this._renderCallback)},r.prototype.removeRendererFromScene=function(t){null!=this._linePool&&this._linePool.removeFromScene(t),null!=this._renderCallback&&t.removeRenderCallback(this._renderCallback),this._linePool=null,this._renderCallback=null},r.prototype.setLineWidth=function(t){this._lineWidth=t},r.prototype.setBrightness=function(t){this._brightness=t},r.prototype.setBaseColor=function(t){this._baseColor.set(t)},e.exports=r},{"./GLLinePool":122,three:void 0}],121:[function(t,e,o){"use strict";var i=t("./TrackballControls"),n=t("three"),r=t("stats-js"),s=function(t,e,o,i){if(this._container=void 0!==t?t:null,this._container){var r=this._container.getBoundingClientRect();this._width=r.width,this._height=r.height}else this._width=100,this._height=100;this._workaroundElementReadyRace=!0,this._camera=new n.PerspectiveCamera(60,this._width/this._height,.1,1e3),this._camera.position.z=20,this._scene=new n.Scene,this._ambientLight=new n.AmbientLight(4210752),this._scene.add(this._ambientLight),this._directionalLight=new n.DirectionalLight(16777215,.5),this._directionalLight.position.set(-1,1,1),this._scene.add(this._directionalLight),this._renderer=new n.WebGLRenderer({antialias:!0}),this._renderer.setSize(this._width,this._height),i&&this._renderer.setClearColor(i),this._renderOnlyWhenDirty=!1,this._dirty=!0,this._renderEveryNFRames=1,this._frameSkipCounter=0,this._container&&(this._container.appendChild(this._renderer.domElement),this._workaroundElementReadyRace&&setTimeout(this.markDirty.bind(this),200)),this._renderCallbacks=[],this._postRenderCallbacks=[],this._controls=null,e&&this.installTrackballControls(),this._stats=null,o&&this.installStats(),this._doPlay=this.play.bind(this),this._markDirty=this.markDirty.bind(this)};s.prototype.installTrackballControls=function(){null===this._controls&&(this._dirty=!0,this._controls=new i(this._camera,this._container),this._controls.rotateSpeed=1,this._controls.zoomSpeed=1.2,this._controls.panSpeed=1,this._controls.noZoom=!1,this._controls.noPan=!1,this._controls.staticMoving=!0,this._controls.dynamicDampingFactor=.3,this._controls.keys=[65,83,68],this._container&&(this._container.addEventListener("mousewheel",this._markDirty),this._container.addEventListener("mousemove",this._markDirty)))},s.prototype.removeTrackballControls=function(){null!==this._controls&&(this._dirty=!0,this._container&&(this._container.removeEventListener("mousewheel",this._markDirty),this._container.removeEventListener("mousemove",this._markDirty)),this._controls.dispose(),this._controls=null)},s.prototype.installStats=function(){this._dirty=!0,this._stats=new r,this._stats.domElement.style.position="absolute",this._stats.domElement.style.top="0px",this._stats.domElement.style.zIndex=100,this._container&&this._container.appendChild(this._stats.domElement)},s.prototype.setRenderOnlyWhenDirty=function(t){this._renderOnlyWhenDirty=t},s.prototype.setRenderEveryNFrames=function(t){this._renderEveryNFRames=t},s.prototype.markDirty=function(){this._dirty=!0},s.prototype.handleResize=function(){if(!this._container)return!1;var t=this._container.getBoundingClientRect();return(t.width!==this._width||t.height!==this._height)&&(this._width=t.width,this._height=t.height,this._camera.aspect=this._width/this._height,this._camera.updateProjectionMatrix(),this._renderer.setSize(this._width,this._height),null!==this._controls&&this._controls.handleResize(),!0)},s.prototype.detachFromContainer=function(){this.stop(),this._container&&(this._container.removeChild(this._renderer.domElement),this._controls&&(this._controls.detachFromContainer(),this._container.removeEventListener("mousewheel",this._markDirty),this._container.removeEventListener("mousemove",this._markDirty)),this._stats&&this._container.removeChild(this._stats.domElement),this._container=null)},s.prototype.attachToContainer=function(t){if(this._dirty=!0,this._container&&this.detachFromContainer(),this._container=void 0!==t?t:null,this._container){var e=this._container.getBoundingClientRect();if(this._width=e.width,this._height=e.height,this._camera.aspect=this._width/this._height,this._camera.updateProjectionMatrix(),this._renderer.setSize(this._width,this._height),this._renderer.domElement=document.adoptNode(this._renderer.domElement),this._container.appendChild(this._renderer.domElement),this._workaroundElementReadyRace){var o=this;setInterval(function(){o.markDirty()},200)}this._controls&&(this._controls.attachToContainer(this._container),this._container.addEventListener("mousewheel",this._markDirty),this._container.addEventListener("mousemove",this._markDirty)),this._stats&&(this._stats.domElement=document.adoptNode(this._stats.domElement),this._container.appendChild(this._stats.domElement))}},s.prototype.dispose=function(){this.detachFromContainer(),this.removeTrackballControls(),this._camera=null,this._scene=null,this._ambientLight=null,this._directionalLight=null,this._renderer=null,this._renderCallbacks=null,this._postRenderCallbacks=null,this._controls=null,this._stats=null},s.prototype.getContainer=function(){return this._container},s.prototype.getCamera=function(){return this._camera},s.prototype.getScene=function(){return this._scene},s.prototype.getAmbientLight=function(){return this._ambientLight},s.prototype.getDirectionalLight=function(){return this._directionalLight},s.prototype.getRenderer=function(){return this._renderer},s.prototype.getTrackballControls=function(){return this._controls},s.prototype.getStats=function(){return this._stats},s.prototype.addRenderCallback=function(t){this._dirty=!0,this._renderCallbacks.push(t)},s.prototype.removeRenderCallback=function(t){this._dirty=!0;var e=this._renderCallbacks.indexOf(t);e>-1&&this._renderCallbacks.splice(e,1)},s.prototype.addPostRenderCallback=function(t){this._dirty=!0,this._postRenderCallbacks.push(t)},s.prototype.removePostRenderCallback=function(t){this._dirty=!0;var e=this._postRenderCallbacks.indexOf(t);e>-1&&this._postRenderCallbacks.splice(e,1)},s.prototype.render=function(){var t=this.handleResize();if(this._frameSkipCounter++,this._frameSkipCounter>=this._renderEveryNFRames&&(!this._renderOnlyWhenDirty||t||this._dirty)){null!==this._controls&&this._controls.update();for(var e=0;e=0?this.leasedLines.splice(e,1):console.log("Error, cannot return line that has not been leased!("+t+")")},r.prototype.returnAllLeased=function(){this.leasedLines.length=0},r.prototype.setLineWidth=function(t){return this.lineMaterial.linewidth=t,this},r.prototype.prepareForRender=function(){for(var t=0;t0){for(var t=0;t1)return null;if(s===!0&&(Math.abs(a.x)>1||Math.abs(a.y)>1))return null;var l=r.getBoundingClientRect(),c=l.width,u=l.height;return{x:a.x*c/2+c/2,y:-a.y*u/2+u/2}},s.getLocalCoordinates=function(t,e){var o=s.getOffsetRect(e);return{x:t.pageX-o.left,y:t.pageY-o.top}},s.getLocalCoordinatesNDC=function(t,e){var o=s.getOffsetRect(e);return{x:(t.pageX-o.left)/o.width,y:1-(t.pageY-o.top)/o.height}},s.getLocalCoordinatesNDCCentered=function(t,e){var o=s.getOffsetRect(e);return{x:(t.pageX-o.left)/o.width*2-1,y:2*(1-(t.pageY-o.top)/o.height)-1}},s.unprojectScreenToPlane=function(t,e,o,s,a){var l=new i.Vector3(t,e,0),c=new i.Vector3(t,e,1);l.unproject(o),c.unproject(o);var u=c.sub(l),h=l;u.normalize();var p=(new i.Vector3).copy(s).sub(h),d=u.dot(a);if(Math.abs(d)<1e-4)return void n(r,"un-project error, no intersection");var m=p.dot(a)/u.dot(a);return m<0?void n(r,"error, intersection behind camera"):h.add(u.multiplyScalar(m))},s.unprojectEventToPlane=function(t,e,o,n,r){var a=s.getLocalCoordinatesNDCCentered(t,e);return void 0===n&&(n=new i.Vector3(0,0,0)),void 0===r&&(r=new i.Vector3(0,1,0)),s.unprojectScreenToPlane(a.x,a.y,o,n,r)},e.exports=s},{"../ifr-core/SLog":55,three:void 0}],125:[function(t,e,o){"use strict";var i=t("three"),n=t("./MouseCoordinateWrangler"),r=t("./ViewportTargetPositioner"),s=t("../ifr-core/SLog"),a="UI_TARGET",l=function(t,e,o,l,c,u){null==o&&(o=new i.Vector3(0,0,0)),null==l&&(l=new i.Vector3(0,0,0)),null==c&&(c=new i.Vector3(0,1,0)),null==u&&(u=["default"]);var h=[],p=new Map,d=null,m=!0,f=null,g=null,_=null,y=null,v=function(e){e.preventDefault(),e.stopPropagation();var o=n.getLocalCoordinatesNDCCentered(e,t);if(null!=d){var i=p.get(d);null!=i&&(g(e)?i.moveToNDCPoint(o.x,o.y,!0):_(e)&&i.moveToNDCPoint(o.x,o.y,!1))}},T=function(t){f(t)&&v(t)},D=!0,O=function(e){D?(document.removeEventListener("mousemove",T,m),document.removeEventListener("mouseup",O,m)):(t.removeEventListener("mousemove",T,m),t.removeEventListener("mouseup",O,m),t.removeEventListener("mouseleave",O,m))};t.addEventListener("mousedown",function(e){f(e)&&(v(e),D?(document.addEventListener("mousemove",T,m),document.addEventListener("mouseup",O,m)):(t.addEventListener("mousemove",T,m),t.addEventListener("mouseup",O,m),t.addEventListener("mouseleave",O,m)))},m),this.setMouseFilters=function(t,e,o){f=null!=t?t:function(t){return!t.altKey&&!t.metaKey&&!t.ctrlKey},g=null!=e?e:function(t){return t.shiftKey},_=null!=o?o:function(t){return!t.shiftKey}},this.addPositionChangedCallback=function(t){var e=h.indexOf(t);e<0&&h.push(t)},this.removePositionChangedCallback=function(t){var e=h.indexOf(t);e>-1&&h.splice(e,1)},this.notifyPositionChangedCallbacks=function(t,e){for(var o=0;o=0?(this.onElement.removeChild(t.div),this.leasedElements.splice(e,1)):console.log("Error, cannot return leased text element that is not been leased!("+(null==t?"null":t.div.innerHTML)+")")},r.prototype.returnAllLeased=function(){for(;this.leasedElements.length>0;){var t=this.leasedElements.pop();this.onElement.removeChild(t.div)}},r.prototype.postRenderCleanup=function(){for(;this.drawOnceElements.length>0;){var t=this.drawOnceElements.pop();this.onElement.removeChild(t.div)}},e.exports=r},{}],127:[function(t,e,o){"use strict";var i=t("three"),n=function(t,e){function o(t){d.enabled!==!1&&(window.removeEventListener("keydown",o),y=_,_===m.NONE&&(t.keyCode!==d.keys[m.ROTATE]||d.noRotate?t.keyCode!==d.keys[m.ZOOM]||d.noZoom?t.keyCode!==d.keys[m.PAN]||d.noPan||(_=m.PAN):_=m.ZOOM:_=m.ROTATE))}function n(t){d.enabled!==!1&&(_=y,window.addEventListener("keydown",o,!1))}function r(t){d.enabled!==!1&&(t.preventDefault(),t.stopPropagation(),_===m.NONE&&(_=t.button,0===t.button&&t.shiftKey&&(_=m.PAN)),_!==m.ROTATE||d.noRotate?_!==m.ZOOM||d.noZoom?_!==m.PAN||d.noPan||(S.copy(N(t.pageX,t.pageY)),b.copy(S)):(O.copy(N(t.pageX,t.pageY)),L.copy(O)):(T.copy(E(t.pageX,t.pageY)),D.copy(T)),document.addEventListener("mousemove",s,!1),document.addEventListener("mouseup",a,!1),d.dispatchEvent(C))}function s(t){d.enabled!==!1&&(t.preventDefault(),t.stopPropagation(),_!==m.ROTATE||d.noRotate?_!==m.ZOOM||d.noZoom?_!==m.PAN||d.noPan||b.copy(N(t.pageX,t.pageY)):L.copy(N(t.pageX,t.pageY)):D.copy(E(t.pageX,t.pageY)))}function a(t){d.enabled!==!1&&(t.preventDefault(),t.stopPropagation(),_=m.NONE,document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",a),d.dispatchEvent(P))}function l(t){if(d.enabled!==!1){t.preventDefault(),t.stopPropagation();var e=0;t.wheelDelta?e=t.wheelDelta/40:t.detail&&(e=-t.detail/3),O.y+=.01*e,d.dispatchEvent(C),d.dispatchEvent(P)}}function c(t){if(d.enabled!==!1){switch(t.touches.length){case 1:_=m.TOUCH_ROTATE,T.copy(E(t.touches[0].pageX,t.touches[0].pageY)),D.copy(T);break;case 2:_=m.TOUCH_ZOOM_PAN;var e=t.touches[0].pageX-t.touches[1].pageX,o=t.touches[0].pageY-t.touches[1].pageY;w=F=Math.sqrt(e*e+o*o);var i=(t.touches[0].pageX+t.touches[1].pageX)/2,n=(t.touches[0].pageY+t.touches[1].pageY)/2;S.copy(N(i,n)),b.copy(S);break;default:_=m.NONE}d.dispatchEvent(C)}}function u(t){if(d.enabled!==!1)switch(t.preventDefault(),t.stopPropagation(),t.touches.length){ case 1:D.copy(E(t.touches[0].pageX,t.touches[0].pageY));break;case 2:var e=t.touches[0].pageX-t.touches[1].pageX,o=t.touches[0].pageY-t.touches[1].pageY;w=Math.sqrt(e*e+o*o);var i=(t.touches[0].pageX+t.touches[1].pageX)/2,n=(t.touches[0].pageY+t.touches[1].pageY)/2;b.copy(N(i,n));break;default:_=m.NONE}}function h(t){if(d.enabled!==!1){switch(t.touches.length){case 1:D.copy(E(t.touches[0].pageX,t.touches[0].pageY)),T.copy(D);break;case 2:F=w=0;var e=(t.touches[0].pageX+t.touches[1].pageX)/2,o=(t.touches[0].pageY+t.touches[1].pageY)/2;b.copy(N(e,o)),S.copy(b)}_=m.NONE,d.dispatchEvent(P)}}function p(t){t.preventDefault()}var d=this,m={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4};this.object=t,this.domElement=null,this.enabled=!1,this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.noRoll=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.keys=[65,83,68],this.target=new i.Vector3;var f=1e-6,g=new i.Vector3,_=m.NONE,y=m.NONE,v=new i.Vector3,T=new i.Vector3,D=new i.Vector3,O=new i.Vector2,L=new i.Vector2,F=0,w=0,S=new i.Vector2,b=new i.Vector2;this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.up0=this.object.up.clone();var k={type:"change"},C={type:"start"},P={type:"end"};this.handleResize=function(){if(d.enabled!==!1)if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var t=this.domElement.getBoundingClientRect(),e=this.domElement.ownerDocument.documentElement;this.screen.left=t.left+window.pageXOffset-e.clientLeft,this.screen.top=t.top+window.pageYOffset-e.clientTop,this.screen.width=t.width,this.screen.height=t.height}},this.handleEvent=function(t){"function"==typeof this[t.type]&&this[t.type](t)};var N=function(){var t=new i.Vector2;return function(e,o){return t.set((e-d.screen.left)/d.screen.width,(o-d.screen.top)/d.screen.height),t}}(),E=function(){var t=new i.Vector3,e=new i.Vector3,o=new i.Vector3;return function(i,n){o.set((i-.5*d.screen.width-d.screen.left)/(.5*d.screen.width),(.5*d.screen.height+d.screen.top-n)/(.5*d.screen.height),0);var r=o.length();return d.noRoll?r1?o.normalize():o.z=Math.sqrt(1-r*r),v.copy(d.object.position).sub(d.target),t.copy(d.object.up).setLength(o.y),t.add(e.copy(d.object.up).cross(v).setLength(o.x)),t.add(v.setLength(o.z)),t}}();this.rotateCamera=function(){var t=new i.Vector3,e=new i.Quaternion;return function(){var o=Math.acos(T.dot(D)/T.length()/D.length());o&&(t.crossVectors(T,D).normalize(),o*=d.rotateSpeed,e.setFromAxisAngle(t,-o),v.applyQuaternion(e),d.object.up.applyQuaternion(e),D.applyQuaternion(e),d.staticMoving?T.copy(D):(e.setFromAxisAngle(t,o*(d.dynamicDampingFactor-1)),T.applyQuaternion(e)))}}(),this.zoomCamera=function(){var t;_===m.TOUCH_ZOOM_PAN?(t=F/w,F=w,v.multiplyScalar(t)):(t=1+(L.y-O.y)*d.zoomSpeed,1!==t&&t>0&&(v.multiplyScalar(t),d.staticMoving?O.copy(L):O.y+=(L.y-O.y)*this.dynamicDampingFactor))},this.panCamera=function(){var t=new i.Vector2,e=new i.Vector3,o=new i.Vector3;return function(){t.copy(b).sub(S),t.lengthSq()&&(t.multiplyScalar(v.length()*d.panSpeed),o.copy(v).cross(d.object.up).setLength(t.x),o.add(e.copy(d.object.up).setLength(t.y)),d.object.position.add(o),d.target.add(o),d.staticMoving?S.copy(b):S.add(t.subVectors(b,S).multiplyScalar(d.dynamicDampingFactor)))}}(),this.checkDistances=function(){d.noZoom&&d.noPan||(v.lengthSq()>d.maxDistance*d.maxDistance&&d.object.position.addVectors(d.target,v.setLength(d.maxDistance)),v.lengthSq()f&&(d.dispatchEvent(k),g.copy(d.object.position))},this.reset=function(){_=m.NONE,y=m.NONE,d.target.copy(d.target0),d.object.position.copy(d.position0),d.object.up.copy(d.up0),v.subVectors(d.object.position,d.target),d.object.lookAt(d.target),d.dispatchEvent(k),g.copy(d.object.position)},this.detachFromContainer=function(){d.domElement&&(d.domElement.removeEventListener("contextmenu",p,!1),d.domElement.removeEventListener("mousedown",r,!1),d.domElement.removeEventListener("mousewheel",l,!1),d.domElement.removeEventListener("DOMMouseScroll",l,!1),d.domElement.removeEventListener("touchstart",c,!1),d.domElement.removeEventListener("touchend",h,!1),d.domElement.removeEventListener("touchmove",u,!1)),window.removeEventListener("keydown",o,!1),window.removeEventListener("keyup",n,!1),document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",a),_=m.NONE,d.enabled=!1,d.domElement=null},this.dispose=function(){d.detachFromContainer()},this.destroy=function(){d.dispose()},this.attachToContainer=function(t){d.domElement&&d.detachFromContainer(),d.domElement=void 0!==t?t:document,d.domElement&&(d.domElement.addEventListener("contextmenu",p,!1),d.domElement.addEventListener("mousedown",r,!1),d.domElement.addEventListener("mousewheel",l,!1),d.domElement.addEventListener("DOMMouseScroll",l,!1),d.domElement.addEventListener("touchstart",c,!1),d.domElement.addEventListener("touchend",h,!1),d.domElement.addEventListener("touchmove",u,!1),window.addEventListener("keydown",o,!1),window.addEventListener("keyup",n,!1),d.enabled=!0,d.handleResize(),d.update())},this.attachToContainer(e)};n.prototype=Object.create(i.EventDispatcher.prototype),e.exports=n},{three:void 0}],128:[function(t,e,o){"use strict";var i=t("three"),n=t("./MouseCoordinateWrangler"),r=t("./AnchoredTargetVisualizer"),s=t("../ifr-core/SLog"),a="UI_TARGET",l=function(t,e,o,n,s){this._name=t,this._camera=e,this._initialPosition=o,null==this._initialPosition&&(this._initialPosition=new i.Vector3(0,0,0)),this._pointOnGroundPlane=n,null==this._pointOnGroundPlane&&(this._pointOnGroundPlane=new i.Vector3(0,0,0)),this._groundPlaneNormal=s,null==this._groundPlaneNormal&&(this._groundPlaneNormal=new i.Vector3(0,1,0)),this._lastPosition=(new i.Vector3).copy(this._initialPosition),this._positionChangedListeners=[],this._anchoredTargetVis=new r(this._groundPlaneNormal),null!=this._lastPosition&&this._anchoredTargetVis.setPosition(this._lastPosition)};l.prototype.moveToNDCPoint=function(t,e,o){var r;if(o){var l=n.unprojectScreenToPlane(t,e,this._camera,this._pointOnGroundPlane,this._groundPlaneNormal);null!=l?r=(new i.Vector3).copy(this._lastPosition).projectOnVector(this._groundPlaneNormal).add(l):s(a,"ViewportTargetPositioner: ground point not computed, not moving target point")}else{var c=new i.Vector3(0,0,-1),u=c.applyMatrix4(this._camera.matrixWorld),h=u.sub(this._camera.position);h.projectOnPlane(this._groundPlaneNormal);var p=this._lastPosition;h.lengthSq()<.001?(s(a,"ViewportTargetPositioner: degenerate angle, not moving target point"),r=void 0):(h.normalize(),r=n.unprojectScreenToPlane(t,e,this._camera,p,h))}void 0!==r&&(this._lastPosition.copy(r),this._notifyPositionChangedCallbacks(r)),this._anchoredTargetVis.setPosition(this._lastPosition)},l.prototype.installRendererIntoScene=function(t){this._anchoredTargetVis.installRendererIntoScene(t)},l.prototype.removeRendererFromScene=function(t){this._anchoredTargetVis.removeRendererFromScene(t)},l.prototype.getPosition=function(t){return null==t&&(t=new i.Vector3),t.copy(this._lastPosition),t},l.prototype.addPositionChangedCallback=function(t){var e=this._positionChangedListeners.indexOf(t);e<0&&this._positionChangedListeners.push(t)},l.prototype.removePositionChangedCallback=function(t){var e=this._positionChangedListeners.indexOf(t);e>-1&&this._positionChangedListeners.splice(e,1)},l.prototype._notifyPositionChangedCallbacks=function(t){for(var e=0;e