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

22 lines
263 KiB
JavaScript
Raw Normal View History

/**
* 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/AnnotatedMot
},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(
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=nu
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(
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._initi
},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.g
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
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=
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