Files
esengine/demo/libs/framework/framework.min.js

1 line
13 KiB
JavaScript
Raw Normal View History

window.framework={},window.__extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])};return function(n,i){function e(){this.constructor=n}t(n,i),n.prototype=null===i?Object.create(i):(e.prototype=i.prototype,new e)}}(),Array.prototype.findIndex=function(t){return function(t,n){for(var i=0,e=t.length;i<e;i++)if(n.call(arguments[2],t[i],i,t))return i;return-1}(this,t)},Array.prototype.any=function(t){return function(t,n){return t.findIndex(n)>-1}(this,t)},Array.prototype.firstOrDefault=function(t){return function(t,n){var i=t.findIndex(n);return-1==i?null:t[i]}(this,t)},Array.prototype.find=function(t){return function(t,n){return t.firstOrDefault(n)}(this,t)},Array.prototype.where=function(t){return function(t,n){if("function"==typeof t.reduce)return t.reduce(function(i,e,r){return n.call(arguments[2],e,r,t)&&i.push(e),i},[]);for(var i=[],e=0,r=t.length;e<r;e++){var o=t[e];n.call(arguments[2],o,e,t)&&i.push(o)}return i}(this,t)},Array.prototype.count=function(t){return function(t,n){return t.where(n).length}(this,t)},Array.prototype.findAll=function(t){return function(t,n){return t.where(n)}(this,t)},Array.prototype.contains=function(t){return function(t,n){for(var i=0,e=t.length;i<e;i++)if(JSON.stringify(t[i])==JSON.stringify(n))return!0;return!1}(this,t)},Array.prototype.removeAll=function(t){!function(t,n){var i;do{(i=t.findIndex(n))>=0&&t.splice(i,1)}while(i>=0)}(this,t)},Array.prototype.remove=function(t){return function(t,n){var i=t.findIndex(function(t){return t===n});return i>=0&&(t.splice(i,1),!0)}(this,t)},Array.prototype.removeAt=function(t){return function(t,n){t.splice(n,1)}(this,t)},Array.prototype.removeRange=function(t,n){return function(t,n,i){t.splice(n,i)}(this,t,n)},Array.prototype.select=function(t){return function(t,n){if("function"==typeof t.reduce)return t.reduce(function(i,e,r){return i.push(n.call(arguments[2],e,r,t)),i},[]);for(var i=[],e=0,r=t.length;e<r;e++)i.push(n.call(arguments[2],t[e],e,t));return i}(this,t)},Array.prototype.orderBy=function(t,n){return function(t,n,i){return t.sort(function(t,e){var r=n(t),o=n(e);return i?i(r,o):r>o?1:-1}),t}(this,t,n)},Array.prototype.orderByDescending=function(t,n){return function(t,n,i){return t.sort(function(t,e){var r=n(t),o=n(e);return i?-i(r,o):r<o?1:-1}),t}(this,t,n)},Array.prototype.groupBy=function(t){return function(t,n){if("function"==typeof t.reduce){var i=[];return t.reduce(function(e,r,o){var s=JSON.stringify(n.call(arguments[1],r,o,t)),a=i.findIndex(function(t){return t===s});return a<0&&(a=i.push(s)-1),e[a]||(e[a]=[]),e[a].push(r),e},[])}for(var e=[],r=[],o=function(i,o){var a=JSON.stringify(n.call(s[1],t[i],i,t)),c=r.findIndex(function(t){return t===a});c<0&&(c=r.push(a)-1),e[c]||(e[c]=[]),e[c].push(t[i])},s=arguments,a=0,c=t.length;a<c;a++)o(a);return e}(this,t)},Array.prototype.sum=function(t){return function(t,n){for(var i,e=0,r=t.length;e<r;e++)0==e?i=n?n.call(arguments[2],t[e],e,t):t[e]:i+=n?n.call(arguments[2],t[e],e,t):t[e];return i}(this,t)};var DirtyType,Component=function(){function t(){}return t.prototype.update=function(){},t.prototype.bind=function(t){return this.displayRender=t,this},t}(),Entity=function(){function t(t){this._updateOrder=0,this.name=t,this.transform=new Transform(this),this.components=[]}return Object.defineProperty(t.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),t.prototype.setUpdateOrder=function(t){if(this._updateOrder!=t)return this._updateOrder=t,this.scene,this},t.prototype.attachToScene=function(t){this.scene=t,t.entities.push(this);for(var n=0;n<this.transform.childCount;n++)this.transform.getChild(n).entity.attachToScene(t)},t.prototype.addComponent=function(t){return t.entity=this,this.components.push(t),t.initialize(),t},t.prototype.update=function(){this.components.forEach(function(t){return t.update()}),this.transform.updateTransform()},t.prototype.destory=function(){