Files
jibo-cli/node_modules/animation-utilities/lib/animation-utilities.js

22 lines
263 KiB
JavaScript

/**
* 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;s<i.length;s++)n(i[s]);return n}({1:[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("../ifr-motion/base/AccelPlanner"),a=t("./TransitionBuilder"),l=function(t,e,o){a.call(this),this.minTransitionTime=null,this.defaultMaxVelocity=e,this.defaultMaxAccel=o,this.maxVelocityByDOF={},this.maxAccelByDOF={},this.preferValueByDOF={},this.robotInfo=t,this.planner=new s};l.prototype=Object.create(a.prototype),l.prototype.constructor=l,l.prototype.setDefaultLimits=function(t,e){this.defaultMaxVelocity=t,this.defaultMaxAccel=e},l.prototype.setMinTransitionTime=function(t){this.minTransitionTime=t},l.prototype.setLimits=function(t,e,o){for(var i=0;i<t.length;i++)this.maxVelocityByDOF[t[i]]=e,this.maxAccelByDOF[t[i]]=o},l.prototype.setPreferValue=function(t,e){for(var o=0;o<t.length;o++)this.preferValueByDOF[t[o]]=e},l.prototype.generateTransition=function(t,e,o,s){var a,l,c,u,h,p=1/30;for(h=0;h<s.length;h++){if(a=s[h],!this.robotInfo.getDOFInfo(a))throw new Error("Error transitioning, no dofInfo found for "+a);var d=t.get(a,0);if(null==d||Array.isArray(d)&&d.length<1)throw new Error("Error transitioning, no FROM value for "+a)}var m=this.robotInfo.getKinematicInfo().getInterpolatorSet(),f=new i("Transition:"+e.getName()),g=0,_=e.getPoseAtTime(o,m),y=t.getCopy();for(h=0;h<s.length;h++)a=s[h],y.set(a,_.get(a,0),0);var v=this.robotInfo.getKinematicInfo().getDOFGlobalAlignment();for(v.refineToGloballyClosestTargetPose(t,y,s),h=0;h<s.length;h++)if(a=s[h],this.robotInfo.getDOFInfo(a).isMetric()){l=t.get(a,0),c=t.get(a,1),null===c&&(c=0),u=y.get(a,0);var T=this.defaultMaxAccel;this.maxAccelByDOF[a]&&(T=this.maxAccelByDOF[a]);var D=this.planner.computeWithFixedAccel(c,0,u-l,T)._totalTime;D>g&&(g=D)}this.minTransitionTime&&this.minTransitionTime>g&&(g=this.minTransitionTime);var O={};for(h=0;h<s.length;h++)a=s[h],this.robotInfo.getDOFInfo(a).isMetric()&&(l=t.get(a,0),c=t.get(a,1),null===c&&(c=0),u=y.get(a,0),g>1e-10?O[a]=this.planner.computeWithFixedTime(c,0,u-l,g):O[a]=null);var L;for(h=0;h<s.length;h++){a=s[h],l=t.get(a,0),u=y.get(a,0);var F=new r,w=O[a];if(w){F.append(0,l);for(var S=p;S<g;){var b=l+w.displacementAtTime(S);F.append(S,b),S+=p}F.append(g,u)}else void 0!==(L=this.preferValueByDOF[a])&&(L===l||L===u)?(F.append(0,L),F.append(g,L)):(F.append(0,l),F.append(g,u));f.addTrack(new n(a,F,g))}return f},l.prototype.clone=function(){var t=new l(this.robotInfo,this.defaultMaxVelocity,this.defaultMaxAccel);t.minTransitionTime=this.minTransitionTime;var e,o=Object.keys(this.maxVelocityByDOF);for(e=0;e<o.length;e++)t.maxVelocityByDOF[o[e]]=this.maxVelocityByDOF[o[e]];for(o=Object.keys(this.maxAccelByDOF),e=0;e<o.length;e++)t.maxAccelByDOF[o[e]]=this.maxAccelByDOF[o[e]];for(o=Object.keys(this.preferValueByDOF),e=0;e<o.length;e++)t.preferValueByDOF[o[e]]=this.preferValueByDOF[o[e]];return t},e.exports=l},{"../ifr-motion/base/AccelPlanner":65,"../ifr-motion/base/Motion":72,"../ifr-motion/base/MotionTrack":75,"../ifr-motion/base/TimestampedBuffer":79,"./TransitionBuilder":5}],2:[function(t,e,o){"use strict";function i(t){for(var e=[],o=t.getOutputs(),i=0;i<o.length;i++)o[i]instanceof y&&(e=e.concat(o[i].getRenderers()));return e}var n=t("../ifr-motion/loaders/AnimationLoader"),r=t("../ifr-motion/base/Motion"),s=t("../ifr-motion/base/AnnotatedMotion"),a=t("../ifr-motion/base/Pose"),l=t("../ifr-motion/base/RelativeTimeClip"),c=t("../ifr-motion/base/MotionEventIterator"),u=t("./LinearTransitionBuilderImpl"),h=t("./AccelerationTransitionBuilder"),p=t("./SingleLookatBuilder"),d=t("./timeline/PoseMotionGenerator"),m=t("./timeline/SimpleMotionGenerator"),f=t("./timeline/LoopedMotionGenerator"),g=t("./timeline/VariableSpeedMotionGenerator"),_=t("../ifr-core/SLog"),y=t("../animation-visualize/RendererOutput"),v=t("../geometry-info/DOFSet"),T=t("three"),D=t("./timeline/TimelineEventDispatcher"),O=t("../ifr-motion/lookat/KinematicFeaturesReporter"),L=t("../ifr-motion/lookat/PlaneDisplacementLookatDOF"),F={},w=new n,S=function(t,e,o,i,n,r){var s=t;I.trajectory.getAnimation(e,function(t){var e=null;t&&(e=new P(s,s.timeline,t,null===s.defaultTransition?null:s.defaultTransition.clone(),s.robotInfo,n,r)),o&&o(e)},i)},b=function(){};b.prototype.init=function(t,e){var o=this;this.timeline=t,this.robotInfo=e,this.defaultTransition=this.createAccelerationTransitionBuilder(3,5),this.defaultTransition.setLimits(e.getBodyDOFNames(),3,5),this.defaultTransition.setLimits(e.getEyeDOFNames(),20,40),this.defaultTransition.setLimits(e.getDOFSet("LED").getDOFs(),10,20),this.defaultTransition.setPreferValue(e.getDOFSet("EYE_VISIBILITY").plus("OVERLAY_VISIBILITY").getDOFs(),0),this.globalAnimationListeners=[],this.globalLookatListeners=[],this.globalAnimationDelegate=function(t,e,i){for(var n=0;n<o.globalAnimationListeners.length;n++)o.globalAnimationListeners[n](t,e,i)},this.globalLookatDelegate=function(t,e,i){for(var n=0;n<o.globalLookatListeners.length;n++)o.globalLookatListeners[n](t,e,i)},this.blinkBuilder=null,this.blinkInProgress=!1,S(this,e.getConfig().getRobotURL()+"jibo_blink.anim",function(t){t.setTransitionIn(null),t.on(I.AnimationEventType.STOPPED,function(){o.blinkInProgress=!1}),t.on(I.AnimationEventType.CANCELLED,function(){o.blinkInProgress=!1}),o.blinkBuilder=t},!1,"blink",this.globalAnimationDelegate),this.kinematicFeatureGenerationTime=null,this.kinematicFeatureComputed=null,this.kinematicFeaturesReporter=new O(e.getKinematicInfo().getFullKinematicGroup(),[new O.VectorFeatureReporter("Base",e.getKinematicInfo().getFullKinematicGroup().getModelControlGroup().getControlForDOF(p.LookatDOFGeometryConfig.BaseLookatDOF.DOFName).getTransformName(),new T.Vector3(0,0,0),p.LookatDOFGeometryConfig.BaseLookatDOF.Forward),new O.VectorFeatureReporter("Head",p.LookatDOFGeometryConfig.EyeLeftRight.CentralTransformName,new T.Vector3(0,0,0),p.LookatDOFGeometryConfig.EyeLeftRight.Forward),new O.PlaneDisplacementVectorReporter("Eye",new L(p.LookatDOFGeometryConfig.EyeLeftRight.LookatDOFName,p.LookatDOFGeometryConfig.EyeLeftRight.DOFName,p.LookatDOFGeometryConfig.EyeLeftRight.CentralTransformName,p.LookatDOFGeometryConfig.EyeLeftRight.Forward,p.LookatDOFGeometryConfig.EyeLeftRight.PlaneNormal,p.LookatDOFGeometryConfig.EyeLeftRight.InternalDistance,p.LookatDOFGeometryConfig.EyeLeftRight.MinValue,p.LookatDOFGeometryConfig.EyeLeftRight.MaxValue),new L(p.LookatDOFGeometryConfig.EyeUpDown.LookatDOFName,p.LookatDOFGeometryConfig.EyeUpDown.DOFName,p.LookatDOFGeometryConfig.EyeUpDown.CentralTransformName,p.LookatDOFGeometryConfig.EyeUpDown.Forward,p.LookatDOFGeometryConfig.EyeUpDown.PlaneNormal,p.LookatDOFGeometryConfig.EyeUpDown.InternalDistance,p.LookatDOFGeometryConfig.EyeUpDown.MinValue,p.LookatDOFGeometryConfig.EyeUpDown.MaxValue))]),this.dofIndicesToNames=e.getKinematicInfo().getDefaultPose().getDOFIndicesToNames(),this.dofNamesToIndices=e.getKinematicInfo().getDefaultPose().getDOFNamesToIndices();var i={ALL:e.getDOFSet("ALL"),BASE:e.getDOFSet("BASE"),BODY:e.getDOFSet("BODY"),EYE:e.getDOFSet("EYE"),LED:e.getDOFSet("LED"),OVERLAY:e.getDOFSet("OVERLAY"),SCREEN:e.getDOFSet("SCREEN"),EYE_ROOT:e.getDOFSet("EYE_ROOT"),EYE_DEFORM:e.getDOFSet("EYE_DEFORM"),EYE_RENDER:e.getDOFSet("EYE_RENDER"),EYE_TRANSLATE:e.getDOFSet("EYE_TRANSLATE"),EYE_ROTATE:e.getDOFSet("EYE_ROTATE"),EYE_COLOR:e.getDOFSet("EYE_COLOR"),EYE_TEXTURE:e.getDOFSet("EYE_TEXTURE"),EYE_VISIBILITY:e.getDOFSet("EYE_VISIBILITY"),OVERLAY_ROOT:e.getDOFSet("OVERLAY_ROOT"),OVERLAY_DEFORM:e.getDOFSet("OVERLAY_DEFORM"),OVERLAY_RENDER:e.getDOFSet("OVERLAY_RENDER"),OVERLAY_TRANSLATE:e.getDOFSet("OVERLAY_TRANSLATE"),OVERLAY_ROTATE:e.getDOFSet("OVERLAY_ROTATE"),OVERLAY_COLOR:e.getDOFSet("OVERLAY_COLOR"),OVERLAY_TEXTURE:e.getDOFSet("OVERLAY_TEXTURE"),OVERLAY_VISIBILITY:e.getDOFSet("OVERLAY_VISIBILITY"),SCREEN_BG_RENDER:e.getDOFSet("SCREEN_BG_RENDER"),SCREEN_BG_COLOR:e.getDOFSet("SCREEN_BG_COLOR"),SCREEN_BG_TEXTURE:e.getDOFSet("SCREEN_BG_TEXTURE")};this.dofs=i},b.prototype.getRobotInfo=function(){return this.robotInfo},b.prototype.getClock=function(){return this.timeline.getClock()},b.prototype.createAnimationBuilder=function(t,e,o){S(this,t,e,o,"default",this.globalAnimationDelegate)},b.prototype.createAnimationBuilderFromData=function(t,e,o){var i=I.trajectory.parseAnimation(t,e,o);return i?new P(this,this.timeline,i,null===this.defaultTransition?null:this.defaultTransition.clone(),this.robotInfo,"default",this.globalAnimationDelegate):null};var k=function(t){this._bFunc=t.blink.bind(t)};k.prototype.blink=function(t){D.queueEvent(this._bFunc,[t])},b.prototype.createLookatBuilder=function(){return new p(this,this.timeline,this.robotInfo,null===this.defaultTransition?null:this.defaultTransition.clone(),this.globalLookatDelegate,new k(this))},b.prototype.blink=function(t){null!=this.blinkBuilder?this.blinkInProgress!==!1&&t!==!0||(this.blinkBuilder.play(),this.blinkInProgress=!0):_.warn("Blink requested but blink builder not yet loaded")},b.prototype.stopAll=function(){},b.prototype.setEyeVisible=function(t){var e=this.robotInfo.getDOFSet("EYE_VISIBILITY").getDOFs()[0],o=this.robotInfo.getDOFSet("OVERLAY_VISIBILITY").getDOFs()[0],i=1,n=0,r=new a("eye visibility pose",[e,o]);r.set(e,t?i:n,0),r.set(o,t?i:n,0);var s=this.timeline.getClock().currentTime();this.timeline.add(new d(this,"eye visibility motion",s,r,.5),"default"),this.globalAnimationDelegate&&this.globalAnimationDelegate("ADDED",null,{dofs:r.getDOFNames(),layer:"default",instant:"setEyeVisible instant"})},b.prototype.setEyeScale=function(t){for(var e=this.robotInfo.getDOFSet("EYE_DEFORM").plus("OVERLAY_DEFORM").getDOFs(),o=this.robotInfo.getKinematicInfo().getDefaultPose(),i=new a("eye pose",e),n=0;n<e.length;n++)i.set(e[n],o.get(e[n],0)*t,0);var r=this.timeline.getClock().currentTime();this.timeline.add(new d(this,"eye scale motion",r,i,.5),"default"),this.globalAnimationDelegate&&this.globalAnimationDelegate("ADDED",null,{dofs:i.getDOFNames(),layer:"default",instant:"setEyeScale instant"})},b.prototype.setEyeScaleXY=function(t,e){for(var o=this.robotInfo.getDOFSet("EYE_DEFORM").plus("OVERLAY_DEFORM").getDOFs(),i=this.robotInfo.getKinematicInfo().getDefaultPose(),n=new a("eye pose",o),r=0;r<o.length;r++)o[r].indexOf("_t_2")>-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;o<e.length;o++)e[o].installRenderPlugin(t)},b.prototype.removeRenderPlugin=function(t){for(var e=i(this.timeline),o=0;o<e.length;o++)e[o].removeRenderPlugin(t)},b.prototype.getInstalledRenderPluginNames=function(){for(var t=[],e=i(this.timeline),o=0;o<e.length;o++)for(var n=e[o].getInstalledRenderPluginNames(),r=0;r<n.length;r++)t.indexOf(n[r])<0&&t.push(n[r]);return t},b.prototype.addGlobalAnimationListener=function(t){this.globalAnimationListeners.indexOf(t)===-1&&this.globalAnimationListeners.push(t)},b.prototype.removeGlobalAnimationListener=function(t){var e=this.globalAnimationListeners.indexOf(t);e!==-1&&this.globalAnimationListeners.splice(e,1)},b.prototype.addGlobalLookatListener=function(t){this.globalLookatListeners.indexOf(t)===-1&&this.globalLookatListeners.push(t)},b.prototype.removeGlobalLookatListener=function(t){var e=this.globalLookatListeners.indexOf(t);e!==-1&&this.globalLookatListeners.splice(e,1)};var C=function(t,e,o,i,n){this.builder=t,this.transitionClip=e,this.animationClip=o,this.layer=i,this.name=n,this.paused=!1,this.speedAtPause=1};C.prototype.stop=function(){var t=this.builder.timeline,e=t.getClock().currentTime();if(!this.animationClip.endsAfter(e))return void _.warn("Ignoring stop on "+this.animationClip.getName()+" as it is already over");null===this.transitionClip?this.animationClip.getStartTime().isGreater(e)&&(e=this.animationClip.getStartTime(),_.info("Stopping called on transitionless animation "+this.animationClip.getName()+" before anim started, moving stopTime forward")):this.transitionClip.getStartTime().isGreater(e)&&(e=this.transitionClip.getStartTime(),_.info("Stopping called on animation "+this.animationClip.getName()+" before its transition started, moving stopTime forward"));var o=null;o=null!==this.transitionClip&&this.transitionClip.endsAfter(e)?this.transitionClip:this.animationClip;for(var i=[],n=o.getDOFIndices(),s=0;s<n.length;s++)o.dofEndsAfter(n[s],e)&&i.push(this.builder.animUtils.dofIndicesToNames[n[s]]);for(var l=new a("stop pose",i),c=0;c<i.length;c++)l.set(i[c],[0]);var u=r.createFromPose(o.getName()+"_stop",l,0),h=new m(this.builder.animUtils,u,e,this.builder.robotInfo);t.add(h,this.layer)},C.prototype.getTransitionStartTime=function(){return this.transitionClip?this.transitionClip.getStartTime():this.animationClip.getStartTime()},C.prototype.getAnimationStartTime=function(){return this.animationClip.getStartTime()},C.prototype.getAnimationEndTime=function(){return console.warn("Deprecation Warning: AnimationInstance.getAnimationEndTime is deprecated, please use animation STOPPED/CANCELLED events instead."),console.warn((new Error).stack),this.getAnimationStartTime().add(this.builder.getConfiguredAnimationDuration())},C.prototype.getBuilder=function(){return this.builder},C.prototype.getName=function(){return this.name},C.prototype.setPaused=function(t){t&&!this.paused?(this.speedAtPause=this.animationClip.getSpeed(),this.animationClip.setSpeed(0),this.paused=!0):!t&&this.paused&&(this.animationClip.setSpeed(this.speedAtPause),this.paused=!1)};var P=function(t,e,o,i,n,r,s){null==r&&(r="default"),this.layer=r,this.animUtils=t,this.timeline=e,this.motion=o,this.dofNames=o.getMotion().getDOFs(),this.eventHandlers={},this.clip=new l(0,o.getMotion().getDuration(),1),this.numLoops=1,this.transition=i,this.stopOrient=!0,this.layerDOFs=e.getDOFsForLayer(r),this.robotInfo=n,this.globalAnimationDelegate=s,this.setDOFs(null)};P.prototype.reset=function(){this.layer="default",this.layerDOFs=this.timeline.getDOFsForLayer(this.layer),this.dofNames=this.motion.getMotion().getDOFs(),this.eventHandlers={},this.clip=new l(0,this.motion.getMotion().getDuration(),1),this.numLoops=1,this.transition=this.animUtils.getDefaultTransition().clone(),this.stopOrient=!0,this.setDOFs(null)},P.prototype.getCleanCopy=function(){var t=this.animUtils.getDefaultTransition().clone();return new P(this.animUtils,this.timeline,this.motion,t,this.robotInfo,"default",this.globalAnimationDelegate)},P.prototype._createStartedHandler=function(t){var e=this.globalAnimationDelegate,o=this.eventHandlers[I.AnimationEventType.STARTED];if(e||o){var i=null;return o&&(i=o.slice(0)),function(){if(e&&e(I.AnimationEventType.STARTED,t,{}),i)for(var o=0;o<i.length;o++)i[o](I.AnimationEventType.STARTED,t,{})}}return null},P.prototype._createStoppedHandler=function(t){var e=this.globalAnimationDelegate,o=this.eventHandlers[I.AnimationEventType.STOPPED];if(e||o){var i=null;return o&&(i=o.slice(0)),function(o){if(e&&e(I.AnimationEventType.STOPPED,t,{interrupted:o}),i)for(var n=0;n<i.length;n++)i[n](I.AnimationEventType.STOPPED,t,{interrupted:o})}}return null},P.prototype._createRemovedHandler=function(t){var e=this.globalAnimationDelegate,o=this.eventHandlers[I.AnimationEventType.STOPPED],i=this.eventHandlers[I.AnimationEventType.CANCELLED];if(e||o||i){var n=null,r=null;return o&&(n=o.slice(0)),i&&(r=i.slice(0)),function(o,i){var s;if(e&&(o&&!i&&e(I.AnimationEventType.STOPPED,t,{interrupted:!0}),o||e(I.AnimationEventType.CANCELLED,t,{})),n&&o&&!i)for(s=0;s<n.length;s++)n[s](I.AnimationEventType.STOPPED,t,{interrupted:!0});if(r&&!o)for(s=0;s<r.length;s++)r[s](I.AnimationEventType.CANCELLED,t,{})}}return null},P.prototype._createEventHandler=function(t){var e=this.globalAnimationDelegate,o=null;this.eventHandlers[I.AnimationEventType.EVENT]&&(o=this.eventHandlers[I.AnimationEventType.EVENT].slice(0));for(var i={},n=Object.keys(this.eventHandlers),r=0;r<n.length;r++){var s=n[r];s!==I.AnimationEventType.STARTED&&s!==I.AnimationEventType.STOPPED&&s!==I.AnimationEventType.CANCELLED&&s!==I.AnimationEventType.EVENT&&this.eventHandlers[s]&&(i[s]=this.eventHandlers[s].slice(0))}return e||o||Object.keys(i).length>0?function(n){var r;if(e&&e(I.AnimationEventType.EVENT,t,{eventName:n.getEventName(),payload:n.getPayload()}),o)for(r=0;r<o.length;r++)o[r](I.AnimationEventType.EVENT,t,{eventName:n.getEventName(),payload:n.getPayload()});var s=n.getEventName();if(i[s])for(r=0;r<i[s].length;r++)i[s][r](s,t,n.getPayload())}:null},P.prototype.play=function(){var t=this.timeline.getClock().currentTime(),e=0,o=null;if(this.transition){var i=this.timeline.getCurrentState([this.layer]).getPose(),n=this.motion.getMotion(),s=this.robotInfo.getDOFSet("BASE").getDOFs()[0];if("default"===this.layer&&this.stopOrient&&this.dofNames.indexOf(s)!==-1){var a=this.timeline.getCurrentState(["lookat"]).getPose(),u=r.createFromPose("stop look",a,1),h=this.transition.generateTransition(a,u,0,a.getDOFNames());this.timeline.add(new m(this.animUtils,h,t,this.robotInfo),"lookat")}var p=this.transition.generateTransition(i,n,this.clip.getInPoint(),this.dofNames);o=new m(this.animUtils,p,t,this.robotInfo),o=this.timeline.add(o,this.layer),null!==o&&(e=p.getDuration())}var d=new C(this,null,null,this.layer,this.motion.getMotion().getName()),_=null,y=new l(this.clip.getInPoint(),this.clip.getOutPoint(),1);if(1===this.numLoops)_=new m(this.animUtils,this.motion.getMotion(),t.add(e),this.robotInfo,this.dofNames,y),_.setEvents(new c(this.motion.getEvents(),y)),_.setSourceTimeReportingEnabled(!0);else{var v=[this.motion.getMotion()],T=[y],D=[new c(this.motion.getEvents(),y)],O=[!0];if(this.transition){var L=this.motion.getMotion().getPoseAtTime(this.clip.getOutPoint(),this.robotInfo.getKinematicInfo().getInterpolatorSet()),F=this.transition.generateTransition(L,this.motion.getMotion(),this.clip.getInPoint(),this.dofNames);v.push(F),T.push(new l(0,F.getDuration(),1)),D.push(new c([],T[1])),O.push(!1)}_=new f(this.animUtils,v,T,this.numLoops,t.add(e),this.robotInfo,this.dofNames),_.setEvents(D),_.setSourceTimeReportingEnabled(O)}return _.setHandlers(this._createStartedHandler(d),this._createStoppedHandler(d),this._createRemovedHandler(d),this._createEventHandler(d)),_=new g(this.animUtils,_,this.clip.getSpeed()),_=this.timeline.add(_,this.layer),d.transitionClip=o,d.animationClip=_,this.globalAnimationDelegate&&this.globalAnimationDelegate("ADDED",d,{dofs:this.dofNames,layer:this.layer}),d},P.prototype.on=function(t,e){var o=this.eventHandlers[t];o||(o=[],this.eventHandlers[t]=o),o.indexOf(e)===-1&&o.push(e)},P.prototype.off=function(t,e){var o=this.eventHandlers[t];if(o){var i=o.indexOf(e);i!==-1&&o.splice(i,1)}},P.prototype.setSpeed=function(t){this.clip=new l(this.clip.getInPoint(),this.clip.getOutPoint(),t)},P.prototype.setNumLoops=function(t){if(t<0)throw new Error("numLoops value is negative: "+t);this.numLoops=t},P.prototype.setDOFs=function(t){null==t?t=this.motion.getMotion().getDOFs():t instanceof v&&(t=t.getDOFs()),this.dofNames=[];for(var e=0;e<t.length;e++)this.motion.getMotion().hasDOF(t[e])&&this.layerDOFs.indexOf(t[e])>-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;u<s.length;u++){if(a=s[u],!this._robotInfo.getDOFInfo(a))throw new Error("Error transitioning, no dofInfo found for "+a);var h=t.get(a,0);if(null==h||Array.isArray(h)&&h.length<1)throw new Error("Error transitioning, no FROM value for "+a)}var p=this._robotInfo.getKinematicInfo().getInterpolatorSet(),d=new i("Transition:"+e.getName()),m=0,f=e.getPoseAtTime(o,p),g=t.getCopy();for(u=0;u<s.length;u++)a=s[u],g.set(a,f.get(a,0),0);var _=this._robotInfo.getKinematicInfo().getDOFGlobalAlignment();if(_.refineToGloballyClosestTargetPose(t,g,s),null!==this._transitionTime)m=this._transitionTime;else for(u=0;u<s.length;u++)if(a=s[u],this._robotInfo.getDOFInfo(a).isMetric()){l=t.get(a,0),c=g.get(a,0);var y=this._defaultMaxVelocity;this._maxVelocityByDOF&&this._maxVelocityByDOF[a]&&(y=this._maxVelocityByDOF[a]);var v=Math.abs(c-l),T=v/y;T>m&&(m=T)}for(u=0;u<s.length;u++){a=s[u],l=t.get(a),c=g.get(a,0);var D=new r;D.append(0,l),D.append(m,c),d.addTrack(new n(a,D,m))}return d},a.prototype.clone=function(){for(var t=new a(this._robotInfo),e=Object.keys(this),o=0;o<e.length;o++)t[e[o]]=this[e[o]];return t},e.exports=a},{"../ifr-motion/base/Motion":72,"../ifr-motion/base/MotionTrack":75,"../ifr-motion/base/TimestampedBuffer":79,"./TransitionBuilder":5}],4:[function(t,e,o){"use strict";var i=t("../ifr-motion/lookat/MotionLookat"),n=t("../ifr-motion/lookat/LookatNode"),r=t("../ifr-motion/lookat/LookatMotionNode"),s=t("../ifr-motion/lookat/OcularStabilizationTracker"),a=t("../ifr-motion/lookat/DiskStabilizationTracker"),l=t("../ifr-motion/lookat/RotationalLookatDOF"),c=t("../ifr-motion/lookat/RotationalPlaneAlignmentLookatDOF"),u=t("../ifr-motion/lookat/PlaneDisplacementLookatDOF"),h=t("../ifr-motion/base/Pose"),p=t("../ifr-motion/base/Motion"),d=t("three"),m=t("./timeline/SimpleMotionGenerator"),f=t("../ifr-core/SLog"),g=t("./timeline/LookatMultiLayerStatusManager"),_=t("../geometry-info/DOFSet"),y=t("../ifr-motion/lookat/trackpolicy/LookatNodeTrackPolicy"),v=t("../ifr-motion/lookat/trackpolicy/TrackPolicyTriggerAlways"),T=t("../ifr-motion/lookat/trackpolicy/TrackPolicyTriggerDiscomfort"),D=t("../ifr-motion/lookat/trackpolicy/TrackPolicyTriggerMovementTerminated"),O=t("../ifr-motion/lookat/trackpolicy/TrackPolicyTriggerOnOtherNode"),L=t("../ifr-motion/lookat/LookatBlinkManager"),F=t("../ifr-motion/lookat/LookatNodeTargetAdjuster"),w=t("../ifr-motion/lookat/LookatWindupPolicy"),S="LOOKAT",b={STARTED:"STARTED",TARGET_REACHED:"TARGET_REACHED",TARGET_SUPERSEDED:"TARGET_SUPERSEDED",STOPPED:"STOPPED",CANCELLED:"CANCELLED"},k=function(t,e,o,i,n,r,s,a,l,c,u,h,p,d,m,f,g,_,y,v,T,D,O,L,F,w,S){this.velocity=t,this.acceleration=e,this.TPTDLimitInner=o,this.TPTDLimitOuter=i,this.TPTDAccumInner=n,this.TPTDAccumOuter=r,this.TPTDMoveImmediatelyPastOuter=s,this.TPTPMoveIfParentMoves=a,this.TPTMTDeadZone=l,this.TPTMTDeadTime=c,this.TPTMTDeadVelocity=u,this.BPTriggerDelta=h,this.BPRetriggerTimeSameTrajectory=p,this.BPRetriggerTimeCrossTrajectory=d,this.BPTrajectorySeparatorDelta=m,this.BPOnlyAtOrAfterWindupPhase=f,this.TAUndershootDistance=g,this.WPTargetDeltaToTriggerNewWindup=_,this.WPMaxAllowedTriggerSpeed=y,this.WPMinAllowedTriggerDistance=v,this.WPMaxAllowedTriggerDistance=T,this.WMWindupDistanceRatio=D,this.WPWindupMinDistance=O,this.WPWindupMaxDistance=L,this.WPOvershootDistanceRatio=F,this.WPOvershootMinDistance=w,this.WPOvershootMaxDistance=S},C=function(t,e){this.min=t,this.max=e},P={BaseLookatDOF:{LookatDOFName:"BaseLookatDOF",DOFName:"bottomSection_r",Forward:new d.Vector3(0,0,-1)},TorsoLookatDOF:{LookatDOFName:"TorsoLookatDOF",DOFName:"middleSection_r",PlaneNormal:new d.Vector3(9.509979e-9,.9271838,.37460676),DistanceAlongAxisToDOFPlane:.18703285,AngleAbovePlane:.29670632},TopLookatDOF:{LookatDOFName:"TopLookatDOF",DOFName:"topSection_r",Forward:new d.Vector3(0,0,-1)},EyeLeftRight:{LookatDOFName:"EyeLeftRight",DOFName:"eyeSubRootBn_t",CentralTransformName:"eyeRootBn",Forward:new d.Vector3(0,0,1),PlaneNormal:new d.Vector3(0,1,0),InternalDistance:.048,MinValue:-.03450607937,MaxValue:.03450607937},EyeUpDown:{LookatDOFName:"EyeUpDown",DOFName:"eyeSubRootBn_t_2",CentralTransformName:"eyeRootBn",Forward:new d.Vector3(0,0,1),PlaneNormal:new d.Vector3(-1,0,0),InternalDistance:.03,MinValue:-.00609550625,MaxValue:.00609550625}},N=function(t,e,o,N,E,I){var R=this,M={BaseLookatNode:new k(null,3,1e-5,1e-5,null,null,!0,!1,.001,.01,.018,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null),TorsoLookatNode:new k(null,2.5,1e-5,1e-5,null,null,!0,!1,.001,.01,.018,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null),TopLookatNode:new k(null,3,1e-5,1e-5,null,null,!0,!1,.001,.01,.018,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null),Eye:new k(null,1,1e-6,1e-6,null,null,!0,!1,1e-4,.01,5e-4,null,2,1,.001,null,null,null,null,null,null,null,null,null,null,null,null)},x={bottomSection_r:new C(null,null),middleSection_r:new C(null,null),topSection_r:new C(null,null),eyeSubRootBn_t:new C(P.EyeLeftRight.MinValue,P.EyeLeftRight.MaxValue),eyeSubRootBn_t_2:new C(P.EyeUpDown.MinValue,P.EyeUpDown.MaxValue)},A=function(t,e){var o=[];if(t.TPTPMoveIfParentMoves&&null!=e){for(var i=new O,n=0;n<e.length;n++)e[n].addListener(i);o.push(i)}return null!=t.TPTDLimitInner?(o.push(new T(t.TPTDLimitInner,t.TPTDLimitOuter,t.TPTDAccumInner,t.TPTDAccumOuter,t.TPTDMoveImmediatelyPastOuter)),o.push(new D(t.TPTMTDeadZone,t.TPTMTDeadTime,t.TPTMTDeadVelocity))):o.push(new v),new y(o)},V=function(t,e){return null!=t&&null!=e.BPTriggerDelta?new L(t,e.BPTriggerDelta,e.BPRetriggerTimeSameTrajectory,e.BPRetriggerTimeCrossTrajectory,e.BPTrajectorySeparatorDelta,e.BPOnlyAtOrAfterWindupPhase):null},B=function(t){return null!=t.TAUndershootDistance?new F(t.TAUndershootDistance):null},G=function(t){return null!=t.WPTargetDeltaToTriggerNewWindup?new w(t.WPTargetDeltaToTriggerNewWindup,t.WPMaxAllowedTriggerSpeed,t.WPMinAllowedTriggerDistance,t.WPMaxAllowedTriggerDistance,t.WMWindupDistanceRatio,t.WPWindupMinDistance,t.WPWindupMaxDistance,t.WPOvershootDistanceRatio,t.WPOvershootMinDistance,t.WPOvershootMaxDistance):null;
},U=function(){var t=o.getKinematicInfo().getFullKinematicGroup(),e=o.getKinematicInfo().getDOFGlobalAlignment(),h=new n("BaseLookatNode",[new l(P.BaseLookatDOF.LookatDOFName,P.BaseLookatDOF.DOFName,P.BaseLookatDOF.Forward)]),p=new n("TorsoLookatNode",[new c(P.TorsoLookatDOF.LookatDOFName,P.TorsoLookatDOF.DOFName,P.TorsoLookatDOF.PlaneNormal,P.TorsoLookatDOF.DistanceAlongAxisToDOFPlane,P.TorsoLookatDOF.AngleAbovePlane,!0)]),d=new n("TopLookatNode",[new l(P.TopLookatDOF.LookatDOFName,P.TopLookatDOF.DOFName,P.TopLookatDOF.Forward)]),m=new n("Eye",[new u(P.EyeLeftRight.LookatDOFName,P.EyeLeftRight.DOFName,P.EyeLeftRight.CentralTransformName,P.EyeLeftRight.Forward,P.EyeLeftRight.PlaneNormal,P.EyeLeftRight.InternalDistance,x.eyeSubRootBn_t.min,x.eyeSubRootBn_t.max),new u(P.EyeUpDown.LookatDOFName,P.EyeUpDown.DOFName,P.EyeUpDown.CentralTransformName,P.EyeUpDown.Forward,P.EyeUpDown.PlaneNormal,P.EyeUpDown.InternalDistance,x.eyeSubRootBn_t_2.min,x.eyeSubRootBn_t_2.max)]),f=A(M.BaseLookatNode,null),g=A(M.TorsoLookatNode,[f]),_=A(M.TopLookatNode,[f,g]),y=A(M.Eye,[f,g,_]);return new i([new r(h,e,M.BaseLookatNode.acceleration,new s(h,e),r.LookStabilizationMode.POINT_AUTO,f,null,B(M.BaseLookatNode),G(M.BaseLookatNode)),new r(p,e,M.TorsoLookatNode.acceleration,new a(p,e,["bottomSection_r"]),r.LookStabilizationMode.UNTARGETED,g,null,B(M.TorsoLookatNode),G(M.TorsoLookatNode)),new r(d,e,M.TopLookatNode.acceleration,new s(d,e),r.LookStabilizationMode.POINT_AUTO,_,null,B(M.TopLookatNode),G(M.TopLookatNode)),new r(m,e,M.Eye.acceleration,new s(m,e),r.LookStabilizationMode.POINT_TARGET,y,V(I,M.Eye),B(M.Eye),G(M.Eye))],t)},j=!0,W=!1,H={},z=Object.keys(x),Y=new h("LookPose",z);this.motionLookat=null;var K=function(i,n,r){i=i.clone();var s=null,a=null,l=r;this.getTarget=function(){return i},this.updateTarget=function(t){Array.isArray(t)?i.set(t[0],t[1],t[2]):i.copy(t),l.setTarget(i)},this.getBuilder=function(){return R},this.getName=function(){return"lookat instance"},this.setClip=function(t,e){s=t,a=e},this.stop=function(){s&&c(s,"default"),a&&c(a,"lookat")};var c=function(i,n){var r=e.getClock().currentTime();if(!i.endsAfter(r))return void f.info("Ignoring stop on SingleLookat as it is already over");i.getStartTime().isGreater(r)&&(r=i.getStartTime(),f.info("Stopping called on lookat before it started, moving stopTime forward"));for(var s=[],a=i.getDOFIndices(),l=0;l<a.length;l++)i.dofEndsAfter(a[l],r)&&s.push(t.dofIndicesToNames[a[l]]);for(var c=new h("stop pose",s),u=0;u<s.length;u++)c.set(s[u],[0]);var d=p.createFromPose(i.getName()+"_stop",c,0),g=new m(t,d,r,o);e.add(g,n)}},q=null;this.startLookat=function(i){var n,r=null;r=Array.isArray(i)?new d.Vector3(i[0],i[1],i[2]):i;var s=e.getClock().currentTime(),a=!1;if(null===R.motionLookat&&(a=!0),!a&&null!==q){var l=q.getActiveDOFIndices(s);for(n=0;n<l.length;n++)if(!Y.hasDOFIndex(l[n])){a=!0;break}}a===!0&&(R.motionLookat=U());var c=R.motionLookat,u=e.getCurrentState(["lookat"]).getPose(),_=[],y=[],v=Y.getDOFNames();for(n=0;n<v.length;n++)null!==u.get(v[n])?y.push(v[n]):_.push(v[n]);var T=e.getCurrentState(["default","lookat"]),D=T.getPose(),O=T.getTime(),L=null,F=new g(t,c,s,r,W),w=!1;if(w){c.reset();for(var b=s,k=[],C=[],P=Number.MAX_VALUE;P>.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;n<y.length;n++)M=y[n],j?A.set(M,D.get(M)):A.set(M,u.get(M)),c.generatePoseIncremental(A,Y,r,O,A.getDOFIndexForName(M)),A.set(M,x.get(M));for(n=0;n<_.length;n++)M=_[n],A.set(M,D.get(M)),c.generatePoseIncremental(A,Y,r,O,A.getDOFIndexForName(M)),A.set(M,x.get(M));L=F.createGenerator(_)}var V=new K(r,c,F);F.setHandlers(J(V),X(V),$(V),Q(V),Z(V)),L=e.add(L,"default");var B=null;if(y.length>0){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<t.length;i++)e.indexOf(t[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<o.length;e++)o[e](b.STARTED,t,{})}}return null},Q=function(t){var e=H[b.TARGET_REACHED];if(E||e){var o=null;return e&&(o=e.slice(0)),function(e){if(E&&E(b.TARGET_REACHED,t,{target:e}),o)for(var i=0;i<o.length;i++)o[i](b.TARGET_REACHED,t,{target:e})}}return null},Z=function(t){var e=H[b.TARGET_SUPERSEDED];if(E||e){var o=null;return e&&(o=e.slice(0)),function(e){if(E&&E(b.TARGET_SUPERSEDED,t,{target:e}),o)for(var i=0;i<o.length;i++)o[i](b.TARGET_SUPERSEDED,t,{target:e})}}return null},X=function(t){var e=H[b.STOPPED];if(E||e){var o=null;return e&&(o=e.slice(0)),function(e){if(E&&E(b.STOPPED,t,{interrupted:e}),o)for(var i=0;i<o.length;i++)o[i](b.STOPPED,t,{interrupted:e})}}return null},$=function(t){var e=H[b.STOPPED],o=H[b.CANCELLED];if(E||e||o){var i=null,n=null;return e&&(i=e.slice(0)),o&&(n=o.slice(0)),function(e,o){var r;if(E&&(e&&!o&&E(b.STOPPED,t,{interrupted:!0}),e||E(b.CANCELLED,t,{})),i&&e&&!o)for(r=0;r<i.length;r++)i[r](b.STOPPED,t,{interrupted:!0});if(n&&!e)for(r=0;r<i.length;r++)n[r](b.CANCELLED,t,{})}}return null}};N.LookatDOFGeometryConfig=P,e.exports=N},{"../geometry-info/DOFSet":43,"../ifr-core/SLog":55,"../ifr-motion/base/Motion":72,"../ifr-motion/base/Pose":76,"../ifr-motion/lookat/DiskStabilizationTracker":97,"../ifr-motion/lookat/LookatBlinkManager":99,"../ifr-motion/lookat/LookatMotionNode":101,"../ifr-motion/lookat/LookatNode":102,"../ifr-motion/lookat/LookatNodeTargetAdjuster":104,"../ifr-motion/lookat/LookatWindupPolicy":105,"../ifr-motion/lookat/MotionLookat":106,"../ifr-motion/lookat/OcularStabilizationTracker":107,"../ifr-motion/lookat/PlaneDisplacementLookatDOF":108,"../ifr-motion/lookat/RotationalLookatDOF":112,"../ifr-motion/lookat/RotationalPlaneAlignmentLookatDOF":113,"../ifr-motion/lookat/trackpolicy/LookatNodeTrackPolicy":114,"../ifr-motion/lookat/trackpolicy/TrackPolicyTriggerAlways":116,"../ifr-motion/lookat/trackpolicy/TrackPolicyTriggerDiscomfort":117,"../ifr-motion/lookat/trackpolicy/TrackPolicyTriggerMovementTerminated":118,"../ifr-motion/lookat/trackpolicy/TrackPolicyTriggerOnOtherNode":119,"./timeline/LookatMultiLayerStatusManager":12,"./timeline/SimpleMotionGenerator":21,three:void 0}],5:[function(t,e,o){"use strict";var i=function(){};i.prototype.generateTransition=function(t,e,o,i){},i.prototype.clone=function(){},e.exports=i},{}],6:[function(t,e,o){"use strict";var i=t("./SampleCombiner"),n=function(){i.call(this)};n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.combineSamples=function(t,e,o,i){for(var n=[],r=0;r<e.length;r++)r<o.length?n.push(e[r]+o[r]):n.push(e[r]);return n},e.exports=n},{"./SampleCombiner":18}],7:[function(t,e,o){"use strict";var i={};i.prototype={display:function(t,e,o){}};var n=function(t,e){this.robotInfo=t,this.outputDelegate=e,this.dofNames=t.getKinematicInfo().getDefaultPose().getDOFIndicesToNames(),this.dofValuesList=[{},{}],this.tickCount=0};n.prototype.handleOutput=function(t,e,o){for(var i=this.dofValuesList[this.tickCount%this.dofValuesList.length],n=0;n<this.dofNames.length;n++){var r=e.getByIndex(n,0);i[this.dofNames[n]]=r}this.outputDelegate.display(t,i,o),this.tickCount++},e.exports=n},{}],8:[function(t,e,o){"use strict";var i=t("./MotionGenerator"),n=t("./TimelineEventDispatcher"),r=function(t,e,o){i.call(this),this._animUtils=t,this._name=e,this._startTime=o,this._clipStartedHandler=null,this._clipStoppedHandler=null,this._clipRemovedHandler=null,this._clipEventHandler=null;var n=this._animUtils.dofIndicesToNames.length;this._dofs=null,this._dofMask=new Array(n).fill(!1),this._dofEndTimes=new Array(n).fill(null),this._endTime=null,this._entered=!1,this._exited=!1,this._interrupted=!1,this._currentTime=null};r.prototype=Object.create(i.prototype),r.prototype.constructor=r,r.prototype._initWithDOFNames=function(t,e){for(var o=new Array(t.length),i=0;i<t.length;i++)o[i]=this._animUtils.dofNamesToIndices[t[i]];this._initWithDOFIndices(o,e)},r.prototype._initWithDOFIndices=function(t,e){this._dofs=t;for(var o=0;o<t.length;o++){var i=t[o];this._dofMask[i]=!0,this._dofEndTimes[i]=e}this._endTime=e},r.prototype.setHandlers=function(t,e,o,i){this._clipStartedHandler=t,this._clipStoppedHandler=e,this._clipRemovedHandler=o,this._clipEventHandler=i},r.prototype.getName=function(){return this._name},r.prototype.getStartTime=function(){return this._startTime},r.prototype.endsAfter=function(t){return null===this._endTime||this._endTime.isGreater(t)},r.prototype.isEmpty=function(){return 0===this._dofs.length||!this.endsAfter(this._startTime)},r.prototype.dofEndsAfter=function(t,e){if(this._dofMask[t]){var o=this._dofEndTimes[t];return null===o||o.isGreater(e)}return!1},r.prototype.cropEnd=function(t,e){var o,i,n,r=!1;if(t.isGreater(this._startTime))for(o=0;o<e.length;o++)i=e[o],this._dofMask[i]&&(n=this._dofEndTimes[i],(null===n||n.isGreater(t))&&(this._dofEndTimes[i]=t,r=!0));else for(o=0;o<e.length;o++)i=e[o],this._dofMask[i]&&(this._dofMask[i]=!1,r=!0);if(r){var s=this._startTime;for(o=0;o<this._dofs.length;o++)if(i=this._dofs[o],this._dofMask[i]){if(n=this._dofEndTimes[i],null===n){s=null;break}n.isGreater(s)&&(s=n)}null!==s&&(null===this._endTime||this._endTime.isGreater(s))&&(this._interrupted=!0),this._endTime=s}},r.prototype.getDOFIndices=function(){return this._dofs},r.prototype.notifyUpdateStarted=function(t){this._currentTime=t},r.prototype.notifyUpdateFinished=function(t){!this._entered&&t.isGreaterOrEqual(this._startTime)&&(this._entered=!0,this._clipStartedHandler&&n.queueEvent(this._clipStartedHandler,[])),this._entered&&!this._exited&&this.queueCustomEvents(),!this._entered||this._exited||this.endsAfter(t)||(this._exited=!0,this._clipStoppedHandler&&n.queueEvent(this._clipStoppedHandler,[this._interrupted]))},r.prototype.notifyRemoved=function(){this._clipRemovedHandler&&n.queueEvent(this._clipRemovedHandler,[this._entered,this._exited])},r.prototype.queueCustomEvents=function(){},e.exports=r},{"./MotionGenerator":15,"./TimelineEventDispatcher":22}],9:[function(t,e,o){"use strict";var i=function(){};i.prototype.combineLayers=function(t,e){},i.prototype.incrementState=function(t,e,o,i){},i.getSkipLayerProperty=function(t){return"skip_layer:"+t},e.exports=i},{}],10:[function(t,e,o){"use strict";var i=function(t,e){this.getTime=function(){return t},this.setTime=function(e){t=e},this.getPose=function(){return e},this.getDOFNames=function(){return e.getDOFNames()},this.getDOFState=function(t){return e.get(t)},this.getDOFStateByIndex=function(t){return e.getByIndex(t)},this.setDOFState=function(t,o){e.set(t,o)},this.setDOFStateByIndex=function(t,o){e.setByIndex(t,o)},this.getCopy=function(o){return null!==o&&void 0!==o||(o=t),new i(o,e.getCopy())}};e.exports=i},{}],11:[function(t,e,o){"use strict";var i=t("./BaseMotionGenerator"),n=t("../../ifr-motion/base/Pose"),r=t("../../ifr-core/SLog"),s="LOOKAT",a=function(t,e,o,a,l,c){var u,h=e.getDOFs();if(null!=l){u=[];for(var p=0;p<l.length;p++)h.indexOf(l[p])>=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;a<s.length;a++)this._activeDOFMask[s[a]]=n.dofEndsAfter(s[a],e);var l=this._lookat.getHoldReached(this._activeDOFMask);return l&&null!=this._waitingToNotifyOnTarget&&(null!=this._targetReachedHandler&&r.queueEvent(this._targetReachedHandler,[this._waitingToNotifyOnTarget]),this._waitingToNotifyOnTarget=null),!(!l||this._continuous)},l.prototype.getActiveDOFIndices=function(t){for(var e,o=[],i=this._layerStatuses.keys();!(e=i.next()).done;)for(var n=e.value,r=n.getDOFIndices(),s=0;s<r.length;s++)n.dofEndsAfter(r[s],t)&&o.push(r[s]);return o},l.prototype.handleStarted=function(t){var e=this._layerStatuses.get(t);if(e.layerHasStarted=!0,this._clipStartedHandler){var o=!0;for(var i of this._layerStatuses.values())i.layerHasStarted||i.layerHasRemoved||(o=!1);o&&(r.queueEvent(this._clipStartedHandler,[]),this._haveSentStart=!0)}},l.prototype.handleStopped=function(t,e){var o=this._layerStatuses.get(t);if(o.layerHasStopped&&i(s,"LookatMultiLayerStatManager: getting stop event for stopped layer "+t),o.layerHasStopped=!0,this._clipStoppedHandler){var n=!0;for(var a of this._layerStatuses.values())a.layerHasStopped||a.layerHasRemoved||(n=!1);n&&r.queueEvent(this._clipStoppedHandler,[e])}},l.prototype.handleRemoved=function(t,e,o){var i=this._layerStatuses.get(t);i.layerHasRemoved=!0;var n=null;if(!this._haveSentStart&&this._clipStartedHandler){var s=!0;for(n of this._layerStatuses.values())n.layerHasRemoved||n.layerHasStarted||(s=!1);s&&(r.queueEvent(this._clipStartedHandler,[]),this._haveSentStart=!0)}if(this._clipRemovedHandler){var a=!0;for(n of this._layerStatuses.values())n.layerHasRemoved||(a=!1);a&&r.queueEvent(this._clipRemovedHandler,[e,o])}},e.exports=l},{"../../ifr-core/SLog":55,"../../ifr-motion/base/Pose":76,"./LookatMotionGenerator":11,"./TimelineEventDispatcher":22}],13:[function(t,e,o){"use strict";var i=t("./BaseMotionGenerator"),n=t("./TimelineEventDispatcher"),r=function(t,e,o,n,r,s,a){if(!e)throw new Error("tried to construct LoopedMotionGenerator with empty motion list");if(n<0)throw new Error("numLoops value is negative: "+n);i.call(this,t,e[0].getName(),r),null!==a&&void 0!==a||(a=e[0].getDOFs());var l;for(this._durationList=[],l=0;l<e.length;l++)this._durationList.push(o[l].getDuration());for(this._loopDuration=0,l=0;l<e.length;l++)this._loopDuration=this._loopDuration+this._durationList[l];var c;if(0===n)c=null;else{var u=this._loopDuration*n;c=r.add(u)}this._initWithDOFNames(a,c),this._clipList=o;var h=s.getKinematicInfo().getInterpolatorSet(),p=this._dofMask.length;for(this._nameList=[],this._motionTracksList=[],this._interpolators=new Array(p).fill(null),l=0;l<e.length;l++)this._nameList.push(e[l].getName()),this._motionTracksList.push(new Array(p).fill(null));for(var d=0;d<a.length;d++){var m=this._dofs[d],f=a[d];for(this._interpolators[m]=h.getInterpolator(f),l=0;l<e.length;l++)this._motionTracksList[l][m]=e[l].getTracks()[f]}this._numLoops=n,this._customEvents=null,this._eventLoopIndex=0,this._sourceTimeReportingFlags=null};r.prototype=Object.create(i.prototype),r.prototype.constructor=r,r.prototype.setEvents=function(t){if(t.length!==this._durationList.length)throw new Error("motionEventsList length "+t.length+" doesn't match motionList length "+this._durationList.length);this._customEvents=t},r.prototype.setSourceTimeReportingEnabled=function(t){if(t.length!==this._durationList.length)throw new Error("enabledFlags length "+t.length+" doesn't match motionList length "+this._durationList.length);this._sourceTimeReportingFlags=t},r.prototype.getDOFState=function(t,e,o){var i=this._currentTime,n=this._dofEndTimes[t];null!==n&&i.isGreater(n)&&(i=n);var r=i.subtract(this._startTime);r=Math.max(r,0);var s=Math.floor(r/this._loopDuration);0!==this._numLoops&&(s=Math.min(s,this._numLoops-1));for(var a=r-this._loopDuration*s,l=0,c=a;l<this._durationList.length-1&&c>this._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<o;){var i;for(i=0;i<this._customEvents.length;i++){for(;this._customEvents[i].hasNext(this._durationList[i]);)n.queueEvent(this._clipEventHandler,[this._customEvents[i].next(this._durationList[i])]);this._customEvents[i].reset()}this._eventLoopIndex++}for(var r=e-this._loopDuration*o,s=0,a=r;s<this._customEvents.length&&a>=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<t.length;o++)this._combinerList[this._dofNamesToIndices[t[o]]]=e},n.prototype.combineSamples=function(t,e,o,i){var n=this._combinerList[t];if(!n)throw new Error("no combiner specified for DOF: "+t);return n.combineSamples(t,e,o,i)},e.exports=n},{"./SampleCombiner":18}],15:[function(t,e,o){"use strict";var i=function(){};i.prototype.getName=function(){},i.prototype.getStartTime=function(){},i.prototype.endsAfter=function(t){},i.prototype.isEmpty=function(){},i.prototype.dofEndsAfter=function(t,e){},i.prototype.cropEnd=function(t,e){},i.prototype.getDOFIndices=function(){},i.prototype.notifyUpdateStarted=function(t){},i.prototype.notifyUpdateFinished=function(t){},i.prototype.notifyRemoved=function(){},i.prototype.getDOFState=function(t,e,o){},e.exports=i},{}],16:[function(t,e,o){"use strict";var i=t("../../ifr-motion/base/Pose"),n=t("../../ifr-motion/base/DOFGlobalAlignment"),r=t("../../ifr-motion/base/CyclicMath"),s=t("../../ifr-core/SLog"),a=t("./TimelineEventDispatcher"),l=t("./LayerState"),c=function(t,e,o,i,r){this._name=t,this._layers=[],this._layerNames=[],this._layerNameToIndex={},this._robotInfo=e,this._dofNames=e.getKinematicInfo().getDefaultPose().getDOFIndicesToNames(),this._dofNamesToIndices=e.getKinematicInfo().getDefaultPose().getDOFNamesToIndices(),this._layerStates=[],this._previousLayerStates=[],this._systemState=new l(o.currentTime(),e.getKinematicInfo().getDefaultPose().getCopy()),this._previousSystemState=this._systemState.getCopy(),this._blackboard={},this._outputs=[],this._clock=o,this._layerCombiner=i,this._modalityName=r,this._dofAlignment=new n(this._robotInfo.getKinematicInfo().getFullKinematicGroup(),null);var s=this._dofNames.slice(0);s=this._dofAlignment.sortDOFsByDepth(s),this._sortedDOFIndices=[];var a;for(a=0;a<s.length;a++)this._sortedDOFIndices.push(this._dofNamesToIndices[s[a]]);for(this._layerDOFFlags=[],this._dofInfoList=[],a=0;a<this._dofNames.length;a++)this._dofInfoList.push(this._robotInfo.getDOFInfo(this._dofNames[a]));this._minimumUpdateDelay=.01};c.prototype.getModalityDelegate=function(t){return t===this._modalityName?this:null},c.prototype.getClock=function(){return this._clock},c.prototype.getName=function(){return this._name},c.prototype.createLayer=function(t,e){if(this._layerNameToIndex.hasOwnProperty(t))s.error("Not creating Timeline layer "+t+" since we already have one!");else{null==e&&(e=this._dofNames);var o=this._layers.length;this._layers.push([]),this._layerNames.push(t),this._layerNameToIndex[t]=o;var n=this._robotInfo.getKinematicInfo().getDefaultPose(),r=new i(t+"_pose",e.slice(0));r.setPose(n);var a=new l(this._clock.currentTime(),r);this._layerStates.push(a),this._previousLayerStates.push(a.getCopy());for(var c=new Array(this._dofNames.length).fill(!1),u=0;u<e.length;u++){var h=this._dofNamesToIndices[e[u]];c[h]=!0}this._layerDOFFlags.push(c)}},c.prototype.getLayerNames=function(){return this._layerNames.slice(0)},c.prototype.getLayerCombiner=function(){return this._layerCombiner},c.prototype.getCurrentState=function(t){if(!t)return this._systemState;var e,o,i=[],n=[];for(e=0;e<t.length;e++){if(o=this._layerNameToIndex[t[e]],void 0===o)return s.error("MotionTimeline: requested state for unknown layer: "+t[e]),null;i.push(this._layerStates[o]),n.push(o)}var r=this._layerCombiner.combineLayers(n,i);if(null!==r){var a=null;if(r.getTime().subtract(this._previousLayerStates[n[0]].getTime())>=this._minimumUpdateDelay&&(a=this._previousLayerStates),null!==a){var l=[];for(e=0;e<n.length;e++)l.push(a[n[e]]);var c=this._layerCombiner.combineLayers(n,l);null!==c&&this.computeVelocity(c,r)}}return r},c.prototype.add=function(t,e){var o=this._layerNameToIndex[e];if(void 0===o)return s.error("MotionTimeline: skipping add on unknown layer: "+e),null;for(var i=t.getStartTime(),n=t.getDOFIndices(),r=0,a=this._layers[o],l=0;l<a.length;){var c=a[l];c.endsAfter(i)&&c.cropEnd(i,n),c.isEmpty()?(a.splice(l,1),c.notifyRemoved()):l++,i.isGreaterOrEqual(c.getStartTime())&&(r=l)}return t.isEmpty()?(t.notifyRemoved(),t=null):a.splice(r,0,t),t},c.prototype.cullUpToTime=function(t){var e,o;for(e=0;e<this._layers.length;e++){var i=this._layers[e];for(o=0;o<i.length&&t.isGreater(i[o].getStartTime());){var n=i[o];n.endsAfter(t)?o++:(i.splice(o,1),n.notifyRemoved())}}},c.prototype.render=function(t){var e,o,i,n,r,s,a,l,c,u=this._previousSystemState;for(this._previousSystemState=this._systemState,this._systemState=u,this._systemState.setTime(t),e=0;e<this._layers.length;e++)u=this._previousLayerStates[e],this._previousLayerStates[e]=this._layerStates[e],this._layerStates[e]=u,this._layerStates[e].setTime(t);for(this._blackboard={},o=0;o<this._sortedDOFIndices.length;o++)for(i=this._sortedDOFIndices[o],e=0;e<this._layers.length;e++)if(this._layerDOFFlags[e][i]){for(r=this._layers[e],c=this._previousLayerStates[e].getTime(),l=null,n=0;n<r.length&&t.isGreaterOrEqual(r[n].getStartTime());)s=r[n],s.dofEndsAfter(i,c)&&(l=s),n++;a=null,a=l?l.getDOFState(i,this._systemState,this._blackboard):this._previousLayerStates[e].getDOFStateByIndex(i),this._layerStates[e].setDOFStateByIndex(i,a),0===e?this._systemState.setDOFStateByIndex(i,a):this._layerCombiner.incrementState(this._systemState,e,this._layerStates[e],i)}this.computeVelocity(this._previousSystemState,this._systemState)},c.prototype.addOutput=function(t){this._outputs.push(t)},c.prototype.removeOutput=function(t){var e=this._outputs.indexOf(t);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;a<s.length;a++){var l=s[a],c=this._dofInfoList[l];if(c.isMetric()){var u=n.getByIndex(l,0),h=i.getByIndex(l,0);c.isCyclic()&&(u=r.closestEquivalentRotation(u,h));var p=(u-h)/o;n.setByIndex(l,p,1)}}},c.prototype.update=function(){var t=this._clock.currentTime();if(!(t.subtract(this._systemState.getTime())<this._minimumUpdateDelay)){var e,o,i,n;for(e=0;e<this._layers.length;e++)for(i=this._layers[e],o=0;o<i.length;o++)n=i[o],n.notifyUpdateStarted(t);this.render(t);for(var r=0;r<this._outputs.length;r++){var s=this._outputs[r];s.handleOutput(t,this._systemState.getPose(),this._blackboard)}for(e=0;e<this._layers.length;e++)for(i=this._layers[e],o=0;o<i.length;o++)n=i[o],n.notifyUpdateFinished(t);this.cullUpToTime(t),a.dispatchQueuedEvents()}},c.prototype.getDOFsForLayer=function(t){var e=this._layerNameToIndex[t];return void 0!==e?this._layerStates[e].getDOFNames():null},e.exports=c},{"../../ifr-core/SLog":55,"../../ifr-motion/base/CyclicMath":68,"../../ifr-motion/base/DOFGlobalAlignment":69,"../../ifr-motion/base/Pose":76,"./LayerState":10,"./TimelineEventDispatcher":22}],17:[function(t,e,o){"use strict";var i=t("./BaseMotionGenerator"),n=function(t,e,o,n,r){i.call(this,t,e,o),this._initWithDOFIndices(n.getDOFIndices(),o.add(r)),this._pose=n};n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.getDOFState=function(t,e,o){return this._pose.getByIndex(t)},e.exports=n},{"./BaseMotionGenerator":8}],18:[function(t,e,o){"use strict";var i=function(){};i.prototype.combineSamples=function(t,e,o,i){},e.exports=i},{}],19:[function(t,e,o){"use strict";var i=t("./SampleCombiner"),n=function(t,e,o,n){i.call(this);var r=t.getKinematicInfo().getDefaultPose().getDOFIndicesToNames().length,s=t.getKinematicInfo().getDefaultPose().getDOFNamesToIndices();this._unityScales=new Array(r).fill(1),this._zeroScales=new Array(r).fill(0);for(var a=0;a<n.length;a++){var l=n[a],c=s[l];null!=e&&null!=e.get(l)?this._unityScales[c]=e.get(l)[0]:this._unityScales[c]=1,null!=o&&null!=o.get(l)?this._zeroScales[c]=o.get(l)[0]:this._zeroScales[c]=0}};n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.combineSamples=function(t,e,o,i){var n=[],r=this._unityScales[t],s=this._zeroScales[t],a=(o[0]-s)/(r-s)+s;isNaN(a)&&(a=0);for(var l=0;l<e.length;l++)n.push(e[l]*a);return n},e.exports=n},{"./SampleCombiner":18}],20:[function(t,e,o){"use strict";var i=t("./LayerCombiner"),n=function(){i.call(this),this.sampleCombiners=[],this.layerNames=[]};n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.addSampleCombiner=function(t,e){this.layerNames.push(t),this.sampleCombiners.push(e)},n.prototype.combineLayers=function(t,e){if(!t)return null;for(var o=e[0].getCopy(),i=1;i<t.length;i++)for(var n=e[i].getPose().getDOFIndices(),r=0;r<n.length;r++)this.incrementState(o,t[i],e[i],n[r]);return o},n.prototype.incrementState=function(t,e,o,i){var n=t.getPose().getByIndex(i),r=o.getPose().getByIndex(i),s=this.sampleCombiners[e];if(n&&r&&s){var a=s.combineSamples(i,n,r,null);t.getPose().setByIndex(i,a)}else;},e.exports=n},{"./LayerCombiner":9}],21:[function(t,e,o){"use strict";var i=t("./BaseMotionGenerator"),n=t("./TimelineEventDispatcher"),r=t("../../ifr-motion/base/RelativeTimeClip"),s=function(t,e,o,n,s,a){null!==s&&void 0!==s||(s=e.getDOFs()),a||(a=new r(0,e.getDuration(),1)),i.call(this,t,e.getName(),o),this._initWithDOFNames(s,o.add(a.getDuration())),this._clip=a;var l=n.getKinematicInfo().getInterpolatorSet(),c=this._dofMask.length;this._motionTracks=new Array(c).fill(null),this._interpolators=new Array(c).fill(null);for(var u=0;u<s.length;u++){var h=this._dofs[u],p=s[u];this._motionTracks[h]=e.getTracks()[p],this._interpolators[h]=l.getInterpolator(p)}this._customEvents=null,this._sourceTimeReportingEnabled=!1};s.prototype=Object.create(i.prototype),s.prototype.constructor=s,s.prototype.setEvents=function(t){this._customEvents=t},s.prototype.setSourceTimeReportingEnabled=function(t){this._sourceTimeReportingEnabled=t},s.prototype.getDOFState=function(t,e,o){var i=this._currentTime,n=this._dofEndTimes[t];null!==n&&i.isGreater(n)&&(i=n);var r=i.subtract(this._startTime),s=this._clip.getSourceTime(r),a=this._motionTracks[t].getDataAtTime(s,this._interpolators[t]);return this._sourceTimeReportingEnabled&&(o.sourceTimes||(o.sourceTimes={}),o.sourceTimes[this.getName()]=s),a},s.prototype.queueCustomEvents=function(){if(this._clipEventHandler&&this._customEvents){var t=this._currentTime;null!==this._endTime&&t.isGreater(this._endTime)&&(t=this._endTime);for(var e=t.subtract(this._startTime);this._customEvents.hasNext(e);)n.queueEvent(this._clipEventHandler,[this._customEvents.next(e)])}},e.exports=s},{"../../ifr-motion/base/RelativeTimeClip":77,"./BaseMotionGenerator":8,"./TimelineEventDispatcher":22}],22:[function(t,e,o){"use strict";var i=t("../../ifr-core/SLog"),n=[],r={queueEvent:function(t,e){null==t&&i.error("Error, null/undefined function queued!\n"+(new Error).stack),n.push({f:t,a:e})},dispatchQueuedEvents:function(){for(var t=0;t<n.length;t++){var e=n[t];e.f.apply(null,e.a)}n.length=0}};e.exports=r},{"../../ifr-core/SLog":55}],23:[function(t,e,o){"use strict";var i=t("./BaseMotionGenerator"),n=t("../../ifr-motion/base/RelativeTimeClip"),r=function(t,e,o){i.call(this,t,e.getName(),e.getStartTime()),this._initWithDOFIndices(e.getDOFIndices(),null),this._generator=e,this._clip=new n(0,Number.MAX_VALUE,o),
this._latestUpdateTime=e.getStartTime(),this._latestSpeedChangeTime=e.getStartTime(),this._generatorTimeAtLatestUpdate=e.getStartTime(),this._latestMapInputTime=null,this._latestMapOutputTime=null};r.prototype=Object.create(i.prototype),r.prototype.constructor=r,r.prototype.getSpeed=function(){return this._clip.getSpeed()},r.prototype.setSpeed=function(t){var e=this._generatorTimeAtLatestUpdate.subtract(this._startTime);this._clip=new n(e,this._clip.getOutPoint(),t),this._latestSpeedChangeTime=this._latestUpdateTime},r.prototype._mapTime=function(t){if(null!==this._latestMapInputTime&&this._latestMapInputTime.equals(t))return this._latestMapOutputTime;var e=null;if(t.isGreater(this._startTime)){var o=t.subtract(this._latestSpeedChangeTime),i=this._clip.getSourceTime(o);e=this._startTime.add(i)}else e=t;return this._latestMapInputTime=t,this._latestMapOutputTime=e,e},r.prototype.endsAfter=function(t){return!!i.prototype.endsAfter.call(this,t)&&this._generator.endsAfter(this._mapTime(t))},r.prototype.dofEndsAfter=function(t,e){return!!i.prototype.dofEndsAfter.call(this,t,e)&&this._generator.dofEndsAfter(t,this._mapTime(e))},r.prototype.cropEnd=function(t,e){i.prototype.cropEnd.call(this,t,e),this._generator.cropEnd(this._mapTime(t),e)},r.prototype.notifyUpdateStarted=function(t){var e=this._mapTime(t);this._generator.notifyUpdateStarted(e),t.isGreater(this._startTime)&&(this._latestUpdateTime=t,this._generatorTimeAtLatestUpdate=e)},r.prototype.notifyUpdateFinished=function(t){this._generator.notifyUpdateFinished(this._mapTime(t))},r.prototype.notifyRemoved=function(){this._generator.notifyRemoved()},r.prototype.getDOFState=function(t,e,o){return this._generator.getDOFState(t,e,o)},e.exports=r},{"../../ifr-motion/base/RelativeTimeClip":77,"./BaseMotionGenerator":8}],24:[function(t,e,o){"use strict";var i=t("../ifr-core/Time"),n=t("../ifr-core/SLog"),r={NONE:0,LIMP:1,BRAKE:2,PWM:3,VELOCITY:4,TRAJECTORY:5,TORQUE:6,POS_VEL:7},s={INDEXED:1,ENABLED:2,BRAKED:4,MOVING:8,STALLED:16,TIMEOUT:32,FAULT:64},a=function(){this.ts=null,this.pos=null,this.inc_pos=null,this.vel=null,this.cur=null,this.pwm=null,this.status=null,this.vel_limit=null,this.acc_limit=null,this.cur_limit=null,this.mode=null,this.ref=null,this.ref_pos=null,this.ref_acc=null,this.ticks=null,this.integrator=null,this.fault_status=null,this.index_count=null};a.prototype.getTimestamp=function(){return null===this.ts?null:i.createFromTimestamp(this.ts)},a.prototype.isIndexed=function(){return null!==this.status&&(1&this.status)>0},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;o<e.length;o++)this.hasOwnProperty(e[o])?this[e[o]]=t[e[o]]:n.info("SingleAxisState: unknown JSON property name: "+e[o]);return this};var l=function(){this.ts=null,this.pelvis=null,this.torso=null,this.neck=null,this.lockout=null};l.prototype.getTimestamp=function(){return null===this.ts?null:i.createFromTimestamp(this.ts)},l.prototype.hasLockout=function(){return null!==this.lockout&&0!==this.lockout},l.prototype.getLockout=function(){return this.lockout},l.prototype.hasFault=function(){return this.pelvis.hasFault()||this.torso.hasFault()||this.neck.hasFault()},l.prototype.hasTimeout=function(){var t=s.TIMEOUT;return this.pelvis.hasStatus(t)||this.torso.hasStatus(t)||this.neck.hasStatus(t)},l.prototype.setFromJson=function(t){return this.ts=t.ts,this.pelvis=(new a).setFromJson(t.pelvis),this.torso=(new a).setFromJson(t.torso),this.neck=(new a).setFromJson(t.neck),void 0!==t.lockout&&(this.lockout=t.lockout),this};var c=function(){this.mode=null,this.value=null,this.vel_limit=null,this.acc_limit=null,this.cur_limit=null},u=function(){this.ts=null,this.pelvis=null,this.torso=null,this.neck=null};u.prototype.setTimestamp=function(t){this.ts=t._timestamp};var h=function(){this.ts=null,this.color=null,this.rate_limit=null};h.prototype.setTimestamp=function(t){this.ts=t._timestamp},h.prototype.setRateLimit=function(t){this.rate_limit=[t,t,t]},e.exports.AxisCommandMode=r,e.exports.StatusFieldBitMask=s,e.exports.SingleAxisState=a,e.exports.AxisState=l,e.exports.SingleAxisCommand=c,e.exports.AxisCommand=u,e.exports.LEDCommand=h},{"../ifr-core/SLog":55,"../ifr-core/Time":56}],25:[function(t,e,o){"use strict";var i=t("./MotionInterface"),n=t("../ifr-core/TimerTools"),r=function(t,e,o,r,s,a){this.clock=t,this.robotInfo=e,this.outputTime=null,this.outputPose=null,this.reactionTime=.02,this.velocityCalcDelta=.02,this.motionInterface=new i(o,a),this.dofNames=this.motionInterface.getMotionDOFNames(),this.enabledArray=[];for(var l=0;l<this.dofNames.length;l++)this.enabledArray.push(void 0!==r&&r);if(this.paused=!1,this.infoListeners=[],this.updateHandle=null,s){var c=this;this.updateHandle=n.setInterval(function(){c.update()},s)}this.cachedTargets=null};r.prototype.getMotionDOFNames=function(){return this.dofNames},r.prototype.isConnected=function(){return this.motionInterface.isConnected()},r.prototype.setEnabled=function(t){for(var e=0;e<this.enabledArray.length;e++)this.enabledArray[e]=t instanceof Array?t[e]:t},r.prototype.setPaused=function(t,e){this.paused=t,null!==e&&void 0!==e&&e()},r.prototype.isPaused=function(){return this.paused},r.prototype.getMotionInterface=function(){return this.motionInterface},r.prototype.addInfoListener=function(t){this.infoListeners.push(t)},r.prototype.handleOutput=function(t,e,o){this.outputTime=t,this.outputPose=e,this.computeTargetsForTime(t,!0)},r.prototype.update=function(){},r.prototype.computeTargetsForTime=function(t,e){if(!e)return this.cachedTargets;if(null!==this.outputPose){for(var o=this.outputPose,i=[],n=0;n<this.dofNames.length;n++){var r=o.get(this.dofNames[n],0),s=o.get(this.dofNames[n],1);Math.abs(s)<.01&&(s=0),i.push({position:r,velocity:s})}return this.cachedTargets=i,i}return this.cachedTargets=null,null},r.prototype.dispose=function(){this.motionInterface.close(),null!==this.updateHandle&&(n.clearInterval(this.updateHandle),this.updateHandle=null),this.robotInfo=null,this.outputPose=null},e.exports=r},{"../ifr-core/TimerTools":57,"./MotionInterface":33}],26:[function(t,e,o){"use strict";var i=t("./BodyData"),n=t("./BodyOutput"),r=t("../ifr-core/Clock"),s=function(t,e,o,i,r,s,a){n.call(this,t,e,o,i,r,s),this.idleModeSwitchTime=.3,null!=a&&(this.idleModeSwitchTime=a),this.startTime=null,this.initialStates=[],this.lastMovingCommandTime=[],this.movingEpsilon=1e-4};s.prototype=Object.create(n.prototype),s.prototype.constructor=n,s.prototype.setPaused=function(t){n.prototype.setPaused.call(this,t),t&&(this.startTime=null,this.initialStates=[],this.lastMovingCommandTime=[])},s.prototype.update=function(){var t,e=this.clock.currentTime(),o=this.computeTargetsForTime(e.add(this.reactionTime));if(null!==o&&this.motionInterface.isConnected()&&!this.isPaused()){if(null===this.startTime){for(this.startTime=e,t=0;t<this.dofNames.length;t++)this.initialStates.push(this.motionInterface.getState(this.dofNames[t]));for(t=0;t<this.dofNames.length;t++)this.lastMovingCommandTime.push(r.currentTime())}var n=1,s=8;if(e.subtract(this.startTime)<s){var a=0;for(t=0;t<this.dofNames.length;t++)Math.abs(this.initialStates[t].pos)>a&&(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;t<this.dofNames.length;t++){var c,u=50;n<1?(c=[o[t].velocity*n,o[t].position*n+this.initialStates[t].pos*(1-n)],this.lastMovingCommandTime[t]=r.currentTime()):c=[o[t].velocity,o[t].position],(Math.abs(c[0])>this.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<this.infoListeners.length;g++)this.infoListeners[g](f)}this.motionInterface.sendCommand()}else this.startTime=null,this.initialStates=[],this.lastMovingCommandTime=[]},e.exports=s},{"../ifr-core/Clock":51,"./BodyData":24,"./BodyOutput":25}],27:[function(t,e,o){"use strict";var i=t("./BodyData"),n=t("./BodyOutput"),r=t("../ifr-motion/base/CyclicMath"),s={ESTABLISHING:"ESTABLISHING",RESUMING:"RESUMING",RUNNING:"RUNNING"},a=function(t,e,o,i,r,a){n.call(this,t,e,o,i,r,a),this.startTime=null,this.initialDeltas=[],this.error=!1,this.goLimpOnError=!0,this.goLimpOnTimeout=!0,this.goLimpOnDisconnect=!0,this.errorsAreSticky=!1,this.controlState=s.ESTABLISHING,this.fadeSecondsMax=8,this.fadeSeconds=0,this.unPauseCallbacks=[]};a.prototype=Object.create(n.prototype),a.prototype.constructor=n,a.prototype.setPaused=function(t,e){!t&&this.isPaused()&&(this.controlState=s.ESTABLISHING),n.prototype.setPaused.call(this,t,null),null!==e&&void 0!==e&&(t?e():this.controlState===s.RUNNING?e():this.unPauseCallbacks.push(e))},a.prototype.update=function(){var t,e=!1,o=this.clock.currentTime(),n=this.computeTargetsForTime(o.add(this.reactionTime));this.motionInterface.hasLockout()||this.motionInterface.hasFault()?(this.error=!0,this.goLimpOnError&&(this.controlState=s.ESTABLISHING)):this.error&&!this.errorsAreSticky&&(this.error=!1);var a=!1;this.motionInterface.hasTimeout()&&(a=!0,this.goLimpOnTimeout&&(this.controlState=s.ESTABLISHING));var l=!0;if(this.motionInterface.isConnected()||(l=!1,this.goLimpOnDisconnect&&(this.controlState=s.ESTABLISHING)),!this.isPaused()){if(this.controlState===s.ESTABLISHING&&l&&!this.error&&!a){var c,u=!0;for(t=0;t<this.dofNames.length;t++){c=this.motionInterface.getState(this.dofNames[t]);var h=n[t];if(Math.abs(c.vel)>.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;t<this.dofNames.length;t++){c=this.motionInterface.getState(this.dofNames[t]);var d=r.closestEquivalentRotation(n[t].position,c.pos),m=d-c.pos;this.initialDeltas.push(m),Math.abs(m)>p&&(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;t<this.dofNames.length;t++){var g=i.AxisCommandMode.BRAKE;!this.enabledArray[t]||this.controlState!==s.RUNNING&&this.controlState!==s.RESUMING||(g=i.AxisCommandMode.POS_VEL);var _,y=50;if(this.controlState===s.RESUMING){var v=this.initialDeltas[t]/this.fadeSeconds;Math.abs(v)<.1&&(v=0),_=[n[t].velocity+v,n[t].position-this.initialDeltas[t]*(1-f)]}else _=[n[t].velocity,n[t].position];if(_[1]=r.closestEquivalentRotation(_[1],0),this.motionInterface.setCommand(this.dofNames[t],g,g===i.AxisCommandMode.POS_VEL?_:0,null,y,null),this.infoListeners.length>0)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;O<this.infoListeners.length;O++)this.infoListeners[O](D)}this.motionInterface.sendCommand()}if(e)for(;this.unPauseCallbacks.length>0;)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;o<this.dofNames.length;o++){var i=e[o].position;this.motionInterface.setCommand(this.dofNames[o],0,i,null,null,null)}this.motionInterface.sendCommand()}},e.exports=n},{"./BodyOutput":25}],29:[function(t,e,o){"use strict";var i=t("./BodyData"),n=t("./BodyOutput"),r=function(t,e,o,i,r,s){n.call(this,t,e,o,i,r,s)};r.prototype=Object.create(n.prototype),r.prototype.constructor=n,r.prototype.update=function(){var t=this.clock.currentTime(),e=this.computeTargetsForTime(t.add(this.reactionTime)&&!this.isPaused());if(null!==e&&this.motionInterface.isConnected()){for(var o=0;o<this.dofNames.length;o++){var n=this.enabledArray[o]?i.AxisCommandMode.TRAJECTORY:i.AxisCommandMode.BRAKE,r=.3,s=30,a=[e[o].velocity,e[o].position,r,0];if(this.motionInterface.setCommand(this.dofNames[o],n,n===i.AxisCommandMode.TRAJECTORY?a:0,null,s,null),this.infoListeners.length>0)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;u<this.infoListeners.length;u++)this.infoListeners[u](c)}this.motionInterface.sendCommand()}},e.exports=r},{"./BodyData":24,"./BodyOutput":25}],30:[function(t,e,o){"use strict";var i=t("./BodyData"),n=t("./BodyOutput"),r=t("../ifr-motion/feedback/PVController"),s=function(t,e,o,i,s,a){n.call(this,t,e,o,i,s,a),this.feedbackControllers=[];for(var l=0;l<this.dofNames.length;l++)this.feedbackControllers.push(new r)};s.prototype=Object.create(n.prototype),s.prototype.constructor=n,s.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;o<this.dofNames.length;o++){this.feedbackControllers[o].setTarget(t,e[o].position,e[o].velocity),this.feedbackControllers[o].calculateForTime(t);var n=this.feedbackControllers[o].getCommandVelocity(),r=this.feedbackControllers[o].getCommandAcceleration(),s=this.enabledArray[o]?i.AxisCommandMode.VELOCITY:i.AxisCommandMode.BRAKE;this.motionInterface.setCommand(this.dofNames[o],s,n,null,r,null);var a=this.motionInterface.getState(this.dofNames[o]);if(this.feedbackControllers[o].acceptFeedback(t,a.pos,a.vel,a.ref),this.infoListeners.length>0)for(var l={dofName:this.dofNames[o],timestamp:t,observedPosition:a.pos,targetPosition:e[o].position,observedVelocity:a.vel,commandVelocity:n},c=0;c<this.infoListeners.length;c++)this.infoListeners[c](l)}this.motionInterface.sendCommand()}},e.exports=s},{"../ifr-motion/feedback/PVController":91,"./BodyData":24,"./BodyOutput":25}],31:[function(t,e,o){"use strict";var i=t("./BodyData"),n=t("../ifr-core/Clock"),r=t("../ifr-core/ReconnectingWebSocket"),s=function(t,e){this.command=new i.LEDCommand,this.command.color=[0,0,0],this.command.setRateLimit(50),this.commandSocket=new r(t+"/led_command",e,3e3,"BODY")};s.prototype.setCommand=function(t,e){for(var o=0;o<3;o++)this.command.color[o]=t[o];return this.command.setRateLimit(e),!0},s.prototype.sendCommand=function(){if(this.isConnected()){this.command.setTimestamp(n.currentTime());var t=JSON.stringify(this.command);return this.commandSocket.send(t),!0}return!1},s.prototype.isConnected=function(){return this.commandSocket.isConnected()},s.prototype.close=function(){this.commandSocket.close()},e.exports=s},{"../ifr-core/Clock":51,"../ifr-core/ReconnectingWebSocket":54,"./BodyData":24}],32:[function(t,e,o){"use strict";var i=t("./LEDInterface"),n=t("../ifr-core/TimerTools"),r=function(t,e,o,r,s,a){if(this.clock=t,this.robotInfo=e,this.outputTime=null,this.outputPose=null,this.reactionTime=.02,this.velocityCalcDelta=.02,this.rateLimit=50,this.ledInterface=new i(o,a),this.dofNames=this.robotInfo.getDOFSet("LED").getDOFs(),this.enabled=void 0===r||r,this.updateHandle=null,s){var l=this;this.updateHandle=n.setInterval(function(){l.update()},s)}};r.prototype.isConnected=function(){return this.ledInterface.isConnected()},r.prototype.setEnabled=function(t){this.enabled=t},r.prototype.handleOutput=function(t,e,o){this.outputTime=t,this.outputPose=e},r.prototype.update=function(){var t=this.clock.currentTime(),e=this.computeTargetsForTime(t.add(this.reactionTime));if(null!==e&&this.enabled&&this.ledInterface.isConnected()){for(var o=[],i=0;i<this.dofNames.length;i++)o.push(e[i].position);this.ledInterface.setCommand(o,this.rateLimit),this.ledInterface.sendCommand()}},r.prototype.computeTargetsForTime=function(t){if(null!==this.outputPose){for(var e=this.outputPose,o=[],i=0;i<this.dofNames.length;i++){var n=e.get(this.dofNames[i],0),r=e.get(this.dofNames[i],1);o.push({position:n,velocity:r})}return o}return null},r.prototype.dispose=function(){this.ledInterface.close(),null!==this.updateHandle&&(n.clearInterval(this.updateHandle),this.updateHandle=null),this.robotInfo=null,this.outputPose=null},e.exports=r},{"../ifr-core/TimerTools":57,"./LEDInterface":31}],33:[function(t,e,o){"use strict";var i=t("./BodyData"),n=t("../ifr-core/Clock"),r=t("../ifr-core/ReconnectingWebSocket"),s=function(t,e,o,n,s){var a=o||"bottomSection_r",l=n||"middleSection_r",c=s||"topSection_r";this.dofToAxis={},this.dofToAxis[a]="pelvis",this.dofToAxis[l]="torso",this.dofToAxis[c]="neck",this.dofNames=[a,l,c],this.stateMessageCount=0,this.latestAxisState=null,this.command=new i.AxisCommand,this.command.pelvis=new i.SingleAxisCommand,this.command.torso=new i.SingleAxisCommand,this.command.neck=new i.SingleAxisCommand;var u=this;this.stateSocket=new r(t+"/axis_state",e,3e3,"BODY"),this.stateSocket.on("message",function(t){var e=JSON.parse(t.data);u.latestAxisState=(new i.AxisState).setFromJson(e),u.stateMessageCount++}),this.stateSocket.on("close",function(){u.latestAxisState=null}),this.stateSocket.on("error",function(){u.latestAxisState=null}),this.commandSocket=new r(t+"/axis_command",e,3e3,"BODY")};s.prototype.getMotionDOFNames=function(){return this.dofNames},s.prototype.getState=function(t){if(!this.dofToAxis.hasOwnProperty(t))throw new Error("unknown motion DOF name: "+t);return null!==this.latestAxisState?this.latestAxisState[this.dofToAxis[t]]:null},s.prototype.getStateMessageCount=function(){return this.stateMessageCount},s.prototype.setCommand=function(t,e,o,i,n,r){if(!this.dofToAxis.hasOwnProperty(t))throw new Error("unknown motion DOF name: "+t);var s=this.getState(t);if(null!==s){var a=this.command[this.dofToAxis[t]];return a.mode=e,a.value=o instanceof Array?o:[o],a.vel_limit=void 0!==i&&null!==i?i:s.vel_limit,a.acc_limit=void 0!==n&&null!==n?n:s.acc_limit,a.cur_limit=void 0!==r&&null!==r?r:s.cur_limit,!0}return!1},s.prototype.sendCommand=function(){if(this.commandSocket.isConnected()){this.command.setTimestamp(n.currentTime());var t=JSON.stringify(this.command);return this.commandSocket.send(t),!0}return!1},s.prototype.isConnected=function(){return null!==this.latestAxisState&&this.commandSocket.isConnected()&&this.stateSocket.isConnected()},s.prototype.hasLockout=function(){return null!==this.latestAxisState&&this.latestAxisState.hasLockout()},s.prototype.hasTimeout=function(){return null!==this.latestAxisState&&this.latestAxisState.hasTimeout()},s.prototype.getLockout=function(){return null!==this.latestAxisState?this.latestAxisState.getLockout():null},s.prototype.hasFault=function(){return null!==this.latestAxisState&&this.latestAxisState.hasFault()},s.prototype.close=function(){this.stateSocket.close(),this.commandSocket.close()},e.exports=s},{"../ifr-core/Clock":51,"../ifr-core/ReconnectingWebSocket":54,"./BodyData":24}],34:[function(t,e,o){"use strict";var i=t("../ifr-core/Time"),n=t("../ifr-core/FileTools"),r={};r.createLog=function(e){var o="fs";o=t(o);var i=o.createWriteStream(e),n=!0;return function(t){n?n=!1:i.write(",\n"),i.write(JSON.stringify(t))}},r.createConsoleLog=function(t){return function(e){console.log(t+JSON.stringify(e))}},r.loadLog=function(t,e){n.loadText(t,function(t,o){if(t)e(t,null);else{var n=null;try{var r="["+o+"]";n=JSON.parse(r);for(var s=0;s<n.length;s++)n[s].timestamp=i.createFromTimestamp(n[s].timestamp._timestamp)}catch(t){e(t,null)}e(null,n)}})},r.loadConsoleLog=function(t,e,o){n.loadText(t,function(t,n){if(t)o(t,null);else{var r=[];try{for(var s=n.split("\n"),a=0;a<s.length;a++){var l=s[a].indexOf(e);l>=0&&r.push(JSON.parse(s[a].substring(l+e.length)))}for(var c=0;c<r.length;c++)r[c].timestamp=i.createFromTimestamp(r[c].timestamp._timestamp)}catch(t){o(t,null)}o(null,r)}})},e.exports=r},{"../ifr-core/FileTools":52,"../ifr-core/Time":56}],35:[function(t,e,o){"use strict";var i=t("./BodyOutput"),n=function(t,e,o,n,r,s,a){i.call(this,t,e,o,r,s,a),this.commandSocket=new WebSocket(n)};n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.update=function(){var t=this.clock.currentTime(),e=this.computeTargetsForTime(t.add(this.reactionTime));if(null!==e&&this.commandSocket.readyState===WebSocket.OPEN&&!this.isPaused()){for(var o=0;o<this.dofNames.length;o++)e[o].enabled=this.enabledArray[o];var i=JSON.stringify(e);if(this.commandSocket.send(i),this.infoListeners.length>0&&this.motionInterface.isConnected())for(o=0;o<this.dofNames.length;o++)for(var n=this.motionInterface.getState(this.dofNames[o]),r={dofName:this.dofNames[o],timestamp:t,observedPosition:n.pos,targetPosition:e[o].position,observedVelocity:n.vel,commandVelocity:e[o].velocity},s=0;s<this.infoListeners.length;s++)this.infoListeners[s](r)}},n.prototype.isConnected=function(){return this.motionInterface.isConnected()&&this.commandSocket.readyState===WebSocket.OPEN},e.exports=n},{"./BodyOutput":25}],36:[function(t,e,o){"use strict";var i=t("../animation-animate/AnimateImpl"),n=t("../animation-animate/timeline/MotionTimeline"),r=t("../animation-animate/timeline/SimpleLayerCombiner"),s=t("../animation-animate/timeline/ScaleSampleCombiner"),a=t("../animation-animate/timeline/AddSampleCombiner"),l=t("../animation-animate/timeline/MixedSampleCombiner"),c=t("../animation-visualize/RendererOutput"),u=t("../ifr-core/Clock"),h=t("../ifr-core/TimerTools"),p=[],d=[],m=function(t,e,o){var i=h.setInterval(function(){for(var t=0;t<o.length;t++)o[t].update()},e);p.push(t),d.push(i)},f=function(t){var e=p.indexOf(t);e>-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<o.length;i++)if(o[i]instanceof c){o[i].addRenderer(e);break}},disconnectRenderer:function(t,e){for(var o=t.getOutputs(),i=0;i<o.length;i++)if(o[i]instanceof c){o[i].removeRenderer(e);break}},disposeTimeline:function(t,e){if(f(t),e===!0)for(var o=t.getOutputs(),i=0;i<o.length;i++)void 0!==o[i].dispose&&o[i].dispose()}};e.exports=g},{"../animation-animate/AnimateImpl":2,"../animation-animate/timeline/AddSampleCombiner":6,"../animation-animate/timeline/MixedSampleCombiner":14,"../animation-animate/timeline/MotionTimeline":16,"../animation-animate/timeline/ScaleSampleCombiner":19,"../animation-animate/timeline/SimpleLayerCombiner":20,"../animation-visualize/RendererOutput":41,"../ifr-core/Clock":51,"../ifr-core/TimerTools":57}],37:[function(t,e,o){"use strict";var i=t("three"),n=t("./RenderPlugin"),r=function(){n.call(this,"DefaultEyeLighting"),this._mainLightBasePosition=new i.Vector3(0,.03,.09),this._mainLightXScale=2,this._mainLightYScale=2.7,this._ledEffectAmount=.2};r.prototype=Object.create(n.prototype),r.prototype.constructor=r,r.prototype.install=function(t,e){if(null!=e){var o=new i.AmbientLight(3158064);e.add(o),this._registerObjectForScene(e,"ambientLight",o);var n=new i.DirectionalLight(0,1);n.position.set(0,-2,0),e.add(n),this._registerObjectForScene(e,"ledLight",n);var r=new i.PointLight(10526880,1.2,1);r.position.copy(this._mainLightBasePosition),this._registerObjectForScene(e,"mainLight",r),e.add(r),this._markMaterialsForUpdate(e)}},r.prototype.update=function(t,e,o){if(null!=e){var i=this._getObjectForScene(e,"ledLight");if(null!=i){var n=o.lightring_redChannelBn_r,r=o.lightring_greenChannelBn_r,s=o.lightring_blueChannelBn_r;null!=n&&null!=r&&null!=s&&i.color.setRGB(n*this._ledEffectAmount,r*this._ledEffectAmount,s*this._ledEffectAmount)}var a=this._getObjectForScene(e,"mainLight");if(null!=a){var l=o.eyeSubRootBn_t,c=o.eyeSubRootBn_t_2;if(null!=l&&null!=c){l=this._mainLightBasePosition.x+l*this._mainLightXScale,c=this._mainLightBasePosition.y+c*this._mainLightYScale;var u=this._mainLightBasePosition.z;a.position.set(l,c,u)}}}},r.prototype.uninstall=function(t,e){if(null!=e){for(var o=["ambientLight","ledLight","mainLight"],i=0;i<o.length;i++){var n=this._getObjectForScene(e,o[i]);null!=n&&e.remove(n)}this._clearObjectForScene(e)}},e.exports=r},{"./RenderPlugin":40,three:void 0}],38:[function(t,e,o){"use strict";var i=t("../ifr-geometry/loaders/ArticulatedModelLoader"),n=t("../ifr-motion/loaders/KinematicsLoader"),r=t("../ifr-motion/dofs/TextureControl"),s=t("three"),a=function(t){this._config=t,this._textureLoader=null,this._modelRoot=null,this._modelControlGroup=null,this.loadSucceeded=!1,this.loadMessage=""};a.prototype.setTextureLoader=function(t){this._textureLoader=t},a.prototype.load=function(t){var e=this,o=new i;o.modelLoader.defaultMaterial.side=s.DoubleSide,o.load("body model",e._config.getBodyGeometryURL(),e._config.getBodySkeletonURL(),function(){var i=o.getResult();if(i.success){e._modelRoot=i.modelRoot;var s=new n,a=s.getModelControlFactory(r.Factory.prototype._controlType);e._textureLoader&&a.setSharedImageLoader(e._textureLoader),s.load(e._config.getBodyKinematicsURL(),function(){var o=s.getResult();o.success?(e._modelControlGroup=o.modelControlGroup,e._modelControlGroup.attachToModel(e._modelRoot),e.loadSucceeded=!0):(e.loadSucceeded=!1,e.loadMessage="kinematics load failed with message: "+o.message+", URL = "+o.url),t&&t()})}else e.loadSucceeded=!1,e.loadMessage=""+i.message+", model URL = "+i.modelUrl+", skeleton URL = "+i.skeletonUrl,t&&t()})},a.prototype.getModelRoot=function(){return this._modelRoot},a.prototype.getModelControlGroup=function(){return this._modelControlGroup},a.prototype.constructFaceScreenRenderTarget=function(t){var e=new s.WebGLRenderTarget(800,450);e.minFilter=s.LinearFilter;var o=this.getModelRoot().getObjectByName(t.faceScreenMeshName,!0);return o.material.map=e,e},e.exports=a},{"../ifr-geometry/loaders/ArticulatedModelLoader":61,"../ifr-motion/dofs/TextureControl":87,"../ifr-motion/loaders/KinematicsLoader":95,three:void 0}],39:[function(t,e,o){"use strict";var i=t("../ifr-geometry/loaders/ArticulatedModelLoader"),n=t("../ifr-motion/loaders/KinematicsLoader"),r=t("../ifr-motion/dofs/TextureControl"),s=t("three"),a=function(t){this._config=t,this._textureLoader=null,this._modelRoot=null,this._modelControlGroup=null,this.loadSucceeded=!1,this.loadMessage=""};a.prototype.setTextureLoader=function(t){this._textureLoader=t},a.prototype.load=function(t){var e=this,o=new i;o.load("eye model",e._config.getEyeGeometryURL(),e._config.getEyeSkeletonURL(),function(){var i=o.getResult();if(i.success){e._modelRoot=i.modelRoot;for(var a=0,l=.01,c=0;c<e._modelRoot.children.length;c++){var u=e._modelRoot.children[c];u instanceof s.SkinnedMesh&&(u.material.transparent=!0,u.frustumCulled=!1,u.position.z=a,a+=l)}e._modelRoot.traverse(function(t){t instanceof s.Mesh&&(t.material.transparent=!0,t.frustumCulled=!1)});var h=new n,p=h.getModelControlFactory(r.Factory.prototype._controlType);e._textureLoader&&p.setSharedImageLoader(e._textureLoader),h.load(e._config.getEyeKinematicsURL(),function(){var o=h.getResult();if(o.success){e._modelControlGroup=o.modelControlGroup,e._modelControlGroup.attachToModel(e._modelRoot);for(var i=0;i<e._modelControlGroup.getControlList().length;i++)"TEXTURE"===e._modelControlGroup.getControlList()[i].getControlType()&&e._modelControlGroup.getControlList()[i].setDefaultNormalURL(e._config.getDefaultNormalMap());e.loadSucceeded=!0}else e.loadSucceeded=!1,e.loadMessage="kinematics load failed with message: "+o.message+", URL = "+o.url;t&&t()})}else e.loadSucceeded=!1,e.loadMessage=""+i.message+", model URL = "+i.modelUrl+", skeleton URL = "+i.skeletonUrl,t&&t()})},a.prototype.getModelRoot=function(){return this._modelRoot},a.prototype.getModelControlGroup=function(){return this._modelControlGroup},a.prototype.constructCamera=function(t){var e=new s.OrthographicCamera(-t.faceScreenWidth/2,t.faceScreenWidth/2,t.faceScreenHeight/2,-t.faceScreenHeight/2,-20,20);return e.position.set(0,0,5),e.updateMatrixWorld(!0),e},a.prototype.constructScene=function(){var t=new s.Scene;return t.add(this.getModelRoot()),t},e.exports=a},{"../ifr-geometry/loaders/ArticulatedModelLoader":61,"../ifr-motion/dofs/TextureControl":87,"../ifr-motion/loaders/KinematicsLoader":95,three:void 0}],40:[function(t,e,o){"use strict";var i=t("three"),n=t("../ifr-core/SLog"),r="RENDER_PLUGIN",s=function(t){this._name=t,this._installed_cache=null},a=function(t){this._scene=t,this._objects={}};s.prototype._getObjectForScene=function(t,e){if(null==this._installed_cache)return null;for(var o=null,i=0;i<this._installed_cache.length;i++)if(t===this._installed_cache[i]._scene){o=this._installed_cache[i];break}return null===o?null:o._objects.hasOwnProperty(e)?o._objects[e]:null},s.prototype._clearObjectForScene=function(t,e){if(null!=this._installed_cache)for(var o=0;o<this._installed_cache.length;o++)if(t===this._installed_cache[o]._scene){if(null==e)this._installed_cache.splice(o,1);else{var i=this._installed_cache[o];delete i._objects[e]}break}},s.prototype._registerObjectForScene=function(t,e,o){null==this._installed_cache&&(this._installed_cache=[]);for(var i=null,s=0;s<this._installed_cache.length;s++)if(t===this._installed_cache[s]._scene){i=this._installed_cache[s];break}null===i&&(i=new a(t),this._installed_cache.push(i)),i._objects.hasOwnProperty(e)&&n(r,'Error, RenderPlugin registering object "'+e+'" but one is already registered'),i._objects[e]=o},s.prototype._markMaterialsForUpdate=function(t){t.traverse(function(t){t instanceof i.Mesh&&null!=t.material&&(t.material.needsUpdate=!0)})},s.prototype.install=function(t,e){},s.prototype.update=function(t,e,o){},s.prototype.uninstall=function(t,e){},s.prototype.getName=function(){return this._name},e.exports=s},{"../ifr-core/SLog":55,three:void 0}],41:[function(t,e,o){"use strict";var i=function(t){this.clock=t,this.kinematicInfo=null,this.renderers=[],this.outputTime=null,this.outputPose=null};i.prototype.setKinematicInfo=function(t){this.kinematicInfo=t},i.prototype.addRenderer=function(t){this.renderers.push(t)},i.prototype.removeRenderer=function(t){var e=this.renderers.indexOf(t);e>-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;i<o.length;i++){var n=t.get(o[i],0);e[o[i]]=n}for(var r=0;r<this.renderers.length;r++)this.renderers[r].display(e)}},i.prototype.dispose=function(){for(var t=0;t<this.renderers.length;t++)this.renderers[t].dispose();this.renderers=[],this.kinematicInfo=null,this.outputPose=null},e.exports=i},{}],42:[function(t,e,o){"use strict";var i=t("../geometry-info/SceneInfo"),n=t("./JiboBody"),r=t("./JiboEye"),s=t("../ifr-visualizer/BasicScene"),a=t("../ifr-geometry/loaders/CachedImageLoader"),l=t("three"),c=t("./DefaultEyeLighting"),u=t("../ifr-core/SLog"),h="MODEL_LOADING",p=function(t,e,o,i,n,r){this.robotInfo=t,this.scene=e,this.modelControlGroups=n,this.textureLoader=r,this.grid=null,this.renderedDOFs=[],this.dofLastValues=[],this.dofIsMetric=[];for(var s=0;s<this.modelControlGroups.length;s++)for(var a=this.modelControlGroups[s].getDOFNames(),l=0;l<a.length;l++){var c=a[l];this.renderedDOFs.indexOf(c)<0&&(this.renderedDOFs.push(c),this.dofLastValues.push(1/0),this.dofIsMetric.push(t.getDOFInfo(c).isMetric()))}this.dofChangeEpsilon=1e-4,this.trackDOFDirtyStatus=!1,this.renderPlugins={},this.bodyScene=o,this.eyeScene=i,this.display(this.robotInfo.getDefaultDOFValues()),null!==this.scene.getContainer()&&this.scene.play()};p.prototype.setRenderOnlyWhenDirty=function(t){this.trackDOFDirtyStatus=t,this.scene.setRenderOnlyWhenDirty(t)},p.prototype.setRenderEveryNFrames=function(t){this.scene.setRenderEveryNFrames(t)},p.prototype.display=function(t){var e=!0;if(this.trackDOFDirtyStatus){for(var o=!1,i=this.dofChangeEpsilon,n=0;n<this.renderedDOFs.length;n++){var r=t[this.renderedDOFs[n]],s=this.dofLastValues[n];r!==s&&(this.dofIsMetric[n]?Math.abs(s-r)>i&&(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<this.modelControlGroups.length;a++)this.modelControlGroups[a].updateFromDOFValues(t);var l=Object.keys(this.renderPlugins);for(a=0;a<l.length;a++)this.renderPlugins[l[a]].update(this.bodyScene,this.eyeScene,t)}},p.prototype.loadTexture=function(t){this.textureLoader.loadImage(t)},p.prototype.setBackgroundColor=function(t,e,o,i){i||(i=1),this.scene.getRenderer().setClearColor(new l.Color(t,e,o),i)},p.prototype.setCamera=function(t,e,o){var i=t,n=e?e:new l.Vector3,r=o?o:45;this.scene.getCamera().position.copy(i),this.scene.getTrackballControls().target.copy(n),this.scene.getCamera().fov=r,this.scene.getCamera().updateProjectionMatrix()},p.prototype.setGrid=function(t,e,o){null!==this.grid&&this.scene.getScene().remove(this.grid),this.grid=new l.GridHelper(e*t,t),this.grid.quaternion.setFromAxisAngle(new l.Vector3(1,0,0),Math.PI/2),this.grid.setColors(o,o),this.scene.getScene().add(this.grid)},p.prototype.detachFromContainer=function(){this.scene.detachFromContainer()},p.prototype.attachToContainer=function(t){null!==this.scene.getContainer()&&this.detachFromContainer(),this.scene.attachToContainer(t),null!==this.scene.getContainer()&&this.scene.play()},p.prototype.dispose=function(){null!==this.scene&&(this.scene.dispose(),this.scene=null),this.robotInfo=null,this.modelControlGroups=[],this.textureLoader=null,this.grid=null},p.prototype.removeCameraControls=function(){this.scene.removeTrackballControls()},p.prototype.installRenderPlugin=function(t){var e=t.getName();this.renderPlugins.hasOwnProperty(e)&&this.renderPlugins[e].uninstall(this.bodyScene,this.eyeScene),t.install(this.bodyScene,this.eyeScene),this.renderPlugins[e]=t},p.prototype.removeRenderPlugin=function(t){this.renderPlugins.hasOwnProperty(t)&&(this.renderPlugins[t].uninstall(this.bodyScene,this.eyeScene),delete this.renderPlugins[t])},p.prototype.getInstalledRenderPluginNames=function(){return Object.keys(this.renderPlugins)};var d={createRobotRenderer:function(t,e,o,m){var f=t.getConfig(),g=null,_=[],y=new a,v=null,T=new i;T.load(f.getSceneInfoURL(),function(){if(T.loadSucceeded){var i=new r(f);i.load(function(){if(i.loadSucceeded)if(_.push(i.getModelControlGroup()),o===d.DisplayType.EYE)g=new s(e,!1,!1,new l.Color(0,0,0)),g._camera=i.constructCamera(T),g._scene=i.constructScene(),v=new p(t,g,null,g._scene,_,y),v.installRenderPlugin(new c),m&&m(v);else{var r=new n(f);r.load(function(){if(r.loadSucceeded){_.push(r.getModelControlGroup()),g=new s(e,!1,!1,new l.Color(0,0,.3)),g.getCamera().up=new l.Vector3(0,0,1),g.installTrackballControls(),g.getDirectionalLight().intensity=.5,g.getDirectionalLight().position.set(1,-1,1);var o=new l.DirectionalLight(16777215,.5);o.position.set(1,1,1),g.getScene().add(o);var n=new l.DirectionalLight(16777215,.5);n.position.set(-1,0,1),g.getScene().add(n);var a=r.getModelRoot();g.getScene().add(a);var d=i.constructScene(),f=i.constructCamera(T),D=r.constructFaceScreenRenderTarget(T),O=new l.Color,L=new l.Color(0,0,0);g.addRenderCallback(function(){var t=g.getRenderer();O.copy(t.getClearColor()),t.setClearColor(L),t.render(d,f,D),t.setClearColor(O)}),v=new p(t,g,g._scene,d,_,y),v.setCamera(new l.Vector3(.5,0,.37),new l.Vector3(0,0,.17),45),v.installRenderPlugin(new c),m&&m(v)}else u(h,"JiboBody load error: "+r.loadMessage),m&&m(null)})}else u(h,"JiboEye load error: "+i.loadMessage),m&&m(null)})}else u(h,"SceneInfo load error: "+T.loadMessage),m&&m(null)})},getEye:function(){return null}},m={BODY:"BODY",EYE:"EYE"};d.DisplayType=m,e.exports=d},{"../geometry-info/SceneInfo":49,"../ifr-core/SLog":55,"../ifr-geometry/loaders/CachedImageLoader":62,"../ifr-visualizer/BasicScene":121,"./DefaultEyeLighting":37,"./JiboBody":38,"./JiboEye":39,three:void 0}],43:[function(t,e,o){"use strict";var i=t("../ifr-core/FileTools"),n=t("../ifr-core/SLog"),r="MODEL_LOADING",s=function(t,e){var o={};if(null!=t)for(var i=0;i<t.length;i++)o[t[i]]=!0;this.plus=function(t){var i;i="string"==typeof t?e[t]:t;var n=this.getDOFs(),r=i.getDOFs();if(null!=i)for(var a=0;a<r.length;a++)o.hasOwnProperty(r[a])||n.push(r[a]);return new s(n,e)},this.minus=function(t){var o;o="string"==typeof t?e[t]:t;var i=[],n=this.getDOFs();if(null!=o)for(var r=0;r<n.length;r++)o.hasDOF(n[r])||i.push(n[r]);else i=n;return new s(i,e)},this.getDOFs=function(){return Object.keys(o)},this.hasDOF=function(t){return o.hasOwnProperty(t)}};s.load=function(t,e){i.loadJSON(t,function(t,o){if(null===t){var i=s.createDOFSetsFromJSON(o);e&&e(i,null)}else e&&e(null,t)})},s.createDOFSetsFromJSON=function(t){var e;"DOFSets"!==t.header.fileType&&n(r,"DOFSet doesn't know how to parse file with type "+t.header.fileType);var o=t.content.DOFSets,i=Object.keys(o),a={};for(e=0;e<i.length;e++)a[i[e]]=new s(o[i[e]],a);if(t.content.hasOwnProperty("CompoundSets")){var l=t.content.CompoundSets,c=Object.keys(l);for(e=0;e<c.length;e++){for(var u=l[c[e]],h=new s(null,a),p=0;p<u.length;p++){var d=u[p];a.hasOwnProperty(d)?h=h.plus(a[d]):n(r,"Error, compound DOFSet "+c[e]+" requested basic set "+d+" but it is not present in file")}a[c[e]]=h}}return a},e.exports=s},{"../ifr-core/FileTools":52,"../ifr-core/SLog":55}],44:[function(t,e,o){"use strict";var i=t("../ifr-motion/dofs/TranslationControl"),n={};n.verticesForDOFValues=function(t,e){for(var o=e.getKinematicInfo().getEyeControlGroup(),n={},r=o.getControlList(),s=0;s<r.length;s++){var a=r[s];a instanceof i&&(n[a._skeletonFrameName]=a.computeFromDOFValues(t,!0))}return n},e.exports=n},{"../ifr-motion/dofs/TranslationControl":88}],45:[function(t,e,o){"use strict";var i=function(t,e,o){this.eyeScreenWidth=t,this.eyeScreenHeight=e,this.eyeScreenBillboardMeshName=o};i.prototype.getWidth=function(){return this.eyeScreenWidth},i.prototype.getHeight=function(){return this.eyeScreenHeight},i.prototype.getEyeScreenBillboardMeshName=function(){return this.eyeScreenBillboardMeshName},e.exports=i},{}],46:[function(t,e,o){"use strict";var i=function(e,o){var i=e;if(void 0===i){var n="find-root";n=t(n),i=n(__dirname)+"/res/geometry-config/"}var r=void 0!==o?o:"P1.0",s=i+r+"/",a=s+"jibo_body.geom",l=s+"jibo_body.skel",c=s+"jibo_body.kin",u=s+"jibo_joined.geom",h=s+"jibo_joined.skel",p=s+"jibo_joined.kin",d=s+"jibo_eye.geom",m=s+"jibo_eye.skel",f=s+"jibo_eye.kin",g=s+"jibo.jscene",_=s+"jibo.dofgroups",y=s+"jibo.lim",v=s+"defaultNormalMap.png";this.getRobotURL=function(){return s},this.getBodyGeometryURL=function(){return a},this.getBodySkeletonURL=function(){return l},this.getBodyKinematicsURL=function(){return c},this.getFullGeometryURL=function(){return u},this.getFullSkeletonURL=function(){return h},this.getFullKinematicsURL=function(){return p},this.getEyeGeometryURL=function(){return d},this.getEyeSkeletonURL=function(){return m},this.getEyeKinematicsURL=function(){return f},this.getSceneInfoURL=function(){return g},this.getDOFGroupsURL=function(){return _},this.getLimitsURL=function(){return y},this.getDefaultNormalMap=function(){return v}};e.exports=i},{}],47:[function(t,e,o){"use strict";var i=t("../ifr-motion/loaders/KinematicsLoader"),n=t("../ifr-motion/loaders/AnimationLoader"),r=t("../ifr-motion/loaders/LimitsLoader"),s=t("../ifr-geometry/loaders/SkeletonLoader"),a=t("./SceneInfo"),l=t("../ifr-motion/dofs/KinematicGroup"),c=t("../ifr-motion/base/InterpolatorSet"),u=t("../ifr-motion/base/SeriesAlignedAxesTargetSelector"),h=t("../ifr-motion/dofs/ModelControlGroup"),p=t("../ifr-motion/base/DOFGlobalAlignment"),d=t("./EyeScreenInfo"),m=t("../ifr-motion/base/Pose"),f=t("./DOFSet"),g=t("../ifr-core/SLog"),_="MODEL_LOADING",y=function(t){this._config=t,this._bodyControlGroup=null,this._eyeControlGroup=null,this._fullControlGroup=null,this._bodyDOFNames=[],this._eyeDOFNames=[],this._dofNames=[],this._interpolatorSet=new c,this._bodyKinematicGroup=null,this._fullKinematicGroup=null,this._defaultAnimation=null,this._defaultPose=null,this.loadSucceeded=!1,this.loadMessage="",this._eyeScreenInfo=null,this._dofSets=null,this._dofGlobalAlignment=null};y.prototype.load=function(t){var e=this,o=[],c=null,y=!1,v=null,T=null,D=null,O=function(t,e){if(o.indexOf(t)>=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;i<e._dofNames.length;i++)if(null===e._defaultPose.get(e._dofNames[i],0)){e.loadMessage="default animation has no value for DOF: "+e._dofNames[i],e.loadSucceeded=!1;break}e._dofGlobalAlignment=new p(e._fullKinematicGroup,{middleSection_r:new u("middleSection_r",["bottomSection_r"],[1]),topSection_r:new u("topSection_r",["middleSection_r","bottomSection_r"],[1,1])});for(var n=Object.keys(D),r=0;r<n.length;r++){var s=e._fullControlGroup.getDOFInfo(n[r]);s.setLimitData(D[n[r]])}}t&&t()};var L=new i,F=O("Ensure All Loads Queued",null);L.load(e._config.getBodyKinematicsURL(),O("Body Kinematics",function(){var t=L.getResult();t.success?(e._bodyControlGroup=t.modelControlGroup,e._bodyDOFNames=e._bodyControlGroup.getDOFNames(),e._interpolatorSet.addModelControlGroup(e._bodyControlGroup)):(y=!0,e.loadMessage="body kinematics load failed with message: "+t.message+", URL = "+t.url)})),L.load(e._config.getEyeKinematicsURL(),O("Eye Kinematics",function(){var t=L.getResult();t.success?(e._eyeControlGroup=t.modelControlGroup,e._eyeDOFNames=e._eyeControlGroup.getDOFNames(),e._interpolatorSet.addModelControlGroup(e._eyeControlGroup)):(y=!0,e.loadMessage="eye kinematics load failed with message: "+t.message+", URL = "+t.url)}));var w=new s;w.load(e._config.getBodySkeletonURL(),O("Body Skeleton",function(){var t=w.getResult();t.success?v=t.skeletonRoot:(y=!0,e.loadMessage="body skeleton load failed with message: "+t.message+", URL = "+t.url)}));var S=new s;S.load(e._config.getFullSkeletonURL(),O("Full Skeleton",function(){var t=S.getResult();t.success?T=t.skeletonRoot:(y=!0,e.loadMessage="full skeleton load failed with message: "+t.message+", URL = "+t.url)}));var b=new n;b.load(e._config.getRobotURL()+"jibo_default.anim",O("Default Animation",function(){var t=b.getResult();t.success?e._defaultAnimation=t.motion:(y=!0,e.loadMessage="default animation load failed with message: "+t.message+", URL = "+t.url)}));var k=new a;k.load(e._config.getSceneInfoURL(),O("Scene Info",function(){k.loadSucceeded?e._eyeScreenInfo=new d(k.faceScreenWidth,k.faceScreenHeight,k.faceScreenMeshName):(y=!0,e.loadMessage="scene info failed with load message: "+k.loadMessage+", URL = "+e._config.getSceneInfoURL())})),f.load(e._config.getDOFGroupsURL(),O("DOF Groups",function(t,o){null!=t?e._dofSets=t:(y=!0,e.loadMessage="DOF Groups failed with load message: "+o+", URL = "+e._config.getDOFGroupsURL())}));var C=new r;C.load(e._config.getLimitsURL(),O("Limits",function(){var t=C.getResult();t.success?D=t.dofLimits:(y=!0,e.loadMessage="limits data load failed with message: "+t.message+", URL = "+t.url)})),F()},y.prototype.getBodyControlGroup=function(){return this._bodyControlGroup},y.prototype.getEyeControlGroup=function(){return this._eyeControlGroup},y.prototype.getFullControlGroup=function(){return this._fullControlGroup},y.prototype.getBodyDOFNames=function(){return this._bodyDOFNames},y.prototype.getEyeDOFNames=function(){return this._eyeDOFNames},y.prototype.getDOFNames=function(){return this._dofNames},y.prototype.getFullKinematicGroup=function(){return this._fullKinematicGroup},y.prototype.getBodyKinematicGroup=function(){return this._bodyKinematicGroup},y.prototype.getInterpolatorSet=function(){return this._interpolatorSet},y.prototype.getDefaultPose=function(){return this._defaultPose},y.prototype.getEyeScreenInfo=function(){return this._eyeScreenInfo},y.prototype.getDOFSets=function(){return this._dofSets},y.prototype.getDOFGlobalAlignment=function(){return this._dofGlobalAlignment},e.exports=y},{"../ifr-core/SLog":55,"../ifr-geometry/loaders/SkeletonLoader":64,"../ifr-motion/base/DOFGlobalAlignment":69,"../ifr-motion/base/InterpolatorSet":70,"../ifr-motion/base/Pose":76,"../ifr-motion/base/SeriesAlignedAxesTargetSelector":78,"../ifr-motion/dofs/KinematicGroup":82,"../ifr-motion/dofs/ModelControlGroup":85,"../ifr-motion/loaders/AnimationLoader":94,"../ifr-motion/loaders/KinematicsLoader":95,"../ifr-motion/loaders/LimitsLoader":96,"./DOFSet":43,"./EyeScreenInfo":45,"./SceneInfo":49}],48:[function(t,e,o){"use strict";var i=t("./JiboConfig"),n=t("./JiboKinematicInfo"),r=t("../ifr-core/SLog"),s="MODEL_LOADING",a=function(t,e){this._jiboConfig=t,this._kinematicInfo=e};a.createInfo=function(t,e){void 0!==t&&null!==t||(t=new i);var o=new n(t);o.load(function(){o.loadSucceeded?e(new a(t,o)):(r(s,"RobotInfo creation failed: "+o.loadMessage),e(null))})},a.prototype.getKinematicInfo=function(){return this._kinematicInfo},a.prototype.getConfig=function(){return this._jiboConfig},a.prototype.getBodyDOFNames=function(){return this._kinematicInfo.getBodyDOFNames()},a.prototype.getEyeDOFNames=function(){return this._kinematicInfo.getEyeDOFNames()},a.prototype.getDOFNames=function(){return this._kinematicInfo.getDOFNames()},a.prototype.getEyeScreenInfo=function(){return this._kinematicInfo.getEyeScreenInfo()},a.prototype.getDOFInfo=function(t){return this._kinematicInfo.getFullControlGroup().getDOFInfo(t)},a.prototype.getDefaultDOFValues=function(){for(var t={},e=this._kinematicInfo.getDefaultPose(),o=this.getDOFNames(),i=0;i<o.length;i++){var n=o[i];t[n]=e.get(n,0)}return t},a.prototype.getDOFSetNames=function(){return Object.keys(this._kinematicInfo.getDOFSets())},a.prototype.getDOFSet=function(t){return this._kinematicInfo.getDOFSets()[t]},e.exports=a},{"../ifr-core/SLog":55,"./JiboConfig":46,"./JiboKinematicInfo":47}],49:[function(t,e,o){"use strict";var i=t("../ifr-core/FileTools"),n=function(){this.faceScreenMeshName=null,this.faceScreenWidth=null,this.faceScreenHeight=null,this.loadURL=null,this.loadSucceeded=!1,this.loadMessage=""};n.prototype.load=function(t,e){this.loadURL=t;var o=this;i.loadJSON(t,function(t,i){null===t?(o.parseData(i),e&&e()):(o.loadSucceeded=!1,o.loadMessage=t,e&&e())})},n.prototype.parseData=function(t){return"SceneInfo"!==t.header.fileType?(this.loadSucceeded=!1,void(this.loadMessage="don't know how to handle file type: "+t.header.fileType)):(this.faceScreenMeshName=t.content.faceScreenMeshName,this.faceScreenWidth=t.content.faceScreenInternalBounds[0],this.faceScreenHeight=t.content.faceScreenInternalBounds[1],void(this.loadSucceeded=!0))},e.exports=n},{"../ifr-core/FileTools":52}],50:[function(t,e,o){"use strict";var i=t("./SLog"),n=null,r={},s=!1;r.init=function(t){null===n?n=t:i.warn("Warning, Bakery initialized multiple times!")};var a=function(t){return n},l=function(){s||(i.info("Bakery values requested by Bakery never initialized"),s=!0)};r.getFloat=function(t,e,o,i,n){var r=a(n);return null!==r?r.getFloat(t,e,o,i,n):(l(),i)},r.getBoolean=function(t,e,o){var i=a(o);return null!==i?i.getBoolean(t,e,o):(l(),e)},r.makeButton=function(t,e,o){var i=a(o);null!==i?i.makeButton(t,e,o):l()},r.showText=function(t,e,o){var i=a(o);null!==i?i.showText(t,e,o):l()},e.exports=r},{"./SLog":55}],51:[function(t,e,o){"use strict";var i=t("./Time"),n={};n.currentTime=function(){var t,e;"undefined"!=typeof window&&"undefined"!=typeof window.performance?(t=window.performance.now(),e=window.performance.timing.navigationStart):(t=0,e=Date.now());var o=Math.floor(t),n=t-o,r=o+e,s=Math.floor(r/1e3);r-=1e3*s;var a=r+n;return a=Math.round(1e3*a),1e6===a&&(a=0,s+=1),new i(s,a)},e.exports=n},{"./Time":56}],52:[function(t,e,o){"use strict";var i=t("urijs"),n={};n.loadText=function(e,o){var n=new i(e);if(n.addQuery(""+(new Date).getTime()),"undefined"!=typeof XMLHttpRequest){var r=new XMLHttpRequest;r.open("GET",n.toString(),!0),r.addEventListener("load",function(t){o&&(200===r.status||0===r.status?o(null,r.responseText):o("FileTools: XMLHttpRequest failed with status: "+r.statusText,null))},!1),r.addEventListener("error",function(t){o&&o("FileTools: XMLHttpRequest error event with status: "+r.statusText,null)},!1),r.send(null)}else if("http"===n.protocol()){var s="http";s=t(s);var a={host:n.hostname(),port:n.port()?parseInt(n.port()):80,path:n.resource(),method:"GET"},l=s.request(a,function(t){200===t.statusCode?(t.setEncoding("utf8"),t.on("data",function(t){o&&o(null,t)})):o&&o("FileTools: http request failed with status code: "+t.statusCode,null)});l.on("error",function(t){o&&o(t.message,null)}),l.end()}else if("file"===n.protocol()||""===n.protocol()){var c="fs";c=t(c),c.readFile(n.path(),"utf8",o)}else o&&o("FileTools: no XMLHttpRequest available, and no fallback support for protocol: "+n.protocol(),null)},n.loadJSON=function(t,e){n.loadText(t,function(t,o){if(e)if(t)e(t,null);else{var i=null,n=!1,r="";try{i=JSON.parse(o)}catch(t){n=!0,r=t}n?e("FileTools: JSON parse error: "+r,null):e(null,i)}})},e.exports=n},{urijs:void 0}],53:[function(t,e,o){"use strict";var i=t("./FileTools"),n=t("./SLog"),r=function(t){var e=null,o=null;if("string"==typeof t?o=t:e=t,this._dataRoot={},this._defaultScopeName="default",e&&(this._dataRoot=e),o){var r=this;i.loadJSON(o,function(t,e){t?n.error("JSONBaker: failed to load data, url: "+o+" error: "+t):r._dataRoot=e})}};r.prototype._getScope=function(t){if(t||(t=this._defaultScopeName),t instanceof Array){for(var e=this._dataRoot,o=0;o<t.length;o++)"object"!=typeof e[t[o]]&&(e[t[o]]={}),e=e[t[o]];return e}return"object"!=typeof this._dataRoot[t]&&(this._dataRoot[t]={}),this._dataRoot[t]},r.prototype.getFloat=function(t,e,o,i,n){var r=this._getScope(n),s=r[t];return void 0!==s&&null!==s||(s=i,r[t]=s),s},r.prototype.getBoolean=function(t,e,o){var i=this._getScope(o),n=i[t];return void 0!==n&&null!==n||(n=e,i[t]=n),n},r.prototype.makeButton=function(t,e,o){},r.prototype.showText=function(t,e,o){},r.prototype.getData=function(){return this._dataRoot},r.prototype.setProperty=function(t,e){var o=t.split("/"),i=o[o.length-1],n=null;o.length>1&&(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<o.length;i++)o[i](e)},n.prototype._openHappened=function(t){i(this._channelName,"Socket opened: "+this._url),this._fireEvent(t.type,t)},n.prototype._closeHappened=function(t){i(this._channelName,"Socket closed: "+this._url+" code: "+t.code+" reason: "+t.reason+" clean: "+t.wasClean),this._fireEvent(t.type,t),this._considerReconnect()},n.prototype._errorHappened=function(t){i(this._channelName,"Socket error: "+this._url),this._fireEvent(t.type,t),this._considerReconnect()},n.prototype._messageHappened=function(t){this._fireEvent(t.type,t)},e.exports=n},{"./SLog":55}],55:[function(t,e,o){"use strict";var i=function(t,e){},n=function(t,e){console.log(t+" : "+e)},r=i,s={ERROR:n},a=function(t,e){s.hasOwnProperty(t)?s[t](t,e):r(t,e)};a.BaseChannels={INFO:"INFO",WARN:"WARN",ERROR:"ERROR"},a.info=function(t){a(a.BaseChannels.INFO,t)},a.warn=function(t){a(a.BaseChannels.WARN,t)},a.error=function(t){a(a.BaseChannels.ERROR,t)},a.setDefaultDelegate=function(t){r=null==t?i:t},a.setChannelDelegate=function(t,e){null==e?s[t]=i:s[t]=e},a.clearChannelDelegate=function(t){if(null==t)for(var e=Object.keys(s),o=0;o<e.length;o++)delete s[e[o]];else delete s[t]},a.setPrintChannels=function(t){if(a.setDefaultDelegate(null),a.clearChannelDelegate(null),null!=t)for(var e=0;e<t.length;e++)a.setChannelDelegate(t[e],n)},a.setPrintAll=function(){a.setDefaultDelegate(n),a.clearChannelDelegate(null)},a.setPrintNone=function(){a.setDefaultDelegate(i),a.clearChannelDelegate(null)},e.exports=a},{}],56:[function(t,e,o){"use strict";var i=function(t){var e=t[0]===+t[0]&&t[1]===+t[1]&&t[0]>=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;c<a.meshes.length;c++){var h=a.meshes[c];if(h.bones){for(var p=0;p<h.bones.length;p++){var d=u.getObjectByName(h.boneFrameNames[p],!0);if(!d)return n._result.success=!1,n._result.message="unable to find skeleton frame: "+h.boneFrameNames[p]+" required to attach bone "+p+" of mesh: "+h.name,void i();d.add(h.bones[p])}h.mesh.material.skinning=!0,l.add(h.mesh)}else{if(!h.skeletonFrameName)return n._result.success=!1,n._result.message="unable to attach mesh: "+h.name+" - no skeleton frame or skinning data specified",void i();var m=u.getObjectByName(h.skeletonFrameName,!0);if(!m)return n._result.success=!1,n._result.message="unable to find skeleton frame: "+h.skeletonFrameName+" required to attach mesh: "+h.name,void i();m.add(h.mesh)}}}else for(c=0;c<a.meshes.length;c++)l.add(a.meshes[c].mesh);n._result.success=!0,n._result.modelRoot=l,i()})},e.exports=a},{"./ModelLoader":63,"./SkeletonLoader":64,three:void 0}],62:[function(t,e,o){"use strict";var i=t("three"),n=function(){this.url=null,this.success=!1,this.image=null},r=function(){this._loader=new i.ImageLoader,this._result=null};r.prototype.getResult=function(){return this._result},r.prototype.loadImage=function(t,e){var o=this;this._loader.load(t,function(i){var r=new n;r.url=t,r.success=!0,r.image=i,o._result=r,e&&e()},void 0,function(i){var r=new n;r.url=t,r.success=!1,o._result=r,e&&e()})},e.exports=r},{three:void 0}],63:[function(t,e,o){"use strict";var i=t("../BasicMesh"),n=t("../BasicFrame"),r=t("../../ifr-core/FileTools"),s=t("three"),a=function(){this.url=null,this.success=!1,this.message="",this.meshes=null},l=function(t){this.defaultMaterial=t,this.defaultMaterial||(this.defaultMaterial=new s.MeshPhongMaterial),this.baseTextureURL=null,this._result=null};l.prototype.getResult=function(){return this._result},l.prototype.load=function(t,e){var o=this;r.loadJSON(t,function(i,n){if(null===i)o.parseData(n,t),e&&e();else{var r=new a;
r.url=t,r.success=!1,r.message=i,o._result=r,e&&e()}})},l.prototype.parseData=function(t,e){if(this._result=new a,this._result.url=e,"Meshes"!==t.header.fileType)return this._result.success=!1,void(this._result.message="don't know how to handle file type: "+t.header.fileType);var o=e.substring(0,e.lastIndexOf("/")+1);this._result.meshes=[];for(var r=0;r<t.content.meshes.length;r++){var l=t.content.meshes[r],c=new i;c.name=l.name,c.skeletonFrameName=l.skeletonFrameName;var u=new s.BufferGeometry,h=new Float32Array(l.position);if(u.addAttribute("position",new s.BufferAttribute(h,3)),l.normal){var p=new Float32Array(l.normal);u.addAttribute("normal",new s.BufferAttribute(p,3))}if(l.textureCoordinates){var d=new Float32Array(l.textureCoordinates);u.addAttribute("uv",new s.BufferAttribute(d,2))}if(l.triangles){var m=new Uint32Array(l.triangles);u.addAttribute("index",new s.BufferAttribute(m,3))}if(l.color){for(var f=new Float32Array(l.color.length/4*3),g=0;g<l.color.length/4;g++)f[3*g]=l.color[4*g],f[3*g+1]=l.color[4*g+1],f[3*g+2]=l.color[4*g+2];u.addAttribute("color",new s.BufferAttribute(f,3))}var _=this.defaultMaterial.clone();if(_.vertexColors=l.color?s.VertexColors:s.NoColors,l.material){var y=l.material;if(y.ambient&&(_.ambient=new s.Color(y.ambient[0],y.ambient[1],y.ambient[2])),y.diffuse&&(_.color=new s.Color(y.diffuse[0],y.diffuse[1],y.diffuse[2])),y.specular&&(_.specular=new s.Color(y.specular[0],y.specular[1],y.specular[2])),y.emissive&&(_.emissive=new s.Color(y.emissive[0],y.emissive[1],y.emissive[2])),y.shininess&&(_.shininess=y.shininess),y.texture){var v=this.baseTextureURL?this.baseTextureURL+y.texture:o+y.texture,T=s.ImageUtils.loadTexture(v);T.minFilter=s.LinearFilter,_.map=T}}if(l.skin){c.mesh=new s.SkinnedMesh(u,_),c.mesh.name=l.name;var D=l.skin;c.boneFrameNames=D.skeletonTotalInfluences;var O=c.boneFrameNames.length,L=(new n).setFromJson(D.skinBindFrame),F=L.toMatrix4();c.bones=[];for(var w=[],S=0;S<O;S++){var b=(new n).setFromJson(D.skinBindInverses[S]);w.push(b.toMatrix4());var k=new s.Bone(c.mesh);c.bones.push(k)}var C=new s.Skeleton(c.bones,w,!1);c.mesh.bindMode="detached",c.mesh.bind(C,F);var P=h.length/3,N=new Float32Array(D.skeletonWeightsByVertex),E=new Float32Array(D.skeletonInfluencesByVertex);if(N.length!==4*P)return this._result.success=!1,void(this._result.message="expected "+4*P+" skeleton weights for mesh "+c.name+", but got: "+N.length);if(E.length!==4*P)return this._result.success=!1,void(this._result.message="expected "+4*P+" skeleton influences for mesh "+c.name+", but got: "+E.length);u.addAttribute("skinWeight",new s.BufferAttribute(N,4)),u.addAttribute("skinIndex",new s.BufferAttribute(E,4))}else c.mesh=new s.Mesh(u,_),c.mesh.name=l.name;this._result.meshes.push(c)}this._result.success=!0},e.exports=l},{"../../ifr-core/FileTools":52,"../BasicFrame":58,"../BasicMesh":59,three:void 0}],64:[function(t,e,o){"use strict";var i=t("../BasicFrame"),n=t("../../ifr-core/FileTools"),r=t("three"),s=function(){this.url=null,this.success=!1,this.message="",this.skeletonRoot=null},a=function(){this._result=null};a.prototype.getResult=function(){return this._result},a.prototype.load=function(t,e){var o=this;n.loadJSON(t,function(i,n){if(null===i)o.parseData(n,t),e&&e();else{var r=new s;r.url=t,r.success=!1,r.message=i,o._result=r,e&&e()}})},a.prototype.parseData=function(t,e){return this._result=new s,this._result.url=e,"Skeleton"!==t.header.fileType?(this._result.success=!1,void(this._result.message="don't know how to handle file type: "+t.header.fileType)):(this._result.skeletonRoot=this._parseSkeleton(t.content),void(this._result.success=!0))},a.prototype._parseSkeleton=function(t){var e=new r.Object3D,o=(new i).setFromJson(t);if(e.name=o.name,e.position.copy(o.position),e.quaternion.copy(o.orientation),t.children)for(var n=0;n<t.children.length;n++)e.add(this._parseSkeleton(t.children[n]));return e},e.exports=a},{"../../ifr-core/FileTools":52,"../BasicFrame":58,three:void 0}],65:[function(t,e,o){"use strict";var i=t("../../ifr-core/SLog"),n="ACCEL_PLANNER",r=function(t,e,o,i,n,r,s){this._initialVelocity=t,this._targetVelocity=e,this._acceleration=o,this._accelerateTime=i,this._decelerateTime=n,this._totalTime=r,this._distance=s};r.prototype.displacementAtTime=function(t){var e=0;if(t>0){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;l<a.length;l++){for(var c=t.getTracks()[a[l]].clone(),u=c.getMotionData().timestampList,h=0;h<u.length;h++)u[h]=u[h]/r;c.length=c.length/r,s.addTrack(c)}o.motion=s;for(var p=[],d=0;d<e.length;d++){var m=e[d].getTimestamp()/r,f=e[d].getEventName(),g=e[d].getPayload();p.push(new n(m,f,g))}o.events=p}}};e.exports=r},{"./Motion":72,"./MotionEvent":73}],67:[function(t,e,o){"use strict";var i=t("./CyclicMath"),n=function(t){this._dofName=t};n.prototype.closestEquivalentRotation=function(t,e){return i.closestEquivalentRotation(e.get(this._dofName,0),t.get(this._dofName,0))},n.prototype.getDOFName=function(){return this._dofName},e.exports=n},{"./CyclicMath":68}],68:[function(t,e,o){"use strict";var i=function(){};i.closestEquivalentRotation=function(t,e){var o=e-t,i=Math.floor((o+Math.PI)/(2*Math.PI)),n=t+i*Math.PI*2;return n},e.exports=i},{}],69:[function(t,e,o){"use strict";var i=t("./CyclicDOFTargetSelector"),n=function(t,e){var o,n={},r={},s=t.getDOFNames(),a={},l=function(t,e){var o=a[t],i=a[e];return null!=o&&null!=i?o-i:0};for(o=0;o<s.length;o++){var c=0,u=t.getModelControlGroup().getControlForDOF(s[o]);if(null!=u&&("ROTATION"===u.getControlType()||"TRANSLATION"===u.getControlType())){var h=u.getTransformName(),p=t.getTransform(h);if(null!=p)for(;null!=p.parent;)c++,p=p.parent}a[s[o]]=c}for(o=0;o<s.length;o++){var d=s[o];t.getModelControlGroup().getDOFInfo(d).isCyclic()&&(e&&e.hasOwnProperty(d)?n[d]=e[d]:n[d]=new i(d),r[d]=new i(d))}this.sortDOFsByDepth=function(t){return t.sort(l)},this.getGlobalTargetSelector=function(t){return n[t]},this.getLocalTargetSelector=function(t){return r[t]},this.refineToGloballyClosestTargetPose=function(t,e,o){null==o&&(o=t.getDOFNames());for(var i=this.sortDOFsByDepth(o.slice(0)),n=0;n<i.length;n++){var r=this.getGlobalTargetSelector(i[n]);if(r){var s=r.closestEquivalentRotation(t,e);e.set(i[n],s,0)}}},this.refineToLocallyClosestTargetPose=function(t,e,o){null==o&&(o=t.getDOFNames());for(var i=0;i<o.length;i++){var n=this.getLocalTargetSelector(o[i]);if(n){var r=n.closestEquivalentRotation(t,e);e.set(o[i],r,0)}}}};e.exports=n},{"./CyclicDOFTargetSelector":67}],70:[function(t,e,o){"use strict";var i=t("./Interpolators"),n=t("../dofs/TextureControl"),r=t("../dofs/VisibilityControl"),s=function(){this.interpolatorSet={}};s.prototype.addInterpolator=function(t,e){this.interpolatorSet[t]=e},s.prototype.getInterpolator=function(t){var e=this.interpolatorSet[t];return void 0!==e?e:null},s.prototype.addModelControlGroup=function(t){for(var e=t.getControlList(),o=0;o<e.length;o++)for(var s=e[o],a=s.getDOFNames(),l=0;l<a.length;l++)s instanceof n||s instanceof r?this.addInterpolator(a[l],new i.DOFSampleInterpolator(new i.StepInterpolator)):this.addInterpolator(a[l],new i.DOFSampleInterpolator(new i.LinearInterpolator))},e.exports=s},{"../dofs/TextureControl":87,"../dofs/VisibilityControl":89,"./Interpolators":71}],71:[function(t,e,o){"use strict";var i={};i.BaseInterpolator=function(){},i.BaseInterpolator.prototype.interpolate=function(t,e,o){return t},i.StepInterpolator=function(t){i.BaseInterpolator.call(this),this.alphaThreshold=void 0!==t?t:1},i.StepInterpolator.prototype=Object.create(i.BaseInterpolator.prototype),i.StepInterpolator.prototype.constructor=i.StepInterpolator,i.StepInterpolator.prototype.interpolate=function(t,e,o){return o<this.alphaThreshold?t:e},i.LinearInterpolator=function(){i.BaseInterpolator.call(this)},i.LinearInterpolator.prototype=Object.create(i.BaseInterpolator.prototype),i.LinearInterpolator.prototype.constructor=i.LinearInterpolator,i.LinearInterpolator.prototype.interpolate=function(t,e,o){return(1-o)*t+o*e},i.DOFSampleInterpolator=function(t,e){i.BaseInterpolator.call(this),this.positionInterpolator=t,this.derivativeInterpolator=void 0!==e?e:new i.LinearInterpolator},i.DOFSampleInterpolator.prototype=Object.create(i.BaseInterpolator.prototype),i.DOFSampleInterpolator.prototype.constructor=i.DOFSampleInterpolator,i.DOFSampleInterpolator.prototype.interpolate=function(t,e,o){t instanceof Array||(t=[t]),e instanceof Array||(e=[e]);for(var i=[],n=Math.min(t.length,e.length),r=0;r<n;r++)0===r?i.push(this.positionInterpolator.interpolate(t[r],e[r],o)):i.push(this.derivativeInterpolator.interpolate(t[r],e[r],o));return i},e.exports=i},{}],72:[function(t,e,o){"use strict";var i=t("./Pose"),n=t("./MotionTrack"),r=t("./TimestampedBuffer"),s=function(t){this.name=t,this.length=0,this.tracks={}};s.prototype.getName=function(){return this.name},s.prototype.getDuration=function(){return this.length},s.prototype.getTracks=function(){return this.tracks},s.prototype.addTrack=function(t){this.tracks[t.getName()]=t,t.getLength()>this.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;r<n.length;r++){var s=n[r];if(this.tracks.hasOwnProperty(s)){var a=e.getInterpolator(s);if(null===a)throw new Error("no interpolator provided for DOF name: "+s);var l=this.tracks[s].getDataAtTime(t,a);null!==l&&o.set(s,l)}}return o},s.prototype.toString=function(){for(var t="Motion "+this.getName()+" length:"+this.getDuration(),e=this.getDOFs(),o=0;o<e.length;o++)t+="\n\t"+this.tracks[e[o]].toString();return t},s.createFromPose=function(t,e,o,i){var a=new s(t);null==i&&(i=e.getDOFNames());for(var l=0;l<i.length;l++){var c=i[l],u=e.get(c),h=new r;h.append(0,u),a.addTrack(new n(c,h,o))}return a},s.createFromPoses=function(t,e,o,i,a){var l=new s(t);null==a&&(a=e[0].getDOFNames());for(var c=0;c<a.length;c++){for(var u=a[c],h=new r,p=0;p<o.length;p++){var d=e[p].get(u);h.append(o[p],d)}l.addTrack(new n(u,h,i))}return l},e.exports=s},{"./MotionTrack":75,"./Pose":76,"./TimestampedBuffer":79}],73:[function(t,e,o){"use strict";var i=function(t,e,o){this.getTimestamp=function(){return t},this.getEventName=function(){return e},this.getPayload=function(){return o}};e.exports=i},{}],74:[function(t,e,o){"use strict";var i=function(t,e){t=t||[];var o=0,i=this;this.hasNext=function(i){for(;o<t.length&&t[o].getTimestamp()<e.getInPoint();)o++;var n=e.getSourceTime(i);return o<t.length&&t[o].getTimestamp()<=n},this.next=function(e){if(i.hasNext(e)){var n=t[o];return o++,n}return null},this.reset=function(){o=0}};e.exports=i},{}],75:[function(t,e,o){"use strict";var i=function(t,e,o){this.name=t,this.motionData=e,this.length=o};i.prototype.clone=function(){return new i(this.name,this.motionData.clone(),this.length)},i.prototype.getName=function(){return this.name},i.prototype.getLength=function(){return this.length},i.prototype.getMotionData=function(){return this.motionData},i.prototype.getDataAtTime=function(t,e){if(0===this.motionData.size())return null;var o=this.motionData.getLeftIndexForTime(t),i=o+1;o=Math.max(o,0),i=Math.min(i,this.motionData.size()-1);var n,r=this.motionData.getTimestamp(o),s=this.motionData.getTimestamp(i);n=r===s?0:(t-r)/(s-r);var a=this.motionData.getData(o),l=this.motionData.getData(i);return e.interpolate(a,l,n)},i.prototype.toString=function(){return"MotionTrack "+this.getName()+", length="+this.getLength()+", Data:"+this.motionData.toString()},e.exports=i},{}],76:[function(t,e,o){"use strict";var i=null,n=null,r=null,s=function(t){r=t.length,i={},n=new Array(r);for(var e=0;e<r;e++)i[t[e]]=e,n[e]=t[e]},a=function(t,e){return t-e},l=function(t,e){var o,s;if(null!==t.dofNames)throw new Error("Cannot re-setup pose with new dofnames!");if(null===i)throw new Error("Pose used before __globalSetup!");var l=e.length;for(t.dofIndices=new Array(l),t.dofPresent=new Array(r),t.dofVals=new Array(r),o=0;o<r;o++)t.dofPresent[o]=!1;for(s=0;s<l;s++){if(o=i[e[s]],"undefined"==typeof o)throw new Error("Cannot use DOF "+e[s]+", not in dofset!");t.dofIndices[s]=o,t.dofPresent[o]=!0,t.dofVals[o]=[]}for(t.dofIndices.sort(a),t.dofNames=new Array(l),s=0;s<l;s++)t.dofNames[s]=n[t.dofIndices[s]]},c=function(t,e){this.name=t,this.dofNames=null,this.dofIndices=null,this.dofPresent=null,this.dofVals=null,void 0!==e&&l(this,e)};c.prototype.setPose=function(t){null===this.dofNames&&l(this,t.dofNames);for(var e=0;e<this.dofIndices.length;e++){var o=this.dofIndices[e];if(t.dofPresent[o]){for(var i=t.dofVals[o],n=this.dofVals[o],r=0;r<i.length;r++)n[r]=i[r];n.length=i.length}}},c.prototype.setPose0Only=function(t){for(var e=0;e<this.dofIndices.length;e++){var o=this.dofIndices[e];if(t.dofPresent[o]){var i=t.dofVals[o],n=this.dofVals[o];i.length>0?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;t<this.dofIndices.length;t++)this.dofVals[this.dofIndices[t]].length=0},c.prototype.getCopy=function(t){for(var e=new c(null!=t?t:this.name),o=this.dofNames,i=this.dofIndices,n=this.dofPresent,s=o.length,a=new Array(s),l=new Array(s),u=new Array(r),h=0;h<s;h++)a[h]=o[h],l[h]=i[h];for(var p=0;p<r;p++)u[p]=n[p];e.dofNames=a,e.dofIndices=l,e.dofPresent=u,e.dofVals=new Array(s);for(var d=0;d<s;d++){for(var m=i[d],f=this.dofVals[m],g=new Array(f.length),_=0;_<f.length;_++)g[_]=f[_];e.dofVals[m]=g}return e},c.prototype.equals=function(t){var e,o;if(this.dofIndices.length!==t.dofIndices.length)return!1;for(e=0;e<this.dofIndices.length;e++){if(this.dofIndices[e]!==t.dofIndices[e])return!1;var i=this.dofIndices[e],n=this.dofVals[i],r=t.dofVals[i];if(n.length!==r.length)return!1;for(o=0;o<n.length;o++)if(n[o]!==r[o])return!1}return!0},c.prototype.equals0Only=function(t){var e;if(this.dofIndices.length!==t.dofIndices.length)return!1;for(e=0;e<this.dofIndices.length;e++){if(this.dofIndices[e]!==t.dofIndices[e])return!1;var o=this.dofIndices[e],i=this.dofVals[o],n=t.dofVals[o];if(i.length>0&&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;e<this.dofIndices.length;e++){var i=this.dofIndices[e];if(t.dofPresent[i]){var n=this.dofVals[i],r=t.dofVals[i];if(n.length!==r.length)return!1;for(o=0;o<r.length;o++)if(n[o]!==r[o])return!1}}return!0},c.prototype.equalsNoChange0Only=function(t){var e;for(e=0;e<this.dofIndices.length;e++){var o=this.dofIndices[e];if(t.dofPresent[o]){var i=this.dofVals[o],n=t.dofVals[o];if(i.length>0&&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;u<r;u++)t.dofPresent[u]&&e.dofPresent[u]&&h.push(n[u]);l(s,h)}for(a=0;a<s.dofIndices.length;a++)u=s.dofIndices[a],t.dofPresent[u]&&e.dofPresent[u]?s.dofVals[u]=o(s.dofNames[a],t.dofVals[u],e.dofVals[u]):i&&(s.dofVals[u].length=0);return s},c.computeUnary=function(t,e,o,i){var n,r;for(null!=i&&null!=i.dofNames||(null==i?i=new c(t.getName(),t.dofNames):l(i,t.dofNames)),n=0;n<i.dofIndices.length;n++)r=i.dofIndices[n],t.dofPresent[r]?i.dofVals[r]=e(i.dofNames[n],t.dofVals[r]):o&&(i.dofVals[r].length=0);return i},c._subtractOperator=function(t,e,o){var i=[],n=e.length>0?e[0]:0,r=o.length>0?o[0]:0;i[0]=n-r;for(var s=1;s<e.length&&s<o.length;)i.push(e[s]-o[s]),s++;return i},c._additionOperator=function(t,e,o){var i=[],n=e.length>0?e[0]:0,r=o.length>0?o[0]:0;i[0]=n+r;for(var s=1;s<e.length&&s<o.length;)i.push(e[s]+o[s]),s++;return i},c._advanceByVelocityOperator=function(t,e,o){var i=[];if(e.length>0){null==o&&(o=1);var n=0;e.length>=2&&(n=e[1]),i[0]=n*o+e[0];for(var r=1;r<e.length;r++)i.push(e[r])}return i},c.subtract=function(t,e,o,i){return c.computeBinary(t,e,c._subtractOperator,o,i)},c.add=function(t,e,o,i){return c.computeBinary(t,e,c._additionOperator,o,i)},c.advanceByTime=function(t,e,o,i){return null==i?c.computeUnary(t,c._advanceByVelocityOperator,e,o):c.computeUnary(t,function(t,e){return c._advanceByVelocityOperator(t,e,i)},e,o)},c.prototype.toString=function(){for(var t="Pose{",e=0;e<this.dofNames.length;e++)t+=this.dofNames[e]+":["+this.dofVals[this.dofIndices[e]].toString()+"]",e<this.dofNames.length-1&&(t+=",");return t+"}"},c.__globalSetup=s,e.exports=c},{}],77:[function(t,e,o){"use strict";var i=function(t,e,o){if(e<t)throw new Error("RelativeTimeClip: out point "+e+" is less than in point "+t);if(o<0)throw new Error("RelativeTimeClip: speed is negative: "+o);this.getInPoint=function(){return t},this.getOutPoint=function(){return e},this.getSpeed=function(){return o},this.getDuration=function(){if(0===o)return Number.MAX_VALUE;var i=e-t;return i/o},this.getSourceTime=function(i){i<0&&(i=0);var n=i*o+t;return n>e&&(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;i<this._alignedParents.length;i++){var r=t.get(this._alignedParents[i],0),s=e.get(this._alignedParents[i],0),a=s-r;o+=this._parentDirections[i]*a}var l=e.get(this.getDOFName(),0),c=t.get(this.getDOFName(),0),u=c-o;return n.closestEquivalentRotation(l,u)},e.exports=r},{"./CyclicDOFTargetSelector":67,"./CyclicMath":68}],79:[function(t,e,o){"use strict";var i=function(){this.timestampList=[],this.dataList=[],this._lastReturnedLeftIndex=0};i.prototype.clone=function(){var t=new i;return t.timestampList=this.timestampList.slice(0),t.dataList=this.dataList.slice(0),t._lastReturnedLeftIndex=this._lastReturnedLeftIndex,t},i.prototype.size=function(){return this.timestampList.length},i.prototype.getStartTime=function(){return this.timestampList[0]},i.prototype.getEndTime=function(){return this.timestampList[this.timestampList.length-1]},i.prototype.append=function(t,e){if(this.size()>0&&t<this.getEndTime())throw new Error("new timestamp "+t+" is out of sequence with previous timestamp "+this.getEndTime());this.timestampList.push(t),this.dataList.push(e)},i.prototype.getTimestamp=function(t){return this.timestampList[t]},i.prototype.getData=function(t){return this.dataList[t]},i.prototype.remove=function(t){return this.timestampList.splice(t,1),this.dataList.splice(t,1)[0]},i.prototype.getDataForTime=function(t){var e=this.getLeftIndexForTime(t);return e>-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&&a<this.size()){var l=this.getTimestamp(a),c=l>t||l===t&&e,u=l<o||l===o&&i;c&&u&&(null===n&&(n=[]),n.push(this.getData(a)))}return n},i.prototype.insert=function(t,e){var o=this.getLeftIndexForTime(t);if(o>=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.getStartTime())return-1;if(t>=this.getEndTime())return this.size()-1;if(this._lastReturnedLeftIndex<this.size()-1&&this.timestampList[this._lastReturnedLeftIndex]<=t&&this.timestampList[this._lastReturnedLeftIndex+1]>t)return this._lastReturnedLeftIndex;if(this._lastReturnedLeftIndex++,this._lastReturnedLeftIndex<this.size()-1&&this.timestampList[this._lastReturnedLeftIndex]<=t&&this.timestampList[this._lastReturnedLeftIndex+1]>t)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;o<this.timestampList.length;o++)t+=e+this.timestampList[o]+":"+this.dataList[o],e=", ";return t},e.exports=i},{}],80:[function(t,e,o){"use strict";function i(t,e,o,i){for(var n=0;n<this._meshes.length;n++)this._billboardMode?this._meshes[n].material.emissive.setRGB(t,e,o):this._meshes[n].material.color.setRGB(t,e,o),void 0!==i&&(this._meshes[n].material.opacity=i)}var n=t("./ModelControl"),r=t("./ModelControlFactory"),s=t("three"),a=function(){n.call(this),this._meshNames=null,this._ledNames=null,this._meshes=[],this._billboardMode=!0};a.prototype=Object.create(n.prototype),a.prototype.constructor=a,a.prototype._controlType="COLOR",a.prototype.setFromJson=function(t){n.prototype.setFromJson.call(this,t),this._dofNames.push(t.redDOFName),this._dofNames.push(t.greenDOFName),this._dofNames.push(t.blueDOFName),t.alphaDOFName&&this._dofNames.push(t.alphaDOFName),this._meshNames=t.meshNames,t.ledNames&&(this._ledNames=t.ledNames)},a.prototype.attachToModel=function(t){if(this._meshes.length=0,null==t)return!1;for(var e=0;e<this._meshNames.length;e++){if(!t.hasOwnProperty(this._meshNames[e]))return!1;this._meshes.push(t[this._meshNames[e]])}return!0},a.prototype.setBillboardMode=function(t){if(t!==this._billboardMode){if(this._meshes.length>0){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;i<this._meshes.length;i++)this._meshes[i].material.emissive.copy(o),this._meshes[i].material.color.copy(e)}this._billboardMode=t}},a.prototype.updateFromDOFValues=function(t){var e,o=[];for(e=0;e<this._dofNames.length;e++){if(!t.hasOwnProperty(this._dofNames[e]))return!1;o.push(t[this._dofNames[e]])}return this._meshes.length>0&&(i.call(this,o[0],o[1],o[2],o[3]),!0)},a.prototype.updateFromPose=function(t){var e,o=[];for(e=0;e<this._dofNames.length;e++){var n=t.get(this._dofNames[e],0);if(null==n)return!1;o.push(n)}return this._meshes.length>0&&(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;o<e.length;o++)this._limitData[e[o]]=t[e[o]]},i.prototype.getLimit=function(t){return this._limitData[t]},e.exports=i},{}],82:[function(t,e,o){"use strict";var i=t("../base/Pose"),n=function(t){t.quaternion.onChange(function(){}),t._nodeDirtyToKG=!0;for(var e=0;e<t.children.length;e++)n(t.children[e])},r=function(t,e){this._modelControlGroup=t,this._hierarchyRoot=e,this._modelMap=null,this._lastPose=new i("KG Last Pose",t.getDOFNames()),n(this._hierarchyRoot),this._assumeKGHasSoleHierarcyControl=!0},s=function(t,e){for(var o=t.clone(void 0,!1),i=0;i<t.children.length;i++){var n=t.children[i];null!=n.name&&e[n.name]&&o.add(s(n,e))}return o},a=function(t,e){null==e&&(e="");for(var o=e+t.name,i=0;i<t.children.length;i++)o+="\n"+a(t.children[i],e+"\t");return o};r.prototype.getCopy=function(t,e){var o;if(null!=t&&null!=this._hierarchyRoot){for(var i={},n=this.getModelMap(),a=0;a<t.length;a++)for(var l=n[t[a]];null!=l;)i.hasOwnProperty(l.name)?l=null:(i[l.name]=!0,l=l.parent);i[this._hierarchyRoot.name]?o=s(this._hierarchyRoot,i):(console.log("Warning, none of required dofs ("+(null==t?"null":t.toString())+")present in hierarchy!"),o=null)}else o=this._hierarchyRoot?this._hierarchyRoot.clone():null;var c=this._modelControlGroup?this._modelControlGroup.getCopy():null;return c.attachToModelAndPrune(o),new r(c,o)},r.prototype.getPose=function(t){},r.prototype.setFromPose=function(t){this._assumeKGHasSoleHierarcyControl&&this._lastPose.equalsNoChange0Only(t)||(this._modelControlGroup.updateFromPose(t),this._lastPose.setPose(t))},r.prototype.updateWorldCoordinateFrames=function(){var t,e,o=this._hierarchyRoot,i=!1;for(o._nodeDirtyToKG&&(o.updateMatrix(),o._nodeDirtyToKG=!1,o.matrixWorld.copy(o.matrix),i=!0),e=o.children.length,t=0;t<e;t++)this._updateWorldCoordinateFramesRecurse(o.children[t],i)},r.prototype._updateWorldCoordinateFramesRecurse=function(t,e){var o,i;for(t._nodeDirtyToKG&&(t.updateMatrix(),t._nodeDirtyToKG=!1,e=!0),e&&t.matrixWorld.multiplyMatrices(t.parent.matrixWorld,t.matrix),i=t.children.length,o=0;o<i;o++)this._updateWorldCoordinateFramesRecurse(t.children[o],e)},r.prototype.getDOFNames=function(){return this._modelControlGroup.getDOFNames()},r.prototype.getModelControlGroup=function(){return this._modelControlGroup},r.prototype.getRoot=function(){return this._hierarchyRoot;
},r.generateTransformMap=function(t){for(var e={},o=[t];o.length>0;){var i=o.shift();if(i.name&&(e[i.name]=i),i.children)for(var n=0;n<i.children.length;n++)o.push(i.children[n])}return e},r.prototype.getModelMap=function(){return this._modelMap||(this._modelMap=r.generateTransformMap(this._hierarchyRoot)),this._modelMap},r.prototype.getTransform=function(t){return this._modelMap||(this._modelMap=r.generateTransformMap(this._hierarchyRoot)),this._modelMap[t]},r.prototype.toString=function(){return"KinematicGroup:\n\tDOFs:"+this.getDOFNames()+"\n\tTree:\n"+a(this._hierarchyRoot,"\t\t")+"\n\tNumControls:"+this._modelControlGroup.getControlList().length},e.exports=r},{"../base/Pose":76}],83:[function(t,e,o){"use strict";var i=function(){this._controlNames=[],this._dofNames=[]};i.prototype._controlType=null,i.prototype.setFromJson=function(t){t.controlName&&this._controlNames.push(t.controlName)},i.prototype.getControlType=function(){return this._controlType},i.prototype.getControlNames=function(){return this._controlNames},i.prototype.getDOFNames=function(){return this._dofNames},i.prototype.getTransformNames=function(){return null},i.prototype.getDescriptiveName=function(){if(0===this._controlNames.length)return null;if(1===this._controlNames.length)return this._controlNames[0];for(var t=this._controlNames[0],e=1;e<this._controlNames.length;e++)t=t+", "+this._controlNames[e];return"MultiControl<"+t+">"},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;e<this._controlList.length;e++)for(var o=this._controlList[e],i=o.getDOFNames(),r=0;r<i.length;r++)this._dofNames.push(i[r]),this._dofNameToControlMap[i[r]]=o,this._dofInfos[i[r]]=new n(i[r],o);for(e=0;e<this._controlList.length;e++)this._controlList[e].attachToControlGroup(this)},r.prototype.getControlList=function(){return this._controlList},r.prototype.getDOFNames=function(){return this._dofNames},r.prototype.getControlForDOF=function(t){return this._dofNameToControlMap[t]},r.prototype.getDOFInfo=function(t){return this._dofInfos[t]},r.prototype.attachToModel=function(t){for(var e=i.generateTransformMap(t),o=!0,n=0;n<this._controlList.length;n++){var r=this._controlList[n].attachToModel(e);r||(o=!1,console.warn("failed to attach model control: "+this._controlList[n].getDescriptiveName()))}return o},r.prototype.attachToModelAndPrune=function(t){var e=i.generateTransformMap(t);this.setControlList(this._controlList.filter(function(t){return t.attachToModel(e)}))},r.prototype.updateFromDOFValues=function(t){for(var e=!0,o=0;o<this._controlList.length;o++){var i=this._controlList[o].updateFromDOFValues(t);i||(e=!1)}return e},r.prototype.updateFromPose=function(t){for(var e=!0,o=0;o<this._controlList.length;o++){var i=this._controlList[o].updateFromPose(t);i||(e=!1)}return e},r.prototype.getRequiredTransformNamesForDOFs=function(t){if(null===t)return null;for(var e=[],o=0;o<t.length;o++){var i=this.getControlForDOF(t[o]),n=i.getTransformNames();if(null!=n)for(var r=0;r<n.length;r++)e.push(n[r])}return e},r.prototype.getPose=function(t){},r.prototype.getCopy=function(){if(null==this._controlList)return new r;for(var t=[this._controlList.length],e=0;e<this._controlList.length;e++)t[e]=this._controlList[e].getCopy(null);var o=new r;return o.setControlList(t),o},e.exports=r},{"./DOFInfo":81,"./KinematicGroup":82}],86:[function(t,e,o){"use strict";function i(t){if(t!==this._lastValue){this._lastValue=t;var e=(new a.Quaternion).setFromAxisAngle(this._rotationalAxis,t);this._skeletonFrame.quaternion.multiplyQuaternions(this._initialRotation,e),this._skeletonFrame._nodeDirtyToKG=!0}}var n=t("./ModelControl"),r=t("./ModelControlFactory"),s=t("../../ifr-geometry/BasicFrame"),a=t("three"),l=function(){n.call(this),this._skeletonFrameName=null,this._rotationalAxis=new a.Vector3,this._initialRotation=new a.Quaternion,this._min=null,this._max=null,this._isCyclic=!1,this._skeletonFrame=null,this._lastValue=null};l.prototype=Object.create(n.prototype),l.prototype.constructor=l,l.prototype._controlType="ROTATION",l.prototype.setFromJson=function(t){n.prototype.setFromJson.call(this,t),this._dofNames.push(t.dofName),this._skeletonFrameName=t.skeletonFrameName,this._rotationalAxis.copy(s.vector3FromJson(t.xyzRotationAxis)),this._initialRotation.copy(s.quaternionFromJson(t.wxyzQuatInitialRotation)),this._min=t.min,this._max=t.max,this._isCyclic=t.isCyclic|!1},l.prototype.attachToModel=function(t){return this._skeletonFrame=null,!(null==t||!t.hasOwnProperty(this._skeletonFrameName))&&(this._skeletonFrame=t[this._skeletonFrameName],!0)},l.prototype.updateFromDOFValues=function(t){if(this._skeletonFrame&&t.hasOwnProperty(this._dofNames[0])){var e=t[this._dofNames[0]];return i.call(this,e),!0}return!1},l.prototype.updateFromPose=function(t){var e=t.get(this._dofNames[0],0);return!(!this._skeletonFrame||null==e)&&(i.call(this,e),!0)},l.prototype.getRotationalAxis=function(t){return null==t&&(t=new a.Vector3),t.copy(this._rotationalAxis)},l.prototype.getInitialRotation=function(t){return null==t&&(t=new a.Quaternion),t.copy(this._initialRotation)},l.prototype.getMin=function(){return this._min},l.prototype.getMax=function(){return this._max},l.prototype.isCyclic=function(){return this._isCyclic},l.prototype.getCopy=function(t){return t||(t=new l),n.prototype.getCopy.call(this,t),t._skeletonFrameName=this._skeletonFrameName,t._rotationalAxis=this._rotationalAxis?this._rotationalAxis.clone():null,t._initialRotation=this._initialRotation?this._initialRotation.clone():null,t._min=this._min,t._max=this._max,t._isCyclic=this._isCyclic,t},l.prototype.getTransformName=function(){return this._skeletonFrameName},l.prototype.getTransformNames=function(){return[this.getTransformName()]},l.Factory=function(){},l.Factory.prototype=Object.create(r.prototype),l.Factory.prototype.constructor=l.Factory,l.Factory.prototype._controlType=l.prototype._controlType,l.Factory.prototype._controlConstructor=l,e.exports=l},{"../../ifr-geometry/BasicFrame":58,"./ModelControl":83,"./ModelControlFactory":84,three:void 0}],87:[function(t,e,o){"use strict";function i(){null==this._mesh.material._specular_disabled&&(this._mesh.material._specular_disabled=new c.Color(this._mesh.material.specular)),this._billboardMode?(this._mesh.material.ambient.setRGB(0,0,0),this._mesh.material.specular.setRGB(0,0,0)):(this._mesh.material.ambient.setRGB(1,1,1),this._mesh.material.specular.set(this._mesh.material._specular_disabled))}function n(t){null!==this._colorControl&&this._colorControl.setBillboardMode(t),t!==this._billboardMode&&(null!==this._mesh&&(t?(this._mesh.material.ambient.setRGB(0,0,0),this._mesh.material.specular.setRGB(0,0,0)):(this._mesh.material.ambient.setRGB(1,1,1),this._mesh.material.specular.set(this._mesh.material._specular_disabled))),this._billboardMode=t)}function r(t){if("string"==typeof t)return n.call(this,!0),this.setTextureFromURL(t),!0;if("object"!=typeof t)return"number"==typeof t&&(u.error("TextureControl for DOF "+this._dofNames[0]+": numerical values (image indices) are no longer supported, use full image URL instead"),!1);var e=t.textureURL,o=t.useNormals,i=t.normalURL;null==o&&(o=null!=i),o===!0&&null==i&&(i=this._defaultNormalURL),o===!0&&this.setNormalFromURL(i),n.call(this,!o),null==e?u.error("Value for DOF "+this._dofNames[0]+' is object, but did not contain field "textureURL"'):this.setTextureFromURL(e)}var s=t("./ModelControl"),a=t("./ModelControlFactory"),l=t("../../ifr-geometry/loaders/CachedImageLoader"),c=t("three"),u=t("../../ifr-core/SLog"),h=function(){s.call(this),this._meshName=null,this._mesh=null,this._texture=new c.Texture,this._texture.minFilter=c.LinearFilter,this._normal=new c.Texture,this._blankTexture=new c.DataTexture(new Uint8Array(16),2,2),this._blankTexture.minFilter=c.LinearFilter,this._imageLoader=null,this._defaultNormalURL=null,this._colorControl=null,this._billboardMode=!0};h.prototype=Object.create(s.prototype),h.prototype.constructor=h,h.prototype._controlType="TEXTURE",h.prototype.setFromJson=function(t){s.prototype.setFromJson.call(this,t),this._dofNames.push(t.dofName),this._meshName=t.meshName},h.prototype.setImageLoader=function(t){this._imageLoader=t},h.prototype.setDefaultNormalURL=function(t){this._defaultNormalURL=t},h.prototype.attachToModel=function(t){return this._mesh=null,!(null==t||!t.hasOwnProperty(this._meshName))&&(this._mesh=t[this._meshName],i.call(this),!0)},s.prototype.attachToControlGroup=function(t){var e=t.getControlList();this._colorControl=null;for(var o=0;o<e.length;o++){if("COLOR"===e[o].getControlType())for(var i=e[o]._meshNames,n=0;n<i.length;n++)if(i[n]===this._meshName){this._colorControl=e[o];break}if(null!==this._colorControl)break}},h.prototype.updateFromDOFValues=function(t){if(this._mesh&&t.hasOwnProperty(this._dofNames[0])){var e=t[this._dofNames[0]];return r.call(this,e)}return!1},h.prototype.updateFromPose=function(t){var e=t.get(this._dofNames[0],0);return!(!this._mesh||null==e)&&r.call(this,e)},h.prototype.setTextureFromURL=function(t){if(this._mesh&&this._texture.sourceFile!==t){this._texture.sourceFile=t,this._blankTexture.needsUpdate=!0,this._mesh.material.map=this._blankTexture;var e=this;this._imageLoader.loadImage(t,function(){var t=e._imageLoader.getResult();t.success&&t.url===e._texture.sourceFile?(e._texture.image=t.image,e._texture.needsUpdate=!0,e._mesh.material.map=e._texture):t.success||u.error("TextureControl for DOF "+e._dofNames[0]+": image load failed, URL = "+t.url)})}},h.prototype.setNormalFromURL=function(t){if(this._mesh&&this._normal.sourceFile!==t){this._normal.sourceFile=t;var e=this;this._imageLoader.loadImage(t,function(){var t=e._imageLoader.getResult();t.success&&t.url===e._normal.sourceFile?(e._normal.image=t.image,e._normal.needsUpdate=!0,null==e._mesh.material.normalMap&&(e._mesh.material.needsUpdate=!0),e._mesh.material.normalMap=e._normal):t.success||u.error("TextureControl for DOF "+e._dofNames[0]+": normal load failed, URL = "+t.url)})}},h.prototype.getCopy=function(t){return t||(t=new h),s.prototype.getCopy.call(this,t),t._meshName=this._meshName,t._texture=this._texture?this._texture.clone():null,t._imageLoader=this._imageLoader,t._defaultNormalURL=this._defaultNormalURL,t},h.Factory=function(){this._sharedImageLoader=new l},h.Factory.prototype=Object.create(a.prototype),h.Factory.prototype.constructor=h.Factory,h.Factory.prototype._controlType=h.prototype._controlType,h.Factory.prototype._controlConstructor=h,h.Factory.prototype.setSharedImageLoader=function(t){this._sharedImageLoader=t},h.Factory.prototype.constructFromJson=function(t){var e=a.prototype.constructFromJson.call(this,t);return e&&e.setImageLoader(this._sharedImageLoader),e},e.exports=h},{"../../ifr-core/SLog":55,"../../ifr-geometry/loaders/CachedImageLoader":62,"./ModelControl":83,"./ModelControlFactory":84,three:void 0}],88:[function(t,e,o){"use strict";function i(t,e){for(var o=!0,i=0;i<t.length;i++)t[i]!==this._lastValue[i]&&(this._lastValue[i]=t[i],o=!1);if(!o||e){for(var n=(new a.Vector3).copy(this._initialPosition),r=new a.Vector3,s=0;s<t.length;s++){var l=a.Math.clamp(t[s],this._minList[s],this._maxList[s]);r.copy(this._translationalDirectionList[s]).multiplyScalar(l),n.add(r)}return n}return null}var n=t("./ModelControl"),r=t("./ModelControlFactory"),s=t("../../ifr-geometry/BasicFrame"),a=t("three"),l=function(){n.call(this),this._skeletonFrameName=null,this._initialPosition=new a.Vector3,this._translationalDirectionList=[],this._minList=[],this._maxList=[],this._skeletonFrame=null,this._lastValue=[]};l.prototype=Object.create(n.prototype),l.prototype.constructor=l,l.prototype._controlType="TRANSLATION",l.prototype.setFromJson=function(t){n.prototype.setFromJson.call(this,t),this._dofNames.push(t.dofName),this._skeletonFrameName=t.skeletonFrameName,this._initialPosition.copy(s.vector3FromJson(t.xyzInitialPosition)),this._translationalDirectionList.push(s.vector3FromJson(t.xyzTranslationDirection)),this._minList.push(t.min),this._maxList.push(t.max)},l.prototype.appendControl=function(t){this._controlNames=this._controlNames.concat(t._controlNames),this._dofNames=this._dofNames.concat(t._dofNames),this._translationalDirectionList=this._translationalDirectionList.concat(t._translationalDirectionList),this._minList=this._minList.concat(t._minList),this._maxList=this._maxList.concat(t._maxList)},l.prototype.attachToModel=function(t){return this._skeletonFrame=null,!(null==t||!t.hasOwnProperty(this._skeletonFrameName))&&(this._skeletonFrame=t[this._skeletonFrameName],!0)},l.prototype.computeFromDOFValues=function(t,e){for(var o=[],n=0;n<this._dofNames.length;n++){if(!t.hasOwnProperty(this._dofNames[n]))return null;o.push(t[this._dofNames[n]])}return i.call(this,o,e)},l.prototype.updateFromDOFValues=function(t){var e=this.computeFromDOFValues(t);return null!=e&&null!=this._skeletonFrame&&(this._skeletonFrame.position.copy(e),this._skeletonFrame._nodeDirtyToKG=!0,!0)},l.prototype.computeFromPose=function(t){for(var e=[],o=0;o<this._dofNames.length;o++){var n=t.get(this._dofNames[o],0);if(null==n)return null;e.push(n)}return i.call(this,e)},l.prototype.updateFromPose=function(t){var e=this.computeFromPose(t);return null!=e&&null!=this._skeletonFrame&&(this._skeletonFrame.position.copy(e),this._skeletonFrame._nodeDirtyToKG=!0,!0)},l.prototype.getCopy=function(t){if(t||(t=new l),n.prototype.getCopy.call(this,t),t._skeletonFrameName=this._skeletonFrameName,t._initialPosition=this._initialPosition?this._initialPosition.clone():null,t._translationalDirectionList=this._translationalDirectionList?this._translationalDirectionList.slice(0):null,t._translationalDirectionList)for(var e=0;e<t._translationalDirectionList.length;e++)t[e]=t[e]?t[e].clone():null;return t._minList=this._minList?this._minList.slice(0):this._minList,t._maxList=this._maxList?this._maxList.slice(0):this._maxList,t},l.prototype.getTransformName=function(){return this._skeletonFrameName},l.prototype.getTransformNames=function(){return[this.getTransformName()]},l.Factory=function(){},l.Factory.prototype=Object.create(r.prototype),l.Factory.prototype.constructor=l.Factory,l.Factory.prototype._controlType=l.prototype._controlType,l.Factory.prototype._controlConstructor=l,l.Factory.prototype.postProcessControlList=function(t){for(var e={},o=[],i=0;i<t.length;i++){var n=t[i];if(n instanceof l)if(e.hasOwnProperty(n._skeletonFrameName)){var r=e[n._skeletonFrameName];r.appendControl(n)}else e[n._skeletonFrameName]=n,o.push(n);else o.push(n)}return o},e.exports=l},{"../../ifr-geometry/BasicFrame":58,"./ModelControl":83,"./ModelControlFactory":84,three:void 0}],89:[function(t,e,o){"use strict";function i(t){if(t!==this._lastValue){if(this._lastValue=t,"number"==typeof t){for(var e=0;e<this._meshes.length;e++)this._meshes[e].visible=0!==t;return!0}return s.error("VisibilityControl for DOF "+this._dofNames[0]+": expected numerical value, but got: "+t),!1}}var n=t("./ModelControl"),r=t("./ModelControlFactory"),s=t("../../ifr-core/SLog"),a=function(){n.call(this),this._meshNames=null,this._meshes=[],this._lastValue=null};a.prototype=Object.create(n.prototype),a.prototype.constructor=a,a.prototype._controlType="VISIBILITY",a.prototype.setFromJson=function(t){n.prototype.setFromJson.call(this,t),this._dofNames.push(t.dofName),this._meshNames=t.meshNames},a.prototype.attachToModel=function(t){if(this._meshes.length=0,null==t)return!1;for(var e=0;e<this._meshNames.length;e++){if(!t.hasOwnProperty(this._meshNames[e]))return!1;this._meshes.push(t[this._meshNames[e]])}return!0},a.prototype.updateFromDOFValues=function(t){if(this._meshes.length>0&&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;h<o.channels.length;h++){var m=o.channels[h],f=new i;f.timestampList=m.times,f.dataList=m.values;var g=new n(m.dofName,f,m.length);a.addTrack(g)}if(this._result.motion=a,o.defaultDOFs&&(this._result.defaultDOFNames=o.defaultDOFs),o.enumMaps){this._result.enumMaps={};for(var _=0;_<o.enumMaps.length;_++){var y=o.enumMaps[_];this._result.enumMaps[y.dofName]=y.values}this.flattenEnums&&p(this._result.motion,this._result.enumMaps)}if(this.resolvePaths&&d(this._result.motion,e),o.events){this._result.events=[];for(var v=0;v<o.events.length;v++){var T=o.events[v];if(void 0===T.time||null===T.time)l(c,"AnimationLoader: skipping event with null or undefined time property");else if(T.time<0||T.time>a.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;n<i.length;n++){var r=i[n];if(e.hasOwnProperty(r))for(var s=o[r].getMotionData().dataList,a=e[r],u=0;u<s.length;u++){var h=s[u];if(h instanceof Array&&(h=h[0]),"number"==typeof h){var p=Math.round(h);s[u]=[a[p]],a.hasOwnProperty(p)||l(c,"AnimationLoader: no enum value specified for key: "+p+", DOF = "+r)}else l(c,"AnimationLoader: DOF "+r+" has an enum map, but found non-numerical value: "+h)}}},d=function(t,e){var o="",i=e.lastIndexOf("/"),n=e.lastIndexOf("\\");if(i!==-1||n!==-1){var r=Math.max(i,n);o=e.substring(0,r+1)}for(var s=t.getTracks(),a=Object.keys(s),u=0;u<a.length;u++){var h=a[u],p=s[h].getMotionData().dataList,d=[],m=p[0];if(m instanceof Array&&(m=m[0]),"string"==typeof m||"object"==typeof m)for(var f=0;f<p.length;f++){var g=p[f];g instanceof Array&&(g=g[0]),"string"==typeof g?p[f]=[o+g]:"object"==typeof g?d.indexOf(g)<0&&("string"==typeof g.textureURL?(g.textureURL=o+g.textureURL,"string"==typeof g.normalURL&&(g.normalURL=o+g.normalURL),d.push(g)):l(c,"AnimationLoader: DOF "+h+" had object-valued samples, but at least one ("+f+') is missing "textureURL" field')):l(c,"AnimationLoader: DOF "+h+" had string-valued samples, but also found non-string value: "+g)}}};e.exports=h},{"../../ifr-core/FileTools":52,"../../ifr-core/SLog":55,"../base/Motion":72,"../base/MotionEvent":73,"../base/MotionTrack":75,"../base/TimestampedBuffer":79}],95:[function(t,e,o){"use strict";var i=t("../dofs/ModelControlGroup"),n=t("../dofs/RotationControl"),r=t("../dofs/TranslationControl"),s=t("../dofs/TextureControl"),a=t("../dofs/ColorControl"),l=t("../dofs/VisibilityControl"),c=t("../../ifr-core/FileTools"),u=function(){this.url=null,this.success=!1,this.message="",this.modelControlGroup=null},h=function(){this._result=null,this._modelControlFactoryMap={},this.addModelControlFactory(new n.Factory),this.addModelControlFactory(new r.Factory),this.addModelControlFactory(new s.Factory),this.addModelControlFactory(new a.Factory),this.addModelControlFactory(new l.Factory)};h.prototype.addModelControlFactory=function(t){this._modelControlFactoryMap[t.getControlType()]=t},h.prototype.getModelControlFactory=function(t){return this._modelControlFactoryMap[t]},h.prototype.getResult=function(){return this._result},h.prototype.load=function(t,e){var o=this;c.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,"Kinematics"!==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=[],n=0;n<t.content.controls.length;n++){var r=t.content.controls[n];if(!this._modelControlFactoryMap.hasOwnProperty(r.controlType))return this._result.success=!1,void(this._result.message="no factory installed for control type: "+r.controlType+", control name = "+r.controlName);var s=this._modelControlFactoryMap[r.controlType],a=s.constructFromJson(r);if(null===a)return this._result.success=!1,void(this._result.message="factory construction failed, control type = "+r.controlType+", control name = "+r.controlName);o.push(a)}for(var l=Object.keys(this._modelControlFactoryMap),c=0;c<l.length;c++)o=this._modelControlFactoryMap[l[c]].postProcessControlList(o);this._result.modelControlGroup=new i,this._result.modelControlGroup.setControlList(o),this._result.success=!0},e.exports=h},{"../../ifr-core/FileTools":52,"../dofs/ColorControl":80,"../dofs/ModelControlGroup":85,"../dofs/RotationControl":86,"../dofs/TextureControl":87,"../dofs/TranslationControl":88,"../dofs/VisibilityControl":89}],96:[function(t,e,o){"use strict";var i=t("../../ifr-core/FileTools"),n=t("../../ifr-core/SLog"),r="MODEL_LOADING",s=function(){this.url=null,this.success=!1,this.message="",this.dofLimits=null},a=function(){this._result=null};a.prototype.getResult=function(){return this._result},a.prototype.load=function(t,e){var o=this;i.loadJSON(t,function(i,n){if(null===i)o.parseData(n,t),e&&e();else{var r=new s;r.url=t,r.success=!1,r.message=i,o._result=r,e&&e()}})},a.prototype.parseData=function(t,e){if(this._result=new s,this._result.url=e,"Limits"!==t.header.fileType)return this._result.success=!1,void(this._result.message="don't know how to handle file type: "+t.header.fileType);var o={},i=t.content.dofLimits;if(i)for(var a=0;a<i.length;a++){var l=i[a].dofName,c=i[a].limits;void 0===l||null===l?n(r,"LimitsLoader: skipping limit data with null or undefined dofName property"):void 0===c||null===c?n(r,"LimitsLoader: skipping limit data with null or undefined limits property"):o[l]=c}this._result.dofLimits=o,this._result.success=!0},e.exports=a},{"../../ifr-core/FileTools":52,"../../ifr-core/SLog":55}],97:[function(t,e,o){"use strict";var i=t("../../ifr-core/SLog"),n=t("../base/Pose"),r=t("../base/CyclicMath"),s=function(t,e,o){var s=!1,a=t.getDOFs(),l=null;if(1!==a.length)throw new Error("DiskStablizationTracker designed for simple 1 dof disk nodes only!");l=a[0];var c=new n(t.getName()+" DST Delta",a),u=0;this.computeStabilizationDelta=function(t,e,i){u=r.closestEquivalentRotation(u,0);for(var n=0,h=0;h<o.length;h++)n+=t.get(o[h],0);if(n=r.closestEquivalentRotation(n,u),s){var p=n-u;c.set(l,-p,0)}else{c.clear();for(var d=0;d<a.length;d++)c.set(a[d],0,0)}return u=n,s=!0,c},this.decomposeVelocity=function(t,e,n,r){var s;null==r&&(r=0);var a=0;for(s=0;s<o.length;s++)a+=t.get(o[s],1);0!==r&&Math.abs(a)>r&&(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<e.length;o++){var n=e[o].getRequiredTransforms(t);null!==n&&(i=i.concat(n))}for(this._kinematicGroup=t.getCopy(i),this._featureRepoters=e,o=0;o<this._featureRepoters.length;o++)this._featureRepoters[o].connectToGroup(this._kinematicGroup)};u.prototype.computeFeatures=function(t){this._kinematicGroup.setFromPose(t),this._kinematicGroup.updateWorldCoordinateFrames();for(var e={},o=0;o<this._featureRepoters.length;o++){
var i=this._featureRepoters[o];e[i.name]=i.computeFeature(t)}return e},u.VectorFeatureReporter=l,u.PlaneDisplacementVectorReporter=c,e.exports=u},{"../../ifr-core/SLog":55,"../../ifr-geometry/ExtraMath":60,"./PlaneDisplacementLookatDOF":108,three:void 0}],99:[function(t,e,o){"use strict";var i=t("./trackpolicy/LookatNodeTrackPolicy"),n=function(t,e,o,i,n,r){this.blinkDelegate=t,this.triggerAtDelta=e,this.minRetriggerTimeSameTrajectory=o,this.minRetriggerTimeAcrossTrajectories=i,this.minDeltaToMarkTrajectoryOver=n,this.onlyAtOrAfterWindupPhase=r,this.lastTriggerTime=null,this.achievedZeroSinceLastBlink=!1};n.prototype.update=function(t,e,o,n){e!==i.TrackMode.DELAY&&e!==i.TrackMode.HOLD?((null===this.lastTriggerTime||this.achievedZeroSinceLastBlink&&n.subtract(this.lastTriggerTime)>=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.highestDistanceOptimalToFiltered<this.minDeltaToMarkTrajectoryOver&&(this.achievedZeroSinceLastBlink=!0)):this.achievedZeroSinceLastBlink=!0},e.exports=n},{"./trackpolicy/LookatNodeTrackPolicy":114}],100:[function(t,e,o){"use strict";var i=function(t,e){this._name=t,this._controlledDOFName=e,this._kinematicGroup=null};i.prototype.connectToGroup=function(t){this._kinematicGroup=t},i.prototype.valToPointAtTarget=function(t,e,o){},i.prototype.getName=function(){return this._name},i.prototype.getControlledDOFName=function(){return this._controlledDOFName},i.prototype.errorRatio=function(t){},i.prototype.suggestForwardTarget=function(t){},e.exports=i},{}],101:[function(t,e,o){"use strict";var i=t("./PoseOffsetFilterWindup"),n=t("../base/Pose"),r=t("../../ifr-core/SLog"),s=t("three"),a=t("./LookatNode"),l=t("./LookatNodeDistanceReport"),c=t("./trackpolicy/LookatNodeTrackPolicy"),u=t("./trackpolicy/TrackPolicyTriggerAlways"),h={POINT_TARGET:"POINT_TARGET",POINT_FORWARD:"POINT_FORWARD",POINT_AUTO:"POINT_AUTO",UNTARGETED:"UNTARGETED"},p=function(t,e,o,r,a,h,p,d,m){this._lookatNode=t,this._stabilization=r;var f=t.getDOFs();this._filter=new i(f),this._filter.setRejectVelocityThreshold(20),null!=o&&this._filter.setAcceleration(o),this._lastUpdateTime=null,this._optimalPose=new n("LMN Optimal",f),this._tempPose=new n("LMN Temp",f),this._stabilizationTarget=new s.Vector3,this._poseForStabilizationTarget=new n("Pose For ST",f),this._holdPose=new n("Hold Pose",f),this._lastInputPose=null,this._currentPoseIncludingOurContribution=null,this._lookatTrackPolicy=h,null==this._lookatTrackPolicy&&(this._lookatTrackPolicy=new c([new u])),this._blinkManager=null,null!=p&&(this._blinkManager=p),this._targetAdjuster=null,null!=d&&(this._targetAdjuster=d),this._adjustedOptimalPose=this._optimalPose,null!=d&&(this._adjustedOptimalPose=new n("LMN Adjusted Optimal",f)),this._dofAligner=e,this._stabilizationMode=a,this._lookatWindupPolicy=null,null!=m&&(this._lookatWindupPolicy=m,this._lookatWindupPolicy.configureFilter(this._filter)),this._lookatNodeDistanceReport=new l,this._trackMode=c.TrackMode.TRACK};p.LookStabilizationMode=h,p.prototype.connectToGroup=function(t){this._lastInputPose=new n("Last Input",t.getDOFNames());for(var e=0;e<this._lastInputPose.dofIndices.length;e++)this._lastInputPose.setByIndex(this._lastInputPose.dofIndices[e],0,0);this._currentPoseIncludingOurContribution=new n("Current Including Us",t.getDOFNames()),this._lookatNode.connectToGroup(t)},p.prototype.update=function(t,e,o,i){if(null!==this._lastUpdateTime&&i.equals(this._lastUpdateTime))return void this._filter.getValue(e);var s;null===this._lastUpdateTime?s=t:(s=this._optimalPose,this._currentPoseIncludingOurContribution.setPose(t),this._filter.getValue(this._currentPoseIncludingOurContribution),t=this._currentPoseIncludingOurContribution);for(var l=this._lastInputPose.getDOFIndices(),u=0,p=0;p<l.length;p++)u+=Math.abs(this._lastInputPose.getByIndex(l[p],0)-t.getByIndex(l[p],0));u<=1e-6?t=this._lastInputPose:this._lastInputPose.setPose(t);var d=new a.PointNodeReport;if(this._lookatNode.getPose(t,this._optimalPose,o,s,d),null!==this._targetAdjuster&&(null===this._lastUpdateTime?this._targetAdjuster.adjustTarget(this._optimalPose,t,o,this._dofAligner,this._adjustedOptimalPose):(this._filter.getValue(this._tempPose),this._targetAdjuster.adjustTarget(this._optimalPose,this._tempPose,o,this._dofAligner,this._adjustedOptimalPose))),this._stabilizationMode!==h.UNTARGETED&&(this._stabilizationMode===h.POINT_FORWARD||this._stabilizationMode===h.POINT_AUTO&&(d._targetStability<.2||!d._pointSucceeded)?(this._stabilizationMode===h.POINT_AUTO&&r.info("Stabilization AUTO mode for "+this.getName()+" falling back to FORWARD with stability "+d._targetStability+", pointSuccess="+d._pointSucceeded),this._lookatNode.suggestForwardTarget(t,this._stabilizationTarget),this._lookatNode.getPose(t,this._poseForStabilizationTarget,this._stabilizationTarget,s)):(this._stabilizationTarget.copy(o),this._poseForStabilizationTarget.setPose(this._optimalPose))),null===this._lastUpdateTime)this._stabilization.reset(),this._holdPose.setPose(t),this._lookatTrackPolicy.reset(),this._stabilization.computeStabilizationDelta(t,this._poseForStabilizationTarget,this._stabilizationTarget),this._tempPose.setPose(t),this._stabilization.decomposeVelocity(t,this._tempPose,this._stabilizationTarget,this._filter.getRejectVelocityThreshold()),this._filter.resetToPose(this._tempPose);else{var m=i.subtract(this._lastUpdateTime);this._filter.getTarget(this._tempPose),this._dofAligner.refineToLocallyClosestTargetPose(this._tempPose,this._adjustedOptimalPose);var f=this._stabilization.computeStabilizationDelta(t,this._poseForStabilizationTarget,this._stabilizationTarget);if(this._filter.applyUnfilteredOffset(f,m),n.add(this._holdPose,f,!1,this._holdPose),this._filter.getValue(this._tempPose,!0),this._lookatNodeDistanceReport.compute(this._holdPose,this._adjustedOptimalPose,this._tempPose),this._trackMode=this._lookatTrackPolicy.computeMode(this._lookatNodeDistanceReport,i),null!==this._lookatWindupPolicy){var g=this._lookatWindupPolicy.shouldWindup(this._lookatNodeDistanceReport,this._trackMode,i,o);g&&this._filter.startWindupIfPossible()}var _=!1;if(this._trackMode===c.TrackMode.HOLD||this._trackMode===c.TrackMode.DELAY?this._filter.setTarget(this._holdPose):(this._filter.setTarget(this._adjustedOptimalPose),_=!0),this._filter.updateByTime(m),null!==this._blinkManager){var y=null;null!==this._lookatWindupPolicy&&(y=this._filter.getWindupState()),this._blinkManager.update(this._lookatNodeDistanceReport,this._trackMode,y,i)}_&&this._filter.getValue(this._holdPose)}null!=e&&this._filter.getValue(e),this._lastUpdateTime=i},p.prototype.getOptimalPose=function(t,e,o){var i;i=null===this._lastUpdateTime?t:this._optimalPose,this._lookatNode.getPose(t,e,o,i)},p.prototype.getPose=function(t){null===this._lastUpdateTime&&r.error('LookatMotionNode asked "getPose()" before initialization'),this._filter.getValue(t)},p.prototype.getDistanceRemaining=function(){return null===this._lastUpdateTime&&r.error('LookatMotionNode asked "getDistanceRemaining()" before initialization'),this._filter.getValue(this._tempPose),this._lookatNode.distanceAsRatio(this._tempPose,this._adjustedOptimalPose)},p.prototype.getDOFs=function(){return this._lookatNode.getDOFs()},p.prototype.reset=function(){this._lastUpdateTime=null,this._trackMode=c.TrackMode.TRACK},p.prototype.getName=function(){return this._lookatNode.getName()},p.prototype.getTrackMode=function(){return this._trackMode},p.prototype.getInHoldMode=function(){return this._trackMode===c.TrackMode.HOLD},e.exports=p},{"../../ifr-core/SLog":55,"../base/Pose":76,"./LookatNode":102,"./LookatNodeDistanceReport":103,"./PoseOffsetFilterWindup":111,"./trackpolicy/LookatNodeTrackPolicy":114,"./trackpolicy/TrackPolicyTriggerAlways":116,three:void 0}],102:[function(t,e,o){"use strict";function i(t,e,o){var i=t._angleToAxis/(Math.PI/2),n=Math.min(5*t._distanceToTarget,1);null===e._targetStability?e._targetStability=i*n:e._targetStability*=i*n,o||(e._pointSucceeded=!1)}var n=t("./PointADOF"),r=t("../../ifr-core/SLog"),s="LOOKAT",a=function(){this._targetStability=null,this._pointSucceeded=!0},l=function(t,e){this._name=t,this._lookatDOFs=e,this._kinematicGroup=null};l.PointNodeReport=a,l.prototype.connectToGroup=function(t){this._kinematicGroup=t;for(var e=0;e<this._lookatDOFs.length;e++)this._lookatDOFs[e].connectToGroup(this._kinematicGroup)},l.prototype.getPose=function(t,e,o,a,l){e!==t&&e.setPose(t),null==a&&(a=t);var c=!1;this._kinematicGroup.setFromPose(t),this._kinematicGroup.updateWorldCoordinateFrames();for(var u=null,h=0;h<this._lookatDOFs.length;h++){l&&(u=new n.PointReport);var p=this._lookatDOFs[h].valToPointAtTarget(o,u,t);u&&i(u,l,null!=p),null!=p?e.set(this._lookatDOFs[h].getControlledDOFName(),p,0):(r(s,"LookatNode "+this._name+" using last value due to uncomputable value for target ("+o.x+", "+o.y+", "+o.z+")"),e.set(this._lookatDOFs[h].getControlledDOFName(),a.get(this._lookatDOFs[h].getControlledDOFName(),0),0),c=!0),h<this._lookatDOFs.length-1&&(this._kinematicGroup.setFromPose(e),this._kinematicGroup.updateWorldCoordinateFrames())}return!c},l.prototype.getDOFs=function(){for(var t=[],e=0;e<this._lookatDOFs.length;e++)t.push(this._lookatDOFs[e].getControlledDOFName());return t},l.prototype.distanceAsRatio=function(t,e){for(var o=0,i=0;i<this._lookatDOFs.length;i++){var n=this._lookatDOFs[i],r=n.getControlledDOFName(),s=t.get(r,0),a=e.get(r,0),l=n.errorRatio(s-a);l>o&&(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;n<i.length;n++){var r=i[n],s=Math.abs(t.getByIndex(r,0)-o.getByIndex(r,0)),a=Math.abs(t.getByIndex(r,0)-e.getByIndex(r,0)),l=Math.abs(e.getByIndex(r,0)-o.getByIndex(r,0)),c=Math.abs(o.getByIndex(r,1));s>this.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;o<this._lookatNodes.length;o++){var s=e.getCopy(e.getModelControlGroup().getRequiredTransformNamesForDOFs(this._lookatNodes[o].getDOFs()),!0);this._lookatNodes[o].connectToGroup(s);var a=s.getDOFNames();for(n=0;n<a.length;n++)r.indexOf(a[n])<0&&r.push(a[n])}for(this._internalPose=new i("LookPose",r),this._dofToLookatNodeMap={},this._lookatNodeToDOFsMap={},this._dofIndexToLookatNodeMap=[],this._lookatNodeIndexToDOFIndices=[],o=0;o<this._lookatNodes.length;o++){var l=this._lookatNodes[o],c=this._lookatNodes[o].getDOFs();if(this._lookatNodeToDOFsMap.hasOwnProperty(l.getName()))throw new Error("Error, multiple lookat nodes named "+l.getName());for(this._lookatNodeToDOFsMap[l.getName()]=c,this._lookatNodeIndexToDOFIndices[o]=[],n=0;n<c.length;n++){var u=c[n];if(this._dofToLookatNodeMap.hasOwnProperty(u))throw new Error("Error, multiple lookat nodes use DOF "+u+": "+this._dofToLookatNodeMap[u].getName()+" and "+l.getName());this._dofToLookatNodeMap[u]=l;var h=this._internalPose.getDOFIndexForName(u);this._dofIndexToLookatNodeMap[h]=l,this._lookatNodeIndexToDOFIndices[o].push(h)}}};n.prototype.generatePose=function(t,e,o,i){this._internalPose.setPose(t);for(var n=0;n<this._lookatNodes.length;n++)this._lookatNodes[n].update(this._internalPose,this._internalPose,o,i);e.setPose(this._internalPose)},n.prototype.generatePoseIncremental=function(t,e,o,i,n){var r=this._dofIndexToLookatNodeMap[n];r.update(t,e,o,i)},n.prototype.getPose=function(t){for(var e=0;e<this._lookatNodes.length;e++)for(var o=this._lookatNodeIndexToDOFIndices[e],i=this._lookatNodes[e],n=0;n<o.length;n++)if(t.hasDOFIndex(o[n])){i.getPose(t);break}},n.prototype.getOptimalPose=function(t,e,o){t!==e&&e.setPose(t),this._internalPose.setPose(t);for(var i=0;i<this._lookatNodes.length;i++)this._lookatNodes[i].getOptimalPose(this._internalPose,this._internalPose,o);e.setPose(this._internalPose)},n.prototype.getDistanceRemaining=function(t){var e,o,i=0;if(null==t)for(e=0;e<this._lookatNodes.length;e++)o=this._lookatNodes[e].getDistanceRemaining(),o>i&&(i=o);else{var n={};for(e=0;e<t.length;e++){var r=t[e];if(this._dofToLookatNodeMap.hasOwnProperty(r)){var s=this._dofToLookatNodeMap[r];n[s.getName()]!==!0&&(o=s.getDistanceRemaining(),o>i&&(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;e<n.length;e++)if(!n[e].getInHoldMode()){i=!1;break}}else{var r,s,a;for(e=0;e<n.length;e++){for(r=!1,s=this._lookatNodeIndexToDOFIndices[e],a=this._lookatNodes[e],o=0;o<s.length;o++)if(t[s[o]]){r=!0;break}if(r&&!a.getInHoldMode()){i=!1;break}}}return i},n.prototype.getDOFs=function(){for(var t=[],e=0;e<this._lookatNodes.length;e++)t=t.concat(this._lookatNodes[e].getDOFs());return t},n.prototype.getStateDOFs=function(){return this._internalPose.getDOFNames()},n.prototype.reset=function(){for(var t=0;t<this._lookatNodes.length;t++)this._lookatNodes[t].reset()},e.exports=n},{"../base/Pose":76}],107:[function(t,e,o){"use strict";var i=t("../../ifr-core/SLog"),n=t("../base/Pose"),r=t("three"),s=t("./LookatNode"),a=function(t,e){var o=!1,a=new r.Vector3,l=t.getDOFs(),c=new n(t.getName()+" Last Optimal",l),u=new n(t.getName()+" Stepped Pose",l),h=new n(t.getName()+" OST Delta",l),p=new n(t.getName()+" Temp Last Pose Optimal",l),d=null;this.computeStabilizationDelta=function(i,r,p){if(o){var d=!1,m=null;if(a.equals(p)?(u.setPose(r),d=!0):(m=new s.PointNodeReport,t.getPose(i,u,a,null,m)),d||m._pointSucceeded)null!=e&&e.refineToLocallyClosestTargetPose(c,u),n.subtract(u,c,!0,h);else for(var f=h.getDOFIndices(),g=0;g<f.length;g++)h.setByIndex(f[g],0,0)}else{h.clear();for(var _=0;_<l.length;_++)h.set(l[_],0,0)}return a.copy(p),null==r?t.getPose(i,c,p):c.setPose(r),o=!0,h},this.decomposeVelocity=function(o,r,s,a){null==a&&(a=0),null===d&&(d=new n(t.getName()+" Decomp Last Pose")),n.advanceByTime(o,!0,d,-.02),t.getPose(o,u,s),t.getPose(d,p,s),null!=e&&e.refineToLocallyClosestTargetPose(p,u),n.subtract(u,p,!0,h);for(var l=h.getDOFIndices(),c=0;c<l.length;c++){var m=l[c],f=o.getByIndex(m,1),g=h.getByIndex(m,0),_=50*g;0!==a&&Math.abs(_)>a&&(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()<l)return n(s,"Error getting relative angle, forward too close to plane normal ("+a.x+", "+a.y+", "+a.z+") too close to axis ("+a.x+", "+a.y+", "+a.z+")"),null;if(g.lengthSq()<l)return n(s,"Error getting relative angle, target dir too close to plane normal ("+a.x+", "+a.y+", "+a.z+") too close to axis ("+g.x+", "+g.y+", "+g.z+")"),null;g.normalize(),f.normalize();var _=(new i.Quaternion).setFromUnitVectors(f,g),y=(new i.Vector4).setAxisAngleFromQuaternion(_),v=d(y,a);return null!==c&&c.shouldDraw(this)&&(c.drawRayLocal(this,"RelativeAngle:Forward",t,o,r,new i.Color(1,0,0)),c.drawLineLocal(this,"RelativeAngle:Target",t,o,(new i.Vector3).copy(o).add(m),new i.Color(.6,.6,0)),c.drawLineLocal(this,"RelativeAngle:FlatTarget",t,o,(new i.Vector3).copy(o).add(g),new i.Color(0,1,1)),c.drawRayLocal(this,"RelativeAngle:AxisOfRotation",t,o,a,new i.Color(.5,1,0)),c.drawPlaneLocal(this,"RelativeAngle:PlaneOfRotation",t,o,a,new i.Color(1,0,1))),v},h.planeIntersectFromRear=function(t,e,o,r,a,l,u){null==o&&(o=new i.Vector3(0,0,0));var p=(new i.Vector3).copy(r).normalize().multiplyScalar(-l).add(o),d=h.getRelativeAngle(t,e,p,r,a,u);if(null!=d){var m;if(m=d>=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()<l)return n(s,"vectorFromPlaneIntersections error, forward ("+r.toString(o)+")and normal1 ("+r.toString(c)+") are not orthogonal"),!1;g.setLength(a);var _=(new i.Vector3).crossVectors(p,o);return _.lengthSq()<l?(n(s,"vectorFromPlaneIntersections error, forward ("+r.toString(o)+")and normal2 ("+r.toString(p)+") are not orthogonal"),!1):(_.setLength(h),m.copy(e).add(g).add(_),g.divideScalar(u),_.divideScalar(d),f.copy(o).normalize().add(g).add(_),t.localToWorld(m),r.convertDirectionLocalToWorld(t,f.normalize(),f),!0)},h.pointDOF=function(t,e,o,r,a){var u=e.worldToLocal((new i.Vector3).copy(r)),h=(new i.Quaternion).copy(e.quaternion);u.applyQuaternion(h);var m=t.getInitialRotation(new i.Quaternion),f=t.getRotationalAxis(new i.Vector3);f.applyQuaternion(m);var g=(new i.Vector3).copy(o).applyQuaternion(m);a&&(a._angleToAxis=p(u.angleTo(f)),a._distanceToTarget=u.length());var _=(new i.Vector3).copy(g).projectOnPlane(f),y=(new i.Vector3).copy(u).projectOnPlane(f);if(_.lengthSq()<l||y.lengthSq()<l)return n(s,"Error pointing DOF, Forward length:"+_.length()+" local length:"+y.length()),null;_.normalize(),y.normalize();var v=(new i.Quaternion).setFromUnitVectors(_,y),T=(new i.Vector4).setAxisAngleFromQuaternion(v),D=d(T,f);if(null!==c&&c.shouldDraw(this)){c.drawRayLocal(this,"PointAt:CurForwardDir",e,null,o,new i.Color(1,0,0));var O=t.getRotationalAxis(new i.Vector3);c.drawRayLocal(this,"PointAt:AxisOfRotation",e,null,O,new i.Color(1,1,0)),c.drawPlaneLocal(this,"PointAt:PlaneOfRotation",e,null,O,new i.Color(1,0,1));var L=(new i.Vector3).copy(o);L.applyQuaternion(m),L.applyQuaternion((new i.Quaternion).copy(h).inverse()),c.drawRayLocal(this,"PointAt:InitForwardDir",e,null,L,new i.Color(0,1,1));var F=(new i.Quaternion).setFromAxisAngle(f,D),w=(new i.Vector3).copy(g).applyQuaternion(F);w.applyQuaternion((new i.Quaternion).copy(h).inverse()),c.drawRayLocal(this,"PointAt:FlatTargetVec",e,null,w,new i.Color(0,1,1))}return D},h.pointDOFToIntersectConeWithPoint=function(t,e,o,r,l,u,h,m){var f=e.worldToLocal((new i.Vector3).copy(l)),g=(new i.Quaternion).copy(e.quaternion);f.applyQuaternion(g);var _=t.getInitialRotation(new i.Quaternion),y=t.getRotationalAxis(new i.Vector3),v=(new i.Vector3).copy(y).applyQuaternion(_);if(o.angleTo(y)>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(w<a)return n(s,"Error, plane normal ("+o.x+", "+o.y+", "+o.z+") too close to axis ("+y.x+", "+y.y+", "+y.z+")"),null;var S=Math.PI/2-v.angleTo(f),b=Math.tan(S),k=Math.tan(w),C=null;if(C=h?Math.PI/2*Math.max(-1,Math.min(1,b/k)):Math.asin(Math.max(-1,Math.min(1,b/k))),m&&(m._angleToAxis=p(f.angleTo(v)),m._distanceToTarget=f.length()),p(f.angleTo(v))<a)return n(s,"Error, Lookat Target local:("+f.x+", "+f.y+", "+f.z+"), world:("+l.x+", "+l.y+", "+l.z+") too close to rotated axis ("+v.x+", "+v.y+", "+v.z+")"),null;var P=(new i.Vector3).crossVectors(v,f).normalize(),N=(new i.Vector3).copy(F).projectOnPlane(v).normalize(),E=(new i.Quaternion).setFromUnitVectors(N,P),I=(new i.Vector4).setAxisAngleFromQuaternion(E),R=d(I,v),M=-(C- -Math.PI/2)+-Math.PI/2,x=R+C,A=R+M;return[x,A]},e.exports=h},{"../../ifr-core/SLog":55,"../../ifr-geometry/ExtraMath":60,three:void 0}],110:[function(t,e,o){"use strict";var i=t("../../ifr-core/SLog"),n=t("../base/AccelPlanner"),r=t("../base/Pose"),s="LOOKAT",a=function(t){this._dofNames=t,this._targetPose=new r("POF Target",t),this._filteredPose=new r("POF Filtered",t),this._accelPlanner=new n,this._accLimit=.5,this._rejectionVelocityThreshold=0,this._epsilon=1e-5,this._dofIndices=this._targetPose.getDOFIndices()};a.prototype._timeForLongestDOF=function(t,e,o,n,r){for(var a,l,c,u,h,p=0,d=0;d<r.length;d++){h=r[d],a=e.getByIndex(h,0),l=e.getByIndex(h,1),c=t.getByIndex(h,0),u=o.computeWithFixedAccel(l,0,c-a,n);var m;u&&u.isConsistent()?m=u.getTotalTime():(i(s,"PoseOffsetFilter(tt) for "+e.getDOFNameForIndex(h)+" got invalid plan, using backup time of 10! (currentVel:"+l+", target:"+c+", currentPos:"+a+", acceLimit:"+n+")"),m=10),m>p&&(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;d<a.length;d++)if(p=a[d],l=n.getByIndex(p,0),c=n.getByIndex(p,1),u=o.getByIndex(p,0),h=r.computeWithFixedTime(c,0,u-l,e),h&&h.isConsistent()){var m=h.displacementAtTime(t),f=h.velocityAtTime(t);n.setByIndex(p,[l+m,f])}else i(s,"PoseOffsetFilter(dp) for "+n.getDOFNameForIndex(p)+" got invalid plan, using backup filter! (currentVel:"+c+", target:"+u+", currentPos:"+l+", totalTransitTime:"+e+")"),n.setByIndex(p,[.99*l+.01*u,.96*c])},a.prototype.updateByTime=function(t){var e=this._timeForLongestDOF(this._targetPose,this._filteredPose,this._accelPlanner,this._accLimit,this._dofIndices);this._advanceFixedTimeMode(t,e,this._targetPose,this._filteredPose,this._accelPlanner,this._dofIndices)},a.prototype.resetToTarget=function(){this._filteredPose.setPose(this._targetPose)},a.prototype.resetToPose=function(t){this._filteredPose.setPose(t),this._targetPose.setPose(t)},a.prototype.setTarget=function(t){this._targetPose.setPose(t)},a.prototype.getTarget=function(t){t.setPose(this._targetPose)},a.prototype.getValue=function(t,e){e?t.setPose(this._filteredPose):t.setPose0Only(this._filteredPose)},a.prototype.getPreOffsetVelocities=function(t){for(var e,o=this._dofIndices,i=this._filteredPose,n=0;n<o.length;n++)e=o[n],t.setByIndex(e,i.getByIndex(e,1),1)},a.prototype.setRejectVelocityThreshold=function(t){this._rejectionVelocityThreshold=t},a.prototype.getRejectVelocityThreshold=function(){return this._rejectionVelocityThreshold},a.prototype.setAcceleration=function(t){this._accLimit=t},a.prototype.applyUnfilteredOffset=function(t,e){for(var o,n=this._dofIndices,r=0!==this._rejectionVelocityThreshold,s=this._rejectionVelocityThreshold*e,a=this._filteredPose,l=0;l<n.length;l++){o=n[l];var c=t.getByIndex(o,0);r&&Math.abs(c)>s&&(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;l<o.length;l++){var c=o[l],u=Math.abs(e.getByIndex(c,1)),h=Math.abs(e.getByIndex(c,0)-t.getByIndex(c,0));u>s&&(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;a<r.length;a++){s=r[a];var c=t.getByIndex(s,0);l+=Math.pow(c,2)}l=Math.sqrt(l);var u=e*o;u=Math.max(i,Math.min(n,u));var h=Math.sqrt(u/l);return h},h=function(t,e,o,i,n){for(var r=0,s=0;s<i.length;s++){var a=i[s],l=e.getByIndex(a,0),c=t.getByIndex(a,0),u=c-l;Math.abs(u)<n&&(u=0),o.setByIndex(a,u,0),0!==u&&(r+=Math.pow(u,2))}return Math.sqrt(r)},p=function(t,e,o,n,r,a,l){var c,u;for(u=0;u<a.length;u++)if(c=a[u],t>l){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*c<n?c=1/e*n:e*c>r&&(c=1/e*r),l=0;l<o.length;l++)a=o[l],t.setByIndex(a,t.getByIndex(a,0)*c,0)}else for(l=0;l<o.length;l++)a=o[l],t.setByIndex(a,0,0)};l.prototype._advanceFixedTimeModeWindup=function(t,e,o,i,n,r,s){var a,l=0,c=0;if(this._windupTimeToZeroPRemaining>0&&(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;l<s.length;l++){a=s[l],c=i.getByIndex(a,0);var h=i.getByIndex(a,1),p=r.getByIndex(a,0),d=n.createPlanWithFixedAccelForever(h,p),m=d.displacementAtTime(u),f=d.velocityAtTime(u);i.setByIndex(a,[c+m,f])}}t>this._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;l<n;l++){e=o[l];var m=this._targetOvershootDelta.getByIndex(e,0),f=this._targetPose.getByIndex(e,0),g=this._filteredPose.getByIndex(e,0),_=f-g;_>0&&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._checkers.length;o++){var l=this._checkers[o],c=l.shouldStartTracking(t,s);c===i.StartStatus.YES&&(a=!0),c===i.StartStatus.LATER&&(r=!0)}a&&this._start(e)}else if(this._currentMode===n.TRACK){var u=!1;for(o=0;o<this._checkers.length;o++){var h=this._checkers[o],p=h.shouldStopTracking(t,s);p===!1&&(u=!0)}u||this._stop(e)}var d;if(d=this._currentMode===n.HOLD&&r?n.DELAY:this._currentMode,null!==this._trackPolicyListeners)for(o=0;o<this._trackPolicyListeners.length;o++)this._trackPolicyListeners[o].notifyTrackMode(d);return d},r.prototype.reset=function(){for(var t=0;t<this._checkers.length;t++)this._checkers[t].reset();this._lastTime=null},r.prototype._start=function(t){if(this._currentMode=n.TRACK,this.reset(),null!==this._trackPolicyListeners)for(var e=0;e<this._trackPolicyListeners.length;e++)this._trackPolicyListeners[e].notifyTrackStarted()},r.prototype._stop=function(t){if(this._currentMode=n.HOLD,this.reset(),null!==this._trackPolicyListeners)for(var e=0;e<this._trackPolicyListeners.length;e++)this._trackPolicyListeners[e].notifyTrackStopped()},e.exports=r},{"./TrackPolicyTrigger":115}],115:[function(t,e,o){"use strict";var i={YES:"YES",NO:"NO",LATER:"LATER"},n=function(){};n.StartStatus=i,n.prototype.shouldStartTracking=function(t,e){return null},n.prototype.shouldStopTracking=function(t,e){return null},n.prototype.reset=function(){},e.exports=n},{}],116:[function(t,e,o){"use strict";var i=t("./TrackPolicyTrigger"),n=function(){i.call(this)};n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.shouldStartTracking=function(t,e){return i.StartStatus.YES},n.prototype.shouldStopTracking=function(t,e){return!1},e.exports=n},{"./TrackPolicyTrigger":115}],117:[function(t,e,o){"use strict";var i=t("./TrackPolicyTrigger"),n=function(t,e,o,n,r){i.call(this),this._limitInner=t,this._limitOuter=e,this._accumValueInner=o,this._accumValueOuter=n,this._moveImmediatelyPastOuter=r,this._accumValueCurrent=0};n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.shouldStartTracking=function(t,e){var o=null,n=t.highestDistanceHoldToOptimal;if(n<this._limitInner)this._accumValueCurrent=0,o=i.StartStatus.NO;else if(n>=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<this._renderCallbacks.length;e++)this._renderCallbacks[e]();for(this._renderer.render(this._scene,this._camera),e=0;e<this._postRenderCallbacks.length;e++)this._postRenderCallbacks[e]();null!==this._stats&&this._stats.update(),this._dirty=!1,this._frameSkipCounter=0}},s.prototype.play=function(){this._requestHandle=window.requestAnimationFrame(this._doPlay),this.render()},s.prototype.stop=function(){void 0!==this._requestHandle&&window.cancelAnimationFrame(this._requestHandle)},e.exports=s},{"./TrackballControls":127,"stats-js":void 0,three:void 0}],122:[function(t,e,o){"use strict";var i=t("three"),n=function(t,e,o){this.pos1=t,this.pos2=e,this.color=o};n.prototype.setPosition=function(t,e){this.pos1=t,this.pos2=e},n.prototype.setColor=function(t){this.color=t};var r=function(t,e){void 0!==e&&null!==e||(e=100),this.maxLines=e,this.numTempLines=0,this.unusedVec=new i.Vector3(1e6,1e6,1e6),this.unusedColor=new i.Color(1,1,1),this.lineMaterial=new i.LineBasicMaterial({vertexColors:i.VertexColors}),this.lineGeometry=new i.Geometry;for(var o=0;o<this.maxLines;o++)this.lineGeometry.vertices.push((new i.Vector3).copy(this.unusedVec)),this.lineGeometry.vertices.push((new i.Vector3).copy(this.unusedVec)),this.lineGeometry.colors.push((new i.Color).copy(this.unusedColor)),this.lineGeometry.colors.push((new i.Color).copy(this.unusedColor));this.line=new i.Line(this.lineGeometry,this.lineMaterial,i.LinePieces),this.line.frustumCulled=!1,this.lineMaterial.linewidth=1,this.postRenderCallbackInstalled=null,this.renderCallbackInstalled=null,this.addedToScene=null,this.leasedLines=[],void 0!==t&&this.addToScene(t)};r.prototype.addToScene=function(t){t.getScene().add(this.line),this.postRenderCallbackInstalled=this.postRenderCleanup.bind(this),this.renderCallbackInstalled=this.prepareForRender.bind(this),this.addedToScene=t,t.addPostRenderCallback(this.postRenderCallbackInstalled),t.addRenderCallback(this.renderCallbackInstalled)},r.prototype.removeFromScene=function(){null!=this.addedToScene&&(this.addedToScene.getScene().remove(this.line),this.addedToScene.removePostRenderCallback(this.postRenderCallbackInstalled),this.addedToScene.removeRenderCallback(this.renderCallbackInstalled),this.addedToScene=null,this.postRenderCallbackInstalled=null)},r.prototype.drawOnce=function(t,e,o){this.numTempLines<this.maxLines&&(this.lineGeometry.vertices[2*this.numTempLines].copy(t),this.lineGeometry.vertices[2*this.numTempLines+1].copy(e),this.lineGeometry.verticesNeedUpdate=!0,void 0!==o&&(this.lineGeometry.colors[2*this.numTempLines].copy(o),this.lineGeometry.colors[2*this.numTempLines+1].copy(o),this.lineGeometry.colorsNeedUpdate=!0),this.numTempLines++)},r.prototype.leaseLine=function(t,e,o){var i=new n(t,e,o);return this.leasedLines.push(i),i},r.prototype.returnLeased=function(t){var e=this.leasedLines.indexOf(t);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;t<this.leasedLines.length;t++){var e=this.leasedLines[t];this.drawOnce(e.pos1,e.pos2,e.color)}},r.prototype.postRenderCleanup=function(){if(this.numTempLines>0){for(var t=0;t<this.numTempLines;t++)this.lineGeometry.vertices[2*t].copy(this.unusedVec),this.lineGeometry.vertices[2*t+1].copy(this.unusedVec),this.lineGeometry.colors[2*t].copy(this.unusedColor),this.lineGeometry.colors[2*t+1].copy(this.unusedColor);this.lineGeometry.verticesNeedUpdate=!0,this.lineGeometry.colorsNeedUpdate=!0,this.numTempLines=0}},e.exports=r},{three:void 0}],123:[function(t,e,o){"use strict";var i=t("./TextOverlayPool"),n=t("./MouseCoordinateWrangler"),r=function(t){this.textOverlay=new i(t.getContainer()),this.container=t.getContainer(),this.camera=t.getCamera(),this.addedToScene=null,this.postRenderCallbackInstalled=null,this._addToScene(t)};r.prototype._addToScene=function(t){this.postRenderCallbackInstalled=this.postRenderCleanup.bind(this),this.addedToScene=t,t.addPostRenderCallback(this.postRenderCallbackInstalled)},r.prototype.removeFromScene=function(){null!=this.addedToScene&&(this.addedToScene.removePostRenderCallback(this.postRenderCallbackInstalled),this.addedToScene=null,this.postRenderCallbackInstalled=null),this.textOverlay.postRenderCleanup(),this.textOverlay.returnAllLeased()},r.prototype.drawOnce2D=function(t,e,o,i,n){this.textOverlay.drawOnce2D(t,e,o,i,n)},r.prototype.drawOnce3D=function(t,e,o,i,r,s){var a=n.projectToScreenPixels(e,o,i,this.camera,this.container,!0);null!==a&&this.textOverlay.drawOnce2D(t,a.x,a.y,r,s)},r.prototype.lease2D=function(t,e,o,i,n){return this.textOverlay.lease2D(t,e,o,i,n)},r.prototype.lease3D=function(t,e,o,i,r,s){var a=n.projectToScreenPixels(e,o,i,this.camera,this.container,!0);null!==a?this.textOverlay.lease2D(t,a.x,a.y,r,s):this.textOverlay.lease2D(t,-1e3,-1e3,r,s)},r.prototype.returnLeased=function(t){this.textOverlay.returnLeased(t)},r.prototype.returnAllLeased=function(){this.textOverlay.returnAllLeased()},r.prototype.postRenderCleanup=function(){this.textOverlay.postRenderCleanup()},e.exports=r},{"./MouseCoordinateWrangler":124,"./TextOverlayPool":126}],124:[function(t,e,o){"use strict";var i=t("three"),n=t("../ifr-core/SLog"),r="MOUSE_COORD_WRANGLER",s={};s.getOffsetRect=function(t){var e=t.getBoundingClientRect(),o=document.body,i=document.documentElement,n=window.pageYOffset||i.scrollTop||o.scrollTop,r=window.pageXOffset||i.scrollLeft||o.scrollLeft,s=i.clientTop||o.clientTop||0,a=i.clientLeft||o.clientLeft||0,l=e.top+n-s,c=e.left+r-a;return{top:Math.round(l),left:Math.round(c),width:Math.round(e.width),height:Math.round(e.height)}},s.projectToScreenNDC=function(t,e,o,n){var r=new i.Vector3(t,e,o).project(n);return{x:r.x,y:r.y}},s.projectToScreenPixels=function(t,e,o,n,r,s){var a=new i.Vector3(t,e,o).project(n);if(a.z<0||a.z>1)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<h.length;o++)h[o](t,e)},this.addTargetPositioner=function(t,i){if(p.has(t))s(a,"Not adding MouseTargetPositioner target "+t+", already have target with that name");else{null==i&&(i=o);var n=new r(t,e,i,l,c);n.addPositionChangedCallback(this.notifyPositionChangedCallbacks),null!==y&&n.installRendererIntoScene(y),p.set(t,n),null===d?(d=t,n.setHighlighted(!0)):n.setHighlighted(!1)}},this.removeTargetPositioner=function(t){if(p.has(t)){var e=p.get(t);null!==y&&e.removeRendererFromScene(y),e.removePositionChangedCallback(this.notifyPositionChangedCallbacks),p.delete(t),d===t&&(d=null)}},this.getTargetPositionerNames=function(){for(var t,e=[],o=p.keys();!(t=o.next()).done;)e.push(t.value);return e},this.selectTarget=function(t){if(null!=d){var e=p.get(d);null!=e&&e.setHighlighted(!1)}if(null!=t){var o=p.get(t);null!=o&&o.setHighlighted(!0)}d=t},this.installRendererIntoScene=function(t){if(null!==y)throw new Error("Remove MTP renderer from existing scene before installing in another!");for(var e of p.values())e.installRendererIntoScene(t);y=t},this.removeRendererFromScene=function(t){for(var e of p.values())e.removeRendererFromScene(t);y=null},this.setMouseFilters();for(var L of u)this.addTargetPositioner(L)};e.exports=l},{"../ifr-core/SLog":55,"./MouseCoordinateWrangler":124,"./ViewportTargetPositioner":128,three:void 0}],126:[function(t,e,o){"use strict";var i=0,n=function(t,e,o){this.div=document.createElement("div"),this.div.id="text-display:"+i++,this.div.style.cssText="padding:0 0 0px 0px;text-align:left;position:absolute",null!=e&&this.setColor(e),null!=o&&this.setSize(o),null!=t&&this.setText(t)};n.prototype.setPosition2D=function(t,e){this.div.style.top=e+"px",this.div.style.left=t+"px"},n.prototype.setColor=function(t){this.div.style.color=t},n.prototype.setText=function(t){this.div.innerHTML=t},n.prototype.setSize=function(t){this.div.style.fontSize=t};var r=function(t){this.onElement=t,this.drawOnceElements=[],this.leasedElements=[]};r.prototype.drawOnce2D=function(t,e,o,i,r){var s=new n(t,i,r);s.setPosition2D(e,o),this.drawOnceElements.push(s),this.onElement.appendChild(s.div)},r.prototype.lease2D=function(t,e,o,i,r){var s=new n(t,i,r);return s.setPosition2D(e,o),this.leasedElements.push(s),this.onElement.appendChild(s.div),s},r.prototype.returnLeased=function(t){var e=this.leasedElements.indexOf(t);e>=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?r<Math.SQRT1_2?o.z=Math.sqrt(1-r*r):o.z=.5/r:r>1?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()<d.minDistance*d.minDistance&&d.object.position.addVectors(d.target,v.setLength(d.minDistance)))},this.update=function(){v.subVectors(d.object.position,d.target),d.noRotate||d.rotateCamera(),d.noZoom||d.zoomCamera(),d.noPan||d.panCamera(),d.object.position.addVectors(d.target,v),d.checkDistances(),d.object.lookAt(d.target),g.distanceToSquared(d.object.position)>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<this._positionChangedListeners.length;e++)this._positionChangedListeners[e](t,this._name)},l.prototype.setHighlighted=function(t){t?(this._anchoredTargetVis.setLineWidth(2),this._anchoredTargetVis.setBrightness(1)):(this._anchoredTargetVis.setLineWidth(.5),this._anchoredTargetVis.setBrightness(.5))},l.prototype.getName=function(){return this._name},e.exports=l},{"../ifr-core/SLog":55,"./AnchoredTargetVisualizer":120,"./MouseCoordinateWrangler":124,three:void 0}],129:[function(t,e,o){"use strict";global._animationutilities_singleton?e.exports=global._animationutilities_singleton:(e.exports.JiboConfig=t("./geometry-info/JiboConfig"),e.exports.RobotInfo=t("./geometry-info/RobotInfo"),e.exports.EyeKinematicsHelper=t("./geometry-info/EyeKinematicsHelper"),e.exports.animate=t("./animation-animate/AnimateImpl"),e.exports.visualize=t("./animation-visualize/VisualizeImpl"),e.exports.TimelineBuilder=t("./animation-macros/TimelineBuilder"),e.exports.core={FileTools:t("./ifr-core/FileTools"),Time:t("./ifr-core/Time"),Clock:t("./ifr-core/Clock"),slog:t("./ifr-core/SLog")},e.exports.Time=e.exports.core.Time,e.exports.Clock=e.exports.core.Clock,e.exports.slog=e.exports.core.slog,e.exports.MotionInterface=t("./animation-body/MotionInterface"),e.exports.body={BodyVelocityOutput:t("./animation-body/BodyVelocityOutput"),BodyTrajectoryOutput:t("./animation-body/BodyTrajectoryOutput"),BodyPositionOutput:t("./animation-body/BodyPositionOutput"),BodyPosVelOutput:t("./animation-body/BodyPosVelOutput"),BodyPosVelComboOutput:t("./animation-body/BodyPosVelComboOutput"),MotionServiceOutput:t("./animation-body/MotionServiceOutput"),MotionLog:t("./animation-body/MotionLog")},e.exports.ui={Bakery:t("./ifr-core/Bakery"),JSONBaker:t("./ifr-core/JSONBaker")},e.exports.protos={SampleCombiner:t("./animation-animate/timeline/SampleCombiner"),RenderPlugin:t("./animation-visualize/RenderPlugin")},e.exports.graphics={AnchoredTargetVisualizer:t("./ifr-visualizer/AnchoredTargetVisualizer"),GLTextOverlayPool:t("./ifr-visualizer/GLTextOverlayPool"),GLLinePool:t("./ifr-visualizer/GLLinePool")},e.exports.LEDOutput=t("./animation-body/LEDOutput"),e.exports.AuxOutput=t("./animation-animate/timeline/AuxOutput"),e.exports.MouseCoordinateWrangler=t("./ifr-visualizer/MouseCoordinateWrangler"),e.exports.MouseTargetPositioner=t("./ifr-visualizer/MouseTargetPositioner"),e.exports.TrajectoryControllerSim=t("./ifr-motion/feedback/TrajectoryControllerSim"),e.exports.PosVelControllerSim=t("./ifr-motion/feedback/PosVelControllerSim"),e.exports.THREE=t("three"),e.exports.slog.setPrintChannels(["ERROR","ACCEL_PLANNER","CALIBRATION","MODEL_LOADING","RENDER_PLUGIN"]),global._animationutilities_singleton=e.exports)},{"./animation-animate/AnimateImpl":2,"./animation-animate/timeline/AuxOutput":7,"./animation-animate/timeline/SampleCombiner":18,"./animation-body/BodyPosVelComboOutput":26,"./animation-body/BodyPosVelOutput":27,"./animation-body/BodyPositionOutput":28,"./animation-body/BodyTrajectoryOutput":29,"./animation-body/BodyVelocityOutput":30,"./animation-body/LEDOutput":32,"./animation-body/MotionInterface":33,"./animation-body/MotionLog":34,"./animation-body/MotionServiceOutput":35,"./animation-macros/TimelineBuilder":36,"./animation-visualize/RenderPlugin":40,"./animation-visualize/VisualizeImpl":42,"./geometry-info/EyeKinematicsHelper":44,"./geometry-info/JiboConfig":46,"./geometry-info/RobotInfo":48,"./ifr-core/Bakery":50,"./ifr-core/Clock":51,"./ifr-core/FileTools":52,"./ifr-core/JSONBaker":53,"./ifr-core/SLog":55,"./ifr-core/Time":56,"./ifr-motion/feedback/PosVelControllerSim":92,"./ifr-motion/feedback/TrajectoryControllerSim":93,"./ifr-visualizer/AnchoredTargetVisualizer":120,"./ifr-visualizer/GLLinePool":122,"./ifr-visualizer/GLTextOverlayPool":123,"./ifr-visualizer/MouseCoordinateWrangler":124,"./ifr-visualizer/MouseTargetPositioner":125,three:void 0}]},{},[129])(129)});