UNPKG

tinyjs-plugin-mars

Version:
88 lines (77 loc) 592 kB
/*! * Name: tinyjs-plugin-mars * Description: The Tiny.js plugin for Mars * Author: zbr80259 * Version: v1.2.2 */ console.log('[tinyjs-plugin-mars]version:1.2.2'); if (window.Tiny && typeof window.Tiny.three === 'undefined') { console.warn('[mars-plugin]tiny3d not import, if it will be used, import tiny3d before mars plugin'); window.Tiny.three = { Container3D: function () { }, Transform3D: function () { }, }; } var mars = (function (exports, Tiny) { 'use strict'; function _interopNamespace(e) { if (e && e.__esModule) return e; var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); } n["default"] = e; return Object.freeze(n); } var Tiny__namespace = /*#__PURE__*/_interopNamespace(Tiny); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics$1 = function(d, b) { extendStatics$1 = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics$1(d, b); }; function __extends$1(d, b) { extendStatics$1(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign$1 = function() { __assign$1 = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign$1.apply(this, arguments); }; var prefix$1="[Mars Player]";var helpLink="https://yuque.antfin.com/huoxing/knaszl/qtnsf2g9ofigggor";var _log$1=console.log.bind(console);var _warn=console.warn.bind(console);var _error=console.error.bind(console);function inspectLogger(log,warn,error){if(log){_log$1=log;}if(warn){_warn=warn;}if(error){_error=error;}}function consoleLog$1(msg){for(var _len=arguments.length,data=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){data[_key-1]=arguments[_key];}_log$1.apply(void 0,[prefix$1+msg].concat(data));}function consoleWarn$1(msg){for(var _len2=arguments.length,data=new Array(_len2>1?_len2-1:0),_key2=1;_key2<_len2;_key2++){data[_key2-1]=arguments[_key2];}_warn.apply(void 0,[prefix$1+msg].concat(data));}function consoleError$1(msg){for(var _len3=arguments.length,data=new Array(_len3>1?_len3-1:0),_key3=1;_key3<_len3;_key3++){data[_key3-1]=arguments[_key3];}_error.apply(void 0,[prefix$1+msg].concat(data));}function _regeneratorRuntime(){_regeneratorRuntime=function(){return exports};var exports={},Op=Object.prototype,hasOwn=Op.hasOwnProperty,defineProperty=Object.defineProperty||function(obj,key,desc){obj[key]=desc.value;},$Symbol="function"==typeof Symbol?Symbol:{},iteratorSymbol=$Symbol.iterator||"@@iterator",asyncIteratorSymbol=$Symbol.asyncIterator||"@@asyncIterator",toStringTagSymbol=$Symbol.toStringTag||"@@toStringTag";function define(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}),obj[key]}try{define({},"");}catch(err){define=function(obj,key,value){return obj[key]=value};}function wrap(innerFn,outerFn,self,tryLocsList){var protoGenerator=outerFn&&outerFn.prototype instanceof Generator?outerFn:Generator,generator=Object.create(protoGenerator.prototype),context=new Context(tryLocsList||[]);return defineProperty(generator,"_invoke",{value:makeInvokeMethod(innerFn,self,context)}),generator}function tryCatch(fn,obj,arg){try{return {type:"normal",arg:fn.call(obj,arg)}}catch(err){return {type:"throw",arg:err}}}exports.wrap=wrap;var ContinueSentinel={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var IteratorPrototype={};define(IteratorPrototype,iteratorSymbol,(function(){return this}));var getProto=Object.getPrototypeOf,NativeIteratorPrototype=getProto&&getProto(getProto(values([])));NativeIteratorPrototype&&NativeIteratorPrototype!==Op&&hasOwn.call(NativeIteratorPrototype,iteratorSymbol)&&(IteratorPrototype=NativeIteratorPrototype);var Gp=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(IteratorPrototype);function defineIteratorMethods(prototype){["next","throw","return"].forEach((function(method){define(prototype,method,(function(arg){return this._invoke(method,arg)}));}));}function AsyncIterator(generator,PromiseImpl){function invoke(method,arg,resolve,reject){var record=tryCatch(generator[method],generator,arg);if("throw"!==record.type){var result=record.arg,value=result.value;return value&&"object"==typeof value&&hasOwn.call(value,"__await")?PromiseImpl.resolve(value.__await).then((function(value){invoke("next",value,resolve,reject);}),(function(err){invoke("throw",err,resolve,reject);})):PromiseImpl.resolve(value).then((function(unwrapped){result.value=unwrapped,resolve(result);}),(function(error){return invoke("throw",error,resolve,reject)}))}reject(record.arg);}var previousPromise;defineProperty(this,"_invoke",{value:function(method,arg){function callInvokeWithMethodAndArg(){return new PromiseImpl((function(resolve,reject){invoke(method,arg,resolve,reject);}))}return previousPromise=previousPromise?previousPromise.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}});}function makeInvokeMethod(innerFn,self,context){var state="suspendedStart";return function(method,arg){if("executing"===state)throw new Error("Generator is already running");if("completed"===state){if("throw"===method)throw arg;return doneResult()}for(context.method=method,context.arg=arg;;){var delegate=context.delegate;if(delegate){var delegateResult=maybeInvokeDelegate(delegate,context);if(delegateResult){if(delegateResult===ContinueSentinel)continue;return delegateResult}}if("next"===context.method)context.sent=context._sent=context.arg;else if("throw"===context.method){if("suspendedStart"===state)throw state="completed",context.arg;context.dispatchException(context.arg);}else "return"===context.method&&context.abrupt("return",context.arg);state="executing";var record=tryCatch(innerFn,self,context);if("normal"===record.type){if(state=context.done?"completed":"suspendedYield",record.arg===ContinueSentinel)continue;return {value:record.arg,done:context.done}}"throw"===record.type&&(state="completed",context.method="throw",context.arg=record.arg);}}}function maybeInvokeDelegate(delegate,context){var methodName=context.method,method=delegate.iterator[methodName];if(undefined===method)return context.delegate=null,"throw"===methodName&&delegate.iterator.return&&(context.method="return",context.arg=undefined,maybeInvokeDelegate(delegate,context),"throw"===context.method)||"return"!==methodName&&(context.method="throw",context.arg=new TypeError("The iterator does not provide a '"+methodName+"' method")),ContinueSentinel;var record=tryCatch(method,delegate.iterator,context.arg);if("throw"===record.type)return context.method="throw",context.arg=record.arg,context.delegate=null,ContinueSentinel;var info=record.arg;return info?info.done?(context[delegate.resultName]=info.value,context.next=delegate.nextLoc,"return"!==context.method&&(context.method="next",context.arg=undefined),context.delegate=null,ContinueSentinel):info:(context.method="throw",context.arg=new TypeError("iterator result is not an object"),context.delegate=null,ContinueSentinel)}function pushTryEntry(locs){var entry={tryLoc:locs[0]};1 in locs&&(entry.catchLoc=locs[1]),2 in locs&&(entry.finallyLoc=locs[2],entry.afterLoc=locs[3]),this.tryEntries.push(entry);}function resetTryEntry(entry){var record=entry.completion||{};record.type="normal",delete record.arg,entry.completion=record;}function Context(tryLocsList){this.tryEntries=[{tryLoc:"root"}],tryLocsList.forEach(pushTryEntry,this),this.reset(!0);}function values(iterable){if(iterable){var iteratorMethod=iterable[iteratorSymbol];if(iteratorMethod)return iteratorMethod.call(iterable);if("function"==typeof iterable.next)return iterable;if(!isNaN(iterable.length)){var i=-1,next=function next(){for(;++i<iterable.length;)if(hasOwn.call(iterable,i))return next.value=iterable[i],next.done=!1,next;return next.value=undefined,next.done=!0,next};return next.next=next}}return {next:doneResult}}function doneResult(){return {value:undefined,done:!0}}return GeneratorFunction.prototype=GeneratorFunctionPrototype,defineProperty(Gp,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),defineProperty(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,toStringTagSymbol,"GeneratorFunction"),exports.isGeneratorFunction=function(genFun){var ctor="function"==typeof genFun&&genFun.constructor;return !!ctor&&(ctor===GeneratorFunction||"GeneratorFunction"===(ctor.displayName||ctor.name))},exports.mark=function(genFun){return Object.setPrototypeOf?Object.setPrototypeOf(genFun,GeneratorFunctionPrototype):(genFun.__proto__=GeneratorFunctionPrototype,define(genFun,toStringTagSymbol,"GeneratorFunction")),genFun.prototype=Object.create(Gp),genFun},exports.awrap=function(arg){return {__await:arg}},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,asyncIteratorSymbol,(function(){return this})),exports.AsyncIterator=AsyncIterator,exports.async=function(innerFn,outerFn,self,tryLocsList,PromiseImpl){void 0===PromiseImpl&&(PromiseImpl=Promise);var iter=new AsyncIterator(wrap(innerFn,outerFn,self,tryLocsList),PromiseImpl);return exports.isGeneratorFunction(outerFn)?iter:iter.next().then((function(result){return result.done?result.value:iter.next()}))},defineIteratorMethods(Gp),define(Gp,toStringTagSymbol,"Generator"),define(Gp,iteratorSymbol,(function(){return this})),define(Gp,"toString",(function(){return "[object Generator]"})),exports.keys=function(val){var object=Object(val),keys=[];for(var key in object)keys.push(key);return keys.reverse(),function next(){for(;keys.length;){var key=keys.pop();if(key in object)return next.value=key,next.done=!1,next}return next.done=!0,next}},exports.values=values,Context.prototype={constructor:Context,reset:function(skipTempReset){if(this.prev=0,this.next=0,this.sent=this._sent=undefined,this.done=!1,this.delegate=null,this.method="next",this.arg=undefined,this.tryEntries.forEach(resetTryEntry),!skipTempReset)for(var name in this)"t"===name.charAt(0)&&hasOwn.call(this,name)&&!isNaN(+name.slice(1))&&(this[name]=undefined);},stop:function(){this.done=!0;var rootRecord=this.tryEntries[0].completion;if("throw"===rootRecord.type)throw rootRecord.arg;return this.rval},dispatchException:function(exception){if(this.done)throw exception;var context=this;function handle(loc,caught){return record.type="throw",record.arg=exception,context.next=loc,caught&&(context.method="next",context.arg=undefined),!!caught}for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i],record=entry.completion;if("root"===entry.tryLoc)return handle("end");if(entry.tryLoc<=this.prev){var hasCatch=hasOwn.call(entry,"catchLoc"),hasFinally=hasOwn.call(entry,"finallyLoc");if(hasCatch&&hasFinally){if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0);if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc)}else if(hasCatch){if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0)}else {if(!hasFinally)throw new Error("try statement without catch or finally");if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc)}}}},abrupt:function(type,arg){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc<=this.prev&&hasOwn.call(entry,"finallyLoc")&&this.prev<entry.finallyLoc){var finallyEntry=entry;break}}finallyEntry&&("break"===type||"continue"===type)&&finallyEntry.tryLoc<=arg&&arg<=finallyEntry.finallyLoc&&(finallyEntry=null);var record=finallyEntry?finallyEntry.completion:{};return record.type=type,record.arg=arg,finallyEntry?(this.method="next",this.next=finallyEntry.finallyLoc,ContinueSentinel):this.complete(record)},complete:function(record,afterLoc){if("throw"===record.type)throw record.arg;return "break"===record.type||"continue"===record.type?this.next=record.arg:"return"===record.type?(this.rval=this.arg=record.arg,this.method="return",this.next="end"):"normal"===record.type&&afterLoc&&(this.next=afterLoc),ContinueSentinel},finish:function(finallyLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.finallyLoc===finallyLoc)return this.complete(entry.completion,entry.afterLoc),resetTryEntry(entry),ContinueSentinel}},catch:function(tryLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc===tryLoc){var record=entry.completion;if("throw"===record.type){var thrown=record.arg;resetTryEntry(entry);}return thrown}}throw new Error("illegal catch attempt")},delegateYield:function(iterable,resultName,nextLoc){return this.delegate={iterator:values(iterable),resultName:resultName,nextLoc:nextLoc},"next"===this.method&&(this.arg=undefined),ContinueSentinel}},exports}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise((function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);}))}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,_toPropertyKey(descriptor.key),descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor}function _extends(){_extends=Object.assign?Object.assign.bind():function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target};return _extends.apply(this,arguments)}function _inheritsLoose(subClass,superClass){subClass.prototype=Object.create(superClass.prototype);subClass.prototype.constructor=subClass;_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(o,p){o.__proto__=p;return o};return _setPrototypeOf(o,p)}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _createForOfIteratorHelperLoose(o,allowArrayLike){var it=typeof Symbol!=="undefined"&&o[Symbol.iterator]||o["@@iterator"];if(it)return (it=it.call(o)).next.bind(it);if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;return function(){if(i>=o.length)return {done:true};return {done:false,value:o[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _toPrimitive(input,hint){if(typeof input!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(typeof res!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.")}return (hint==="string"?String:Number)(input)}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return typeof key==="symbol"?key:String(key)}var RENDER_PREFER_LOOKUP_TEXTURE="lookup_texture";var LOAD_PREFER_IMAGE_BITMAP="load_image_bitmap";var TEMPLATE_USE_OFFSCREEN_CANVAS="offscreen_canvas";if(typeof __MarsConfig__==="undefined"){if(typeof window==="object"){window.__MarsConfig__={};}else {global.__MarsConfig__={};}}var config=__MarsConfig__;function getConfig(name){return config[name]}function setConfig(name,value){return config[name]=value}var _objAssign=Object.assign;function objAssign(target,source1,source2,source3){var _arguments=arguments;if(_objAssign){return _objAssign.apply(this,arguments)}var _loop=function _loop(){var obj=_arguments[i];if(obj){Object.keys(obj).forEach((function(key){target[key]=obj[key];}));}};for(var i=1;i<arguments.length;i++){_loop();}return target}var imageBitMapAvailable$2=typeof createImageBitmap==="function";function closeImageBitMap$1(img){if(imageBitMapAvailable$2){if(img instanceof ImageBitmap){img.close();}else if(img instanceof Array){img.forEach(closeImageBitMap$1);}}}function loadImageAsync$1(img,noBitmap){var url;var revokeURL;if(img instanceof Blob){if(imageBitMapAvailable$2&&getConfig(LOAD_PREFER_IMAGE_BITMAP));url=URL.createObjectURL(img);revokeURL=true;}else if(imageBitMapAvailable$2&&img instanceof ImageBitmap);else if(img instanceof HTMLImageElement){if(img.complete){return Promise.resolve(img)}url=img.src;}else if(typeof img==="string"){url=img;}if(url){if(imageBitMapAvailable$2&&getConfig(LOAD_PREFER_IMAGE_BITMAP)&&!noBitmap){return requestAsync$1(url,{responseType:"blob"}).then((function(blob){return createImageBitmap(blob)})).catch((function(e){throw Error("load image fail:"+url)}))}var _img=new Image;if(!/^data:/.test(url)){_img.crossOrigin="*";}_img.src=url;return new Promise((function(resolve,reject){_img.onload=function(){_img.onload=null;if(revokeURL){URL.revokeObjectURL(url);}return resolve(_img)};_img.onerror=function(err){_img.onerror=null;if(revokeURL){URL.revokeObjectURL(url);}return reject(Error("load image fail:"+url))};}))}return Promise.reject(Error("invalid url type "+img))}function arrRemove$1(arr,ele){var idx=arr.indexOf(ele);if(idx>-1){arr.splice(idx,1);return true}return false}function arrAdd$1(arr,item){if(!arr.includes(item)){arr.push(item);return true}return false}var hasOwnProperty$1=Object.prototype.hasOwnProperty;function forEach$1(object,callback,thisObj){if(isObj$1(object)){if(thisObj===undefined){thisObj=object;}if(object instanceof Array||"length"in object){var len=object.length;for(var i=0;i<len;i++){callback.call(thisObj,object[i],i);}}else {for(var name in object){if(hasOwnProperty$1.call(object,name)){callback.call(thisObj,object[name],name);}}}}return object}function isFunc$1(any){return typeof any==="function"}function isObj$1(any){return typeof any==="object"&&any}function isStr$1(any){return typeof any==="string"}function noop$1(){}function random(min,max){return min+Math.random()*(max-min)}function randomArrItem(arr,keepArr){var index=Math.floor(Math.random()*arr.length);var item=arr[index];if(!keepArr){arr.splice(index,1);}return item}function requestAsync$1(url,opt){{opt=opt||{};return new Promise((function(resolve,reject){var xhr=new XMLHttpRequest;xhr.responseType=opt.responseType||"json";xhr.addEventListener("load",(function(){return resolve(xhr.response)}));xhr.addEventListener("error",(function(){return reject(Error("load "+url+" fail"))}));xhr.open(opt.method||"get",url);xhr.send(opt.data);}))}}function arrAddWithOrder(arr,item,property,descending){if(arr.includes(item)){return}arr.push(item);if(arr.length===1){return}var index=arr.length-1;if(index){var currentItem=arr[index];if(descending){while(arr[index-1][property]<currentItem[property]){arr[index]=arr[index-1];index--;if(index===0){break}}}else {while(arr[index-1][property]>currentItem[property]){arr[index]=arr[index-1];index--;if(index===0){break}}}arr[index]=currentItem;}}function deepClone(a){if(Array.isArray(a)){return a.map(deepClone)}else if(isObj$1(a)){if(ArrayBuffer.isView(a)){return a.slice()}var ret={};var kas=Object.keys(a);for(var i=0;i<kas.length;i++){var _key=kas[i];ret[_key]=deepClone(a[_key]);}return ret}return a}var toHalf=function(){var floatView=new Float32Array(1);var int32View=new Int32Array(floatView.buffer);return function toHalf(val){floatView[0]=val;var x=int32View[0];var bits=x>>16&32768;var m=x>>12&2047;var e=x>>23&255;if(e<103){return bits}if(e>142){bits|=31744;bits|=(e==255?0:1)&&x&8388607;return bits}if(e<113){m|=2048;bits|=(m>>114-e)+(m>>113-e&1);return bits}bits|=e-112<<10|m>>1;bits+=m&1;return bits}}();var Float16ArrayWrapper=function(){function Float16ArrayWrapper(num){if(Number.isInteger(num)){this.data=new Uint16Array(num);}else if(isObj$1(num)&&Number.isInteger(num.length)){var data=this.data=new Uint16Array(num.length);for(var i=0;i<data.length;i++){data[i]=toHalf(num[i]);}}}var _proto=Float16ArrayWrapper.prototype;_proto.set=function set(number,startIndex){for(var i=0;i<number.length;i++){this.data[i+startIndex]=toHalf(number[i]);}};return Float16ArrayWrapper}();function imageDataFromColor(color){if(isStr$1(color)){color=colorToArr(color);}var image=createImageData(1,1);var data=image.data;for(var i=0;i<4;i++){data[i]=color[i];}return image}function colorStopsFromGradient(gradient){var stops=[];if(gradient instanceof Array){gradient.forEach((function(val){var s=val[0],r=val[1],g=val[2],b=val[3],a=val[4];stops.push({stop:parsePercent(s),color:[r,g,b,a]});}));}else {forEach$1(gradient,(function(colorRGB,stop){var color=colorToArr(colorRGB);stops.push({stop:parsePercent(stop),color:color});}));}stops=stops.sort((function(a,b){return a.stop-b.stop}));if(stops.length){if(stops[0].stop!==0){stops.unshift({stop:0,color:stops[0].color.slice()});}var lastStop=stops[stops.length-1];if(lastStop.stop!==1){stops.push({stop:1,color:lastStop.color.slice()});}}return stops}function createImageData(width,height){return {width:width,height:height,data:new Uint8Array(width*height*4)}}function getColorFromGradientStops(stops,key,normalize){if(stops.length){var _color;for(var j=1;j<=stops.length-1;j++){var s0=stops[j-1];var s1=stops[j];if(s0.stop<=key&&key<=s1.stop){_color=interpolateColor(s0.color,s1.color,(key-s0.stop)/(s1.stop-s0.stop));break}}if(!_color){_color=stops[stops.length-1].color;}return normalize?_color.map((function(n){return n/255})):_color}return [0,0,0,0]}function imageDataFromGradient(gradient){var width=128;var image=createImageData(width,1);var data=image.data;var stops=colorStopsFromGradient(gradient);if(stops.length){data.set(stops[0].color,0);for(var i=1,cursor=0;i<width-1;i++){var index=i/width;var s0=void 0,s1=void 0;for(var j=cursor;j<stops.length;j++){s0=stops[j];s1=stops[j+1];if(s0.stop<=index&&s1.stop>index){break}}var _color2=interpolateColor(s0.color,s1.color,(index-s0.stop)/(s1.stop-s0.stop));data.set(_color2,i*4);}data.set(stops[stops.length-1].color,(width-1)*4);}return image}function interpolateColor(a,b,s,origin){var ret=[];var ms=1-s;if(origin){for(var i=0;i<4;i++){ret[i]=a[i]*ms+b[i]*s;}}else {for(var _i2=0;_i2<3;_i2++){ret[_i2]=Math.round(Math.sqrt(a[_i2]*a[_i2]*ms+b[_i2]*b[_i2]*s));}ret[3]=Math.round(a[3]*ms+b[3]*s);}return ret}function colorToArr(hex,normalized){var ret;if(isStr$1(hex)){hex=hex.replace(/[\s\t\r\n]/g,"");var m=/rgba?\(([.\d]+),([.\d]+),([.\d]+),?([.\d]+)?\)/.exec(hex);if(m){var _a=+m[4];ret=[+m[1],+m[2],+m[3],isNaN(_a)?255:_a*255];}else if(/^#[a-f\d]{3}$/i.test(hex)){ret=[parseInt(hex[1]+hex[1],16),parseInt(hex[2]+hex[2],16),parseInt(hex[3]+hex[3],16),255];}else if(m=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)){ret=[parseInt(m[1],16),parseInt(m[2],16),parseInt(m[3],16),255]||[0,0,0,255];}}else if(hex instanceof Array){ret=[hex[0],hex[1],hex[2],isNaN(hex[3])?255:hex[3]];}if(normalized){for(var i=0;i<4;i++){ret[i]/=255;}}return ret}function parsePercent(c){var match=/^(-)?([\d+.]+)%$/.exec(c);if(match){return +match[2]/100*(match[1]?-1:1)}return +c} /*! * Name: @ali/specification * Description: Mars JSON Specification * Author: zbr80259@alibaba-inc.com * Version: v1.6.10 */var RenderLevel;(function(RenderLevel){RenderLevel["S"]="S";RenderLevel["APlus"]="A+";RenderLevel["A"]="A";RenderLevel["BPlus"]="B+";RenderLevel["B"]="B";})(RenderLevel||(RenderLevel={}));var BlendingMode;(function(BlendingMode){BlendingMode[BlendingMode["alpha"]=0]="alpha";BlendingMode[BlendingMode["ADD"]=1]="ADD";BlendingMode[BlendingMode["MULTIPLY"]=2]="MULTIPLY";BlendingMode[BlendingMode["BRIGHTNESS"]=3]="BRIGHTNESS";BlendingMode[BlendingMode["SUBTRACTION"]=4]="SUBTRACTION";BlendingMode[BlendingMode["STRONG_LIGHT"]=5]="STRONG_LIGHT";BlendingMode[BlendingMode["WEAK_LIGHT"]=6]="WEAK_LIGHT";BlendingMode[BlendingMode["SUPERPOSITION"]=7]="SUPERPOSITION";})(BlendingMode||(BlendingMode={}));var SideMode;(function(SideMode){SideMode[SideMode["DOUBLE"]=1032]="DOUBLE";SideMode[SideMode["FRONT"]=1028]="FRONT";SideMode[SideMode["BACK"]=1029]="BACK";})(SideMode||(SideMode={}));var MaskMode;(function(MaskMode){MaskMode[MaskMode["NONE"]=0]="NONE";MaskMode[MaskMode["MASK"]=1]="MASK";MaskMode[MaskMode["OBSCURED"]=2]="OBSCURED";MaskMode[MaskMode["REVERSE_OBSCURED"]=3]="REVERSE_OBSCURED";})(MaskMode||(MaskMode={}));var ShapeType;(function(ShapeType){ShapeType[ShapeType["NONE"]=0]="NONE";ShapeType[ShapeType["SPHERE"]=1]="SPHERE";ShapeType[ShapeType["CONE"]=2]="CONE";ShapeType[ShapeType["HEMISPHERE"]=3]="HEMISPHERE";ShapeType[ShapeType["CIRCLE"]=4]="CIRCLE";ShapeType[ShapeType["DONUT"]=5]="DONUT";ShapeType[ShapeType["RECTANGLE"]=6]="RECTANGLE";ShapeType[ShapeType["RECTANGLE_EDGE"]=7]="RECTANGLE_EDGE";ShapeType[ShapeType["RECTANGLEEDGE"]=7]="RECTANGLEEDGE";ShapeType[ShapeType["EDGE"]=8]="EDGE";ShapeType[ShapeType["TEXTURE"]=9]="TEXTURE";})(ShapeType||(ShapeType={}));var PluginType;(function(PluginType){PluginType[PluginType["GYROSCOPE"]=0]="GYROSCOPE";PluginType[PluginType["SPINE"]=1]="SPINE";})(PluginType||(PluginType={}));var InteractType;(function(InteractType){InteractType[InteractType["CLICK"]=0]="CLICK";InteractType[InteractType["MESSAGE"]=1]="MESSAGE";InteractType[InteractType["DRAG"]=2]="DRAG";})(InteractType||(InteractType={}));var InteractBehavior;(function(InteractBehavior){InteractBehavior[InteractBehavior["NONE"]=0]="NONE";InteractBehavior[InteractBehavior["NOTIFY"]=1]="NOTIFY";InteractBehavior[InteractBehavior["RESUME_PLAYER"]=2]="RESUME_PLAYER";InteractBehavior[InteractBehavior["REMOVE"]=3]="REMOVE";InteractBehavior[InteractBehavior["PAUSE"]=4]="PAUSE";})(InteractBehavior||(InteractBehavior={}));var ItemType;(function(ItemType){ItemType["base"]="0";ItemType["sprite"]="1";ItemType["particle"]="2";ItemType["null"]="3";ItemType["interact"]="4";ItemType["plugin"]="5";ItemType["camera"]="6";ItemType["composition"]="7";ItemType["filter"]="8";ItemType["spine"]="spine";})(ItemType||(ItemType={}));var RenderMode;(function(RenderMode){RenderMode[RenderMode["BILLBOARD"]=0]="BILLBOARD";RenderMode[RenderMode["MESH"]=1]="MESH";RenderMode[RenderMode["VERTICAL_BILLBOARD"]=2]="VERTICAL_BILLBOARD";RenderMode[RenderMode["HORIZONTAL_BILLBOARD"]=3]="HORIZONTAL_BILLBOARD";})(RenderMode||(RenderMode={}));var ParticleOrigin;(function(ParticleOrigin){ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_CENTER"]=0]="PARTICLE_ORIGIN_CENTER";ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_LEFT_TOP"]=1]="PARTICLE_ORIGIN_LEFT_TOP";ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_LEFT_CENTER"]=2]="PARTICLE_ORIGIN_LEFT_CENTER";ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_LEFT_BOTTOM"]=3]="PARTICLE_ORIGIN_LEFT_BOTTOM";ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_CENTER_TOP"]=4]="PARTICLE_ORIGIN_CENTER_TOP";ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_CENTER_BOTTOM"]=5]="PARTICLE_ORIGIN_CENTER_BOTTOM";ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_RIGHT_TOP"]=6]="PARTICLE_ORIGIN_RIGHT_TOP";ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_RIGHT_CENTER"]=7]="PARTICLE_ORIGIN_RIGHT_CENTER";ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_RIGHT_BOTTOM"]=8]="PARTICLE_ORIGIN_RIGHT_BOTTOM";})(ParticleOrigin||(ParticleOrigin={}));var END_BEHAVIOR_DESTROY$1=0;var END_BEHAVIOR_PAUSE$1=1;var END_BEHAVIOR_FORWARD$1=2;var END_BEHAVIOR_PAUSE_AND_DESTROY$1=3;var END_BEHAVIOR_FREEZE$1=4;var END_BEHAVIOR_RESTART$1=5;var END_BEHAVIOR_DESTROY_CHILDREN$1=6;var CAMERA_CLIP_MODE_VERTICAL$1=1;var CAMERA_CLIP_MODE_NORMAL$1=0;var CameraClipMode;(function(CameraClipMode){CameraClipMode[CameraClipMode["portrait"]=CAMERA_CLIP_MODE_VERTICAL$1]="portrait";CameraClipMode[CameraClipMode["landscape"]=CAMERA_CLIP_MODE_NORMAL$1]="landscape";})(CameraClipMode||(CameraClipMode={}));var CompositionEndBehavior;(function(CompositionEndBehavior){CompositionEndBehavior[CompositionEndBehavior["destroy"]=END_BEHAVIOR_DESTROY$1]="destroy";CompositionEndBehavior[CompositionEndBehavior["pause"]=END_BEHAVIOR_PAUSE$1]="pause";CompositionEndBehavior[CompositionEndBehavior["restart"]=END_BEHAVIOR_RESTART$1]="restart";CompositionEndBehavior[CompositionEndBehavior["forward"]=END_BEHAVIOR_FORWARD$1]="forward";CompositionEndBehavior[CompositionEndBehavior["pause_destroy"]=END_BEHAVIOR_PAUSE_AND_DESTROY$1]="pause_destroy";})(CompositionEndBehavior||(CompositionEndBehavior={}));var TextOverflow;(function(TextOverflow){TextOverflow[TextOverflow["display"]=0]="display";TextOverflow[TextOverflow["clip"]=1]="clip";TextOverflow[TextOverflow["ellipsis"]=2]="ellipsis";})(TextOverflow||(TextOverflow={}));var TextAlignment;(function(TextAlignment){TextAlignment[TextAlignment["left"]=0]="left";TextAlignment[TextAlignment["middle"]=1]="middle";TextAlignment[TextAlignment["right"]=2]="right";})(TextAlignment||(TextAlignment={}));var FontStyle;(function(FontStyle){FontStyle[FontStyle["normal"]=0]="normal";FontStyle[FontStyle["italic"]=1]="italic";FontStyle[FontStyle["oblique"]=2]="oblique";})(FontStyle||(FontStyle={}));var ValueType;(function(ValueType){ValueType[ValueType["CONSTANT"]=0]="CONSTANT";ValueType[ValueType["CONSTANT_VEC2"]=1]="CONSTANT_VEC2";ValueType[ValueType["CONSTANT_VEC3"]=2]="CONSTANT_VEC3";ValueType[ValueType["CONSTANT_VEC4"]=3]="CONSTANT_VEC4";ValueType[ValueType["RANDOM"]=4]="RANDOM";ValueType[ValueType["LINE"]=5]="LINE";ValueType[ValueType["CURVE"]=6]="CURVE";ValueType[ValueType["BEZIER_PATH"]=7]="BEZIER_PATH";ValueType[ValueType["RGBA_COLOR"]=8]="RGBA_COLOR";ValueType[ValueType["GRADIENT_COLOR"]=9]="GRADIENT_COLOR";ValueType[ValueType["SHAPE_POINTS"]=10]="SHAPE_POINTS";ValueType[ValueType["SHAPE_SPLITS"]=11]="SHAPE_SPLITS";ValueType[ValueType["LINEAR_PATH"]=12]="LINEAR_PATH";ValueType[ValueType["COLORS"]=13]="COLORS";ValueType[ValueType["BINARY"]=20]="BINARY";})(ValueType||(ValueType={}));var ItemEndBehavior;(function(ItemEndBehavior){ItemEndBehavior[ItemEndBehavior["destroy"]=END_BEHAVIOR_DESTROY$1]="destroy";ItemEndBehavior[ItemEndBehavior["loop"]=END_BEHAVIOR_RESTART$1]="loop";ItemEndBehavior[ItemEndBehavior["forward"]=END_BEHAVIOR_FREEZE$1]="forward";})(ItemEndBehavior||(ItemEndBehavior={}));var ParentItemEndBehavior;(function(ParentItemEndBehavior){ParentItemEndBehavior[ParentItemEndBehavior["destroyChildren"]=END_BEHAVIOR_DESTROY_CHILDREN$1]="destroyChildren";})(ParentItemEndBehavior||(ParentItemEndBehavior={}));var ParticleInteractionBehavior;(function(ParticleInteractionBehavior){ParticleInteractionBehavior[ParticleInteractionBehavior["none"]=0]="none";ParticleInteractionBehavior[ParticleInteractionBehavior["removeParticle"]=1]="removeParticle";})(ParticleInteractionBehavior||(ParticleInteractionBehavior={}));var ShapeArcMode;(function(ShapeArcMode){ShapeArcMode[ShapeArcMode["RANDOM"]=0]="RANDOM";ShapeArcMode[ShapeArcMode["UNIDIRECTIONAL_CYCLE"]=1]="UNIDIRECTIONAL_CYCLE";ShapeArcMode[ShapeArcMode["BIDIRECTIONAL_CYCLE"]=2]="BIDIRECTIONAL_CYCLE";ShapeArcMode[ShapeArcMode["UNIFORM_BURST"]=3]="UNIFORM_BURST";})(ShapeArcMode||(ShapeArcMode={}));var ModelBoundingType;(function(ModelBoundingType){ModelBoundingType[ModelBoundingType["box"]=2]="box";ModelBoundingType[ModelBoundingType["sphere"]=3]="sphere";})(ModelBoundingType||(ModelBoundingType={}));var MaterialType;(function(MaterialType){MaterialType["unlit"]="unlit";MaterialType["pbr"]="pbr";MaterialType["hair"]="hair";})(MaterialType||(MaterialType={}));var MaterialBlending;(function(MaterialBlending){MaterialBlending[MaterialBlending["opaque"]=100]="opaque";MaterialBlending[MaterialBlending["masked"]=101]="masked";MaterialBlending[MaterialBlending["translucent"]=102]="translucent";MaterialBlending[MaterialBlending["additive"]=103]="additive";})(MaterialBlending||(MaterialBlending={}));var RenderMode3D;(function(RenderMode3D){RenderMode3D["none"]="none";RenderMode3D["uv"]="uv";RenderMode3D["normal"]="normal";RenderMode3D["basecolor"]="basecolor";RenderMode3D["alpha"]="alpha";RenderMode3D["metallic"]="metallic";RenderMode3D["roughness"]="roughness";RenderMode3D["ao"]="ao";RenderMode3D["emissive"]="emissive";})(RenderMode3D||(RenderMode3D={}));var NOT_IMPLEMENT="not_implement";var map$2={[ValueType.RANDOM](props){if(props[0]instanceof Array){return new RandomVectorValue(props)}return new RandomValue(props)},[ValueType.CONSTANT](props){return new StaticValue(props)},[ValueType.CONSTANT_VEC2](props){return new StaticValue(props)},[ValueType.CONSTANT_VEC3](props){return new StaticValue(props)},[ValueType.CONSTANT_VEC4](props){return new StaticValue(props)},[ValueType.CURVE](props){return new CurveValue(props)},[ValueType.RGBA_COLOR](props){return new StaticValue(props)},[ValueType.COLORS](props){return new RandomSetValue(props.map((function(c){return colorToArr(c,false)})))},[ValueType.LINE](props){if(props.length===2&&props[0][0]===0&&props[1][0]===1){return new LinearValue([props[0][1],props[1][1]])}return new LineSegments(props)},[ValueType.GRADIENT_COLOR](props){return new GradientValue(props)},[ValueType.LINEAR_PATH](pros){return new PathSegments(pros)},[ValueType.BEZIER_PATH](pros){return new BezierSegments(pros)}};function createValueGetter(args){if(!args||!isNaN(+args)){return new StaticValue(args||0)}if(args instanceof ValueGetter){return args}return map$2[args[0]](args[1])}var ValueGetter=function(){function ValueGetter(arg){this.onCreate(arg);}var _proto=ValueGetter.prototype;_proto.onCreate=function onCreate(props){throw Error(NOT_IMPLEMENT)};_proto.getIntegrateValue=function getIntegrateValue(t0,t1,timeScale){throw Error(NOT_IMPLEMENT)};_proto.getIntegrateByTime=function getIntegrateByTime(t0,time){throw Error(NOT_IMPLEMENT)};_proto.getValue=function getValue(time){throw Error(NOT_IMPLEMENT)};_proto.toUniform=function toUniform(meta){throw Error(NOT_IMPLEMENT)};_proto.map=function map(func){throw Error(NOT_IMPLEMENT)};_proto.scaleXCoord=function scaleXCoord(scale){return this};return ValueGetter}();var StaticValue=function(_ValueGetter){_inheritsLoose(StaticValue,_ValueGetter);function StaticValue(){return _ValueGetter.apply(this,arguments)||this}var _proto2=StaticValue.prototype;_proto2.onCreate=function onCreate(arg){this._value=arg;};_proto2.getIntegrateValue=function getIntegrateValue(t0,t1,ts){return this._value*(t1-t0)};_proto2.getIntegrateByTime=function getIntegrateByTime(t0,t1){return .5*this._value*(t1*t1-t0*t0)};_proto2.getValue=function getValue(time){return this._value};_proto2.toUniform=function toUniform(meta){return new Float32Array([0,this._value,0,0])};_proto2.map=function map(func){var val=this._value;this._value=func(val);return this};return StaticValue}(ValueGetter);var RandomSetValue=function(_ValueGetter2){_inheritsLoose(RandomSetValue,_ValueGetter2);function RandomSetValue(){return _ValueGetter2.apply(this,arguments)||this}var _proto3=RandomSetValue.prototype;_proto3.onCreate=function onCreate(arg){this._items=arg;};_proto3.getValue=function getValue(t){var items=this._items;return items[Math.floor(Math.random()*items.length)]};_proto3.map=function map(func){this._items=this._items.map(func);return this};return RandomSetValue}(ValueGetter);var RandomValue=function(_ValueGetter3){_inheritsLoose(RandomValue,_ValueGetter3);function RandomValue(){return _ValueGetter3.apply(this,arguments)||this}var _proto4=RandomValue.prototype;_proto4.onCreate=function onCreate(props){this._min=props[0];this._max=props[1];};_proto4.getValue=function getValue(time){return random(this._min,this._max)};_proto4.toUniform=function toUniform(meta){return new Float32Array([4,this._min,this._max,0])};_proto4.map=function map(func){this._min=func(this._min);this._max=func(this._max);return this};return RandomValue}(ValueGetter);var RandomVectorValue=function(_ValueGetter4){_inheritsLoose(RandomVectorValue,_ValueGetter4);function RandomVectorValue(){return _ValueGetter4.apply(this,arguments)||this}var _proto5=RandomVectorValue.prototype;_proto5.onCreate=function onCreate(props){this._min=props[0];this._max=props[1];};_proto5.getValue=function getValue(time){var min=this._min;var max=this._max;var ret=[];for(var i=0;i<min.length;i++){var t=Math.random();ret[i]=min[i]*(1-t)+max[i]*t;}return ret};_proto5.map=function map(func){this._min=this._min.map(func);this._max=this._max.map(func);return this};return RandomVectorValue}(ValueGetter);var LinearValue=function(_ValueGetter5){_inheritsLoose(LinearValue,_ValueGetter5);function LinearValue(){return _ValueGetter5.apply(this,arguments)||this}var _proto6=LinearValue.prototype;_proto6.onCreate=function onCreate(props){this._min=props[0];this._max=props[1];this._xCoord=1;};_proto6.getValue=function getValue(t){t/=this._xCoord;return this._min*(1-t)+this._max*t};_proto6.toUniform=function toUniform(){return new Float32Array([1,this._min,this._max,this._xCoord])};_proto6.getIntegrateValue=function getIntegrateValue(t0,t1,timeScale){var min=this._min;var max=this._max;var ts=this._xCoord*(timeScale||1);var v1=min+(max-min)*(t1/ts);var v0=min+(max-min)*(t0/ts);return ((v1+min)*t1-(v0+min)*t0)/2};_proto6.getIntegrateByTime=function getIntegrateByTime(t0,t1){return lineSegIntegrateByTime(t1,0,this._xCoord,this._min,this._max)-lineSegIntegrateByTime(t0,0,this._xCoord,this._min,this._max)};_proto6.map=function map(func){this._min=func(this._min);this._max=func(this._max);return this};_proto6.scaleXCoord=function scaleXCoord(scale){this._xCoord=scale;return this};return LinearValue}(ValueGetter);var GradientValue=function(_ValueGetter6){_inheritsLoose(GradientValue,_ValueGetter6);function GradientValue(){return _ValueGetter6.apply(this,arguments)||this}var _proto7=GradientValue.prototype;_proto7.onCreate=function onCreate(props){this.stops=colorStopsFromGradient(props);};_proto7.getStops=function getStops(){return this.stops};_proto7.getValue=function getValue(time){var stops=this.stops;var last=stops.length-1;for(var i=0;i<last;i++){var a=stops[i];var b=stops[i+1];if(a.stop<=time&&b.stop>time){var t=(time-a.stop)/(b.stop-a.stop);return interpolateColor(a.color,b.color,t,true)}}return stops[last].color.slice()};return GradientValue}(ValueGetter);var CURVE_PRO_TIME=0;var CURVE_PRO_VALUE=1;var CURVE_PRO_IN_TANGENT=2;var CURVE_PRO_OUT_TANGENT=3;var CurveValue=function(_ValueGetter7){_inheritsLoose(CurveValue,_ValueGetter7);function CurveValue(){return _ValueGetter7.apply(this,arguments)||this}CurveValue.getAllData=function getAllData(meta,halfFloat){var ret=new(halfFloat?Float16ArrayWrapper:Float32Array)(meta.index*4);for(var i=0,cursor=0,curves=meta.curves;i<curves.length;i++){var data=curves[i].toData();ret.set(data,cursor);cursor+=data.length;}return halfFloat?ret.data:ret};var _proto8=CurveValue.prototype;_proto8.onCreate=function onCreate(props){var min=Infinity;var max=-Infinity;if(Number.isFinite(props[0])&&Number.isFinite(props[1])){var keys=[];for(var i=2;i<props.length;i++){keys.push(props[i].slice(0,4));}this.keys=keys;this.min=props[0];this.dist=props[1]-props[0];}else {var _keys=this.keys=props.map((function(item){if(item instanceof Array){min=Math.min(min,item[1]);max=Math.max(max,item[1]);return item.slice(0,4)}else if(isObj$1(item)){min=Math.min(min,item.value);max=Math.max(max,item.value);return [item.time,item.value,item.inTangent||0,item.outTangent||0]}throw Error("invalid keyframe")}));var dist=max-min;if(dist!==0){for(var _i2=0;_i2<_keys.length;_i2++){var key=_keys[_i2];key[1]=(key[1]-min)/dist;}}var key0=_keys[0];if(key0[0]>0){key0[2]=0;_keys.unshift([0,key0[1],0,0]);}var key1=_keys[_keys.length-1];if(key1[0]<1){key1[3]=0;_keys.push([1,key1[1],0,0]);}this.min=min;this.dist=dist;}this.isCurveValue=true;};_proto8.getValue=function getValue(time){var keys=this.keys,min=this.min,dist=this.dist;if(time<=keys[0][CURVE_PRO_TIME]){return keys[0][CURVE_PRO_VALUE]*dist+min}var end=keys.length-1;for(var i=0;i<end;i++){var key=keys[i];var k2=keys[i+1];if(time>key[CURVE_PRO_TIME]&&time<=k2[CURVE_PRO_TIME]){return curveValueEvaluate(time,key,k2)*dist+min}}return keys[end][CURVE_PRO_VALUE]*dist+min};_proto8.getIntegrateByTime=function getIntegrateByTime(t0,t1){var d=this._integrate(t1,true)-this._integrate(t0,true);return this.min*.5*(t1-t0)*(t1-t0)+d*this.dist};_proto8.getIntegrateValue=function getIntegrateValue(t0,t1,ts){ts=ts||1;var d=(this._integrate(t1/ts,false)-this._integrate(t0/ts,false))*ts;var dt=(t1-t0)/ts;return this.min*dt+d*this.dist};_proto8._integrate=function _integrate(time,byTime){var keys=this.keys;if(time<=keys[0][CURVE_PRO_TIME]){return 0}var ret=0;var end=keys.length-1;var func=byTime?curveValueIntegrateByTime:curveValueIntegrate;for(var i=0;i<end;i++){var key=keys[i];var k2=keys[i+1];var t1=key[CURVE_PRO_TIME];var t2=k2[CURVE_PRO_TIME];if(time>t1&&time<=t2){return ret+func(time,key,k2)}else {ret+=func(t2,key,k2);}}return ret};_proto8.toData=function toData(){var keys=this.keys;var data=new Float32Array(keys.length*4);for(var i=0,cursor=0;i<keys.length;i++,cursor+=4){data.set(keys[i],cursor);}return data};_proto8.toUniform=function toUniform(meta){var index=meta.index;var keys=this.keys;meta.curves.push(this);meta.index+=keys.length;meta.max=Math.max(meta.max,keys.length);meta.curveCount+=keys.length;return new Float32Array([2,index+1/keys.length,this.min,this.dist])};_proto8.map=function map(func){this.keys.forEach((function(k){k[CURVE_PRO_VALUE]=func(k[CURVE_PRO_VALUE]);}));return this};_proto8.scaleXCoord=function scaleXCoord(scale){this.keys.forEach((function(k){return k[CURVE_PRO_TIME]=scale*k[CURVE_PRO_TIME]}));return this};return CurveValue}(ValueGetter);var LineSegments=function(_ValueGetter8){_inheritsLoose(LineSegments,_ValueGetter8);function LineSegments(){return _ValueGetter8.apply(this,arguments)||this}var _proto9=LineSegments.prototype;_proto9.onCreate=function onCreate(props){var keys=this.keys=props.map((function(p){if(p.slice){return p.slice(0,2)}return [p.time,p.value]})).sort((function(a,b){return a[0]-b[0]}));var last=keys[keys.length-1];if(last[0]<1){keys.push([1,last[1]]);}var first=keys[0];if(first[0]>0){keys.unshift([0,first[1]]);}this.isLineSeg=true;};_proto9.getValue=function getValue(time){var keys=this.keys;if(time<keys[0][0]){return keys[0][1]}var end=keys.length-1;for(var i=0;i<end;i++){var key=keys[i];var k2=keys[i+1];var x0=key[0];var x1=k2[0];if(time>=x0&&time<=x1){var p=(time-x0)/(x1-x0);var y0=key[1];return y0+p*(k2[1]-y0)}}return keys[end][1]};_proto9.getIntegrateValue=function getIntegrateValue(t0,t1,ts){if(ts===void 0){ts=1;}return (this._integrate(t1,false)-this._integrate(t0,false))*ts};_proto9.getIntegrateByTime=function getIntegrateByTime(t0,t1){return this._integrate(t1,true)-this._integrate(t0,true)};_proto9._integrate=function _integrate(time,byTime){var keys=this.keys;if(time<=keys[0][0]){return 0}var ret=0;var end=keys.length-1;var func=byTime?lineSegIntegrateByTime:lineSegIntegrate;for(var i=0;i<end;i++){var k1=keys[i];var k2=keys[i+1];var t0=k1[0];var t1=k2[0];if(time>t0&&time<=t1){return ret+func(time,t0,t1,k1[1],k2[1])}else {ret+=func(t1,t0,t1,k1[1],k2[1]);}}return ret};_proto9.toData=function toData(){var keys=this.keys;var data=new Float32Array(Math.ceil(keys.length/2)*4);for(var i=0,cursor=0;i<keys.length;i++,cursor+=2){data.set(keys[i],cursor);}data.set(keys[keys.length-1],data.length-2);return data};_proto9.toUniform=function toUniform(meta){var index=meta.index;var keys=this.keys;var uniformCount=Math.ceil(keys.length/2);meta.lineSegCount+=uniformCount;meta.curves.push(this);meta.index+=uniformCount;meta.max=Math.max(meta.max,uniformCount);return new Float32Array([3,index,uniformCount,0])};_proto9.map=function map(func){this.keys.forEach((function(k){return k[1]=func(k[1])}));return this};_proto9.scaleXCoord=function scaleXCoord(scale){this.keys.forEach((function(k){return k[0]=scale*k[0]}));return this};return LineSegments}(ValueGetter);var PathSegments=function(_ValueGetter9){_inheritsLoose(PathSegments,_ValueGetter9);function PathSegments(){return _ValueGetter9.apply(this,arguments)||this}var _proto10=PathSegments.prototype;_proto10.onCreate=function onCreate(props){this.keys=props[0];this.values=props[1];};_proto10.getValue=function getValue(time){var keys=this.keys;var values=this.values;for(var i=0;i<keys.length-1;i++){var k0=keys[i];var k1=keys[i+1];if(k0[0]<=time&&k1[0]>=time){var dis=k1[1]-k0[1];var dt=void 0;if(dis===0){dt=(time-k0[0])/(k1[0]-k0[0]);}else {var val=curveValueEvaluate(time,k0,k1);dt=(val-k0[1])/dis;}return this._calculateVec(i,dt)}}if(time<=keys[0][0]){return values[0].slice()}return values[values.length-1].slice()};_proto10._calculateVec=function _calculateVec(i,dt){var vec0=this.values[i];var vec1=this.values[i+1];var ret=[0,0,0];for(var j=0;j<vec0.length;j++){ret[j]=vec0[j]*(1-dt)+vec1[j]*dt;}return ret};return PathSegments}(ValueGetter);var BezierSegments=function(_PathSegments){_inheritsLoose(BezierSegments,_PathSegments);function BezierSegments(){return _PathSegments.apply(this,arguments)||this}var _proto11=BezierSegments.prototype;_proto11.onCreate=function onCreate(props){_PathSegments.prototype.onCreate.call(this,props);this.cps=props[2];};_proto11._calculateVec=function _calculateVec(i,t){var vec0=this.values[i];var vec1=this.values[i+1];var outCp=this.cps[i+i];var inCp=this.cps[i+i+1];var ret=[0,0,0];var ddt=1-t;var a=ddt*ddt*ddt;var b=3*t*ddt*ddt;var c=3*t*t*ddt;var d=t*t*t;for(var j=0;j<vec0.length;j++){ret[j]=a*vec0[j]+b*outCp[j]+c*inCp[j]+d*vec1[j];}return ret};return BezierSegments}(PathSegments);function lineSegIntegrate(t,t0,t1,y0,y1){var h=t-t0;return (y0+y0+(y1-y0)*h/(t1-t0))*h/2}function lineSegIntegrateByTime(t,t0,t1,y0,y1){var t2=t*t;var t3=t2*t;var t02=t0*t0;var t03=t02*t0;return (2*t3*(y0-y1)+3*t2*(t0*y1-t1*y0)-t03*(2*y0+y1)+3*t02*t1*y0)/(6*(t0-t1))}function curveValueEvaluate(time,keyframe0,keyframe1){var dt=keyframe1[CURVE_PRO_TIME]-keyframe0[CURVE_PRO_TIME];var m0=keyframe0[CURVE_PRO_OUT_TANGENT]*dt;var m1=keyframe1[CURVE_PRO_IN_TANGENT]*dt;var t=(time-keyframe0[CURVE_PRO_TIME])/dt;var t2=t*t;var t3=t2*t;var a=2*t3-3*t2+1;var b=t3-2*t2+t;var c=t3-t2;var d=-2*t3+3*t2;return a*keyframe0[CURVE_PRO_VALUE]+b*m0+c*m1+d*keyframe1[CURVE_PRO_VALUE]}function curveValueIntegrate(time,keyframe0,keyframe1){var k=keyframe1[CURVE_PRO_TIME]-keyframe0[CURVE_PRO_TIME];var m0=keyframe0[CURVE_PRO_OUT_TANGENT]*k;var m1=keyframe1[CURVE_PRO_IN_TANGENT]*k;var t0=keyframe0[CURVE_PRO_TIME];var v0=keyframe0[CURVE_PRO_VALUE];var v1=keyframe1[CURVE_PRO_VALUE];var dt=t0-time;var dt2=dt*dt;var dt3=dt2*dt;return (m0+m1+2*v0-2*v1)*dt3*dt/(4*k*k*k)+(2*m0+m1+3*v0-3*v1)*dt3/(3*k*k)+m0*dt2/2/k-v0*dt}function curveValueIntegrateByTime(t1,keyframe0,keyframe1){var k=keyframe1[CURVE_PRO_TIME]-keyframe0[CURVE_PRO_TIME];var m0=keyframe0[CURVE_PRO_OUT_TANGENT]*k;var m1=keyframe1[CURVE_PRO_IN_TANGENT]*k;var t0=keyframe0[CURVE_PRO_TIME];var v0=keyframe0[CURVE_PRO_VALUE];var v1=keyframe1[CURVE_PRO_VALUE];var dt=t0-t1;var dt2=dt*dt;var dt3=dt2*dt;var k2=k*k;var k3=k2*k;var ret=-30*k3*v0*(t0+t1)*dt+10*k2*m0*(t0+2*t1)*dt2+5*k*(t0+3*t1)*(2*m0+m1+3*v0-3*v1)*dt3+3*(t0+4*t1)*(m0+m1+2*v0-2*v1)*dt3*dt;return ret/60/k3}function getKeyFrameMetaByRawValue(value,meta){if(value){var _type=value[0];var keys=value[1];if(_type===ValueType.CURVE){meta.curves.push(keys);var keyLen=keys.length;if(keys[0][0]>0){keyLen++;}if(keys[keys.length-1][0]<1){keyLen++;}meta.index+=keyLen;meta.max=Math.max(meta.max,keyLen);meta.curveCount+=keyLen;}else if(_type===ValueType.LINE){var _keyLen=keys.length;if(_keyLen===2&&keys[0][0]===0&&keys[1][0]===1){return}if(keys[0][0]>0){_keyLen++;}if(keys[keys.length-1][0]<1){_keyLen++;}var uniformCount=Ma