mirror of
https://github.com/status-im/artproject.git
synced 2025-02-23 05:08:24 +00:00
10 lines
141 KiB
JavaScript
10 lines
141 KiB
JavaScript
|
/*empire.studio - Design & Strategy*/
|
||
|
function arrayWriteToEnd(t,e){for(var i=1;i<t.length;i++)t[i-1]=t[i];t[t.length-1]=e}function isNumeric(t){return!isNaN(parseFloat(t))&&isFinite(t)}function ajaxRequest(t,e){var i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer",i.onload=function(t){e(t.target.response)},i.send()}function float32Concat(t,e){t instanceof Float32Array||(t=new Float32Array(t)),e instanceof Float32Array||(e=new Float32Array(e));var i=t.length,r=new Float32Array(i+e.length);return r.set(t),r.set(e,i),r}var CABLES=CABLES||{};CABLES.generateUUID=function(){var t=(new Date).getTime(),e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var i=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?i:3&i|8).toString(16)});return e},CABLES.smoothStep=function(t){var e=Math.max(0,Math.min(1,(t-0)/1));return t=e*e*(3-2*e)},CABLES.smootherStep=function(t){var e=Math.max(0,Math.min(1,(t-0)/1));return t=e*e*e*(e*(6*e-15)+10)},CABLES.map=function(t,e,i,r,s,n){if(t>=i)return s;if(e>=t)return r;var o=!1,a=Math.min(e,i),h=Math.max(e,i);a!=e&&(o=!0);var l=!1,u=Math.min(r,s),c=Math.max(r,s);u!=r&&(l=!0);var g=0,p=0;return g=o?(h-t)*(c-u)/(h-a):(t-a)*(c-u)/(h-a),p=l?c-g:g+u,n?1==n?(t=Math.max(0,Math.min(1,(p-r)/(s-r))),r+t*t*(3-2*t)*(s-r)):2==n?(t=Math.max(0,Math.min(1,(p-r)/(s-r))),r+t*t*t*(t*(6*t-15)+10)*(s-r)):p:p},Math.randomSeed=1,Math.seededRandom=function(t,e){0===Math.randomSeed&&(Math.randomSeed=999*Math.random()),t=t||1,e=e||0,Math.randomSeed=(9301*Math.randomSeed+49297)%233280;var i=Math.randomSeed/233280;return e+i*(t-e)},String.prototype.startsWith=function(t){return 0===this.indexOf(t)},String.prototype.endsWith=function(t){return this.match(t+"$")==t},CABLES.jsonp=function(t,e){CABLES.jsonpCounter=CABLES.jsonpCounter||0,CABLES.jsonpCounter++;var i=CABLES.jsonpCounter;console.log("making jsonp request..."),CABLES["jsonpFunc"+i]=function(t){console.log(t),e(!1,t)};var r="?";t.indexOf(r)>-1&&(r="&");var s=document.createElement("script");s.setAttribute("src",t+r+"callback=CABLES.jsonpFunc"+i),document.body.appendChild(s)},CABLES.ajaxSync=function(t,e,i,r,s){CABLES.ajaxIntern(t,e,i,r,s,!1)},CABLES.ajax=function(t,e,i,r,s,n){CABLES.ajaxIntern(t,e,i,r,s,!0,n)},CABLES.ajaxIntern=function(t,e,i,r,s,n){var o;try{o=new XMLHttpRequest}catch(a){}o.onreadystatechange=function(){4==o.readyState&&e(!1,o.responseText,o)},o.addEventListener("progress",function(t){}),o.open(i?i.toUpperCase():"GET",t,n),r?(o.setRequestHeader("Content-type",s?s:"application/x-www-form-urlencoded"),o.send(r)):o.send()},String.prototype.endl=function(){return this+"\n"};var arrayContains=function(t,e){for(var i=t.length;i--;)if(t[i]===e)return!0;return!1};CGL=CGL||{},CGL.DEG2RAD=Math.PI/180,CGL.RAD2DEG=180/Math.PI,CGL.onLoadingAssetsFinished=null,CGL.isWindows=-1!=window.navigator.userAgent.indexOf("Windows"),CGL.getWheelSpeed=function(t){var e;if(t.wheelDelta)e=t.wheelDelta%120-0==-0?t.wheelDelta/120:t.wheelDelta/30,e*=-1.5,CGL.isWindows&&(e*=2);else{var i=t.deltaY?t.deltaY:t.detail;e=-(i%3?10*i:i/3),e*=-3}return e>20&&(e=20),-20>e&&(e=-20),e},CABLES.Browser=function(t){function e(t){i=!0,console.log("browser report canceled...")}var i=!1,r="hidden";r in document?document.addEventListener("visibilitychange",e):(r="mozHidden")in document?document.addEventListener("mozvisibilitychange",e):(r="webkitHidden")in document?document.addEventListener("webkitvisibilitychange",e):(r="msHidden")in document?document.addEventListener("msvisibilitychange",e):"onfocusin"in document?document.onfocusin=document.onfocusout=e:window.onpageshow=window.onpagehide=window.onfocus=window.onblur=e;var s={nVer:navigator.appVersion,nAgt:navigator.userAgent,browserName:navigator.appName,fullVersion:parseFloat(navigator.appVersion),majorVersion:parseInt(navigator.appVersion,10),lang:navigator.language,platform:navigator.platform,sizeScreen:[window.screen.availHeight,window.screen.availWidth],sizeWindow:[window.screen.height,window.screen.width]};this.sendReport=function(e){if(!i){if(!t)return void console.log("report canceled - no projectid");s.gl={renderer:"unknown",sizeCa
|
||
|
this._cgl.gl.vertexAttribDivisor(this._attributes[i].loc+1,0),this._cgl.gl.vertexAttribDivisor(this._attributes[i].loc+2,0),this._cgl.gl.vertexAttribDivisor(this._attributes[i].loc+3,0),this._cgl.gl.disableVertexAttribArray(this._attributes[i].loc+1),this._cgl.gl.disableVertexAttribArray(this._attributes[i].loc+2),this._cgl.gl.disableVertexAttribArray(this._attributes[i].loc+3))),-1!=this._attributes[i].loc&&this._cgl.gl.disableVertexAttribArray(this._attributes[i].loc)},CGL.Mesh.prototype.meshChanged=function(){return this._cgl.lastMesh&&this._cgl.lastMesh!=this},CGL.Mesh.hadError=!1,CGL.Mesh.prototype.printDebug=function(t){if(!CGL.Mesh.hadError){var e=this._cgl.gl.getError();if(e!=this._cgl.gl.NO_ERROR){CGL.Mesh.hadError=!0,e==this._cgl.gl.OUT_OF_MEMORY&&console.log("OUT_OF_MEMORY"),e==this._cgl.gl.INVALID_ENUM&&console.log("INVALID_ENUM"),e==this._cgl.gl.INVALID_OPERATION&&console.log("INVALID_OPERATION"),e==this._cgl.gl.INVALID_FRAMEBUFFER_OPERATION&&console.log("INVALID_FRAMEBUFFER_OPERATION"),e==this._cgl.gl.INVALID_VALUE&&console.log("INVALID_VALUE"),e==this._cgl.gl.CONTEXT_LOST_WEBGL&&console.log("CONTEXT_LOST_WEBGL"),e==this._cgl.gl.NO_ERROR&&console.log("NO_ERROR"),console.error("mesh error"),console.log("shader:",t.name),console.log("geom:",this._geom.name),console.log("verts:",this._geom.vertices.length),this._geom.tangents&&console.log("tangents:",this._geom.tangents.length),console.log("texCoords:",this._geom.texCoords.length),console.log("texCoords indizes:",this._geom.texCoordsIndices.length),console.log("indizes:",this._geom.verticesIndices.length);for(var i=0,r=0;r<this._geom.verticesIndices.length;r++)i=Math.max(this._geom.verticesIndices[r],i);console.log("max index",i),console.log("get error: ",e),t.printStats()}}},CGL.Mesh.prototype.setNumVertices=function(t){this._bufVertexAttrib.numItems=t},CGL.Mesh.prototype.render=function(t){if(t){t.wireframe&&this._geom.isIndexed()&&(console.log("unindex"),this._geom.unIndex(),this._geom.calcBaycentric(),this.setGeom(this._geom),this.setAttribute("attrBaycentric",this._geom.baycentrics,3));var e=!1;(CGL.MESH.lastMesh!=this||CGL.MESH.lastShader!=t)&&(e=!0,CGL.MESH.lastMesh&&CGL.MESH.lastShader&&CGL.MESH.lastMesh.unBind(CGL.MESH.lastShader)),CGL.MESH.lastMesh&&CGL.MESH.lastShader||(e=!0),e&&this._preBind(t),t.bind(),t.bindTextures&&t.bindTextures(),e&&this._bind(t),this.addVertexNumbers&&this._setVertexNumbers(),CGL.MESH.lastMesh=this,CGL.MESH.lastShader=t;var i=this._cgl.gl.TRIANGLES;void 0!==this._glPrimitive&&(i=this._glPrimitive),null!==t.glPrimitive&&(i=t.glPrimitive),this.hasFeedbacks()?this.drawFeedbacks(t,i):0===this._bufVerticesIndizes.numItems?this._cgl.gl.drawArrays(i,this._bufVertexAttrib.startItem,this._bufVertexAttrib.numItems-this._bufVertexAttrib.startItem):0===this.numInstances?this._cgl.gl.drawElements(i,this._bufVerticesIndizes.numItems,this._cgl.gl.UNSIGNED_SHORT,0):this._cgl.gl.drawElementsInstanced(i,this._bufVerticesIndizes.numItems,this._cgl.gl.UNSIGNED_SHORT,0,this.numInstances)}},CGL.Mesh.prototype.dispose=function(){},CGL.Mesh.prototype.hasFeedbacks=function(){return this._feedBacks.length>0},CGL.Mesh.prototype.removeFeedbacks=function(t){this._feedbacks&&(this._feedbacks.length=0,this._feedBacksChanged=!0)},CGL.Mesh.prototype.setAttributeFeedback=function(){},CGL.Mesh.prototype.setFeedback=function(t,e,i){var r={nameOut:e},s=!1;this.unBindFeedbacks();for(var n=0;n<this._feedBacks.length;n++)this._feedBacks[n].nameOut==e&&(r=this._feedBacks[n],s=!0);return s||(this._feedBacksChanged=!0),r.initialArr=i,r.attrib=t,r.outBuffer&&this._cgl.gl.deleteBuffer(r.outBuffer),r.outBuffer=this._cgl.gl.createBuffer(),this._cgl.gl.bindBuffer(this._cgl.gl.ARRAY_BUFFER,r.outBuffer),this._cgl.gl.bufferData(this._cgl.gl.ARRAY_BUFFER,r.initialArr,this._cgl.gl.STATIC_DRAW),this._cgl.gl.bindBuffer(this._cgl.gl.ARRAY_BUFFER,r.attrib.buffer),this._cgl.gl.bufferData(this._cgl.gl.ARRAY_BUFFER,r.initialArr,this._cgl.gl.STATIC_DRAW),s||this._feedBacks.push(r),r},CGL.Mesh.prototype.bindFeedback=function(t){if(this._feedBacks&&0!==this._feedBacks.length){-1==this.
|
||
|
|
||
|
}else if(this.textureType==CGL.Texture.TYPE_DEPTH){var r=this._cgl.gl.DEPTH_COMPONENT;1!=this._cgl.glVersion&&(r=this._cgl.gl.DEPTH_COMPONENT32F),this._cgl.gl.texImage2D(this.texTarget,0,r,t,e,0,this._cgl.gl.DEPTH_COMPONENT,this._cgl.gl.FLOAT,null)}else this._cgl.gl.texImage2D(this.texTarget,0,this._cgl.gl.RGBA,t,e,0,this._cgl.gl.RGBA,this._cgl.gl.UNSIGNED_BYTE,i);2!=this._cgl.glVersion&&!this.isPowerOfTwo()||this.filter!=CGL.Texture.FILTER_MIPMAP||this._cgl.gl.generateMipmap(this.texTarget),this._cgl.gl.bindTexture(this.texTarget,null)}},CGL.Texture.prototype.initFromData=function(t,e,i,r,s){this.filter=r,this.wrap=s,this.width=e,this.height=i,this._fromData=!0,this._cgl.gl.bindTexture(this.texTarget,this.tex),this._cgl.gl.texImage2D(this.texTarget,0,this._cgl.gl.RGBA,e,i,0,this._cgl.gl.RGBA,this._cgl.gl.UNSIGNED_BYTE,t),this._setFilter(),2!=this._cgl.glVersion&&!this.isPowerOfTwo()||this.filter!=CGL.Texture.FILTER_MIPMAP||this._cgl.gl.generateMipmap(this.texTarget),this._cgl.gl.bindTexture(this.texTarget,null)},CGL.Texture.prototype.initTexture=function(t,e){this._fromData=!1,e&&(this.unpackAlpha=e.unpackAlpha||this.unpackAlpha),this._cgl.gl.pixelStorei(this._cgl.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.unpackAlpha),t.width&&(this.width=t.width),t.height&&(this.height=t.height),e&&(this.filter=e),this._cgl.gl.bindTexture(this.texTarget,this.tex),this._cgl.gl.pixelStorei(this._cgl.gl.UNPACK_FLIP_Y_WEBGL,!this.flip),this._cgl.gl.texImage2D(this.texTarget,0,this._cgl.gl.RGBA,this._cgl.gl.RGBA,this._cgl.gl.UNSIGNED_BYTE,this.image),this._setFilter(),2!=this._cgl.glVersion&&!this.isPowerOfTwo()||this.filter!=CGL.Texture.FILTER_MIPMAP||this._cgl.gl.generateMipmap(this.texTarget),this._cgl.gl.bindTexture(this.texTarget,null),this._cgl.gl.pixelStorei(this._cgl.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1)},CGL.Texture.prototype["delete"]=function(){CGL.profileTextureDelete++,this._cgl.gl.deleteTexture(this.tex)},CGL.Texture.prototype.isPowerOfTwo=function(){return CGL.Texture.isPowerOfTwo(this.width)&&CGL.Texture.isPowerOfTwo(this.height)},CGL.Texture.prototype.printInfo=function(){console.log(this.getInfo())},CGL.Texture.prototype.getInfoReadable=function(){var t=this.getInfo(),e="";t.name=t.name.substr(0,t.name.indexOf("?rnd="));for(var i in t)e+="* "+i+": **"+t[i]+"**\n";return e},CGL.Texture.prototype.getInfo=function(){var t={};t.name=this.name,t["power of two"]=this.isPowerOfTwo(),t.size=this.width+" x "+this.height;var e=this.texTarget;return this.texTarget==this._cgl.gl.TEXTURE_2D&&(e="TEXTURE_2D"),t.target=e,t.unpackAlpha=this.unpackAlpha,t.textureType=this.textureType==CGL.Texture.TYPE_FLOAT?"TYPE_FLOAT":this.textureType==CGL.Texture.TYPE_DEPTH?"TYPE_DEPTH":this.textureType==CGL.Texture.TYPE_DEFAULT?"TYPE_DEFAULT":"UNKNOWN",t.wrap=this.wrap==CGL.Texture.WRAP_CLAMP_TO_EDGE?"CLAMP_TO_EDGE":this.wrap==CGL.Texture.WRAP_REPEAT?"WRAP_REPEAT":this.wrap==CGL.Texture.WRAP_MIRRORED_REPEAT?"WRAP_MIRRORED_REPEAT":"UNKNOWN",t.filter=this.filter==CGL.Texture.FILTER_NEAREST?"FILTER_NEAREST":this.filter==CGL.Texture.FILTER_LINEAR?"FILTER_LINEAR":this.filter==CGL.Texture.FILTER_MIPMAP?"FILTER_MIPMAP":"UNKNOWN",t},CGL.Texture.prototype._setFilter=function(){if(this._fromData||this._cgl.gl.pixelStorei(this._cgl.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.unpackAlpha),this.shadowMap&&(console.log("shadowmap tex"),this._cgl.gl.texParameteri(this._cgl.gl.TEXTURE_2D,this._cgl.gl.TEXTURE_COMPARE_MODE,this._cgl.gl.COMPARE_REF_TO_TEXTURE),this._cgl.gl.texParameteri(this._cgl.gl.TEXTURE_2D,this._cgl.gl.TEXTURE_COMPARE_FUNC,this._cgl.gl.LEQUAL)),1!=this._cgl.glVersion||this.isPowerOfTwo())if(this.wrap==CGL.Texture.WRAP_CLAMP_TO_EDGE&&(this._cgl.gl.texParameteri(this.texTarget,this._cgl.gl.TEXTURE_WRAP_S,this._cgl.gl.CLAMP_TO_EDGE),this._cgl.gl.texParameteri(this.texTarget,this._cgl.gl.TEXTURE_WRAP_T,this._cgl.gl.CLAMP_TO_EDGE)),this.wrap==CGL.Texture.WRAP_REPEAT&&(this._cgl.gl.texParameteri(this.texTarget,this._cgl.gl.TEXTURE_WRAP_S,this._cgl.gl.REPEAT),this._cgl.gl.texParameteri(this.texTarget,this._cgl.gl.TEXTURE_WRAP_T,this._cgl.gl.REPEAT)),this.wrap==CG
|
||
|
this.instancing=new CABLES.Instancing,this.onOneFrameRendered=null,this.config=t||{glCanvasResizeToWindow:!1,glCanvasId:"glcanvas",prefixAssetPath:"",silent:!1,onError:null,onFinishedLoading:null,onFirstFrameRendered:null,fpsLimit:0},this.config.prefixAssetPath||(this.config.prefixAssetPath=""),this.config.masterVolume||(this.config.masterVolume=1),this._variables={},this._variableListeners=[],this.vars={},t&&t.vars&&(this.vars=t.vars),this.cgl=new CGL.State,this.cgl.patch=this,this.cgl.setCanvas(this.config.glCanvasId),this.config.glCanvasResizeToWindow===!0&&this.cgl.setAutoResizeToWindow(!0),this.loading.setOnFinishedLoading(this.config.onFinishedLoading),this.cgl.aborted&&(this.aborted=!0),this.cgl.silent&&(this.silent=!0),this.freeTimer.play(),this.exec(),this.aborted||(this.config.patch?(this.deSerialize(this.config.patch),this.timer.play()):this.config.patchFile&&(CABLES.ajax(this.config.patchFile,function(t,e){var i=JSON.parse(e);if(t){return console.error("err",t),console.error("data",i),void console.error("data",i.msg)}this.deSerialize(i)}.bind(this)),this.timer.play()))},CABLES.Patch.prototype.isPlaying=function(){return!this._paused},CABLES.Patch.prototype.renderOneFrame=function(){this._paused=!0,this._renderOneFrame=!0,this.exec(),this._renderOneFrame=!1},CABLES.Patch.prototype.pause=function(){this._paused=!0,this.freeTimer.pause()},CABLES.Patch.prototype.resume=function(){this._paused&&(this._paused=!1,this.freeTimer.play(),this.exec())},CABLES.Patch.prototype.setVolume=function(t){this.config.masterVolume=t;for(var e=0;e<this._volumeListeners.length;e++)this._volumeListeners[e].onMasterVolumeChanged(t)},CABLES.Patch.prototype.getFilePath=function(t){if(!t)return t;if(0===t.indexOf("https:")||0===t.indexOf("http:"))return t;t=t.replace("//","/");var e=this.config.prefixAssetPath+t+(this.config.suffixAssetPath||"");return e},CABLES.Patch.prototype.clear=function(){for(this.cgl.TextureEffectMesh=null,this.animFrameOps.length=0,this.timer=new CABLES.Timer;this.ops.length>0;)this.deleteOp(this.ops[0].id)},CABLES.Patch.getOpClass=function(t){var e=t.split("."),i=null;try{return 2==e.length?i=window[e[0]][e[1]]:3==e.length?i=window[e[0]][e[1]][e[2]]:4==e.length?i=window[e[0]][e[1]][e[2]][e[3]]:5==e.length?i=window[e[0]][e[1]][e[2]][e[3]][e[4]]:6==e.length?i=window[e[0]][e[1]][e[2]][e[3]][e[4]][e[5]]:7==e.length?i=window[e[0]][e[1]][e[2]][e[3]][e[4]][e[5]][e[6]]:8==e.length?i=window[e[0]][e[1]][e[2]][e[3]][e[4]][e[5]][e[6]][e[7]]:9==e.length?i=window[e[0]][e[1]][e[2]][e[3]][e[4]][e[5]][e[6]][e[7]][e[8]]:10==e.length&&(i=window[e[0]][e[1]][e[2]][e[3]][e[4]][e[5]][e[6]][e[7]][e[8]][e[9]]),i}catch(r){return null}},CABLES.Patch.prototype.createOp=function(t){var e=t.split("."),i=null;try{var r=CABLES.Patch.getOpClass(t);if(!r)throw CABLES.UI&&CABLES.UI.MODAL.showError("unknown op","unknown op: "+t),console.error("unknown op: "+t),"unknown op: "+t;2==e.length?i=new window[e[0]][e[1]](this,t):3==e.length?i=new window[e[0]][e[1]][e[2]](this,t):4==e.length?i=new window[e[0]][e[1]][e[2]][e[3]](this,t):5==e.length?i=new window[e[0]][e[1]][e[2]][e[3]][e[4]](this,t):6==e.length?i=new window[e[0]][e[1]][e[2]][e[3]][e[4]][e[5]](this,t):7==e.length?i=new window[e[0]][e[1]][e[2]][e[3]][e[4]][e[5]][e[6]](this,t):8==e.length?i=new window[e[0]][e[1]][e[2]][e[3]][e[4]][e[5]][e[6]][e[7]](this,t):9==e.length?i=new window[e[0]][e[1]][e[2]][e[3]][e[4]][e[5]][e[6]][e[7]][e[8]](this,t):10==e.length?i=new window[e[0]][e[1]][e[2]][e[3]][e[4]][e[5]][e[6]][e[7]][e[8]][e[9]](this,t):console.log("parts.length",e.length)}catch(s){if(console.error("instancing error "+t),!CABLES.UI)throw CABLES.api&&CABLES.api.sendErrorReport(s),console.log(s),console.log(s.stacktrace),"instancing error "+t;CABLES.UI.MODAL.showOpException(s,t)}return i&&(i.objName=t,i.patch=this),i},CABLES.Patch.prototype.addOp=function(t,e){if(!t||-1==t.indexOf("."))return void CABLES.UI.MODAL.showError("could not create op","op unknown");var i=this.createOp(t);return i&&(i.uiAttr(e),i.onCreate&&i.onCreate(),i.hasOwnProperty("onAnimFrame")&&this.animFrameOps.push(i),i.hasOwnPro
|
||
|
|
||
|
},CABLES.TL.Anim.prototype.createPort=function(t,e,i){var r=t.addInPort(new Port(t,e,OP_PORT_TYPE_VALUE,{display:"dropdown",values:["linear","absolute","smoothstep","smootherstep","Cubic In","Cubic Out","Cubic In Out","Expo In","Expo Out","Expo In Out","Sin In","Sin Out","Sin In Out","Quart In","Quart Out","Quart In Out","Quint In","Quint Out","Quint In Out","Back In","Back Out","Back In Out","Elastic In","Elastic Out","Elastic In Out","Bounce In","Bounce Out"]}));return r.set("linear"),r.defaultValue="linear",r.onChange=function(){this.defaultEasing=this.easingFromString(r.get()),i&&i()}.bind(this),r},CABLES.TL.Anim.slerpQuaternion=function(t,e,i,r,s,n){CABLES.TL.Anim.slerpQuaternion.q1||(CABLES.TL.Anim.slerpQuaternion.q1=quat.create(),CABLES.TL.Anim.slerpQuaternion.q2=quat.create());var o=i.getKeyIndex(t),a=parseInt(i.getKeyIndex(t))+1;if(a>=i.keys.length&&(a=i.keys.length-1),o==a)quat.set(e,i.keys[o].value,r.keys[o].value,s.keys[o].value,n.keys[o].value);else{var h=i.keys[o].time,l=i.keys[a].time,u=(t-h)/(l-h);quat.set(CABLES.TL.Anim.slerpQuaternion.q1,i.keys[o].value,r.keys[o].value,s.keys[o].value,n.keys[o].value),quat.set(CABLES.TL.Anim.slerpQuaternion.q2,i.keys[a].value,r.keys[a].value,s.keys[a].value,n.keys[a].value),quat.slerp(e,CABLES.TL.Anim.slerpQuaternion.q1,CABLES.TL.Anim.slerpQuaternion.q2,u)}return e},CABLES=CABLES||{},CABLES.InertiaAnim=function(t){this._inVelocity=0,this._lastVal=0,this._lastTime=0,this.value=0,this._cb=t,this.INERTIA_SCROLL_FACTOR=3.5,this.INERTIA_ACCELERATION=.95,this._firstTime=!0,this.bounds=null},CABLES.InertiaAnim.prototype.updateSmooth=function(){this.value+=this._inVelocity*this.INERTIA_SCROLL_FACTOR,this._inVelocity*=this.INERTIA_ACCELERATION,this._cb&&this._cb(this.value),Math.abs(this._inVelocity)<.1&&(clearInterval(this._smoothInterval),this._inVelocity=0)},CABLES.InertiaAnim.prototype.get=function(){return this.value},CABLES.InertiaAnim.prototype.release=function(){clearInterval(this._smoothInterval),this._smoothInterval=setInterval(this.updateSmooth.bind(this),16.7),this._firstTime=!0},CABLES.InertiaAnim.prototype.set=function(t){this._firstTime&&(clearInterval(this._smoothInterval),this.value=t,this._lastTime=CABLES.now(),this._firstTime=!1);var e=t-this.value;this._inVelocity=e/(CABLES.now()-this._lastTime+1e-7),this.value=t,this._cb&&this._cb(this.value),this._lastTime=CABLES.now()},CABLES.LoadingStatus=function(){var t={},e=[],i=0;this.setOnFinishedLoading=function(t){e.push(t)},this.getProgress=function(){return i},this.checkStatus=function(){console.log("--------");var r=0,s=0;for(var n in t)s++,t[n].finished||(r++,console.log(t[n].type+": "+t[n].finished+": "+t[n].name));if(i=(s-r)/s,CGL.onLoadingAssetsFinished&&(console.error("CGL.onLoadingAssetsFinished is deprecated, please use config parameter onFinishedLoading with scene/patch constructor"),setTimeout(e,200)),0===r)for(var o=0;o<e.length;o++)setTimeout(e[o],200)},this.finished=function(e){t[e]&&(t[e].finished=!0),this.checkStatus()},this.start=function(e,i){var r=CABLES.generateUUID();return console.log("start loading",i),t[r]={id:r,type:e,name:i,finished:!1},r}},log=function(){Function.prototype.apply.apply(console.log,[console,arguments])},log.warn=function(){Function.prototype.apply.apply(console.warn,[console,arguments])};var CABLES=CABLES||{};CABLES.PACO_CLEAR=0,CABLES.PACO_VALUECHANGE=1,CABLES.PACO_OP_DELETE=2,CABLES.PACO_UNLINK=3,CABLES.PACO_LINK=4,CABLES.PACO_LOAD=5,CABLES.PACO_OP_CREATE=6,CABLES.PACO_OP_ENABLE=7,CABLES.PACO_OP_DISABLE=8,CABLES.togglePacoRenderer=function(){var t=CABLES.UI.userSettings.get("pacoRenderer")||!1;CABLES.UI.userSettings.set("pacoRenderer",!t),document.location.reload()},CABLES.showPacoRenderer=function(){},CABLES.PatchConnectionReceiver=function(t,e,i){this._patch=t,this.connector=i?i:new CABLES.PatchConnectorBroadcastChannel,this.connector.receive(this)},CABLES.PatchConnectionReceiver.prototype._receive=function(t){var e={};if(e=t.event?t:JSON.parse(t.data),e.event==CABLES.PACO_OP_CREATE){console.log("op create: data.vars.objName");var i=this._patch.addOp(e.vars.objName);i
|
||
|
//# sourceMappingURL=cables.min.js.map
|