From 66575c79a6abb26e9e6fe6cd689a7ee87f33494e Mon Sep 17 00:00:00 2001 From: cppctamber Date: Sun, 12 Aug 2018 15:43:29 +1200 Subject: [PATCH 01/25] Added support for new transpiler features and preparation for others - Added support for decorators - Added support for extending Error - Added support for class parameters - Added support for linting on newer babel features - Added `Tw2Error` base class in preparation for future Promise support - Moved all singly instantiated classes and objects to `/global` - All singly instantiated `Tw2` files moved into `/global/engine` - All singly instantiated `Tw2` classes are no longer exported - Removed `Tw2EventEmitter` constructor options so it can be used with `Object.assign(Constructor.prototype, Tw2EventEmitter.prototype` - Separated util functions into their own files - Added new type utility functions which now replace all typeof checks - Removed deprecated classes and the `/core/deprecated` folder - Moved `EveStarField` from `/eve/object` to `/eve/effect` - Fixed minor eslint errors - Fixed order of `Tw2VertexDeclaration` Declare function and added default gl type --- .eslintrc | 7 +- dist/ccpwgl_int.js | 52445 ++++++++-------- dist/ccpwgl_int.min.js | 2 +- package.json | 8 +- src/core/Tw2Error.js | 44 + src/core/Tw2EventEmitter.js | 107 +- src/core/Tw2Frustum.js | 2 +- src/core/Tw2RenderTarget.js | 3 +- src/core/batch/Tw2BatchAccumulator.js | 2 +- src/core/batch/Tw2RenderBatch.js | 2 +- src/core/curve/Tw2CurveSet.js | 2 +- src/core/curve/Tw2ValueBinding.js | 8 +- src/core/data/Tw2BasicPerObjectData.js | 2 +- src/core/data/Tw2PerObjectData.js | 2 +- src/core/data/Tw2RawData.js | 4 +- src/core/deprecated/Tw2RuntimeInstanceData.js | 227 - src/core/deprecated/Tw2VariableStore.js | 96 - src/core/deprecated/index.js | 2 - src/core/geometry/Tw2GeometryBone.js | 2 +- src/core/geometry/Tw2GeometryMesh.js | 2 +- src/core/geometry/Tw2GeometryMeshArea.js | 2 +- src/core/global/index.js | 4 - src/core/index.js | 7 +- src/core/mesh/Tw2Effect.js | 3 +- src/core/mesh/Tw2InstancedMesh.js | 3 +- src/core/mesh/Tw2Mesh.js | 4 +- src/core/mesh/Tw2MeshArea.js | 2 +- src/core/model/Tw2AnimationController.js | 16 +- src/core/model/Tw2Bone.js | 2 +- src/core/parameter/Tw2FloatParameter.js | 16 +- src/core/parameter/Tw2MatrixParameter.js | 2 +- src/core/parameter/Tw2Parameter.js | 14 +- src/core/parameter/Tw2TextureParameter.js | 12 +- src/core/parameter/Tw2TransformParameter.js | 2 +- src/core/parameter/Tw2VariableParameter.js | 2 +- src/core/parameter/Tw2Vector2Parameter.js | 2 +- src/core/parameter/Tw2Vector3Parameter.js | 2 +- src/core/parameter/Tw2Vector4Parameter.js | 2 +- src/core/post/Tw2PostProcess.js | 2 +- src/core/reader/Tw2ObjectReader.js | 3 +- src/core/resource/Tw2EffectRes.js | 2 +- src/core/resource/Tw2GeometryRes.js | 18 +- src/core/resource/Tw2LoadingObject.js | 3 +- src/core/resource/Tw2Resource.js | 2 +- src/core/resource/Tw2Shader.js | 6 +- src/core/resource/Tw2TextureRes.js | 4 +- src/core/resource/Tw2VideoRes.js | 4 +- src/core/sampler/Tw2SamplerOverride.js | 2 +- src/core/sampler/Tw2SamplerState.js | 2 +- src/core/vertex/Tw2VertexDeclaration.js | 21 +- src/curve/curves/Tw2ColorCurve.js | 2 +- src/curve/curves/Tw2ColorCurve2.js | 2 +- src/curve/curves/Tw2Curve.js | 2 +- src/curve/curves/Tw2PerlinCurve.js | 2 +- src/curve/curves/Tw2QuaternionCurve.js | 2 +- src/curve/curves/Tw2RigidOrientation.js | 2 +- src/curve/curves/Tw2RotationCurve.js | 2 +- src/curve/curves/Tw2Vector2Curve.js | 2 +- src/curve/curves/Tw2Vector3Curve.js | 2 +- src/curve/curves/Tw2VectorCurve.js | 2 +- src/curve/maya/Tw2MayaAnimationEngine.js | 2 +- src/curve/maya/Tw2MayaEulerRotationCurve.js | 2 +- src/curve/maya/Tw2MayaVector3Curve.js | 2 +- src/curve/sequencers/Tw2ColorSequencer.js | 2 +- src/curve/sequencers/Tw2EulerRotation.js | 2 +- .../sequencers/Tw2QuaternionSequencer.js | 2 +- .../sequencers/Tw2RGBAScalarSequencer.js | 2 +- src/curve/sequencers/Tw2VectorSequencer.js | 2 +- src/curve/sequencers/Tw2XYZScalarSequencer.js | 2 +- src/curve/sequencers/Tw2YPRSequencer.js | 2 +- src/curve/tracks/Tw2TransformTrack.js | 3 +- src/curve/tracks/Tw2WbgTrack.js | 3 +- src/eve/EveSOF.js | 3 +- src/eve/EveSpaceScene.js | 4 +- src/eve/child/EveChild.js | 2 +- src/eve/child/EveChildBillboard.js | 4 +- src/eve/child/EveChildMesh.js | 2 +- src/eve/child/EveChildParticleSystem.js | 2 +- src/eve/effect/EveLensflare.js | 4 +- src/eve/effect/EveMeshOverlayEffect.js | 4 +- src/eve/effect/EveOccluder.js | 11 +- src/eve/{object => effect}/EveStarField.js | 10 +- src/eve/effect/EveStretch.js | 4 +- src/eve/effect/EveTurretFiringFX.js | 2 +- src/eve/effect/index.js | 3 +- src/eve/item/EveBoosterSet.js | 4 +- src/eve/item/EveCurveLineSet.js | 3 +- src/eve/item/EveLocator.js | 2 +- src/eve/item/EveObjectSet.js | 2 +- src/eve/item/EvePlaneSet.js | 4 +- src/eve/item/EveSpaceObjectDecal.js | 10 +- src/eve/item/EveSpotlightSet.js | 4 +- src/eve/item/EveSpriteSet.js | 4 +- src/eve/item/EveTurretSet.js | 4 +- src/eve/object/EveEffectRoot.js | 4 +- src/eve/object/EveMissile.js | 2 +- src/eve/object/EveObject.js | 2 +- src/eve/object/EvePlanet.js | 7 +- src/eve/object/EveSpaceObject.js | 2 +- src/eve/object/EveTransform.js | 4 +- .../global => global/engine}/Tw2Device.js | 14 +- .../global => global/engine}/Tw2Logger.js | 13 +- .../global => global/engine}/Tw2MotherLode.js | 5 +- .../global => global/engine}/Tw2ResMan.js | 4 +- .../global => global/engine}/Tw2Store.js | 248 +- src/global/engine/index.js | 4 + src/global/index.js | 7 + src/{ => global}/math/curve.js | 0 src/{ => global}/math/index.js | 1 - src/{ => global}/math/mat3.js | 0 src/{ => global}/math/mat4.js | 0 src/{ => global}/math/noise.js | 0 src/{ => global}/math/num.js | 0 src/{ => global}/math/quat.js | 0 src/{ => global}/math/vec2.js | 0 src/{ => global}/math/vec3.js | 0 src/{ => global}/math/vec4.js | 0 src/global/util/arr.js | 77 + src/global/util/index.js | 5 + src/global/util/obj.js | 68 + src/global/util/type.js | 230 + src/global/util/url.js | 76 + src/global/util/uuid.js | 80 + src/index.js | 7 +- src/math/util.js | 247 - src/particle/Tw2ParticleSystem.js | 3 +- .../constraints/Tw2ParticleConstraint.js | 2 +- src/particle/emitters/Tw2GpuUniqueEmitter.js | 2 +- src/particle/emitters/Tw2ParticleEmitter.js | 2 +- .../forces/Tw2ParticleAttractorForce.js | 2 +- src/particle/forces/Tw2ParticleDirectForce.js | 2 +- .../forces/Tw2ParticleFluidDragForce.js | 2 +- src/particle/forces/Tw2ParticleForce.js | 2 +- src/particle/forces/Tw2ParticleSpring.js | 2 +- .../forces/Tw2ParticleTurbulenceForce.js | 2 +- .../Tw2ParticleAttributeGenerator.js | 2 +- .../Tw2RandomIntegerAttributeGenerator.js | 2 +- .../Tw2RandomUniformAttributeGenerator.js | 2 +- .../Tw2SphereShapeAttributeGenerator.js | 2 +- webpack.config.js | 12 + 140 files changed, 27385 insertions(+), 27036 deletions(-) create mode 100644 src/core/Tw2Error.js delete mode 100644 src/core/deprecated/Tw2RuntimeInstanceData.js delete mode 100644 src/core/deprecated/Tw2VariableStore.js delete mode 100644 src/core/deprecated/index.js delete mode 100644 src/core/global/index.js rename src/eve/{object => effect}/EveStarField.js (78%) rename src/{core/global => global/engine}/Tw2Device.js (99%) rename src/{core/global => global/engine}/Tw2Logger.js (92%) rename src/{core/global => global/engine}/Tw2MotherLode.js (97%) rename src/{core/global => global/engine}/Tw2ResMan.js (99%) rename src/{core/global => global/engine}/Tw2Store.js (62%) create mode 100644 src/global/engine/index.js create mode 100644 src/global/index.js rename src/{ => global}/math/curve.js (100%) rename src/{ => global}/math/index.js (93%) rename src/{ => global}/math/mat3.js (100%) rename src/{ => global}/math/mat4.js (100%) rename src/{ => global}/math/noise.js (100%) rename src/{ => global}/math/num.js (100%) rename src/{ => global}/math/quat.js (100%) rename src/{ => global}/math/vec2.js (100%) rename src/{ => global}/math/vec3.js (100%) rename src/{ => global}/math/vec4.js (100%) create mode 100644 src/global/util/arr.js create mode 100644 src/global/util/index.js create mode 100644 src/global/util/obj.js create mode 100644 src/global/util/type.js create mode 100644 src/global/util/url.js create mode 100644 src/global/util/uuid.js delete mode 100644 src/math/util.js diff --git a/.eslintrc b/.eslintrc index a748f80..beec9b8 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,13 +1,14 @@ { + "parser" : "babel-eslint", + "parserOptions": { + "sourceType": "module" + }, "env": { "browser": true, "commonjs": true, "es6": true }, "extends": "eslint:recommended", - "parserOptions": { - "sourceType": "module" - }, "rules": { "no-unused-vars": "warn", "no-console": "off", diff --git a/dist/ccpwgl_int.js b/dist/ccpwgl_int.js index db0a2a0..819a4e3 100644 --- a/dist/ccpwgl_int.js +++ b/dist/ccpwgl_int.js @@ -70,7 +70,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 64); +/******/ return __webpack_require__(__webpack_require__.s = 65); /******/ }) /************************************************************************/ /******/ ([ @@ -83,126 +83,39 @@ return /******/ (function(modules) { // webpackBootstrap Object.defineProperty(exports, "__esModule", { value: true }); +exports.util = undefined; -var _num = __webpack_require__(30); +var _math = __webpack_require__(18); -Object.keys(_num).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _num[key]; - } - }); -}); - -var _vec = __webpack_require__(66); - -Object.keys(_vec).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _vec[key]; - } - }); -}); - -var _vec2 = __webpack_require__(34); - -Object.keys(_vec2).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _vec2[key]; - } - }); -}); - -var _vec3 = __webpack_require__(35); - -Object.keys(_vec3).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _vec3[key]; - } - }); -}); - -var _quat = __webpack_require__(72); - -Object.keys(_quat).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _quat[key]; - } - }); -}); - -var _mat = __webpack_require__(73); - -Object.keys(_mat).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _mat[key]; - } - }); -}); - -var _mat2 = __webpack_require__(74); - -Object.keys(_mat2).forEach(function (key) { +Object.keys(_math).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { - return _mat2[key]; + return _math[key]; } }); }); -var _noise = __webpack_require__(75); +var _engine = __webpack_require__(78); -Object.keys(_noise).forEach(function (key) { +Object.keys(_engine).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { - return _noise[key]; + return _engine[key]; } }); }); -var _curve = __webpack_require__(76); +var _util = __webpack_require__(16); -Object.keys(_curve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _curve[key]; - } - }); -}); +var util = _interopRequireWildcard(_util); -var _util = __webpack_require__(77); +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } -Object.keys(_util).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _util[key]; - } - }); -}); +exports.util = util; /***/ }), /* 1 */ @@ -215,7 +128,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _batch = __webpack_require__(20); +var _batch = __webpack_require__(15); Object.keys(_batch).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -227,55 +140,43 @@ Object.keys(_batch).forEach(function (key) { }); }); -var _curve = __webpack_require__(86); - -Object.keys(_curve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _curve[key]; - } - }); -}); - -var _data = __webpack_require__(96); +var _class = __webpack_require__(36); -Object.keys(_data).forEach(function (key) { +Object.keys(_class).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { - return _data[key]; + return _class[key]; } }); }); -var _deprecated = __webpack_require__(98); +var _curve = __webpack_require__(93); -Object.keys(_deprecated).forEach(function (key) { +Object.keys(_curve).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { - return _deprecated[key]; + return _curve[key]; } }); }); -var _global = __webpack_require__(17); +var _data = __webpack_require__(103); -Object.keys(_global).forEach(function (key) { +Object.keys(_data).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { - return _global[key]; + return _data[key]; } }); }); -var _geometry = __webpack_require__(46); +var _geometry = __webpack_require__(47); Object.keys(_geometry).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -287,7 +188,7 @@ Object.keys(_geometry).forEach(function (key) { }); }); -var _mesh = __webpack_require__(47); +var _mesh = __webpack_require__(48); Object.keys(_mesh).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -299,7 +200,7 @@ Object.keys(_mesh).forEach(function (key) { }); }); -var _model = __webpack_require__(131); +var _model = __webpack_require__(118); Object.keys(_model).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -311,7 +212,7 @@ Object.keys(_model).forEach(function (key) { }); }); -var _parameter = __webpack_require__(24); +var _parameter = __webpack_require__(45); Object.keys(_parameter).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -323,7 +224,7 @@ Object.keys(_parameter).forEach(function (key) { }); }); -var _post = __webpack_require__(137); +var _post = __webpack_require__(124); Object.keys(_post).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -335,7 +236,7 @@ Object.keys(_post).forEach(function (key) { }); }); -var _reader = __webpack_require__(29); +var _reader = __webpack_require__(26); Object.keys(_reader).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -347,7 +248,7 @@ Object.keys(_reader).forEach(function (key) { }); }); -var _resource = __webpack_require__(28); +var _resource = __webpack_require__(25); Object.keys(_resource).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -383,7 +284,7 @@ Object.keys(_vertex).forEach(function (key) { }); }); -var _Tw2Float = __webpack_require__(139); +var _Tw2Float = __webpack_require__(126); Object.keys(_Tw2Float).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -395,7 +296,7 @@ Object.keys(_Tw2Float).forEach(function (key) { }); }); -var _Tw2Frustum = __webpack_require__(140); +var _Tw2Frustum = __webpack_require__(127); Object.keys(_Tw2Frustum).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -407,7 +308,7 @@ Object.keys(_Tw2Frustum).forEach(function (key) { }); }); -var _Tw2RenderTarget = __webpack_require__(56); +var _Tw2RenderTarget = __webpack_require__(57); Object.keys(_Tw2RenderTarget).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -419,18 +320,6 @@ Object.keys(_Tw2RenderTarget).forEach(function (key) { }); }); -var _Tw2EventEmitter = __webpack_require__(36); - -Object.keys(_Tw2EventEmitter).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2EventEmitter[key]; - } - }); -}); - /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { @@ -441,1274 +330,1138 @@ Object.keys(_Tw2EventEmitter).forEach(function (key) { Object.defineProperty(exports, "__esModule", { value: true }); -exports.device = exports.Tw2Device = undefined; +exports.Tw2Curve = exports.Tw2CurveKey = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); - -var _Tw2Store = __webpack_require__(16); - -var _Tw2Logger = __webpack_require__(4); +var _global = __webpack_require__(0); -var _Tw2ResMan = __webpack_require__(6); - -var _Tw2Effect = __webpack_require__(40); - -var _vertex = __webpack_require__(9); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /* eslint no-unused-vars:0 */ -var WebGLDebugUtil = __webpack_require__(81); /** - * Tw2Device + * Tw2CurveKey base class * - * @property {?WebGLRenderingContext|*} gl - The device's gl context - * @property {?number} glVersion - The device's gl version - * @property {?VRDisplay} vrDisplay - An optional VRDisplay context - * @property {?{}} ext - An object containing compatibility extensions - * @property {boolean} debugMode - Toggles debug mode - * @property {number} dt - Clock delta time - * @property {number} startTime - Clock start time - * @property {number} currentTime - Clock current time - * @property {?number} previousTime - Clock previous time - * @property {vec3} eyePosition - The device's current eye position - * @property {vec4} targetResolution - The device's current target resolution - * @property {mat4} world - The device's current world matrix - * @property {mat4} view - The device's current view matrix - * @property {mat4} viewInverse - The device's current inverse view matrix - * @property {mat4} viewTranspose - The device's current view matrix transposed - * @property {mat4} projection - The device's current projection matrix - * @property {mat4} projectionInverse - The device's current inverse projection matrix - * @property {mat4} projectionTranspose - The device's current projection matrix transposed - * @property {mat4} viewProjection - The device's current view projection matrix - * @property {mat4} viewProjectionTranspose - The device's current view projection matrix transposed - * @property {?HTMLCanvasElement} canvas - The html canvas the gl context was created from - * @property {number} viewportWidth - The canvas's current width - * @property {number} viewportHeight - The canvas's current height - * @property {number} viewportAspect - The canvas's current display aspect - * @property {number} viewportPixelRatio - The canvas's pixel ratio - * @property {string} effectDir - The directory used to translate ccp effect file paths - * @property {number} mipLevelSkipCount - Controls what quality ccp texture resource to load (mutates paths) - * @property {string} shaderModel - Controls what quality ccp effect resource to load (mutates paths) - * @property {boolean} enableAnisotropicFiltering - Enables anisotropic filtering - * @property {boolean} alphaBlendBackBuffer - Enables alpha blending (glParams.alpha) - * @property {boolean} antialiasing - Identifies if antialiasing is enabled - * @property {number} msaaSamples - The amount of samples used for antialiasing - * @property {number[]} wrapModes - texture wrap modes - * @property {*} shadowHandles - unused - * @property {Tw2PerObjectData} perObjectData - The current frame's per object data - * @property {?{}} _alphaBlendState - Alpha states for blending - * @property {?{}} _alphaTestState - Alpha test states - * @property {?{}} _depthOffsetState - Depth states - * @property {?Array} _blendTable - Webgl blend enum table - * @property {?Float32Array} _shadowStateBuffer - unused - * @property {Array} _scheduled - Functions that are scheduled to be called per frame - * @property {WebGLBuffer} _quadBuffer - Webgl buffer for full screen quad - * @property {Tw2VertexDeclaration} _quadDecl - Quad vertex declarations - * @property {WebGLBuffer} _cameraQuadBuffer - Webgl buffer for camera space quad - * @property {number} _currentRenderMode - The device's current render mode - * @property {WebGLTexture} _fallbackCube - A fallback cube texture - * @property {WebGLTexture} _fallbackTexture - A fallback texture - * @property {Tw2Effect} _blitEffect - The blit effect used for rendering textures - * @property {?Function} _onResize - An optional function which is called when the canvas resizes - * @property {{}} utils - Webgl debug utils + * @property {number|string} id + * @property {string} name + * @property {number} time * @class */ +var Tw2CurveKey = exports.Tw2CurveKey = function Tw2CurveKey() { + _classCallCheck(this, Tw2CurveKey); -var Tw2Device = exports.Tw2Device = function () { - function Tw2Device() { - _classCallCheck(this, Tw2Device); - - this.gl = null; - this.glVersion = Tw2Device.WebglVersion.NONE; - this.vrDisplay = null; - this.ext = null; - - this.debugMode = false; - - this.dt = 0; - this.frameCounter = 0; - this.startTime = this.Now(); - this.currentTime = this.startTime; - this.previousTime = null; - - this.eyePosition = _math.vec3.create(); - this.targetResolution = _math.vec4.create(); - this.world = _math.mat4.create(); - this.view = _math.mat4.create(); - this.viewInverse = _math.mat4.create(); - this.viewTranspose = _math.mat4.create(); - this.projection = _math.mat4.create(); - this.projectionInverse = _math.mat4.create(); - this.projectionTranspose = _math.mat4.create(); - this.viewProjection = _math.mat4.create(); - this.viewProjectionTranspose = _math.mat4.create(); - - this.canvas = null; - this.viewportWidth = 0; - this.viewportHeight = 0; - this.viewportAspect = 0; - this.viewportPixelRatio = 'devicePixelRatio' in window ? window.devicePixelRatio : 1; + this._id = _global.util.generateID(); + this.name = ''; + this.time = 0; +}; - this.effectDir = '/effect.gles2/'; - this.mipLevelSkipCount = 0; - this.shaderModel = 'hi'; - this.enableAnisotropicFiltering = true; - this.alphaBlendBackBuffer = true; +/** + * Tw2Curve base class + * + * @property {number|string} id + * @property {string} name + * @class + */ - this.antialiasing = true; - this.msaaSamples = 0; - this.wrapModes = []; - this.shadowHandles = null; - this.perObjectData = null; - this._alphaBlendState = null; - this._alphaTestState = null; - this._depthOffsetState = null; - this._blendTable = null; - this._shadowStateBuffer = null; - this._scheduled = []; - this._quadBuffer = null; - this._quadDecl = null; - this._cameraQuadBuffer = null; - this._currentRenderMode = this.RM_ANY; - this._fallbackCube = null; - this._fallbackTexture = null; - this._blitEffect = null; - this._onResize = null; +var Tw2Curve = exports.Tw2Curve = function () { + function Tw2Curve() { + _classCallCheck(this, Tw2Curve); - this.utils = WebGLDebugUtil; + this._id = _global.util.generateID(); + this.name = ''; } /** - * Gets the current device time - * @returns {number} + * Initializes the Curve */ - _createClass(Tw2Device, [{ - key: 'Now', - value: function Now() { - return this.constructor.Clock.now(); + _createClass(Tw2Curve, [{ + key: 'Initialize', + value: function Initialize() { + this.Sort(); } /** - * Creates webgl Device - * @param {HTMLCanvasElement} canvas - The html canvas to create a webgl rendering context from - * @param {{}} [params] - Optional gl parameters - * @param {boolean} [params.webgl2] - Optional flag to enable a webgl2 rendering context - * @returns {number} - The webgl rendering context create (0 if failed) + * Sorts the curve */ }, { - key: 'CreateDevice', - value: function CreateDevice(canvas, params) { - this.gl = null; - this.glVersion = Tw2Device.WebglVersion.NONE; - this.effectDir = '/effect.gles2/'; + key: 'Sort', + value: function Sort() {} - // Try webgl2 if enabled - if (params && params.webgl2) { - this.gl = Tw2Device.CreateContext(canvas, params, Tw2Device.Webgl2ContextNames); - if (this.gl) this.glVersion = Tw2Device.WebglVersion.WEBGL2; - } - // Fallback to webgl - if (!this.gl) { - this.gl = Tw2Device.CreateContext(canvas, params, Tw2Device.WebglContextNames); - if (this.gl) this.glVersion = Tw2Device.WebglVersion.WEBGL; - } + /** + * Gets the curve's length + * @returns {number} + */ - this.ext = { - drawElementsInstanced: function drawElementsInstanced() { - return false; - }, - drawArraysInstanced: function drawArraysInstanced() { - return false; - }, - vertexAttribDivisor: function vertexAttribDivisor() { - return false; - }, - hasInstancedArrays: function hasInstancedArrays() { - return false; - } - }; + }, { + key: 'GetLength', + value: function GetLength() { + return 0; + } - var gl = this.gl; + /** + * Updates the current value at the given time + * @param {number} time + */ - switch (this.glVersion) { - case Tw2Device.WebglVersion.WEBGL2: - this.ext = { - drawElementsInstanced: function drawElementsInstanced(mode, count, type, offset, instanceCount) { - gl.drawElementsInstanced(mode, count, type, offset, instanceCount); - }, - drawArraysInstanced: function drawArraysInstanced(mode, first, count, instanceCount) { - gl.drawArraysInstanced(mode, first, count, instanceCount); - }, - vertexAttribDivisor: function vertexAttribDivisor(location, divisor) { - gl.vertexAttribDivisor(location, divisor); - }, - hasInstancedArrays: function hasInstancedArrays() { - return true; - } - }; - break; + }, { + key: 'UpdateValue', + value: function UpdateValue(time) {} - case Tw2Device.WebglVersion.WEBGL: - this.GetExtension('OES_standard_derivatives'); - this.GetExtension('OES_element_index_uint'); - this.GetExtension('OES_texture_float'); - this.GetExtension('EXT_shader_texture_lod'); - var instancedArrays = this.GetExtension('ANGLE_instanced_arrays'); - if (instancedArrays) { - this.ext = { - drawElementsInstanced: function drawElementsInstanced(mode, count, type, offset, instanceCount) { - instancedArrays['drawElementsInstancedANGLE'](mode, count, type, offset, instanceCount); - }, - drawArraysInstanced: function drawArraysInstanced(mode, first, count, instanceCount) { - instancedArrays['drawArraysInstancedANGLE'](mode, first, count, instanceCount); - }, - vertexAttribDivisor: function vertexAttribDivisor(location, divisor) { - instancedArrays['vertexAttribDivisorANGLE'](location, divisor); - }, - hasInstancedArrays: function hasInstancedArrays() { - return true; - } - }; - } - break; + /** + * Compares curve keys + * @param {Tw2CurveKey} a + * @param {Tw2CurveKey} b + * @returns {number} + */ - default: - return this.glVersion; - } + }], [{ + key: 'Compare', + value: function Compare(a, b) { + if (a.time < b.time) return -1; + if (a.time > b.time) return 1; + return 0; + } - if (gl && this.debugMode) { - this.gl = this.utils.makeDebugContext(gl); - } + /** + * Sorts legacy curve keys + * @param {*} curve + * @param {Array.} [keys=curve.keys] - Optional keys override + */ - _Tw2Logger.logger.log('webgl', { - log: 'warn', - type: 'Context created', - value: this.glVersion - }); + }, { + key: 'Sort', + value: function Sort(curve) { + var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : curve.keys; - // Optional extensions - this.ext.CompressedTexture = this.GetExtension('compressed_texture_s3tc'); - this.ext.AnisotropicFilter = this.GetExtension('EXT_texture_filter_anisotropic'); - if (this.ext.AnisotropicFilter) { - this.ext.AnisotropicFilter.maxAnisotropy = gl.getParameter(this.ext.AnisotropicFilter['MAX_TEXTURE_MAX_ANISOTROPY_EXT']); + if (keys && keys.length) { + keys.sort(Tw2Curve.Compare); + curve.length = keys[keys.length - 1].time; } + } - // CCP mobile shader binary (is this depreciated?) - var shaderBinary = this.GetExtension('CCP_shader_binary'); - if (shaderBinary) { - var renderer = gl.getParameter(this.gl.RENDERER), - maliVer = renderer.match(/Mali-(\w+).*/); + /** + * Sorts curve keys + * @param {*} curve + */ - if (maliVer) { - this.effectDir = '/effect.gles2.mali' + maliVer[1] + '/'; - this.ext.ShaderBinary = shaderBinary; + }, { + key: 'Sort2', + value: function Sort2(curve) { + if (curve.keys && curve.keys.length) { + curve.keys.sort(Tw2Curve.Compare); + var back = curve.keys[curve.keys.length - 1]; + + if (back.time > curve.length) { + var preLength = curve.length, + endValue = curve.endValue, + endTangent = curve.endTangent; + + curve.length = back.time; + curve.endValue = back.value; + curve.endTangent = back.leftTangent; + + if (preLength > 0) { + back.time = preLength; + back.value = endValue; + back.leftTangent = endTangent; + } } } + } + }]); - // Quality - this.alphaBlendBackBuffer = !params || params['alpha'] === undefined || params['alpha']; - this.msaaSamples = this.gl.getParameter(this.gl.SAMPLES); - this.antialiasing = this.msaaSamples > 1; - - this.canvas = canvas; - this.Resize(); + return Tw2Curve; +}(); - var vertices = [1.0, 1.0, 0.0, 1.0, 1.0, 1.0, -1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, -1.0, 0.0, 1.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, 0.0, 0.0]; +/** + * The curve's key dimension + * @type {?number} + */ - this._quadBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, this._quadBuffer); - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); - this._cameraQuadBuffer = gl.createBuffer(); - this._quadDecl = new _vertex.Tw2VertexDeclaration(); - this._quadDecl.elements.push(new _vertex.Tw2VertexElement(_vertex.Tw2VertexDeclaration.Type.POSITION, 0, gl.FLOAT, 4, 0)); - this._quadDecl.elements.push(new _vertex.Tw2VertexElement(_vertex.Tw2VertexDeclaration.Type.TEXCOORD, 0, gl.FLOAT, 2, 16)); - this._quadDecl.RebuildHash(); - this._alphaTestState = {}; - this._alphaTestState.states = {}; - this._alphaTestState.states[this.RS_ALPHATESTENABLE] = 0; - this._alphaTestState.states[this.RS_ALPHAREF] = -1; - this._alphaTestState.states[this.RS_ALPHAFUNC] = this.CMP_GREATER; - this._alphaTestState.states[this.RS_CLIPPING] = 0; - this._alphaTestState.states[this.RS_CLIPPLANEENABLE] = 0; - this._alphaTestState.dirty = false; +Tw2Curve.inputDimension = null; - this._alphaBlendState = {}; - this._alphaBlendState.states = {}; - this._alphaBlendState.states[this.RS_SRCBLEND] = this.BLEND_SRCALPHA; - this._alphaBlendState.states[this.RS_DESTBLEND] = this.BLEND_INVSRCALPHA; - this._alphaBlendState.states[this.RS_BLENDOP] = this.BLENDOP_ADD; - this._alphaBlendState.states[this.RS_SEPARATEALPHABLENDENABLE] = 0; - this._alphaBlendState.states[this.RS_BLENDOPALPHA] = this.BLENDOP_ADD; - this._alphaBlendState.states[this.RS_SRCBLENDALPHA] = this.BLEND_SRCALPHA; - this._alphaBlendState.states[this.RS_DESTBLENDALPHA] = this.BLEND_INVSRCALPHA; - this._alphaBlendState.dirty = false; +/** + * The curve's dimension + * @type {?number} + */ +Tw2Curve.outputDimension = null; - this._depthOffsetState = {}; - this._depthOffsetState.states = {}; - this._depthOffsetState.states[this.RS_SLOPESCALEDEPTHBIAS] = 0; - this._depthOffsetState.states[this.RS_DEPTHBIAS] = 0; - this._depthOffsetState.dirty = false; +/** + * The curve's current value property + * @type {?string} + */ +Tw2Curve.valueProperty = null; - this.wrapModes = []; - this.wrapModes[0] = 0; - this.wrapModes[1] = gl.REPEAT; - this.wrapModes[2] = gl.MIRRORED_REPEAT; - this.wrapModes[3] = gl.CLAMP_TO_EDGE; - this.wrapModes[4] = gl.CLAMP_TO_EDGE; - this.wrapModes[5] = gl.CLAMP_TO_EDGE; +/** + * The curve's type + * @type {?number} + */ +Tw2Curve.curveType = null; - this._shadowStateBuffer = new Float32Array(24); +/** + * The curve's Key constructor + * @type {?Tw2CurveKey} + */ +Tw2Curve.Key = null; - // webgl to direct 3d blend table - this._blendTable = [-1, // -- - gl.ZERO, // D3DBLEND_ZERO - gl.ONE, // D3DBLEND_ONE - gl.SRC_COLOR, // D3DBLEND_SRCCOLOR - gl.ONE_MINUS_SRC_COLOR, // D3DBLEND_INVSRCCOLOR - gl.SRC_ALPHA, // D3DBLEND_SRCALPHA - gl.ONE_MINUS_SRC_ALPHA, // D3DBLEND_INVSRCALPHA - gl.DST_ALPHA, // D3DBLEND_DESTALPHA - gl.ONE_MINUS_DST_ALPHA, // D3DBLEND_INVDESTALPHA - gl.DST_COLOR, // D3DBLEND_DESTCOLOR - gl.ONE_MINUS_DST_COLOR, // D3DBLEND_INVDESTCOLOR - gl.SRC_ALPHA_SATURATE, // D3DBLEND_SRCALPHASAT - -1, // D3DBLEND_BOTHSRCALPHA - -1, // D3DBLEND_BOTHINVSRCALPHA - gl.CONSTANT_COLOR, // D3DBLEND_BLENDFACTOR - gl.ONE_MINUS_CONSTANT_COLOR // D3DBLEND_INVBLENDFACTOR - ]; +/** + * Interpolation types + * @type {?{ string: number}} + */ +Tw2Curve.Interpolation = null; - return this.glVersion; - } +/** + * Extrapolation types + * @type {?{ string: number}} + */ +Tw2Curve.Extrapolation = null; - /** - * Schedules a function to be called per tick - * @param {Function} func - */ +/** + * Curve types + * @type {{CURVE: number, CURVE2: number, CURVE_MAYA: number, SEQUENCER: number, SEQUENCER2: number}} + */ +Tw2Curve.Type = { + CURVE: 1, + CURVE2: 2, + CURVE_MAYA: 3, + CURVE_NO_KEYS: 4, + SEQUENCER: 100, + SEQUENCER2: 101 +}; - }, { - key: 'Schedule', - value: function Schedule(func) { - if (!this._scheduled.includes(func)) { - this._scheduled.push(func); - } - } +/** + * Class globals + * @type {*} + */ +Tw2Curve.global = { + vec3_0: _global.vec3.create(), + vec4_0: _global.vec4.create(), + quat_0: _global.quat.create(), + quat_1: _global.quat.create() +}; - /** - * Sets a callback which is fired on canvas resizing - * @param {Function} func - */ +/***/ }), +/* 3 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - }, { - key: 'OnResize', - value: function OnResize(func) { - this._onResize = func; - } +"use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ARRAY_TYPE", function() { return ARRAY_TYPE; }); +/* harmony export (immutable) */ __webpack_exports__["setMatrixArrayType"] = setMatrixArrayType; +/* harmony export (immutable) */ __webpack_exports__["toRadian"] = toRadian; +/* harmony export (immutable) */ __webpack_exports__["equals"] = equals; +/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. - /** - * Handles resize events - */ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: - }, { - key: 'Resize', - value: function Resize() { - if (this.vrDisplay && this.vrDisplay['isPresenting']) { - var leftEye = this.vrDisplay['getEyeParameters']('left'), - rightEye = this.vrDisplay['getEyeParameters']('right'); +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. - this.canvas.width = Math.max(leftEye['renderWidth'], rightEye['renderWidth']) * 2; - this.canvas.height = Math.max(rightEye['renderHeight'], rightEye['renderHeight']); - } else { - this.canvas.width = this.canvas.offsetWidth * this.viewportPixelRatio; - this.canvas.height = this.canvas.offsetHeight * this.viewportPixelRatio; - } +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. */ - this.viewportWidth = this.canvas.clientWidth; - this.viewportHeight = this.canvas.clientHeight; - this.viewportAspect = this.viewportWidth / this.viewportHeight; +/** + * Common utilities + * @module glMatrix + */ - if (this._onResize) { - this._onResize(this.viewportWidth, this.viewportHeight); - } +// Configuration Constants +const EPSILON = 0.000001; +/* harmony export (immutable) */ __webpack_exports__["EPSILON"] = EPSILON; - _Tw2Store.store.SetVariableValue('ViewportSize', [this.viewportWidth, this.viewportHeight, this.viewportWidth, this.viewportHeight]); - } +let ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array; +const RANDOM = Math.random; +/* harmony export (immutable) */ __webpack_exports__["RANDOM"] = RANDOM; - /** - * Per frame Tick - */ - }, { - key: 'Tick', - value: function Tick() { - if (this.canvas.clientWidth !== this.viewportWidth || this.canvas.clientHeight !== this.viewportHeight) { - this.Resize(); - } +/** + * Sets the type of array used when creating new vectors and matrices + * + * @param {Type} type Array type, such as Float32Array or Array + */ +function setMatrixArrayType(type) { + ARRAY_TYPE = type; +} - var previousTime = this.previousTime === null ? 0 : this.previousTime, - now = this.Now(); +const degree = Math.PI / 180; - this.currentTime = (now - this.startTime) * 0.001; - this.dt = this.previousTime === null ? 0 : (now - this.previousTime) * 0.001; - this.previousTime = now; +/** + * Convert Degree To Radian + * + * @param {Number} a Angle in Degrees + */ +function toRadian(a) { + return a * degree; +} - _Tw2Store.store.SetVariableValue('Time', [this.currentTime, this.currentTime - Math.floor(this.currentTime), this.frameCounter, previousTime]); +/** + * Tests whether or not the arguments have approximately the same value, within an absolute + * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less + * than or equal to 1.0, and a relative tolerance is used for larger values) + * + * @param {Number} a The first number to test. + * @param {Number} b The second number to test. + * @returns {Boolean} True if the numbers are approximately equal, false otherwise. + */ +function equals(a, b) { + return Math.abs(a - b) <= EPSILON*Math.max(1.0, Math.abs(a), Math.abs(b)); +} - _Tw2ResMan.resMan.PrepareLoop(this.dt); - for (var i = 0; i < this._scheduled.length; ++i) { - if (!this._scheduled[i](this.dt)) { - this._scheduled.splice(i, 1); - --i; - } - } +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2VectorParameter = exports.Tw2Parameter = undefined; + +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* eslint no-unused-vars:0 */ + + +var _global = __webpack_require__(0); + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * Tw2Parameter base class + * + * @param {string} [name=''] + * @property {string|number} _id + * @property {string} name + * @property {Array} _onModified + */ +var Tw2Parameter = exports.Tw2Parameter = function () { + function Tw2Parameter() { + var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + + _classCallCheck(this, Tw2Parameter); + + this._id = _global.util.generateID(); + this.name = name; + this._onModified = []; + } + + /** + * Gets the parameter's constant buffer size + * @returns {number} 0 if invalid + */ + + + _createClass(Tw2Parameter, [{ + key: 'OnValueChanged', - this.frameCounter++; - } /** - * Requests an animation frame - * @param {Function} func - * @returns {number} + * Fire on value changes + * @property {*} [controller] - An optional object which changed the parameter's value + * @property {string[]} [properties] - An optional array for tracking the parameters that were updated */ - - }, { - key: 'RequestAnimationFrame', - value: function RequestAnimationFrame(func) { - return this.vrDisplay ? this.vrDisplay.requestAnimationFrame(func) : Tw2Device.RequestAnimationFrame(func); + value: function OnValueChanged(controller, properties) { + for (var i = 0; i < this._onModified.length; i++) { + this._onModified[i](this, controller, properties); + } } /** - * Sets World transform matrix - * @param {mat4} matrix + * Adds a callback which is fired when the parameter's OnValueChanged method is called + * @param {function} func + * @returns {boolean} true if successful */ }, { - key: 'SetWorld', - value: function SetWorld(matrix) { - _math.mat4.copy(this.world, matrix); - //mat4.inverse(this.worldInverse, this.world); + key: 'AddCallback', + value: function AddCallback(func) { + if (!this._onModified.includes(func)) { + this._onModified.push(func); + } + return true; } /** - * Sets view matrix - * @param {mat4} matrix + * Removes a callback + * @param {Function} func */ }, { - key: 'SetView', - value: function SetView(matrix) { - _math.mat4.copy(this.view, matrix); - _math.mat4.invert(this.viewInverse, this.view); - _math.mat4.transpose(this.viewTranspose, this.view); - _math.mat4.getTranslation(this.eyePosition, this.viewInverse); - this.UpdateViewProjection(); + key: 'RemoveCallback', + value: function RemoveCallback(func) { + var index = this._onModified.indexOf(func); + if (index !== -1) { + this._onModified.splice(index, 1); + } } /** - * Sets projection matrix - * @param {mat4} matrix - * @param {boolean} [forceUpdateViewProjection] + * Gets the parameter's value + * @param {boolean} [serialize] - forces serialized result + * @returns {*} */ }, { - key: 'SetProjection', - value: function SetProjection(matrix, forceUpdateViewProjection) { - _math.mat4.copy(this.projection, matrix); - _math.mat4.transpose(this.projectionTranspose, this.projection); - _math.mat4.invert(this.projectionInverse, this.projection); - this.GetTargetResolution(this.targetResolution); - if (forceUpdateViewProjection) this.UpdateViewProjection(); - } + key: 'GetValue', + value: function GetValue(serialize) {} /** - * Updates view projection matrices + * Binds the parameter + * @param {*} a + * @param {*} b + * @param {*} c + * @returns {boolean} false if not bound */ }, { - key: 'UpdateViewProjection', - value: function UpdateViewProjection() { - _math.mat4.multiply(this.viewProjection, this.projection, this.view); - _math.mat4.transpose(this.viewProjectionTranspose, this.viewProjection); - _Tw2Store.store.SetVariableValue('ViewProjectionMat', this.viewProjection); + key: 'Bind', + value: function Bind(a, b, c) { + return false; } /** - * Gets the device's target resolution - * @param {vec4} out - * @returns {vec4} out + * Unbinds the parameter */ }, { - key: 'GetTargetResolution', - value: function GetTargetResolution(out) { - var aspectRatio = this.projection[0] ? this.projection[5] / this.projection[0] : 0.0; - var aspectAdjustment = 1.0; - if (aspectRatio > 1.6) aspectAdjustment = aspectRatio / 1.6; - var fov = 2.0 * Math.atan(aspectAdjustment / this.projection[5]); - out[0] = this.viewportWidth; - out[1] = this.viewportHeight; - out[2] = fov; - out[3] = fov * aspectRatio; - return out; - } + key: 'UnBind', + value: function UnBind() {} /** - * GetEyePosition - * @param {vec3} [out] - * @return {vec3} + * Applies the parameter to a constant buffer + * @param {*} a + * @param {*} b + * @param {*} c */ }, { - key: 'GetEyePosition', - value: function GetEyePosition(out) { - return _math.vec3.copy(out, this.eyePosition); - } + key: 'Apply', + value: function Apply(a, b, c) {} /** - * Returns whether or not Alpha Test is enabled - * return {Boolean} + * Copies another parameter's value + * @param {*} parameter */ }, { - key: 'IsAlphaTestEnabled', - value: function IsAlphaTestEnabled() { - return this._alphaTestState.states[this.RS_ALPHATESTENABLE]; - } + key: 'Copy', + value: function Copy(parameter) {} /** - * Checks if a frame buffer is complete - * - * @param frameBuffer - * @returns {boolean} + * Clones the parameter + * @returns {Tw2Parameter} */ }, { - key: 'IsFrameBufferComplete', - value: function IsFrameBufferComplete(frameBuffer) { - return this.gl.checkFramebufferStatus(frameBuffer) === this.gl.FRAMEBUFFER_COMPLETE; + key: 'Clone', + value: function Clone() { + var parameter = new this.constructor(); + parameter.Copy(this, true); + return parameter; + } + }, { + key: 'size', + get: function get() { + return this.constructor.constantBufferSize; + } + }]); + + return Tw2Parameter; +}(); + +/** + * The parameter's constant buffer size + * @type {number} + */ + + +Tw2Parameter.constantBufferSize = 0; + +/** + * Tw2VectorParameter base class + * + * @property {Float32Array} value + * @property {?Float32Array} constantBuffer + * @property {?number} offset + * @class + */ + +var Tw2VectorParameter = exports.Tw2VectorParameter = function (_Tw2Parameter) { + _inherits(Tw2VectorParameter, _Tw2Parameter); + + function Tw2VectorParameter(name, value) { + _classCallCheck(this, Tw2VectorParameter); + + var _this = _possibleConstructorReturn(this, (Tw2VectorParameter.__proto__ || Object.getPrototypeOf(Tw2VectorParameter)).call(this, name)); + + _this.value = new Float32Array(_this.size); + _this.constantBuffer = null; + _this.offset = null; + if (value) _this.value.set(value); + return _this; + } + + /** + * Sets the parameter's value + * @param {Float32Array} value + */ + + + _createClass(Tw2VectorParameter, [{ + key: 'SetValue', + value: function SetValue(value) { + this.value.set(value); + this.OnValueChanged(); } /** - * Gets a gl extension - * @param {string} extension - The gl extension name - * @returns{*} + * Sets a parameter's value at a given index + * @param {number} index - the parameter's value index to change + * @param {number} value - the value to set + * @throw Index Error */ }, { - key: 'GetExtension', - value: function GetExtension(extension) { - for (var prefix in Tw2Device.WebglVendorPrefixes) { - if (Tw2Device.WebglVendorPrefixes.hasOwnProperty(prefix)) { - var ext = this.gl.getExtension(Tw2Device.WebglVendorPrefixes[prefix] + extension); - if (ext) return ext; + key: 'SetIndexValue', + value: function SetIndexValue(index, value) { + if (this.value[index] !== undefined) { + if (this.value[index] !== value) { + this.value[index] = value; + this.OnValueChanged(); } + return; } - return null; + throw new Error('Index Error'); } /** - * Gets a fallback texture - * @returns {*} + * Gets the parameter's value + * @param {boolean} [serialize] - An optional parameter to force a serialized result + * @returns {Array|Float32Array} */ }, { - key: 'GetFallbackTexture', - value: function GetFallbackTexture() { - if (!this._fallbackTexture) { - this._fallbackTexture = this.CreateSolidTexture(); - } - return this._fallbackTexture; + key: 'GetValue', + value: function GetValue(serialize) { + var value = this.constantBuffer ? this.constantBuffer.subarray(this.offset, this.offset + this.size) : this.value; + return serialize ? Array.from(value) : new Float32Array(value); } /** - * Gets a fallback cube map - * @returns {*} + * Gets a parameter's value at a given index + * @param index + * @returns {number} + * @throw Index Error */ }, { - key: 'GetFallbackCubeMap', - value: function GetFallbackCubeMap() { - if (!this._fallbackCube) { - this._fallbackCube = this.CreateSolidCube(); + key: 'GetIndexValue', + value: function GetIndexValue(index) { + if (this.value[index] !== undefined) { + return this.value[index]; } - return this._fallbackCube; + throw new Error('Index Error'); } /** - * Creates a solid colored texture - * @param {vec4|Array} [rgba] - The colour to create, if omitted defaults to completely transparent - * @returns {WebGLTexture} + * Fire on value changes + * @param {*} [controller] - An optional parameter for tracking the object that called the function + * @param {string[]} [properties] - An optional array for tracking the parameters that were updated */ }, { - key: 'CreateSolidTexture', - value: function CreateSolidTexture() { - var rgba = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [0, 0, 0, 0]; + key: 'OnValueChanged', + value: function OnValueChanged(controller, properties) { + if (this.constantBuffer) { + this.Apply(this.constantBuffer, this.offset); + } - var texture = this.gl.createTexture(); - this.gl.bindTexture(this.gl.TEXTURE_2D, texture); - this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, 1, 1, 0, this.gl.RGBA, this.gl.UNSIGNED_BYTE, new Uint8Array(rgba)); - this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE); - this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE); - this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.NEAREST); - this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.NEAREST); - this.gl.bindTexture(this.gl.TEXTURE_2D, null); - return texture; + _get(Tw2VectorParameter.prototype.__proto__ || Object.getPrototypeOf(Tw2VectorParameter.prototype), 'OnValueChanged', this).call(this, controller, properties); } /** - * Creates a solid coloured cube texture - * @param {vec4|Array} rgba - * @returns {WebGLTexture} + * Binds the parameter to a constant buffer + * @param {Float32Array} constantBuffer + * @param {number} offset + * @param {number} size + * @returns {boolean} true if bound */ }, { - key: 'CreateSolidCube', - value: function CreateSolidCube() { - var rgba = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [0, 0, 0, 0]; - - var texture = this.gl.createTexture(); - this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP, texture); - for (var j = 0; j < 6; ++j) { - this.gl.texImage2D(this.gl.TEXTURE_CUBE_MAP_POSITIVE_X + j, 0, this.gl.RGBA, 1, 1, 0, this.gl.RGBA, this.gl.UNSIGNED_BYTE, new Uint8Array(rgba)); + key: 'Bind', + value: function Bind(constantBuffer, offset, size) { + if (!this.constantBuffer && size >= this.size) { + this.constantBuffer = constantBuffer; + this.offset = offset; + this.Apply(constantBuffer, offset, size); + return true; } - this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE); - this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE); - this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP, this.gl.TEXTURE_MAG_FILTER, this.gl.NEAREST); - this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP, this.gl.TEXTURE_MIN_FILTER, this.gl.NEAREST); - //this.gl.generateMipmap(this.gl.TEXTURE_CUBE_MAP); - this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP, null); - return texture; + return false; } /** - * RenderFullScreenQuad - * @param {Tw2Effect} effect - * @param {string} technique - Technique name - * @returns {boolean} + * Unbinds the parameter from a constant buffer */ }, { - key: 'RenderFullScreenQuad', - value: function RenderFullScreenQuad(effect) { - var technique = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Main'; + key: 'Unbind', + value: function Unbind() { + this.constantBuffer = null; + } - if (!effect || !effect.IsGood()) return false; + /** + * Applies the parameter's value to it's constant buffer + * @param {Float32Array} constantBuffer + * @param {number} offset + * @param {number} [size] + */ - this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this._quadBuffer); - for (var pass = 0; pass < effect.GetPassCount(technique); ++pass) { - effect.ApplyPass(technique, pass); - if (!this._quadDecl.SetDeclaration(effect.GetPassInput(technique, pass), 24)) return false; - this.ApplyShadowState(); - this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4); - } - return true; + }, { + key: 'Apply', + value: function Apply(constantBuffer, offset, size) { + constantBuffer.set(this.value, offset); } /** - * Renders a Texture to the screen - * @param {WebGLTexture} texture + * Checks if a value equals the parameter's value + * - Assumes the correct length array or typed array is passed + * @param {Array|Float32Array} value * @returns {boolean} */ }, { - key: 'RenderTexture', - value: function RenderTexture(texture) { - if (this._blitEffect === null) { - this._blitEffect = _Tw2Effect.Tw2Effect.create({ - effectFilePath: 'res:/graphics/effect/managed/space/system/blit.fx', - textures: { - BlitSource: '' - } - }); + key: 'EqualsValue', + value: function EqualsValue(value) { + for (var i = 0; i < this.size; i++) { + if (this.value[i] !== value[i]) { + return false; + } } + return true; + } - this._blitEffect.parameters['BlitSource'].textureRes = texture; - return this.RenderFullScreenQuad(this._blitEffect); + /** + * Copies another parameter's value + * @param {Tw2VectorParameter|*} parameter + * @param {boolean} [includeName] + */ + + }, { + key: 'Copy', + value: function Copy(parameter, includeName) { + if (includeName) this.name = parameter.name; + this.SetValue(parameter.GetValue()); } /** - * RenderCameraSpaceQuad - * @param {Tw2Effect} effect - * @param {string} technique - Technique name + * Checks if a value is a valid parameter input + * @param {Float32Array|Array} value * @returns {boolean} */ - }, { - key: 'RenderCameraSpaceQuad', - value: function RenderCameraSpaceQuad(effect) { - var technique = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Main'; + }], [{ + key: 'isValue', + value: function isValue(value) { + return _global.util.isArrayLike(value) && value.length === this.constantBufferSize; + } + }]); - if (!effect || !effect.IsGood()) return false; + return Tw2VectorParameter; +}(Tw2Parameter); - var vertices = new Float32Array([1.0, 1.0, 0.0, 1.0, 1.0, 1.0, -1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, -1.0, 0.0, 1.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, 0.0, 0.0]); +/** + * The parameter's constantBufferSize + * @type {number} + */ - var projInv = this.projectionInverse; - for (var i = 0; i < 4; ++i) { - var vec = vertices.subarray(i * 6, i * 6 + 4); - _math.vec4.transformMat4(vec, vec, projInv); - _math.vec3.scale(vec, vec, 1 / vec[3]); - vec[3] = 1; - } - this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this._cameraQuadBuffer); - this.gl.bufferData(this.gl.ARRAY_BUFFER, vertices, this.gl.STATIC_DRAW); - for (var pass = 0; pass < effect.GetPassCount(technique); ++pass) { - effect.ApplyPass(technique, pass); - if (!this._quadDecl.SetDeclaration(effect.GetPassInput(technique, pass), 24)) return false; - this.ApplyShadowState(); - this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4); - } - return true; - } +Tw2VectorParameter.constantBufferSize = 0; - /** - * Set a render state - * @param state - * @param value - */ +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { - }, { - key: 'SetRenderState', - value: function SetRenderState(state, value) { - this._currentRenderMode = this.RM_ANY; - var gl = this.gl; +"use strict"; - switch (state) { - case this.RS_ZENABLE: - if (value) { - gl.enable(gl.DEPTH_TEST); - } else { - gl.disable(gl.DEPTH_TEST); - } - return; - case this.RS_ZWRITEENABLE: - gl.depthMask(!!value); - return; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2CurveSequencer = undefined; - case this.RS_ALPHATESTENABLE: - case this.RS_ALPHAREF: - case this.RS_ALPHAFUNC: - case this.RS_CLIPPING: - case this.RS_CLIPPLANEENABLE: - if (this._alphaTestState[state] !== value) { - this._alphaTestState.states[state] = value; - this._alphaTestState.dirty = true; - } - return; +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - case this.RS_SRCBLEND: - case this.RS_DESTBLEND: - case this.RS_BLENDOP: - case this.RS_SEPARATEALPHABLENDENABLE: - case this.RS_BLENDOPALPHA: - case this.RS_SRCBLENDALPHA: - case this.RS_DESTBLENDALPHA: - if (this._alphaBlendState[state] !== value) { - this._alphaBlendState.states[state] = value; - this._alphaBlendState.dirty = true; - } - return; +var _curves = __webpack_require__(13); - case this.RS_CULLMODE: - switch (value) { - case this.CULL_NONE: - gl.disable(gl.CULL_FACE); - return; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - case this.CULL_CW: - gl.enable(gl.CULL_FACE); - gl.cullFace(gl.FRONT); - return; +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - case this.CULL_CCW: - gl.enable(gl.CULL_FACE); - gl.cullFace(gl.BACK); - return; - } - return; +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - case this.RS_ZFUNC: - gl.depthFunc(0x0200 + value - 1); - return; +/** + * Tw2CurveSequencer base class + * + * @class + */ +var Tw2CurveSequencer = exports.Tw2CurveSequencer = function (_Tw2Curve) { + _inherits(Tw2CurveSequencer, _Tw2Curve); - case this.RS_ALPHABLENDENABLE: - if (value) gl.enable(gl.BLEND);else gl.disable(gl.BLEND); - return; + function Tw2CurveSequencer() { + _classCallCheck(this, Tw2CurveSequencer); - case this.RS_COLORWRITEENABLE: - gl.colorMask((value & 1) !== 0, (value & 2) !== 0, (value & 4) !== 0, (value & 8) !== 0); - return; + return _possibleConstructorReturn(this, (Tw2CurveSequencer.__proto__ || Object.getPrototypeOf(Tw2CurveSequencer)).call(this)); + } - case this.RS_SCISSORTESTENABLE: - if (value) gl.enable(gl.SCISSOR_TEST);else gl.disable(gl.SCISSOR_TEST); - return; + /** + * Legacy sequencer sorting + * @param {Tw2CurveSequencer} sequencer + */ - case this.RS_SLOPESCALEDEPTHBIAS: - case this.RS_DEPTHBIAS: - value = Tw2Device.DwordToFloat(value); - if (this._depthOffsetState[state] !== value) { - this._depthOffsetState.states[state] = value; - this._depthOffsetState.dirty = true; - } - return; + + _createClass(Tw2CurveSequencer, null, [{ + key: 'Sort', + value: function Sort(sequencer) { + var curves = sequencer['functions']; + if (curves && curves.length) { + for (var i = 0; i < curves.length; i++) { + if (curves[i] && 'Sort' in curves[i]) curves[i].Sort(); + } } } /** - * ApplyShadowState + * Standard sequencer sorting + * @param {Tw2CurveSequencer} sequencer */ }, { - key: 'ApplyShadowState', - value: function ApplyShadowState() { - if (this._alphaBlendState.dirty) { - var blendOp = this.gl.FUNC_ADD; - if (this._alphaBlendState.states[this.RS_BLENDOP] === this.BLENDOP_SUBTRACT) { - blendOp = this.gl.FUNC_SUBTRACT; - } else if (this._alphaBlendState.states[this.RS_BLENDOP] === this.BLENDOP_REVSUBTRACT) { - blendOp = this.gl.FUNC_REVERSE_SUBTRACT; + key: 'Sort2', + value: function Sort2(sequencer) { + var names = sequencer.constructor.childProperties; + if (names) { + for (var i = 0; i < names.length; i++) { + var curve = sequencer[names[i]]; + if (curve && 'Sort' in curve) curve.Sort(); } + } + } + }]); - var srcBlend = this._blendTable[this._alphaBlendState.states[this.RS_SRCBLEND]], - destBlend = this._blendTable[this._alphaBlendState.states[this.RS_DESTBLEND]]; + return Tw2CurveSequencer; +}(_curves.Tw2Curve); - if (this._alphaBlendState.states[this.RS_SEPARATEALPHABLENDENABLE]) { - var blendOpAlpha = this.gl.FUNC_ADD; - if (this._alphaBlendState.states[this.RS_BLENDOP] === this.BLENDOP_SUBTRACT) { - blendOpAlpha = this.gl.FUNC_SUBTRACT; - } else if (this._alphaBlendState.states[this.RS_BLENDOP] === this.BLENDOP_REVSUBTRACT) { - blendOpAlpha = this.gl.FUNC_REVERSE_SUBTRACT; - } +/** + * The sequencer's curve property names + * @type {?Array.} + */ - var srcBlendAlpha = this._blendTable[this._alphaBlendState.states[this.RS_SRCBLENDALPHA]], - destBlendAlpha = this._blendTable[this._alphaBlendState.states[this.RS_DESTBLENDALPHA]]; - this.gl.blendEquationSeparate(blendOp, blendOpAlpha); - this.gl.blendFuncSeparate(srcBlend, destBlend, srcBlendAlpha, destBlendAlpha); - } else { - this.gl.blendEquation(blendOp); - this.gl.blendFunc(srcBlend, destBlend); - } - this._alphaBlendState.dirty = false; - } +Tw2CurveSequencer.childProperties = null; - if (this._depthOffsetState.dirty) { - this.gl.polygonOffset(this._depthOffsetState.states[this.RS_SLOPESCALEDEPTHBIAS], this._depthOffsetState.states[this.RS_DEPTHBIAS]); - this._depthOffsetState.dirty = false; - } +/** + * The sequencer's curve array + * @type {?string} + */ +Tw2CurveSequencer.childArray = null; - var alphaTestFunc = void 0, - invertedAlphaTest = void 0, - alphaTestRef = void 0; +/** + * Operator types + * @type {null} + */ +Tw2CurveSequencer.Operator = null; - if (this.shadowHandles && this._alphaTestState.states[this.RS_ALPHATESTENABLE]) { - switch (this._alphaTestState.states[this.RS_ALPHAFUNC]) { - case this.CMP_NEVER: - alphaTestFunc = 0; - invertedAlphaTest = 1; - alphaTestRef = -256; - break; +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { - case this.CMP_LESS: - alphaTestFunc = 0; - invertedAlphaTest = -1; - alphaTestRef = this._alphaTestState.states[this.RS_ALPHAREF] - 1; - break; +"use strict"; - case this.CMP_EQUAL: - alphaTestFunc = 1; - invertedAlphaTest = 0; - alphaTestRef = this._alphaTestState.states[this.RS_ALPHAREF]; - break; - case this.CMP_LEQUAL: - alphaTestFunc = 0; - invertedAlphaTest = -1; - alphaTestRef = this._alphaTestState.states[this.RS_ALPHAREF]; - break; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.EveObjectSet = exports.EveObjectSetItem = undefined; - case this.CMP_GREATER: - alphaTestFunc = 0; - invertedAlphaTest = 1; - alphaTestRef = -this._alphaTestState.states[this.RS_ALPHAREF] - 1; - break; +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* eslint no-unused-vars:0 */ - /*case this.CMP_NOTEQUAL: - var alphaTestFunc = 1; - var invertedAlphaTest = 1; - var alphaTestRef = this._alphaTestState.states[this.RS_ALPHAREF]; - break;*/ - case this.CMP_GREATEREQUAL: - alphaTestFunc = 0; - invertedAlphaTest = 1; - alphaTestRef = -this._alphaTestState.states[this.RS_ALPHAREF]; - break; +var _global = __webpack_require__(0); - default: - alphaTestFunc = 0; - invertedAlphaTest = 0; - alphaTestRef = 1; - break; - } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var clipPlaneEnable = 0; - this.gl.uniform4f(this.shadowHandles.shadowStateInt, invertedAlphaTest, alphaTestRef, alphaTestFunc, clipPlaneEnable); - //this._shadowStateBuffers - } +/** + * EveObjectSetItem base class + * + * @property {string|number} _id - The set item's id + * @property {string} name - The set item's name + * @property {boolean} display - Toggles the set item's visibility + * @property {?Function} _onModified - A callback which is fired on value changes + */ +var EveObjectSetItem = exports.EveObjectSetItem = function () { + function EveObjectSetItem() { + _classCallCheck(this, EveObjectSetItem); + + this._id = _global.util.generateID(); + this.name = ''; + this.display = true; + this._rebuildPending = true; + this._onModified = null; + } + + /** + * Fire on value changes + */ + + + _createClass(EveObjectSetItem, [{ + key: 'OnValueChanged', + value: function OnValueChanged() { + this._rebuildPending = true; + if (this._onModified) this._onModified(this); } + }]); - /** - * Sets a render mode - * @param {number} renderMode - */ + return EveObjectSetItem; +}(); - }, { - key: 'SetStandardStates', - value: function SetStandardStates(renderMode) { - if (this._currentRenderMode === renderMode) return; +/** + * EveObjectSet base class + * + * @property {number|String} _id - The set's id + * @property {string} name - The set's name + * @property {boolean} display - Toggles set visibility + * @property {Array} items - The set's items + * @property {Array} _visibleItems - The set's items that will be rendered when the set is visible + * @property {boolean} _rebuildPending - Identifies if the set requires rebuilding + * @class + */ - this.gl.frontFace(this.gl.CW); - switch (renderMode) { - case this.RM_OPAQUE: - case this.RM_PICKABLE: - this.SetRenderState(this.RS_ZENABLE, true); - this.SetRenderState(this.RS_ZWRITEENABLE, true); - this.SetRenderState(this.RS_ZFUNC, this.CMP_LEQUAL); - this.SetRenderState(this.RS_CULLMODE, this.CULL_CW); - this.SetRenderState(this.RS_ALPHABLENDENABLE, false); - this.SetRenderState(this.RS_ALPHATESTENABLE, false); - this.SetRenderState(this.RS_SEPARATEALPHABLENDENABLE, false); - this.SetRenderState(this.RS_SLOPESCALEDEPTHBIAS, 0); - this.SetRenderState(this.RS_DEPTHBIAS, 0); - this.SetRenderState(this.RS_COLORWRITEENABLE, 0xf); - break; - case this.RM_DECAL: - this.SetRenderState(this.RS_ALPHABLENDENABLE, false); - this.SetRenderState(this.RS_ALPHATESTENABLE, true); - this.SetRenderState(this.RS_ALPHAFUNC, this.CMP_GREATER); - this.SetRenderState(this.RS_ALPHAREF, 127); - this.SetRenderState(this.RS_ZENABLE, true); - this.SetRenderState(this.RS_ZWRITEENABLE, true); - this.SetRenderState(this.RS_ZFUNC, this.CMP_LEQUAL); - this.SetRenderState(this.RS_CULLMODE, this.CULL_CW); - this.SetRenderState(this.RS_BLENDOP, this.BLENDOP_ADD); - this.SetRenderState(this.RS_SLOPESCALEDEPTHBIAS, 0); - this.SetRenderState(this.RS_DEPTHBIAS, 0); - this.SetRenderState(this.RS_SEPARATEALPHABLENDENABLE, false); - this.SetRenderState(this.RS_COLORWRITEENABLE, 0xf); - break; +var EveObjectSet = exports.EveObjectSet = function () { + function EveObjectSet() { + var _this = this; - case this.RM_TRANSPARENT: - this.SetRenderState(this.RS_CULLMODE, this.CULL_CW); - this.SetRenderState(this.RS_ALPHABLENDENABLE, true); - this.SetRenderState(this.RS_SRCBLEND, this.BLEND_SRCALPHA); - this.SetRenderState(this.RS_DESTBLEND, this.BLEND_INVSRCALPHA); - this.SetRenderState(this.RS_BLENDOP, this.BLENDOP_ADD); - this.SetRenderState(this.RS_ZENABLE, true); - this.SetRenderState(this.RS_ZWRITEENABLE, false); - this.SetRenderState(this.RS_ZFUNC, this.CMP_LEQUAL); - this.SetRenderState(this.RS_ALPHATESTENABLE, false); - this.SetRenderState(this.RS_SLOPESCALEDEPTHBIAS, 0); // -1.0 - this.SetRenderState(this.RS_DEPTHBIAS, 0); - this.SetRenderState(this.RS_SEPARATEALPHABLENDENABLE, false); - this.SetRenderState(this.RS_COLORWRITEENABLE, 0xf); - break; + _classCallCheck(this, EveObjectSet); - case this.RM_ADDITIVE: - this.SetRenderState(this.RS_CULLMODE, this.CULL_NONE); - this.SetRenderState(this.RS_ALPHABLENDENABLE, true); - this.SetRenderState(this.RS_SRCBLEND, this.BLEND_ONE); - this.SetRenderState(this.RS_DESTBLEND, this.BLEND_ONE); - this.SetRenderState(this.RS_BLENDOP, this.BLENDOP_ADD); - this.SetRenderState(this.RS_ZENABLE, true); - this.SetRenderState(this.RS_ZWRITEENABLE, false); - this.SetRenderState(this.RS_ZFUNC, this.CMP_LEQUAL); - this.SetRenderState(this.RS_ALPHATESTENABLE, false); - this.SetRenderState(this.RS_SLOPESCALEDEPTHBIAS, 0); - this.SetRenderState(this.RS_DEPTHBIAS, 0); - this.SetRenderState(this.RS_SEPARATEALPHABLENDENABLE, false); - this.SetRenderState(this.RS_COLORWRITEENABLE, 0xf); - break; + this._id = _global.util.generateID(); + this.name = ''; + this.display = true; + this.items = []; + this._visibleItems = []; + this._rebuildPending = false; + this._onChildModified = function (item) { + return _this.OnValueChanged(item); + }; + } - case this.RM_FULLSCREEN: - this.SetRenderState(this.RS_ALPHABLENDENABLE, false); - this.SetRenderState(this.RS_ALPHATESTENABLE, false); - this.SetRenderState(this.RS_CULLMODE, this.CULL_NONE); - this.SetRenderState(this.RS_ZENABLE, false); - this.SetRenderState(this.RS_ZWRITEENABLE, false); - this.SetRenderState(this.RS_ZFUNC, this.CMP_ALWAYS); - this.SetRenderState(this.RS_SLOPESCALEDEPTHBIAS, 0); - this.SetRenderState(this.RS_DEPTHBIAS, 0); - this.SetRenderState(this.RS_SEPARATEALPHABLENDENABLE, false); - this.SetRenderState(this.RS_COLORWRITEENABLE, 0xf); - break; + /** + * Initializes the set + */ - default: - return; - } - this._currentRenderMode = renderMode; + _createClass(EveObjectSet, [{ + key: 'Initialize', + value: function Initialize() { + this.Rebuild(); } /** - * Converts a Dword to Float - * @param value - * @return {Number} + * Fires on value changes */ - }], [{ - key: 'DwordToFloat', - value: function DwordToFloat(value) { - var b4 = value & 0xff, - b3 = (value & 0xff00) >> 8, - b2 = (value & 0xff0000) >> 16, - b1 = (value & 0xff000000) >> 24, - sign = 1 - 2 * (b1 >> 7), - // sign = bit 0 - exp = (b1 << 1 & 0xff | b2 >> 7) - 127, - // exponent = bits 1..8 - sig = (b2 & 0x7f) << 16 | b3 << 8 | b4; // significand = bits 9..31 + }, { + key: 'OnValueChanged', + value: function OnValueChanged() { + this._rebuildPending = true; + } - if (sig === 0 && exp === -127) return 0.0; - return sign * (1 + sig * Math.pow(2, -23)) * Math.pow(2, exp); + /** + * Creates an item from an options object and then adds it to the set + * @param {*} [opt={}] + * @returns {?EveObjectSetItem|*} + */ + + }, { + key: 'CreateItem', + value: function CreateItem() { + var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var Item = this.constructor.Item; + if (Item && 'create' in Item) { + var item = Item.create(opt); + this.AddItem(item); + return item; + } + return null; } /** - * Creates a gl context - * - * @param {HTMLCanvasElement} canvas - * @param {*} [params] - * @param {*} [contextNames] - * @returns {*} + * Adds a set item + * @param {EveObjectSetItem|*} item */ }, { - key: 'CreateContext', - value: function CreateContext(canvas, params, contextNames) { - contextNames = Array.isArray(contextNames) ? contextNames : [contextNames]; - for (var i = 0; i < contextNames.length; i++) { - try { - return canvas.getContext(contextNames[i], params); - } catch (err) { - /* eslint-disable-line no-empty */ + key: 'AddItem', + value: function AddItem(item) { + if (!this.items.includes(item)) { + item._onModified = this._onChildModified; + this.items.push(item); + this.OnValueChanged(); + } + } + + /** + * Removes a set item + * @param {EveObjectSetItem|*} item + */ + + }, { + key: 'RemoveItem', + value: function RemoveItem(item) { + var index = this.items.indexOf(item); + if (index !== -1) { + item._onModified = null; + this.items.splice(index, 1); + this.OnValueChanged(); + } + } + + /** + * Clears all set items + */ + + }, { + key: 'ClearItems', + value: function ClearItems() { + for (var i = 0; i < this.items.length; i++) { + this.items[i]._onModified = null; + } + this.items = []; + this.OnValueChanged(); + } + + /** + * Finds an item by it's id + * @param {?number} [id=null] + * @returns {?EveObjectSetItem|*} + */ + + }, { + key: 'FindItemByID', + value: function FindItemByID() { + var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + + if (id !== null) { + for (var i = 0; i < this.items.length; i++) { + if (this.items[i]._id === id) { + return this.items[i]; + } } } return null; } + + /** + * Gets the set's resources + * @param {Array} [out=[]] + * @returns {Array} + */ + + }, { + key: 'GetResources', + value: function GetResources() { + var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + + return out; + } + + /** + * Per frame update + * @param {number} dt + */ + + }, { + key: 'Update', + value: function Update(dt) { + if (this._rebuildPending) { + this.Rebuild(); + } + } + + /** + * Unloads the set's buffers + */ + + }, { + key: 'Unload', + value: function Unload() {} + + /** + * Rebuilds the set + */ + + }, { + key: 'Rebuild', + value: function Rebuild() { + this.constructor.RebuildItems(this); + this._rebuildPending = false; + } + + /** + * Gets render batches + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator + * @param {Tw2PerObjectData|Tw2BasicPerObjectData} perObjectData + */ + + }, { + key: 'GetBatches', + value: function GetBatches(mode, accumulator, perObjectData) {} + + /** + * Renders the set + */ + + }, { + key: 'Render', + value: function Render() {} + + /** + * Rebuilds the set's items + * + * @param {EveObjectSet|*} eveSet + */ + + }], [{ + key: 'RebuildItems', + value: function RebuildItems(eveSet) { + eveSet._visibleItems = []; + for (var i = 0; i < eveSet.items.length; i++) { + var item = eveSet.items[i]; + item._onModified = eveSet._onChildModified; + + if (item.display) { + eveSet._visibleItems.push(item); + item._rebuildPending = false; + } + } + } }]); - return Tw2Device; + return EveObjectSet; }(); /** - * The constructor used to generate the time - * @type {DateConstructor} + * The object set's item + * @type {?Function} */ -Tw2Device.Clock = Date; - -var timeOuts = void 0; +EveObjectSet.Item = null; /** - * Requests and animation frame - * @param {Function} callback - * @returns {number} id + * Class global and scratch variables + * @type {{vec3_0, vec3_1, vec3_2}} */ -Tw2Device.RequestAnimationFrame = function () { - var requestFrame = window['requestAnimationFrame'] || window['webkitRequestAnimationFrame'] || window['mozRequestAnimationFrame'] || window['oRequestAnimationFrame'] || window['msRequestAnimationFrame'] || function (callback) { - if (!timeOuts) timeOuts = []; - timeOuts.push(window.setTimeout(callback, 1000 / 60)); - return timeOuts.length - 1; - }; +EveObjectSet.global = { + vec3_0: _global.vec3.create(), + vec3_1: _global.vec3.create(), + vec3_2: _global.vec3.create(), + vec4_0: _global.vec4.create(), + vec4_1: _global.vec4.create(), + mat4_0: _global.mat4.create() +}; - return function RequestAnimationFrame(callback) { - return requestFrame(callback); - }; -}(); +/***/ }), +/* 7 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -/** - * Cancels an animation frame by it's id - * @param {number} id +"use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__gl_matrix_common__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__gl_matrix_mat2__ = __webpack_require__(68); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__gl_matrix_mat2d__ = __webpack_require__(69); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__gl_matrix_mat3__ = __webpack_require__(30); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__gl_matrix_mat4__ = __webpack_require__(70); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__gl_matrix_quat__ = __webpack_require__(71); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__gl_matrix_vec2__ = __webpack_require__(72); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__gl_matrix_vec3__ = __webpack_require__(31); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__gl_matrix_vec4__ = __webpack_require__(32); +/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "glMatrix", function() { return __WEBPACK_IMPORTED_MODULE_0__gl_matrix_common__; }); +/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "mat2", function() { return __WEBPACK_IMPORTED_MODULE_1__gl_matrix_mat2__; }); +/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "mat2d", function() { return __WEBPACK_IMPORTED_MODULE_2__gl_matrix_mat2d__; }); +/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "mat3", function() { return __WEBPACK_IMPORTED_MODULE_3__gl_matrix_mat3__; }); +/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "mat4", function() { return __WEBPACK_IMPORTED_MODULE_4__gl_matrix_mat4__; }); +/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "quat", function() { return __WEBPACK_IMPORTED_MODULE_5__gl_matrix_quat__; }); +/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "vec2", function() { return __WEBPACK_IMPORTED_MODULE_6__gl_matrix_vec2__; }); +/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "vec3", function() { return __WEBPACK_IMPORTED_MODULE_7__gl_matrix_vec3__; }); +/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "vec4", function() { return __WEBPACK_IMPORTED_MODULE_8__gl_matrix_vec4__; }); +/** + * @fileoverview gl-matrix - High performance matrix and vector operations + * @author Brandon Jones + * @author Colin MacKenzie IV + * @version 2.4.0 */ -Tw2Device.CancelAnimationFrame = function () { - var cancelFrame = window['cancelAnimationFrame'] || window['webkitRequestAnimationFrame'] || window['mozRequestAnimationFrame'] || window['oRequestAnimationFrame'] || window['msRequestAnimationFrame'] || function (id) { - if (!timeOuts) timeOuts = []; - if (timeOuts[id] !== undefined) { - window.clearTimeout(timeOuts[id]); - timeOuts[id] = undefined; - return true; - } - }; - return function CancelAnimationFrame(id) { - cancelFrame(id); - }; -}(); +/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. */ +// END HEADER + + + + + + + + -// Webgl details -Tw2Device.WebglVendorPrefixes = ['', 'MOZ_', 'WEBKIT_', 'WEBGL_']; -Tw2Device.WebglContextNames = ['webgl', 'experimental-webgl']; -Tw2Device.Webgl2ContextNames = ['webgl2', 'experimental-webgl2']; -Tw2Device.WebglVersion = { - NONE: 0, - WEBGL: 1, - WEBGL2: 2 -}; -// Render Modes -Tw2Device.prototype.RM_ANY = -1; -Tw2Device.prototype.RM_OPAQUE = 0; -Tw2Device.prototype.RM_DECAL = 1; -Tw2Device.prototype.RM_TRANSPARENT = 2; -Tw2Device.prototype.RM_ADDITIVE = 3; -Tw2Device.prototype.RM_DEPTH = 4; -Tw2Device.prototype.RM_FULLSCREEN = 5; -Tw2Device.prototype.RM_PICKABLE = 6; -// Render States -Tw2Device.prototype.RS_ZENABLE = 7; // D3DZBUFFERTYPE (or TRUE/FALSE for legacy) -Tw2Device.prototype.RS_FILLMODE = 8; // D3DFILLMODE -Tw2Device.prototype.RS_SHADEMODE = 9; // D3DSHADEMODE -Tw2Device.prototype.RS_ZWRITEENABLE = 14; // TRUE to enable z writes -Tw2Device.prototype.RS_ALPHATESTENABLE = 15; // TRUE to enable alpha tests -Tw2Device.prototype.RS_LASTPIXEL = 16; // TRUE for last-pixel on lines -Tw2Device.prototype.RS_SRCBLEND = 19; // D3DBLEND -Tw2Device.prototype.RS_DESTBLEND = 20; // D3DBLEND -Tw2Device.prototype.RS_CULLMODE = 22; // D3DCULL -Tw2Device.prototype.RS_ZFUNC = 23; // D3DCMPFUNC -Tw2Device.prototype.RS_ALPHAREF = 24; // D3DFIXED -Tw2Device.prototype.RS_ALPHAFUNC = 25; // D3DCMPFUNC -Tw2Device.prototype.RS_DITHERENABLE = 26; // TRUE to enable dithering -Tw2Device.prototype.RS_ALPHABLENDENABLE = 27; // TRUE to enable alpha blending -Tw2Device.prototype.RS_FOGENABLE = 28; // TRUE to enable fog blending -Tw2Device.prototype.RS_SPECULARENABLE = 29; // TRUE to enable specular -Tw2Device.prototype.RS_FOGCOLOR = 34; // D3DCOLOR -Tw2Device.prototype.RS_FOGTABLEMODE = 35; // D3DFOGMODE -Tw2Device.prototype.RS_FOGSTART = 36; // Fog start (for both vertex and pixel fog) -Tw2Device.prototype.RS_FOGEND = 37; // Fog end -Tw2Device.prototype.RS_FOGDENSITY = 38; // Fog density -Tw2Device.prototype.RS_RANGEFOGENABLE = 48; // Enables range-based fog -Tw2Device.prototype.RS_STENCILENABLE = 52; // BOOL enable/disable stenciling -Tw2Device.prototype.RS_STENCILFAIL = 53; // D3DSTENCILOP to do if stencil test fails -Tw2Device.prototype.RS_STENCILZFAIL = 54; // D3DSTENCILOP to do if stencil test passes and Z test fails -Tw2Device.prototype.RS_STENCILPASS = 55; // D3DSTENCILOP to do if both stencil and Z tests pass -Tw2Device.prototype.RS_STENCILFUNC = 56; // D3DCMPFUNC fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true -Tw2Device.prototype.RS_STENCILREF = 57; // Reference value used in stencil test -Tw2Device.prototype.RS_STENCILMASK = 58; // Mask value used in stencil test -Tw2Device.prototype.RS_STENCILWRITEMASK = 59; // Write mask applied to values written to stencil buffer -Tw2Device.prototype.RS_TEXTUREFACTOR = 60; // D3DCOLOR used for multi-texture blend -Tw2Device.prototype.RS_WRAP0 = 128; // wrap for 1st texture coord. set -Tw2Device.prototype.RS_WRAP1 = 129; // wrap for 2nd texture coord. set -Tw2Device.prototype.RS_WRAP2 = 130; // wrap for 3rd texture coord. set -Tw2Device.prototype.RS_WRAP3 = 131; // wrap for 4th texture coord. set -Tw2Device.prototype.RS_WRAP4 = 132; // wrap for 5th texture coord. set -Tw2Device.prototype.RS_WRAP5 = 133; // wrap for 6th texture coord. set -Tw2Device.prototype.RS_WRAP6 = 134; // wrap for 7th texture coord. set -Tw2Device.prototype.RS_WRAP7 = 135; // wrap for 8th texture coord. set -Tw2Device.prototype.RS_CLIPPING = 136; -Tw2Device.prototype.RS_LIGHTING = 137; -Tw2Device.prototype.RS_AMBIENT = 139; -Tw2Device.prototype.RS_FOGVERTEXMODE = 140; -Tw2Device.prototype.RS_COLORVERTEX = 141; -Tw2Device.prototype.RS_LOCALVIEWER = 142; -Tw2Device.prototype.RS_NORMALIZENORMALS = 143; -Tw2Device.prototype.RS_DIFFUSEMATERIALSOURCE = 145; -Tw2Device.prototype.RS_SPECULARMATERIALSOURCE = 146; -Tw2Device.prototype.RS_AMBIENTMATERIALSOURCE = 147; -Tw2Device.prototype.RS_EMISSIVEMATERIALSOURCE = 148; -Tw2Device.prototype.RS_VERTEXBLEND = 151; -Tw2Device.prototype.RS_CLIPPLANEENABLE = 152; -Tw2Device.prototype.RS_POINTSIZE = 154; // float point size -Tw2Device.prototype.RS_POINTSIZE_MIN = 155; // float point size min threshold -Tw2Device.prototype.RS_POINTSPRITEENABLE = 156; // BOOL point texture coord control -Tw2Device.prototype.RS_POINTSCALEENABLE = 157; // BOOL point size scale enable -Tw2Device.prototype.RS_POINTSCALE_A = 158; // float point attenuation A value -Tw2Device.prototype.RS_POINTSCALE_B = 159; // float point attenuation B value -Tw2Device.prototype.RS_POINTSCALE_C = 160; // float point attenuation C value -Tw2Device.prototype.RS_MULTISAMPLEANTIALIAS = 161; // BOOL - set to do FSAA with multisample buffer -Tw2Device.prototype.RS_MULTISAMPLEMASK = 162; // DWORD - per-sample enable/disable -Tw2Device.prototype.RS_PATCHEDGESTYLE = 163; // Sets whether patch edges will use float style tessellation -Tw2Device.prototype.RS_DEBUGMONITORTOKEN = 165; // DEBUG ONLY - token to debug monitor -Tw2Device.prototype.RS_POINTSIZE_MAX = 166; -// float point size max threshold -Tw2Device.prototype.RS_INDEXEDVERTEXBLENDENABLE = 167; -Tw2Device.prototype.RS_COLORWRITEENABLE = 168; // per-channel write enable -Tw2Device.prototype.RS_TWEENFACTOR = 170; // float tween factor -Tw2Device.prototype.RS_BLENDOP = 171; // D3DBLENDOP setting -Tw2Device.prototype.RS_POSITIONDEGREE = 172; // NPatch position interpolation degree. D3DDEGREE_LINEAR or D3DDEGREE_CUBIC (default) -Tw2Device.prototype.RS_NORMALDEGREE = 173; // NPatch normal interpolation degree. D3DDEGREE_LINEAR (default) or D3DDEGREE_QUADRATIC -Tw2Device.prototype.RS_SCISSORTESTENABLE = 174; -Tw2Device.prototype.RS_SLOPESCALEDEPTHBIAS = 175; -Tw2Device.prototype.RS_ANTIALIASEDLINEENABLE = 176; -Tw2Device.prototype.RS_TWOSIDEDSTENCILMODE = 185; // BOOL enable/disable 2 sided stenciling -Tw2Device.prototype.RS_CCW_STENCILFAIL = 186; // D3DSTENCILOP to do if ccw stencil test fails -Tw2Device.prototype.RS_CCW_STENCILZFAIL = 187; // D3DSTENCILOP to do if ccw stencil test passes and Z test fails -Tw2Device.prototype.RS_CCW_STENCILPASS = 188; // D3DSTENCILOP to do if both ccw stencil and Z tests pass -Tw2Device.prototype.RS_CCW_STENCILFUNC = 189; // D3DCMPFUNC fn. ccw Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true -Tw2Device.prototype.RS_COLORWRITEENABLE1 = 190; // Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS -Tw2Device.prototype.RS_COLORWRITEENABLE2 = 191; // Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS -Tw2Device.prototype.RS_COLORWRITEENABLE3 = 192; // Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS -Tw2Device.prototype.RS_BLENDFACTOR = 193; // D3DCOLOR used for a constant blend factor during alpha blending for devices that support D3DPBLENDCAPS_BLENDFACTOR -Tw2Device.prototype.RS_SRGBWRITEENABLE = 194; // Enable rendertarget writes to be DE-linearized to SRGB (for formats that expose D3DUSAGE_QUERY_SRGBWRITE) -Tw2Device.prototype.RS_DEPTHBIAS = 195; -Tw2Device.prototype.RS_SEPARATEALPHABLENDENABLE = 206; // TRUE to enable a separate blending function for the alpha channel -Tw2Device.prototype.RS_SRCBLENDALPHA = 207; // SRC blend factor for the alpha channel when RS_SEPARATEDESTALPHAENABLE is TRUE -Tw2Device.prototype.RS_DESTBLENDALPHA = 208; // DST blend factor for the alpha channel when RS_SEPARATEDESTALPHAENABLE is TRUE -Tw2Device.prototype.RS_BLENDOPALPHA = 209; // Blending operation for the alpha channel when RS_SEPARATEDESTALPHAENABLE is TRUE */// Cull Modes -Tw2Device.prototype.CULL_NONE = 1; -Tw2Device.prototype.CULL_CW = 2; -Tw2Device.prototype.CULL_CCW = 3; -// Compare -Tw2Device.prototype.CMP_NEVER = 1; -Tw2Device.prototype.CMP_LESS = 2; -Tw2Device.prototype.CMP_EQUAL = 3; -Tw2Device.prototype.CMP_LEQUAL = 4; -Tw2Device.prototype.CMP_GREATER = 5; -Tw2Device.prototype.CMP_NOTEQUAL = 6; -Tw2Device.prototype.CMP_GREATEREQUAL = 7; -Tw2Device.prototype.CMP_ALWAYS = 8; -// Blend -Tw2Device.prototype.BLEND_ZERO = 1; -Tw2Device.prototype.BLEND_ONE = 2; -Tw2Device.prototype.BLEND_SRCCOLOR = 3; -Tw2Device.prototype.BLEND_INVSRCCOLOR = 4; -Tw2Device.prototype.BLEND_SRCALPHA = 5; -Tw2Device.prototype.BLEND_INVSRCALPHA = 6; -Tw2Device.prototype.BLEND_DESTALPHA = 7; -Tw2Device.prototype.BLEND_INVDESTALPHA = 8; -Tw2Device.prototype.BLEND_DESTCOLOR = 9; -Tw2Device.prototype.BLEND_INVDESTCOLOR = 10; -Tw2Device.prototype.BLEND_SRCALPHASAT = 11; -Tw2Device.prototype.BLEND_BOTHSRCALPHA = 12; -Tw2Device.prototype.BLEND_BOTHINVSRCALPHA = 13; -Tw2Device.prototype.BLEND_BLENDFACTOR = 14; -Tw2Device.prototype.BLEND_INVBLENDFACTOR = 15; -// Blend Operations -Tw2Device.prototype.BLENDOP_ADD = 1; -Tw2Device.prototype.BLENDOP_SUBTRACT = 2; -Tw2Device.prototype.BLENDOP_REVSUBTRACT = 3; -Tw2Device.prototype.BLENDOP_MIN = 4; -Tw2Device.prototype.BLENDOP_MAX = 5; -var device = exports.device = new Tw2Device(); /***/ }), -/* 3 */ +/* 8 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -1717,223 +1470,252 @@ var device = exports.device = new Tw2Device(); Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2Curve = exports.Tw2CurveKey = undefined; +exports.Tw2Resource = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /* eslint no-unused-vars:0 */ - +var _global = __webpack_require__(0); -/** - * Tw2CurveKey base class - * - * @property {number|string} id - * @property {string} name - * @property {number} time - * @class - */ -var Tw2CurveKey = exports.Tw2CurveKey = function Tw2CurveKey() { - _classCallCheck(this, Tw2CurveKey); - - this._id = _math.util.generateID(); - this.name = ''; - this.time = 0; -}; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** - * Tw2Curve base class + * Tw2Resource base class * - * @property {number|string} id - * @property {string} name + * @property {string} path + * @property {boolean} _isLoading + * @property {boolean} _isGood + * @property {boolean} _isPurged + * @property {Array} _notifications + * @property {number} activeFrame + * @property {number} doNotPurge * @class */ +var Tw2Resource = exports.Tw2Resource = function () { + function Tw2Resource() { + _classCallCheck(this, Tw2Resource); - -var Tw2Curve = exports.Tw2Curve = function () { - function Tw2Curve() { - _classCallCheck(this, Tw2Curve); - - this._id = _math.util.generateID(); - this.name = ''; + this.path = ''; + this._isLoading = false; + this._isGood = false; + this._isPurged = false; + this._notifications = []; + this.activeFrame = 0; + this.doNotPurge = 0; } /** - * Initializes the Curve + * Checks to see if the resource is loading + * @returns {boolean} */ - _createClass(Tw2Curve, [{ - key: 'Initialize', - value: function Initialize() { - this.Sort(); + _createClass(Tw2Resource, [{ + key: 'IsLoading', + value: function IsLoading() { + this.KeepAlive(); + return this._isLoading; } /** - * Sorts the curve + * Checks to see if the resource is good + * @returns {boolean} */ }, { - key: 'Sort', - value: function Sort() {} + key: 'IsGood', + value: function IsGood() { + this.KeepAlive(); + return this._isGood; + } /** - * Gets the curve's length - * @returns {number} + * Checks to see if the resource is purged + * @returns {boolean} + * @prototype */ }, { - key: 'GetLength', - value: function GetLength() { - return 0; + key: 'IsPurged', + value: function IsPurged() { + return this._isPurged; } /** - * Updates the current value at the given time - * @param {number} time + * LoadStarted */ }, { - key: 'UpdateValue', - value: function UpdateValue(time) {} + key: 'LoadStarted', + value: function LoadStarted() { + this._isLoading = true; + this.UpdateNotifications('ReleaseCachedData'); + } /** - * Compares curve keys - * @param {Tw2CurveKey} a - * @param {Tw2CurveKey} b - * @returns {number} + * LoadFinished + * @param {boolean} success */ - }], [{ - key: 'Compare', - value: function Compare(a, b) { - if (a.time < b.time) return -1; - if (a.time > b.time) return 1; - return 0; + }, { + key: 'LoadFinished', + value: function LoadFinished(success) { + this._isLoading = false; + if (!success) this._isGood = false; } /** - * Sorts legacy curve keys - * @param {*} curve - * @param {Array.} [keys=curve.keys] - Optional keys override + * PrepareFinished + * @param {boolean} success */ }, { - key: 'Sort', - value: function Sort(curve) { - var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : curve.keys; + key: 'PrepareFinished', + value: function PrepareFinished(success) { + this._isLoading = false; + this._isGood = success; + this.UpdateNotifications('RebuildCachedData'); + } - if (keys && keys.length) { - keys.sort(Tw2Curve.Compare); - curve.length = keys[keys.length - 1].time; - } + /** + * Sets resource's isGood property + * @param {boolean} success + */ + + }, { + key: 'SetIsGood', + value: function SetIsGood(success) { + this._isGood = success; } /** - * Sorts curve keys - * @param {*} curve + * Unloads the resource */ }, { - key: 'Sort2', - value: function Sort2(curve) { - if (curve.keys && curve.keys.length) { - curve.keys.sort(Tw2Curve.Compare); - var back = curve.keys[curve.keys.length - 1]; + key: 'Unload', + value: function Unload() {} - if (back.time > curve.length) { - var preLength = curve.length, - endValue = curve.endValue, - endTangent = curve.endTangent; + /** + * Reloads the resource + */ - curve.length = back.time; - curve.endValue = back.value; - curve.endTangent = back.leftTangent; + }, { + key: 'Reload', + value: function Reload() { + this.Unload(); + _global.resMan.ReloadResource(this); + } - if (preLength > 0) { - back.time = preLength; - back.value = endValue; - back.leftTangent = endTangent; - } + /** + * Keeps the resource from being purged + */ + + }, { + key: 'KeepAlive', + value: function KeepAlive() { + this.activeFrame = _global.resMan.activeFrame; + if (this._isPurged) this.Reload(); + } + + /** + * Registers a notification + * @param {*} notification + */ + + }, { + key: 'RegisterNotification', + value: function RegisterNotification(notification) { + if (!this._notifications.includes(notification)) { + this._notifications.push(notification); + if (this._isGood && 'RebuildCachedData' in notification) { + notification.RebuildCachedData(this); + } + } + } + + /** + * Deregisters a notification + * @param {*} notification + */ + + }, { + key: 'UnregisterNotification', + value: function UnregisterNotification(notification) { + this._notifications.splice(this._notifications.indexOf(notification), 1); + } + + /** + * Updates a notification + * @param {string} funcName - The function name to call + */ + + }, { + key: 'UpdateNotifications', + value: function UpdateNotifications(funcName) { + for (var i = 0; i < this._notifications.length; i++) { + if (funcName in this._notifications[i]) { + this._notifications[i][funcName](this); } } } }]); - return Tw2Curve; + return Tw2Resource; }(); /** - * The curve's key dimension - * @type {?number} + * An optional function for when the resource handles it's own loading + * - If the method returns false then the resource manager will handle the http request + * @type {?Function} + * @returns {boolean} */ -Tw2Curve.inputDimension = null; +Tw2Resource.prototype.DoCustomLoad = null; /** - * The curve's dimension - * @type {?number} + * HTTP request response type + * @type {null} */ -Tw2Curve.outputDimension = null; +Tw2Resource.prototype.requestResponseType = null; -/** - * The curve's current value property - * @type {?string} - */ -Tw2Curve.valueProperty = null; +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * The curve's type - * @type {?number} - */ -Tw2Curve.curveType = null; +"use strict"; -/** - * The curve's Key constructor - * @type {?Tw2CurveKey} - */ -Tw2Curve.Key = null; -/** - * Interpolation types - * @type {?{ string: number}} - */ -Tw2Curve.Interpolation = null; +Object.defineProperty(exports, "__esModule", { + value: true +}); -/** - * Extrapolation types - * @type {?{ string: number}} - */ -Tw2Curve.Extrapolation = null; +var _Tw2VertexDeclaration = __webpack_require__(87); -/** - * Curve types - * @type {{CURVE: number, CURVE2: number, CURVE_MAYA: number, SEQUENCER: number, SEQUENCER2: number}} - */ -Tw2Curve.Type = { - CURVE: 1, - CURVE2: 2, - CURVE_MAYA: 3, - CURVE_NO_KEYS: 4, - SEQUENCER: 100, - SEQUENCER2: 101 -}; +Object.keys(_Tw2VertexDeclaration).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2VertexDeclaration[key]; + } + }); +}); -/** - * Class globals - * @type {*} - */ -Tw2Curve.global = { - vec3_0: _math.vec3.create(), - vec4_0: _math.vec4.create(), - quat_0: _math.quat.create(), - quat_1: _math.quat.create() -}; +var _Tw2VertexElement = __webpack_require__(44); + +Object.keys(_Tw2VertexElement).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2VertexElement[key]; + } + }); +}); /***/ }), -/* 4 */ +/* 10 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -1942,263 +1724,113 @@ Tw2Curve.global = { Object.defineProperty(exports, "__esModule", { value: true }); -exports.logger = exports.Tw2Logger = undefined; +exports.EveChild = undefined; -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* eslint no-unused-vars:0 */ -var _Tw2EventEmitter2 = __webpack_require__(36); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * Event log - * @typedef {*} eventLog - * @property {string} log - Desired console output type - * @property {string} msg - A message to log - * @property {string} path - An optional resource path - * @property {number} time - An optional time - * @property {string} type - The type of log - * @property {*} value - An optional value - * @property {*} data - An optional values object - * @property {Error} err - An optional caught error - * @property {boolean} hide - True to skip console output - * @property {boolean} logged - Identifies if the log has been logged - */ - /** - * Handles basic event logging + * EveChild base class * - * @param {string} [name=''] - The logger's name - * @property {string} name - The name of the logger and it's prefix - * @property {{}} visible - Visibility options - * @property {boolean} visible.log - Toggles console log output - * @property {boolean} visible.info - Toggles console info output - * @property {boolean} visible.debug - Toggles console debug output - * @property {boolean} visible.warn - Toggles console warn output - * @property {boolean} visible.error - Toggles console error output - * @property {number} maxLogs - The maximum logs that will be stored - * @property {boolean} display - Enabled console logging - * @property {Array} _logs - Stored logs - * @property {?Function} _onNewLog - On new log + * @property {number|string} _id + * @property {string} name + * @property {boolean} display + * @property {boolean} useSRT + * @property {number} lowestLodVisible + * @property {boolean} staticTransform + * @property {quat} rotation + * @property {vec3} translation + * @property {vec3} scaling + * @property {mat4} localTransform + * @property {mat4} worldTransform + * @property {mat4} worldTransformLast + * @property {?|Tw2BasicPerObjectData|Tw2PerObjectData} _perObjectData + * @class */ -var Tw2Logger = function (_Tw2EventEmitter) { - _inherits(Tw2Logger, _Tw2EventEmitter); - - function Tw2Logger() { - var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - - _classCallCheck(this, Tw2Logger); - - var _this = _possibleConstructorReturn(this, (Tw2Logger.__proto__ || Object.getPrototypeOf(Tw2Logger)).call(this)); +var EveChild = exports.EveChild = function () { + function EveChild() { + _classCallCheck(this, EveChild); - _this.name = name; - _this.display = true; - _this.visible = {}; - _this.visible.log = true; - _this.visible.info = true; - _this.visible.debug = true; - _this.visible.warn = true; - _this.visible.error = true; - _this.maxLogs = 100; - _this._logs = []; - return _this; + this._id = _global.util.generateID(); + this.name = ''; + this.display = true; + this.useSRT = true; + this.lowestLodVisible = 2; + this.staticTransform = false; + this.rotation = _global.quat.create(); + this.translation = _global.vec3.create(); + this.scaling = _global.vec3.fromValues(1, 1, 1); + this.localTransform = _global.mat4.create(); + this.worldTransform = _global.mat4.create(); + this.worldTransformLast = _global.mat4.create(); + this._perObjectData = null; + this.isEffectChild = true; } /** - * Adds an event log and outputs it to the console - * @param {string} eventName - * @param {eventLog} log - * @returns {eventLog} log + * Gets the child's resources + * @param {Array} [out=[]] + * @returns {Array} out */ - _createClass(Tw2Logger, [{ - key: 'log', - value: function log(eventName, _log) { - _log.log = Tw2Logger.Type[_log.log ? _log.log.toUpperCase() : 'LOG'] || 'log'; - - if (!_log.hide && this.display && this.visible[_log.log]) { - var header = this.name + ': {' + eventName + '}'; - var body = _log.msg || ''; - - if (_log.path) { - body += ' \'' + _log.path + '\''; - if ('time' in _log) body += ' in ' + _log.time.toFixed(3) + ' secs'; - } - - if (_log.value !== undefined || _log.type) { - body += ' ('; - if (_log.type) body += _log.type; - if (_log.type && _log.value !== undefined) body += ':'; - if (_log.value !== undefined) body += _log.value; - body += ')'; - } - - if ('data' in _log || 'err' in _log) { - console.group(header); - console[_log.log](body); - if (_log.data) console.debug(_log.data); - if (_log.err) console.debug(_log.err.stack || _log.err.toString()); - console.groupEnd(); - } else { - console[_log.log](header, body); - } - } - - if (this.maxLogs) { - if (this._logs.length >= this.maxLogs) { - this._logs.splice(this.maxLogs, this._logs.length - 1); - } - this._logs.unshift(_log); - } else { - this._logs = []; - } + _createClass(EveChild, [{ + key: 'GetResources', + value: function GetResources() { + var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - this.emit('log', _log); - return _log; + return out; } /** - * Gets an array of logs - * @param {number} [count] - * @returns {Array} + * Per frame update + * @param {number} dt + * @param {mat4} parentTransform */ }, { - key: 'GetLogs', - value: function GetLogs(count) { - return Object.assign([], count === undefined ? this._logs : this._logs.splice(0, count)); + key: 'Update', + value: function Update(dt, parentTransform) { + if (this.useSRT) { + _global.quat.normalize(this.rotation, this.rotation); + _global.mat4.fromRotationTranslationScale(this.localTransform, this.rotation, this.translation, this.scaling); + } + + _global.mat4.copy(this.worldTransformLast, this.worldTransform); + _global.mat4.multiply(this.worldTransform, parentTransform, this.localTransform); } /** - * Sets the logger's properties - * @param {*} [opt={}] + * Gets render batches + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator */ }, { - key: 'Set', - value: function Set() { - var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - _math.util.assignIfExists(this, opt, ['name', 'maxLogs', 'display']); - _math.util.assignIfExists(this.visible, opt.visible, ['log', 'info', 'debug', 'warn', 'error']); - } + key: 'GetBatches', + value: function GetBatches(mode, accumulator) {} }]); - return Tw2Logger; -}(_Tw2EventEmitter2.Tw2EventEmitter); + return EveChild; +}(); /** - * Console outputs - * @type {{THROW: string, ERROR: string, WARNING: string, WARN: string, INFO: string, LOG: string, DEBUG: string}} + * Class globals and scratch variables + * @type {Object} */ -exports.Tw2Logger = Tw2Logger; -Tw2Logger.Type = { - THROW: 'error', - ERROR: 'error', - WARNING: 'warn', - WARN: 'warn', - INFO: 'info', - LOG: 'log', - DEBUG: 'debug' +EveChild.global = { + mat4_0: _global.mat4.create(), + vec3_0: _global.vec3.create() }; -var logger = exports.logger = new Tw2Logger('CCPWGL'); - -/** - * The default event logger logger - * @type {Tw2Logger} - */ -_Tw2EventEmitter2.Tw2EventEmitter.logger = logger; - -/***/ }), -/* 5 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ARRAY_TYPE", function() { return ARRAY_TYPE; }); -/* harmony export (immutable) */ __webpack_exports__["setMatrixArrayType"] = setMatrixArrayType; -/* harmony export (immutable) */ __webpack_exports__["toRadian"] = toRadian; -/* harmony export (immutable) */ __webpack_exports__["equals"] = equals; -/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. */ - -/** - * Common utilities - * @module glMatrix - */ - -// Configuration Constants -const EPSILON = 0.000001; -/* harmony export (immutable) */ __webpack_exports__["EPSILON"] = EPSILON; - -let ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array; -const RANDOM = Math.random; -/* harmony export (immutable) */ __webpack_exports__["RANDOM"] = RANDOM; - - -/** - * Sets the type of array used when creating new vectors and matrices - * - * @param {Type} type Array type, such as Float32Array or Array - */ -function setMatrixArrayType(type) { - ARRAY_TYPE = type; -} - -const degree = Math.PI / 180; - -/** - * Convert Degree To Radian - * - * @param {Number} a Angle in Degrees - */ -function toRadian(a) { - return a * degree; -} - -/** - * Tests whether or not the arguments have approximately the same value, within an absolute - * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less - * than or equal to 1.0, and a relative tolerance is used for larger values) - * - * @param {Number} a The first number to test. - * @param {Number} b The second number to test. - * @returns {Boolean} True if the numbers are approximately equal, false otherwise. - */ -function equals(a, b) { - return Math.abs(a - b) <= EPSILON*Math.max(1.0, Math.abs(a), Math.abs(b)); -} - - /***/ }), -/* 6 */ +/* 11 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -2207,501 +1839,364 @@ function equals(a, b) { Object.defineProperty(exports, "__esModule", { value: true }); -exports.resMan = exports.Tw2ResMan = undefined; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _Tw2Logger = __webpack_require__(4); +exports.EveObject = undefined; -var _Tw2Store = __webpack_require__(16); +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* eslint no-unused-vars:0 */ -var _Tw2MotherLode = __webpack_require__(78); -var _Tw2LoadingObject = __webpack_require__(37); +var _global = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** - * Resource Manager + * EveObject base class * - * @property {Boolean} systemMirror - Toggles whether {@link Tw2GeometryRes} Index and Buffer data arrays are visible - * @property {Tw2MotherLode} motherLode - * @property {Number} maxPrepareTime - * @property {Number} prepareBudget - * @property {Boolean} autoPurgeResources=true - Sets whether resources should be purged automatically - * @property {Number} purgeTime=30 = Sets how long resources can remain inactive before they are purged - * @property {Number} activeFrame - * @property {Array} _prepareQueue - * @property {Number} _purgeTime - * @property {Number} _purgeFrame - * @property {Number} _purgeFrameLimit - * @property {Number} _pendingLoads - a count of how many things are pending load - * @property {Number} _noLoadFrames + * @property {number} _id + * @property {string} name + * @property {boolean} display * @class */ -var Tw2ResMan = exports.Tw2ResMan = function () { - function Tw2ResMan() { - _classCallCheck(this, Tw2ResMan); +var EveObject = exports.EveObject = function () { + function EveObject() { + _classCallCheck(this, EveObject); - this.motherLode = new _Tw2MotherLode.Tw2MotherLode(); - this.systemMirror = false; - this.maxPrepareTime = 0.05; - this.prepareBudget = 0; - this.autoPurgeResources = true; - this.activeFrame = 0; - this.purgeTime = 30; - this._prepareQueue = []; - this._purgeTime = 0; - this._purgeFrame = 0; - this._purgeFrameLimit = 1000; - this._pendingLoads = 0; - this._noLoadFrames = 0; + this._id = _global.util.generateID(); + this.name = ''; + this.display = true; } /** - * IsLoading - * @returns {Boolean} - * + * Initializes the object */ - _createClass(Tw2ResMan, [{ - key: 'IsLoading', - value: function IsLoading() { - return this._noLoadFrames < 2; - } + _createClass(EveObject, [{ + key: 'Initialize', + value: function Initialize() {} /** - * Clears the motherLode {@link Tw2MotherLode} + * Gets object resources + * @param {Array} [out=[]] + * @returns {Array} out */ }, { - key: 'Clear', - value: function Clear() { - this.motherLode.Clear(); + key: 'GetResources', + value: function GetResources() { + var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + + return out; } /** - * Unloads and Clears the motherLode {@link Tw2MotherLode} + * Per frame update + * @param {number} dt - delta time */ }, { - key: 'UnloadAndClear', - value: function UnloadAndClear() { - this.motherLode.UnloadAndClear(); - } + key: 'Update', + value: function Update(dt) {} /** - * Internal update function. It is called every frame. - * @param {Number} dt - deltaTime - * @returns {Boolean} + * Accumulates batches + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator */ }, { - key: 'PrepareLoop', - value: function PrepareLoop(dt) { - if (this._prepareQueue.length === 0 && this._pendingLoads === 0) { - if (this._noLoadFrames < 2) { - this._noLoadFrames++; - } - } else { - this._noLoadFrames = 0; - } + key: 'GetBatches', + value: function GetBatches(mode, accumulator) {} + }]); - this.prepareBudget = this.maxPrepareTime; + return EveObject; +}(); - var startTime = Date.now(); - while (this._prepareQueue.length) { - var res = this._prepareQueue[0][0], - data = this._prepareQueue[0][1], - xml = this._prepareQueue[0][2]; +/** + * Class global and scratch variables + * @type {{string:*}} + */ - var handlesPrepareQueue = void 0; - try { - handlesPrepareQueue = res.Prepare(data, xml); - } catch (e) { - this._prepareQueue.shift(); - throw e; - } +EveObject.global = { + vec3_0: _global.vec3.create(), + vec3_1: _global.vec3.create(), + vec3_2: _global.vec3.create(), + vec3_3: _global.vec3.create(), + vec3_4: _global.vec3.create(), + vec3_5: _global.vec3.create(), + vec3_6: _global.vec3.create(), + vec3_7: _global.vec3.create(), + mat4_0: _global.mat4.create(), + mat4_1: _global.mat4.create(), + mat4_2: _global.mat4.create() +}; - if (!handlesPrepareQueue) { - _Tw2Logger.logger.log('res.event', { - msg: 'Prepared ', - path: res.path, - time: (Date.now() - startTime) * 0.001, - type: 'prepared' - }); +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { - this._prepareQueue.shift(); - } +"use strict"; - this.prepareBudget -= (Date.now() - startTime) * 0.001; - if (this.prepareBudget < 0) break; - } - this._purgeTime += dt; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2ParticleForce = undefined; - if (this._purgeTime > 1) { - this.activeFrame += 1; - this._purgeTime -= Math.floor(this._purgeTime); - this._purgeFrame += 1; +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* eslint no-unused-vars:0 */ - if (this._purgeFrame >= 5) { - if (this.autoPurgeResources) { - this.motherLode.PurgeInactive(this._purgeFrame, this._purgeFrameLimit, this.purgeTime); - } - } - } - return true; - } +var _global = __webpack_require__(0); - /** - * Gets a resource - * @param {String} path - * @returns {Tw2Resource} resource - */ +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - }, { - key: 'GetResource', - value: function GetResource(path) { - var res = void 0; - path = Tw2ResMan.NormalizePath(path); +/** + * Tw2ParticleForce base class + * + * @property {number|string} id + * @property {string} name + * @class + */ +var Tw2ParticleForce = exports.Tw2ParticleForce = function () { + function Tw2ParticleForce() { + _classCallCheck(this, Tw2ParticleForce); - // Check if already loaded - res = this.motherLode.Find(path); - if (res) { - if (res.IsPurged()) res.Reload(); - return res; - } + this._id = _global.util.generateID(); + this.name = ''; + } - var ext = Tw2ResMan.GetPathExt(path); - if (ext === null) { - _Tw2Logger.logger.log('res.error', { - log: 'error', - src: ['Tw2ResMan', 'ReloadResource'], - msg: 'Undefined extension', - type: 'extension.undefined', - path: path - }); - return null; - } + /** + * Applies forces + * @param {Tw2ParticleElement} position + * @param {Tw2ParticleElement} velocity + * @param {Tw2ParticleElement} force + * @param {number} dt + * @param {number} mass + */ - var Extension = _Tw2Store.store.GetExtension(ext); - if (!Extension) { - _Tw2Logger.logger.log('res.error', { - log: 'error', - src: ['Tw2ResMan', 'ReloadResource'], - msg: 'Unregistered extension', - type: 'extension.unregistered', - path: path, - value: ext - }); - return null; - } - res = new Extension(); - res.path = path; - return Tw2ResMan.LoadResource(this, res); - } + _createClass(Tw2ParticleForce, [{ + key: 'ApplyForce', + value: function ApplyForce(position, velocity, force, dt, mass) {} /** - * Gets a resource object - * @param {string} path - * @param {Function} callback + * Per frame update (Called before ApplyForce) + * @param {number} dt - delta time */ }, { - key: 'GetObject', - value: function GetObject(path, callback) { - var obj = {}; - path = Tw2ResMan.NormalizePath(path); + key: 'Update', + value: function Update(dt) {} + }]); - // Check if already loaded - var res = this.motherLode.Find(path); - if (res) { - res.AddObject(obj, callback); - return; - } + return Tw2ParticleForce; +}(); - res = new _Tw2LoadingObject.Tw2LoadingObject(); - res.path = path; - res.AddObject(obj, callback); - Tw2ResMan.LoadResource(this, res); - } +/** + * Class globals + * @type {*} + */ - /** - * Reloads a resource - * @param {Tw2Resource} resource - * @returns {Tw2Resource} resource - */ - }, { - key: 'ReloadResource', - value: function ReloadResource(resource) { - var path = resource.path; +Tw2ParticleForce.global = { + vec3_0: _global.vec3.create(), + vec3_1: _global.vec3.create(), + vec4_0: _global.vec4.create() +}; - // Check if already loaded and good - var res = this.motherLode.Find(path); - if (res && !res.IsPurged()) return res; +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { - _Tw2Logger.logger.log('res.event', { - msg: 'Reloading ', - path: path, - type: 'reload' - }); +"use strict"; - return Tw2ResMan.LoadResource(this, resource); - } - /** - * Builds a url from a resource path - * @param {string} resPath - * @returns {string} - */ +Object.defineProperty(exports, "__esModule", { + value: true +}); - }], [{ - key: 'BuildUrl', - value: function BuildUrl(resPath) { - var prefixIndex = resPath.indexOf(':/'); - if (prefixIndex === -1) { - _Tw2Logger.logger.log('res.error', { - log: 'warn', - src: ['Tw2ResMan', 'BuildUrl'], - msg: 'Invalid path', - type: 'prefix.undefined', - path: resPath - }); - return resPath; - } +var _Tw2Curve = __webpack_require__(2); - var prefix = resPath.substr(0, prefixIndex), - path = _Tw2Store.store.GetPath(prefix); +Object.keys(_Tw2Curve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2Curve[key]; + } + }); +}); - if (!path) { - _Tw2Logger.logger.log('res.error', { - log: 'warn', - src: ['Tw2ResMan', 'BuildUrl'], - msg: 'Unregistered path', - path: resPath, - type: 'prefix.unregistered', - value: prefix - }); - return resPath; - } +var _Tw2ColorCurve = __webpack_require__(128); - return path + resPath.substr(prefixIndex + 2); - } +Object.keys(_Tw2ColorCurve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2ColorCurve[key]; + } + }); +}); - /** - * Normalizes a file path by making it lower case and replaces all '\\' with '/' - * @param {string} path - * @returns {string} - */ +var _Tw2ColorCurve2 = __webpack_require__(129); - }, { - key: 'NormalizePath', - value: function NormalizePath(path) { - if (path.substr(0, 5) === 'str:/') return path; - path = path.toLowerCase(); - path.replace('\\', '/'); - return path; - } +Object.keys(_Tw2ColorCurve2).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2ColorCurve2[key]; + } + }); +}); - /** - * Gets a path's extension - * @param {string} path - * @returns {?string} - */ +var _Tw2EventCurve = __webpack_require__(130); - }, { - key: 'GetPathExt', - value: function GetPathExt(path) { - if (path.substr(0, 5) === 'str:/') { - var slash = path.indexOf('/', 5); - if (slash === -1) return null; - return path.substr(5, slash - 5); - } else { - var dot = path.lastIndexOf('.'); - if (dot === -1) return null; - return path.substr(dot + 1); - } - } +Object.keys(_Tw2EventCurve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2EventCurve[key]; + } + }); +}); - /** - * Returns a path suitable for logging by truncating really long file names - * @param {string} path - * @returns {string} - */ +var _Tw2PerlinCurve = __webpack_require__(131); - }, { - key: 'LogPathString', - value: function LogPathString(path) { - if (path.substr(0, 5) === 'str:/' && path.length > 64) { - return path.substr(0, 64) + '...'; - } - return path; - } +Object.keys(_Tw2PerlinCurve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2PerlinCurve[key]; + } + }); +}); - /** - * Loads a resource - * @param {Tw2ResMan} resMan - * @param {Tw2Resource} res - * @returns {Tw2Resource} - */ +var _Tw2QuaternionCurve = __webpack_require__(132); - }, { - key: 'LoadResource', - value: function LoadResource(resMan, res) { - var path = res.path, - url = Tw2ResMan.BuildUrl(path); +Object.keys(_Tw2QuaternionCurve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2QuaternionCurve[key]; + } + }); +}); - res._isPurged = false; - resMan.motherLode.Add(path, res); - if (res.DoCustomLoad && res.DoCustomLoad(url)) return res; +var _Tw2RandomConstantCurve = __webpack_require__(133); - var httpRequest = Tw2ResMan.CreateHttpRequest(res.requestResponseType); - if (httpRequest) { - _Tw2Logger.logger.log('res.event', { - msg: 'Requesting', - path: path, - type: 'request' - }); +Object.keys(_Tw2RandomConstantCurve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2RandomConstantCurve[key]; + } + }); +}); - httpRequest.onreadystatechange = Tw2ResMan.DoLoadResource(resMan, res); - httpRequest.open('GET', url); - res.LoadStarted(); +var _Tw2RigidOrientation = __webpack_require__(134); - try { - httpRequest.send(); - resMan._pendingLoads++; - } catch (e) { - _Tw2Logger.logger.log('res.error', { - log: 'error', - src: ['Tw2ResMan', 'LoadResource'], - msg: 'Error sending object HTTP request', - path: path, - type: 'http.request', - err: e - }); - } - } - return res; - } +Object.keys(_Tw2RigidOrientation).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2RigidOrientation[key]; + } + }); +}); - /** - * Creates an onreadystatechange callback - * @param {Tw2ResMan} resMan - * @param {Tw2Resource} res - */ +var _Tw2RotationCurve = __webpack_require__(135); - }, { - key: 'DoLoadResource', - value: function DoLoadResource(resMan, res) { - return function () { - var readyState = 0; +Object.keys(_Tw2RotationCurve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2RotationCurve[key]; + } + }); +}); - try { - readyState = this.readyState; - } catch (e) { - _Tw2Logger.logger.log('res.error', { - log: 'error', - src: ['Tw2ResMan', '_DoLoadResource'], - msg: 'Communication error loading', - path: res.path, - type: 'http.readystate', - value: readyState - }); +var _Tw2ScalarCurve = __webpack_require__(136); - res.LoadFinished(false); - resMan._pendingLoads--; - return; - } +Object.keys(_Tw2ScalarCurve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2ScalarCurve[key]; + } + }); +}); - if (readyState === 4) { - if (this.status === 200) { - var data = null, - xml = null; +var _Tw2ScalarCurve2 = __webpack_require__(137); - try { - data = this.responseText; - xml = this.responseXML; - } catch (e) { - data = this.response; - } +Object.keys(_Tw2ScalarCurve2).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2ScalarCurve2[key]; + } + }); +}); - res.LoadFinished(true); - resMan._prepareQueue.push([res, data, xml]); - } else { - _Tw2Logger.logger.log('res.error', { - log: 'error', - src: ['Tw2ResMan', '_DoLoadResource'], - msg: 'Communication error loading', - path: res.path, - type: 'http.status', - value: this.status - }); - res.LoadFinished(false); - res.PrepareFinished(false); - } - resMan._pendingLoads--; - } - }; - } +var _Tw2SineCurve = __webpack_require__(138); - /** - * Creates an HTTP request - * @param {?string} [responseType] - * @returns {XMLHttpRequest|ActiveXObject} - */ +Object.keys(_Tw2SineCurve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2SineCurve[key]; + } + }); +}); - }, { - key: 'CreateHttpRequest', - value: function CreateHttpRequest(responseType) { - var httpRequest = null; +var _Tw2Vector2Curve = __webpack_require__(139); - if (window.XMLHttpRequest) { - // Mozilla, Safari, ... - httpRequest = new XMLHttpRequest(); - } else if (window.ActiveXObject) { - // IE - try { - httpRequest = new window['ActiveXObject']('Msxml2.XMLHTTP'); - } catch (e) { - try { - httpRequest = new window['ActiveXObject']('Microsoft.XMLHTTP'); - } catch (e) { - /*eslint-disable-line-no-empty*/ - } - } - } - - if (!httpRequest) { - _Tw2Logger.logger.log('res.error', { - log: 'error', - src: ['Tw2LoadingObject', 'Prepare'], - msg: 'Could not create an XMLHTTP instance', - type: 'http.instance' - }); - } else if (responseType) { - httpRequest.responseType = responseType; - } - - return httpRequest; - } - }]); +Object.keys(_Tw2Vector2Curve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2Vector2Curve[key]; + } + }); +}); - return Tw2ResMan; -}(); +var _Tw2Vector3Curve = __webpack_require__(140); -// Global instance of Tw2ResMan +Object.keys(_Tw2Vector3Curve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2Vector3Curve[key]; + } + }); +}); +var _Tw2VectorCurve = __webpack_require__(141); -var resMan = exports.resMan = new Tw2ResMan(); +Object.keys(_Tw2VectorCurve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2VectorCurve[key]; + } + }); +}); /***/ }), -/* 7 */ +/* 14 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -2710,382 +2205,317 @@ var resMan = exports.resMan = new Tw2ResMan(); Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2VectorParameter = exports.Tw2Parameter = undefined; - -var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* eslint no-unused-vars:0 */ +exports.Tw2ParticleElementDeclaration = exports.Tw2ParticleElement = undefined; +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _core = __webpack_require__(1); -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } +/** + * Tw2ParticleElement + * + * @param {Tw2ParticleElementDeclaration} decl + * @property {number} elementType + * @property {string} customName + * @property {number} dimension + * @property {number} usageIndex + * @property {boolean} usedByGPU + * @property buffer + * @property {number} startOffset + * @property {number} offset + * @property {number} instanceStride + * @property {number} vertexStride + * @property {boolean} dirty + * @class + */ +var Tw2ParticleElement = exports.Tw2ParticleElement = function Tw2ParticleElement(decl) { + _classCallCheck(this, Tw2ParticleElement); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + this.elementType = decl.elementType; + this.customName = decl.customName; + this.dimension = decl.GetDimension(); + this.usageIndex = decl.usageIndex; + this.usedByGPU = decl.usedByGPU; + this.buffer = null; + this.startOffset = 0; + this.offset = 0; + this.instanceStride = 0; + this.vertexStride = 0; + this.dirty = false; +}; /** - * Tw2Parameter base class + * Tw2ParticleElementDeclaration * - * @param {string} [name=''] - * @property {string|number} _id - * @property {string} name - * @property {Array} _onModified + * @property {number} elementType=4 + * @property {string} customName + * @property {number} dimension=1 + * @property {number} usageIndex + * @property {boolean} usedByGPU + * @class */ -var Tw2Parameter = exports.Tw2Parameter = function () { - function Tw2Parameter() { - var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - _classCallCheck(this, Tw2Parameter); - this._id = _math.util.generateID(); - this.name = name; - this._onModified = []; +var Tw2ParticleElementDeclaration = exports.Tw2ParticleElementDeclaration = function () { + function Tw2ParticleElementDeclaration() { + _classCallCheck(this, Tw2ParticleElementDeclaration); + + this.elementType = 4; + this.customName = ''; + this.dimension = 1; + this.usageIndex = 0; + this.usedByGPU = true; } /** - * Gets the parameter's constant buffer size - * @returns {number} 0 if invalid + * Gets the dimension of an element type + * @returns {number} */ - _createClass(Tw2Parameter, [{ - key: 'OnValueChanged', - + _createClass(Tw2ParticleElementDeclaration, [{ + key: 'GetDimension', + value: function GetDimension() { + switch (this.elementType) { + case Tw2ParticleElementDeclaration.Type.LIFETIME: + return 2; - /** - * Fire on value changes - * @property {*} [controller] - An optional object which changed the parameter's value - * @property {string[]} [properties] - An optional array for tracking the parameters that were updated - */ - value: function OnValueChanged(controller, properties) { - for (var i = 0; i < this._onModified.length; i++) { - this._onModified[i](this, controller, properties); - } - } + case Tw2ParticleElementDeclaration.Type.POSITION: + return 3; - /** - * Adds a callback which is fired when the parameter's OnValueChanged method is called - * @param {function} func - * @returns {boolean} true if successful - */ + case Tw2ParticleElementDeclaration.Type.VELOCITY: + return 3; - }, { - key: 'AddCallback', - value: function AddCallback(func) { - if (!this._onModified.includes(func)) { - this._onModified.push(func); + case Tw2ParticleElementDeclaration.Type.MASS: + return 1; } - return true; + return this.dimension; } /** - * Removes a callback - * @param {Function} func + * GetDeclaration + * @returns {Tw2VertexElement} */ }, { - key: 'RemoveCallback', - value: function RemoveCallback(func) { - var index = this._onModified.indexOf(func); - if (index !== -1) { - this._onModified.splice(index, 1); - } - } + key: 'GetDeclaration', + value: function GetDeclaration() { + var usage = void 0; + switch (this.elementType) { + case Tw2ParticleElementDeclaration.Type.LIFETIME: + usage = _core.Tw2VertexDeclaration.Type.TANGENT; + break; - /** - * Gets the parameter's value - * @param {boolean} [serialize] - forces serialized result - * @returns {null} - */ + case Tw2ParticleElementDeclaration.Type.POSITION: + usage = _core.Tw2VertexDeclaration.Type.POSITION; + break; - }, { - key: 'GetValue', - value: function GetValue(serialize) { - return null; - } + case Tw2ParticleElementDeclaration.Type.VELOCITY: + usage = _core.Tw2VertexDeclaration.Type.NORMAL; + break; - /** - * Binds the parameter - * @param {*} a - * @param {*} b - * @param {*} c - * @returns {boolean} false if not bound - */ + case Tw2ParticleElementDeclaration.Type.MASS: + usage = _core.Tw2VertexDeclaration.Type.BINORMAL; + break; - }, { - key: 'Bind', - value: function Bind(a, b, c) { - return false; + default: + usage = _core.Tw2VertexDeclaration.Type.TEXCOORD; + } + + return new _core.Tw2VertexElement(usage, this.usageIndex, _core.device.gl.FLOAT, this.GetDimension()); } + }]); - /** - * Unbinds the parameter - */ + return Tw2ParticleElementDeclaration; +}(); - }, { - key: 'UnBind', - value: function UnBind() {} +/** + * Particle element declaration types + * @type {{LIFETIME: number, POSITION: number, VELOCITY: number, MASS: number, CUSTOM: number}} + */ - /** - * Applies the parameter to a constant buffer - * @param {*} a - * @param {*} b - * @param {*} c - */ - }, { - key: 'Apply', - value: function Apply(a, b, c) {} +Tw2ParticleElementDeclaration.Type = { + LIFETIME: 0, + POSITION: 1, + VELOCITY: 2, + MASS: 3, + CUSTOM: 4 +}; - /** - * Copies another parameter's value - * @param {*} parameter - */ +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { - }, { - key: 'Copy', - value: function Copy(parameter) {} +"use strict"; - /** - * Clones the parameter - * @returns {Tw2Parameter} - */ - }, { - key: 'Clone', - value: function Clone() { - var parameter = new this.constructor(); - parameter.Copy(this, true); - return parameter; - } - }, { - key: 'size', - get: function get() { - return this.constructor.constantBufferSize; - } - }]); +Object.defineProperty(exports, "__esModule", { + value: true +}); - return Tw2Parameter; -}(); +var _Tw2BatchAccumulator = __webpack_require__(66); -/** - * The parameter's constant buffer size - * @type {number} - */ +Object.keys(_Tw2BatchAccumulator).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2BatchAccumulator[key]; + } + }); +}); +var _Tw2ForwardingRenderBatch = __webpack_require__(90); -Tw2Parameter.constantBufferSize = 0; +Object.keys(_Tw2ForwardingRenderBatch).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2ForwardingRenderBatch[key]; + } + }); +}); -/** - * Tw2VectorParameter base class - * - * @property {Float32Array} value - * @property {?Float32Array} constantBuffer - * @property {?number} offset - * @class - */ +var _Tw2GeometryBatch = __webpack_require__(23); -var Tw2VectorParameter = exports.Tw2VectorParameter = function (_Tw2Parameter) { - _inherits(Tw2VectorParameter, _Tw2Parameter); +Object.keys(_Tw2GeometryBatch).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2GeometryBatch[key]; + } + }); +}); - function Tw2VectorParameter(name, value) { - _classCallCheck(this, Tw2VectorParameter); +var _Tw2GeometryLineBatch = __webpack_require__(91); - var _this = _possibleConstructorReturn(this, (Tw2VectorParameter.__proto__ || Object.getPrototypeOf(Tw2VectorParameter)).call(this, name)); +Object.keys(_Tw2GeometryLineBatch).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2GeometryLineBatch[key]; + } + }); +}); - _this.value = new Float32Array(_this.size); - _this.constantBuffer = null; - _this.offset = null; - if (value) _this.value.set(value); - return _this; +var _Tw2RenderBatch = __webpack_require__(22); + +Object.keys(_Tw2RenderBatch).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2RenderBatch[key]; } + }); +}); - /** - * Sets the parameter's value - * @param {Float32Array} value - */ +var _Tw2InstancedMeshBatch = __webpack_require__(92); +Object.keys(_Tw2InstancedMeshBatch).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2InstancedMeshBatch[key]; + } + }); +}); - _createClass(Tw2VectorParameter, [{ - key: 'SetValue', - value: function SetValue(value) { - this.value.set(value); - this.OnValueChanged(); - } +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { - /** - * Sets a parameter's value at a given index - * @param {number} index - the parameter's value index to change - * @param {number} value - the value to set - * @throw Index Error - */ +"use strict"; - }, { - key: 'SetIndexValue', - value: function SetIndexValue(index, value) { - if (this.value[index] !== undefined) { - if (this.value[index] !== value) { - this.value[index] = value; - this.OnValueChanged(); - } - return; - } - throw new Error('Index Error'); - } +Object.defineProperty(exports, "__esModule", { + value: true +}); - /** - * Gets the parameter's value - * @param {boolean} [serialize] - An optional parameter to force a serialized result - * @returns {Array|Float32Array} - */ +var _arr = __webpack_require__(35); - }, { - key: 'GetValue', - value: function GetValue(serialize) { - var value = this.constantBuffer ? this.constantBuffer.subarray(this.offset, this.offset + this.size) : this.value; - return serialize ? Array.from(value) : new Float32Array(value); - } +Object.keys(_arr).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _arr[key]; + } + }); +}); - /** - * Gets a parameter's value at a given index - * @param index - * @returns {number} - * @throw Index Error - */ +var _obj = __webpack_require__(80); - }, { - key: 'GetIndexValue', - value: function GetIndexValue(index) { - if (this.value[index] !== undefined) { - return this.value[index]; - } - throw new Error('Index Error'); - } +Object.keys(_obj).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _obj[key]; + } + }); +}); - /** - * Fire on value changes - * @param {*} [controller] - An optional parameter for tracking the object that called the function - * @param {string[]} [properties] - An optional array for tracking the parameters that were updated - */ +var _type = __webpack_require__(20); - }, { - key: 'OnValueChanged', - value: function OnValueChanged(controller, properties) { - if (this.constantBuffer) { - this.Apply(this.constantBuffer, this.offset); - } +Object.keys(_type).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _type[key]; + } + }); +}); - _get(Tw2VectorParameter.prototype.__proto__ || Object.getPrototypeOf(Tw2VectorParameter.prototype), 'OnValueChanged', this).call(this, controller, properties); - } +var _uuid = __webpack_require__(81); - /** - * Binds the parameter to a constant buffer - * @param {Float32Array} constantBuffer - * @param {number} offset - * @param {number} size - * @returns {boolean} true if bound - */ +Object.keys(_uuid).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _uuid[key]; + } + }); +}); - }, { - key: 'Bind', - value: function Bind(constantBuffer, offset, size) { - if (!this.constantBuffer && size >= this.size) { - this.constantBuffer = constantBuffer; - this.offset = offset; - this.Apply(constantBuffer, offset, size); - return true; - } - return false; - } +var _url = __webpack_require__(82); - /** - * Unbinds the parameter from a constant buffer - */ +Object.keys(_url).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _url[key]; + } + }); +}); - }, { - key: 'Unbind', - value: function Unbind() { - this.constantBuffer = null; - } +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { - /** - * Applies the parameter's value to it's constant buffer - * @param {Float32Array} constantBuffer - * @param {number} offset - * @param {number} [size] - */ - - }, { - key: 'Apply', - value: function Apply(constantBuffer, offset, size) { - constantBuffer.set(this.value, offset); - } - - /** - * Checks if a value equals the parameter's value - * - Assumes the correct length array or typed array is passed - * @param {Array|Float32Array} value - * @returns {boolean} - */ - - }, { - key: 'EqualsValue', - value: function EqualsValue(value) { - for (var i = 0; i < this.size; i++) { - if (this.value[i] !== value[i]) { - return false; - } - } - return true; - } - - /** - * Copies another parameter's value - * @param {Tw2VectorParameter|*} parameter - * @param {boolean} [includeName] - */ - - }, { - key: 'Copy', - value: function Copy(parameter, includeName) { - if (includeName) this.name = parameter.name; - this.SetValue(parameter.GetValue()); - } - - /** - * Checks if a value is a valid parameter input - * @param {Float32Array|Array} value - * @returns {boolean} - */ - - }], [{ - key: 'is', - value: function is(value) { - return _math.util.isArrayLike(value) && value.length === this.constantBufferSize; - } - }]); - - return Tw2VectorParameter; -}(Tw2Parameter); - -/***/ }), -/* 8 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2CurveSequencer = undefined; +exports.logger = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _curves = __webpack_require__(19); +var _class = __webpack_require__(36); + +var _util = __webpack_require__(16); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -3094,79 +2524,172 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2CurveSequencer base class + * Event log + * @typedef {*} eventLog + * @property {string} log - Desired console output type + * @property {string} msg - A message to log + * @property {string} path - An optional resource path + * @property {number} time - An optional time + * @property {string} type - The type of log + * @property {*} value - An optional value + * @property {*} data - An optional values object + * @property {Error} err - An optional caught error + * @property {boolean} hide - True to skip console output + * @property {boolean} logged - Identifies if the log has been logged + */ + +/** + * Handles basic event logging * - * @class + * @param {string} [name=''] - The logger's name + * @property {string} name - The name of the logger and it's prefix + * @property {{}} visible - Visibility options + * @property {boolean} visible.log - Toggles console log output + * @property {boolean} visible.info - Toggles console info output + * @property {boolean} visible.debug - Toggles console debug output + * @property {boolean} visible.warn - Toggles console warn output + * @property {boolean} visible.error - Toggles console error output + * @property {number} maxLogs - The maximum logs that will be stored + * @property {boolean} display - Enabled console logging + * @property {Array} _logs - Stored logs + * @property {?Function} _onNewLog - On new log */ -var Tw2CurveSequencer = exports.Tw2CurveSequencer = function (_Tw2Curve) { - _inherits(Tw2CurveSequencer, _Tw2Curve); +var Tw2Logger = function (_Tw2EventEmitter) { + _inherits(Tw2Logger, _Tw2EventEmitter); - function Tw2CurveSequencer() { - _classCallCheck(this, Tw2CurveSequencer); + function Tw2Logger() { + var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - return _possibleConstructorReturn(this, (Tw2CurveSequencer.__proto__ || Object.getPrototypeOf(Tw2CurveSequencer)).call(this)); + _classCallCheck(this, Tw2Logger); + + var _this = _possibleConstructorReturn(this, (Tw2Logger.__proto__ || Object.getPrototypeOf(Tw2Logger)).call(this)); + + _this.name = name; + _this.display = true; + _this.visible = {}; + _this.visible.log = true; + _this.visible.info = true; + _this.visible.debug = true; + _this.visible.warn = true; + _this.visible.error = true; + _this.maxLogs = 100; + _this._logs = []; + return _this; } /** - * Legacy sequencer sorting - * @param {Tw2CurveSequencer} sequencer + * Adds an event log and outputs it to the console + * @param {string} eventName + * @param {eventLog} log + * @returns {eventLog} log */ - _createClass(Tw2CurveSequencer, null, [{ - key: 'Sort', - value: function Sort(sequencer) { - var curves = sequencer['functions']; - if (curves && curves.length) { - for (var i = 0; i < curves.length; i++) { - if (curves[i] && 'Sort' in curves[i]) curves[i].Sort(); + _createClass(Tw2Logger, [{ + key: 'log', + value: function log(eventName, _log) { + if (_log.logged) return _log; + + _log.log = Tw2Logger.Type[_log.log ? _log.log.toUpperCase() : 'LOG'] || 'log'; + + if (!_log.hide && this.display && this.visible[_log.log]) { + var header = this.name + ': {' + eventName + '}'; + var body = _log.msg || ''; + + if (_log.path) { + body += ' \'' + _log.path + '\''; + if ('time' in _log) body += ' in ' + _log.time.toFixed(3) + ' secs'; + } + + if (_log.value !== undefined || _log.type) { + body += ' ('; + if (_log.type) body += _log.type; + if (_log.type && _log.value !== undefined) body += ':'; + if (_log.value !== undefined) body += _log.value; + body += ')'; + } + + if ('data' in _log || 'err' in _log) { + console.group(header); + console[_log.log](body); + if (_log.data) console.debug(_log.data); + if (_log.err) console.debug(_log.err.stack || _log.err.toString()); + console.groupEnd(); + } else { + console[_log.log](header, body); + } + } + + if (this.maxLogs) { + if (this._logs.length >= this.maxLogs) { + this._logs.splice(this.maxLogs, this._logs.length - 1); } + this._logs.unshift(_log); + } else { + this._logs = []; } + + this.emit('log', _log); + _log.logged = true; + return _log; } /** - * Standard sequencer sorting - * @param {Tw2CurveSequencer} sequencer + * Gets an array of logs + * @param {number} [count] + * @returns {Array} */ }, { - key: 'Sort2', - value: function Sort2(sequencer) { - var names = sequencer.constructor.childProperties; - if (names) { - for (var i = 0; i < names.length; i++) { - var curve = sequencer[names[i]]; - if (curve && 'Sort' in curve) curve.Sort(); - } - } + key: 'GetLogs', + value: function GetLogs(count) { + return Object.assign([], count === undefined ? this._logs : this._logs.splice(0, count)); + } + + /** + * Sets the logger's properties + * @param {*} [opt={}] + */ + + }, { + key: 'Set', + value: function Set() { + var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + (0, _util.assignIfExists)(this, opt, ['name', 'maxLogs', 'display']); + (0, _util.assignIfExists)(this.visible, opt.visible, ['log', 'info', 'debug', 'warn', 'error']); } }]); - return Tw2CurveSequencer; -}(_curves.Tw2Curve); + return Tw2Logger; +}(_class.Tw2EventEmitter); /** - * The sequencer's curve property names - * @type {?Array.} + * Console outputs + * @type {{THROW: string, ERROR: string, WARNING: string, WARN: string, INFO: string, LOG: string, DEBUG: string}} */ -Tw2CurveSequencer.childProperties = null; +Tw2Logger.Type = { + THROW: 'error', + ERROR: 'error', + WARNING: 'warn', + WARN: 'warn', + INFO: 'info', + LOG: 'log', + DEBUG: 'debug' +}; -/** - * The sequencer's curve array - * @type {?string} - */ -Tw2CurveSequencer.childArray = null; +var logger = exports.logger = new Tw2Logger('CCPWGL'); /** - * Operator types - * @type {null} + * The default event logger logger + * @type {Tw2Logger} */ -Tw2CurveSequencer.Operator = null; +_class.Tw2EventEmitter.logger = logger; /***/ }), -/* 9 */ +/* 18 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -3176,617 +2699,741 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2VertexDeclaration = __webpack_require__(80); +var _num = __webpack_require__(29); -Object.keys(_Tw2VertexDeclaration).forEach(function (key) { +Object.keys(_num).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { - return _Tw2VertexDeclaration[key]; + return _num[key]; } }); }); -var _Tw2VertexElement = __webpack_require__(43); +var _vec = __webpack_require__(67); -Object.keys(_Tw2VertexElement).forEach(function (key) { +Object.keys(_vec).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { - return _Tw2VertexElement[key]; + return _vec[key]; } }); }); -/***/ }), -/* 10 */ -/***/ (function(module, exports, __webpack_require__) { +var _vec2 = __webpack_require__(33); -"use strict"; +Object.keys(_vec2).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _vec2[key]; + } + }); +}); +var _vec3 = __webpack_require__(34); -Object.defineProperty(exports, "__esModule", { - value: true +Object.keys(_vec3).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _vec3[key]; + } + }); }); -exports.EveObjectSet = exports.EveObjectSetItem = undefined; -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* eslint no-unused-vars:0 */ +var _quat = __webpack_require__(73); +Object.keys(_quat).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _quat[key]; + } + }); +}); -var _math = __webpack_require__(0); +var _mat = __webpack_require__(74); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +Object.keys(_mat).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _mat[key]; + } + }); +}); -/** - * EveObjectSetItem base class - * - * @property {string|number} _id - The set item's id - * @property {string} name - The set item's name - * @property {boolean} display - Toggles the set item's visibility - * @property {?Function} _onModified - A callback which is fired on value changes - */ -var EveObjectSetItem = exports.EveObjectSetItem = function () { - function EveObjectSetItem() { - _classCallCheck(this, EveObjectSetItem); +var _mat2 = __webpack_require__(75); - this._id = _math.util.generateID(); - this.name = ''; - this.display = true; - this._rebuildPending = true; - this._onModified = null; +Object.keys(_mat2).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _mat2[key]; } + }); +}); - /** - * Fire on value changes - */ +var _noise = __webpack_require__(76); +Object.keys(_noise).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _noise[key]; + } + }); +}); - _createClass(EveObjectSetItem, [{ - key: 'OnValueChanged', - value: function OnValueChanged() { - this._rebuildPending = true; - if (this._onModified) this._onModified(this); - } - }]); +var _curve = __webpack_require__(77); - return EveObjectSetItem; -}(); +Object.keys(_curve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _curve[key]; + } + }); +}); + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.store = undefined; + +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _util = __webpack_require__(16); + +var _Tw2Logger = __webpack_require__(17); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** - * EveObjectSet base class + * Stores engine data * - * @property {number|String} _id - The set's id - * @property {string} name - The set's name - * @property {boolean} display - Toggles set visibility - * @property {Array} items - The set's items - * @property {Array} _visibleItems - The set's items that will be rendered when the set is visible - * @property {boolean} _rebuildPending - Identifies if the set requires rebuilding + * @property {Object.< string, string>} _path + * @property {Object.< string, Array>} _dynamicPath + * @property {Object.< string, Tw2Parameter>} _variable + * @property {Object.< string, Function>} _type + * @property {Object.< string, Function>} _extension + * @property {Object.< string, Function>} _constructor + * @property {Object.< string, Tw2Schema>} _schema + * @property {Object.< string, Array>} _missing * @class */ +var Tw2Store = function () { + function Tw2Store() { + _classCallCheck(this, Tw2Store); - -var EveObjectSet = exports.EveObjectSet = function () { - function EveObjectSet() { - var _this = this; - - _classCallCheck(this, EveObjectSet); - - this._id = _math.util.generateID(); - this.name = ''; - this.display = true; - this.items = []; - this._visibleItems = []; - this._rebuildPending = false; - this._onChildModified = function (item) { - return _this.OnValueChanged(item); - }; + this._type = {}; + this._path = {}; + this._variable = {}; + this._extension = {}; + this._constructor = {}; + this._dynamicPath = {}; + this._schema = {}; + this._missing = {}; } /** - * Initializes the set + * Checks if a resource path exists + * @param {string} prefix + * @returns {boolean} */ - _createClass(EveObjectSet, [{ - key: 'Initialize', - value: function Initialize() { - this.Rebuild(); + _createClass(Tw2Store, [{ + key: 'HasPath', + value: function HasPath(prefix) { + return prefix && prefix in this._path; } /** - * Fires on value changes + * Gets a path by it's prefix + * @param {string} prefix + * @returns {?string} */ }, { - key: 'OnValueChanged', - value: function OnValueChanged() { - this._rebuildPending = true; + key: 'GetPath', + value: function GetPath(prefix) { + return Tw2Store.GetStoreItem(this, 'path', prefix); } /** - * Creates an item from an options object and then adds it to the set - * @param {*} [opt={}] - * @returns {?EveObjectSetItem|*} + * Registers a resource path + * @param {string} prefix + * @param {string} path + * @returns {boolean} */ }, { - key: 'CreateItem', - value: function CreateItem() { - var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - var Item = this.constructor.Item; - if (Item && 'create' in Item) { - var item = Item.create(opt); - this.AddItem(item); - return item; - } - return null; + key: 'RegisterPath', + value: function RegisterPath(prefix, path) { + return Tw2Store.SetStoreItem(this, 'path', prefix, path, _util.isString); } /** - * Adds a set item - * @param {EveObjectSetItem|*} item + * Registers resource paths from an object or an array of objects + * @param {{string:string}|Array<{string:string}>} obj + * @returns {boolean} */ }, { - key: 'AddItem', - value: function AddItem(item) { - if (!this.items.includes(item)) { - item._onModified = this._onChildModified; - this.items.push(item); - this.OnValueChanged(); - } + key: 'RegisterPaths', + value: function RegisterPaths(obj) { + return Tw2Store.RegisterFromObject(this, 'RegisterPath', obj); } /** - * Removes a set item - * @param {EveObjectSetItem|*} item + * Checks if a dynamic path exists + * @param {string} prefix + * @returns {boolean} */ }, { - key: 'RemoveItem', - value: function RemoveItem(item) { - var index = this.items.indexOf(item); - if (index !== -1) { - item._onModified = null; - this.items.splice(index, 1); - this.OnValueChanged(); - } + key: 'HasDynamicPath', + value: function HasDynamicPath(prefix) { + return prefix && prefix in this._dynamicPath; } /** - * Clears all set items + * Gets a dynamic path by it's prefix + * @param {string} prefix + * @returns {?Array} */ }, { - key: 'ClearItems', - value: function ClearItems() { - for (var i = 0; i < this.items.length; i++) { - this.items[i]._onModified = null; - } - this.items = []; - this.OnValueChanged(); + key: 'GetDynamicPath', + value: function GetDynamicPath(prefix) { + return Tw2Store.GetStoreItem(this, 'dynamicPath', prefix); } /** - * Finds an item by it's id - * @param {?number} [id=null] - * @returns {?EveObjectSetItem|*} + * Registers a dynamic path + * @param {string} prefix + * @param {string[]} paths + * @returns {boolean} */ }, { - key: 'FindItemByID', - value: function FindItemByID() { - var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - - if (id !== null) { - for (var i = 0; i < this.items.length; i++) { - if (this.items[i]._id === id) { - return this.items[i]; - } - } - } - return null; + key: 'RegisterDynamicPath', + value: function RegisterDynamicPath(prefix, paths) { + return Tw2Store.SetStoreItem(this, 'dynamicPath', prefix, paths, _util.isArray); } /** - * Gets the set's resources - * @param {Array} [out=[]] - * @returns {Array} + * Registers dynamic paths from an object or array of objects + * @param {{string:string[]}|Array<{string:string[]}>} obj + * @returns {boolean} */ }, { - key: 'GetResources', - value: function GetResources() { - var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - - return out; + key: 'RegisterDynamicPaths', + value: function RegisterDynamicPaths(obj) { + return Tw2Store.RegisterFromObject(this, 'RegisterDynamicPath', obj); } /** - * Per frame update - * @param {number} dt + * Checks if an extension exists + * @param {string} ext + * @returns {boolean} */ }, { - key: 'Update', - value: function Update(dt) { - if (this._rebuildPending) { - this.Rebuild(); - } + key: 'HasExtension', + value: function HasExtension(ext) { + return ext && ext in this._extension; } /** - * Unloads the set's buffers + * Gets a resource extension by name + * @param {string} ext + * @returns {?Function} */ }, { - key: 'Unload', - value: function Unload() {} + key: 'GetExtension', + value: function GetExtension(ext) { + return Tw2Store.GetStoreItem(this, 'extension', ext); + } /** - * Rebuilds the set + * Registers a resource extension + * @param {string} ext + * @param {Function} Constructor + * @returns {boolean} */ }, { - key: 'Rebuild', - value: function Rebuild() { - this.constructor.RebuildItems(this); - this._rebuildPending = false; + key: 'RegisterExtension', + value: function RegisterExtension(ext, Constructor) { + return Tw2Store.SetStoreItem(this, 'extension', ext, Constructor, _util.isFunction); } /** - * Gets render batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator - * @param {Tw2PerObjectData|Tw2BasicPerObjectData} perObjectData + * Registers resource extensions from an object or array of objects + * @param {{string:Function}|Array<{string:Function}>} obj + * @returns {boolean} */ }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator, perObjectData) {} + key: 'RegisterExtensions', + value: function RegisterExtensions(obj) { + return Tw2Store.RegisterFromObject(this, 'RegisterExtension', obj); + } /** - * Renders the set + * Checks if a constructor exists + * @param {string} name + * @returns {boolean} */ }, { - key: 'Render', - value: function Render() {} + key: 'HasConstructor', + value: function HasConstructor(name) { + return name && name in this._constructor; + } /** - * Rebuilds the set's items - * - * @param {EveObjectSet|*} eveSet + * Gets a library constructor by name + * @param {string} name + * @returns {?Function} */ - }], [{ - key: 'RebuildItems', - value: function RebuildItems(eveSet) { - eveSet._visibleItems = []; - for (var i = 0; i < eveSet.items.length; i++) { - var item = eveSet.items[i]; - item._onModified = eveSet._onChildModified; - - if (item.display) { - eveSet._visibleItems.push(item); - item._rebuildPending = false; - } - } + }, { + key: 'GetConstructor', + value: function GetConstructor(name) { + return Tw2Store.GetStoreItem(this, 'constructor', name); } - }]); - - return EveObjectSet; -}(); -/** - * The object set's item - * @type {?Function} - */ - - -EveObjectSet.Item = null; - -/** - * Class global and scratch variables - * @type {{vec3_0, vec3_1, vec3_2}} - */ -EveObjectSet.global = { - vec3_0: _math.vec3.create(), - vec3_1: _math.vec3.create(), - vec3_2: _math.vec3.create(), - vec4_0: _math.vec4.create(), - vec4_1: _math.vec4.create(), - mat4_0: _math.mat4.create() -}; - -/***/ }), -/* 11 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__gl_matrix_common__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__gl_matrix_mat2__ = __webpack_require__(67); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__gl_matrix_mat2d__ = __webpack_require__(68); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__gl_matrix_mat3__ = __webpack_require__(31); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__gl_matrix_mat4__ = __webpack_require__(69); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__gl_matrix_quat__ = __webpack_require__(70); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__gl_matrix_vec2__ = __webpack_require__(71); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__gl_matrix_vec3__ = __webpack_require__(32); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__gl_matrix_vec4__ = __webpack_require__(33); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "glMatrix", function() { return __WEBPACK_IMPORTED_MODULE_0__gl_matrix_common__; }); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "mat2", function() { return __WEBPACK_IMPORTED_MODULE_1__gl_matrix_mat2__; }); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "mat2d", function() { return __WEBPACK_IMPORTED_MODULE_2__gl_matrix_mat2d__; }); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "mat3", function() { return __WEBPACK_IMPORTED_MODULE_3__gl_matrix_mat3__; }); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "mat4", function() { return __WEBPACK_IMPORTED_MODULE_4__gl_matrix_mat4__; }); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "quat", function() { return __WEBPACK_IMPORTED_MODULE_5__gl_matrix_quat__; }); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "vec2", function() { return __WEBPACK_IMPORTED_MODULE_6__gl_matrix_vec2__; }); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "vec3", function() { return __WEBPACK_IMPORTED_MODULE_7__gl_matrix_vec3__; }); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "vec4", function() { return __WEBPACK_IMPORTED_MODULE_8__gl_matrix_vec4__; }); -/** - * @fileoverview gl-matrix - High performance matrix and vector operations - * @author Brandon Jones - * @author Colin MacKenzie IV - * @version 2.4.0 - */ - -/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. + /** + * Registers library constructors + * @param {string} name + * @param {Function} Constructor + * @returns {boolean} + */ -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: + }, { + key: 'RegisterConstructor', + value: function RegisterConstructor(name, Constructor) { + if ((0, _util.isFunction)(Constructor)) { + return Tw2Store.SetStoreItem(this, 'constructor', name, Constructor); + } + return false; + } -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. + /** + * Registers library constructors from an object or array of objects + * @param {{string:Function}|Array<{string:Function}>} obj + * @returns {boolean} + */ -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. */ -// END HEADER + }, { + key: 'RegisterConstructors', + value: function RegisterConstructors(obj) { + return Tw2Store.RegisterFromObject(this, 'RegisterConstructor', obj); + } + /** + * Checks if a variable exists + * @param {string} name + * @returns {boolean} + */ + }, { + key: 'HasVariable', + value: function HasVariable(name) { + return name && name in this._variable; + } + /** + * Gets a variable by name + * @param {string} name + * @returns {?*} + */ + }, { + key: 'GetVariable', + value: function GetVariable(name) { + return Tw2Store.GetStoreItem(this, 'variable', name); + } + /** + * Gets a variable's value + * @param {string} name + * @param {boolean} [serialize] + * @returns {?*} null if the variable doesn't exist or it does but it has no GetValue method + */ + }, { + key: 'GetVariableValue', + value: function GetVariableValue(name, serialize) { + var variable = this.GetVariable(name); + return variable && variable.GetValue ? variable.GetValue(serialize) : null; + } + /** + * Sets a variable's value + * @param {string} name + * @param {*} value + * @returns {?boolean} null if the variable doesn't exist or it does but has no SetValue method + */ + }, { + key: 'SetVariableValue', + value: function SetVariableValue(name, value) { + var variable = this.GetVariable(name); + if (variable && variable.SetValue) { + variable.SetValue(value); + return true; + } + return null; + } + /** + * Registers a variable + * @param {string} name + * @param {*|{value:*, Type: string|Function}} [value] + * @param {string|Function} [Type] + * @returns {?*} + */ + }, { + key: 'RegisterVariable', + value: function RegisterVariable(name, value, Type) { + var variable = this.CreateType(name, value, Type); + Tw2Store.SetStoreItem(this, 'variable', name, variable); + return variable; + } + /** + * Registers variables from an object or array of objects + * @param {{string:*|{value:*,type:string|Function}|Array<{string:*|{value:*,type:string|Function}>}} obj + */ + }, { + key: 'RegisterVariables', + value: function RegisterVariables(obj) { + return Tw2Store.RegisterFromObject(this, 'RegisterVariable', obj); + } -/***/ }), -/* 12 */ -/***/ (function(module, exports, __webpack_require__) { + /** + * Gets a parameter constructor by it's short name + * @param {string} name + * @returns {?Function} + */ -"use strict"; + }, { + key: 'GetType', + value: function GetType(name) { + return Tw2Store.GetStoreItem(this, 'type', name); + } + /** + * Checks if a type exists + * @param {string} name + * @returns {boolean} + */ -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2Resource = undefined; + }, { + key: 'HasType', + value: function HasType(name) { + return name && name in this._type; + } -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + /** + * Gets a type by value + * @param {*} value + * @returns {?Function} + */ -var _Tw2ResMan = __webpack_require__(6); + }, { + key: 'GetTypeByValue', + value: function GetTypeByValue(value) { + for (var type in this._type) { + if (this._type.hasOwnProperty(type) && 'isValue' in this._type[type]) { + if (this._type[type]['isValue'](value)) { + return this._type[type]; + } + } + } + return null; + } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + /** + * Creates a type by value and/or type name or function + * @param {string} name + * @param {?*} [value] + * @param {?|string|Function} [Type] + * @returns {?*} new parameter + */ -/** - * Tw2Resource base class - * - * @property {string} path - * @property {boolean} _isLoading - * @property {boolean} _isGood - * @property {boolean} _isPurged - * @property {Array} _notifications - * @property {number} activeFrame - * @property {number} doNotPurge - * @class - */ -var Tw2Resource = exports.Tw2Resource = function () { - function Tw2Resource() { - _classCallCheck(this, Tw2Resource); + }, { + key: 'CreateType', + value: function CreateType(name, value, Type) { + if ((0, _util.isPlain)(value)) { + Type = value['Type'] || value['type']; + value = value['value']; + } - this.path = ''; - this._isLoading = false; - this._isGood = false; - this._isPurged = false; - this._notifications = []; - this.activeFrame = 0; - this.doNotPurge = 0; - } + if (!Type) { + Type = this.GetTypeByValue(value); + } - /** - * Checks to see if the resource is loading - * @returns {boolean} - */ + if ((0, _util.isString)(Type)) { + Type = this.GetType(Type); + } + if ((0, _util.isFunction)(Type)) { + return new Type(name, value); + } - _createClass(Tw2Resource, [{ - key: 'IsLoading', - value: function IsLoading() { - this.KeepAlive(); - return this._isLoading; + return null; } /** - * Checks to see if the resource is good + * Registers a parameter type + * @param {string} name + * @param {Function} Constructor * @returns {boolean} */ }, { - key: 'IsGood', - value: function IsGood() { - this.KeepAlive(); - return this._isGood; + key: 'RegisterType', + value: function RegisterType(name, Constructor) { + return Tw2Store.SetStoreItem(this, 'type', name, Constructor, _util.isFunction); } /** - * Checks to see if the resource is purged + * Registers parameter types from an object or array of objects + * @param {{string: Function}|[{string:Function}]} obj * @returns {boolean} - * @prototype */ }, { - key: 'IsPurged', - value: function IsPurged() { - return this._isPurged; + key: 'RegisterTypes', + value: function RegisterTypes(obj) { + return Tw2Store.RegisterFromObject(this, 'RegisterType', obj); } /** - * LoadStarted + * Checks if a schema exists + * @param {string} name + * @returns {boolean} */ }, { - key: 'LoadStarted', - value: function LoadStarted() { - this._isLoading = true; - this.UpdateNotifications('ReleaseCachedData'); + key: 'HasSchema', + value: function HasSchema(name) { + return name && name in this._schema; } /** - * LoadFinished - * @param {boolean} success + * Gets a schema by it's name + * @param {string} name + * @returns {?string} */ }, { - key: 'LoadFinished', - value: function LoadFinished(success) { - this._isLoading = false; - if (!success) this._isGood = false; + key: 'GetSchema', + value: function GetSchema(name) { + return Tw2Store.GetStoreItem(this, 'schema', name); } /** - * PrepareFinished - * @param {boolean} success + * Registers a schema + * @param {string} name + * @param {string} schema + * @returns {boolean} */ }, { - key: 'PrepareFinished', - value: function PrepareFinished(success) { - this._isLoading = false; - this._isGood = success; - this.UpdateNotifications('RebuildCachedData'); + key: 'RegisterSchema', + value: function RegisterSchema(name, schema) { + return Tw2Store.SetStoreItem(this, 'schema', name, schema, function (a) { + return a && a.constructor.name === 'Tw2Schema'; + }); } /** - * Sets resource's isGood property - * @param {boolean} success + * Registers schemas from an object or an array of objects + * @param {{string:string}|Array<{string:string}>} obj + * @returns {boolean} */ }, { - key: 'SetIsGood', - value: function SetIsGood(success) { - this._isGood = success; + key: 'RegisterSchemas', + value: function RegisterSchemas(obj) { + return Tw2Store.RegisterFromObject(this, 'RegisterSchema', obj); } /** - * Unloads the resource + * Registers store values + * @param {{}} [opt={}] + * @param {boolean} [opt.uuid] + * @param {*} opt.paths + * @param {*} opt.dynamicPaths + * @param {*} opt.types + * @param {*} opt.constructors + * @param {*} opt.extensions + * @param {*} opt.variables + * @param {*} opt.schemas */ }, { - key: 'Unload', - value: function Unload() {} - - /** - * Reloads the resource - */ + key: 'Register', + value: function Register() { + var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - }, { - key: 'Reload', - value: function Reload() { - this.Unload(); - _Tw2ResMan.resMan.ReloadResource(this); + if ('uuid' in opt) (0, _util.enableUUID)(opt.uuid); + this.RegisterPaths(opt.paths); + this.RegisterDynamicPaths(opt.dynamicPaths); + this.RegisterTypes(opt.types); + this.RegisterConstructors(opt.constructors); + this.RegisterExtensions(opt.extensions); + this.RegisterVariables(opt.variables); + this.RegisterSchemas(opt.schemas); } /** - * Keeps the resource from being purged + * Gets a value from a store + * - Records missing keys for debugging + * @param {Tw2Store} store + * @param {string} type + * @param {string} key + * @returns {?*} */ - }, { - key: 'KeepAlive', - value: function KeepAlive() { - this.activeFrame = _Tw2ResMan.resMan.activeFrame; - if (this._isPurged) this.Reload(); - } + }], [{ + key: 'GetStoreItem', + value: function GetStoreItem(store, type, key) { + var storeSet = store['_' + type]; + if (storeSet && (0, _util.isString)(key)) { + if (key in storeSet) { + return storeSet[key]; + } - /** - * Registers a notification - * @param {*} notification - */ + if (!store._missing[type]) { + store._missing[type] = []; + } - }, { - key: 'RegisterNotification', - value: function RegisterNotification(notification) { - if (!this._notifications.includes(notification)) { - this._notifications.push(notification); - if (this._isGood && 'RebuildCachedData' in notification) { - notification.RebuildCachedData(this); + if (!store._missing[type].includes(key)) { + store._missing[type].push(key); + + _Tw2Logger.logger.log('store.warning', { + log: 'warning', + msg: 'Missing ' + type + ': \'' + key + '\'' + }); } } + + return null; } /** - * Deregisters a notification - * @param {*} notification + * Sets a store value + * @param {Tw2Store} store + * @param {string} type + * @param {string} key + * @param {*} value + * @param {Function} [validator] + * @returns {boolean} true if successful */ }, { - key: 'UnregisterNotification', - value: function UnregisterNotification(notification) { - this._notifications.splice(this._notifications.indexOf(notification), 1); + key: 'SetStoreItem', + value: function SetStoreItem(store, type) { + var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; + var value = arguments[3]; + var validator = arguments[4]; + + if (validator && !validator(value)) { + _Tw2Logger.logger.log('store.error', { + log: 'error', + msg: 'Invalid value ' + type + ': \'' + key + '\'' + }); + return false; + } + + var storeSet = store['_' + type]; + if (storeSet && (0, _util.isString)(key) && !(0, _util.isUndefined)(value)) { + var existing = storeSet[key]; + storeSet[key] = value; + + if (!existing) { + _Tw2Logger.logger.log('store.registered', { + log: 'debug', + msg: 'Registered ' + type + ': \'' + key + '\'', + hide: true + }); + } else { + _Tw2Logger.logger.log('store.registered', { + log: 'debug', + msg: 'Re-registered ' + type + ': \'' + key + '\'', + data: { + old_value: existing, + new_value: value + } + }); + } + return true; + } + return false; } /** - * Updates a notification - * @param {string} funcName - The function name to call + * Converts an object or array of objects into single function calls + * @param {Tw2Store} store + * @param {string} funcName + * @param {Array|Object} obj + * @returns {boolean} */ }, { - key: 'UpdateNotifications', - value: function UpdateNotifications(funcName) { - for (var i = 0; i < this._notifications.length; i++) { - if (funcName in this._notifications[i]) { - this._notifications[i][funcName](this); + key: 'RegisterFromObject', + value: function RegisterFromObject(store, funcName, obj) { + if (obj && funcName in store) { + obj = (0, _util.toArray)(obj); + for (var i = 0; i < obj.length; i++) { + for (var key in obj[i]) { + if (obj[i].hasOwnProperty(key)) { + store[funcName](key, obj[i][key]); + } + } } + return true; } + return false; } }]); - return Tw2Resource; + return Tw2Store; }(); -/** - * An optional function for when the resource handles it's own loading - * - If the method returns false then the resource manager will handle the http request - * @type {?Function} - * @returns {boolean} - */ - - -Tw2Resource.prototype.DoCustomLoad = null; - -/** - * HTTP request response type - * @type {null} - */ -Tw2Resource.prototype.requestResponseType = null; +var store = exports.store = new Tw2Store(); /***/ }), -/* 13 */ +/* 20 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -3795,186 +3442,267 @@ Tw2Resource.prototype.requestResponseType = null; Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2ParticleForce = undefined; -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* eslint no-unused-vars:0 */ +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; +exports.isArrayLike = isArrayLike; +exports.isBoolean = isBoolean; +exports.isDescriptor = isDescriptor; +exports.isNumber = isNumber; +exports.isFunction = isFunction; +exports.isNoU = isNoU; +exports.isNull = isNull; +exports.isObject = isObject; +exports.isObjectLike = isObjectLike; +exports.isPlain = isPlain; +exports.isPrimary = isPrimary; +exports.isString = isString; +exports.isSymbol = isSymbol; +exports.isTag = isTag; +exports.isTyped = isTyped; +exports.isUndefined = isUndefined; +exports.isVector = isVector; +var toString = Object.prototype.toString; -var _math = __webpack_require__(0); +/** + * Checks if a value is an array + * @param {*} a + * @returns {boolean} + */ +var isArray = exports.isArray = Array.isArray; -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +/** + * Checks if a value is an array or a typed array + * @param {*} a + * @returns {boolean} + */ +function isArrayLike(a) { + return a ? isArray(a) || isTyped(a) : false; +} /** - * Tw2ParticleForce base class - * - * @property {number|string} id - * @property {string} name - * @class + * Checks if a value is a boolean + * @param {*} a + * @returns {boolean} */ -var Tw2ParticleForce = exports.Tw2ParticleForce = function () { - function Tw2ParticleForce() { - _classCallCheck(this, Tw2ParticleForce); +function isBoolean(a) { + return isTag(a, '[object Boolean]'); +} - this._id = _math.util.generateID(); - this.name = ''; +/** + * Checks if a value is a descriptor + * @author jay phelps + * @param {*} a + * @returns {boolean} + */ +function isDescriptor(a) { + if (!a || !a.hasOwnProperty) { + return false; } - /** - * Applies forces - * @param {Tw2ParticleElement} position - * @param {Tw2ParticleElement} velocity - * @param {Tw2ParticleElement} force - * @param {number} dt - * @param {number} mass - */ - + var keys = ['value', 'initializer', 'get', 'set']; - _createClass(Tw2ParticleForce, [{ - key: 'ApplyForce', - value: function ApplyForce(position, velocity, force, dt, mass) {} + for (var i = 0, l = keys.length; i < l; i++) { + if (a.hasOwnProperty(keys[i])) { + return true; + } + } - /** - * Per frame update (Called before ApplyForce) - * @param {number} dt - delta time - */ + return false; +} - }, { - key: 'Update', - value: function Update(dt) {} - }]); +/** + * Checks if a value is a number + * @param {*} a + * @returns {boolean} + */ +function isNumber(a) { + return isTag(a, '[object Number]'); +} - return Tw2ParticleForce; -}(); +/** + * Checks if a value is a function + * @param {*} a + * @returns {boolean} + */ +function isFunction(a) { + return typeof a === 'function'; +} /** - * Class globals - * @type {*} + * Checks if a value is null or undefined + * @param {*} a + * @returns {boolean} */ +function isNoU(a) { + return a == null; +} +/** + * Checks if a value is null + * @param {*} a + * @returns {boolean} + */ +function isNull(a) { + return a === null; +} -Tw2ParticleForce.global = { - vec3_0: _math.vec3.create(), - vec3_1: _math.vec3.create(), - vec4_0: _math.vec4.create() -}; +/** + * Checks if a value is an object and not null + * @param {*} a + * @returns {boolean} + */ +function isObject(a) { + var type = typeof a === 'undefined' ? 'undefined' : _typeof(a); + return a !== null && (type === 'object' || type === 'function'); +} -/***/ }), -/* 14 */ -/***/ (function(module, exports, __webpack_require__) { +/** + * Checks if a value has the type object, and is not null + * @param {*} a + * @returns {boolean} + */ +function isObjectLike(a) { + return a !== null && (typeof a === 'undefined' ? 'undefined' : _typeof(a)) === 'object'; +} -"use strict"; +/** + * Checks if a value is a plain object + * @author lodash + * @param {*} a + * @returns {boolean} + */ +function isPlain(a) { + if (!isObject(a) || !isTag(a, '[object Object]')) { + return false; + } + if (Object.getPrototypeOf(a) === null) { + return true; + } -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.EveChild = undefined; + var proto = a; + while (Object.getPrototypeOf(proto) !== null) { + proto = Object.getPrototypeOf(proto); + } -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* eslint no-unused-vars:0 */ + return Object.getPrototypeOf(a) === proto; +} +/** + * Checks if a value is a primary type + * @param {*} a + * @returns {boolean} + */ +function isPrimary(a) { + return isBoolean(a) || isNumber(a) || isString(a); +} -var _math = __webpack_require__(0); +/** + * Checks if a value is a string + * @param {*} a + * @returns {boolean} + */ +function isString(a) { + return isTag(a, '[object String]'); +} -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +/** + * Checks if a value is a symbol + * @param {*} a + * @returns {boolean} + */ +function isSymbol(a) { + return (typeof a === 'undefined' ? 'undefined' : _typeof(a)) === 'symbol' || isTag(a, '[object Symbol]'); +} /** - * EveChild base class - * - * @property {number|string} _id - * @property {string} name - * @property {boolean} display - * @property {boolean} useSRT - * @property {number} lowestLodVisible - * @property {boolean} staticTransform - * @property {quat} rotation - * @property {vec3} translation - * @property {vec3} scaling - * @property {mat4} localTransform - * @property {mat4} worldTransform - * @property {mat4} worldTransformLast - * @property {?|Tw2BasicPerObjectData|Tw2PerObjectData} _perObjectData - * @class + * Checks if a value has a given tag + * @param {*} a + * @param {string} tag + * @returns {boolean} */ -var EveChild = exports.EveChild = function () { - function EveChild() { - _classCallCheck(this, EveChild); +function isTag(a, tag) { + return toString.call(a) === tag; +} - this._id = _math.util.generateID(); - this.name = ''; - this.display = true; - this.useSRT = true; - this.lowestLodVisible = 2; - this.staticTransform = false; - this.rotation = _math.quat.create(); - this.translation = _math.vec3.create(); - this.scaling = _math.vec3.fromValues(1, 1, 1); - this.localTransform = _math.mat4.create(); - this.worldTransform = _math.mat4.create(); - this.worldTransformLast = _math.mat4.create(); - this._perObjectData = null; - this.isEffectChild = true; - } +/** + * Checks if a value is a typed array + * @param {*} a + * @returns {boolean} + */ +function isTyped(a) { + return a ? !!(a.buffer instanceof ArrayBuffer && a.BYTES_PER_ELEMENT) : false; +} - /** - * Gets the child's resources - * @param {Array} [out=[]] - * @returns {Array} out - */ +/** + * Checks if a value is undefined + * @param {*} a + * @returns {boolean} + */ +function isUndefined(a) { + return a === undefined; +} +/** + * Checks if a value is arraylike and only contains numbers + * @param {*} a + * @returns {boolean} + */ +function isVector(a) { + if (!a) { + return false; + } - _createClass(EveChild, [{ - key: 'GetResources', - value: function GetResources() { - var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + if (isTyped(a)) { + return true; + } - return out; + if (isArray(a)) { + for (var i = 0; i < a.length; i++) { + if (!isNumber(a[i])) return false; } + return true; + } +} - /** - * Per frame update - * @param {number} dt - * @param {mat4} parentTransform - */ - - }, { - key: 'Update', - value: function Update(dt, parentTransform) { - if (this.useSRT) { - _math.quat.normalize(this.rotation, this.rotation); - _math.mat4.fromRotationTranslationScale(this.localTransform, this.rotation, this.translation, this.scaling); - } +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { - _math.mat4.copy(this.worldTransformLast, this.worldTransform); - _math.mat4.multiply(this.worldTransform, parentTransform, this.localTransform); - } +"use strict"; - /** - * Gets render batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator - */ - }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator) {} - }]); +Object.defineProperty(exports, "__esModule", { + value: true +}); - return EveChild; -}(); +var _Tw2SamplerState = __webpack_require__(43); -/** - * Class globals and scratch variables - * @type {Object} - */ +Object.keys(_Tw2SamplerState).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2SamplerState[key]; + } + }); +}); +var _Tw2SamplerOverride = __webpack_require__(86); -EveChild.global = { - mat4_0: _math.mat4.create(), - vec3_0: _math.vec3.create() -}; +Object.keys(_Tw2SamplerOverride).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2SamplerOverride[key]; + } + }); +}); /***/ }), -/* 15 */ +/* 22 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -3983,100 +3711,113 @@ EveChild.global = { Object.defineProperty(exports, "__esModule", { value: true }); -exports.EveObject = undefined; +exports.Tw2RenderBatch = undefined; -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* eslint no-unused-vars:0 */ +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /*eslint no-unused-vars:0*/ -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** - * EveObject base class + * Tw2RenderBatch base class * - * @property {number} _id - * @property {string} name - * @property {boolean} display + * @property {number} renderMode + * @property {Tw2PerObjectData} perObjectData * @class */ -var EveObject = exports.EveObject = function () { - function EveObject() { - _classCallCheck(this, EveObject); +var Tw2RenderBatch = exports.Tw2RenderBatch = function () { + function Tw2RenderBatch() { + _classCallCheck(this, Tw2RenderBatch); - this._id = _math.util.generateID(); - this.name = ''; - this.display = true; + this.renderMode = _global.device.RM_ANY; + this.perObjectData = null; } /** - * Initializes the object + * Commits the batch + * @param {string} technique - technique name */ - _createClass(EveObject, [{ - key: 'Initialize', - value: function Initialize() {} + _createClass(Tw2RenderBatch, [{ + key: 'Commit', + value: function Commit(technique) {} + }]); - /** - * Gets object resources - * @param {Array} [out=[]] - * @returns {Array} out - */ + return Tw2RenderBatch; +}(); - }, { - key: 'GetResources', - value: function GetResources() { - var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { - return out; - } +"use strict"; - /** - * Per frame update - * @param {number} dt - delta time - */ - }, { - key: 'Update', - value: function Update(dt) {} +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2GeometryBatch = undefined; - /** - * Accumulates batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator - */ +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator) {} - }]); +var _Tw2RenderBatch2 = __webpack_require__(22); - return EveObject; -}(); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Class global and scratch variables - * @type {{string:*}} + * A render batch for geometry + * + * @property {Tw2GeometryRes} geometryRes + * @property {Number} meshIx + * @property {Number} start + * @property {Number} count + * @property {Tw2Effect} effect + * @property {string} technique + * @class */ +var Tw2GeometryBatch = exports.Tw2GeometryBatch = function (_Tw2RenderBatch) { + _inherits(Tw2GeometryBatch, _Tw2RenderBatch); + + function Tw2GeometryBatch() { + _classCallCheck(this, Tw2GeometryBatch); + var _this = _possibleConstructorReturn(this, (Tw2GeometryBatch.__proto__ || Object.getPrototypeOf(Tw2GeometryBatch)).call(this)); -EveObject.global = { - vec3_0: _math.vec3.create(), - vec3_1: _math.vec3.create(), - vec3_2: _math.vec3.create(), - vec3_3: _math.vec3.create(), - vec3_4: _math.vec3.create(), - vec3_5: _math.vec3.create(), - vec3_6: _math.vec3.create(), - vec3_7: _math.vec3.create(), - mat4_0: _math.mat4.create(), - mat4_1: _math.mat4.create(), - mat4_2: _math.mat4.create() -}; + _this.geometryRes = null; + _this.meshIx = 0; + _this.start = 0; + _this.count = 1; + _this.effect = null; + return _this; + } + + /** + * Commits the Tw2InstancedMeshBatch for rendering + * @param {string} technique - technique name + */ + + + _createClass(Tw2GeometryBatch, [{ + key: 'Commit', + value: function Commit(technique) { + if (this.geometryRes && this.effect) { + this.geometryRes.RenderAreas(this.meshIx, this.start, this.count, this.effect, technique); + } + } + }]); + + return Tw2GeometryBatch; +}(_Tw2RenderBatch2.Tw2RenderBatch); /***/ }), -/* 16 */ +/* 24 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -4085,1802 +3826,2130 @@ EveObject.global = { Object.defineProperty(exports, "__esModule", { value: true }); -exports.store = undefined; +exports.Tw2RawData = undefined; -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; -var _math = __webpack_require__(0); +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2Logger = __webpack_require__(4); +var _global = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** - * Stores engine data + * Stores raw data for {@link Tw2PerObjectData} * - * @property {Object.< string, string>} _paths - * @property {Object.< string, Array>} _dynamicPaths - * @property {Object.< string, Tw2Parameter>} _variables - * @property {Object.< string, Function>} _types - * @property {Object.< string, Function>} _extensions - * @property {Object.< string, Function>} _constructors - * @property {Object.< string, Array>} _missing + * @param {{string:Float32Array|Array|number}} [declarations] An optional object containing raw data declarations + * @property {number} nextOffset + * @property {Float32Array} data + * @property {*} elements * @class */ -var Tw2Store = function () { - function Tw2Store() { - _classCallCheck(this, Tw2Store); +var Tw2RawData = exports.Tw2RawData = function () { + function Tw2RawData(declarations) { + _classCallCheck(this, Tw2RawData); - this._types = {}; - this._paths = {}; - this._variables = {}; - this._extensions = {}; - this._constructors = {}; - this._dynamicPaths = {}; - this._missing = {}; + this.nextOffset = 0; + this.data = null; + this.elements = {}; + + if (declarations) { + this.DeclareFromObject(declarations); + } } /** - * Checks if a resource path exists - * @param {string} prefix - * @returns {boolean} + * Sets a element value + * @param {string} name + * @param {Float32Array|Array} value */ - _createClass(Tw2Store, [{ - key: 'HasPath', - value: function HasPath(prefix) { - return prefix && prefix in this._paths; + _createClass(Tw2RawData, [{ + key: 'Set', + value: function Set(name, value) { + var el = this.elements[name]; + this.data.set(value.length > el.size ? value.subarray(0, el.size) : value, el.offset); } /** - * Gets a path by it's prefix - * @param {string} prefix - * @returns {?string} + * Gets an element's array value + * @param {string} name + * @return {Float32Array} */ }, { - key: 'GetPath', - value: function GetPath(prefix) { - return Tw2Store.GetStoreItem(this, 'paths', prefix); + key: 'Get', + value: function Get(name) { + return this.elements[name].array; } /** - * Registers a resource path - * @param {string} prefix - * @param {string} path - * @returns {boolean} + * Gets an element's array value from the share data array + * @param {string} name + * @return {Float32Array} */ }, { - key: 'RegisterPath', - value: function RegisterPath(prefix, path) { - return !!Tw2Store.SetStoreItem(this, 'paths', prefix, path); + key: 'GetData', + value: function GetData(name) { + return this.data.subarray(this.elements[name].offset, this.elements[name].offset + this.elements[name].array.length); } /** - * Registers resource paths from an object or an array of objects - * @param {{string:string}|Array<{string:string}>} obj - * @returns {boolean} + * Creates the raw data element arrays */ }, { - key: 'RegisterPaths', - value: function RegisterPaths(obj) { - return Tw2Store.RegisterFromObject(this, 'RegisterPath', obj); + key: 'Create', + value: function Create() { + this.data = new Float32Array(this.nextOffset); + for (var name in this.elements) { + if (this.elements.hasOwnProperty(name)) { + var el = this.elements[name]; + el.array = this.data.subarray(el.offset, el.offset + el.size); + + if (el.value !== null) { + if (el.size === 1) { + el.array[0] = el.value; + } else { + for (var i = 0; i < el.size; i++) { + el.array[i] = el.value[i]; + } + } + el.value = null; + } + } + } } /** - * Checks if a dynamic path exists - * @param {string} prefix - * @returns {boolean} + * Declares a raw data element + * @param {String} name + * @param {number} size + * @param {!|number|Array|Float32Array} [value=null] optional value to set on raw data creation */ }, { - key: 'HasDynamicPath', - value: function HasDynamicPath(prefix) { - return prefix && prefix in this._dynamicPaths; - } + key: 'Declare', + value: function Declare(name, size) { + var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; - /** - * Gets a dynamic path by it's prefix - * @param {string} prefix - * @returns {?Array} - */ + this.elements[name] = { + offset: this.nextOffset, + size: size, + array: null, + value: value + }; - }, { - key: 'GetDynamicPath', - value: function GetDynamicPath(prefix) { - return Tw2Store.GetStoreItem(this, 'dynamicPaths', prefix); + this.nextOffset += size; } /** - * Registers a dynamic path - * @param {string} prefix - * @param {string[]} paths - * @returns {boolean} + * Declares raw data from an object and then creates the elements + * @param {{string:Float32Array|Array|number}} declarations */ }, { - key: 'RegisterDynamicPath', - value: function RegisterDynamicPath(prefix, paths) { - return !!Tw2Store.SetStoreItem(this, 'dynamicPaths', prefix, paths); - } + key: 'DeclareFromObject', + value: function DeclareFromObject() { + var declarations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - /** - * Registers dynamic paths from an object or array of objects - * @param {{string:string[]}|Array<{string:string[]}>} obj - * @returns {boolean} - */ + for (var name in declarations) { + if (declarations.hasOwnProperty(name)) { + var value = declarations[name]; - }, { - key: 'RegisterDynamicPaths', - value: function RegisterDynamicPaths(obj) { - return Tw2Store.RegisterFromObject(this, 'RegisterDynamicPath', obj); + if (_global.util.isNumber(value)) { + this.Declare(name, 1, value); + } else if (_global.util.isArrayLike(value)) { + if (value.length === 1) { + this.Declare(name, value.length, value); + } + } else { + throw new Error('Invalid declaration type: ' + (typeof value === 'undefined' ? 'undefined' : _typeof(value))); + } + } + } + + this.Create(); } + }]); - /** - * Checks if an extension exists - * @param {string} ext - * @returns {boolean} - */ + return Tw2RawData; +}(); - }, { - key: 'HasExtension', - value: function HasExtension(ext) { - return ext && ext in this._extensions; - } +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { - /** - * Gets a resource extension by name - * @param {string} ext - * @returns {?Function} - */ +"use strict"; - }, { - key: 'GetExtension', - value: function GetExtension(ext) { - return Tw2Store.GetStoreItem(this, 'extensions', ext); - } - - /** - * Registers a resource extension - * @param {name} ext - * @param {Function} Constructor - * @returns {boolean} - */ - - }, { - key: 'RegisterExtension', - value: function RegisterExtension(ext, Constructor) { - if (typeof Constructor === 'function') { - return !!Tw2Store.SetStoreItem(this, 'extensions', ext, Constructor); - } - return false; - } - - /** - * Registers resource extensions from an object or array of objects - * @param {{string:Function}|Array<{string:Function}>} obj - * @returns {boolean} - */ - - }, { - key: 'RegisterExtensions', - value: function RegisterExtensions(obj) { - return Tw2Store.RegisterFromObject(this, 'RegisterExtension', obj); - } - - /** - * Checks if a constructor exists - * @param {string} name - * @returns {boolean} - */ - }, { - key: 'HasConstructor', - value: function HasConstructor(name) { - return name && name in this._constructors; - } +Object.defineProperty(exports, "__esModule", { + value: true +}); - /** - * Gets a library constructor by name - * @param {string} name - * @returns {?Function} - */ +var _Tw2EffectRes = __webpack_require__(120); - }, { - key: 'GetConstructor', - value: function GetConstructor(name) { - return Tw2Store.GetStoreItem(this, 'constructors', name); - } +Object.keys(_Tw2EffectRes).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2EffectRes[key]; + } + }); +}); - /** - * Registers library constructors - * @param {string} name - * @param {Function} Constructor - * @returns {boolean} - */ +var _Tw2GeometryRes = __webpack_require__(122); - }, { - key: 'RegisterConstructor', - value: function RegisterConstructor(name, Constructor) { - if (typeof Constructor === 'function') { - return !!Tw2Store.SetStoreItem(this, 'constructors', name, Constructor); - } - return false; - } +Object.keys(_Tw2GeometryRes).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2GeometryRes[key]; + } + }); +}); - /** - * Registers library constructors from an object or array of objects - * @param {{string:Function}|Array<{string:Function}>} obj - * @returns {boolean} - */ +var _Tw2LoadingObject = __webpack_require__(38); - }, { - key: 'RegisterConstructors', - value: function RegisterConstructors(obj) { - return Tw2Store.RegisterFromObject(this, 'RegisterConstructor', obj); - } +Object.keys(_Tw2LoadingObject).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2LoadingObject[key]; + } + }); +}); - /** - * Checks if a variable exists - * @param {string} name - * @returns {boolean} - */ +var _Tw2Resource = __webpack_require__(8); - }, { - key: 'HasVariable', - value: function HasVariable(name) { - return name && name in this._variables; - } +Object.keys(_Tw2Resource).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2Resource[key]; + } + }); +}); - /** - * Gets a variable by name - * @param {string} name - * @returns {?*} - */ +var _Tw2TextureRes = __webpack_require__(52); - }, { - key: 'GetVariable', - value: function GetVariable(name) { - return Tw2Store.GetStoreItem(this, 'variables', name); - } +Object.keys(_Tw2TextureRes).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2TextureRes[key]; + } + }); +}); - /** - * Gets a variable's value - * @param {string} name - * @param {boolean} [serialize] - * @returns {?*} null if the variable doesn't exist or it does but it has no GetValue method - */ +var _Tw2VideoRes = __webpack_require__(123); - }, { - key: 'GetVariableValue', - value: function GetVariableValue(name, serialize) { - var variable = this.GetVariable(name); - return variable && variable.GetValue ? variable.GetValue(serialize) : null; - } +Object.keys(_Tw2VideoRes).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2VideoRes[key]; + } + }); +}); - /** - * Sets a variable's value - * @param {string} name - * @param {*} value - * @returns {?boolean} null if the variable doesn't exist or it does but has no SetValue method - */ +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { - }, { - key: 'SetVariableValue', - value: function SetVariableValue(name, value) { - var variable = this.GetVariable(name); - if (variable && variable.SetValue) { - variable.SetValue(value); - return true; - } - return null; - } +"use strict"; - /** - * Registers a variable - * @param {string} name - * @param {*|{value:*, type: string|Function}} [value] - * @param {string|Function} [Type] - * @returns {?*} - */ - }, { - key: 'RegisterVariable', - value: function RegisterVariable(name, value, Type) { - var variable = this.CreateType(name, value, Type); - return Tw2Store.SetStoreItem(this, 'variables', name, variable); - } +Object.defineProperty(exports, "__esModule", { + value: true +}); - /** - * Registers variables from an object or array of objects - * @param {{string:*|{value:*,type:string|Function}|Array<{string:*|{value:*,type:string|Function}>}} obj - */ +var _Tw2BinaryReader = __webpack_require__(40); - }, { - key: 'RegisterVariables', - value: function RegisterVariables(obj) { - return Tw2Store.RegisterFromObject(this, 'RegisterVariable', obj); - } +Object.keys(_Tw2BinaryReader).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2BinaryReader[key]; + } + }); +}); - /** - * Gets a parameter constructor by it's short name - * @param {string} name - * @returns {?Function} - */ +var _Tw2ObjectReader = __webpack_require__(39); - }, { - key: 'GetType', - value: function GetType(name) { - return Tw2Store.GetStoreItem(this, 'types', name); - } +Object.keys(_Tw2ObjectReader).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2ObjectReader[key]; + } + }); +}); - /** - * Checks if a type exists - * @param {string} name - * @returns {boolean} - */ +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { - }, { - key: 'HasType', - value: function HasType(name) { - return name && name in this._types; - } +"use strict"; - /** - * Gets a type by value - * @param {*} value - * @returns {?Function} - */ - }, { - key: 'GetTypeByValue', - value: function GetTypeByValue(value) { - for (var type in this._types) { - if (this._types.hasOwnProperty(type) && 'is' in this._types[type]) { - if (this._types[type]['is'](value)) return this._types[type]; - } - } - return null; - } +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2ParticleEmitter = undefined; - /** - * Creates a type by value and/or type name or function - * @param {string} name - * @param {?*} [value] - * @param {?|string|Function} [Type] - * @returns {?*} new parameter - */ +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* eslint no-unused-vars:0 */ - }, { - key: 'CreateType', - value: function CreateType(name, value, Type) { - if (value && value.constructor.name === 'Object') { - Type = value['Type'] || value['type']; - value = value['value']; - } - if (!Type) { - Type = this.GetTypeByValue(value); - } else if (typeof Type === 'string') { - Type = this.GetType(Type); - } +var _global = __webpack_require__(0); - if (typeof Type === 'function') { - return new Type(name, value); - } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - return null; - } +/** + * Particle Emitter base class + * + * @property {number|string} id + * @property {string} name + * @property {Tw2ParticleSystem} particleSystem + * @class + */ +var Tw2ParticleEmitter = exports.Tw2ParticleEmitter = function () { + function Tw2ParticleEmitter() { + _classCallCheck(this, Tw2ParticleEmitter); - /** - * Registers a parameter type - * @param {string} name - * @param {Function} Constructor - * @returns {boolean} - */ + this._id = _global.util.generateID(); + this.name = ''; + this.particleSystem = null; + } - }, { - key: 'RegisterType', - value: function RegisterType(name, Constructor) { - if (typeof Constructor === 'function') { - return !!Tw2Store.SetStoreItem(this, 'types', name, Constructor); - } - return false; - } + /** + * Initializes the particle emitter + */ - /** - * Registers parameter types from an object or array of objects - * @param {{string: Function}|[{string:Function}]} obj - * @returns {boolean} - */ - }, { - key: 'RegisterTypes', - value: function RegisterTypes(obj) { - return Tw2Store.RegisterFromObject(this, 'RegisterType', obj); - } + _createClass(Tw2ParticleEmitter, [{ + key: 'Initialize', + value: function Initialize() {} /** - * Registers store values - * @param {{}} [opt={}] - * @param {boolean} [opt.uuid] - * @param {*} opt.paths - * @param {*} opt.dynamicPaths - * @param {*} opt.types - * @param {*} opt.constructors - * @param {*} opt.extensions - * @param {*} opt.variables + * Per frame update + * @param {number} dt - delta time */ }, { - key: 'Register', - value: function Register() { - var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + key: 'Update', + value: function Update(dt) {} + }]); - if ('uuid' in opt) _math.util.enableUUID(opt.uuid); - this.RegisterPaths(opt.paths); - this.RegisterDynamicPaths(opt.dynamicPaths); - this.RegisterTypes(opt.types); - this.RegisterConstructors(opt.constructors); - this.RegisterExtensions(opt.extensions); - this.RegisterVariables(opt.variables); - } + return Tw2ParticleEmitter; +}(); - /** - * Gets a value from a store - * - Records missing keys for debugging - * @param {Tw2Store} store - * @param {string} type - * @param {string} key - * @returns {?*} - */ +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { - }], [{ - key: 'GetStoreItem', - value: function GetStoreItem(store, type, key) { - if (typeof key === 'string') { - var storeSet = store['_' + type], - singular = type.substring(0, type.length - 1); +"use strict"; - if (storeSet) { - if (key in storeSet) { - return storeSet[key]; - } - if (!store._missing[type]) { - store._missing[type] = []; - } +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2ParticleAttributeGenerator = undefined; - if (!store._missing[type].includes(key)) { - store._missing[type].push(key); +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* eslint no-unused-vars:0 */ - _Tw2Logger.logger.log('store.warning', { - log: 'warning', - msg: 'Missing ' + singular + ': \'' + key + '\'' - }); - } - } - } - return null; - } +var _global = __webpack_require__(0); - /** - * Sets a store value - * @param {Tw2Store} store - * @param {string} type - * @param {string} key - * @param {*} value - */ +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - }, { - key: 'SetStoreItem', - value: function SetStoreItem(store, type) { - var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; - var value = arguments[3]; +/** + * Tw2ParticleAttributeGenerator base class + * + * @property {number|string} id + * @property {string} name + * @class + */ +var Tw2ParticleAttributeGenerator = exports.Tw2ParticleAttributeGenerator = function () { + function Tw2ParticleAttributeGenerator() { + _classCallCheck(this, Tw2ParticleAttributeGenerator); - if (typeof key === 'string' && value !== undefined) { - var storeSet = store['_' + type]; - if (storeSet) { - var existing = storeSet[key], - singular = type.substring(0, type.length - 1); + this._id = _global.util.generateID(); + this.name = ''; + } - storeSet[key] = value; + /** + * Binds a particle system element to the generator + * @param {Tw2ParticleSystem} ps + * @returns {boolean} True if successfully bound + */ - if (!existing) { - _Tw2Logger.logger.log('store.registered', { - log: 'debug', - msg: 'Registered ' + singular + ': \'' + key + '\'', - hide: true - }); - } else { - _Tw2Logger.logger.log('store.registered', { - log: 'debug', - msg: 'Re-registered ' + singular + ': \'' + key + '\'', - data: { - old_value: existing, - new_value: value - } - }); - } - return value; - } - } + _createClass(Tw2ParticleAttributeGenerator, [{ + key: 'Bind', + value: function Bind(ps) { return false; } /** - * Converts an object or array of objects into single function calls - * @param {Tw2Store} store - * @param {string} funcName - * @param {Array|Object} obj - * @returns {boolean} + * Generates the attributes + * @param {Tw2ParticleElement} position + * @param {Tw2ParticleElement} velocity + * @param {number} index */ }, { - key: 'RegisterFromObject', - value: function RegisterFromObject(store, funcName, obj) { - if (obj && funcName in store) { - obj = Array.isArray(obj) ? obj : [obj]; - for (var i = 0; i < obj.length; i++) { - for (var key in obj[i]) { - if (obj[i].hasOwnProperty(key)) { - store[funcName](key, obj[i][key]); - } - } - } - return true; - } - return false; - } + key: 'Generate', + value: function Generate(position, velocity, index) {} }]); - return Tw2Store; + return Tw2ParticleAttributeGenerator; }(); -var store = exports.store = new Tw2Store(); +Tw2ParticleAttributeGenerator.global = { + vec3_0: _global.vec3.create() +}; /***/ }), -/* 17 */ +/* 29 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _Tw2Device = __webpack_require__(2); - -Object.keys(_Tw2Device).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2Device[key]; - } - }); -}); - -var _Tw2ResMan = __webpack_require__(6); - -Object.keys(_Tw2ResMan).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2ResMan[key]; - } - }); + value: true }); +var num = exports.num = {}; -var _Tw2Store = __webpack_require__(16); - -Object.keys(_Tw2Store).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2Store[key]; +/** + * biCumulative + * + * @param {number} t + * @param {number} order + * @returns {number} + */ +num.biCumulative = function (t, order) { + if (order === 1) { + var some = 1.0 - t; + return 1.0 - some * some * some; + } else if (order === 2) { + return 3.0 * t * t - 2.0 * t * t * t; + } else { + return t * t * t; } - }); -}); - -var _Tw2Logger = __webpack_require__(4); +}; -Object.keys(_Tw2Logger).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2Logger[key]; - } - }); -}); +/** + * Exponential decay + * + * @param {number} omega0 + * @param {number} torque + * @param {number} I - inertia + * @param {number} d - drag + * @param {number} time - time + * @returns {number} + */ +num.exponentialDecay = function (omega0, torque, I, d, time) { + return torque * time / d + I * (omega0 * d - torque) / (d * d) * (1.0 - Math.pow(Math.E, -d * time / I)); +}; /***/ }), -/* 18 */ -/***/ (function(module, exports, __webpack_require__) { +/* 30 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +/* harmony export (immutable) */ __webpack_exports__["create"] = create; +/* harmony export (immutable) */ __webpack_exports__["fromMat4"] = fromMat4; +/* harmony export (immutable) */ __webpack_exports__["clone"] = clone; +/* harmony export (immutable) */ __webpack_exports__["copy"] = copy; +/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues; +/* harmony export (immutable) */ __webpack_exports__["set"] = set; +/* harmony export (immutable) */ __webpack_exports__["identity"] = identity; +/* harmony export (immutable) */ __webpack_exports__["transpose"] = transpose; +/* harmony export (immutable) */ __webpack_exports__["invert"] = invert; +/* harmony export (immutable) */ __webpack_exports__["adjoint"] = adjoint; +/* harmony export (immutable) */ __webpack_exports__["determinant"] = determinant; +/* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply; +/* harmony export (immutable) */ __webpack_exports__["translate"] = translate; +/* harmony export (immutable) */ __webpack_exports__["rotate"] = rotate; +/* harmony export (immutable) */ __webpack_exports__["scale"] = scale; +/* harmony export (immutable) */ __webpack_exports__["fromTranslation"] = fromTranslation; +/* harmony export (immutable) */ __webpack_exports__["fromRotation"] = fromRotation; +/* harmony export (immutable) */ __webpack_exports__["fromScaling"] = fromScaling; +/* harmony export (immutable) */ __webpack_exports__["fromMat2d"] = fromMat2d; +/* harmony export (immutable) */ __webpack_exports__["fromQuat"] = fromQuat; +/* harmony export (immutable) */ __webpack_exports__["normalFromMat4"] = normalFromMat4; +/* harmony export (immutable) */ __webpack_exports__["projection"] = projection; +/* harmony export (immutable) */ __webpack_exports__["str"] = str; +/* harmony export (immutable) */ __webpack_exports__["frob"] = frob; +/* harmony export (immutable) */ __webpack_exports__["add"] = add; +/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract; +/* harmony export (immutable) */ __webpack_exports__["multiplyScalar"] = multiplyScalar; +/* harmony export (immutable) */ __webpack_exports__["multiplyScalarAndAdd"] = multiplyScalarAndAdd; +/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals; +/* harmony export (immutable) */ __webpack_exports__["equals"] = equals; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(3); +/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2ParticleElementDeclaration = exports.Tw2ParticleElement = undefined; +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. */ -var _core = __webpack_require__(1); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -/** - * Tw2ParticleElement - * - * @param {Tw2ParticleElementDeclaration} decl - * @property {number} elementType - * @property {string} customName - * @property {number} dimension - * @property {number} usageIndex - * @property {boolean} usedByGPU - * @property buffer - * @property {number} startOffset - * @property {number} offset - * @property {number} instanceStride - * @property {number} vertexStride - * @property {boolean} dirty - * @class +/** + * 3x3 Matrix + * @module mat3 */ -var Tw2ParticleElement = exports.Tw2ParticleElement = function Tw2ParticleElement(decl) { - _classCallCheck(this, Tw2ParticleElement); - - this.elementType = decl.elementType; - this.customName = decl.customName; - this.dimension = decl.GetDimension(); - this.usageIndex = decl.usageIndex; - this.usedByGPU = decl.usedByGPU; - this.buffer = null; - this.startOffset = 0; - this.offset = 0; - this.instanceStride = 0; - this.vertexStride = 0; - this.dirty = false; -}; -/** - * Tw2ParticleElementDeclaration - * - * @property {number} elementType=4 - * @property {string} customName - * @property {number} dimension=1 - * @property {number} usageIndex - * @property {boolean} usedByGPU - * @class +/** + * Creates a new identity mat3 + * + * @returns {mat3} a new 3x3 matrix */ +function create() { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](9); + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 1; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 1; + return out; +} +/** + * Copies the upper-left 3x3 values into the given mat3. + * + * @param {mat3} out the receiving 3x3 matrix + * @param {mat4} a the source 4x4 matrix + * @returns {mat3} out + */ +function fromMat4(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[4]; + out[4] = a[5]; + out[5] = a[6]; + out[6] = a[8]; + out[7] = a[9]; + out[8] = a[10]; + return out; +} -var Tw2ParticleElementDeclaration = exports.Tw2ParticleElementDeclaration = function () { - function Tw2ParticleElementDeclaration() { - _classCallCheck(this, Tw2ParticleElementDeclaration); +/** + * Creates a new mat3 initialized with values from an existing matrix + * + * @param {mat3} a matrix to clone + * @returns {mat3} a new 3x3 matrix + */ +function clone(a) { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](9); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + return out; +} - this.elementType = 4; - this.customName = ''; - this.dimension = 1; - this.usageIndex = 0; - this.usedByGPU = true; - } +/** + * Copy the values from one mat3 to another + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the source matrix + * @returns {mat3} out + */ +function copy(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + return out; +} - /** - * Gets the dimension of an element type - * @returns {number} - */ +/** + * Create a new mat3 with the given values + * + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m10 Component in column 1, row 0 position (index 3) + * @param {Number} m11 Component in column 1, row 1 position (index 4) + * @param {Number} m12 Component in column 1, row 2 position (index 5) + * @param {Number} m20 Component in column 2, row 0 position (index 6) + * @param {Number} m21 Component in column 2, row 1 position (index 7) + * @param {Number} m22 Component in column 2, row 2 position (index 8) + * @returns {mat3} A new mat3 + */ +function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](9); + out[0] = m00; + out[1] = m01; + out[2] = m02; + out[3] = m10; + out[4] = m11; + out[5] = m12; + out[6] = m20; + out[7] = m21; + out[8] = m22; + return out; +} +/** + * Set the components of a mat3 to the given values + * + * @param {mat3} out the receiving matrix + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m10 Component in column 1, row 0 position (index 3) + * @param {Number} m11 Component in column 1, row 1 position (index 4) + * @param {Number} m12 Component in column 1, row 2 position (index 5) + * @param {Number} m20 Component in column 2, row 0 position (index 6) + * @param {Number} m21 Component in column 2, row 1 position (index 7) + * @param {Number} m22 Component in column 2, row 2 position (index 8) + * @returns {mat3} out + */ +function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) { + out[0] = m00; + out[1] = m01; + out[2] = m02; + out[3] = m10; + out[4] = m11; + out[5] = m12; + out[6] = m20; + out[7] = m21; + out[8] = m22; + return out; +} - _createClass(Tw2ParticleElementDeclaration, [{ - key: 'GetDimension', - value: function GetDimension() { - switch (this.elementType) { - case Tw2ParticleElementDeclaration.Type.LIFETIME: - return 2; +/** + * Set a mat3 to the identity matrix + * + * @param {mat3} out the receiving matrix + * @returns {mat3} out + */ +function identity(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 1; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 1; + return out; +} - case Tw2ParticleElementDeclaration.Type.POSITION: - return 3; +/** + * Transpose the values of a mat3 + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the source matrix + * @returns {mat3} out + */ +function transpose(out, a) { + // If we are transposing ourselves we can skip a few steps but have to cache some values + if (out === a) { + let a01 = a[1], a02 = a[2], a12 = a[5]; + out[1] = a[3]; + out[2] = a[6]; + out[3] = a01; + out[5] = a[7]; + out[6] = a02; + out[7] = a12; + } else { + out[0] = a[0]; + out[1] = a[3]; + out[2] = a[6]; + out[3] = a[1]; + out[4] = a[4]; + out[5] = a[7]; + out[6] = a[2]; + out[7] = a[5]; + out[8] = a[8]; + } - case Tw2ParticleElementDeclaration.Type.VELOCITY: - return 3; + return out; +} - case Tw2ParticleElementDeclaration.Type.MASS: - return 1; - } - return this.dimension; - } +/** + * Inverts a mat3 + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the source matrix + * @returns {mat3} out + */ +function invert(out, a) { + let a00 = a[0], a01 = a[1], a02 = a[2]; + let a10 = a[3], a11 = a[4], a12 = a[5]; + let a20 = a[6], a21 = a[7], a22 = a[8]; - /** - * GetDeclaration - * @returns {Tw2VertexElement} - */ + let b01 = a22 * a11 - a12 * a21; + let b11 = -a22 * a10 + a12 * a20; + let b21 = a21 * a10 - a11 * a20; - }, { - key: 'GetDeclaration', - value: function GetDeclaration() { - var usage = void 0; - switch (this.elementType) { - case Tw2ParticleElementDeclaration.Type.LIFETIME: - usage = _core.Tw2VertexDeclaration.Type.TANGENT; - break; + // Calculate the determinant + let det = a00 * b01 + a01 * b11 + a02 * b21; - case Tw2ParticleElementDeclaration.Type.POSITION: - usage = _core.Tw2VertexDeclaration.Type.POSITION; - break; + if (!det) { + return null; + } + det = 1.0 / det; - case Tw2ParticleElementDeclaration.Type.VELOCITY: - usage = _core.Tw2VertexDeclaration.Type.NORMAL; - break; + out[0] = b01 * det; + out[1] = (-a22 * a01 + a02 * a21) * det; + out[2] = (a12 * a01 - a02 * a11) * det; + out[3] = b11 * det; + out[4] = (a22 * a00 - a02 * a20) * det; + out[5] = (-a12 * a00 + a02 * a10) * det; + out[6] = b21 * det; + out[7] = (-a21 * a00 + a01 * a20) * det; + out[8] = (a11 * a00 - a01 * a10) * det; + return out; +} - case Tw2ParticleElementDeclaration.Type.MASS: - usage = _core.Tw2VertexDeclaration.Type.BINORMAL; - break; +/** + * Calculates the adjugate of a mat3 + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the source matrix + * @returns {mat3} out + */ +function adjoint(out, a) { + let a00 = a[0], a01 = a[1], a02 = a[2]; + let a10 = a[3], a11 = a[4], a12 = a[5]; + let a20 = a[6], a21 = a[7], a22 = a[8]; - default: - usage = _core.Tw2VertexDeclaration.Type.TEXCOORD; - } + out[0] = (a11 * a22 - a12 * a21); + out[1] = (a02 * a21 - a01 * a22); + out[2] = (a01 * a12 - a02 * a11); + out[3] = (a12 * a20 - a10 * a22); + out[4] = (a00 * a22 - a02 * a20); + out[5] = (a02 * a10 - a00 * a12); + out[6] = (a10 * a21 - a11 * a20); + out[7] = (a01 * a20 - a00 * a21); + out[8] = (a00 * a11 - a01 * a10); + return out; +} - return new _core.Tw2VertexElement(usage, this.usageIndex, _core.device.gl.FLOAT, this.GetDimension()); - } - }]); +/** + * Calculates the determinant of a mat3 + * + * @param {mat3} a the source matrix + * @returns {Number} determinant of a + */ +function determinant(a) { + let a00 = a[0], a01 = a[1], a02 = a[2]; + let a10 = a[3], a11 = a[4], a12 = a[5]; + let a20 = a[6], a21 = a[7], a22 = a[8]; - return Tw2ParticleElementDeclaration; -}(); + return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); +} -/** - * Particle element declaration types - * @type {{LIFETIME: number, POSITION: number, VELOCITY: number, MASS: number, CUSTOM: number}} +/** + * Multiplies two mat3's + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the first operand + * @param {mat3} b the second operand + * @returns {mat3} out */ +function multiply(out, a, b) { + let a00 = a[0], a01 = a[1], a02 = a[2]; + let a10 = a[3], a11 = a[4], a12 = a[5]; + let a20 = a[6], a21 = a[7], a22 = a[8]; + let b00 = b[0], b01 = b[1], b02 = b[2]; + let b10 = b[3], b11 = b[4], b12 = b[5]; + let b20 = b[6], b21 = b[7], b22 = b[8]; -Tw2ParticleElementDeclaration.Type = { - LIFETIME: 0, - POSITION: 1, - VELOCITY: 2, - MASS: 3, - CUSTOM: 4 -}; + out[0] = b00 * a00 + b01 * a10 + b02 * a20; + out[1] = b00 * a01 + b01 * a11 + b02 * a21; + out[2] = b00 * a02 + b01 * a12 + b02 * a22; -/***/ }), -/* 19 */ -/***/ (function(module, exports, __webpack_require__) { + out[3] = b10 * a00 + b11 * a10 + b12 * a20; + out[4] = b10 * a01 + b11 * a11 + b12 * a21; + out[5] = b10 * a02 + b11 * a12 + b12 * a22; -"use strict"; + out[6] = b20 * a00 + b21 * a10 + b22 * a20; + out[7] = b20 * a01 + b21 * a11 + b22 * a21; + out[8] = b20 * a02 + b21 * a12 + b22 * a22; + return out; +} +/** + * Translate a mat3 by the given vector + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the matrix to translate + * @param {vec2} v vector to translate by + * @returns {mat3} out + */ +function translate(out, a, v) { + let a00 = a[0], a01 = a[1], a02 = a[2], + a10 = a[3], a11 = a[4], a12 = a[5], + a20 = a[6], a21 = a[7], a22 = a[8], + x = v[0], y = v[1]; -Object.defineProperty(exports, "__esModule", { - value: true -}); + out[0] = a00; + out[1] = a01; + out[2] = a02; -var _Tw2Curve = __webpack_require__(3); + out[3] = a10; + out[4] = a11; + out[5] = a12; -Object.keys(_Tw2Curve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2Curve[key]; - } - }); -}); + out[6] = x * a00 + y * a10 + a20; + out[7] = x * a01 + y * a11 + a21; + out[8] = x * a02 + y * a12 + a22; + return out; +} -var _Tw2ColorCurve = __webpack_require__(141); +/** + * Rotates a mat3 by the given angle + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat3} out + */ +function rotate(out, a, rad) { + let a00 = a[0], a01 = a[1], a02 = a[2], + a10 = a[3], a11 = a[4], a12 = a[5], + a20 = a[6], a21 = a[7], a22 = a[8], -Object.keys(_Tw2ColorCurve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2ColorCurve[key]; - } - }); -}); + s = Math.sin(rad), + c = Math.cos(rad); -var _Tw2ColorCurve2 = __webpack_require__(142); + out[0] = c * a00 + s * a10; + out[1] = c * a01 + s * a11; + out[2] = c * a02 + s * a12; -Object.keys(_Tw2ColorCurve2).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2ColorCurve2[key]; - } - }); -}); + out[3] = c * a10 - s * a00; + out[4] = c * a11 - s * a01; + out[5] = c * a12 - s * a02; -var _Tw2EventCurve = __webpack_require__(143); - -Object.keys(_Tw2EventCurve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2EventCurve[key]; - } - }); -}); - -var _Tw2PerlinCurve = __webpack_require__(144); - -Object.keys(_Tw2PerlinCurve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2PerlinCurve[key]; - } - }); -}); - -var _Tw2QuaternionCurve = __webpack_require__(145); - -Object.keys(_Tw2QuaternionCurve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2QuaternionCurve[key]; - } - }); -}); + out[6] = a20; + out[7] = a21; + out[8] = a22; + return out; +}; -var _Tw2RandomConstantCurve = __webpack_require__(146); +/** + * Scales the mat3 by the dimensions in the given vec2 + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the matrix to rotate + * @param {vec2} v the vec2 to scale the matrix by + * @returns {mat3} out + **/ +function scale(out, a, v) { + let x = v[0], y = v[1]; -Object.keys(_Tw2RandomConstantCurve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2RandomConstantCurve[key]; - } - }); -}); + out[0] = x * a[0]; + out[1] = x * a[1]; + out[2] = x * a[2]; -var _Tw2RigidOrientation = __webpack_require__(147); + out[3] = y * a[3]; + out[4] = y * a[4]; + out[5] = y * a[5]; -Object.keys(_Tw2RigidOrientation).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2RigidOrientation[key]; - } - }); -}); + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + return out; +} -var _Tw2RotationCurve = __webpack_require__(148); +/** + * Creates a matrix from a vector translation + * This is equivalent to (but much faster than): + * + * mat3.identity(dest); + * mat3.translate(dest, dest, vec); + * + * @param {mat3} out mat3 receiving operation result + * @param {vec2} v Translation vector + * @returns {mat3} out + */ +function fromTranslation(out, v) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 1; + out[5] = 0; + out[6] = v[0]; + out[7] = v[1]; + out[8] = 1; + return out; +} -Object.keys(_Tw2RotationCurve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2RotationCurve[key]; - } - }); -}); +/** + * Creates a matrix from a given angle + * This is equivalent to (but much faster than): + * + * mat3.identity(dest); + * mat3.rotate(dest, dest, rad); + * + * @param {mat3} out mat3 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat3} out + */ +function fromRotation(out, rad) { + let s = Math.sin(rad), c = Math.cos(rad); -var _Tw2ScalarCurve = __webpack_require__(149); + out[0] = c; + out[1] = s; + out[2] = 0; -Object.keys(_Tw2ScalarCurve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2ScalarCurve[key]; - } - }); -}); + out[3] = -s; + out[4] = c; + out[5] = 0; -var _Tw2ScalarCurve2 = __webpack_require__(150); + out[6] = 0; + out[7] = 0; + out[8] = 1; + return out; +} -Object.keys(_Tw2ScalarCurve2).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2ScalarCurve2[key]; - } - }); -}); +/** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat3.identity(dest); + * mat3.scale(dest, dest, vec); + * + * @param {mat3} out mat3 receiving operation result + * @param {vec2} v Scaling vector + * @returns {mat3} out + */ +function fromScaling(out, v) { + out[0] = v[0]; + out[1] = 0; + out[2] = 0; -var _Tw2SineCurve = __webpack_require__(151); + out[3] = 0; + out[4] = v[1]; + out[5] = 0; -Object.keys(_Tw2SineCurve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2SineCurve[key]; - } - }); -}); + out[6] = 0; + out[7] = 0; + out[8] = 1; + return out; +} -var _Tw2Vector2Curve = __webpack_require__(152); +/** + * Copies the values from a mat2d into a mat3 + * + * @param {mat3} out the receiving matrix + * @param {mat2d} a the matrix to copy + * @returns {mat3} out + **/ +function fromMat2d(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = 0; -Object.keys(_Tw2Vector2Curve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2Vector2Curve[key]; - } - }); -}); + out[3] = a[2]; + out[4] = a[3]; + out[5] = 0; -var _Tw2Vector3Curve = __webpack_require__(153); + out[6] = a[4]; + out[7] = a[5]; + out[8] = 1; + return out; +} -Object.keys(_Tw2Vector3Curve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2Vector3Curve[key]; - } - }); -}); +/** +* Calculates a 3x3 matrix from the given quaternion +* +* @param {mat3} out mat3 receiving operation result +* @param {quat} q Quaternion to create matrix from +* +* @returns {mat3} out +*/ +function fromQuat(out, q) { + let x = q[0], y = q[1], z = q[2], w = q[3]; + let x2 = x + x; + let y2 = y + y; + let z2 = z + z; -var _Tw2VectorCurve = __webpack_require__(154); + let xx = x * x2; + let yx = y * x2; + let yy = y * y2; + let zx = z * x2; + let zy = z * y2; + let zz = z * z2; + let wx = w * x2; + let wy = w * y2; + let wz = w * z2; -Object.keys(_Tw2VectorCurve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2VectorCurve[key]; - } - }); -}); + out[0] = 1 - yy - zz; + out[3] = yx - wz; + out[6] = zx + wy; -/***/ }), -/* 20 */ -/***/ (function(module, exports, __webpack_require__) { + out[1] = yx + wz; + out[4] = 1 - xx - zz; + out[7] = zy - wx; -"use strict"; + out[2] = zx - wy; + out[5] = zy + wx; + out[8] = 1 - xx - yy; + return out; +} -Object.defineProperty(exports, "__esModule", { - value: true -}); +/** +* Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix +* +* @param {mat3} out mat3 receiving operation result +* @param {mat4} a Mat4 to derive the normal matrix from +* +* @returns {mat3} out +*/ +function normalFromMat4(out, a) { + let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; -var _Tw2BatchAccumulator = __webpack_require__(65); + let b00 = a00 * a11 - a01 * a10; + let b01 = a00 * a12 - a02 * a10; + let b02 = a00 * a13 - a03 * a10; + let b03 = a01 * a12 - a02 * a11; + let b04 = a01 * a13 - a03 * a11; + let b05 = a02 * a13 - a03 * a12; + let b06 = a20 * a31 - a21 * a30; + let b07 = a20 * a32 - a22 * a30; + let b08 = a20 * a33 - a23 * a30; + let b09 = a21 * a32 - a22 * a31; + let b10 = a21 * a33 - a23 * a31; + let b11 = a22 * a33 - a23 * a32; -Object.keys(_Tw2BatchAccumulator).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2BatchAccumulator[key]; - } - }); -}); + // Calculate the determinant + let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; -var _Tw2ForwardingRenderBatch = __webpack_require__(83); + if (!det) { + return null; + } + det = 1.0 / det; -Object.keys(_Tw2ForwardingRenderBatch).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2ForwardingRenderBatch[key]; - } - }); -}); + out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; -var _Tw2GeometryBatch = __webpack_require__(23); + out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; -Object.keys(_Tw2GeometryBatch).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2GeometryBatch[key]; - } - }); -}); + out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; -var _Tw2GeometryLineBatch = __webpack_require__(84); + return out; +} -Object.keys(_Tw2GeometryLineBatch).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2GeometryLineBatch[key]; - } - }); -}); +/** + * Generates a 2D projection matrix with the given bounds + * + * @param {mat3} out mat3 frustum matrix will be written into + * @param {number} width Width of your gl context + * @param {number} height Height of gl context + * @returns {mat3} out + */ +function projection(out, width, height) { + out[0] = 2 / width; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = -2 / height; + out[5] = 0; + out[6] = -1; + out[7] = 1; + out[8] = 1; + return out; +} -var _Tw2RenderBatch = __webpack_require__(22); +/** + * Returns a string representation of a mat3 + * + * @param {mat3} a matrix to represent as a string + * @returns {String} string representation of the matrix + */ +function str(a) { + return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + + a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + + a[6] + ', ' + a[7] + ', ' + a[8] + ')'; +} -Object.keys(_Tw2RenderBatch).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2RenderBatch[key]; - } - }); -}); +/** + * Returns Frobenius norm of a mat3 + * + * @param {mat3} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm + */ +function frob(a) { + return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2))) +} -var _Tw2InstancedMeshBatch = __webpack_require__(85); +/** + * Adds two mat3's + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the first operand + * @param {mat3} b the second operand + * @returns {mat3} out + */ +function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; + out[4] = a[4] + b[4]; + out[5] = a[5] + b[5]; + out[6] = a[6] + b[6]; + out[7] = a[7] + b[7]; + out[8] = a[8] + b[8]; + return out; +} -Object.keys(_Tw2InstancedMeshBatch).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2InstancedMeshBatch[key]; - } - }); -}); +/** + * Subtracts matrix b from matrix a + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the first operand + * @param {mat3} b the second operand + * @returns {mat3} out + */ +function subtract(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + out[3] = a[3] - b[3]; + out[4] = a[4] - b[4]; + out[5] = a[5] - b[5]; + out[6] = a[6] - b[6]; + out[7] = a[7] - b[7]; + out[8] = a[8] - b[8]; + return out; +} -/***/ }), -/* 21 */ -/***/ (function(module, exports, __webpack_require__) { -"use strict"; +/** + * Multiply each element of the matrix by a scalar. + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the matrix to scale + * @param {Number} b amount to scale the matrix's elements by + * @returns {mat3} out + */ +function multiplyScalar(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; + out[4] = a[4] * b; + out[5] = a[5] * b; + out[6] = a[6] * b; + out[7] = a[7] * b; + out[8] = a[8] * b; + return out; +} -Object.defineProperty(exports, "__esModule", { - value: true -}); +/** + * Adds two mat3's after multiplying each element of the second operand by a scalar value. + * + * @param {mat3} out the receiving vector + * @param {mat3} a the first operand + * @param {mat3} b the second operand + * @param {Number} scale the amount to scale b's elements by before adding + * @returns {mat3} out + */ +function multiplyScalarAndAdd(out, a, b, scale) { + out[0] = a[0] + (b[0] * scale); + out[1] = a[1] + (b[1] * scale); + out[2] = a[2] + (b[2] * scale); + out[3] = a[3] + (b[3] * scale); + out[4] = a[4] + (b[4] * scale); + out[5] = a[5] + (b[5] * scale); + out[6] = a[6] + (b[6] * scale); + out[7] = a[7] + (b[7] * scale); + out[8] = a[8] + (b[8] * scale); + return out; +} -var _Tw2SamplerState = __webpack_require__(42); +/** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {mat3} a The first matrix. + * @param {mat3} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ +function exactEquals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && + a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && + a[6] === b[6] && a[7] === b[7] && a[8] === b[8]; +} -Object.keys(_Tw2SamplerState).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2SamplerState[key]; - } - }); -}); - -var _Tw2SamplerOverride = __webpack_require__(79); - -Object.keys(_Tw2SamplerOverride).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2SamplerOverride[key]; - } - }); -}); - -/***/ }), -/* 22 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2RenderBatch = undefined; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /*eslint no-unused-vars:0*/ - - -var _global = __webpack_require__(17); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Tw2RenderBatch base class - * - * @property {number} renderMode - * @property {Tw2PerObjectData} perObjectData - * @class +/** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {mat3} a The first matrix. + * @param {mat3} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. */ -var Tw2RenderBatch = exports.Tw2RenderBatch = function () { - function Tw2RenderBatch() { - _classCallCheck(this, Tw2RenderBatch); +function equals(a, b) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7], a8 = a[8]; + let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8]; + return (Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && + Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && + Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && + Math.abs(a3 - b3) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a3), Math.abs(b3)) && + Math.abs(a4 - b4) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a4), Math.abs(b4)) && + Math.abs(a5 - b5) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a5), Math.abs(b5)) && + Math.abs(a6 - b6) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a6), Math.abs(b6)) && + Math.abs(a7 - b7) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a7), Math.abs(b7)) && + Math.abs(a8 - b8) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a8), Math.abs(b8))); +} - this.renderMode = _global.device.RM_ANY; - this.perObjectData = null; - } +/** + * Alias for {@link mat3.multiply} + * @function + */ +const mul = multiply; +/* harmony export (immutable) */ __webpack_exports__["mul"] = mul; - /** - * Commits the batch - * @param {string} technique - technique name - */ +/** + * Alias for {@link mat3.subtract} + * @function + */ +const sub = subtract; +/* harmony export (immutable) */ __webpack_exports__["sub"] = sub; - _createClass(Tw2RenderBatch, [{ - key: 'Commit', - value: function Commit(technique) {} - }]); - return Tw2RenderBatch; -}(); /***/ }), -/* 23 */ -/***/ (function(module, exports, __webpack_require__) { +/* 31 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +/* harmony export (immutable) */ __webpack_exports__["create"] = create; +/* harmony export (immutable) */ __webpack_exports__["clone"] = clone; +/* harmony export (immutable) */ __webpack_exports__["length"] = length; +/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues; +/* harmony export (immutable) */ __webpack_exports__["copy"] = copy; +/* harmony export (immutable) */ __webpack_exports__["set"] = set; +/* harmony export (immutable) */ __webpack_exports__["add"] = add; +/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract; +/* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply; +/* harmony export (immutable) */ __webpack_exports__["divide"] = divide; +/* harmony export (immutable) */ __webpack_exports__["ceil"] = ceil; +/* harmony export (immutable) */ __webpack_exports__["floor"] = floor; +/* harmony export (immutable) */ __webpack_exports__["min"] = min; +/* harmony export (immutable) */ __webpack_exports__["max"] = max; +/* harmony export (immutable) */ __webpack_exports__["round"] = round; +/* harmony export (immutable) */ __webpack_exports__["scale"] = scale; +/* harmony export (immutable) */ __webpack_exports__["scaleAndAdd"] = scaleAndAdd; +/* harmony export (immutable) */ __webpack_exports__["distance"] = distance; +/* harmony export (immutable) */ __webpack_exports__["squaredDistance"] = squaredDistance; +/* harmony export (immutable) */ __webpack_exports__["squaredLength"] = squaredLength; +/* harmony export (immutable) */ __webpack_exports__["negate"] = negate; +/* harmony export (immutable) */ __webpack_exports__["inverse"] = inverse; +/* harmony export (immutable) */ __webpack_exports__["normalize"] = normalize; +/* harmony export (immutable) */ __webpack_exports__["dot"] = dot; +/* harmony export (immutable) */ __webpack_exports__["cross"] = cross; +/* harmony export (immutable) */ __webpack_exports__["lerp"] = lerp; +/* harmony export (immutable) */ __webpack_exports__["hermite"] = hermite; +/* harmony export (immutable) */ __webpack_exports__["bezier"] = bezier; +/* harmony export (immutable) */ __webpack_exports__["random"] = random; +/* harmony export (immutable) */ __webpack_exports__["transformMat4"] = transformMat4; +/* harmony export (immutable) */ __webpack_exports__["transformMat3"] = transformMat3; +/* harmony export (immutable) */ __webpack_exports__["transformQuat"] = transformQuat; +/* harmony export (immutable) */ __webpack_exports__["rotateX"] = rotateX; +/* harmony export (immutable) */ __webpack_exports__["rotateY"] = rotateY; +/* harmony export (immutable) */ __webpack_exports__["rotateZ"] = rotateZ; +/* harmony export (immutable) */ __webpack_exports__["angle"] = angle; +/* harmony export (immutable) */ __webpack_exports__["str"] = str; +/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals; +/* harmony export (immutable) */ __webpack_exports__["equals"] = equals; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(3); +/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2GeometryBatch = undefined; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _Tw2RenderBatch2 = __webpack_require__(22); +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. */ -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -/** - * A render batch for geometry - * - * @property {Tw2GeometryRes} geometryRes - * @property {Number} meshIx - * @property {Number} start - * @property {Number} count - * @property {Tw2Effect} effect - * @property {string} technique - * @class +/** + * 3 Dimensional Vector + * @module vec3 */ -var Tw2GeometryBatch = exports.Tw2GeometryBatch = function (_Tw2RenderBatch) { - _inherits(Tw2GeometryBatch, _Tw2RenderBatch); - function Tw2GeometryBatch() { - _classCallCheck(this, Tw2GeometryBatch); +/** + * Creates a new, empty vec3 + * + * @returns {vec3} a new 3D vector + */ +function create() { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](3); + out[0] = 0; + out[1] = 0; + out[2] = 0; + return out; +} - var _this = _possibleConstructorReturn(this, (Tw2GeometryBatch.__proto__ || Object.getPrototypeOf(Tw2GeometryBatch)).call(this)); +/** + * Creates a new vec3 initialized with values from an existing vector + * + * @param {vec3} a vector to clone + * @returns {vec3} a new 3D vector + */ +function clone(a) { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](3); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + return out; +} - _this.geometryRes = null; - _this.meshIx = 0; - _this.start = 0; - _this.count = 1; - _this.effect = null; - return _this; - } +/** + * Calculates the length of a vec3 + * + * @param {vec3} a vector to calculate length of + * @returns {Number} length of a + */ +function length(a) { + let x = a[0]; + let y = a[1]; + let z = a[2]; + return Math.sqrt(x*x + y*y + z*z); +} - /** - * Commits the Tw2InstancedMeshBatch for rendering - * @param {string} technique - technique name - */ +/** + * Creates a new vec3 initialized with the given values + * + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @returns {vec3} a new 3D vector + */ +function fromValues(x, y, z) { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](3); + out[0] = x; + out[1] = y; + out[2] = z; + return out; +} +/** + * Copy the values from one vec3 to another + * + * @param {vec3} out the receiving vector + * @param {vec3} a the source vector + * @returns {vec3} out + */ +function copy(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + return out; +} - _createClass(Tw2GeometryBatch, [{ - key: 'Commit', - value: function Commit(technique) { - if (this.geometryRes && this.effect) { - this.geometryRes.RenderAreas(this.meshIx, this.start, this.count, this.effect, technique); - } - } - }]); +/** + * Set the components of a vec3 to the given values + * + * @param {vec3} out the receiving vector + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @returns {vec3} out + */ +function set(out, x, y, z) { + out[0] = x; + out[1] = y; + out[2] = z; + return out; +} - return Tw2GeometryBatch; -}(_Tw2RenderBatch2.Tw2RenderBatch); +/** + * Adds two vec3's + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {vec3} out + */ +function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + return out; +} -/***/ }), -/* 24 */ -/***/ (function(module, exports, __webpack_require__) { +/** + * Subtracts vector b from vector a + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {vec3} out + */ +function subtract(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + return out; +} -"use strict"; +/** + * Multiplies two vec3's + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {vec3} out + */ +function multiply(out, a, b) { + out[0] = a[0] * b[0]; + out[1] = a[1] * b[1]; + out[2] = a[2] * b[2]; + return out; +} +/** + * Divides two vec3's + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {vec3} out + */ +function divide(out, a, b) { + out[0] = a[0] / b[0]; + out[1] = a[1] / b[1]; + out[2] = a[2] / b[2]; + return out; +} -Object.defineProperty(exports, "__esModule", { - value: true -}); +/** + * Math.ceil the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to ceil + * @returns {vec3} out + */ +function ceil(out, a) { + out[0] = Math.ceil(a[0]); + out[1] = Math.ceil(a[1]); + out[2] = Math.ceil(a[2]); + return out; +} -var _Tw2Parameter = __webpack_require__(7); +/** + * Math.floor the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to floor + * @returns {vec3} out + */ +function floor(out, a) { + out[0] = Math.floor(a[0]); + out[1] = Math.floor(a[1]); + out[2] = Math.floor(a[2]); + return out; +} -Object.keys(_Tw2Parameter).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2Parameter[key]; - } - }); -}); +/** + * Returns the minimum of two vec3's + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {vec3} out + */ +function min(out, a, b) { + out[0] = Math.min(a[0], b[0]); + out[1] = Math.min(a[1], b[1]); + out[2] = Math.min(a[2], b[2]); + return out; +} -var _Tw2FloatParameter = __webpack_require__(89); +/** + * Returns the maximum of two vec3's + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {vec3} out + */ +function max(out, a, b) { + out[0] = Math.max(a[0], b[0]); + out[1] = Math.max(a[1], b[1]); + out[2] = Math.max(a[2], b[2]); + return out; +} -Object.keys(_Tw2FloatParameter).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2FloatParameter[key]; - } - }); -}); +/** + * Math.round the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to round + * @returns {vec3} out + */ +function round(out, a) { + out[0] = Math.round(a[0]); + out[1] = Math.round(a[1]); + out[2] = Math.round(a[2]); + return out; +} -var _Tw2MatrixParameter = __webpack_require__(90); +/** + * Scales a vec3 by a scalar number + * + * @param {vec3} out the receiving vector + * @param {vec3} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {vec3} out + */ +function scale(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + return out; +} -Object.keys(_Tw2MatrixParameter).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2MatrixParameter[key]; - } - }); -}); +/** + * Adds two vec3's after scaling the second operand by a scalar value + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @param {Number} scale the amount to scale b by before adding + * @returns {vec3} out + */ +function scaleAndAdd(out, a, b, scale) { + out[0] = a[0] + (b[0] * scale); + out[1] = a[1] + (b[1] * scale); + out[2] = a[2] + (b[2] * scale); + return out; +} -var _Tw2TransformParameter = __webpack_require__(91); +/** + * Calculates the euclidian distance between two vec3's + * + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {Number} distance between a and b + */ +function distance(a, b) { + let x = b[0] - a[0]; + let y = b[1] - a[1]; + let z = b[2] - a[2]; + return Math.sqrt(x*x + y*y + z*z); +} -Object.keys(_Tw2TransformParameter).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2TransformParameter[key]; - } - }); -}); +/** + * Calculates the squared euclidian distance between two vec3's + * + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {Number} squared distance between a and b + */ +function squaredDistance(a, b) { + let x = b[0] - a[0]; + let y = b[1] - a[1]; + let z = b[2] - a[2]; + return x*x + y*y + z*z; +} -var _Tw2VariableParameter = __webpack_require__(92); +/** + * Calculates the squared length of a vec3 + * + * @param {vec3} a vector to calculate squared length of + * @returns {Number} squared length of a + */ +function squaredLength(a) { + let x = a[0]; + let y = a[1]; + let z = a[2]; + return x*x + y*y + z*z; +} -Object.keys(_Tw2VariableParameter).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2VariableParameter[key]; - } - }); -}); - -var _Tw2Vector2Parameter = __webpack_require__(93); +/** + * Negates the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to negate + * @returns {vec3} out + */ +function negate(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + out[2] = -a[2]; + return out; +} -Object.keys(_Tw2Vector2Parameter).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2Vector2Parameter[key]; - } - }); -}); +/** + * Returns the inverse of the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to invert + * @returns {vec3} out + */ +function inverse(out, a) { + out[0] = 1.0 / a[0]; + out[1] = 1.0 / a[1]; + out[2] = 1.0 / a[2]; + return out; +} -var _Tw2Vector3Parameter = __webpack_require__(94); +/** + * Normalize a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to normalize + * @returns {vec3} out + */ +function normalize(out, a) { + let x = a[0]; + let y = a[1]; + let z = a[2]; + let len = x*x + y*y + z*z; + if (len > 0) { + //TODO: evaluate use of glm_invsqrt here? + len = 1 / Math.sqrt(len); + out[0] = a[0] * len; + out[1] = a[1] * len; + out[2] = a[2] * len; + } + return out; +} -Object.keys(_Tw2Vector3Parameter).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2Vector3Parameter[key]; - } - }); -}); +/** + * Calculates the dot product of two vec3's + * + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {Number} dot product of a and b + */ +function dot(a, b) { + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; +} -var _Tw2Vector4Parameter = __webpack_require__(95); +/** + * Computes the cross product of two vec3's + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @returns {vec3} out + */ +function cross(out, a, b) { + let ax = a[0], ay = a[1], az = a[2]; + let bx = b[0], by = b[1], bz = b[2]; -Object.keys(_Tw2Vector4Parameter).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2Vector4Parameter[key]; - } - }); -}); + out[0] = ay * bz - az * by; + out[1] = az * bx - ax * bz; + out[2] = ax * by - ay * bx; + return out; +} -var _Tw2TextureParameter = __webpack_require__(41); +/** + * Performs a linear interpolation between two vec3's + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @param {Number} t interpolation amount between the two inputs + * @returns {vec3} out + */ +function lerp(out, a, b, t) { + let ax = a[0]; + let ay = a[1]; + let az = a[2]; + out[0] = ax + t * (b[0] - ax); + out[1] = ay + t * (b[1] - ay); + out[2] = az + t * (b[2] - az); + return out; +} -Object.keys(_Tw2TextureParameter).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2TextureParameter[key]; - } - }); -}); +/** + * Performs a hermite interpolation with two control points + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @param {vec3} c the third operand + * @param {vec3} d the fourth operand + * @param {Number} t interpolation amount between the two inputs + * @returns {vec3} out + */ +function hermite(out, a, b, c, d, t) { + let factorTimes2 = t * t; + let factor1 = factorTimes2 * (2 * t - 3) + 1; + let factor2 = factorTimes2 * (t - 2) + t; + let factor3 = factorTimes2 * (t - 1); + let factor4 = factorTimes2 * (3 - 2 * t); -/***/ }), -/* 25 */ -/***/ (function(module, exports, __webpack_require__) { + out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; + out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; + out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; -"use strict"; + return out; +} +/** + * Performs a bezier interpolation with two control points + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @param {vec3} c the third operand + * @param {vec3} d the fourth operand + * @param {Number} t interpolation amount between the two inputs + * @returns {vec3} out + */ +function bezier(out, a, b, c, d, t) { + let inverseFactor = 1 - t; + let inverseFactorTimesTwo = inverseFactor * inverseFactor; + let factorTimes2 = t * t; + let factor1 = inverseFactorTimesTwo * inverseFactor; + let factor2 = 3 * t * inverseFactorTimesTwo; + let factor3 = 3 * factorTimes2 * inverseFactor; + let factor4 = factorTimes2 * t; -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2RawData = undefined; + out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; + out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; + out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + return out; +} -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +/** + * Generates a random vector with the given scale + * + * @param {vec3} out the receiving vector + * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned + * @returns {vec3} out + */ +function random(out, scale) { + scale = scale || 1.0; -var _math = __webpack_require__(0); + let r = __WEBPACK_IMPORTED_MODULE_0__common__["RANDOM"]() * 2.0 * Math.PI; + let z = (__WEBPACK_IMPORTED_MODULE_0__common__["RANDOM"]() * 2.0) - 1.0; + let zScale = Math.sqrt(1.0-z*z) * scale; -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + out[0] = Math.cos(r) * zScale; + out[1] = Math.sin(r) * zScale; + out[2] = z * scale; + return out; +} -/** - * Stores raw data for {@link Tw2PerObjectData} - * - * @param {{string:Float32Array|Array|number}} [declarations] An optional object containing raw data declarations - * @property {number} nextOffset - * @property {Float32Array} data - * @property {*} elements - * @class +/** + * Transforms the vec3 with a mat4. + * 4th vector component is implicitly '1' + * + * @param {vec3} out the receiving vector + * @param {vec3} a the vector to transform + * @param {mat4} m matrix to transform with + * @returns {vec3} out */ -var Tw2RawData = exports.Tw2RawData = function () { - function Tw2RawData(declarations) { - _classCallCheck(this, Tw2RawData); - - this.nextOffset = 0; - this.data = null; - this.elements = {}; +function transformMat4(out, a, m) { + let x = a[0], y = a[1], z = a[2]; + let w = m[3] * x + m[7] * y + m[11] * z + m[15]; + w = w || 1.0; + out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w; + out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w; + out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w; + return out; +} - if (declarations) { - this.DeclareFromObject(declarations); - } - } +/** + * Transforms the vec3 with a mat3. + * + * @param {vec3} out the receiving vector + * @param {vec3} a the vector to transform + * @param {mat3} m the 3x3 matrix to transform with + * @returns {vec3} out + */ +function transformMat3(out, a, m) { + let x = a[0], y = a[1], z = a[2]; + out[0] = x * m[0] + y * m[3] + z * m[6]; + out[1] = x * m[1] + y * m[4] + z * m[7]; + out[2] = x * m[2] + y * m[5] + z * m[8]; + return out; +} - /** - * Sets a element value - * @param {string} name - * @param {Float32Array|Array} value - */ +/** + * Transforms the vec3 with a quat + * + * @param {vec3} out the receiving vector + * @param {vec3} a the vector to transform + * @param {quat} q quaternion to transform with + * @returns {vec3} out + */ +function transformQuat(out, a, q) { + // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations + let x = a[0], y = a[1], z = a[2]; + let qx = q[0], qy = q[1], qz = q[2], qw = q[3]; - _createClass(Tw2RawData, [{ - key: 'Set', - value: function Set(name, value) { - var el = this.elements[name]; - this.data.set(value.length > el.size ? value.subarray(0, el.size) : value, el.offset); - } + // calculate quat * vec + let ix = qw * x + qy * z - qz * y; + let iy = qw * y + qz * x - qx * z; + let iz = qw * z + qx * y - qy * x; + let iw = -qx * x - qy * y - qz * z; - /** - * Gets an element's array value - * @param {string} name - * @return {Float32Array} - */ + // calculate result * inverse quat + out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy; + out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz; + out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx; + return out; +} - }, { - key: 'Get', - value: function Get(name) { - return this.elements[name].array; - } +/** + * Rotate a 3D vector around the x-axis + * @param {vec3} out The receiving vec3 + * @param {vec3} a The vec3 point to rotate + * @param {vec3} b The origin of the rotation + * @param {Number} c The angle of rotation + * @returns {vec3} out + */ +function rotateX(out, a, b, c){ + let p = [], r=[]; + //Translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; - /** - * Gets an element's array value from the share data array - * @param {string} name - * @return {Float32Array} - */ + //perform rotation + r[0] = p[0]; + r[1] = p[1]*Math.cos(c) - p[2]*Math.sin(c); + r[2] = p[1]*Math.sin(c) + p[2]*Math.cos(c); - }, { - key: 'GetData', - value: function GetData(name) { - return this.data.subarray(this.elements[name].offset, this.elements[name].offset + this.elements[name].array.length); - } + //translate to correct position + out[0] = r[0] + b[0]; + out[1] = r[1] + b[1]; + out[2] = r[2] + b[2]; - /** - * Creates the raw data element arrays - */ + return out; +} - }, { - key: 'Create', - value: function Create() { - this.data = new Float32Array(this.nextOffset); - for (var name in this.elements) { - if (this.elements.hasOwnProperty(name)) { - var el = this.elements[name]; - el.array = this.data.subarray(el.offset, el.offset + el.size); +/** + * Rotate a 3D vector around the y-axis + * @param {vec3} out The receiving vec3 + * @param {vec3} a The vec3 point to rotate + * @param {vec3} b The origin of the rotation + * @param {Number} c The angle of rotation + * @returns {vec3} out + */ +function rotateY(out, a, b, c){ + let p = [], r=[]; + //Translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; - if (el.value !== null) { - if (el.size === 1) { - el.array[0] = el.value; - } else { - for (var i = 0; i < el.size; i++) { - el.array[i] = el.value[i]; - } - } - el.value = null; - } - } - } - } + //perform rotation + r[0] = p[2]*Math.sin(c) + p[0]*Math.cos(c); + r[1] = p[1]; + r[2] = p[2]*Math.cos(c) - p[0]*Math.sin(c); - /** - * Declares a raw data element - * @param {String} name - * @param {number} size - * @param {!|number|Array|Float32Array} [value=null] optional value to set on raw data creation - */ + //translate to correct position + out[0] = r[0] + b[0]; + out[1] = r[1] + b[1]; + out[2] = r[2] + b[2]; - }, { - key: 'Declare', - value: function Declare(name, size) { - var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; + return out; +} - this.elements[name] = { - offset: this.nextOffset, - size: size, - array: null, - value: value - }; +/** + * Rotate a 3D vector around the z-axis + * @param {vec3} out The receiving vec3 + * @param {vec3} a The vec3 point to rotate + * @param {vec3} b The origin of the rotation + * @param {Number} c The angle of rotation + * @returns {vec3} out + */ +function rotateZ(out, a, b, c){ + let p = [], r=[]; + //Translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; - this.nextOffset += size; - } + //perform rotation + r[0] = p[0]*Math.cos(c) - p[1]*Math.sin(c); + r[1] = p[0]*Math.sin(c) + p[1]*Math.cos(c); + r[2] = p[2]; - /** - * Declares raw data from an object and then creates the elements - * @param {{string:Float32Array|Array|number}} declarations - */ + //translate to correct position + out[0] = r[0] + b[0]; + out[1] = r[1] + b[1]; + out[2] = r[2] + b[2]; - }, { - key: 'DeclareFromObject', - value: function DeclareFromObject() { - var declarations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return out; +} - for (var name in declarations) { - if (declarations.hasOwnProperty(name)) { - var value = declarations[name]; +/** + * Get the angle between two 3D vectors + * @param {vec3} a The first operand + * @param {vec3} b The second operand + * @returns {Number} The angle in radians + */ +function angle(a, b) { + let tempA = fromValues(a[0], a[1], a[2]); + let tempB = fromValues(b[0], b[1], b[2]); - if (typeof value === 'number') { - this.Declare(name, 1, value); - } else if (_math.util.isArrayLike(value)) { - if (value.length === 1) { - this.Declare(name, value.length, value); - } - } else { - throw new Error('Invalid declaration type: ' + (typeof value === 'undefined' ? 'undefined' : _typeof(value))); - } - } - } + normalize(tempA, tempA); + normalize(tempB, tempB); - this.Create(); - } - }]); + let cosine = dot(tempA, tempB); - return Tw2RawData; -}(); + if(cosine > 1.0) { + return 0; + } + else if(cosine < -1.0) { + return Math.PI; + } else { + return Math.acos(cosine); + } +} -/***/ }), -/* 26 */ -/***/ (function(module, exports, __webpack_require__) { +/** + * Returns a string representation of a vector + * + * @param {vec3} a vector to represent as a string + * @returns {String} string representation of the vector + */ +function str(a) { + return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')'; +} -"use strict"; +/** + * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) + * + * @param {vec3} a The first vector. + * @param {vec3} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ +function exactEquals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2]; +} +/** + * Returns whether or not the vectors have approximately the same elements in the same position. + * + * @param {vec3} a The first vector. + * @param {vec3} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ +function equals(a, b) { + let a0 = a[0], a1 = a[1], a2 = a[2]; + let b0 = b[0], b1 = b[1], b2 = b[2]; + return (Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && + Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && + Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a2), Math.abs(b2))); +} -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2ParticleEmitter = undefined; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* eslint no-unused-vars:0 */ - - -var _math = __webpack_require__(0); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Particle Emitter base class - * - * @property {number|string} id - * @property {string} name - * @property {Tw2ParticleSystem} particleSystem - * @class +/** + * Alias for {@link vec3.subtract} + * @function */ -var Tw2ParticleEmitter = exports.Tw2ParticleEmitter = function () { - function Tw2ParticleEmitter() { - _classCallCheck(this, Tw2ParticleEmitter); - - this._id = _math.util.generateID(); - this.name = ''; - this.particleSystem = null; - } - - /** - * Initializes the particle emitter - */ - - - _createClass(Tw2ParticleEmitter, [{ - key: 'Initialize', - value: function Initialize() {} - - /** - * Per frame update - * @param {number} dt - delta time - */ - - }, { - key: 'Update', - value: function Update(dt) {} - }]); - - return Tw2ParticleEmitter; -}(); - -/***/ }), -/* 27 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2ParticleAttributeGenerator = undefined; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* eslint no-unused-vars:0 */ - - -var _math = __webpack_require__(0); +const sub = subtract; +/* harmony export (immutable) */ __webpack_exports__["sub"] = sub; -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -/** - * Tw2ParticleAttributeGenerator base class - * - * @property {number|string} id - * @property {string} name - * @class +/** + * Alias for {@link vec3.multiply} + * @function */ -var Tw2ParticleAttributeGenerator = exports.Tw2ParticleAttributeGenerator = function () { - function Tw2ParticleAttributeGenerator() { - _classCallCheck(this, Tw2ParticleAttributeGenerator); - - this._id = _math.util.generateID(); - this.name = ''; - } - - /** - * Binds a particle system element to the generator - * @param {Tw2ParticleSystem} ps - * @returns {boolean} True if successfully bound - */ - - - _createClass(Tw2ParticleAttributeGenerator, [{ - key: 'Bind', - value: function Bind(ps) { - return false; - } - - /** - * Generates the attributes - * @param {Tw2ParticleElement} position - * @param {Tw2ParticleElement} velocity - * @param {number} index - */ - - }, { - key: 'Generate', - value: function Generate(position, velocity, index) {} - }]); - - return Tw2ParticleAttributeGenerator; -}(); - -Tw2ParticleAttributeGenerator.global = { - vec3_0: _math.vec3.create() -}; - -/***/ }), -/* 28 */ -/***/ (function(module, exports, __webpack_require__) { +const mul = multiply; +/* harmony export (immutable) */ __webpack_exports__["mul"] = mul; -"use strict"; +/** + * Alias for {@link vec3.divide} + * @function + */ +const div = divide; +/* harmony export (immutable) */ __webpack_exports__["div"] = div; -Object.defineProperty(exports, "__esModule", { - value: true -}); -var _Tw2EffectRes = __webpack_require__(133); +/** + * Alias for {@link vec3.distance} + * @function + */ +const dist = distance; +/* harmony export (immutable) */ __webpack_exports__["dist"] = dist; -Object.keys(_Tw2EffectRes).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2EffectRes[key]; - } - }); -}); -var _Tw2GeometryRes = __webpack_require__(135); +/** + * Alias for {@link vec3.squaredDistance} + * @function + */ +const sqrDist = squaredDistance; +/* harmony export (immutable) */ __webpack_exports__["sqrDist"] = sqrDist; -Object.keys(_Tw2GeometryRes).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2GeometryRes[key]; - } - }); -}); -var _Tw2LoadingObject = __webpack_require__(37); +/** + * Alias for {@link vec3.length} + * @function + */ +const len = length; +/* harmony export (immutable) */ __webpack_exports__["len"] = len; -Object.keys(_Tw2LoadingObject).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2LoadingObject[key]; - } - }); -}); -var _Tw2Resource = __webpack_require__(12); +/** + * Alias for {@link vec3.squaredLength} + * @function + */ +const sqrLen = squaredLength; +/* harmony export (immutable) */ __webpack_exports__["sqrLen"] = sqrLen; -Object.keys(_Tw2Resource).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2Resource[key]; - } - }); -}); -var _Tw2TextureRes = __webpack_require__(51); +/** + * Perform some operation over an array of vec3s. + * + * @param {Array} a the array of vectors to iterate over + * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed + * @param {Number} offset Number of elements to skip at the beginning of the array + * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array + * @param {Function} fn Function to call for each vector in the array + * @param {Object} [arg] additional argument to pass to fn + * @returns {Array} a + * @function + */ +const forEach = (function() { + let vec = create(); -Object.keys(_Tw2TextureRes).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2TextureRes[key]; + return function(a, stride, offset, count, fn, arg) { + let i, l; + if(!stride) { + stride = 3; } - }); -}); - -var _Tw2VideoRes = __webpack_require__(136); -Object.keys(_Tw2VideoRes).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2VideoRes[key]; + if(!offset) { + offset = 0; } - }); -}); - -/***/ }), -/* 29 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _Tw2BinaryReader = __webpack_require__(39); - -Object.keys(_Tw2BinaryReader).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2BinaryReader[key]; + if(count) { + l = Math.min((count * stride) + offset, a.length); + } else { + l = a.length; } - }); -}); -var _Tw2ObjectReader = __webpack_require__(38); - -Object.keys(_Tw2ObjectReader).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2ObjectReader[key]; + for(i = offset; i < l; i += stride) { + vec[0] = a[i]; vec[1] = a[i+1]; vec[2] = a[i+2]; + fn(vec, vec, arg); + a[i] = vec[0]; a[i+1] = vec[1]; a[i+2] = vec[2]; } - }); -}); - -/***/ }), -/* 30 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -var num = exports.num = {}; + return a; + }; +})(); +/* harmony export (immutable) */ __webpack_exports__["forEach"] = forEach; -/** - * biCumulative - * - * @param {number} t - * @param {number} order - * @returns {number} - */ -num.biCumulative = function (t, order) { - if (order === 1) { - var some = 1.0 - t; - return 1.0 - some * some * some; - } else if (order === 2) { - return 3.0 * t * t - 2.0 * t * t * t; - } else { - return t * t * t; - } -}; -/** - * Exponential decay - * - * @param {number} omega0 - * @param {number} torque - * @param {number} I - inertia - * @param {number} d - drag - * @param {number} time - time - * @returns {number} - */ -num.exponentialDecay = function (omega0, torque, I, d, time) { - return torque * time / d + I * (omega0 * d - torque) / (d * d) * (1.0 - Math.pow(Math.E, -d * time / I)); -}; /***/ }), -/* 31 */ +/* 32 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony export (immutable) */ __webpack_exports__["create"] = create; -/* harmony export (immutable) */ __webpack_exports__["fromMat4"] = fromMat4; /* harmony export (immutable) */ __webpack_exports__["clone"] = clone; -/* harmony export (immutable) */ __webpack_exports__["copy"] = copy; /* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues; +/* harmony export (immutable) */ __webpack_exports__["copy"] = copy; /* harmony export (immutable) */ __webpack_exports__["set"] = set; -/* harmony export (immutable) */ __webpack_exports__["identity"] = identity; -/* harmony export (immutable) */ __webpack_exports__["transpose"] = transpose; -/* harmony export (immutable) */ __webpack_exports__["invert"] = invert; -/* harmony export (immutable) */ __webpack_exports__["adjoint"] = adjoint; -/* harmony export (immutable) */ __webpack_exports__["determinant"] = determinant; +/* harmony export (immutable) */ __webpack_exports__["add"] = add; +/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract; /* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply; -/* harmony export (immutable) */ __webpack_exports__["translate"] = translate; -/* harmony export (immutable) */ __webpack_exports__["rotate"] = rotate; +/* harmony export (immutable) */ __webpack_exports__["divide"] = divide; +/* harmony export (immutable) */ __webpack_exports__["ceil"] = ceil; +/* harmony export (immutable) */ __webpack_exports__["floor"] = floor; +/* harmony export (immutable) */ __webpack_exports__["min"] = min; +/* harmony export (immutable) */ __webpack_exports__["max"] = max; +/* harmony export (immutable) */ __webpack_exports__["round"] = round; /* harmony export (immutable) */ __webpack_exports__["scale"] = scale; -/* harmony export (immutable) */ __webpack_exports__["fromTranslation"] = fromTranslation; -/* harmony export (immutable) */ __webpack_exports__["fromRotation"] = fromRotation; -/* harmony export (immutable) */ __webpack_exports__["fromScaling"] = fromScaling; -/* harmony export (immutable) */ __webpack_exports__["fromMat2d"] = fromMat2d; -/* harmony export (immutable) */ __webpack_exports__["fromQuat"] = fromQuat; -/* harmony export (immutable) */ __webpack_exports__["normalFromMat4"] = normalFromMat4; -/* harmony export (immutable) */ __webpack_exports__["projection"] = projection; +/* harmony export (immutable) */ __webpack_exports__["scaleAndAdd"] = scaleAndAdd; +/* harmony export (immutable) */ __webpack_exports__["distance"] = distance; +/* harmony export (immutable) */ __webpack_exports__["squaredDistance"] = squaredDistance; +/* harmony export (immutable) */ __webpack_exports__["length"] = length; +/* harmony export (immutable) */ __webpack_exports__["squaredLength"] = squaredLength; +/* harmony export (immutable) */ __webpack_exports__["negate"] = negate; +/* harmony export (immutable) */ __webpack_exports__["inverse"] = inverse; +/* harmony export (immutable) */ __webpack_exports__["normalize"] = normalize; +/* harmony export (immutable) */ __webpack_exports__["dot"] = dot; +/* harmony export (immutable) */ __webpack_exports__["lerp"] = lerp; +/* harmony export (immutable) */ __webpack_exports__["random"] = random; +/* harmony export (immutable) */ __webpack_exports__["transformMat4"] = transformMat4; +/* harmony export (immutable) */ __webpack_exports__["transformQuat"] = transformQuat; /* harmony export (immutable) */ __webpack_exports__["str"] = str; -/* harmony export (immutable) */ __webpack_exports__["frob"] = frob; -/* harmony export (immutable) */ __webpack_exports__["add"] = add; -/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract; -/* harmony export (immutable) */ __webpack_exports__["multiplyScalar"] = multiplyScalar; -/* harmony export (immutable) */ __webpack_exports__["multiplyScalarAndAdd"] = multiplyScalarAndAdd; /* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals; /* harmony export (immutable) */ __webpack_exports__["equals"] = equals; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(3); /* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. Permission is hereby granted, free of charge, to any person obtaining a copy @@ -5904,2629 +5973,1414 @@ THE SOFTWARE. */ /** - * 3x3 Matrix - * @module mat3 + * 4 Dimensional Vector + * @module vec4 */ /** - * Creates a new identity mat3 + * Creates a new, empty vec4 * - * @returns {mat3} a new 3x3 matrix + * @returns {vec4} a new 4D vector */ function create() { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](9); - out[0] = 1; + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](4); + out[0] = 0; out[1] = 0; out[2] = 0; out[3] = 0; - out[4] = 1; - out[5] = 0; - out[6] = 0; - out[7] = 0; - out[8] = 1; return out; } /** - * Copies the upper-left 3x3 values into the given mat3. + * Creates a new vec4 initialized with values from an existing vector * - * @param {mat3} out the receiving 3x3 matrix - * @param {mat4} a the source 4x4 matrix - * @returns {mat3} out + * @param {vec4} a vector to clone + * @returns {vec4} a new 4D vector */ -function fromMat4(out, a) { +function clone(a) { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](4); out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; - out[3] = a[4]; - out[4] = a[5]; - out[5] = a[6]; - out[6] = a[8]; - out[7] = a[9]; - out[8] = a[10]; + out[3] = a[3]; return out; } /** - * Creates a new mat3 initialized with values from an existing matrix + * Creates a new vec4 initialized with the given values * - * @param {mat3} a matrix to clone - * @returns {mat3} a new 3x3 matrix + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {vec4} a new 4D vector */ -function clone(a) { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](9); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; +function fromValues(x, y, z, w) { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](4); + out[0] = x; + out[1] = y; + out[2] = z; + out[3] = w; return out; } /** - * Copy the values from one mat3 to another + * Copy the values from one vec4 to another * - * @param {mat3} out the receiving matrix - * @param {mat3} a the source matrix - * @returns {mat3} out + * @param {vec4} out the receiving vector + * @param {vec4} a the source vector + * @returns {vec4} out */ function copy(out, a) { out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; return out; } /** - * Create a new mat3 with the given values + * Set the components of a vec4 to the given values * - * @param {Number} m00 Component in column 0, row 0 position (index 0) - * @param {Number} m01 Component in column 0, row 1 position (index 1) - * @param {Number} m02 Component in column 0, row 2 position (index 2) - * @param {Number} m10 Component in column 1, row 0 position (index 3) - * @param {Number} m11 Component in column 1, row 1 position (index 4) - * @param {Number} m12 Component in column 1, row 2 position (index 5) - * @param {Number} m20 Component in column 2, row 0 position (index 6) - * @param {Number} m21 Component in column 2, row 1 position (index 7) - * @param {Number} m22 Component in column 2, row 2 position (index 8) - * @returns {mat3} A new mat3 + * @param {vec4} out the receiving vector + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {vec4} out */ -function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](9); - out[0] = m00; - out[1] = m01; - out[2] = m02; - out[3] = m10; - out[4] = m11; - out[5] = m12; - out[6] = m20; - out[7] = m21; - out[8] = m22; +function set(out, x, y, z, w) { + out[0] = x; + out[1] = y; + out[2] = z; + out[3] = w; return out; } /** - * Set the components of a mat3 to the given values + * Adds two vec4's * - * @param {mat3} out the receiving matrix - * @param {Number} m00 Component in column 0, row 0 position (index 0) - * @param {Number} m01 Component in column 0, row 1 position (index 1) - * @param {Number} m02 Component in column 0, row 2 position (index 2) - * @param {Number} m10 Component in column 1, row 0 position (index 3) - * @param {Number} m11 Component in column 1, row 1 position (index 4) - * @param {Number} m12 Component in column 1, row 2 position (index 5) - * @param {Number} m20 Component in column 2, row 0 position (index 6) - * @param {Number} m21 Component in column 2, row 1 position (index 7) - * @param {Number} m22 Component in column 2, row 2 position (index 8) - * @returns {mat3} out + * @param {vec4} out the receiving vector + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {vec4} out */ -function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) { - out[0] = m00; - out[1] = m01; - out[2] = m02; - out[3] = m10; - out[4] = m11; - out[5] = m12; - out[6] = m20; - out[7] = m21; - out[8] = m22; +function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; return out; } /** - * Set a mat3 to the identity matrix + * Subtracts vector b from vector a * - * @param {mat3} out the receiving matrix - * @returns {mat3} out + * @param {vec4} out the receiving vector + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {vec4} out */ -function identity(out) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 1; - out[5] = 0; - out[6] = 0; - out[7] = 0; - out[8] = 1; - return out; -} +function subtract(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + out[3] = a[3] - b[3]; + return out; +} /** - * Transpose the values of a mat3 + * Multiplies two vec4's * - * @param {mat3} out the receiving matrix - * @param {mat3} a the source matrix - * @returns {mat3} out + * @param {vec4} out the receiving vector + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {vec4} out */ -function transpose(out, a) { - // If we are transposing ourselves we can skip a few steps but have to cache some values - if (out === a) { - let a01 = a[1], a02 = a[2], a12 = a[5]; - out[1] = a[3]; - out[2] = a[6]; - out[3] = a01; - out[5] = a[7]; - out[6] = a02; - out[7] = a12; - } else { - out[0] = a[0]; - out[1] = a[3]; - out[2] = a[6]; - out[3] = a[1]; - out[4] = a[4]; - out[5] = a[7]; - out[6] = a[2]; - out[7] = a[5]; - out[8] = a[8]; - } - +function multiply(out, a, b) { + out[0] = a[0] * b[0]; + out[1] = a[1] * b[1]; + out[2] = a[2] * b[2]; + out[3] = a[3] * b[3]; return out; } /** - * Inverts a mat3 + * Divides two vec4's * - * @param {mat3} out the receiving matrix - * @param {mat3} a the source matrix - * @returns {mat3} out + * @param {vec4} out the receiving vector + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {vec4} out */ -function invert(out, a) { - let a00 = a[0], a01 = a[1], a02 = a[2]; - let a10 = a[3], a11 = a[4], a12 = a[5]; - let a20 = a[6], a21 = a[7], a22 = a[8]; - - let b01 = a22 * a11 - a12 * a21; - let b11 = -a22 * a10 + a12 * a20; - let b21 = a21 * a10 - a11 * a20; - - // Calculate the determinant - let det = a00 * b01 + a01 * b11 + a02 * b21; - - if (!det) { - return null; - } - det = 1.0 / det; - - out[0] = b01 * det; - out[1] = (-a22 * a01 + a02 * a21) * det; - out[2] = (a12 * a01 - a02 * a11) * det; - out[3] = b11 * det; - out[4] = (a22 * a00 - a02 * a20) * det; - out[5] = (-a12 * a00 + a02 * a10) * det; - out[6] = b21 * det; - out[7] = (-a21 * a00 + a01 * a20) * det; - out[8] = (a11 * a00 - a01 * a10) * det; +function divide(out, a, b) { + out[0] = a[0] / b[0]; + out[1] = a[1] / b[1]; + out[2] = a[2] / b[2]; + out[3] = a[3] / b[3]; return out; } /** - * Calculates the adjugate of a mat3 + * Math.ceil the components of a vec4 * - * @param {mat3} out the receiving matrix - * @param {mat3} a the source matrix - * @returns {mat3} out + * @param {vec4} out the receiving vector + * @param {vec4} a vector to ceil + * @returns {vec4} out */ -function adjoint(out, a) { - let a00 = a[0], a01 = a[1], a02 = a[2]; - let a10 = a[3], a11 = a[4], a12 = a[5]; - let a20 = a[6], a21 = a[7], a22 = a[8]; - - out[0] = (a11 * a22 - a12 * a21); - out[1] = (a02 * a21 - a01 * a22); - out[2] = (a01 * a12 - a02 * a11); - out[3] = (a12 * a20 - a10 * a22); - out[4] = (a00 * a22 - a02 * a20); - out[5] = (a02 * a10 - a00 * a12); - out[6] = (a10 * a21 - a11 * a20); - out[7] = (a01 * a20 - a00 * a21); - out[8] = (a00 * a11 - a01 * a10); +function ceil(out, a) { + out[0] = Math.ceil(a[0]); + out[1] = Math.ceil(a[1]); + out[2] = Math.ceil(a[2]); + out[3] = Math.ceil(a[3]); return out; } /** - * Calculates the determinant of a mat3 + * Math.floor the components of a vec4 * - * @param {mat3} a the source matrix - * @returns {Number} determinant of a + * @param {vec4} out the receiving vector + * @param {vec4} a vector to floor + * @returns {vec4} out */ -function determinant(a) { - let a00 = a[0], a01 = a[1], a02 = a[2]; - let a10 = a[3], a11 = a[4], a12 = a[5]; - let a20 = a[6], a21 = a[7], a22 = a[8]; - - return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); +function floor(out, a) { + out[0] = Math.floor(a[0]); + out[1] = Math.floor(a[1]); + out[2] = Math.floor(a[2]); + out[3] = Math.floor(a[3]); + return out; } /** - * Multiplies two mat3's + * Returns the minimum of two vec4's * - * @param {mat3} out the receiving matrix - * @param {mat3} a the first operand - * @param {mat3} b the second operand - * @returns {mat3} out + * @param {vec4} out the receiving vector + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {vec4} out */ -function multiply(out, a, b) { - let a00 = a[0], a01 = a[1], a02 = a[2]; - let a10 = a[3], a11 = a[4], a12 = a[5]; - let a20 = a[6], a21 = a[7], a22 = a[8]; - - let b00 = b[0], b01 = b[1], b02 = b[2]; - let b10 = b[3], b11 = b[4], b12 = b[5]; - let b20 = b[6], b21 = b[7], b22 = b[8]; - - out[0] = b00 * a00 + b01 * a10 + b02 * a20; - out[1] = b00 * a01 + b01 * a11 + b02 * a21; - out[2] = b00 * a02 + b01 * a12 + b02 * a22; - - out[3] = b10 * a00 + b11 * a10 + b12 * a20; - out[4] = b10 * a01 + b11 * a11 + b12 * a21; - out[5] = b10 * a02 + b11 * a12 + b12 * a22; - - out[6] = b20 * a00 + b21 * a10 + b22 * a20; - out[7] = b20 * a01 + b21 * a11 + b22 * a21; - out[8] = b20 * a02 + b21 * a12 + b22 * a22; +function min(out, a, b) { + out[0] = Math.min(a[0], b[0]); + out[1] = Math.min(a[1], b[1]); + out[2] = Math.min(a[2], b[2]); + out[3] = Math.min(a[3], b[3]); return out; } /** - * Translate a mat3 by the given vector + * Returns the maximum of two vec4's * - * @param {mat3} out the receiving matrix - * @param {mat3} a the matrix to translate - * @param {vec2} v vector to translate by - * @returns {mat3} out + * @param {vec4} out the receiving vector + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {vec4} out */ -function translate(out, a, v) { - let a00 = a[0], a01 = a[1], a02 = a[2], - a10 = a[3], a11 = a[4], a12 = a[5], - a20 = a[6], a21 = a[7], a22 = a[8], - x = v[0], y = v[1]; - - out[0] = a00; - out[1] = a01; - out[2] = a02; - - out[3] = a10; - out[4] = a11; - out[5] = a12; - - out[6] = x * a00 + y * a10 + a20; - out[7] = x * a01 + y * a11 + a21; - out[8] = x * a02 + y * a12 + a22; +function max(out, a, b) { + out[0] = Math.max(a[0], b[0]); + out[1] = Math.max(a[1], b[1]); + out[2] = Math.max(a[2], b[2]); + out[3] = Math.max(a[3], b[3]); return out; } /** - * Rotates a mat3 by the given angle + * Math.round the components of a vec4 * - * @param {mat3} out the receiving matrix - * @param {mat3} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat3} out + * @param {vec4} out the receiving vector + * @param {vec4} a vector to round + * @returns {vec4} out */ -function rotate(out, a, rad) { - let a00 = a[0], a01 = a[1], a02 = a[2], - a10 = a[3], a11 = a[4], a12 = a[5], - a20 = a[6], a21 = a[7], a22 = a[8], - - s = Math.sin(rad), - c = Math.cos(rad); - - out[0] = c * a00 + s * a10; - out[1] = c * a01 + s * a11; - out[2] = c * a02 + s * a12; - - out[3] = c * a10 - s * a00; - out[4] = c * a11 - s * a01; - out[5] = c * a12 - s * a02; - - out[6] = a20; - out[7] = a21; - out[8] = a22; +function round(out, a) { + out[0] = Math.round(a[0]); + out[1] = Math.round(a[1]); + out[2] = Math.round(a[2]); + out[3] = Math.round(a[3]); return out; -}; +} /** - * Scales the mat3 by the dimensions in the given vec2 + * Scales a vec4 by a scalar number * - * @param {mat3} out the receiving matrix - * @param {mat3} a the matrix to rotate - * @param {vec2} v the vec2 to scale the matrix by - * @returns {mat3} out - **/ -function scale(out, a, v) { - let x = v[0], y = v[1]; - - out[0] = x * a[0]; - out[1] = x * a[1]; - out[2] = x * a[2]; - - out[3] = y * a[3]; - out[4] = y * a[4]; - out[5] = y * a[5]; - - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; + * @param {vec4} out the receiving vector + * @param {vec4} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {vec4} out + */ +function scale(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; return out; } /** - * Creates a matrix from a vector translation - * This is equivalent to (but much faster than): - * - * mat3.identity(dest); - * mat3.translate(dest, dest, vec); + * Adds two vec4's after scaling the second operand by a scalar value * - * @param {mat3} out mat3 receiving operation result - * @param {vec2} v Translation vector - * @returns {mat3} out + * @param {vec4} out the receiving vector + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @param {Number} scale the amount to scale b by before adding + * @returns {vec4} out */ -function fromTranslation(out, v) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 1; - out[5] = 0; - out[6] = v[0]; - out[7] = v[1]; - out[8] = 1; +function scaleAndAdd(out, a, b, scale) { + out[0] = a[0] + (b[0] * scale); + out[1] = a[1] + (b[1] * scale); + out[2] = a[2] + (b[2] * scale); + out[3] = a[3] + (b[3] * scale); return out; } /** - * Creates a matrix from a given angle - * This is equivalent to (but much faster than): + * Calculates the euclidian distance between two vec4's * - * mat3.identity(dest); - * mat3.rotate(dest, dest, rad); + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {Number} distance between a and b + */ +function distance(a, b) { + let x = b[0] - a[0]; + let y = b[1] - a[1]; + let z = b[2] - a[2]; + let w = b[3] - a[3]; + return Math.sqrt(x*x + y*y + z*z + w*w); +} + +/** + * Calculates the squared euclidian distance between two vec4's * - * @param {mat3} out mat3 receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat3} out + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {Number} squared distance between a and b */ -function fromRotation(out, rad) { - let s = Math.sin(rad), c = Math.cos(rad); +function squaredDistance(a, b) { + let x = b[0] - a[0]; + let y = b[1] - a[1]; + let z = b[2] - a[2]; + let w = b[3] - a[3]; + return x*x + y*y + z*z + w*w; +} - out[0] = c; - out[1] = s; - out[2] = 0; +/** + * Calculates the length of a vec4 + * + * @param {vec4} a vector to calculate length of + * @returns {Number} length of a + */ +function length(a) { + let x = a[0]; + let y = a[1]; + let z = a[2]; + let w = a[3]; + return Math.sqrt(x*x + y*y + z*z + w*w); +} - out[3] = -s; - out[4] = c; - out[5] = 0; +/** + * Calculates the squared length of a vec4 + * + * @param {vec4} a vector to calculate squared length of + * @returns {Number} squared length of a + */ +function squaredLength(a) { + let x = a[0]; + let y = a[1]; + let z = a[2]; + let w = a[3]; + return x*x + y*y + z*z + w*w; +} - out[6] = 0; - out[7] = 0; - out[8] = 1; +/** + * Negates the components of a vec4 + * + * @param {vec4} out the receiving vector + * @param {vec4} a vector to negate + * @returns {vec4} out + */ +function negate(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + out[2] = -a[2]; + out[3] = -a[3]; return out; } /** - * Creates a matrix from a vector scaling - * This is equivalent to (but much faster than): - * - * mat3.identity(dest); - * mat3.scale(dest, dest, vec); + * Returns the inverse of the components of a vec4 * - * @param {mat3} out mat3 receiving operation result - * @param {vec2} v Scaling vector - * @returns {mat3} out + * @param {vec4} out the receiving vector + * @param {vec4} a vector to invert + * @returns {vec4} out */ -function fromScaling(out, v) { - out[0] = v[0]; - out[1] = 0; - out[2] = 0; - - out[3] = 0; - out[4] = v[1]; - out[5] = 0; - - out[6] = 0; - out[7] = 0; - out[8] = 1; +function inverse(out, a) { + out[0] = 1.0 / a[0]; + out[1] = 1.0 / a[1]; + out[2] = 1.0 / a[2]; + out[3] = 1.0 / a[3]; return out; } /** - * Copies the values from a mat2d into a mat3 + * Normalize a vec4 * - * @param {mat3} out the receiving matrix - * @param {mat2d} a the matrix to copy - * @returns {mat3} out - **/ -function fromMat2d(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = 0; - - out[3] = a[2]; - out[4] = a[3]; - out[5] = 0; - - out[6] = a[4]; - out[7] = a[5]; - out[8] = 1; + * @param {vec4} out the receiving vector + * @param {vec4} a vector to normalize + * @returns {vec4} out + */ +function normalize(out, a) { + let x = a[0]; + let y = a[1]; + let z = a[2]; + let w = a[3]; + let len = x*x + y*y + z*z + w*w; + if (len > 0) { + len = 1 / Math.sqrt(len); + out[0] = x * len; + out[1] = y * len; + out[2] = z * len; + out[3] = w * len; + } return out; } /** -* Calculates a 3x3 matrix from the given quaternion -* -* @param {mat3} out mat3 receiving operation result -* @param {quat} q Quaternion to create matrix from -* -* @returns {mat3} out -*/ -function fromQuat(out, q) { - let x = q[0], y = q[1], z = q[2], w = q[3]; - let x2 = x + x; - let y2 = y + y; - let z2 = z + z; - - let xx = x * x2; - let yx = y * x2; - let yy = y * y2; - let zx = z * x2; - let zy = z * y2; - let zz = z * z2; - let wx = w * x2; - let wy = w * y2; - let wz = w * z2; - - out[0] = 1 - yy - zz; - out[3] = yx - wz; - out[6] = zx + wy; - - out[1] = yx + wz; - out[4] = 1 - xx - zz; - out[7] = zy - wx; - - out[2] = zx - wy; - out[5] = zy + wx; - out[8] = 1 - xx - yy; + * Calculates the dot product of two vec4's + * + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @returns {Number} dot product of a and b + */ +function dot(a, b) { + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; +} +/** + * Performs a linear interpolation between two vec4's + * + * @param {vec4} out the receiving vector + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @param {Number} t interpolation amount between the two inputs + * @returns {vec4} out + */ +function lerp(out, a, b, t) { + let ax = a[0]; + let ay = a[1]; + let az = a[2]; + let aw = a[3]; + out[0] = ax + t * (b[0] - ax); + out[1] = ay + t * (b[1] - ay); + out[2] = az + t * (b[2] - az); + out[3] = aw + t * (b[3] - aw); return out; } /** -* Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix -* -* @param {mat3} out mat3 receiving operation result -* @param {mat4} a Mat4 to derive the normal matrix from -* -* @returns {mat3} out -*/ -function normalFromMat4(out, a) { - let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - - let b00 = a00 * a11 - a01 * a10; - let b01 = a00 * a12 - a02 * a10; - let b02 = a00 * a13 - a03 * a10; - let b03 = a01 * a12 - a02 * a11; - let b04 = a01 * a13 - a03 * a11; - let b05 = a02 * a13 - a03 * a12; - let b06 = a20 * a31 - a21 * a30; - let b07 = a20 * a32 - a22 * a30; - let b08 = a20 * a33 - a23 * a30; - let b09 = a21 * a32 - a22 * a31; - let b10 = a21 * a33 - a23 * a31; - let b11 = a22 * a33 - a23 * a32; - - // Calculate the determinant - let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - - if (!det) { - return null; - } - det = 1.0 / det; - - out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; - out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; - out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; - - out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; - out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; - out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; - - out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; - out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; - - return out; -} - -/** - * Generates a 2D projection matrix with the given bounds - * - * @param {mat3} out mat3 frustum matrix will be written into - * @param {number} width Width of your gl context - * @param {number} height Height of gl context - * @returns {mat3} out - */ -function projection(out, width, height) { - out[0] = 2 / width; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = -2 / height; - out[5] = 0; - out[6] = -1; - out[7] = 1; - out[8] = 1; - return out; -} - -/** - * Returns a string representation of a mat3 + * Generates a random vector with the given scale * - * @param {mat3} a matrix to represent as a string - * @returns {String} string representation of the matrix + * @param {vec4} out the receiving vector + * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned + * @returns {vec4} out */ -function str(a) { - return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + - a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + - a[6] + ', ' + a[7] + ', ' + a[8] + ')'; -} +function random(out, vectorScale) { + vectorScale = vectorScale || 1.0; -/** - * Returns Frobenius norm of a mat3 - * - * @param {mat3} a the matrix to calculate Frobenius norm of - * @returns {Number} Frobenius norm - */ -function frob(a) { - return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2))) + //TODO: This is a pretty awful way of doing this. Find something better. + out[0] = __WEBPACK_IMPORTED_MODULE_0__common__["RANDOM"](); + out[1] = __WEBPACK_IMPORTED_MODULE_0__common__["RANDOM"](); + out[2] = __WEBPACK_IMPORTED_MODULE_0__common__["RANDOM"](); + out[3] = __WEBPACK_IMPORTED_MODULE_0__common__["RANDOM"](); + normalize(out, out); + scale(out, out, vectorScale); + return out; } /** - * Adds two mat3's + * Transforms the vec4 with a mat4. * - * @param {mat3} out the receiving matrix - * @param {mat3} a the first operand - * @param {mat3} b the second operand - * @returns {mat3} out + * @param {vec4} out the receiving vector + * @param {vec4} a the vector to transform + * @param {mat4} m matrix to transform with + * @returns {vec4} out */ -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - out[3] = a[3] + b[3]; - out[4] = a[4] + b[4]; - out[5] = a[5] + b[5]; - out[6] = a[6] + b[6]; - out[7] = a[7] + b[7]; - out[8] = a[8] + b[8]; +function transformMat4(out, a, m) { + let x = a[0], y = a[1], z = a[2], w = a[3]; + out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w; + out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w; + out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w; + out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w; return out; } /** - * Subtracts matrix b from matrix a + * Transforms the vec4 with a quat * - * @param {mat3} out the receiving matrix - * @param {mat3} a the first operand - * @param {mat3} b the second operand - * @returns {mat3} out + * @param {vec4} out the receiving vector + * @param {vec4} a the vector to transform + * @param {quat} q quaternion to transform with + * @returns {vec4} out */ -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; - out[3] = a[3] - b[3]; - out[4] = a[4] - b[4]; - out[5] = a[5] - b[5]; - out[6] = a[6] - b[6]; - out[7] = a[7] - b[7]; - out[8] = a[8] - b[8]; - return out; -} - +function transformQuat(out, a, q) { + let x = a[0], y = a[1], z = a[2]; + let qx = q[0], qy = q[1], qz = q[2], qw = q[3]; + // calculate quat * vec + let ix = qw * x + qy * z - qz * y; + let iy = qw * y + qz * x - qx * z; + let iz = qw * z + qx * y - qy * x; + let iw = -qx * x - qy * y - qz * z; -/** - * Multiply each element of the matrix by a scalar. - * - * @param {mat3} out the receiving matrix - * @param {mat3} a the matrix to scale - * @param {Number} b amount to scale the matrix's elements by - * @returns {mat3} out - */ -function multiplyScalar(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - out[3] = a[3] * b; - out[4] = a[4] * b; - out[5] = a[5] * b; - out[6] = a[6] * b; - out[7] = a[7] * b; - out[8] = a[8] * b; + // calculate result * inverse quat + out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy; + out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz; + out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx; + out[3] = a[3]; return out; } /** - * Adds two mat3's after multiplying each element of the second operand by a scalar value. + * Returns a string representation of a vector * - * @param {mat3} out the receiving vector - * @param {mat3} a the first operand - * @param {mat3} b the second operand - * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat3} out + * @param {vec4} a vector to represent as a string + * @returns {String} string representation of the vector */ -function multiplyScalarAndAdd(out, a, b, scale) { - out[0] = a[0] + (b[0] * scale); - out[1] = a[1] + (b[1] * scale); - out[2] = a[2] + (b[2] * scale); - out[3] = a[3] + (b[3] * scale); - out[4] = a[4] + (b[4] * scale); - out[5] = a[5] + (b[5] * scale); - out[6] = a[6] + (b[6] * scale); - out[7] = a[7] + (b[7] * scale); - out[8] = a[8] + (b[8] * scale); - return out; +function str(a) { + return 'vec4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')'; } /** - * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) * - * @param {mat3} a The first matrix. - * @param {mat3} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. + * @param {vec4} a The first vector. + * @param {vec4} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. */ function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && - a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && - a[6] === b[6] && a[7] === b[7] && a[8] === b[8]; + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; } /** - * Returns whether or not the matrices have approximately the same elements in the same position. + * Returns whether or not the vectors have approximately the same elements in the same position. * - * @param {mat3} a The first matrix. - * @param {mat3} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. + * @param {vec4} a The first vector. + * @param {vec4} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. */ function equals(a, b) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7], a8 = a[8]; - let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8]; + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; return (Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && - Math.abs(a3 - b3) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a3), Math.abs(b3)) && - Math.abs(a4 - b4) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a4), Math.abs(b4)) && - Math.abs(a5 - b5) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a5), Math.abs(b5)) && - Math.abs(a6 - b6) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a6), Math.abs(b6)) && - Math.abs(a7 - b7) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a7), Math.abs(b7)) && - Math.abs(a8 - b8) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a8), Math.abs(b8))); + Math.abs(a3 - b3) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a3), Math.abs(b3))); } /** - * Alias for {@link mat3.multiply} + * Alias for {@link vec4.subtract} * @function */ -const mul = multiply; -/* harmony export (immutable) */ __webpack_exports__["mul"] = mul; +const sub = subtract; +/* harmony export (immutable) */ __webpack_exports__["sub"] = sub; /** - * Alias for {@link mat3.subtract} + * Alias for {@link vec4.multiply} * @function */ -const sub = subtract; -/* harmony export (immutable) */ __webpack_exports__["sub"] = sub; - - - -/***/ }), -/* 32 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony export (immutable) */ __webpack_exports__["create"] = create; -/* harmony export (immutable) */ __webpack_exports__["clone"] = clone; -/* harmony export (immutable) */ __webpack_exports__["length"] = length; -/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues; -/* harmony export (immutable) */ __webpack_exports__["copy"] = copy; -/* harmony export (immutable) */ __webpack_exports__["set"] = set; -/* harmony export (immutable) */ __webpack_exports__["add"] = add; -/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract; -/* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply; -/* harmony export (immutable) */ __webpack_exports__["divide"] = divide; -/* harmony export (immutable) */ __webpack_exports__["ceil"] = ceil; -/* harmony export (immutable) */ __webpack_exports__["floor"] = floor; -/* harmony export (immutable) */ __webpack_exports__["min"] = min; -/* harmony export (immutable) */ __webpack_exports__["max"] = max; -/* harmony export (immutable) */ __webpack_exports__["round"] = round; -/* harmony export (immutable) */ __webpack_exports__["scale"] = scale; -/* harmony export (immutable) */ __webpack_exports__["scaleAndAdd"] = scaleAndAdd; -/* harmony export (immutable) */ __webpack_exports__["distance"] = distance; -/* harmony export (immutable) */ __webpack_exports__["squaredDistance"] = squaredDistance; -/* harmony export (immutable) */ __webpack_exports__["squaredLength"] = squaredLength; -/* harmony export (immutable) */ __webpack_exports__["negate"] = negate; -/* harmony export (immutable) */ __webpack_exports__["inverse"] = inverse; -/* harmony export (immutable) */ __webpack_exports__["normalize"] = normalize; -/* harmony export (immutable) */ __webpack_exports__["dot"] = dot; -/* harmony export (immutable) */ __webpack_exports__["cross"] = cross; -/* harmony export (immutable) */ __webpack_exports__["lerp"] = lerp; -/* harmony export (immutable) */ __webpack_exports__["hermite"] = hermite; -/* harmony export (immutable) */ __webpack_exports__["bezier"] = bezier; -/* harmony export (immutable) */ __webpack_exports__["random"] = random; -/* harmony export (immutable) */ __webpack_exports__["transformMat4"] = transformMat4; -/* harmony export (immutable) */ __webpack_exports__["transformMat3"] = transformMat3; -/* harmony export (immutable) */ __webpack_exports__["transformQuat"] = transformQuat; -/* harmony export (immutable) */ __webpack_exports__["rotateX"] = rotateX; -/* harmony export (immutable) */ __webpack_exports__["rotateY"] = rotateY; -/* harmony export (immutable) */ __webpack_exports__["rotateZ"] = rotateZ; -/* harmony export (immutable) */ __webpack_exports__["angle"] = angle; -/* harmony export (immutable) */ __webpack_exports__["str"] = str; -/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals; -/* harmony export (immutable) */ __webpack_exports__["equals"] = equals; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(5); -/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. */ - +const mul = multiply; +/* harmony export (immutable) */ __webpack_exports__["mul"] = mul; /** - * 3 Dimensional Vector - * @module vec3 + * Alias for {@link vec4.divide} + * @function */ +const div = divide; +/* harmony export (immutable) */ __webpack_exports__["div"] = div; -/** - * Creates a new, empty vec3 - * - * @returns {vec3} a new 3D vector - */ -function create() { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](3); - out[0] = 0; - out[1] = 0; - out[2] = 0; - return out; -} /** - * Creates a new vec3 initialized with values from an existing vector - * - * @param {vec3} a vector to clone - * @returns {vec3} a new 3D vector + * Alias for {@link vec4.distance} + * @function */ -function clone(a) { - var out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](3); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - return out; -} +const dist = distance; +/* harmony export (immutable) */ __webpack_exports__["dist"] = dist; -/** - * Calculates the length of a vec3 - * - * @param {vec3} a vector to calculate length of - * @returns {Number} length of a - */ -function length(a) { - let x = a[0]; - let y = a[1]; - let z = a[2]; - return Math.sqrt(x*x + y*y + z*z); -} /** - * Creates a new vec3 initialized with the given values - * - * @param {Number} x X component - * @param {Number} y Y component - * @param {Number} z Z component - * @returns {vec3} a new 3D vector + * Alias for {@link vec4.squaredDistance} + * @function */ -function fromValues(x, y, z) { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](3); - out[0] = x; - out[1] = y; - out[2] = z; - return out; -} +const sqrDist = squaredDistance; +/* harmony export (immutable) */ __webpack_exports__["sqrDist"] = sqrDist; -/** - * Copy the values from one vec3 to another - * - * @param {vec3} out the receiving vector - * @param {vec3} a the source vector - * @returns {vec3} out - */ -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - return out; -} /** - * Set the components of a vec3 to the given values - * - * @param {vec3} out the receiving vector - * @param {Number} x X component - * @param {Number} y Y component - * @param {Number} z Z component - * @returns {vec3} out + * Alias for {@link vec4.length} + * @function */ -function set(out, x, y, z) { - out[0] = x; - out[1] = y; - out[2] = z; - return out; -} +const len = length; +/* harmony export (immutable) */ __webpack_exports__["len"] = len; -/** - * Adds two vec3's - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {vec3} out - */ -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - return out; -} /** - * Subtracts vector b from vector a - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {vec3} out + * Alias for {@link vec4.squaredLength} + * @function */ -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; - return out; -} +const sqrLen = squaredLength; +/* harmony export (immutable) */ __webpack_exports__["sqrLen"] = sqrLen; -/** - * Multiplies two vec3's - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {vec3} out - */ -function multiply(out, a, b) { - out[0] = a[0] * b[0]; - out[1] = a[1] * b[1]; - out[2] = a[2] * b[2]; - return out; -} /** - * Divides two vec3's + * Perform some operation over an array of vec4s. * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {vec3} out + * @param {Array} a the array of vectors to iterate over + * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed + * @param {Number} offset Number of elements to skip at the beginning of the array + * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array + * @param {Function} fn Function to call for each vector in the array + * @param {Object} [arg] additional argument to pass to fn + * @returns {Array} a + * @function */ -function divide(out, a, b) { - out[0] = a[0] / b[0]; - out[1] = a[1] / b[1]; - out[2] = a[2] / b[2]; - return out; -} +const forEach = (function() { + let vec = create(); -/** - * Math.ceil the components of a vec3 - * - * @param {vec3} out the receiving vector - * @param {vec3} a vector to ceil - * @returns {vec3} out - */ -function ceil(out, a) { - out[0] = Math.ceil(a[0]); - out[1] = Math.ceil(a[1]); - out[2] = Math.ceil(a[2]); - return out; -} + return function(a, stride, offset, count, fn, arg) { + let i, l; + if(!stride) { + stride = 4; + } -/** - * Math.floor the components of a vec3 - * - * @param {vec3} out the receiving vector - * @param {vec3} a vector to floor - * @returns {vec3} out - */ -function floor(out, a) { - out[0] = Math.floor(a[0]); - out[1] = Math.floor(a[1]); - out[2] = Math.floor(a[2]); - return out; -} + if(!offset) { + offset = 0; + } -/** - * Returns the minimum of two vec3's - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {vec3} out - */ -function min(out, a, b) { - out[0] = Math.min(a[0], b[0]); - out[1] = Math.min(a[1], b[1]); - out[2] = Math.min(a[2], b[2]); - return out; -} + if(count) { + l = Math.min((count * stride) + offset, a.length); + } else { + l = a.length; + } -/** - * Returns the maximum of two vec3's - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {vec3} out - */ -function max(out, a, b) { - out[0] = Math.max(a[0], b[0]); - out[1] = Math.max(a[1], b[1]); - out[2] = Math.max(a[2], b[2]); - return out; -} + for(i = offset; i < l; i += stride) { + vec[0] = a[i]; vec[1] = a[i+1]; vec[2] = a[i+2]; vec[3] = a[i+3]; + fn(vec, vec, arg); + a[i] = vec[0]; a[i+1] = vec[1]; a[i+2] = vec[2]; a[i+3] = vec[3]; + } -/** - * Math.round the components of a vec3 - * - * @param {vec3} out the receiving vector - * @param {vec3} a vector to round - * @returns {vec3} out - */ -function round(out, a) { - out[0] = Math.round(a[0]); - out[1] = Math.round(a[1]); - out[2] = Math.round(a[2]); - return out; -} + return a; + }; +})(); +/* harmony export (immutable) */ __webpack_exports__["forEach"] = forEach; -/** - * Scales a vec3 by a scalar number - * - * @param {vec3} out the receiving vector - * @param {vec3} a the vector to scale - * @param {Number} b amount to scale the vector by - * @returns {vec3} out - */ -function scale(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - return out; -} -/** - * Adds two vec3's after scaling the second operand by a scalar value - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @param {Number} scale the amount to scale b by before adding - * @returns {vec3} out - */ -function scaleAndAdd(out, a, b, scale) { - out[0] = a[0] + (b[0] * scale); - out[1] = a[1] + (b[1] * scale); - out[2] = a[2] + (b[2] * scale); - return out; -} -/** - * Calculates the euclidian distance between two vec3's - * - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {Number} distance between a and b - */ -function distance(a, b) { - let x = b[0] - a[0]; - let y = b[1] - a[1]; - let z = b[2] - a[2]; - return Math.sqrt(x*x + y*y + z*z); -} +/***/ }), +/* 33 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * Calculates the squared euclidian distance between two vec3's - * - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {Number} squared distance between a and b - */ -function squaredDistance(a, b) { - let x = b[0] - a[0]; - let y = b[1] - a[1]; - let z = b[2] - a[2]; - return x*x + y*y + z*z; -} +"use strict"; -/** - * Calculates the squared length of a vec3 - * - * @param {vec3} a vector to calculate squared length of - * @returns {Number} squared length of a - */ -function squaredLength(a) { - let x = a[0]; - let y = a[1]; - let z = a[2]; - return x*x + y*y + z*z; -} -/** - * Negates the components of a vec3 - * - * @param {vec3} out the receiving vector - * @param {vec3} a vector to negate - * @returns {vec3} out - */ -function negate(out, a) { - out[0] = -a[0]; - out[1] = -a[1]; - out[2] = -a[2]; - return out; -} +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.vec3 = undefined; -/** - * Returns the inverse of the components of a vec3 - * - * @param {vec3} out the receiving vector - * @param {vec3} a vector to invert - * @returns {vec3} out - */ -function inverse(out, a) { - out[0] = 1.0 / a[0]; - out[1] = 1.0 / a[1]; - out[2] = 1.0 / a[2]; - return out; -} +var _glMatrix = __webpack_require__(7); -/** - * Normalize a vec3 - * - * @param {vec3} out the receiving vector - * @param {vec3} a vector to normalize - * @returns {vec3} out - */ -function normalize(out, a) { - let x = a[0]; - let y = a[1]; - let z = a[2]; - let len = x*x + y*y + z*z; - if (len > 0) { - //TODO: evaluate use of glm_invsqrt here? - len = 1 / Math.sqrt(len); - out[0] = a[0] * len; - out[1] = a[1] * len; - out[2] = a[2] * len; - } - return out; -} +var _num = __webpack_require__(29); -/** - * Calculates the dot product of two vec3's - * - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {Number} dot product of a and b - */ -function dot(a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; -} +exports.vec3 = _glMatrix.vec3; -/** - * Computes the cross product of two vec3's - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @returns {vec3} out +/** + * Sets a vec3 with cartesian coordinates from spherical coordinates and an optional center point + * @param {vec3} out - receiving vec3 + * @param {vec3} spherical - source vec3 with spherical coordinates (phi, theta, radius) + * @param {vec3} [center] - Optional center + * @returns {vec3} out - receiving vec3 */ -function cross(out, a, b) { - let ax = a[0], ay = a[1], az = a[2]; - let bx = b[0], by = b[1], bz = b[2]; - - out[0] = ay * bz - az * by; - out[1] = az * bx - ax * bz; - out[2] = ax * by - ay * bx; - return out; -} -/** - * Performs a linear interpolation between two vec3's - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @param {Number} t interpolation amount between the two inputs - * @returns {vec3} out - */ -function lerp(out, a, b, t) { - let ax = a[0]; - let ay = a[1]; - let az = a[2]; - out[0] = ax + t * (b[0] - ax); - out[1] = ay + t * (b[1] - ay); - out[2] = az + t * (b[2] - az); - return out; -} +_glMatrix.vec3.fromSpherical = function (out, spherical, center) { + var phi = spherical[0], + theta = spherical[1], + radius = spherical[2]; -/** - * Performs a hermite interpolation with two control points - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @param {vec3} c the third operand - * @param {vec3} d the fourth operand - * @param {Number} t interpolation amount between the two inputs - * @returns {vec3} out - */ -function hermite(out, a, b, c, d, t) { - let factorTimes2 = t * t; - let factor1 = factorTimes2 * (2 * t - 3) + 1; - let factor2 = factorTimes2 * (t - 2) + t; - let factor3 = factorTimes2 * (t - 1); - let factor4 = factorTimes2 * (3 - 2 * t); + out[0] = radius * Math.sin(phi) * Math.sin(theta); + out[1] = radius * Math.cos(theta); + out[2] = radius * Math.cos(phi) * Math.sin(theta); - out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; - out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; - out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; + if (center) { + out[0] += center[0]; + out[1] += center[1]; + out[2] += center[2]; + } - return out; -} + return out; +}; -/** - * Performs a bezier interpolation with two control points - * - * @param {vec3} out the receiving vector - * @param {vec3} a the first operand - * @param {vec3} b the second operand - * @param {vec3} c the third operand - * @param {vec3} d the fourth operand - * @param {Number} t interpolation amount between the two inputs - * @returns {vec3} out +/** + * Gets spherical coordinates from a vector + * @param {vec3} out + * @param {vec3} a + * @returns {vec3} out */ -function bezier(out, a, b, c, d, t) { - let inverseFactor = 1 - t; - let inverseFactorTimesTwo = inverseFactor * inverseFactor; - let factorTimes2 = t * t; - let factor1 = inverseFactorTimesTwo * inverseFactor; - let factor2 = 3 * t * inverseFactorTimesTwo; - let factor3 = 3 * factorTimes2 * inverseFactor; - let factor4 = factorTimes2 * t; +_glMatrix.vec3.getSpherical = function (out, a) { + var phi = 0, + theta = 0, + radius = _glMatrix.vec3.length(a); - out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; - out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; - out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; + if (radius !== 0) { + phi = Math.acos(Math.max(a[1] / radius, Math.min(-1, 1))); + theta = Math.atan2(a[0], a[2]); + } - return out; -} + out[0] = phi; + out[1] = theta; + out[2] = radius; + return out; +}; -/** - * Generates a random vector with the given scale - * - * @param {vec3} out the receiving vector - * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned - * @returns {vec3} out +/** + * Exponential decay + * + * @param {vec3} out + * @param {vec3} omega0 + * @param {vec3} torque + * @param {number} I + * @param {number} drag + * @param {number} time + * @returns {vec3} out */ -function random(out, scale) { - scale = scale || 1.0; +_glMatrix.vec3.exponentialDecay = function (out, omega0, torque, I, drag, time) { + out[0] = _num.num.exponentialDecay(omega0[0], torque[0], I, drag, time); + out[1] = _num.num.exponentialDecay(omega0[1], torque[1], I, drag, time); + out[2] = _num.num.exponentialDecay(omega0[2], torque[2], I, drag, time); + return out; +}; - let r = __WEBPACK_IMPORTED_MODULE_0__common__["RANDOM"]() * 2.0 * Math.PI; - let z = (__WEBPACK_IMPORTED_MODULE_0__common__["RANDOM"]() * 2.0) - 1.0; - let zScale = Math.sqrt(1.0-z*z) * scale; +/** + * Projects a local vec3 to screen space with viewport settings + * @param {vec3} out - receiving vec3 + * @param {vec3} a - local vec3 + * @param {mat4} m - model view projection matrix + * @param {vec4} viewport - view port settings (x, y, width, height) + * @returns {vec3} out - receiving vec3 (x, y, perspectiveDivide) + */ +_glMatrix.vec3.project = function (out, a, m, viewport) { + var x = a[0], + y = a[1], + z = a[2]; - out[0] = Math.cos(r) * zScale; - out[1] = Math.sin(r) * zScale; - out[2] = z * scale; - return out; -} + var outX = m[0] * x + m[4] * y + m[8] * z + m[12], + outY = m[1] * x + m[5] * y + m[9] * z + m[13], + perD = m[3] * x + m[7] * y + m[11] * z + m[15]; -/** - * Transforms the vec3 with a mat4. - * 4th vector component is implicitly '1' - * - * @param {vec3} out the receiving vector - * @param {vec3} a the vector to transform - * @param {mat4} m matrix to transform with - * @returns {vec3} out - */ -function transformMat4(out, a, m) { - let x = a[0], y = a[1], z = a[2]; - let w = m[3] * x + m[7] * y + m[11] * z + m[15]; - w = w || 1.0; - out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w; - out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w; - out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w; - return out; -} + var projectionX = (outX / perD + 1) / 2; + var projectionY = 1 - (outY / perD + 1) / 2; -/** - * Transforms the vec3 with a mat3. - * - * @param {vec3} out the receiving vector - * @param {vec3} a the vector to transform - * @param {mat3} m the 3x3 matrix to transform with - * @returns {vec3} out - */ -function transformMat3(out, a, m) { - let x = a[0], y = a[1], z = a[2]; - out[0] = x * m[0] + y * m[3] + z * m[6]; - out[1] = x * m[1] + y * m[4] + z * m[7]; - out[2] = x * m[2] + y * m[5] + z * m[8]; - return out; -} + out[0] = projectionX * viewport[2] + viewport[0]; + out[1] = projectionY * viewport[3] + viewport[1]; + out[2] = perD; + return out; +}; -/** - * Transforms the vec3 with a quat - * - * @param {vec3} out the receiving vector - * @param {vec3} a the vector to transform - * @param {quat} q quaternion to transform with - * @returns {vec3} out +/** + * Unprojects a vec3 with canvas coordinates to world space + * @param {vec3} out - receiving vec3 + * @param {vec3} a - vec3 to unproject + * @param {mat4} invViewProj - inverse view projection matrix + * @param {vec4|Array} viewport - [ x, y, width, height ] + * @returns {vec3} out + * @throw On perspective divide error */ -function transformQuat(out, a, q) { - // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations +_glMatrix.vec3.unproject = function () { + var vec4_0 = void 0; - let x = a[0], y = a[1], z = a[2]; - let qx = q[0], qy = q[1], qz = q[2], qw = q[3]; + return function unProject(out, a, invViewProj, viewport) { + if (!vec4_0) vec4_0 = _glMatrix.vec4.create(); - // calculate quat * vec - let ix = qw * x + qy * z - qz * y; - let iy = qw * y + qz * x - qx * z; - let iz = qw * z + qx * y - qy * x; - let iw = -qx * x - qy * y - qz * z; + var x = a[0], + y = a[1], + z = a[2]; - // calculate result * inverse quat - out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy; - out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz; - out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx; - return out; -} + vec4_0[0] = (x - viewport[0]) * 2.0 / viewport[2] - 1.0; + vec4_0[1] = (y - viewport[1]) * 2.0 / viewport[3] - 1.0; + vec4_0[2] = 2.0 * z - 1.0; + vec4_0[3] = 1.0; -/** - * Rotate a 3D vector around the x-axis - * @param {vec3} out The receiving vec3 - * @param {vec3} a The vec3 point to rotate - * @param {vec3} b The origin of the rotation - * @param {Number} c The angle of rotation - * @returns {vec3} out - */ -function rotateX(out, a, b, c){ - let p = [], r=[]; - //Translate point to the origin - p[0] = a[0] - b[0]; - p[1] = a[1] - b[1]; - p[2] = a[2] - b[2]; + _glMatrix.vec4.transformMat4(vec4_0, vec4_0, invViewProj); - //perform rotation - r[0] = p[0]; - r[1] = p[1]*Math.cos(c) - p[2]*Math.sin(c); - r[2] = p[1]*Math.sin(c) + p[2]*Math.cos(c); + if (vec4_0[3] === 0.0) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + throw new Error('Perspective divide error'); + } - //translate to correct position - out[0] = r[0] + b[0]; - out[1] = r[1] + b[1]; - out[2] = r[2] + b[2]; + out[0] = vec4_0[0] / vec4_0[3]; + out[1] = vec4_0[1] / vec4_0[3]; + out[2] = vec4_0[2] / vec4_0[3]; + return out; + }; +}(); - return out; -} +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * Rotate a 3D vector around the y-axis - * @param {vec3} out The receiving vec3 - * @param {vec3} a The vec3 point to rotate - * @param {vec3} b The origin of the rotation - * @param {Number} c The angle of rotation - * @returns {vec3} out - */ -function rotateY(out, a, b, c){ - let p = [], r=[]; - //Translate point to the origin - p[0] = a[0] - b[0]; - p[1] = a[1] - b[1]; - p[2] = a[2] - b[2]; +"use strict"; - //perform rotation - r[0] = p[2]*Math.sin(c) + p[0]*Math.cos(c); - r[1] = p[1]; - r[2] = p[2]*Math.cos(c) - p[0]*Math.sin(c); - //translate to correct position - out[0] = r[0] + b[0]; - out[1] = r[1] + b[1]; - out[2] = r[2] + b[2]; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.vec4 = undefined; - return out; -} +var _glMatrix = __webpack_require__(7); -/** - * Rotate a 3D vector around the z-axis - * @param {vec3} out The receiving vec3 - * @param {vec3} a The vec3 point to rotate - * @param {vec3} b The origin of the rotation - * @param {Number} c The angle of rotation - * @returns {vec3} out - */ -function rotateZ(out, a, b, c){ - let p = [], r=[]; - //Translate point to the origin - p[0] = a[0] - b[0]; - p[1] = a[1] - b[1]; - p[2] = a[2] - b[2]; +exports.vec4 = _glMatrix.vec4; - //perform rotation - r[0] = p[0]*Math.cos(c) - p[1]*Math.sin(c); - r[1] = p[0]*Math.sin(c) + p[1]*Math.cos(c); - r[2] = p[2]; +/***/ }), +/* 35 */ +/***/ (function(module, exports, __webpack_require__) { - //translate to correct position - out[0] = r[0] + b[0]; - out[1] = r[1] + b[1]; - out[2] = r[2] + b[2]; +"use strict"; - return out; -} -/** - * Get the angle between two 3D vectors - * @param {vec3} a The first operand - * @param {vec3} b The second operand - * @returns {Number} The angle in radians - */ -function angle(a, b) { - let tempA = fromValues(a[0], a[1], a[2]); - let tempB = fromValues(b[0], b[1], b[2]); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.addToArray = addToArray; +exports.perArrayChild = perArrayChild; +exports.removeFromArray = removeFromArray; +exports.toArray = toArray; +exports.toUniqueArray = toUniqueArray; - normalize(tempA, tempA); - normalize(tempB, tempB); +var _type = __webpack_require__(20); - let cosine = dot(tempA, tempB); +/** + * Adds arguments to an array if they don't already exist in it + * @param {Array} arr + * @param args + * @returns {boolean} true if something was added + */ +function addToArray(arr) { + var added = false; - if(cosine > 1.0) { - return 0; - } - else if(cosine < -1.0) { - return Math.PI; - } else { - return Math.acos(cosine); - } + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + for (var i = 0; i < args.length; i++) { + if (arr.indexOf(args[i]) === -1) { + arr.push(args[i]); + added = true; + } + } + return added; } -/** - * Returns a string representation of a vector - * - * @param {vec3} a vector to represent as a string - * @returns {String} string representation of the vector +/** + * Calls a function with arguments for each child in an array where that function exists + * @param {Array} arr + * @param {string} func + * @param args */ -function str(a) { - return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')'; +function perArrayChild(arr, func) { + var len = arr.length; + + for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { + args[_key2 - 2] = arguments[_key2]; + } + + for (var i = 0; i < len; i++) { + var _arr$i; + + if (func in arr) (_arr$i = arr[i])[func].apply(_arr$i, args); + } } -/** - * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) - * - * @param {vec3} a The first vector. - * @param {vec3} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. +/** + * Removes arguments from an array if they exist in it + * @param {Array} arr + * @param args + * @returns {boolean} true if something was removed */ -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2]; +function removeFromArray(arr) { + var removed = false; + + for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { + args[_key3 - 1] = arguments[_key3]; + } + + for (var i = 0; i < args.length; i++) { + var index = arr.indexOf(args[i]); + if (index !== -1) { + arr.splice(index, 1); + removed = true; + } + } + return removed; } -/** - * Returns whether or not the vectors have approximately the same elements in the same position. - * - * @param {vec3} a The first vector. - * @param {vec3} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. +/** + * Returns a value if it is an array, or a new array with the object in it + * @param {*} a + * @returns {Array} */ -function equals(a, b) { - let a0 = a[0], a1 = a[1], a2 = a[2]; - let b0 = b[0], b1 = b[1], b2 = b[2]; - return (Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && - Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && - Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a2), Math.abs(b2))); +function toArray(a) { + return (0, _type.isArray)(a) ? a : [a]; } -/** - * Alias for {@link vec3.subtract} - * @function +/** + * Returns an array containing only unique numbers + * @param {*} a + * @returns {Array} */ -const sub = subtract; -/* harmony export (immutable) */ __webpack_exports__["sub"] = sub; +function toUniqueArray(a) { + return Array.from(new Set(toArray(a))); +} +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * Alias for {@link vec3.multiply} - * @function - */ -const mul = multiply; -/* harmony export (immutable) */ __webpack_exports__["mul"] = mul; +"use strict"; -/** - * Alias for {@link vec3.divide} - * @function - */ -const div = divide; -/* harmony export (immutable) */ __webpack_exports__["div"] = div; +Object.defineProperty(exports, "__esModule", { + value: true +}); +var _Tw2EventEmitter = __webpack_require__(83); -/** - * Alias for {@link vec3.distance} - * @function - */ -const dist = distance; -/* harmony export (immutable) */ __webpack_exports__["dist"] = dist; +Object.keys(_Tw2EventEmitter).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2EventEmitter[key]; + } + }); +}); +var _Tw2Error = __webpack_require__(84); -/** - * Alias for {@link vec3.squaredDistance} - * @function - */ -const sqrDist = squaredDistance; -/* harmony export (immutable) */ __webpack_exports__["sqrDist"] = sqrDist; +Object.keys(_Tw2Error).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2Error[key]; + } + }); +}); +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * Alias for {@link vec3.length} - * @function - */ -const len = length; -/* harmony export (immutable) */ __webpack_exports__["len"] = len; +"use strict"; -/** - * Alias for {@link vec3.squaredLength} - * @function - */ -const sqrLen = squaredLength; -/* harmony export (immutable) */ __webpack_exports__["sqrLen"] = sqrLen; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.resMan = exports.Tw2ResMan = undefined; +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -/** - * Perform some operation over an array of vec3s. - * - * @param {Array} a the array of vectors to iterate over - * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed - * @param {Number} offset Number of elements to skip at the beginning of the array - * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array - * @param {Function} fn Function to call for each vector in the array - * @param {Object} [arg] additional argument to pass to fn - * @returns {Array} a - * @function - */ -const forEach = (function() { - let vec = create(); +var _Tw2Logger = __webpack_require__(17); - return function(a, stride, offset, count, fn, arg) { - let i, l; - if(!stride) { - stride = 3; - } +var _Tw2Store = __webpack_require__(19); - if(!offset) { - offset = 0; - } +var _Tw2MotherLode = __webpack_require__(85); - if(count) { - l = Math.min((count * stride) + offset, a.length); - } else { - l = a.length; - } +var _Tw2LoadingObject = __webpack_require__(38); - for(i = offset; i < l; i += stride) { - vec[0] = a[i]; vec[1] = a[i+1]; vec[2] = a[i+2]; - fn(vec, vec, arg); - a[i] = vec[0]; a[i+1] = vec[1]; a[i+2] = vec[2]; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * Resource Manager + * + * @property {Boolean} systemMirror - Toggles whether {@link Tw2GeometryRes} Index and Buffer data arrays are visible + * @property {Tw2MotherLode} motherLode + * @property {Number} maxPrepareTime + * @property {Number} prepareBudget + * @property {Boolean} autoPurgeResources=true - Sets whether resources should be purged automatically + * @property {Number} purgeTime=30 = Sets how long resources can remain inactive before they are purged + * @property {Number} activeFrame + * @property {Array} _prepareQueue + * @property {Number} _purgeTime + * @property {Number} _purgeFrame + * @property {Number} _purgeFrameLimit + * @property {Number} _pendingLoads - a count of how many things are pending load + * @property {Number} _noLoadFrames + * @class + */ +var Tw2ResMan = exports.Tw2ResMan = function () { + function Tw2ResMan() { + _classCallCheck(this, Tw2ResMan); + + this.motherLode = new _Tw2MotherLode.Tw2MotherLode(); + this.systemMirror = false; + this.maxPrepareTime = 0.05; + this.prepareBudget = 0; + this.autoPurgeResources = true; + this.activeFrame = 0; + this.purgeTime = 30; + this._prepareQueue = []; + this._purgeTime = 0; + this._purgeFrame = 0; + this._purgeFrameLimit = 1000; + this._pendingLoads = 0; + this._noLoadFrames = 0; } - return a; - }; -})(); -/* harmony export (immutable) */ __webpack_exports__["forEach"] = forEach; + /** + * IsLoading + * @returns {Boolean} + * + */ + _createClass(Tw2ResMan, [{ + key: 'IsLoading', + value: function IsLoading() { + return this._noLoadFrames < 2; + } -/***/ }), -/* 33 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + /** + * Clears the motherLode {@link Tw2MotherLode} + */ -"use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony export (immutable) */ __webpack_exports__["create"] = create; -/* harmony export (immutable) */ __webpack_exports__["clone"] = clone; -/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues; -/* harmony export (immutable) */ __webpack_exports__["copy"] = copy; -/* harmony export (immutable) */ __webpack_exports__["set"] = set; -/* harmony export (immutable) */ __webpack_exports__["add"] = add; -/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract; -/* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply; -/* harmony export (immutable) */ __webpack_exports__["divide"] = divide; -/* harmony export (immutable) */ __webpack_exports__["ceil"] = ceil; -/* harmony export (immutable) */ __webpack_exports__["floor"] = floor; -/* harmony export (immutable) */ __webpack_exports__["min"] = min; -/* harmony export (immutable) */ __webpack_exports__["max"] = max; -/* harmony export (immutable) */ __webpack_exports__["round"] = round; -/* harmony export (immutable) */ __webpack_exports__["scale"] = scale; -/* harmony export (immutable) */ __webpack_exports__["scaleAndAdd"] = scaleAndAdd; -/* harmony export (immutable) */ __webpack_exports__["distance"] = distance; -/* harmony export (immutable) */ __webpack_exports__["squaredDistance"] = squaredDistance; -/* harmony export (immutable) */ __webpack_exports__["length"] = length; -/* harmony export (immutable) */ __webpack_exports__["squaredLength"] = squaredLength; -/* harmony export (immutable) */ __webpack_exports__["negate"] = negate; -/* harmony export (immutable) */ __webpack_exports__["inverse"] = inverse; -/* harmony export (immutable) */ __webpack_exports__["normalize"] = normalize; -/* harmony export (immutable) */ __webpack_exports__["dot"] = dot; -/* harmony export (immutable) */ __webpack_exports__["lerp"] = lerp; -/* harmony export (immutable) */ __webpack_exports__["random"] = random; -/* harmony export (immutable) */ __webpack_exports__["transformMat4"] = transformMat4; -/* harmony export (immutable) */ __webpack_exports__["transformQuat"] = transformQuat; -/* harmony export (immutable) */ __webpack_exports__["str"] = str; -/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals; -/* harmony export (immutable) */ __webpack_exports__["equals"] = equals; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(5); -/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. + }, { + key: 'Clear', + value: function Clear() { + this.motherLode.Clear(); + } -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: + /** + * Unloads and Clears the motherLode {@link Tw2MotherLode} + */ -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. + }, { + key: 'UnloadAndClear', + value: function UnloadAndClear() { + this.motherLode.UnloadAndClear(); + } -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. */ + /** + * Internal update function. It is called every frame. + * @param {Number} dt - deltaTime + * @returns {Boolean} + */ + }, { + key: 'PrepareLoop', + value: function PrepareLoop(dt) { + if (this._prepareQueue.length === 0 && this._pendingLoads === 0) { + if (this._noLoadFrames < 2) { + this._noLoadFrames++; + } + } else { + this._noLoadFrames = 0; + } + this.prepareBudget = this.maxPrepareTime; -/** - * 4 Dimensional Vector - * @module vec4 - */ + var startTime = Date.now(); + while (this._prepareQueue.length) { + var res = this._prepareQueue[0][0], + data = this._prepareQueue[0][1], + xml = this._prepareQueue[0][2]; -/** - * Creates a new, empty vec4 - * - * @returns {vec4} a new 4D vector - */ -function create() { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](4); - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 0; - return out; -} + var handlesPrepareQueue = void 0; -/** - * Creates a new vec4 initialized with values from an existing vector - * - * @param {vec4} a vector to clone - * @returns {vec4} a new 4D vector - */ -function clone(a) { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](4); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - return out; -} + try { + handlesPrepareQueue = res.Prepare(data, xml); + } catch (e) { + this._prepareQueue.shift(); + throw e; + } -/** - * Creates a new vec4 initialized with the given values - * - * @param {Number} x X component - * @param {Number} y Y component - * @param {Number} z Z component - * @param {Number} w W component - * @returns {vec4} a new 4D vector - */ -function fromValues(x, y, z, w) { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](4); - out[0] = x; - out[1] = y; - out[2] = z; - out[3] = w; - return out; -} + if (!handlesPrepareQueue) { + _Tw2Logger.logger.log('res.event', { + msg: 'Prepared ', + path: res.path, + time: (Date.now() - startTime) * 0.001, + type: 'prepared' + }); -/** - * Copy the values from one vec4 to another - * - * @param {vec4} out the receiving vector - * @param {vec4} a the source vector - * @returns {vec4} out - */ -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - return out; -} + this._prepareQueue.shift(); + } -/** - * Set the components of a vec4 to the given values - * - * @param {vec4} out the receiving vector - * @param {Number} x X component - * @param {Number} y Y component - * @param {Number} z Z component - * @param {Number} w W component - * @returns {vec4} out - */ -function set(out, x, y, z, w) { - out[0] = x; - out[1] = y; - out[2] = z; - out[3] = w; - return out; -} + this.prepareBudget -= (Date.now() - startTime) * 0.001; + if (this.prepareBudget < 0) break; + } -/** - * Adds two vec4's - * - * @param {vec4} out the receiving vector - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {vec4} out - */ -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - out[3] = a[3] + b[3]; - return out; -} + this._purgeTime += dt; -/** - * Subtracts vector b from vector a - * - * @param {vec4} out the receiving vector - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {vec4} out - */ -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; - out[3] = a[3] - b[3]; - return out; -} + if (this._purgeTime > 1) { + this.activeFrame += 1; + this._purgeTime -= Math.floor(this._purgeTime); + this._purgeFrame += 1; -/** - * Multiplies two vec4's - * - * @param {vec4} out the receiving vector - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {vec4} out - */ -function multiply(out, a, b) { - out[0] = a[0] * b[0]; - out[1] = a[1] * b[1]; - out[2] = a[2] * b[2]; - out[3] = a[3] * b[3]; - return out; -} + if (this._purgeFrame >= 5) { + if (this.autoPurgeResources) { + this.motherLode.PurgeInactive(this._purgeFrame, this._purgeFrameLimit, this.purgeTime, _Tw2Logger.logger); + } + } + } -/** - * Divides two vec4's - * - * @param {vec4} out the receiving vector - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {vec4} out - */ -function divide(out, a, b) { - out[0] = a[0] / b[0]; - out[1] = a[1] / b[1]; - out[2] = a[2] / b[2]; - out[3] = a[3] / b[3]; - return out; -} - -/** - * Math.ceil the components of a vec4 - * - * @param {vec4} out the receiving vector - * @param {vec4} a vector to ceil - * @returns {vec4} out - */ -function ceil(out, a) { - out[0] = Math.ceil(a[0]); - out[1] = Math.ceil(a[1]); - out[2] = Math.ceil(a[2]); - out[3] = Math.ceil(a[3]); - return out; -} - -/** - * Math.floor the components of a vec4 - * - * @param {vec4} out the receiving vector - * @param {vec4} a vector to floor - * @returns {vec4} out - */ -function floor(out, a) { - out[0] = Math.floor(a[0]); - out[1] = Math.floor(a[1]); - out[2] = Math.floor(a[2]); - out[3] = Math.floor(a[3]); - return out; -} - -/** - * Returns the minimum of two vec4's - * - * @param {vec4} out the receiving vector - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {vec4} out - */ -function min(out, a, b) { - out[0] = Math.min(a[0], b[0]); - out[1] = Math.min(a[1], b[1]); - out[2] = Math.min(a[2], b[2]); - out[3] = Math.min(a[3], b[3]); - return out; -} - -/** - * Returns the maximum of two vec4's - * - * @param {vec4} out the receiving vector - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {vec4} out - */ -function max(out, a, b) { - out[0] = Math.max(a[0], b[0]); - out[1] = Math.max(a[1], b[1]); - out[2] = Math.max(a[2], b[2]); - out[3] = Math.max(a[3], b[3]); - return out; -} - -/** - * Math.round the components of a vec4 - * - * @param {vec4} out the receiving vector - * @param {vec4} a vector to round - * @returns {vec4} out - */ -function round(out, a) { - out[0] = Math.round(a[0]); - out[1] = Math.round(a[1]); - out[2] = Math.round(a[2]); - out[3] = Math.round(a[3]); - return out; -} - -/** - * Scales a vec4 by a scalar number - * - * @param {vec4} out the receiving vector - * @param {vec4} a the vector to scale - * @param {Number} b amount to scale the vector by - * @returns {vec4} out - */ -function scale(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - out[3] = a[3] * b; - return out; -} - -/** - * Adds two vec4's after scaling the second operand by a scalar value - * - * @param {vec4} out the receiving vector - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @param {Number} scale the amount to scale b by before adding - * @returns {vec4} out - */ -function scaleAndAdd(out, a, b, scale) { - out[0] = a[0] + (b[0] * scale); - out[1] = a[1] + (b[1] * scale); - out[2] = a[2] + (b[2] * scale); - out[3] = a[3] + (b[3] * scale); - return out; -} - -/** - * Calculates the euclidian distance between two vec4's - * - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {Number} distance between a and b - */ -function distance(a, b) { - let x = b[0] - a[0]; - let y = b[1] - a[1]; - let z = b[2] - a[2]; - let w = b[3] - a[3]; - return Math.sqrt(x*x + y*y + z*z + w*w); -} - -/** - * Calculates the squared euclidian distance between two vec4's - * - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {Number} squared distance between a and b - */ -function squaredDistance(a, b) { - let x = b[0] - a[0]; - let y = b[1] - a[1]; - let z = b[2] - a[2]; - let w = b[3] - a[3]; - return x*x + y*y + z*z + w*w; -} - -/** - * Calculates the length of a vec4 - * - * @param {vec4} a vector to calculate length of - * @returns {Number} length of a - */ -function length(a) { - let x = a[0]; - let y = a[1]; - let z = a[2]; - let w = a[3]; - return Math.sqrt(x*x + y*y + z*z + w*w); -} - -/** - * Calculates the squared length of a vec4 - * - * @param {vec4} a vector to calculate squared length of - * @returns {Number} squared length of a - */ -function squaredLength(a) { - let x = a[0]; - let y = a[1]; - let z = a[2]; - let w = a[3]; - return x*x + y*y + z*z + w*w; -} - -/** - * Negates the components of a vec4 - * - * @param {vec4} out the receiving vector - * @param {vec4} a vector to negate - * @returns {vec4} out - */ -function negate(out, a) { - out[0] = -a[0]; - out[1] = -a[1]; - out[2] = -a[2]; - out[3] = -a[3]; - return out; -} - -/** - * Returns the inverse of the components of a vec4 - * - * @param {vec4} out the receiving vector - * @param {vec4} a vector to invert - * @returns {vec4} out - */ -function inverse(out, a) { - out[0] = 1.0 / a[0]; - out[1] = 1.0 / a[1]; - out[2] = 1.0 / a[2]; - out[3] = 1.0 / a[3]; - return out; -} - -/** - * Normalize a vec4 - * - * @param {vec4} out the receiving vector - * @param {vec4} a vector to normalize - * @returns {vec4} out - */ -function normalize(out, a) { - let x = a[0]; - let y = a[1]; - let z = a[2]; - let w = a[3]; - let len = x*x + y*y + z*z + w*w; - if (len > 0) { - len = 1 / Math.sqrt(len); - out[0] = x * len; - out[1] = y * len; - out[2] = z * len; - out[3] = w * len; - } - return out; -} - -/** - * Calculates the dot product of two vec4's - * - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @returns {Number} dot product of a and b - */ -function dot(a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; -} - -/** - * Performs a linear interpolation between two vec4's - * - * @param {vec4} out the receiving vector - * @param {vec4} a the first operand - * @param {vec4} b the second operand - * @param {Number} t interpolation amount between the two inputs - * @returns {vec4} out - */ -function lerp(out, a, b, t) { - let ax = a[0]; - let ay = a[1]; - let az = a[2]; - let aw = a[3]; - out[0] = ax + t * (b[0] - ax); - out[1] = ay + t * (b[1] - ay); - out[2] = az + t * (b[2] - az); - out[3] = aw + t * (b[3] - aw); - return out; -} - -/** - * Generates a random vector with the given scale - * - * @param {vec4} out the receiving vector - * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned - * @returns {vec4} out - */ -function random(out, vectorScale) { - vectorScale = vectorScale || 1.0; - - //TODO: This is a pretty awful way of doing this. Find something better. - out[0] = __WEBPACK_IMPORTED_MODULE_0__common__["RANDOM"](); - out[1] = __WEBPACK_IMPORTED_MODULE_0__common__["RANDOM"](); - out[2] = __WEBPACK_IMPORTED_MODULE_0__common__["RANDOM"](); - out[3] = __WEBPACK_IMPORTED_MODULE_0__common__["RANDOM"](); - normalize(out, out); - scale(out, out, vectorScale); - return out; -} - -/** - * Transforms the vec4 with a mat4. - * - * @param {vec4} out the receiving vector - * @param {vec4} a the vector to transform - * @param {mat4} m matrix to transform with - * @returns {vec4} out - */ -function transformMat4(out, a, m) { - let x = a[0], y = a[1], z = a[2], w = a[3]; - out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w; - out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w; - out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w; - out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w; - return out; -} - -/** - * Transforms the vec4 with a quat - * - * @param {vec4} out the receiving vector - * @param {vec4} a the vector to transform - * @param {quat} q quaternion to transform with - * @returns {vec4} out - */ -function transformQuat(out, a, q) { - let x = a[0], y = a[1], z = a[2]; - let qx = q[0], qy = q[1], qz = q[2], qw = q[3]; - - // calculate quat * vec - let ix = qw * x + qy * z - qz * y; - let iy = qw * y + qz * x - qx * z; - let iz = qw * z + qx * y - qy * x; - let iw = -qx * x - qy * y - qz * z; - - // calculate result * inverse quat - out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy; - out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz; - out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx; - out[3] = a[3]; - return out; -} - -/** - * Returns a string representation of a vector - * - * @param {vec4} a vector to represent as a string - * @returns {String} string representation of the vector - */ -function str(a) { - return 'vec4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')'; -} - -/** - * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) - * - * @param {vec4} a The first vector. - * @param {vec4} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. - */ -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; -} - -/** - * Returns whether or not the vectors have approximately the same elements in the same position. - * - * @param {vec4} a The first vector. - * @param {vec4} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. - */ -function equals(a, b) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - return (Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && - Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && - Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && - Math.abs(a3 - b3) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a3), Math.abs(b3))); -} - -/** - * Alias for {@link vec4.subtract} - * @function - */ -const sub = subtract; -/* harmony export (immutable) */ __webpack_exports__["sub"] = sub; - - -/** - * Alias for {@link vec4.multiply} - * @function - */ -const mul = multiply; -/* harmony export (immutable) */ __webpack_exports__["mul"] = mul; - - -/** - * Alias for {@link vec4.divide} - * @function - */ -const div = divide; -/* harmony export (immutable) */ __webpack_exports__["div"] = div; - - -/** - * Alias for {@link vec4.distance} - * @function - */ -const dist = distance; -/* harmony export (immutable) */ __webpack_exports__["dist"] = dist; - - -/** - * Alias for {@link vec4.squaredDistance} - * @function - */ -const sqrDist = squaredDistance; -/* harmony export (immutable) */ __webpack_exports__["sqrDist"] = sqrDist; - - -/** - * Alias for {@link vec4.length} - * @function - */ -const len = length; -/* harmony export (immutable) */ __webpack_exports__["len"] = len; - - -/** - * Alias for {@link vec4.squaredLength} - * @function - */ -const sqrLen = squaredLength; -/* harmony export (immutable) */ __webpack_exports__["sqrLen"] = sqrLen; - - -/** - * Perform some operation over an array of vec4s. - * - * @param {Array} a the array of vectors to iterate over - * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed - * @param {Number} offset Number of elements to skip at the beginning of the array - * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array - * @param {Function} fn Function to call for each vector in the array - * @param {Object} [arg] additional argument to pass to fn - * @returns {Array} a - * @function - */ -const forEach = (function() { - let vec = create(); - - return function(a, stride, offset, count, fn, arg) { - let i, l; - if(!stride) { - stride = 4; - } - - if(!offset) { - offset = 0; - } - - if(count) { - l = Math.min((count * stride) + offset, a.length); - } else { - l = a.length; - } - - for(i = offset; i < l; i += stride) { - vec[0] = a[i]; vec[1] = a[i+1]; vec[2] = a[i+2]; vec[3] = a[i+3]; - fn(vec, vec, arg); - a[i] = vec[0]; a[i+1] = vec[1]; a[i+2] = vec[2]; a[i+3] = vec[3]; - } - - return a; - }; -})(); -/* harmony export (immutable) */ __webpack_exports__["forEach"] = forEach; - - - -/***/ }), -/* 34 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.vec3 = undefined; - -var _glMatrix = __webpack_require__(11); - -var _num = __webpack_require__(30); - -exports.vec3 = _glMatrix.vec3; - -/** - * Sets a vec3 with cartesian coordinates from spherical coordinates and an optional center point - * @param {vec3} out - receiving vec3 - * @param {vec3} spherical - source vec3 with spherical coordinates (phi, theta, radius) - * @param {vec3} [center] - Optional center - * @returns {vec3} out - receiving vec3 - */ - -_glMatrix.vec3.fromSpherical = function (out, spherical, center) { - var phi = spherical[0], - theta = spherical[1], - radius = spherical[2]; - - out[0] = radius * Math.sin(phi) * Math.sin(theta); - out[1] = radius * Math.cos(theta); - out[2] = radius * Math.cos(phi) * Math.sin(theta); - - if (center) { - out[0] += center[0]; - out[1] += center[1]; - out[2] += center[2]; - } - - return out; -}; - -/** - * Gets spherical coordinates from a vector - * @param {vec3} out - * @param {vec3} a - * @returns {vec3} out - */ -_glMatrix.vec3.getSpherical = function (out, a) { - var phi = 0, - theta = 0, - radius = _glMatrix.vec3.length(a); - - if (radius !== 0) { - phi = Math.acos(Math.max(a[1] / radius, Math.min(-1, 1))); - theta = Math.atan2(a[0], a[2]); - } - - out[0] = phi; - out[1] = theta; - out[2] = radius; - return out; -}; - -/** - * Exponential decay - * - * @param {vec3} out - * @param {vec3} omega0 - * @param {vec3} torque - * @param {number} I - * @param {number} drag - * @param {number} time - * @returns {vec3} out - */ -_glMatrix.vec3.exponentialDecay = function (out, omega0, torque, I, drag, time) { - out[0] = _num.num.exponentialDecay(omega0[0], torque[0], I, drag, time); - out[1] = _num.num.exponentialDecay(omega0[1], torque[1], I, drag, time); - out[2] = _num.num.exponentialDecay(omega0[2], torque[2], I, drag, time); - return out; -}; - -/** - * Projects a local vec3 to screen space with viewport settings - * @param {vec3} out - receiving vec3 - * @param {vec3} a - local vec3 - * @param {mat4} m - model view projection matrix - * @param {vec4} viewport - view port settings (x, y, width, height) - * @returns {vec3} out - receiving vec3 (x, y, perspectiveDivide) - */ -_glMatrix.vec3.project = function (out, a, m, viewport) { - var x = a[0], - y = a[1], - z = a[2]; - - var outX = m[0] * x + m[4] * y + m[8] * z + m[12], - outY = m[1] * x + m[5] * y + m[9] * z + m[13], - perD = m[3] * x + m[7] * y + m[11] * z + m[15]; - - var projectionX = (outX / perD + 1) / 2; - var projectionY = 1 - (outY / perD + 1) / 2; - - out[0] = projectionX * viewport[2] + viewport[0]; - out[1] = projectionY * viewport[3] + viewport[1]; - out[2] = perD; - return out; -}; - -/** - * Unprojects a vec3 with canvas coordinates to world space - * @param {vec3} out - receiving vec3 - * @param {vec3} a - vec3 to unproject - * @param {mat4} invViewProj - inverse view projection matrix - * @param {vec4|Array} viewport - [ x, y, width, height ] - * @returns {vec3} out - * @throw On perspective divide error - */ -_glMatrix.vec3.unproject = function () { - var vec4_0 = void 0; - - return function unProject(out, a, invViewProj, viewport) { - if (!vec4_0) vec4_0 = _glMatrix.vec4.create(); - - var x = a[0], - y = a[1], - z = a[2]; - - vec4_0[0] = (x - viewport[0]) * 2.0 / viewport[2] - 1.0; - vec4_0[1] = (y - viewport[1]) * 2.0 / viewport[3] - 1.0; - vec4_0[2] = 2.0 * z - 1.0; - vec4_0[3] = 1.0; - - _glMatrix.vec4.transformMat4(vec4_0, vec4_0, invViewProj); - - if (vec4_0[3] === 0.0) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - throw new Error('Perspective divide error'); + return true; } - out[0] = vec4_0[0] / vec4_0[3]; - out[1] = vec4_0[1] / vec4_0[3]; - out[2] = vec4_0[2] / vec4_0[3]; - return out; - }; -}(); - -/***/ }), -/* 35 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.vec4 = undefined; - -var _glMatrix = __webpack_require__(11); - -exports.vec4 = _glMatrix.vec4; - -/***/ }), -/* 36 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; + /** + * Gets a resource + * @param {String} path + * @returns {Tw2Resource} resource + */ + }, { + key: 'GetResource', + value: function GetResource(path) { + var res = void 0; + path = Tw2ResMan.NormalizePath(path); -Object.defineProperty(exports, "__esModule", { - value: true -}); + // Check if already loaded + res = this.motherLode.Find(path); + if (res) { + if (res.IsPurged()) res.Reload(); + return res; + } -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + var ext = Tw2ResMan.GetPathExt(path); + if (ext === null) { + _Tw2Logger.logger.log('res.error', { + log: 'error', + src: ['Tw2ResMan', 'ReloadResource'], + msg: 'Undefined extension', + type: 'extension.undefined', + path: path + }); + return null; + } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + var Extension = _Tw2Store.store.GetExtension(ext); + if (!Extension) { + _Tw2Logger.logger.log('res.error', { + log: 'error', + src: ['Tw2ResMan', 'ReloadResource'], + msg: 'Unregistered extension', + type: 'extension.unregistered', + path: path, + value: ext + }); + return null; + } -/** - * Emitter privates - * @type {WeakMap} - */ -var PRIVATE = new WeakMap(); + res = new Extension(); + res.path = path; + return Tw2ResMan.LoadResource(this, res); + } -/** - * Tw2EventEmitter - * @class - */ + /** + * Gets a resource object + * @param {string} path + * @param {Function} callback + */ -var Tw2EventEmitter = exports.Tw2EventEmitter = function () { - function Tw2EventEmitter() { - _classCallCheck(this, Tw2EventEmitter); + }, { + key: 'GetObject', + value: function GetObject(path, callback) { + var obj = {}; + path = Tw2ResMan.NormalizePath(path); - PRIVATE.set(this, { events: {} }); - } + // Check if already loaded + var res = this.motherLode.Find(path); + if (res) { + res.AddObject(obj, callback); + return; + } - /** - * Emits an event - * @param {string} eventName - * @param {*} [e={}] - * @returns {Tw2EventEmitter} - * @emit event_added { eventName: string} - the first time an event is emitted - */ + res = new _Tw2LoadingObject.Tw2LoadingObject(); + res.path = path; + res.AddObject(obj, callback); + Tw2ResMan.LoadResource(this, res); + } + /** + * Reloads a resource + * @param {Tw2Resource} resource + * @returns {Tw2Resource} resource + */ - _createClass(Tw2EventEmitter, [{ - key: 'emit', - value: function emit(eventName, e) { - eventName = eventName.toLowerCase(); + }, { + key: 'ReloadResource', + value: function ReloadResource(resource) { + var path = resource.path; - // Short cut to creating a log output - if (e && e['__log']) { - e.log = this.log(eventName, e['__log']); - delete e['__log']; - } + // Check if already loaded and good + var res = this.motherLode.Find(path); + if (res && !res.IsPurged()) return res; - var events = PRIVATE.get(this).events; - if (eventName in events) { - events[eventName].forEach(function (value, key) { - key.call(value.context, e); - if (value.once) events[eventName].delete(key); - }); - } else { - events[eventName] = new Set(); - this.emit('event_added', { eventName: eventName }); - } + _Tw2Logger.logger.log('res.event', { + msg: 'Reloading ', + path: path, + type: 'reload' + }); - return this; + return Tw2ResMan.LoadResource(this, resource); } /** - * Adds a listener to an event - * @param {Array|string} eventName - * @param {Function} listener - * @param {*} [context=undefined] - * @param {boolean} [once=false] - * @returns {Tw2EventEmitter} + * Builds a url from a resource path + * @param {string} resPath + * @returns {string} */ - }, { - key: 'on', - value: function on(eventName, listener) { - var _this = this; + }], [{ + key: 'BuildUrl', + value: function BuildUrl(resPath) { + var prefixIndex = resPath.indexOf(':/'); + if (prefixIndex === -1) { + _Tw2Logger.logger.log('res.error', { + log: 'warn', + src: ['Tw2ResMan', 'BuildUrl'], + msg: 'Invalid path', + type: 'prefix.undefined', + path: resPath + }); + return resPath; + } - var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; - var once = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + var prefix = resPath.substr(0, prefixIndex), + path = _Tw2Store.store.GetPath(prefix); - var events = PRIVATE.get(this).events; - eventName = eventName.toLowerCase(); - if (!events[eventName]) { - events[eventName] = new Set(); - events[eventName].add(function () { - return _this.emit('event_added', { eventName: eventName }); - }, { once: true }); + if (!path) { + _Tw2Logger.logger.log('res.error', { + log: 'warn', + src: ['Tw2ResMan', 'BuildUrl'], + msg: 'Unregistered path', + path: resPath, + type: 'prefix.unregistered', + value: prefix + }); + return resPath; } - events[eventName].add(listener, { context: context, once: once }); - return this; + + return path + resPath.substr(prefixIndex + 2); } /** - * Adds a listener to an event, and clears it after it's first emit - * @param {string} eventName - * @param {Function} listener - * @param {*} [context] - * @returns {Tw2EventEmitter} + * Normalizes a file path by making it lower case and replaces all '\\' with '/' + * @param {string} path + * @returns {string} */ }, { - key: 'once', - value: function once(eventName, listener, context) { - return this.on(eventName, listener, context, true); + key: 'NormalizePath', + value: function NormalizePath(path) { + if (path.substr(0, 5) === 'str:/') return path; + path = path.toLowerCase(); + path.replace('\\', '/'); + return path; } /** - * Removes a listener from a specific event or from all by passing '*' as the eventName - * @param {string} eventName - * @param {Function} listener - * @returns {Tw2EventEmitter} + * Gets a path's extension + * @param {string} path + * @returns {?string} */ }, { - key: 'off', - value: function off(eventName, listener) { - var events = PRIVATE.get(this).events; - eventName = eventName.toLowerCase(); - if (eventName in events) events[eventName].delete(listener); - return this; + key: 'GetPathExt', + value: function GetPathExt(path) { + if (path.substr(0, 5) === 'str:/') { + var slash = path.indexOf('/', 5); + if (slash === -1) return null; + return path.substr(5, slash - 5); + } else { + var dot = path.lastIndexOf('.'); + if (dot === -1) return null; + return path.substr(dot + 1); + } } /** - * Deletes an event and it's listeners - * @param {string} eventName - * @returns {Tw2EventEmitter} - * @emit event_removed { eventName: String } + * Returns a path suitable for logging by truncating really long file names + * @param {string} path + * @returns {string} */ }, { - key: 'del', - value: function del(eventName) { - var events = PRIVATE.get(this).events; - eventName = eventName.toLowerCase(); - if (eventName in events) { - this.emit('event_removed', { eventName: eventName }); - delete events[eventName]; + key: 'LogPathString', + value: function LogPathString(path) { + if (path.substr(0, 5) === 'str:/' && path.length > 64) { + return path.substr(0, 64) + '...'; } - return this; + return path; } /** - * Clears a listener from all events - * @param {Function} listener - * @returns {Tw2EventEmitter} + * Loads a resource + * @param {Tw2ResMan} resMan + * @param {Tw2Resource} res + * @returns {Tw2Resource} */ }, { - key: 'clr', - value: function clr(listener) { - var events = PRIVATE.get(this).events; - for (var eventName in events) { - if (events.hasOwnProperty(eventName) && events[eventName].has(listener)) { - events[eventName].delete(listener); + key: 'LoadResource', + value: function LoadResource(resMan, res) { + var path = res.path, + url = Tw2ResMan.BuildUrl(path); + + res._isPurged = false; + resMan.motherLode.Add(path, res); + if (res.DoCustomLoad && res.DoCustomLoad(url)) return res; + + var httpRequest = Tw2ResMan.CreateHttpRequest(res.requestResponseType); + if (httpRequest) { + _Tw2Logger.logger.log('res.event', { + msg: 'Requesting', + path: path, + type: 'request' + }); + + httpRequest.onreadystatechange = Tw2ResMan.DoLoadResource(resMan, res); + httpRequest.open('GET', url); + res.LoadStarted(); + + try { + httpRequest.send(); + resMan._pendingLoads++; + } catch (e) { + _Tw2Logger.logger.log('res.error', { + log: 'error', + src: ['Tw2ResMan', 'LoadResource'], + msg: 'Error sending object HTTP request', + path: path, + type: 'http.request', + err: e + }); } } - return this; + return res; } /** - * Kills all events and listeners from the emitter - * @returns {Tw2EventEmitter} - * @emit event_kill + * Creates an onreadystatechange callback + * @param {Tw2ResMan} resMan + * @param {Tw2Resource} res */ }, { - key: 'kill', - value: function kill() { - this.emit('event_kill'); - PRIVATE.get(this).events = {}; - return this; + key: 'DoLoadResource', + value: function DoLoadResource(resMan, res) { + return function () { + var readyState = 0; + + try { + readyState = this.readyState; + } catch (e) { + _Tw2Logger.logger.log('res.error', { + log: 'error', + src: ['Tw2ResMan', '_DoLoadResource'], + msg: 'Communication error loading', + path: res.path, + type: 'http.readystate', + value: readyState + }); + + res.LoadFinished(false); + resMan._pendingLoads--; + return; + } + + if (readyState === 4) { + if (this.status === 200) { + var data = null, + xml = null; + + try { + data = this.responseText; + xml = this.responseXML; + } catch (e) { + data = this.response; + } + + res.LoadFinished(true); + resMan._prepareQueue.push([res, data, xml]); + } else { + _Tw2Logger.logger.log('res.error', { + log: 'error', + src: ['Tw2ResMan', '_DoLoadResource'], + msg: 'Communication error loading', + path: res.path, + type: 'http.status', + value: this.status + }); + res.LoadFinished(false); + res.PrepareFinished(false); + } + resMan._pendingLoads--; + } + }; } /** - * Logs an event log - * @param {string} eventName - * @param {eventLog} eventLog - * @returns {eventLog} + * Creates an HTTP request + * @param {?string} [responseType] + * @returns {XMLHttpRequest|ActiveXObject} */ }, { - key: 'log', - value: function log(eventName, eventLog) { - if (this.constructor.logger) { - this.constructor.logger.log(eventName, eventLog); + key: 'CreateHttpRequest', + value: function CreateHttpRequest(responseType) { + var httpRequest = null; + + if (window.XMLHttpRequest) { + // Mozilla, Safari, ... + httpRequest = new XMLHttpRequest(); + } else if (window.ActiveXObject) { + // IE + try { + httpRequest = new window['ActiveXObject']('Msxml2.XMLHTTP'); + } catch (e) { + try { + httpRequest = new window['ActiveXObject']('Microsoft.XMLHTTP'); + } catch (e) { + /*eslint-disable-line-no-empty*/ + } + } } - return eventLog; + + if (!httpRequest) { + _Tw2Logger.logger.log('res.error', { + log: 'error', + src: ['Tw2LoadingObject', 'Prepare'], + msg: 'Could not create an XMLHTTP instance', + type: 'http.instance' + }); + } else if (responseType) { + httpRequest.responseType = responseType; + } + + return httpRequest; } }]); - return Tw2EventEmitter; + return Tw2ResMan; }(); -/** - * Global logger - * @type {*} - */ +// Global instance of Tw2ResMan -Tw2EventEmitter.logger = null; +var resMan = exports.resMan = new Tw2ResMan(); /***/ }), -/* 37 */ +/* 38 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8539,13 +7393,11 @@ exports.Tw2LoadingObject = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2ResMan = __webpack_require__(6); - -var _Tw2Logger = __webpack_require__(4); +var _global = __webpack_require__(0); -var _Tw2Resource2 = __webpack_require__(12); +var _Tw2Resource2 = __webpack_require__(8); -var _Tw2ObjectReader = __webpack_require__(38); +var _Tw2ObjectReader = __webpack_require__(39); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -8602,7 +7454,7 @@ var Tw2LoadingObject = exports.Tw2LoadingObject = function (_Tw2Resource) { key: 'Prepare', value: function Prepare(text) { if (!_Tw2ObjectReader.Tw2ObjectReader.IsValidXML(text)) { - _Tw2Logger.logger.log('res.error', { + _global.logger.log('res.error', { log: 'error', src: ['Tw2LoadingObject', 'Prepare'], msg: 'Invalid XML', @@ -8623,7 +7475,7 @@ var Tw2LoadingObject = exports.Tw2LoadingObject = function (_Tw2Resource) { try { this._objects[this._inPrepare]._loadCallback(this._constructor.Construct()); } catch (e) { - _Tw2Logger.logger.log('res.error', { + _global.logger.log('res.error', { log: 'error', src: ['Tw2LoadingObject', 'Prepare'], msg: 'Error preparing resource', @@ -8636,7 +7488,7 @@ var Tw2LoadingObject = exports.Tw2LoadingObject = function (_Tw2Resource) { this._inPrepare++; } - _Tw2ResMan.resMan.motherLode.Remove(this.path); + _global.resMan.motherLode.Remove(this.path); this.PrepareFinished(true); } }]); @@ -8653,7 +7505,7 @@ var Tw2LoadingObject = exports.Tw2LoadingObject = function (_Tw2Resource) { Tw2LoadingObject.prototype.requestResponseType = 'arraybuffer'; /***/ }), -/* 38 */ +/* 39 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8666,11 +7518,9 @@ exports.Tw2ObjectReader = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2Logger = __webpack_require__(4); +var _global = __webpack_require__(0); -var _Tw2Store = __webpack_require__(16); - -var _Tw2BinaryReader = __webpack_require__(39); +var _Tw2BinaryReader = __webpack_require__(40); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -8711,7 +7561,7 @@ var Tw2ObjectReader = exports.Tw2ObjectReader = function () { key: 'Initialize', value: function Initialize() { if (!Tw2ObjectReader.IsValidXML(this.xmlNode)) { - _Tw2Logger.logger.log('res.error', { + _global.logger.log('res.error', { log: 'error', src: ['Tw2ObjectReader', 'constructor'], msg: 'Invalid Binary', @@ -8774,9 +7624,9 @@ var Tw2ObjectReader = exports.Tw2ObjectReader = function () { var object = void 0; - var Constructor = _Tw2Store.store.GetConstructor(data.type); + var Constructor = _global.store.GetConstructor(data.type); if (!Constructor) { - _Tw2Logger.logger.log('res.error', { + _global.logger.log('res.error', { log: 'throw', src: ['Tw2ObjectReader', 'Tw2ObjectReader.ConstructObject'], msg: 'Object with undefined type', @@ -8790,7 +7640,7 @@ var Tw2ObjectReader = exports.Tw2ObjectReader = function () { try { object = new Constructor(); } catch (e) { - _Tw2Logger.logger.log('res.error', { + _global.logger.log('res.error', { log: 'throw', src: ['Tw2ObjectReader', 'Tw2ObjectReader.ConstructObject'], msg: 'Error instantiating constructor', @@ -9095,7 +7945,7 @@ Tw2ObjectReader.TypedArrays = { }; /***/ }), -/* 39 */ +/* 40 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -9256,7 +8106,7 @@ var Tw2BinaryReader = exports.Tw2BinaryReader = function () { }(); /***/ }), -/* 40 */ +/* 41 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -9269,11 +8119,9 @@ exports.Tw2Effect = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); - -var _global = __webpack_require__(17); +var _global = __webpack_require__(0); -var _Tw2TextureParameter = __webpack_require__(41); +var _Tw2TextureParameter = __webpack_require__(42); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -9296,7 +8144,7 @@ var Tw2Effect = exports.Tw2Effect = function () { function Tw2Effect() { _classCallCheck(this, Tw2Effect); - this._id = _math.util.generateID(); + this._id = _global.util.generateID(); this.name = ''; this.effectFilePath = ''; this.effectRes = null; @@ -9850,7 +8698,7 @@ var Tw2Effect = exports.Tw2Effect = function () { var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var effect = new this(); - _math.util.assignIfExists(effect, opt, ['name', 'effectFilePath', 'display', 'autoParameter']); + _global.util.assignIfExists(effect, opt, ['name', 'effectFilePath', 'display', 'autoParameter']); if ('parameters' in opt) effect.SetParameters(opt.parameters); if ('textures' in opt) effect.SetTextures(opt.textures); if ('overrides' in opt) effect.SetOverrides(opt.overrides); @@ -9877,7 +8725,7 @@ var Tw2Effect = exports.Tw2Effect = function () { Tw2Effect.ConstantIgnore = ['PerFrameVS', 'PerObjectVS', 'PerFramePS', 'PerObjectPS', 'PerObjectPSInt']; /***/ }), -/* 41 */ +/* 42 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -9892,15 +8740,11 @@ var _createClass = function () { function defineProperties(target, props) { for var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; -var _Tw2ResMan = __webpack_require__(6); - -var _Tw2Device = __webpack_require__(2); +var _global = __webpack_require__(0); var _sampler = __webpack_require__(21); -var _Tw2Parameter2 = __webpack_require__(7); - -var _math = __webpack_require__(0); +var _Tw2Parameter2 = __webpack_require__(4); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -10019,7 +8863,7 @@ var Tw2TextureParameter = exports.Tw2TextureParameter = function (_Tw2Parameter) value: function OnValueChanged(controller, properties) { if (this.resourcePath !== '') { this.resourcePath = this.resourcePath.toLowerCase(); - this.textureRes = this.resourcePath !== '' ? _Tw2ResMan.resMan.GetResource(this.resourcePath) : null; + this.textureRes = this.resourcePath !== '' ? _global.resMan.GetResource(this.resourcePath) : null; } this.UpdateOverrides(); @@ -10043,7 +8887,7 @@ var Tw2TextureParameter = exports.Tw2TextureParameter = function (_Tw2Parameter) this._sampler.registerIndex = sampler.registerIndex; sampler = this._sampler; } - _Tw2Device.device.gl.activeTexture(_Tw2Device.device.gl.TEXTURE0 + stage); + _global.device.gl.activeTexture(_global.device.gl.TEXTURE0 + stage); this.textureRes.Bind(sampler, slices); } } @@ -10058,7 +8902,7 @@ var Tw2TextureParameter = exports.Tw2TextureParameter = function (_Tw2Parameter) value: function SetOverrides() { var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - _math.util.assignIfExists(this, opt, Tw2TextureParameter.overrideProperties); + _global.util.assignIfExists(this, opt, Tw2TextureParameter.overrideProperties); this.OnValueChanged(); } @@ -10072,7 +8916,7 @@ var Tw2TextureParameter = exports.Tw2TextureParameter = function (_Tw2Parameter) value: function GetOverrides() { var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - _math.util.assignIfExists(out, this, Tw2TextureParameter.overrideProperties); + _global.util.assignIfExists(out, this, Tw2TextureParameter.overrideProperties); return out; } @@ -10090,39 +8934,39 @@ var Tw2TextureParameter = exports.Tw2TextureParameter = function (_Tw2Parameter) if (this.filterMode === 1) { switch (this.mipFilterMode) { case 0: - sampler.minFilter = _Tw2Device.device.gl.NEAREST; + sampler.minFilter = _global.device.gl.NEAREST; break; case 1: - sampler.minFilter = _Tw2Device.device.gl.NEAREST_MIPMAP_NEAREST; + sampler.minFilter = _global.device.gl.NEAREST_MIPMAP_NEAREST; break; default: - sampler.minFilter = _Tw2Device.device.gl.NEAREST_MIPMAP_LINEAR; + sampler.minFilter = _global.device.gl.NEAREST_MIPMAP_LINEAR; } - sampler.minFilterNoMips = _Tw2Device.device.gl.NEAREST; - sampler.magFilter = _Tw2Device.device.gl.NEAREST; + sampler.minFilterNoMips = _global.device.gl.NEAREST; + sampler.magFilter = _global.device.gl.NEAREST; } else { switch (this.mipFilterMode) { case 0: - sampler.minFilter = _Tw2Device.device.gl.LINEAR; + sampler.minFilter = _global.device.gl.LINEAR; break; case 1: - sampler.minFilter = _Tw2Device.device.gl.LINEAR_MIPMAP_NEAREST; + sampler.minFilter = _global.device.gl.LINEAR_MIPMAP_NEAREST; break; default: - sampler.minFilter = _Tw2Device.device.gl.LINEAR_MIPMAP_LINEAR; + sampler.minFilter = _global.device.gl.LINEAR_MIPMAP_LINEAR; } - sampler.minFilterNoMips = _Tw2Device.device.gl.LINEAR; - sampler.magFilter = _Tw2Device.device.gl.LINEAR; + sampler.minFilterNoMips = _global.device.gl.LINEAR; + sampler.magFilter = _global.device.gl.LINEAR; } - sampler.addressU = _Tw2Device.device.wrapModes[this.addressUMode]; - sampler.addressV = _Tw2Device.device.wrapModes[this.addressVMode]; - sampler.addressW = _Tw2Device.device.wrapModes[this.addressWMode]; + sampler.addressU = _global.device.wrapModes[this.addressUMode]; + sampler.addressV = _global.device.wrapModes[this.addressVMode]; + sampler.addressW = _global.device.wrapModes[this.addressWMode]; sampler.anisotropy = this.maxAnisotropy; sampler.ComputeHash(); } else if (this._sampler) { @@ -10187,8 +9031,8 @@ var Tw2TextureParameter = exports.Tw2TextureParameter = function (_Tw2Parameter) } /** - * - * @param value + * Checks if a value is a valid parameter value + * @param {*} a * @returns {boolean} */ @@ -10198,9 +9042,9 @@ var Tw2TextureParameter = exports.Tw2TextureParameter = function (_Tw2Parameter) return this.textureRes && this.textureRes._isAttached; } }], [{ - key: 'is', - value: function is(value) { - return typeof value === 'string'; + key: 'isValue', + value: function isValue(a) { + return _global.util.isString(a); } }]); @@ -10222,7 +9066,7 @@ Tw2TextureParameter.prototype.SetValue = Tw2TextureParameter.prototype.SetTextur Tw2TextureParameter.overrideProperties = ['useAllOverrides', 'addressUMode', 'addressVMode', 'addressWMode', 'filterMode', 'mipFilterMode', 'maxAnisotropy']; /***/ }), -/* 42 */ +/* 43 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -10235,7 +9079,7 @@ exports.Tw2SamplerState = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2Device = __webpack_require__(2); +var _global = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -10262,14 +9106,14 @@ var Tw2SamplerState = exports.Tw2SamplerState = function () { this.name = ''; this.registerIndex = 0; - this.minFilter = _Tw2Device.device.gl.LINEAR; - this.maxFilter = _Tw2Device.device.gl.LINEAR; - this.minFilterNoMips = _Tw2Device.device.gl.LINEAR; - this.addressU = _Tw2Device.device.gl.REPEAT; - this.addressV = _Tw2Device.device.gl.REPEAT; - this.addressW = _Tw2Device.device.gl.REPEAT; + this.minFilter = _global.device.gl.LINEAR; + this.maxFilter = _global.device.gl.LINEAR; + this.minFilterNoMips = _global.device.gl.LINEAR; + this.addressU = _global.device.gl.REPEAT; + this.addressV = _global.device.gl.REPEAT; + this.addressW = _global.device.gl.REPEAT; this.anisotropy = 1; - this.samplerType = _Tw2Device.device.gl.TEXTURE_2D; + this.samplerType = _global.device.gl.TEXTURE_2D; this.isVolume = false; this.hash = 0; } @@ -10304,7 +9148,7 @@ var Tw2SamplerState = exports.Tw2SamplerState = function () { key: 'Apply', value: function Apply(hasMipMaps) { var targetType = this.samplerType, - d = _Tw2Device.device; + d = _global.device; d.gl.texParameteri(targetType, d.gl.TEXTURE_WRAP_S, hasMipMaps ? this.addressU : d.gl.CLAMP_TO_EDGE); d.gl.texParameteri(targetType, d.gl.TEXTURE_WRAP_T, hasMipMaps ? this.addressV : d.gl.CLAMP_TO_EDGE); @@ -10364,7 +9208,7 @@ Tw2SamplerState.MipFilterMode = { }; /***/ }), -/* 43 */ +/* 44 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -10408,7 +9252,126 @@ var Tw2VertexElement = exports.Tw2VertexElement = function Tw2VertexElement(usag }; /***/ }), -/* 44 */ +/* 45 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _Tw2Parameter = __webpack_require__(4); + +Object.keys(_Tw2Parameter).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2Parameter[key]; + } + }); +}); + +var _Tw2FloatParameter = __webpack_require__(96); + +Object.keys(_Tw2FloatParameter).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2FloatParameter[key]; + } + }); +}); + +var _Tw2MatrixParameter = __webpack_require__(97); + +Object.keys(_Tw2MatrixParameter).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2MatrixParameter[key]; + } + }); +}); + +var _Tw2TransformParameter = __webpack_require__(98); + +Object.keys(_Tw2TransformParameter).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2TransformParameter[key]; + } + }); +}); + +var _Tw2VariableParameter = __webpack_require__(99); + +Object.keys(_Tw2VariableParameter).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2VariableParameter[key]; + } + }); +}); + +var _Tw2Vector2Parameter = __webpack_require__(100); + +Object.keys(_Tw2Vector2Parameter).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2Vector2Parameter[key]; + } + }); +}); + +var _Tw2Vector3Parameter = __webpack_require__(101); + +Object.keys(_Tw2Vector3Parameter).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2Vector3Parameter[key]; + } + }); +}); + +var _Tw2Vector4Parameter = __webpack_require__(102); + +Object.keys(_Tw2Vector4Parameter).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2Vector4Parameter[key]; + } + }); +}); + +var _Tw2TextureParameter = __webpack_require__(42); + +Object.keys(_Tw2TextureParameter).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2TextureParameter[key]; + } + }); +}); + +/***/ }), +/* 46 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -10421,9 +9384,9 @@ exports.Tw2PerObjectData = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2Device = __webpack_require__(2); +var _global = __webpack_require__(0); -var _Tw2RawData = __webpack_require__(25); +var _Tw2RawData = __webpack_require__(24); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -10457,11 +9420,11 @@ var Tw2PerObjectData = exports.Tw2PerObjectData = function () { key: 'SetPerObjectDataToDevice', value: function SetPerObjectDataToDevice(constantBufferHandles) { if (this.perObjectVSData && constantBufferHandles[3]) { - _Tw2Device.device.gl.uniform4fv(constantBufferHandles[3], this.perObjectVSData.data); + _global.device.gl.uniform4fv(constantBufferHandles[3], this.perObjectVSData.data); } if (this.perObjectPSData && constantBufferHandles[4]) { - _Tw2Device.device.gl.uniform4fv(constantBufferHandles[4], this.perObjectPSData.data); + _global.device.gl.uniform4fv(constantBufferHandles[4], this.perObjectPSData.data); } } @@ -10489,90 +9452,7 @@ var Tw2PerObjectData = exports.Tw2PerObjectData = function () { }(); /***/ }), -/* 45 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _emitters = __webpack_require__(100); - -Object.keys(_emitters).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _emitters[key]; - } - }); -}); - -var _forces = __webpack_require__(104); - -Object.keys(_forces).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _forces[key]; - } - }); -}); - -var _generators = __webpack_require__(111); - -Object.keys(_generators).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _generators[key]; - } - }); -}); - -var _constraints = __webpack_require__(115); - -Object.keys(_constraints).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _constraints[key]; - } - }); -}); - -var _Tw2ParticleSystem = __webpack_require__(116); - -Object.keys(_Tw2ParticleSystem).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2ParticleSystem[key]; - } - }); -}); - -var _Tw2ParticleElement = __webpack_require__(18); - -Object.keys(_Tw2ParticleElement).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2ParticleElement[key]; - } - }); -}); - -/***/ }), -/* 46 */ +/* 47 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -10582,7 +9462,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2BlendShapeData = __webpack_require__(118); +var _Tw2BlendShapeData = __webpack_require__(105); Object.keys(_Tw2BlendShapeData).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10594,7 +9474,7 @@ Object.keys(_Tw2BlendShapeData).forEach(function (key) { }); }); -var _Tw2GeometryAnimation = __webpack_require__(119); +var _Tw2GeometryAnimation = __webpack_require__(106); Object.keys(_Tw2GeometryAnimation).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10606,7 +9486,7 @@ Object.keys(_Tw2GeometryAnimation).forEach(function (key) { }); }); -var _Tw2GeometryBone = __webpack_require__(120); +var _Tw2GeometryBone = __webpack_require__(107); Object.keys(_Tw2GeometryBone).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10618,7 +9498,7 @@ Object.keys(_Tw2GeometryBone).forEach(function (key) { }); }); -var _Tw2GeometryCurve = __webpack_require__(121); +var _Tw2GeometryCurve = __webpack_require__(108); Object.keys(_Tw2GeometryCurve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10630,7 +9510,7 @@ Object.keys(_Tw2GeometryCurve).forEach(function (key) { }); }); -var _Tw2GeometryMesh = __webpack_require__(122); +var _Tw2GeometryMesh = __webpack_require__(109); Object.keys(_Tw2GeometryMesh).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10642,7 +9522,7 @@ Object.keys(_Tw2GeometryMesh).forEach(function (key) { }); }); -var _Tw2GeometryMeshArea = __webpack_require__(123); +var _Tw2GeometryMeshArea = __webpack_require__(110); Object.keys(_Tw2GeometryMeshArea).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10654,7 +9534,7 @@ Object.keys(_Tw2GeometryMeshArea).forEach(function (key) { }); }); -var _Tw2GeometryMeshBinding = __webpack_require__(124); +var _Tw2GeometryMeshBinding = __webpack_require__(111); Object.keys(_Tw2GeometryMeshBinding).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10666,7 +9546,7 @@ Object.keys(_Tw2GeometryMeshBinding).forEach(function (key) { }); }); -var _Tw2GeometryModel = __webpack_require__(125); +var _Tw2GeometryModel = __webpack_require__(112); Object.keys(_Tw2GeometryModel).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10678,7 +9558,7 @@ Object.keys(_Tw2GeometryModel).forEach(function (key) { }); }); -var _Tw2GeometrySkeleton = __webpack_require__(126); +var _Tw2GeometrySkeleton = __webpack_require__(113); Object.keys(_Tw2GeometrySkeleton).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10690,7 +9570,7 @@ Object.keys(_Tw2GeometrySkeleton).forEach(function (key) { }); }); -var _Tw2GeometryTrackGroup = __webpack_require__(127); +var _Tw2GeometryTrackGroup = __webpack_require__(114); Object.keys(_Tw2GeometryTrackGroup).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10702,7 +9582,7 @@ Object.keys(_Tw2GeometryTrackGroup).forEach(function (key) { }); }); -var _Tw2GeometryTransformTrack = __webpack_require__(128); +var _Tw2GeometryTransformTrack = __webpack_require__(115); Object.keys(_Tw2GeometryTransformTrack).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10715,7 +9595,7 @@ Object.keys(_Tw2GeometryTransformTrack).forEach(function (key) { }); /***/ }), -/* 47 */ +/* 48 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -10725,7 +9605,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2Effect = __webpack_require__(40); +var _Tw2Effect = __webpack_require__(41); Object.keys(_Tw2Effect).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10737,7 +9617,7 @@ Object.keys(_Tw2Effect).forEach(function (key) { }); }); -var _Tw2InstancedMesh = __webpack_require__(129); +var _Tw2InstancedMesh = __webpack_require__(116); Object.keys(_Tw2InstancedMesh).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10749,7 +9629,7 @@ Object.keys(_Tw2InstancedMesh).forEach(function (key) { }); }); -var _Tw2Mesh = __webpack_require__(48); +var _Tw2Mesh = __webpack_require__(49); Object.keys(_Tw2Mesh).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10761,7 +9641,7 @@ Object.keys(_Tw2Mesh).forEach(function (key) { }); }); -var _Tw2MeshArea = __webpack_require__(49); +var _Tw2MeshArea = __webpack_require__(50); Object.keys(_Tw2MeshArea).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10773,7 +9653,7 @@ Object.keys(_Tw2MeshArea).forEach(function (key) { }); }); -var _Tw2MeshLineArea = __webpack_require__(130); +var _Tw2MeshLineArea = __webpack_require__(117); Object.keys(_Tw2MeshLineArea).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10786,7 +9666,7 @@ Object.keys(_Tw2MeshLineArea).forEach(function (key) { }); /***/ }), -/* 48 */ +/* 49 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -10799,11 +9679,7 @@ exports.Tw2Mesh = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); - -var _Tw2ResMan = __webpack_require__(6); - -var _Tw2Device = __webpack_require__(2); +var _global = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -10835,7 +9711,7 @@ var Tw2Mesh = exports.Tw2Mesh = function () { function Tw2Mesh() { _classCallCheck(this, Tw2Mesh); - this._id = _math.util.generateID(); + this._id = _global.util.generateID(); this.name = ''; this.display = true; this.visible = {}; @@ -10866,7 +9742,7 @@ var Tw2Mesh = exports.Tw2Mesh = function () { key: 'Initialize', value: function Initialize() { if (this.geometryResPath !== '') { - this.geometryResource = _Tw2ResMan.resMan.GetResource(this.geometryResPath); + this.geometryResource = _global.resMan.GetResource(this.geometryResPath); } } @@ -10896,12 +9772,12 @@ var Tw2Mesh = exports.Tw2Mesh = function () { out.push(this.geometryResource); } - _math.util.perArrayChild(this.opaqueAreas, 'GetResources', out); - _math.util.perArrayChild(this.transparentAreas, 'GetResources', out); - _math.util.perArrayChild(this.additiveAreas, 'GetResources', out); - _math.util.perArrayChild(this.pickableAreas, 'GetResources', out); - _math.util.perArrayChild(this.decalAreas, 'GetResources', out); - _math.util.perArrayChild(this.depthAreas, 'GetResources', out); + _global.util.perArrayChild(this.opaqueAreas, 'GetResources', out); + _global.util.perArrayChild(this.transparentAreas, 'GetResources', out); + _global.util.perArrayChild(this.additiveAreas, 'GetResources', out); + _global.util.perArrayChild(this.pickableAreas, 'GetResources', out); + _global.util.perArrayChild(this.decalAreas, 'GetResources', out); + _global.util.perArrayChild(this.depthAreas, 'GetResources', out); return out; } @@ -10919,31 +9795,31 @@ var Tw2Mesh = exports.Tw2Mesh = function () { var getBatches = this.constructor.GetAreaBatches; switch (mode) { - case _Tw2Device.device.RM_OPAQUE: + case _global.device.RM_OPAQUE: if (this.visible.opaqueAreas) { getBatches(this, this.opaqueAreas, mode, accumulator, perObjectData); } return; - case _Tw2Device.device.RM_DECAL: + case _global.device.RM_DECAL: if (this.visible.decalAreas) { getBatches(this, this.opaqueAreas, mode, accumulator, perObjectData); } return; - case _Tw2Device.device.RM_TRANSPARENT: + case _global.device.RM_TRANSPARENT: if (this.visible.transparentAreas) { getBatches(this, this.transparentAreas, mode, accumulator, perObjectData); } return; - case _Tw2Device.device.RM_ADDITIVE: + case _global.device.RM_ADDITIVE: if (this.visible.transparentAreas) { getBatches(this, this.additiveAreas, mode, accumulator, perObjectData); } return; - case _Tw2Device.device.RM_PICKABLE: + case _global.device.RM_PICKABLE: if (this.visible.pickableAreas) { getBatches(this, this.pickableAreas, mode, accumulator, perObjectData); } @@ -10984,7 +9860,7 @@ var Tw2Mesh = exports.Tw2Mesh = function () { }(); /***/ }), -/* 49 */ +/* 50 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -10995,9 +9871,9 @@ Object.defineProperty(exports, "__esModule", { }); exports.Tw2MeshArea = undefined; -var _batch = __webpack_require__(20); +var _batch = __webpack_require__(15); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -11015,7 +9891,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var Tw2MeshArea = exports.Tw2MeshArea = function Tw2MeshArea() { _classCallCheck(this, Tw2MeshArea); - this._id = _math.util.generateID(); + this._id = _global.util.generateID(); this.name = ''; this.effect = null; this.meshIndex = 0; @@ -11033,7 +9909,7 @@ var Tw2MeshArea = exports.Tw2MeshArea = function Tw2MeshArea() { Tw2MeshArea.batchType = _batch.Tw2GeometryBatch; /***/ }), -/* 50 */ +/* 51 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -11089,7 +9965,7 @@ var Tw2Animation = exports.Tw2Animation = function () { }(); /***/ }), -/* 51 */ +/* 52 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -11102,13 +9978,9 @@ exports.Tw2TextureRes = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2ResMan = __webpack_require__(6); - -var _Tw2Device = __webpack_require__(2); +var _global = __webpack_require__(0); -var _Tw2Logger = __webpack_require__(4); - -var _Tw2Resource2 = __webpack_require__(12); +var _Tw2Resource2 = __webpack_require__(8); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -11159,7 +10031,7 @@ var Tw2TextureRes = exports.Tw2TextureRes = function (_Tw2Resource) { _createClass(Tw2TextureRes, [{ key: 'Prepare', value: function Prepare(text) { - var d = _Tw2Device.device, + var d = _global.device, format = this.images[0]['ccpGLFormat'] ? this.images[0]['ccpGLFormat'] : d.gl.RGBA; switch (text) { @@ -11211,7 +10083,7 @@ var Tw2TextureRes = exports.Tw2TextureRes = function (_Tw2Resource) { value: function DoCustomLoad(path) { var _this2 = this; - var ext = _Tw2ResMan.resMan.constructor.GetPathExt(path); + var ext = _global.resMan.constructor.GetPathExt(path); switch (ext) { case 'cube': this.isCube = true; @@ -11225,7 +10097,7 @@ var Tw2TextureRes = exports.Tw2TextureRes = function (_Tw2Resource) { } this.LoadStarted(); - _Tw2ResMan.resMan._pendingLoads++; + _global.resMan._pendingLoads++; this.images = []; this.images[0] = new Image(); @@ -11235,8 +10107,8 @@ var Tw2TextureRes = exports.Tw2TextureRes = function (_Tw2Resource) { * Fires on errors */ this.images[0].onerror = function () { - _Tw2ResMan.resMan._pendingLoads--; - _Tw2Logger.logger.log('res.error', { + _global.resMan._pendingLoads--; + _global.logger.log('res.error', { log: 'error', src: ['Tw2TextureRes', 'DoCustomLoad'], msg: 'Error loading resource', @@ -11252,8 +10124,8 @@ var Tw2TextureRes = exports.Tw2TextureRes = function (_Tw2Resource) { * Fires when loaded */ this.images[0].onload = function () { - _Tw2ResMan.resMan._pendingLoads--; - _Tw2ResMan.resMan._prepareQueue.push([_this2, ext, null]); + _global.resMan._pendingLoads--; + _global.resMan._prepareQueue.push([_this2, ext, null]); _this2.LoadFinished(true); }; @@ -11270,7 +10142,7 @@ var Tw2TextureRes = exports.Tw2TextureRes = function (_Tw2Resource) { key: 'Unload', value: function Unload() { if (this.texture) { - _Tw2Device.device.gl.deleteTexture(this.texture); + _global.device.gl.deleteTexture(this.texture); this.texture = null; } this._isPurged = true; @@ -11302,7 +10174,7 @@ var Tw2TextureRes = exports.Tw2TextureRes = function (_Tw2Resource) { }, { key: 'Bind', value: function Bind(sampler, slices) { - var d = _Tw2Device.device; + var d = _global.device; this.KeepAlive(); var targetType = sampler.samplerType; @@ -11346,7 +10218,7 @@ var Tw2TextureRes = exports.Tw2TextureRes = function (_Tw2Resource) { }, { key: 'AddMipLevelSkipCount', value: function AddMipLevelSkipCount(path) { - var d = _Tw2Device.device, + var d = _global.device, mipExt = d.mipLevelSkipCount > 0 ? '.' + d.mipLevelSkipCount.toString() : ''; if (d.mipLevelSkipCount > 0) { @@ -11363,7 +10235,7 @@ var Tw2TextureRes = exports.Tw2TextureRes = function (_Tw2Resource) { }(_Tw2Resource2.Tw2Resource); /***/ }), -/* 52 */ +/* 53 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -11374,7 +10246,7 @@ Object.defineProperty(exports, "__esModule", { }); exports.Tw2Bone = undefined; -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -11391,13 +10263,13 @@ var Tw2Bone = exports.Tw2Bone = function Tw2Bone() { _classCallCheck(this, Tw2Bone); this.boneRes = null; - this.localTransform = _math.mat4.create(); - this.worldTransform = _math.mat4.create(); - this.offsetTransform = _math.mat4.create(); + this.localTransform = _global.mat4.create(); + this.worldTransform = _global.mat4.create(); + this.offsetTransform = _global.mat4.create(); }; /***/ }), -/* 53 */ +/* 54 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -11426,7 +10298,7 @@ var Tw2Model = exports.Tw2Model = function Tw2Model() { }; /***/ }), -/* 54 */ +/* 55 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -11453,7 +10325,7 @@ var Tw2Track = exports.Tw2Track = function Tw2Track() { }; /***/ }), -/* 55 */ +/* 56 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -11482,7 +10354,7 @@ var Tw2TrackGroup = exports.Tw2TrackGroup = function Tw2TrackGroup() { }; /***/ }), -/* 56 */ +/* 57 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -11495,11 +10367,9 @@ exports.Tw2RenderTarget = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); - -var _Tw2Device = __webpack_require__(2); +var _global = __webpack_require__(0); -var _Tw2TextureRes = __webpack_require__(51); +var _Tw2TextureRes = __webpack_require__(52); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -11520,7 +10390,7 @@ var Tw2RenderTarget = exports.Tw2RenderTarget = function () { function Tw2RenderTarget() { _classCallCheck(this, Tw2RenderTarget); - this._id = _math.util.generateID(); + this._id = _global.util.generateID(); this.name = ''; this.texture = null; this.width = null; @@ -11539,17 +10409,17 @@ var Tw2RenderTarget = exports.Tw2RenderTarget = function () { key: 'Destroy', value: function Destroy() { if (this.texture) { - _Tw2Device.device.gl.deleteTexture(this.texture.texture); + _global.device.gl.deleteTexture(this.texture.texture); this.texture = null; } if (this._renderBuffer) { - _Tw2Device.device.gl.deleteRenderbuffer(this._renderBuffer); + _global.device.gl.deleteRenderbuffer(this._renderBuffer); this._renderBuffer = null; } if (this._frameBuffer) { - _Tw2Device.device.gl.deleteFramebuffer(this._frameBuffer); + _global.device.gl.deleteFramebuffer(this._frameBuffer); this._frameBuffer = null; } } @@ -11567,33 +10437,33 @@ var Tw2RenderTarget = exports.Tw2RenderTarget = function () { value: function Create(width, height, hasDepth) { this.Destroy(); this.texture = new _Tw2TextureRes.Tw2TextureRes(); - this.texture.Attach(_Tw2Device.device.gl.createTexture()); + this.texture.Attach(_global.device.gl.createTexture()); - this._frameBuffer = _Tw2Device.device.gl.createFramebuffer(); - _Tw2Device.device.gl.bindFramebuffer(_Tw2Device.device.gl.FRAMEBUFFER, this._frameBuffer); + this._frameBuffer = _global.device.gl.createFramebuffer(); + _global.device.gl.bindFramebuffer(_global.device.gl.FRAMEBUFFER, this._frameBuffer); - _Tw2Device.device.gl.bindTexture(_Tw2Device.device.gl.TEXTURE_2D, this.texture.texture); - _Tw2Device.device.gl.texImage2D(_Tw2Device.device.gl.TEXTURE_2D, 0, _Tw2Device.device.gl.RGBA, width, height, 0, _Tw2Device.device.gl.RGBA, _Tw2Device.device.gl.UNSIGNED_BYTE, null); - _Tw2Device.device.gl.texParameteri(_Tw2Device.device.gl.TEXTURE_2D, _Tw2Device.device.gl.TEXTURE_MAG_FILTER, _Tw2Device.device.gl.LINEAR); - _Tw2Device.device.gl.texParameteri(_Tw2Device.device.gl.TEXTURE_2D, _Tw2Device.device.gl.TEXTURE_MIN_FILTER, _Tw2Device.device.gl.LINEAR); - _Tw2Device.device.gl.bindTexture(_Tw2Device.device.gl.TEXTURE_2D, null); + _global.device.gl.bindTexture(_global.device.gl.TEXTURE_2D, this.texture.texture); + _global.device.gl.texImage2D(_global.device.gl.TEXTURE_2D, 0, _global.device.gl.RGBA, width, height, 0, _global.device.gl.RGBA, _global.device.gl.UNSIGNED_BYTE, null); + _global.device.gl.texParameteri(_global.device.gl.TEXTURE_2D, _global.device.gl.TEXTURE_MAG_FILTER, _global.device.gl.LINEAR); + _global.device.gl.texParameteri(_global.device.gl.TEXTURE_2D, _global.device.gl.TEXTURE_MIN_FILTER, _global.device.gl.LINEAR); + _global.device.gl.bindTexture(_global.device.gl.TEXTURE_2D, null); this._renderBuffer = null; if (hasDepth) { - this._renderBuffer = _Tw2Device.device.gl.createRenderbuffer(); - _Tw2Device.device.gl.bindRenderbuffer(_Tw2Device.device.gl.RENDERBUFFER, this._renderBuffer); - _Tw2Device.device.gl.renderbufferStorage(_Tw2Device.device.gl.RENDERBUFFER, _Tw2Device.device.gl.DEPTH_COMPONENT16, width, height); + this._renderBuffer = _global.device.gl.createRenderbuffer(); + _global.device.gl.bindRenderbuffer(_global.device.gl.RENDERBUFFER, this._renderBuffer); + _global.device.gl.renderbufferStorage(_global.device.gl.RENDERBUFFER, _global.device.gl.DEPTH_COMPONENT16, width, height); } - _Tw2Device.device.gl.framebufferTexture2D(_Tw2Device.device.gl.FRAMEBUFFER, _Tw2Device.device.gl.COLOR_ATTACHMENT0, _Tw2Device.device.gl.TEXTURE_2D, this.texture.texture, 0); + _global.device.gl.framebufferTexture2D(_global.device.gl.FRAMEBUFFER, _global.device.gl.COLOR_ATTACHMENT0, _global.device.gl.TEXTURE_2D, this.texture.texture, 0); if (hasDepth) { - _Tw2Device.device.gl.framebufferRenderbuffer(_Tw2Device.device.gl.FRAMEBUFFER, _Tw2Device.device.gl.DEPTH_ATTACHMENT, _Tw2Device.device.gl.RENDERBUFFER, this._renderBuffer); + _global.device.gl.framebufferRenderbuffer(_global.device.gl.FRAMEBUFFER, _global.device.gl.DEPTH_ATTACHMENT, _global.device.gl.RENDERBUFFER, this._renderBuffer); } - _Tw2Device.device.gl.bindRenderbuffer(_Tw2Device.device.gl.RENDERBUFFER, null); - _Tw2Device.device.gl.bindFramebuffer(_Tw2Device.device.gl.FRAMEBUFFER, null); + _global.device.gl.bindRenderbuffer(_global.device.gl.RENDERBUFFER, null); + _global.device.gl.bindFramebuffer(_global.device.gl.FRAMEBUFFER, null); this.texture.width = this.width = width; this.texture.height = this.height = height; @@ -11607,8 +10477,8 @@ var Tw2RenderTarget = exports.Tw2RenderTarget = function () { }, { key: 'Set', value: function Set() { - _Tw2Device.device.gl.bindFramebuffer(_Tw2Device.device.gl.FRAMEBUFFER, this._frameBuffer); - _Tw2Device.device.gl.viewport(0, 0, this.width, this.height); + _global.device.gl.bindFramebuffer(_global.device.gl.FRAMEBUFFER, this._frameBuffer); + _global.device.gl.viewport(0, 0, this.width, this.height); } /** @@ -11618,8 +10488,8 @@ var Tw2RenderTarget = exports.Tw2RenderTarget = function () { }, { key: 'Unset', value: function Unset() { - _Tw2Device.device.gl.bindFramebuffer(_Tw2Device.device.gl.FRAMEBUFFER, null); - _Tw2Device.device.gl.viewport(0, 0, _Tw2Device.device.viewportWidth, _Tw2Device.device.viewportHeight); + _global.device.gl.bindFramebuffer(_global.device.gl.FRAMEBUFFER, null); + _global.device.gl.viewport(0, 0, _global.device.viewportWidth, _global.device.viewportHeight); } }]); @@ -11627,7 +10497,7 @@ var Tw2RenderTarget = exports.Tw2RenderTarget = function () { }(); /***/ }), -/* 57 */ +/* 58 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -11637,7 +10507,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _curves = __webpack_require__(19); +var _curves = __webpack_require__(13); Object.keys(_curves).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11649,7 +10519,7 @@ Object.keys(_curves).forEach(function (key) { }); }); -var _sequencers = __webpack_require__(155); +var _sequencers = __webpack_require__(142); Object.keys(_sequencers).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11661,7 +10531,7 @@ Object.keys(_sequencers).forEach(function (key) { }); }); -var _tracks = __webpack_require__(164); +var _tracks = __webpack_require__(151); Object.keys(_tracks).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11673,7 +10543,7 @@ Object.keys(_tracks).forEach(function (key) { }); }); -var _maya = __webpack_require__(167); +var _maya = __webpack_require__(154); Object.keys(_maya).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11686,7 +10556,7 @@ Object.keys(_maya).forEach(function (key) { }); /***/ }), -/* 58 */ +/* 59 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -11696,7 +10566,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _EveChild = __webpack_require__(14); +var _EveChild = __webpack_require__(10); Object.keys(_EveChild).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11708,7 +10578,7 @@ Object.keys(_EveChild).forEach(function (key) { }); }); -var _EveChildBillboard = __webpack_require__(173); +var _EveChildBillboard = __webpack_require__(160); Object.keys(_EveChildBillboard).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11720,7 +10590,7 @@ Object.keys(_EveChildBillboard).forEach(function (key) { }); }); -var _EveChildContainer = __webpack_require__(174); +var _EveChildContainer = __webpack_require__(161); Object.keys(_EveChildContainer).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11732,7 +10602,7 @@ Object.keys(_EveChildContainer).forEach(function (key) { }); }); -var _EveChildExplosion = __webpack_require__(175); +var _EveChildExplosion = __webpack_require__(162); Object.keys(_EveChildExplosion).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11744,7 +10614,7 @@ Object.keys(_EveChildExplosion).forEach(function (key) { }); }); -var _EveChildMesh = __webpack_require__(176); +var _EveChildMesh = __webpack_require__(163); Object.keys(_EveChildMesh).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11756,7 +10626,7 @@ Object.keys(_EveChildMesh).forEach(function (key) { }); }); -var _EveChildParticleSystem = __webpack_require__(177); +var _EveChildParticleSystem = __webpack_require__(164); Object.keys(_EveChildParticleSystem).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11769,7 +10639,7 @@ Object.keys(_EveChildParticleSystem).forEach(function (key) { }); /***/ }), -/* 59 */ +/* 60 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -11782,7 +10652,7 @@ exports.EveOccluder = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); var _core = __webpack_require__(1); @@ -11801,7 +10671,7 @@ var EveOccluder = exports.EveOccluder = function () { function EveOccluder() { _classCallCheck(this, EveOccluder); - this._id = _math.util.generateID(); + this._id = _global.util.generateID(); this.name = ''; this.value = 1; this.sprites = []; @@ -11819,9 +10689,9 @@ var EveOccluder = exports.EveOccluder = function () { _createClass(EveOccluder, [{ key: 'UpdateValue', value: function UpdateValue(parentTransform, index) { - if (!_core.device.alphaBlendBackBuffer) return; + if (!_global.device.alphaBlendBackBuffer) return; - var d = _core.device, + var d = _global.device, g = EveOccluder.global, worldViewProj = g.mat4_0, center = g.vec4_0; @@ -11833,18 +10703,18 @@ var EveOccluder = exports.EveOccluder = function () { this.sprites[i].GetBatches(d.RM_DECAL, g.accumulator); } - _core.store.SetVariableValue('OccluderValue', [(1 << index * 2) / 255.0, (2 << index * 2) / 255.0, 0, 0]); + _global.store.SetVariableValue('OccluderValue', [(1 << index * 2) / 255.0, (2 << index * 2) / 255.0, 0, 0]); g.accumulator.Render(); - _math.mat4.multiply(worldViewProj, d.viewProjection, this.sprites[0].worldTransform); - _math.vec4.transformMat4(center, [0, 0, 0, 1], worldViewProj); + _global.mat4.multiply(worldViewProj, d.viewProjection, this.sprites[0].worldTransform); + _global.vec4.transformMat4(center, [0, 0, 0, 1], worldViewProj); var x0 = (center[0] / center[3] + 1) * 0.5, y0 = (center[1] / center[3] + 1) * 0.5; - _math.vec4.set(center, 0.5, 0.5, 0, 1); - _math.vec4.transformMat4(center, center, worldViewProj); + _global.vec4.set(center, 0.5, 0.5, 0, 1); + _global.vec4.transformMat4(center, center, worldViewProj); var x1 = (center[0] / center[3] + 1) * 0.5, y1 = (center[1] / center[3] + 1) * 0.5; @@ -11869,7 +10739,7 @@ var EveOccluder = exports.EveOccluder = function () { }], [{ key: 'CollectSamples', value: function CollectSamples(tex, index, total, samples) { - var d = _core.device, + var d = _global.device, g = this.global, effect = g.effect, vertexBuffer = g.vertexBuffer, @@ -11901,11 +10771,11 @@ var EveOccluder = exports.EveOccluder = function () { value: function init() { if (EveOccluder.global) return; - var d = _core.device, + var d = _global.device, g = EveOccluder.global = {}; - g.mat4_0 = _math.mat4.create(); - g.vec4_0 = _math.vec4.create(); + g.mat4_0 = _global.mat4.create(); + g.vec4_0 = _global.vec4.create(); g.accumulator = new _core.Tw2BatchAccumulator(); g.effect = _core.Tw2Effect.create({ @@ -11978,7 +10848,7 @@ var EveOccluder = exports.EveOccluder = function () { EveOccluder.global = null; /***/ }), -/* 60 */ +/* 61 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -11988,7 +10858,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _EveObject = __webpack_require__(15); +var _EveObject = __webpack_require__(11); Object.keys(_EveObject).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -12000,7 +10870,7 @@ Object.keys(_EveObject).forEach(function (key) { }); }); -var _EveEffectRoot = __webpack_require__(183); +var _EveEffectRoot = __webpack_require__(171); Object.keys(_EveEffectRoot).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -12012,7 +10882,7 @@ Object.keys(_EveEffectRoot).forEach(function (key) { }); }); -var _EveMissile = __webpack_require__(184); +var _EveMissile = __webpack_require__(172); Object.keys(_EveMissile).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -12024,7 +10894,7 @@ Object.keys(_EveMissile).forEach(function (key) { }); }); -var _EvePlanet = __webpack_require__(185); +var _EvePlanet = __webpack_require__(173); Object.keys(_EvePlanet).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -12036,7 +10906,7 @@ Object.keys(_EvePlanet).forEach(function (key) { }); }); -var _EveShip = __webpack_require__(186); +var _EveShip = __webpack_require__(174); Object.keys(_EveShip).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -12048,7 +10918,7 @@ Object.keys(_EveShip).forEach(function (key) { }); }); -var _EveSpaceObject = __webpack_require__(62); +var _EveSpaceObject = __webpack_require__(63); Object.keys(_EveSpaceObject).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -12060,7 +10930,7 @@ Object.keys(_EveSpaceObject).forEach(function (key) { }); }); -var _EveTransform = __webpack_require__(61); +var _EveTransform = __webpack_require__(62); Object.keys(_EveTransform).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -12073,7 +10943,7 @@ Object.keys(_EveTransform).forEach(function (key) { }); /***/ }), -/* 61 */ +/* 62 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -12086,11 +10956,11 @@ exports.EveTransform = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); var _core = __webpack_require__(1); -var _EveObject2 = __webpack_require__(15); +var _EveObject2 = __webpack_require__(11); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -12145,11 +11015,11 @@ var EveTransform = exports.EveTransform = function (_EveObject) { _this.distanceBasedScaleArg1 = 0.2; _this.distanceBasedScaleArg2 = 0.63; _this.useDistanceBasedScale = false; - _this.scaling = _math.vec3.fromValues(1, 1, 1); - _this.translation = _math.vec3.create(); - _this.rotation = _math.quat.create(); - _this.localTransform = _math.mat4.create(); - _this.worldTransform = _math.mat4.create(); + _this.scaling = _global.vec3.fromValues(1, 1, 1); + _this.translation = _global.vec3.create(); + _this.rotation = _global.quat.create(); + _this.localTransform = _global.mat4.create(); + _this.worldTransform = _global.mat4.create(); _this._perObjectData = new _core.Tw2BasicPerObjectData(); _this._perObjectData.perObjectFFEData = new _core.Tw2RawData(); @@ -12167,7 +11037,7 @@ var EveTransform = exports.EveTransform = function (_EveObject) { _createClass(EveTransform, [{ key: 'Initialize', value: function Initialize() { - _math.mat4.fromRotationTranslationScale(this.localTransform, this.rotation, this.translation, this.scaling); + _global.mat4.fromRotationTranslationScale(this.localTransform, this.rotation, this.translation, this.scaling); } /** @@ -12202,31 +11072,31 @@ var EveTransform = exports.EveTransform = function (_EveObject) { }, { key: 'UpdateViewDependentData', value: function UpdateViewDependentData(parentTransform) { - var d = _core.device, + var d = _global.device, g = EveTransform.global, finalScale = g.vec3_0, parentScale = g.vec3_1, dir = g.vec3_2, viewInv = d.viewInverse; - _math.quat.normalize(this.rotation, this.rotation); - _math.mat4.fromRotationTranslationScale(this.localTransform, this.rotation, this.translation, this.scaling); - _math.mat4.getScaling(parentScale, parentTransform); + _global.quat.normalize(this.rotation, this.rotation); + _global.mat4.fromRotationTranslationScale(this.localTransform, this.rotation, this.translation, this.scaling); + _global.mat4.getScaling(parentScale, parentTransform); switch (this.modifier) { case EveTransform.Modifier.BILLBOARD: case EveTransform.Modifier.SIMPLE_HALO: var dirNorm = g.vec3_3; - _math.mat4.multiply(this.worldTransform, parentTransform, this.localTransform); - _math.vec3.multiply(finalScale, this.scaling, parentScale); + _global.mat4.multiply(this.worldTransform, parentTransform, this.localTransform); + _global.vec3.multiply(finalScale, this.scaling, parentScale); if (this.modifier === EveTransform.Modifier.SIMPLE_HALO) { - _math.vec3.subtract(dir, d.GetEyePosition(dir), this.worldTransform.subarray(12)); - _math.vec3.normalize(dirNorm, this.worldTransform.subarray(8)); - _math.vec3.normalize(dir, dir); - var scale = _math.vec3.dot(dir, dirNorm); + _global.vec3.subtract(dir, d.GetEyePosition(dir), this.worldTransform.subarray(12)); + _global.vec3.normalize(dirNorm, this.worldTransform.subarray(8)); + _global.vec3.normalize(dir, dir); + var scale = _global.vec3.dot(dir, dirNorm); if (scale < 0) scale = 0; - _math.vec3.scale(finalScale, finalScale, scale * scale); + _global.vec3.scale(finalScale, finalScale, scale * scale); } this.worldTransform[0] = viewInv[0] * finalScale[0]; @@ -12242,9 +11112,9 @@ var EveTransform = exports.EveTransform = function (_EveObject) { case EveTransform.Modifier.EVE_CAMERA_ROTATION: var translation = g.vec3_3; - _math.vec3.transformMat4(translation, this.translation, parentTransform); - _math.mat4.fromRotationTranslationScale(this.localTransform, this.rotation, translation, this.scaling); - _math.mat4.multiply(this.worldTransform, viewInv, this.localTransform); + _global.vec3.transformMat4(translation, this.translation, parentTransform); + _global.mat4.fromRotationTranslationScale(this.localTransform, this.rotation, translation, this.scaling); + _global.mat4.multiply(this.worldTransform, viewInv, this.localTransform); this.worldTransform[12] = this.localTransform[12]; this.worldTransform[13] = this.localTransform[13]; this.worldTransform[14] = this.localTransform[14]; @@ -12262,26 +11132,26 @@ var EveTransform = exports.EveTransform = function (_EveObject) { rotationT = g.mat4_2; // 3 4 3 3 3 4 3 3 - _math.mat4.translate(this.worldTransform, parentTransform, this.translation); - _math.mat4.transpose(parentT, parentTransform); + _global.mat4.translate(this.worldTransform, parentTransform, this.translation); + _global.mat4.transpose(parentT, parentTransform); d.GetEyePosition(dir); dir[0] -= this.worldTransform[12]; dir[1] -= this.worldTransform[13]; dir[2] -= this.worldTransform[14]; - _math.vec3.copy(camFwd, dir); - _math.vec3.transformMat4(camFwd, camFwd, parentT); - _math.vec3.divide(camFwd, camFwd, parentScale); - _math.vec3.normalize(camFwd, camFwd); + _global.vec3.copy(camFwd, dir); + _global.vec3.transformMat4(camFwd, camFwd, parentT); + _global.vec3.divide(camFwd, camFwd, parentScale); + _global.vec3.normalize(camFwd, camFwd); - _math.vec3.set(right, d.view[0], d.view[4], d.view[8]); - _math.vec3.transformMat4(right, right, parentT); - _math.vec3.normalize(right, right); + _global.vec3.set(right, d.view[0], d.view[4], d.view[8]); + _global.vec3.transformMat4(right, right, parentT); + _global.vec3.normalize(right, right); - _math.vec3.cross(up, camFwd, right); - _math.vec3.normalize(up, up); - _math.vec3.cross(right, up, camFwd); + _global.vec3.cross(up, camFwd, right); + _global.vec3.normalize(up, up); + _global.vec3.cross(right, up, camFwd); alignMat[0] = right[0]; alignMat[1] = right[1]; @@ -12294,28 +11164,28 @@ var EveTransform = exports.EveTransform = function (_EveObject) { alignMat[10] = camFwd[2]; alignMat[15] = 1; - _math.mat4.fromQuat(rotationT, this.rotation); - _math.mat4.multiply(alignMat, alignMat, rotationT); + _global.mat4.fromQuat(rotationT, this.rotation); + _global.mat4.multiply(alignMat, alignMat, rotationT); if (this.modifier === EveTransform.Modifier.EVE_SIMPLE_HALO) { - _math.vec3.normalize(forward, this.worldTransform.subarray(8)); - _math.vec3.normalize(dirToCamNorm, dir); - var _scale = -_math.vec3.dot(dirToCamNorm, forward); + _global.vec3.normalize(forward, this.worldTransform.subarray(8)); + _global.vec3.normalize(dirToCamNorm, dir); + var _scale = -_global.vec3.dot(dirToCamNorm, forward); if (_scale < 0) _scale = 0; - _math.mat4.multiply(this.worldTransform, this.worldTransform, alignMat); - _math.mat4.scale(this.worldTransform, this.worldTransform, [this.scaling[0] * _scale, this.scaling[1] * _scale, this.scaling[2] * _scale]); + _global.mat4.multiply(this.worldTransform, this.worldTransform, alignMat); + _global.mat4.scale(this.worldTransform, this.worldTransform, [this.scaling[0] * _scale, this.scaling[1] * _scale, this.scaling[2] * _scale]); } else { - _math.mat4.scale(this.worldTransform, this.worldTransform, this.scaling); - _math.mat4.multiply(this.worldTransform, this.worldTransform, alignMat); + _global.mat4.scale(this.worldTransform, this.worldTransform, this.scaling); + _global.mat4.multiply(this.worldTransform, this.worldTransform, alignMat); } break; case EveTransform.Modifier.LOOK_AT_CAMERA: var lookAt = g.mat4_0; - _math.mat4.multiply(this.worldTransform, parentTransform, this.localTransform); - _math.mat4.lookAt(lookAt, viewInv.subarray(12), this.worldTransform.subarray(12), [0, 1, 0]); - _math.mat4.transpose(lookAt, lookAt); - _math.vec3.multiply(finalScale, this.scaling, parentScale); + _global.mat4.multiply(this.worldTransform, parentTransform, this.localTransform); + _global.mat4.lookAt(lookAt, viewInv.subarray(12), this.worldTransform.subarray(12), [0, 1, 0]); + _global.mat4.transpose(lookAt, lookAt); + _global.vec3.multiply(finalScale, this.scaling, parentScale); this.worldTransform[0] = lookAt[0] * finalScale[0]; this.worldTransform[1] = lookAt[1] * finalScale[0]; this.worldTransform[2] = lookAt[2] * finalScale[0]; @@ -12328,7 +11198,7 @@ var EveTransform = exports.EveTransform = function (_EveObject) { break; default: - _math.mat4.multiply(this.worldTransform, parentTransform, this.localTransform); + _global.mat4.multiply(this.worldTransform, parentTransform, this.localTransform); } for (var i = 0; i < this.children.length; ++i) { @@ -12374,8 +11244,8 @@ var EveTransform = exports.EveTransform = function (_EveObject) { if (!this.display) return; if (this.visible.mesh && this.mesh) { - _math.mat4.transpose(this._perObjectData.perObjectFFEData.Get('World'), this.worldTransform); - _math.mat4.invert(this._perObjectData.perObjectFFEData.Get('WorldInverseTranspose'), this.worldTransform); + _global.mat4.transpose(this._perObjectData.perObjectFFEData.Get('World'), this.worldTransform); + _global.mat4.invert(this._perObjectData.perObjectFFEData.Get('WorldInverseTranspose'), this.worldTransform); if (perObjectData) { this._perObjectData.perObjectVSData = perObjectData.perObjectVSData; @@ -12432,7 +11302,7 @@ EveTransform.Modifier = { }; /***/ }), -/* 62 */ +/* 63 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -12445,11 +11315,11 @@ exports.EveStation = exports.EveSpaceObject = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); var _core = __webpack_require__(1); -var _EveObject2 = __webpack_require__(15); +var _EveObject2 = __webpack_require__(11); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -12533,11 +11403,11 @@ var EveSpaceObject = exports.EveSpaceObject = function (_EveObject) { _this.customMasks = []; _this.lod = 3; _this.killCount = 0; - _this.transform = _math.mat4.create(); - _this.boundingSphereCenter = _math.vec3.create(); + _this.transform = _global.mat4.create(); + _this.boundingSphereCenter = _global.vec3.create(); _this.boundingSphereRadius = 0; - _this.shapeEllipsoidRadius = _math.vec3.create(); - _this.shapeEllipsoidCenter = _math.vec3.create(); + _this.shapeEllipsoidRadius = _global.vec3.create(); + _this.shapeEllipsoidCenter = _global.vec3.create(); _this._perObjectData = new _core.Tw2PerObjectData(); _this._perObjectData.perObjectVSData = new _core.Tw2RawData(); @@ -12570,8 +11440,8 @@ var EveSpaceObject = exports.EveSpaceObject = function (_EveObject) { _this._perObjectData.perObjectVSData.Get('Shipdata')[3] = -10; _this._perObjectData.perObjectPSData.Get('Shipdata')[3] = 1; - _math.mat4.identity(_this._perObjectData.perObjectVSData.Get('CustomMaskMatrix0')); - _math.mat4.identity(_this._perObjectData.perObjectVSData.Get('CustomMaskMatrix1')); + _global.mat4.identity(_this._perObjectData.perObjectVSData.Get('CustomMaskMatrix0')); + _global.mat4.identity(_this._perObjectData.perObjectVSData.Get('CustomMaskMatrix1')); return _this; } @@ -12610,7 +11480,7 @@ var EveSpaceObject = exports.EveSpaceObject = function (_EveObject) { }, { key: 'UpdateLod', value: function UpdateLod(frustum) { - var center = _math.vec3.transformMat4(EveSpaceObject.global.vec3_0, this.boundingSphereCenter, this.transform); + var center = _global.vec3.transformMat4(EveSpaceObject.global.vec3_0, this.boundingSphereCenter, this.transform); if (frustum.IsSphereVisible(center, this.boundingSphereRadius)) { if (frustum.GetPixelSizeAcross(center, this.boundingSphereRadius) < 100) { @@ -12636,14 +11506,14 @@ var EveSpaceObject = exports.EveSpaceObject = function (_EveObject) { }, { key: 'AddCustomMask', value: function AddCustomMask(position, scaling, rotation, isMirrored, sourceMaterial, targetMaterials) { - var transform = _math.mat4.fromRotationTranslationScale(_math.mat4.create(), rotation, position, scaling); - _math.mat4.invert(transform, transform); - _math.mat4.transpose(transform, transform); + var transform = _global.mat4.fromRotationTranslationScale(_global.mat4.create(), rotation, position, scaling); + _global.mat4.invert(transform, transform); + _global.mat4.transpose(transform, transform); this.customMasks.push({ transform: transform, - maskData: _math.vec4.fromValues(1, isMirrored ? 1 : 0, 0, 0), - materialID: _math.vec4.fromValues(sourceMaterial, 0, 0, 0), + maskData: _global.vec4.fromValues(1, isMirrored ? 1 : 0, 0, 0), + materialID: _global.vec4.fromValues(sourceMaterial, 0, 0, 0), targets: targetMaterials }); } @@ -12775,17 +11645,17 @@ var EveSpaceObject = exports.EveSpaceObject = function (_EveObject) { if (this.mesh) this.mesh.GetResources(out); if (this.animation) this.animation.GetResources(out); - _math.util.perArrayChild(this.spriteSets, 'GetResources', out); - _math.util.perArrayChild(this.turretSets, 'GetResources', out); - _math.util.perArrayChild(this.decals, 'GetResources', out); - _math.util.perArrayChild(this.spotlightSets, 'GetResources', out); - _math.util.perArrayChild(this.planeSets, 'GetResources', out); - _math.util.perArrayChild(this.lineSets, 'GetResources', out); - _math.util.perArrayChild(this.overlayEffects, 'GetResources', out); - _math.util.perArrayChild(this.effectChildren, 'GetResources', out); + _global.util.perArrayChild(this.spriteSets, 'GetResources', out); + _global.util.perArrayChild(this.turretSets, 'GetResources', out); + _global.util.perArrayChild(this.decals, 'GetResources', out); + _global.util.perArrayChild(this.spotlightSets, 'GetResources', out); + _global.util.perArrayChild(this.planeSets, 'GetResources', out); + _global.util.perArrayChild(this.lineSets, 'GetResources', out); + _global.util.perArrayChild(this.overlayEffects, 'GetResources', out); + _global.util.perArrayChild(this.effectChildren, 'GetResources', out); if (!excludeChildren) { - _math.util.perArrayChild(this.children, 'GetResources', out); + _global.util.perArrayChild(this.children, 'GetResources', out); } return out; @@ -12802,8 +11672,8 @@ var EveSpaceObject = exports.EveSpaceObject = function (_EveObject) { this.children[i].UpdateViewDependentData(this.transform); } - _math.mat4.transpose(this._perObjectData.perObjectVSData.Get('WorldMat'), this.transform); - _math.mat4.transpose(this._perObjectData.perObjectVSData.Get('WorldMatLast'), this.transform); + _global.mat4.transpose(this._perObjectData.perObjectVSData.Get('WorldMat'), this.transform); + _global.mat4.transpose(this._perObjectData.perObjectVSData.Get('WorldMatLast'), this.transform); var center = this._perObjectData.perObjectVSData.Get('EllipsoidCenter'), radii = this._perObjectData.perObjectVSData.Get('EllipsoidRadii'); @@ -12816,10 +11686,10 @@ var EveSpaceObject = exports.EveSpaceObject = function (_EveObject) { radii[1] = this.shapeEllipsoidRadius[1]; radii[2] = this.shapeEllipsoidRadius[2]; } else if (this.mesh && this.mesh.IsGood()) { - _math.vec3.subtract(center, this.mesh.geometryResource.maxBounds, this.mesh.geometryResource.minBounds); - _math.vec3.scale(center, center, 0.5 * 1.732050807); - _math.vec3.add(radii, this.mesh.geometryResource.maxBounds, this.mesh.geometryResource.minBounds); - _math.vec3.scale(radii, radii, 0.5); + _global.vec3.subtract(center, this.mesh.geometryResource.maxBounds, this.mesh.geometryResource.minBounds); + _global.vec3.scale(center, center, 0.5 * 1.732050807); + _global.vec3.add(radii, this.mesh.geometryResource.maxBounds, this.mesh.geometryResource.minBounds); + _global.vec3.scale(radii, radii, 0.5); } for (var _i = 0; _i < this.customMasks.length; ++_i) { @@ -12967,10 +11837,358 @@ var EveSpaceObject = exports.EveSpaceObject = function (_EveObject) { return EveSpaceObject; }(_EveObject2.EveObject); -exports.EveStation = EveSpaceObject; +exports.EveStation = EveSpaceObject; + +/***/ }), +/* 64 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _EveObjectSet = __webpack_require__(6); + +Object.keys(_EveObjectSet).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _EveObjectSet[key]; + } + }); +}); + +var _EveBoosterSet = __webpack_require__(175); + +Object.keys(_EveBoosterSet).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _EveBoosterSet[key]; + } + }); +}); + +var _EveCurveLineSet = __webpack_require__(176); + +Object.keys(_EveCurveLineSet).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _EveCurveLineSet[key]; + } + }); +}); + +var _EveLocator = __webpack_require__(177); + +Object.keys(_EveLocator).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _EveLocator[key]; + } + }); +}); + +var _EvePlaneSet = __webpack_require__(178); + +Object.keys(_EvePlaneSet).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _EvePlaneSet[key]; + } + }); +}); + +var _EveSpaceObjectDecal = __webpack_require__(179); + +Object.keys(_EveSpaceObjectDecal).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _EveSpaceObjectDecal[key]; + } + }); +}); + +var _EveSpotlightSet = __webpack_require__(180); + +Object.keys(_EveSpotlightSet).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _EveSpotlightSet[key]; + } + }); +}); + +var _EveSpriteSet = __webpack_require__(181); + +Object.keys(_EveSpriteSet).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _EveSpriteSet[key]; + } + }); +}); + +var _EveTurretSet = __webpack_require__(182); + +Object.keys(_EveTurretSet).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _EveTurretSet[key]; + } + }); +}); + +/***/ }), +/* 65 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.logger = exports.resMan = exports.store = exports.device = exports.util = exports.math = undefined; + +var _core = __webpack_require__(1); + +Object.keys(_core).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _core[key]; + } + }); +}); + +var _curve = __webpack_require__(58); + +Object.keys(_curve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _curve[key]; + } + }); +}); + +var _eve = __webpack_require__(159); + +Object.keys(_eve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _eve[key]; + } + }); +}); + +var _particle = __webpack_require__(185); + +Object.keys(_particle).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _particle[key]; + } + }); +}); + +var _math = __webpack_require__(18); + +var math = _interopRequireWildcard(_math); + +var core = _interopRequireWildcard(_core); + +var curve = _interopRequireWildcard(_curve); + +var eve = _interopRequireWildcard(_eve); + +var particle = _interopRequireWildcard(_particle); + +var _global = __webpack_require__(0); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +exports.math = math; +exports.util = _global.util; +exports.device = _global.device; +exports.store = _global.store; +exports.resMan = _global.resMan; +exports.logger = _global.logger; +var vec4 = math.vec4, + mat4 = math.mat4; + +/** + * Register globals + */ + +_global.store.Register({ + + paths: { + 'res': 'https://developers.eveonline.com/ccpwgl/assetpath/1097993/' + }, + + extensions: { + 'sm_hi': core.Tw2EffectRes, + 'sm_lo': core.Tw2EffectRes, + 'wbg': core.Tw2GeometryRes, + 'png': core.Tw2TextureRes, + 'cube': core.Tw2TextureRes, + 'mp4': core.Tw2VideoRes, + 'ogg': core.Tw2VideoRes, + 'webm': core.Tw2VideoRes + }, + + constructors: [core, curve, eve, particle], + + types: { + 'float': core.Tw2FloatParameter, + 'number': core.Tw2FloatParameter, + 'texture': core.Tw2TextureParameter, + 'vector2': core.Tw2Vector2Parameter, + 'vector3': core.Tw2Vector3Parameter, + 'vector4': core.Tw2Vector4Parameter, + 'matrix4': core.Tw2MatrixParameter + }, + + variables: { + 'WorldMat': mat4.create(), + 'ViewMat': mat4.create(), + 'ProjectionMat': mat4.create(), + 'ViewProjectionMat': mat4.create(), + 'ViewportSize': vec4.create(), + 'Time': vec4.create(), + 'u_DecalMatrix': mat4.create(), + 'u_InvDecalMatrix': mat4.create(), + 'EveSpaceSceneEnvMap': '', + 'EnvMap1': '', + 'EnvMap2': '', + 'EnvMap3': '', + 'ShadowLightness': 0, + 'OccluderValue': vec4.fromValues(1, 1, 0, 0), + 'LensflareFxOccScale': vec4.fromValues(1, 1, 0, 0), + 'LensflareFxDirectionScale': vec4.create() + } + +}); + +/***/ }), +/* 66 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2BatchAccumulator = undefined; + +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _global = __webpack_require__(0); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * Accumulates render batches for rendering + * + * @param {function} [sorting=null] - An optional function for sorting the collected render batches + * @property {Array.} batches - Accumulator render batches and/or child Tw2BatchAccumulators + * @property {function} _sortMethod - An optional method to sort batches before rendering them + * @class + */ +var Tw2BatchAccumulator = exports.Tw2BatchAccumulator = function () { + function Tw2BatchAccumulator() { + var sorting = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + + _classCallCheck(this, Tw2BatchAccumulator); + + this.batches = []; + this._sortMethod = sorting; + } + + /** + * Commits a batch + * @param {Tw2BatchAccumulator|Tw2RenderBatch} batch + */ + + + _createClass(Tw2BatchAccumulator, [{ + key: 'Commit', + value: function Commit(batch) { + this.batches.push(batch); + } + + /** + * Clears any accumulated render batches + */ + + }, { + key: 'Clear', + value: function Clear() { + this.batches = []; + } + + /** + * Renders the accumulated render batches + * @param {string} [technique] - technique name + */ + + }, { + key: 'Render', + value: function Render() { + var technique = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Main'; + + if (this._sortMethod) { + this.batches.sort(this._sortMethod); + } + + for (var i = 0; i < this.batches.length; ++i) { + if (this.batches[i] instanceof Tw2BatchAccumulator) { + this.batches[i].Render(technique); + } else { + if (this.batches[i].renderMode !== _global.device.RM_ANY) { + _global.device.SetStandardStates(this.batches[i].renderMode); + } + + _global.device.perObjectData = this.batches[i].perObjectData; + this.batches[i].Commit(technique); + } + } + } + }]); + + return Tw2BatchAccumulator; +}(); /***/ }), -/* 63 */ +/* 67 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -12979,355 +12197,986 @@ exports.EveStation = EveSpaceObject; Object.defineProperty(exports, "__esModule", { value: true }); +exports.vec2 = undefined; -var _EveObjectSet = __webpack_require__(10); +var _glMatrix = __webpack_require__(7); -Object.keys(_EveObjectSet).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _EveObjectSet[key]; - } - }); -}); +exports.vec2 = _glMatrix.vec2; -var _EveBoosterSet = __webpack_require__(187); +/***/ }), +/* 68 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -Object.keys(_EveBoosterSet).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _EveBoosterSet[key]; - } - }); -}); +"use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +/* harmony export (immutable) */ __webpack_exports__["create"] = create; +/* harmony export (immutable) */ __webpack_exports__["clone"] = clone; +/* harmony export (immutable) */ __webpack_exports__["copy"] = copy; +/* harmony export (immutable) */ __webpack_exports__["identity"] = identity; +/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues; +/* harmony export (immutable) */ __webpack_exports__["set"] = set; +/* harmony export (immutable) */ __webpack_exports__["transpose"] = transpose; +/* harmony export (immutable) */ __webpack_exports__["invert"] = invert; +/* harmony export (immutable) */ __webpack_exports__["adjoint"] = adjoint; +/* harmony export (immutable) */ __webpack_exports__["determinant"] = determinant; +/* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply; +/* harmony export (immutable) */ __webpack_exports__["rotate"] = rotate; +/* harmony export (immutable) */ __webpack_exports__["scale"] = scale; +/* harmony export (immutable) */ __webpack_exports__["fromRotation"] = fromRotation; +/* harmony export (immutable) */ __webpack_exports__["fromScaling"] = fromScaling; +/* harmony export (immutable) */ __webpack_exports__["str"] = str; +/* harmony export (immutable) */ __webpack_exports__["frob"] = frob; +/* harmony export (immutable) */ __webpack_exports__["LDU"] = LDU; +/* harmony export (immutable) */ __webpack_exports__["add"] = add; +/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract; +/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals; +/* harmony export (immutable) */ __webpack_exports__["equals"] = equals; +/* harmony export (immutable) */ __webpack_exports__["multiplyScalar"] = multiplyScalar; +/* harmony export (immutable) */ __webpack_exports__["multiplyScalarAndAdd"] = multiplyScalarAndAdd; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(3); +/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. -var _EveCurveLineSet = __webpack_require__(188); +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -Object.keys(_EveCurveLineSet).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _EveCurveLineSet[key]; - } - }); -}); +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. -var _EveLocator = __webpack_require__(189); +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. */ -Object.keys(_EveLocator).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _EveLocator[key]; - } - }); -}); -var _EvePlaneSet = __webpack_require__(190); -Object.keys(_EvePlaneSet).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _EvePlaneSet[key]; - } - }); -}); +/** + * 2x2 Matrix + * @module mat2 + */ -var _EveSpaceObjectDecal = __webpack_require__(191); +/** + * Creates a new identity mat2 + * + * @returns {mat2} a new 2x2 matrix + */ +function create() { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](4); + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + return out; +} -Object.keys(_EveSpaceObjectDecal).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _EveSpaceObjectDecal[key]; - } - }); -}); +/** + * Creates a new mat2 initialized with values from an existing matrix + * + * @param {mat2} a matrix to clone + * @returns {mat2} a new 2x2 matrix + */ +function clone(a) { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](4); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + return out; +} -var _EveSpotlightSet = __webpack_require__(192); +/** + * Copy the values from one mat2 to another + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the source matrix + * @returns {mat2} out + */ +function copy(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + return out; +} -Object.keys(_EveSpotlightSet).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _EveSpotlightSet[key]; - } - }); -}); +/** + * Set a mat2 to the identity matrix + * + * @param {mat2} out the receiving matrix + * @returns {mat2} out + */ +function identity(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + return out; +} -var _EveSpriteSet = __webpack_require__(193); +/** + * Create a new mat2 with the given values + * + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m10 Component in column 1, row 0 position (index 2) + * @param {Number} m11 Component in column 1, row 1 position (index 3) + * @returns {mat2} out A new 2x2 matrix + */ +function fromValues(m00, m01, m10, m11) { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](4); + out[0] = m00; + out[1] = m01; + out[2] = m10; + out[3] = m11; + return out; +} -Object.keys(_EveSpriteSet).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _EveSpriteSet[key]; - } - }); -}); +/** + * Set the components of a mat2 to the given values + * + * @param {mat2} out the receiving matrix + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m10 Component in column 1, row 0 position (index 2) + * @param {Number} m11 Component in column 1, row 1 position (index 3) + * @returns {mat2} out + */ +function set(out, m00, m01, m10, m11) { + out[0] = m00; + out[1] = m01; + out[2] = m10; + out[3] = m11; + return out; +} -var _EveTurretSet = __webpack_require__(194); +/** + * Transpose the values of a mat2 + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the source matrix + * @returns {mat2} out + */ +function transpose(out, a) { + // If we are transposing ourselves we can skip a few steps but have to cache + // some values + if (out === a) { + let a1 = a[1]; + out[1] = a[2]; + out[2] = a1; + } else { + out[0] = a[0]; + out[1] = a[2]; + out[2] = a[1]; + out[3] = a[3]; + } -Object.keys(_EveTurretSet).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _EveTurretSet[key]; - } - }); -}); + return out; +} -/***/ }), -/* 64 */ -/***/ (function(module, exports, __webpack_require__) { +/** + * Inverts a mat2 + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the source matrix + * @returns {mat2} out + */ +function invert(out, a) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; -"use strict"; + // Calculate the determinant + let det = a0 * a3 - a2 * a1; + if (!det) { + return null; + } + det = 1.0 / det; -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.math = undefined; + out[0] = a3 * det; + out[1] = -a1 * det; + out[2] = -a2 * det; + out[3] = a0 * det; -var _core = __webpack_require__(1); + return out; +} -Object.keys(_core).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _core[key]; - } - }); -}); +/** + * Calculates the adjugate of a mat2 + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the source matrix + * @returns {mat2} out + */ +function adjoint(out, a) { + // Caching this value is nessecary if out == a + let a0 = a[0]; + out[0] = a[3]; + out[1] = -a[1]; + out[2] = -a[2]; + out[3] = a0; -var _curve = __webpack_require__(57); + return out; +} -Object.keys(_curve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _curve[key]; - } - }); -}); +/** + * Calculates the determinant of a mat2 + * + * @param {mat2} a the source matrix + * @returns {Number} determinant of a + */ +function determinant(a) { + return a[0] * a[3] - a[2] * a[1]; +} + +/** + * Multiplies two mat2's + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the first operand + * @param {mat2} b the second operand + * @returns {mat2} out + */ +function multiply(out, a, b) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + out[0] = a0 * b0 + a2 * b1; + out[1] = a1 * b0 + a3 * b1; + out[2] = a0 * b2 + a2 * b3; + out[3] = a1 * b2 + a3 * b3; + return out; +} + +/** + * Rotates a mat2 by the given angle + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat2} out + */ +function rotate(out, a, rad) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + let s = Math.sin(rad); + let c = Math.cos(rad); + out[0] = a0 * c + a2 * s; + out[1] = a1 * c + a3 * s; + out[2] = a0 * -s + a2 * c; + out[3] = a1 * -s + a3 * c; + return out; +} -var _eve = __webpack_require__(172); +/** + * Scales the mat2 by the dimensions in the given vec2 + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the matrix to rotate + * @param {vec2} v the vec2 to scale the matrix by + * @returns {mat2} out + **/ +function scale(out, a, v) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + let v0 = v[0], v1 = v[1]; + out[0] = a0 * v0; + out[1] = a1 * v0; + out[2] = a2 * v1; + out[3] = a3 * v1; + return out; +} -Object.keys(_eve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _eve[key]; - } - }); -}); +/** + * Creates a matrix from a given angle + * This is equivalent to (but much faster than): + * + * mat2.identity(dest); + * mat2.rotate(dest, dest, rad); + * + * @param {mat2} out mat2 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat2} out + */ +function fromRotation(out, rad) { + let s = Math.sin(rad); + let c = Math.cos(rad); + out[0] = c; + out[1] = s; + out[2] = -s; + out[3] = c; + return out; +} + +/** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat2.identity(dest); + * mat2.scale(dest, dest, vec); + * + * @param {mat2} out mat2 receiving operation result + * @param {vec2} v Scaling vector + * @returns {mat2} out + */ +function fromScaling(out, v) { + out[0] = v[0]; + out[1] = 0; + out[2] = 0; + out[3] = v[1]; + return out; +} + +/** + * Returns a string representation of a mat2 + * + * @param {mat2} a matrix to represent as a string + * @returns {String} string representation of the matrix + */ +function str(a) { + return 'mat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')'; +} + +/** + * Returns Frobenius norm of a mat2 + * + * @param {mat2} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm + */ +function frob(a) { + return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2))) +} + +/** + * Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix + * @param {mat2} L the lower triangular matrix + * @param {mat2} D the diagonal matrix + * @param {mat2} U the upper triangular matrix + * @param {mat2} a the input matrix to factorize + */ + +function LDU(L, D, U, a) { + L[2] = a[2]/a[0]; + U[0] = a[0]; + U[1] = a[1]; + U[3] = a[3] - L[2] * U[1]; + return [L, D, U]; +} + +/** + * Adds two mat2's + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the first operand + * @param {mat2} b the second operand + * @returns {mat2} out + */ +function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; + return out; +} + +/** + * Subtracts matrix b from matrix a + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the first operand + * @param {mat2} b the second operand + * @returns {mat2} out + */ +function subtract(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + out[3] = a[3] - b[3]; + return out; +} + +/** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {mat2} a The first matrix. + * @param {mat2} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ +function exactEquals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; +} -var _particle = __webpack_require__(45); +/** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {mat2} a The first matrix. + * @param {mat2} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ +function equals(a, b) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + return (Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && + Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && + Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && + Math.abs(a3 - b3) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a3), Math.abs(b3))); +} -Object.keys(_particle).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _particle[key]; - } - }); -}); +/** + * Multiply each element of the matrix by a scalar. + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the matrix to scale + * @param {Number} b amount to scale the matrix's elements by + * @returns {mat2} out + */ +function multiplyScalar(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; + return out; +} -var _math = __webpack_require__(0); +/** + * Adds two mat2's after multiplying each element of the second operand by a scalar value. + * + * @param {mat2} out the receiving vector + * @param {mat2} a the first operand + * @param {mat2} b the second operand + * @param {Number} scale the amount to scale b's elements by before adding + * @returns {mat2} out + */ +function multiplyScalarAndAdd(out, a, b, scale) { + out[0] = a[0] + (b[0] * scale); + out[1] = a[1] + (b[1] * scale); + out[2] = a[2] + (b[2] * scale); + out[3] = a[3] + (b[3] * scale); + return out; +} -var math = _interopRequireWildcard(_math); +/** + * Alias for {@link mat2.multiply} + * @function + */ +const mul = multiply; +/* harmony export (immutable) */ __webpack_exports__["mul"] = mul; -var core = _interopRequireWildcard(_core); -var curve = _interopRequireWildcard(_curve); +/** + * Alias for {@link mat2.subtract} + * @function + */ +const sub = subtract; +/* harmony export (immutable) */ __webpack_exports__["sub"] = sub; -var eve = _interopRequireWildcard(_eve); -var particle = _interopRequireWildcard(_particle); -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } +/***/ }), +/* 69 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -exports.math = math; -var vec4 = math.vec4, - mat4 = math.mat4; +"use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +/* harmony export (immutable) */ __webpack_exports__["create"] = create; +/* harmony export (immutable) */ __webpack_exports__["clone"] = clone; +/* harmony export (immutable) */ __webpack_exports__["copy"] = copy; +/* harmony export (immutable) */ __webpack_exports__["identity"] = identity; +/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues; +/* harmony export (immutable) */ __webpack_exports__["set"] = set; +/* harmony export (immutable) */ __webpack_exports__["invert"] = invert; +/* harmony export (immutable) */ __webpack_exports__["determinant"] = determinant; +/* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply; +/* harmony export (immutable) */ __webpack_exports__["rotate"] = rotate; +/* harmony export (immutable) */ __webpack_exports__["scale"] = scale; +/* harmony export (immutable) */ __webpack_exports__["translate"] = translate; +/* harmony export (immutable) */ __webpack_exports__["fromRotation"] = fromRotation; +/* harmony export (immutable) */ __webpack_exports__["fromScaling"] = fromScaling; +/* harmony export (immutable) */ __webpack_exports__["fromTranslation"] = fromTranslation; +/* harmony export (immutable) */ __webpack_exports__["str"] = str; +/* harmony export (immutable) */ __webpack_exports__["frob"] = frob; +/* harmony export (immutable) */ __webpack_exports__["add"] = add; +/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract; +/* harmony export (immutable) */ __webpack_exports__["multiplyScalar"] = multiplyScalar; +/* harmony export (immutable) */ __webpack_exports__["multiplyScalarAndAdd"] = multiplyScalarAndAdd; +/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals; +/* harmony export (immutable) */ __webpack_exports__["equals"] = equals; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(3); +/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. -/** - * Register globals - */ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -core.store.Register({ +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. - paths: { - 'res': 'https://developers.eveonline.com/ccpwgl/assetpath/1097993/' - }, +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. */ - extensions: { - 'sm_hi': core.Tw2EffectRes, - 'sm_lo': core.Tw2EffectRes, - 'wbg': core.Tw2GeometryRes, - 'png': core.Tw2TextureRes, - 'cube': core.Tw2TextureRes, - 'mp4': core.Tw2VideoRes, - 'ogg': core.Tw2VideoRes, - 'webm': core.Tw2VideoRes - }, - constructors: [core, curve, eve, particle], - types: { - 'float': core.Tw2FloatParameter, - 'number': core.Tw2FloatParameter, - 'texture': core.Tw2TextureParameter, - 'vector2': core.Tw2Vector2Parameter, - 'vector3': core.Tw2Vector3Parameter, - 'vector4': core.Tw2Vector4Parameter, - 'matrix4': core.Tw2MatrixParameter - }, +/** + * 2x3 Matrix + * @module mat2d + * + * @description + * A mat2d contains six elements defined as: + *
+ * [a, c, tx,
+ *  b, d, ty]
+ * 
+ * This is a short form for the 3x3 matrix: + *
+ * [a, c, tx,
+ *  b, d, ty,
+ *  0, 0, 1]
+ * 
+ * The last row is ignored so the array is shorter and operations are faster. + */ - variables: { - 'WorldMat': mat4.create(), - 'ViewMat': mat4.create(), - 'ProjectionMat': mat4.create(), - 'ViewProjectionMat': mat4.create(), - 'ViewportSize': vec4.create(), - 'Time': vec4.create(), - 'u_DecalMatrix': mat4.create(), - 'u_InvDecalMatrix': mat4.create(), - 'EveSpaceSceneEnvMap': '', - 'EnvMap1': '', - 'EnvMap2': '', - 'EnvMap3': '', - 'ShadowLightness': 0, - 'OccluderValue': vec4.fromValues(1, 1, 0, 0), - 'LensflareFxOccScale': vec4.fromValues(1, 1, 0, 0), - 'LensflareFxDirectionScale': vec4.create() - } +/** + * Creates a new identity mat2d + * + * @returns {mat2d} a new 2x3 matrix + */ +function create() { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](6); + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + out[4] = 0; + out[5] = 0; + return out; +} -}); +/** + * Creates a new mat2d initialized with values from an existing matrix + * + * @param {mat2d} a matrix to clone + * @returns {mat2d} a new 2x3 matrix + */ +function clone(a) { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](6); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + return out; +} -/***/ }), -/* 65 */ -/***/ (function(module, exports, __webpack_require__) { +/** + * Copy the values from one mat2d to another + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the source matrix + * @returns {mat2d} out + */ +function copy(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + return out; +} -"use strict"; +/** + * Set a mat2d to the identity matrix + * + * @param {mat2d} out the receiving matrix + * @returns {mat2d} out + */ +function identity(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + out[4] = 0; + out[5] = 0; + return out; +} +/** + * Create a new mat2d with the given values + * + * @param {Number} a Component A (index 0) + * @param {Number} b Component B (index 1) + * @param {Number} c Component C (index 2) + * @param {Number} d Component D (index 3) + * @param {Number} tx Component TX (index 4) + * @param {Number} ty Component TY (index 5) + * @returns {mat2d} A new mat2d + */ +function fromValues(a, b, c, d, tx, ty) { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](6); + out[0] = a; + out[1] = b; + out[2] = c; + out[3] = d; + out[4] = tx; + out[5] = ty; + return out; +} -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2BatchAccumulator = undefined; +/** + * Set the components of a mat2d to the given values + * + * @param {mat2d} out the receiving matrix + * @param {Number} a Component A (index 0) + * @param {Number} b Component B (index 1) + * @param {Number} c Component C (index 2) + * @param {Number} d Component D (index 3) + * @param {Number} tx Component TX (index 4) + * @param {Number} ty Component TY (index 5) + * @returns {mat2d} out + */ +function set(out, a, b, c, d, tx, ty) { + out[0] = a; + out[1] = b; + out[2] = c; + out[3] = d; + out[4] = tx; + out[5] = ty; + return out; +} -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +/** + * Inverts a mat2d + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the source matrix + * @returns {mat2d} out + */ +function invert(out, a) { + let aa = a[0], ab = a[1], ac = a[2], ad = a[3]; + let atx = a[4], aty = a[5]; -var _Tw2Device = __webpack_require__(2); + let det = aa * ad - ab * ac; + if(!det){ + return null; + } + det = 1.0 / det; -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + out[0] = ad * det; + out[1] = -ab * det; + out[2] = -ac * det; + out[3] = aa * det; + out[4] = (ac * aty - ad * atx) * det; + out[5] = (ab * atx - aa * aty) * det; + return out; +} -/** - * Accumulates render batches for rendering - * - * @param {function} [sorting=null] - An optional function for sorting the collected render batches - * @property {Array.} batches - Accumulator render batches and/or child Tw2BatchAccumulators - * @property {function} _sortMethod - An optional method to sort batches before rendering them - * @class +/** + * Calculates the determinant of a mat2d + * + * @param {mat2d} a the source matrix + * @returns {Number} determinant of a */ -var Tw2BatchAccumulator = exports.Tw2BatchAccumulator = function () { - function Tw2BatchAccumulator() { - var sorting = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; +function determinant(a) { + return a[0] * a[3] - a[1] * a[2]; +} - _classCallCheck(this, Tw2BatchAccumulator); +/** + * Multiplies two mat2d's + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the first operand + * @param {mat2d} b the second operand + * @returns {mat2d} out + */ +function multiply(out, a, b) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; + let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5]; + out[0] = a0 * b0 + a2 * b1; + out[1] = a1 * b0 + a3 * b1; + out[2] = a0 * b2 + a2 * b3; + out[3] = a1 * b2 + a3 * b3; + out[4] = a0 * b4 + a2 * b5 + a4; + out[5] = a1 * b4 + a3 * b5 + a5; + return out; +} - this.batches = []; - this._sortMethod = sorting; - } +/** + * Rotates a mat2d by the given angle + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat2d} out + */ +function rotate(out, a, rad) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; + let s = Math.sin(rad); + let c = Math.cos(rad); + out[0] = a0 * c + a2 * s; + out[1] = a1 * c + a3 * s; + out[2] = a0 * -s + a2 * c; + out[3] = a1 * -s + a3 * c; + out[4] = a4; + out[5] = a5; + return out; +} - /** - * Commits a batch - * @param {Tw2BatchAccumulator|Tw2RenderBatch} batch - */ +/** + * Scales the mat2d by the dimensions in the given vec2 + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the matrix to translate + * @param {vec2} v the vec2 to scale the matrix by + * @returns {mat2d} out + **/ +function scale(out, a, v) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; + let v0 = v[0], v1 = v[1]; + out[0] = a0 * v0; + out[1] = a1 * v0; + out[2] = a2 * v1; + out[3] = a3 * v1; + out[4] = a4; + out[5] = a5; + return out; +} +/** + * Translates the mat2d by the dimensions in the given vec2 + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the matrix to translate + * @param {vec2} v the vec2 to translate the matrix by + * @returns {mat2d} out + **/ +function translate(out, a, v) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; + let v0 = v[0], v1 = v[1]; + out[0] = a0; + out[1] = a1; + out[2] = a2; + out[3] = a3; + out[4] = a0 * v0 + a2 * v1 + a4; + out[5] = a1 * v0 + a3 * v1 + a5; + return out; +} - _createClass(Tw2BatchAccumulator, [{ - key: 'Commit', - value: function Commit(batch) { - this.batches.push(batch); - } +/** + * Creates a matrix from a given angle + * This is equivalent to (but much faster than): + * + * mat2d.identity(dest); + * mat2d.rotate(dest, dest, rad); + * + * @param {mat2d} out mat2d receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat2d} out + */ +function fromRotation(out, rad) { + let s = Math.sin(rad), c = Math.cos(rad); + out[0] = c; + out[1] = s; + out[2] = -s; + out[3] = c; + out[4] = 0; + out[5] = 0; + return out; +} - /** - * Clears any accumulated render batches - */ +/** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat2d.identity(dest); + * mat2d.scale(dest, dest, vec); + * + * @param {mat2d} out mat2d receiving operation result + * @param {vec2} v Scaling vector + * @returns {mat2d} out + */ +function fromScaling(out, v) { + out[0] = v[0]; + out[1] = 0; + out[2] = 0; + out[3] = v[1]; + out[4] = 0; + out[5] = 0; + return out; +} - }, { - key: 'Clear', - value: function Clear() { - this.batches = []; - } +/** + * Creates a matrix from a vector translation + * This is equivalent to (but much faster than): + * + * mat2d.identity(dest); + * mat2d.translate(dest, dest, vec); + * + * @param {mat2d} out mat2d receiving operation result + * @param {vec2} v Translation vector + * @returns {mat2d} out + */ +function fromTranslation(out, v) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + out[4] = v[0]; + out[5] = v[1]; + return out; +} - /** - * Renders the accumulated render batches - * @param {string} [technique] - technique name - */ +/** + * Returns a string representation of a mat2d + * + * @param {mat2d} a matrix to represent as a string + * @returns {String} string representation of the matrix + */ +function str(a) { + return 'mat2d(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + + a[3] + ', ' + a[4] + ', ' + a[5] + ')'; +} - }, { - key: 'Render', - value: function Render() { - var technique = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Main'; +/** + * Returns Frobenius norm of a mat2d + * + * @param {mat2d} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm + */ +function frob(a) { + return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + 1)) +} - if (this._sortMethod) { - this.batches.sort(this._sortMethod); - } +/** + * Adds two mat2d's + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the first operand + * @param {mat2d} b the second operand + * @returns {mat2d} out + */ +function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; + out[4] = a[4] + b[4]; + out[5] = a[5] + b[5]; + return out; +} - for (var i = 0; i < this.batches.length; ++i) { - if (this.batches[i] instanceof Tw2BatchAccumulator) { - this.batches[i].Render(technique); - } else { - if (this.batches[i].renderMode !== _Tw2Device.device.RM_ANY) { - _Tw2Device.device.SetStandardStates(this.batches[i].renderMode); - } +/** + * Subtracts matrix b from matrix a + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the first operand + * @param {mat2d} b the second operand + * @returns {mat2d} out + */ +function subtract(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + out[3] = a[3] - b[3]; + out[4] = a[4] - b[4]; + out[5] = a[5] - b[5]; + return out; +} - _Tw2Device.device.perObjectData = this.batches[i].perObjectData; - this.batches[i].Commit(technique); - } - } - } - }]); +/** + * Multiply each element of the matrix by a scalar. + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the matrix to scale + * @param {Number} b amount to scale the matrix's elements by + * @returns {mat2d} out + */ +function multiplyScalar(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; + out[4] = a[4] * b; + out[5] = a[5] * b; + return out; +} - return Tw2BatchAccumulator; -}(); +/** + * Adds two mat2d's after multiplying each element of the second operand by a scalar value. + * + * @param {mat2d} out the receiving vector + * @param {mat2d} a the first operand + * @param {mat2d} b the second operand + * @param {Number} scale the amount to scale b's elements by before adding + * @returns {mat2d} out + */ +function multiplyScalarAndAdd(out, a, b, scale) { + out[0] = a[0] + (b[0] * scale); + out[1] = a[1] + (b[1] * scale); + out[2] = a[2] + (b[2] * scale); + out[3] = a[3] + (b[3] * scale); + out[4] = a[4] + (b[4] * scale); + out[5] = a[5] + (b[5] * scale); + return out; +} -/***/ }), -/* 66 */ -/***/ (function(module, exports, __webpack_require__) { +/** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {mat2d} a The first matrix. + * @param {mat2d} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ +function exactEquals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5]; +} -"use strict"; +/** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {mat2d} a The first matrix. + * @param {mat2d} b The second matrix. + * @returns {Boolean} True if the matrices are equal, false otherwise. + */ +function equals(a, b) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; + let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5]; + return (Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && + Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && + Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && + Math.abs(a3 - b3) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a3), Math.abs(b3)) && + Math.abs(a4 - b4) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a4), Math.abs(b4)) && + Math.abs(a5 - b5) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a5), Math.abs(b5))); +} + +/** + * Alias for {@link mat2d.multiply} + * @function + */ +const mul = multiply; +/* harmony export (immutable) */ __webpack_exports__["mul"] = mul; -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.vec2 = undefined; +/** + * Alias for {@link mat2d.subtract} + * @function + */ +const sub = subtract; +/* harmony export (immutable) */ __webpack_exports__["sub"] = sub; -var _glMatrix = __webpack_require__(11); -exports.vec2 = _glMatrix.vec2; /***/ }), -/* 67 */ +/* 70 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -13335,28 +13184,48 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony export (immutable) */ __webpack_exports__["create"] = create; /* harmony export (immutable) */ __webpack_exports__["clone"] = clone; /* harmony export (immutable) */ __webpack_exports__["copy"] = copy; -/* harmony export (immutable) */ __webpack_exports__["identity"] = identity; /* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues; /* harmony export (immutable) */ __webpack_exports__["set"] = set; +/* harmony export (immutable) */ __webpack_exports__["identity"] = identity; /* harmony export (immutable) */ __webpack_exports__["transpose"] = transpose; /* harmony export (immutable) */ __webpack_exports__["invert"] = invert; /* harmony export (immutable) */ __webpack_exports__["adjoint"] = adjoint; /* harmony export (immutable) */ __webpack_exports__["determinant"] = determinant; /* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply; -/* harmony export (immutable) */ __webpack_exports__["rotate"] = rotate; +/* harmony export (immutable) */ __webpack_exports__["translate"] = translate; /* harmony export (immutable) */ __webpack_exports__["scale"] = scale; -/* harmony export (immutable) */ __webpack_exports__["fromRotation"] = fromRotation; +/* harmony export (immutable) */ __webpack_exports__["rotate"] = rotate; +/* harmony export (immutable) */ __webpack_exports__["rotateX"] = rotateX; +/* harmony export (immutable) */ __webpack_exports__["rotateY"] = rotateY; +/* harmony export (immutable) */ __webpack_exports__["rotateZ"] = rotateZ; +/* harmony export (immutable) */ __webpack_exports__["fromTranslation"] = fromTranslation; /* harmony export (immutable) */ __webpack_exports__["fromScaling"] = fromScaling; +/* harmony export (immutable) */ __webpack_exports__["fromRotation"] = fromRotation; +/* harmony export (immutable) */ __webpack_exports__["fromXRotation"] = fromXRotation; +/* harmony export (immutable) */ __webpack_exports__["fromYRotation"] = fromYRotation; +/* harmony export (immutable) */ __webpack_exports__["fromZRotation"] = fromZRotation; +/* harmony export (immutable) */ __webpack_exports__["fromRotationTranslation"] = fromRotationTranslation; +/* harmony export (immutable) */ __webpack_exports__["getTranslation"] = getTranslation; +/* harmony export (immutable) */ __webpack_exports__["getScaling"] = getScaling; +/* harmony export (immutable) */ __webpack_exports__["getRotation"] = getRotation; +/* harmony export (immutable) */ __webpack_exports__["fromRotationTranslationScale"] = fromRotationTranslationScale; +/* harmony export (immutable) */ __webpack_exports__["fromRotationTranslationScaleOrigin"] = fromRotationTranslationScaleOrigin; +/* harmony export (immutable) */ __webpack_exports__["fromQuat"] = fromQuat; +/* harmony export (immutable) */ __webpack_exports__["frustum"] = frustum; +/* harmony export (immutable) */ __webpack_exports__["perspective"] = perspective; +/* harmony export (immutable) */ __webpack_exports__["perspectiveFromFieldOfView"] = perspectiveFromFieldOfView; +/* harmony export (immutable) */ __webpack_exports__["ortho"] = ortho; +/* harmony export (immutable) */ __webpack_exports__["lookAt"] = lookAt; +/* harmony export (immutable) */ __webpack_exports__["targetTo"] = targetTo; /* harmony export (immutable) */ __webpack_exports__["str"] = str; /* harmony export (immutable) */ __webpack_exports__["frob"] = frob; -/* harmony export (immutable) */ __webpack_exports__["LDU"] = LDU; /* harmony export (immutable) */ __webpack_exports__["add"] = add; /* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract; -/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals; -/* harmony export (immutable) */ __webpack_exports__["equals"] = equals; /* harmony export (immutable) */ __webpack_exports__["multiplyScalar"] = multiplyScalar; /* harmony export (immutable) */ __webpack_exports__["multiplyScalarAndAdd"] = multiplyScalarAndAdd; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(5); +/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals; +/* harmony export (immutable) */ __webpack_exports__["equals"] = equals; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(3); /* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. Permission is hereby granted, free of charge, to any person obtaining a copy @@ -13379,813 +13248,1498 @@ THE SOFTWARE. */ -/** - * 2x2 Matrix - * @module mat2 - */ +/** + * 4x4 Matrix + * @module mat4 + */ + +/** + * Creates a new identity mat4 + * + * @returns {mat4} a new 4x4 matrix + */ +function create() { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](16); + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} + +/** + * Creates a new mat4 initialized with values from an existing matrix + * + * @param {mat4} a matrix to clone + * @returns {mat4} a new 4x4 matrix + */ +function clone(a) { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](16); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + return out; +} + +/** + * Copy the values from one mat4 to another + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the source matrix + * @returns {mat4} out + */ +function copy(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + return out; +} + +/** + * Create a new mat4 with the given values + * + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m03 Component in column 0, row 3 position (index 3) + * @param {Number} m10 Component in column 1, row 0 position (index 4) + * @param {Number} m11 Component in column 1, row 1 position (index 5) + * @param {Number} m12 Component in column 1, row 2 position (index 6) + * @param {Number} m13 Component in column 1, row 3 position (index 7) + * @param {Number} m20 Component in column 2, row 0 position (index 8) + * @param {Number} m21 Component in column 2, row 1 position (index 9) + * @param {Number} m22 Component in column 2, row 2 position (index 10) + * @param {Number} m23 Component in column 2, row 3 position (index 11) + * @param {Number} m30 Component in column 3, row 0 position (index 12) + * @param {Number} m31 Component in column 3, row 1 position (index 13) + * @param {Number} m32 Component in column 3, row 2 position (index 14) + * @param {Number} m33 Component in column 3, row 3 position (index 15) + * @returns {mat4} A new mat4 + */ +function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](16); + out[0] = m00; + out[1] = m01; + out[2] = m02; + out[3] = m03; + out[4] = m10; + out[5] = m11; + out[6] = m12; + out[7] = m13; + out[8] = m20; + out[9] = m21; + out[10] = m22; + out[11] = m23; + out[12] = m30; + out[13] = m31; + out[14] = m32; + out[15] = m33; + return out; +} + +/** + * Set the components of a mat4 to the given values + * + * @param {mat4} out the receiving matrix + * @param {Number} m00 Component in column 0, row 0 position (index 0) + * @param {Number} m01 Component in column 0, row 1 position (index 1) + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m03 Component in column 0, row 3 position (index 3) + * @param {Number} m10 Component in column 1, row 0 position (index 4) + * @param {Number} m11 Component in column 1, row 1 position (index 5) + * @param {Number} m12 Component in column 1, row 2 position (index 6) + * @param {Number} m13 Component in column 1, row 3 position (index 7) + * @param {Number} m20 Component in column 2, row 0 position (index 8) + * @param {Number} m21 Component in column 2, row 1 position (index 9) + * @param {Number} m22 Component in column 2, row 2 position (index 10) + * @param {Number} m23 Component in column 2, row 3 position (index 11) + * @param {Number} m30 Component in column 3, row 0 position (index 12) + * @param {Number} m31 Component in column 3, row 1 position (index 13) + * @param {Number} m32 Component in column 3, row 2 position (index 14) + * @param {Number} m33 Component in column 3, row 3 position (index 15) + * @returns {mat4} out + */ +function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { + out[0] = m00; + out[1] = m01; + out[2] = m02; + out[3] = m03; + out[4] = m10; + out[5] = m11; + out[6] = m12; + out[7] = m13; + out[8] = m20; + out[9] = m21; + out[10] = m22; + out[11] = m23; + out[12] = m30; + out[13] = m31; + out[14] = m32; + out[15] = m33; + return out; +} + + +/** + * Set a mat4 to the identity matrix + * + * @param {mat4} out the receiving matrix + * @returns {mat4} out + */ +function identity(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} + +/** + * Transpose the values of a mat4 + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the source matrix + * @returns {mat4} out + */ +function transpose(out, a) { + // If we are transposing ourselves we can skip a few steps but have to cache some values + if (out === a) { + let a01 = a[1], a02 = a[2], a03 = a[3]; + let a12 = a[6], a13 = a[7]; + let a23 = a[11]; + + out[1] = a[4]; + out[2] = a[8]; + out[3] = a[12]; + out[4] = a01; + out[6] = a[9]; + out[7] = a[13]; + out[8] = a02; + out[9] = a12; + out[11] = a[14]; + out[12] = a03; + out[13] = a13; + out[14] = a23; + } else { + out[0] = a[0]; + out[1] = a[4]; + out[2] = a[8]; + out[3] = a[12]; + out[4] = a[1]; + out[5] = a[5]; + out[6] = a[9]; + out[7] = a[13]; + out[8] = a[2]; + out[9] = a[6]; + out[10] = a[10]; + out[11] = a[14]; + out[12] = a[3]; + out[13] = a[7]; + out[14] = a[11]; + out[15] = a[15]; + } + + return out; +} + +/** + * Inverts a mat4 + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the source matrix + * @returns {mat4} out + */ +function invert(out, a) { + let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + + let b00 = a00 * a11 - a01 * a10; + let b01 = a00 * a12 - a02 * a10; + let b02 = a00 * a13 - a03 * a10; + let b03 = a01 * a12 - a02 * a11; + let b04 = a01 * a13 - a03 * a11; + let b05 = a02 * a13 - a03 * a12; + let b06 = a20 * a31 - a21 * a30; + let b07 = a20 * a32 - a22 * a30; + let b08 = a20 * a33 - a23 * a30; + let b09 = a21 * a32 - a22 * a31; + let b10 = a21 * a33 - a23 * a31; + let b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) { + return null; + } + det = 1.0 / det; + + out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; + out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; + out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; + out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; + out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; + out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; + out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; + + return out; +} + +/** + * Calculates the adjugate of a mat4 + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the source matrix + * @returns {mat4} out + */ +function adjoint(out, a) { + let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + + out[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22)); + out[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); + out[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12)); + out[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); + out[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); + out[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22)); + out[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); + out[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12)); + out[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21)); + out[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); + out[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11)); + out[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); + out[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); + out[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21)); + out[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); + out[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11)); + return out; +} + +/** + * Calculates the determinant of a mat4 + * + * @param {mat4} a the source matrix + * @returns {Number} determinant of a + */ +function determinant(a) { + let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + + let b00 = a00 * a11 - a01 * a10; + let b01 = a00 * a12 - a02 * a10; + let b02 = a00 * a13 - a03 * a10; + let b03 = a01 * a12 - a02 * a11; + let b04 = a01 * a13 - a03 * a11; + let b05 = a02 * a13 - a03 * a12; + let b06 = a20 * a31 - a21 * a30; + let b07 = a20 * a32 - a22 * a30; + let b08 = a20 * a33 - a23 * a30; + let b09 = a21 * a32 - a22 * a31; + let b10 = a21 * a33 - a23 * a31; + let b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; +} /** - * Creates a new identity mat2 + * Multiplies two mat4s * - * @returns {mat2} a new 2x2 matrix + * @param {mat4} out the receiving matrix + * @param {mat4} a the first operand + * @param {mat4} b the second operand + * @returns {mat4} out */ -function create() { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](4); - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 1; +function multiply(out, a, b) { + let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + + // Cache only the current line of the second matrix + let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + out[0] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[1] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[2] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[3] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + + b0 = b[4]; b1 = b[5]; b2 = b[6]; b3 = b[7]; + out[4] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[5] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[6] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[7] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + + b0 = b[8]; b1 = b[9]; b2 = b[10]; b3 = b[11]; + out[8] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[9] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[10] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[11] = b0*a03 + b1*a13 + b2*a23 + b3*a33; + + b0 = b[12]; b1 = b[13]; b2 = b[14]; b3 = b[15]; + out[12] = b0*a00 + b1*a10 + b2*a20 + b3*a30; + out[13] = b0*a01 + b1*a11 + b2*a21 + b3*a31; + out[14] = b0*a02 + b1*a12 + b2*a22 + b3*a32; + out[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33; return out; } /** - * Creates a new mat2 initialized with values from an existing matrix + * Translate a mat4 by the given vector * - * @param {mat2} a matrix to clone - * @returns {mat2} a new 2x2 matrix + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to translate + * @param {vec3} v vector to translate by + * @returns {mat4} out */ -function clone(a) { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](4); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; +function translate(out, a, v) { + let x = v[0], y = v[1], z = v[2]; + let a00, a01, a02, a03; + let a10, a11, a12, a13; + let a20, a21, a22, a23; + + if (a === out) { + out[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; + out[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; + out[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; + out[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; + } else { + a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3]; + a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7]; + a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11]; + + out[0] = a00; out[1] = a01; out[2] = a02; out[3] = a03; + out[4] = a10; out[5] = a11; out[6] = a12; out[7] = a13; + out[8] = a20; out[9] = a21; out[10] = a22; out[11] = a23; + + out[12] = a00 * x + a10 * y + a20 * z + a[12]; + out[13] = a01 * x + a11 * y + a21 * z + a[13]; + out[14] = a02 * x + a12 * y + a22 * z + a[14]; + out[15] = a03 * x + a13 * y + a23 * z + a[15]; + } + return out; } /** - * Copy the values from one mat2 to another + * Scales the mat4 by the dimensions in the given vec3 not using vectorization * - * @param {mat2} out the receiving matrix - * @param {mat2} a the source matrix - * @returns {mat2} out - */ -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to scale + * @param {vec3} v the vec3 to scale the matrix by + * @returns {mat4} out + **/ +function scale(out, a, v) { + let x = v[0], y = v[1], z = v[2]; + + out[0] = a[0] * x; + out[1] = a[1] * x; + out[2] = a[2] * x; + out[3] = a[3] * x; + out[4] = a[4] * y; + out[5] = a[5] * y; + out[6] = a[6] * y; + out[7] = a[7] * y; + out[8] = a[8] * z; + out[9] = a[9] * z; + out[10] = a[10] * z; + out[11] = a[11] * z; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; return out; } /** - * Set a mat2 to the identity matrix + * Rotates a mat4 by the given angle around the given axis * - * @param {mat2} out the receiving matrix - * @returns {mat2} out + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @param {vec3} axis the axis to rotate around + * @returns {mat4} out */ -function identity(out) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 1; +function rotate(out, a, rad, axis) { + let x = axis[0], y = axis[1], z = axis[2]; + let len = Math.sqrt(x * x + y * y + z * z); + let s, c, t; + let a00, a01, a02, a03; + let a10, a11, a12, a13; + let a20, a21, a22, a23; + let b00, b01, b02; + let b10, b11, b12; + let b20, b21, b22; + + if (Math.abs(len) < __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]) { return null; } + + len = 1 / len; + x *= len; + y *= len; + z *= len; + + s = Math.sin(rad); + c = Math.cos(rad); + t = 1 - c; + + a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3]; + a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7]; + a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11]; + + // Construct the elements of the rotation matrix + b00 = x * x * t + c; b01 = y * x * t + z * s; b02 = z * x * t - y * s; + b10 = x * y * t - z * s; b11 = y * y * t + c; b12 = z * y * t + x * s; + b20 = x * z * t + y * s; b21 = y * z * t - x * s; b22 = z * z * t + c; + + // Perform rotation-specific matrix multiplication + out[0] = a00 * b00 + a10 * b01 + a20 * b02; + out[1] = a01 * b00 + a11 * b01 + a21 * b02; + out[2] = a02 * b00 + a12 * b01 + a22 * b02; + out[3] = a03 * b00 + a13 * b01 + a23 * b02; + out[4] = a00 * b10 + a10 * b11 + a20 * b12; + out[5] = a01 * b10 + a11 * b11 + a21 * b12; + out[6] = a02 * b10 + a12 * b11 + a22 * b12; + out[7] = a03 * b10 + a13 * b11 + a23 * b12; + out[8] = a00 * b20 + a10 * b21 + a20 * b22; + out[9] = a01 * b20 + a11 * b21 + a21 * b22; + out[10] = a02 * b20 + a12 * b21 + a22 * b22; + out[11] = a03 * b20 + a13 * b21 + a23 * b22; + + if (a !== out) { // If the source and destination differ, copy the unchanged last row + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } return out; } /** - * Create a new mat2 with the given values + * Rotates a matrix by the given angle around the X axis * - * @param {Number} m00 Component in column 0, row 0 position (index 0) - * @param {Number} m01 Component in column 0, row 1 position (index 1) - * @param {Number} m10 Component in column 1, row 0 position (index 2) - * @param {Number} m11 Component in column 1, row 1 position (index 3) - * @returns {mat2} out A new 2x2 matrix + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out */ -function fromValues(m00, m01, m10, m11) { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](4); - out[0] = m00; - out[1] = m01; - out[2] = m10; - out[3] = m11; +function rotateX(out, a, rad) { + let s = Math.sin(rad); + let c = Math.cos(rad); + let a10 = a[4]; + let a11 = a[5]; + let a12 = a[6]; + let a13 = a[7]; + let a20 = a[8]; + let a21 = a[9]; + let a22 = a[10]; + let a23 = a[11]; + + if (a !== out) { // If the source and destination differ, copy the unchanged rows + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } + + // Perform axis-specific matrix multiplication + out[4] = a10 * c + a20 * s; + out[5] = a11 * c + a21 * s; + out[6] = a12 * c + a22 * s; + out[7] = a13 * c + a23 * s; + out[8] = a20 * c - a10 * s; + out[9] = a21 * c - a11 * s; + out[10] = a22 * c - a12 * s; + out[11] = a23 * c - a13 * s; return out; } /** - * Set the components of a mat2 to the given values + * Rotates a matrix by the given angle around the Y axis * - * @param {mat2} out the receiving matrix - * @param {Number} m00 Component in column 0, row 0 position (index 0) - * @param {Number} m01 Component in column 0, row 1 position (index 1) - * @param {Number} m10 Component in column 1, row 0 position (index 2) - * @param {Number} m11 Component in column 1, row 1 position (index 3) - * @returns {mat2} out + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out */ -function set(out, m00, m01, m10, m11) { - out[0] = m00; - out[1] = m01; - out[2] = m10; - out[3] = m11; +function rotateY(out, a, rad) { + let s = Math.sin(rad); + let c = Math.cos(rad); + let a00 = a[0]; + let a01 = a[1]; + let a02 = a[2]; + let a03 = a[3]; + let a20 = a[8]; + let a21 = a[9]; + let a22 = a[10]; + let a23 = a[11]; + + if (a !== out) { // If the source and destination differ, copy the unchanged rows + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } + + // Perform axis-specific matrix multiplication + out[0] = a00 * c - a20 * s; + out[1] = a01 * c - a21 * s; + out[2] = a02 * c - a22 * s; + out[3] = a03 * c - a23 * s; + out[8] = a00 * s + a20 * c; + out[9] = a01 * s + a21 * c; + out[10] = a02 * s + a22 * c; + out[11] = a03 * s + a23 * c; return out; } /** - * Transpose the values of a mat2 + * Rotates a matrix by the given angle around the Z axis * - * @param {mat2} out the receiving matrix - * @param {mat2} a the source matrix - * @returns {mat2} out + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out */ -function transpose(out, a) { - // If we are transposing ourselves we can skip a few steps but have to cache - // some values - if (out === a) { - let a1 = a[1]; - out[1] = a[2]; - out[2] = a1; - } else { - out[0] = a[0]; - out[1] = a[2]; - out[2] = a[1]; - out[3] = a[3]; +function rotateZ(out, a, rad) { + let s = Math.sin(rad); + let c = Math.cos(rad); + let a00 = a[0]; + let a01 = a[1]; + let a02 = a[2]; + let a03 = a[3]; + let a10 = a[4]; + let a11 = a[5]; + let a12 = a[6]; + let a13 = a[7]; + + if (a !== out) { // If the source and destination differ, copy the unchanged last row + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; } + // Perform axis-specific matrix multiplication + out[0] = a00 * c + a10 * s; + out[1] = a01 * c + a11 * s; + out[2] = a02 * c + a12 * s; + out[3] = a03 * c + a13 * s; + out[4] = a10 * c - a00 * s; + out[5] = a11 * c - a01 * s; + out[6] = a12 * c - a02 * s; + out[7] = a13 * c - a03 * s; return out; } /** - * Inverts a mat2 + * Creates a matrix from a vector translation + * This is equivalent to (but much faster than): * - * @param {mat2} out the receiving matrix - * @param {mat2} a the source matrix - * @returns {mat2} out + * mat4.identity(dest); + * mat4.translate(dest, dest, vec); + * + * @param {mat4} out mat4 receiving operation result + * @param {vec3} v Translation vector + * @returns {mat4} out */ -function invert(out, a) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - - // Calculate the determinant - let det = a0 * a3 - a2 * a1; - - if (!det) { - return null; - } - det = 1.0 / det; - - out[0] = a3 * det; - out[1] = -a1 * det; - out[2] = -a2 * det; - out[3] = a0 * det; - +function fromTranslation(out, v) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = v[0]; + out[13] = v[1]; + out[14] = v[2]; + out[15] = 1; return out; } /** - * Calculates the adjugate of a mat2 + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): * - * @param {mat2} out the receiving matrix - * @param {mat2} a the source matrix - * @returns {mat2} out + * mat4.identity(dest); + * mat4.scale(dest, dest, vec); + * + * @param {mat4} out mat4 receiving operation result + * @param {vec3} v Scaling vector + * @returns {mat4} out */ -function adjoint(out, a) { - // Caching this value is nessecary if out == a - let a0 = a[0]; - out[0] = a[3]; - out[1] = -a[1]; - out[2] = -a[2]; - out[3] = a0; - +function fromScaling(out, v) { + out[0] = v[0]; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = v[1]; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = v[2]; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; return out; } /** - * Calculates the determinant of a mat2 + * Creates a matrix from a given angle around a given axis + * This is equivalent to (but much faster than): * - * @param {mat2} a the source matrix - * @returns {Number} determinant of a + * mat4.identity(dest); + * mat4.rotate(dest, dest, rad, axis); + * + * @param {mat4} out mat4 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @param {vec3} axis the axis to rotate around + * @returns {mat4} out */ -function determinant(a) { - return a[0] * a[3] - a[2] * a[1]; +function fromRotation(out, rad, axis) { + let x = axis[0], y = axis[1], z = axis[2]; + let len = Math.sqrt(x * x + y * y + z * z); + let s, c, t; + + if (Math.abs(len) < __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]) { return null; } + + len = 1 / len; + x *= len; + y *= len; + z *= len; + + s = Math.sin(rad); + c = Math.cos(rad); + t = 1 - c; + + // Perform rotation-specific matrix multiplication + out[0] = x * x * t + c; + out[1] = y * x * t + z * s; + out[2] = z * x * t - y * s; + out[3] = 0; + out[4] = x * y * t - z * s; + out[5] = y * y * t + c; + out[6] = z * y * t + x * s; + out[7] = 0; + out[8] = x * z * t + y * s; + out[9] = y * z * t - x * s; + out[10] = z * z * t + c; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; } /** - * Multiplies two mat2's + * Creates a matrix from the given angle around the X axis + * This is equivalent to (but much faster than): * - * @param {mat2} out the receiving matrix - * @param {mat2} a the first operand - * @param {mat2} b the second operand - * @returns {mat2} out + * mat4.identity(dest); + * mat4.rotateX(dest, dest, rad); + * + * @param {mat4} out mat4 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out */ -function multiply(out, a, b) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - out[0] = a0 * b0 + a2 * b1; - out[1] = a1 * b0 + a3 * b1; - out[2] = a0 * b2 + a2 * b3; - out[3] = a1 * b2 + a3 * b3; +function fromXRotation(out, rad) { + let s = Math.sin(rad); + let c = Math.cos(rad); + + // Perform axis-specific matrix multiplication + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = c; + out[6] = s; + out[7] = 0; + out[8] = 0; + out[9] = -s; + out[10] = c; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; return out; } /** - * Rotates a mat2 by the given angle + * Creates a matrix from the given angle around the Y axis + * This is equivalent to (but much faster than): * - * @param {mat2} out the receiving matrix - * @param {mat2} a the matrix to rotate + * mat4.identity(dest); + * mat4.rotateY(dest, dest, rad); + * + * @param {mat4} out mat4 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2} out + * @returns {mat4} out */ -function rotate(out, a, rad) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; +function fromYRotation(out, rad) { let s = Math.sin(rad); let c = Math.cos(rad); - out[0] = a0 * c + a2 * s; - out[1] = a1 * c + a3 * s; - out[2] = a0 * -s + a2 * c; - out[3] = a1 * -s + a3 * c; - return out; -} -/** - * Scales the mat2 by the dimensions in the given vec2 - * - * @param {mat2} out the receiving matrix - * @param {mat2} a the matrix to rotate - * @param {vec2} v the vec2 to scale the matrix by - * @returns {mat2} out - **/ -function scale(out, a, v) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - let v0 = v[0], v1 = v[1]; - out[0] = a0 * v0; - out[1] = a1 * v0; - out[2] = a2 * v1; - out[3] = a3 * v1; + // Perform axis-specific matrix multiplication + out[0] = c; + out[1] = 0; + out[2] = -s; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = s; + out[9] = 0; + out[10] = c; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; return out; } /** - * Creates a matrix from a given angle + * Creates a matrix from the given angle around the Z axis * This is equivalent to (but much faster than): * - * mat2.identity(dest); - * mat2.rotate(dest, dest, rad); + * mat4.identity(dest); + * mat4.rotateZ(dest, dest, rad); * - * @param {mat2} out mat2 receiving operation result + * @param {mat4} out mat4 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2} out + * @returns {mat4} out */ -function fromRotation(out, rad) { +function fromZRotation(out, rad) { let s = Math.sin(rad); let c = Math.cos(rad); - out[0] = c; - out[1] = s; - out[2] = -s; - out[3] = c; + + // Perform axis-specific matrix multiplication + out[0] = c; + out[1] = s; + out[2] = 0; + out[3] = 0; + out[4] = -s; + out[5] = c; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; return out; } /** - * Creates a matrix from a vector scaling + * Creates a matrix from a quaternion rotation and vector translation * This is equivalent to (but much faster than): * - * mat2.identity(dest); - * mat2.scale(dest, dest, vec); + * mat4.identity(dest); + * mat4.translate(dest, vec); + * let quatMat = mat4.create(); + * quat4.toMat4(quat, quatMat); + * mat4.multiply(dest, quatMat); * - * @param {mat2} out mat2 receiving operation result - * @param {vec2} v Scaling vector - * @returns {mat2} out + * @param {mat4} out mat4 receiving operation result + * @param {quat4} q Rotation quaternion + * @param {vec3} v Translation vector + * @returns {mat4} out */ -function fromScaling(out, v) { - out[0] = v[0]; - out[1] = 0; - out[2] = 0; - out[3] = v[1]; +function fromRotationTranslation(out, q, v) { + // Quaternion math + let x = q[0], y = q[1], z = q[2], w = q[3]; + let x2 = x + x; + let y2 = y + y; + let z2 = z + z; + + let xx = x * x2; + let xy = x * y2; + let xz = x * z2; + let yy = y * y2; + let yz = y * z2; + let zz = z * z2; + let wx = w * x2; + let wy = w * y2; + let wz = w * z2; + + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + out[12] = v[0]; + out[13] = v[1]; + out[14] = v[2]; + out[15] = 1; + return out; } /** - * Returns a string representation of a mat2 - * - * @param {mat2} a matrix to represent as a string - * @returns {String} string representation of the matrix + * Returns the translation vector component of a transformation + * matrix. If a matrix is built with fromRotationTranslation, + * the returned vector will be the same as the translation vector + * originally supplied. + * @param {vec3} out Vector to receive translation component + * @param {mat4} mat Matrix to be decomposed (input) + * @return {vec3} out */ -function str(a) { - return 'mat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')'; -} +function getTranslation(out, mat) { + out[0] = mat[12]; + out[1] = mat[13]; + out[2] = mat[14]; -/** - * Returns Frobenius norm of a mat2 - * - * @param {mat2} a the matrix to calculate Frobenius norm of - * @returns {Number} Frobenius norm - */ -function frob(a) { - return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2))) + return out; } /** - * Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix - * @param {mat2} L the lower triangular matrix - * @param {mat2} D the diagonal matrix - * @param {mat2} U the upper triangular matrix - * @param {mat2} a the input matrix to factorize + * Returns the scaling factor component of a transformation + * matrix. If a matrix is built with fromRotationTranslationScale + * with a normalized Quaternion paramter, the returned vector will be + * the same as the scaling vector + * originally supplied. + * @param {vec3} out Vector to receive scaling factor component + * @param {mat4} mat Matrix to be decomposed (input) + * @return {vec3} out */ +function getScaling(out, mat) { + let m11 = mat[0]; + let m12 = mat[1]; + let m13 = mat[2]; + let m21 = mat[4]; + let m22 = mat[5]; + let m23 = mat[6]; + let m31 = mat[8]; + let m32 = mat[9]; + let m33 = mat[10]; -function LDU(L, D, U, a) { - L[2] = a[2]/a[0]; - U[0] = a[0]; - U[1] = a[1]; - U[3] = a[3] - L[2] * U[1]; - return [L, D, U]; -} + out[0] = Math.sqrt(m11 * m11 + m12 * m12 + m13 * m13); + out[1] = Math.sqrt(m21 * m21 + m22 * m22 + m23 * m23); + out[2] = Math.sqrt(m31 * m31 + m32 * m32 + m33 * m33); -/** - * Adds two mat2's - * - * @param {mat2} out the receiving matrix - * @param {mat2} a the first operand - * @param {mat2} b the second operand - * @returns {mat2} out - */ -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - out[3] = a[3] + b[3]; return out; } /** - * Subtracts matrix b from matrix a - * - * @param {mat2} out the receiving matrix - * @param {mat2} a the first operand - * @param {mat2} b the second operand - * @returns {mat2} out + * Returns a quaternion representing the rotational component + * of a transformation matrix. If a matrix is built with + * fromRotationTranslation, the returned quaternion will be the + * same as the quaternion originally supplied. + * @param {quat} out Quaternion to receive the rotation component + * @param {mat4} mat Matrix to be decomposed (input) + * @return {quat} out */ -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; - out[3] = a[3] - b[3]; +function getRotation(out, mat) { + // Algorithm taken from http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm + let trace = mat[0] + mat[5] + mat[10]; + let S = 0; + + if (trace > 0) { + S = Math.sqrt(trace + 1.0) * 2; + out[3] = 0.25 * S; + out[0] = (mat[6] - mat[9]) / S; + out[1] = (mat[8] - mat[2]) / S; + out[2] = (mat[1] - mat[4]) / S; + } else if ((mat[0] > mat[5])&(mat[0] > mat[10])) { + S = Math.sqrt(1.0 + mat[0] - mat[5] - mat[10]) * 2; + out[3] = (mat[6] - mat[9]) / S; + out[0] = 0.25 * S; + out[1] = (mat[1] + mat[4]) / S; + out[2] = (mat[8] + mat[2]) / S; + } else if (mat[5] > mat[10]) { + S = Math.sqrt(1.0 + mat[5] - mat[0] - mat[10]) * 2; + out[3] = (mat[8] - mat[2]) / S; + out[0] = (mat[1] + mat[4]) / S; + out[1] = 0.25 * S; + out[2] = (mat[6] + mat[9]) / S; + } else { + S = Math.sqrt(1.0 + mat[10] - mat[0] - mat[5]) * 2; + out[3] = (mat[1] - mat[4]) / S; + out[0] = (mat[8] + mat[2]) / S; + out[1] = (mat[6] + mat[9]) / S; + out[2] = 0.25 * S; + } + return out; } /** - * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * Creates a matrix from a quaternion rotation, vector translation and vector scale + * This is equivalent to (but much faster than): * - * @param {mat2} a The first matrix. - * @param {mat2} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. - */ -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; -} - -/** - * Returns whether or not the matrices have approximately the same elements in the same position. + * mat4.identity(dest); + * mat4.translate(dest, vec); + * let quatMat = mat4.create(); + * quat4.toMat4(quat, quatMat); + * mat4.multiply(dest, quatMat); + * mat4.scale(dest, scale) * - * @param {mat2} a The first matrix. - * @param {mat2} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. + * @param {mat4} out mat4 receiving operation result + * @param {quat4} q Rotation quaternion + * @param {vec3} v Translation vector + * @param {vec3} s Scaling vector + * @returns {mat4} out */ -function equals(a, b) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - return (Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && - Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && - Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && - Math.abs(a3 - b3) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a3), Math.abs(b3))); -} +function fromRotationTranslationScale(out, q, v, s) { + // Quaternion math + let x = q[0], y = q[1], z = q[2], w = q[3]; + let x2 = x + x; + let y2 = y + y; + let z2 = z + z; -/** - * Multiply each element of the matrix by a scalar. - * - * @param {mat2} out the receiving matrix - * @param {mat2} a the matrix to scale - * @param {Number} b amount to scale the matrix's elements by - * @returns {mat2} out - */ -function multiplyScalar(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - out[3] = a[3] * b; - return out; -} + let xx = x * x2; + let xy = x * y2; + let xz = x * z2; + let yy = y * y2; + let yz = y * z2; + let zz = z * z2; + let wx = w * x2; + let wy = w * y2; + let wz = w * z2; + let sx = s[0]; + let sy = s[1]; + let sz = s[2]; + + out[0] = (1 - (yy + zz)) * sx; + out[1] = (xy + wz) * sx; + out[2] = (xz - wy) * sx; + out[3] = 0; + out[4] = (xy - wz) * sy; + out[5] = (1 - (xx + zz)) * sy; + out[6] = (yz + wx) * sy; + out[7] = 0; + out[8] = (xz + wy) * sz; + out[9] = (yz - wx) * sz; + out[10] = (1 - (xx + yy)) * sz; + out[11] = 0; + out[12] = v[0]; + out[13] = v[1]; + out[14] = v[2]; + out[15] = 1; -/** - * Adds two mat2's after multiplying each element of the second operand by a scalar value. - * - * @param {mat2} out the receiving vector - * @param {mat2} a the first operand - * @param {mat2} b the second operand - * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat2} out - */ -function multiplyScalarAndAdd(out, a, b, scale) { - out[0] = a[0] + (b[0] * scale); - out[1] = a[1] + (b[1] * scale); - out[2] = a[2] + (b[2] * scale); - out[3] = a[3] + (b[3] * scale); return out; } /** - * Alias for {@link mat2.multiply} - * @function - */ -const mul = multiply; -/* harmony export (immutable) */ __webpack_exports__["mul"] = mul; - - -/** - * Alias for {@link mat2.subtract} - * @function + * Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, vec); + * mat4.translate(dest, origin); + * let quatMat = mat4.create(); + * quat4.toMat4(quat, quatMat); + * mat4.multiply(dest, quatMat); + * mat4.scale(dest, scale) + * mat4.translate(dest, negativeOrigin); + * + * @param {mat4} out mat4 receiving operation result + * @param {quat4} q Rotation quaternion + * @param {vec3} v Translation vector + * @param {vec3} s Scaling vector + * @param {vec3} o The origin vector around which to scale and rotate + * @returns {mat4} out */ -const sub = subtract; -/* harmony export (immutable) */ __webpack_exports__["sub"] = sub; - - - -/***/ }), -/* 68 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony export (immutable) */ __webpack_exports__["create"] = create; -/* harmony export (immutable) */ __webpack_exports__["clone"] = clone; -/* harmony export (immutable) */ __webpack_exports__["copy"] = copy; -/* harmony export (immutable) */ __webpack_exports__["identity"] = identity; -/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues; -/* harmony export (immutable) */ __webpack_exports__["set"] = set; -/* harmony export (immutable) */ __webpack_exports__["invert"] = invert; -/* harmony export (immutable) */ __webpack_exports__["determinant"] = determinant; -/* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply; -/* harmony export (immutable) */ __webpack_exports__["rotate"] = rotate; -/* harmony export (immutable) */ __webpack_exports__["scale"] = scale; -/* harmony export (immutable) */ __webpack_exports__["translate"] = translate; -/* harmony export (immutable) */ __webpack_exports__["fromRotation"] = fromRotation; -/* harmony export (immutable) */ __webpack_exports__["fromScaling"] = fromScaling; -/* harmony export (immutable) */ __webpack_exports__["fromTranslation"] = fromTranslation; -/* harmony export (immutable) */ __webpack_exports__["str"] = str; -/* harmony export (immutable) */ __webpack_exports__["frob"] = frob; -/* harmony export (immutable) */ __webpack_exports__["add"] = add; -/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract; -/* harmony export (immutable) */ __webpack_exports__["multiplyScalar"] = multiplyScalar; -/* harmony export (immutable) */ __webpack_exports__["multiplyScalarAndAdd"] = multiplyScalarAndAdd; -/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals; -/* harmony export (immutable) */ __webpack_exports__["equals"] = equals; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(5); -/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. */ +function fromRotationTranslationScaleOrigin(out, q, v, s, o) { + // Quaternion math + let x = q[0], y = q[1], z = q[2], w = q[3]; + let x2 = x + x; + let y2 = y + y; + let z2 = z + z; + let xx = x * x2; + let xy = x * y2; + let xz = x * z2; + let yy = y * y2; + let yz = y * z2; + let zz = z * z2; + let wx = w * x2; + let wy = w * y2; + let wz = w * z2; + let sx = s[0]; + let sy = s[1]; + let sz = s[2]; -/** - * 2x3 Matrix - * @module mat2d - * - * @description - * A mat2d contains six elements defined as: - *
- * [a, c, tx,
- *  b, d, ty]
- * 
- * This is a short form for the 3x3 matrix: - *
- * [a, c, tx,
- *  b, d, ty,
- *  0, 0, 1]
- * 
- * The last row is ignored so the array is shorter and operations are faster. - */ + let ox = o[0]; + let oy = o[1]; + let oz = o[2]; + + out[0] = (1 - (yy + zz)) * sx; + out[1] = (xy + wz) * sx; + out[2] = (xz - wy) * sx; + out[3] = 0; + out[4] = (xy - wz) * sy; + out[5] = (1 - (xx + zz)) * sy; + out[6] = (yz + wx) * sy; + out[7] = 0; + out[8] = (xz + wy) * sz; + out[9] = (yz - wx) * sz; + out[10] = (1 - (xx + yy)) * sz; + out[11] = 0; + out[12] = v[0] + ox - (out[0] * ox + out[4] * oy + out[8] * oz); + out[13] = v[1] + oy - (out[1] * ox + out[5] * oy + out[9] * oz); + out[14] = v[2] + oz - (out[2] * ox + out[6] * oy + out[10] * oz); + out[15] = 1; -/** - * Creates a new identity mat2d - * - * @returns {mat2d} a new 2x3 matrix - */ -function create() { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](6); - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 1; - out[4] = 0; - out[5] = 0; return out; } /** - * Creates a new mat2d initialized with values from an existing matrix + * Calculates a 4x4 matrix from the given quaternion * - * @param {mat2d} a matrix to clone - * @returns {mat2d} a new 2x3 matrix + * @param {mat4} out mat4 receiving operation result + * @param {quat} q Quaternion to create matrix from + * + * @returns {mat4} out */ -function clone(a) { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](6); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; +function fromQuat(out, q) { + let x = q[0], y = q[1], z = q[2], w = q[3]; + let x2 = x + x; + let y2 = y + y; + let z2 = z + z; + + let xx = x * x2; + let yx = y * x2; + let yy = y * y2; + let zx = z * x2; + let zy = z * y2; + let zz = z * z2; + let wx = w * x2; + let wy = w * y2; + let wz = w * z2; + + out[0] = 1 - yy - zz; + out[1] = yx + wz; + out[2] = zx - wy; + out[3] = 0; + + out[4] = yx - wz; + out[5] = 1 - xx - zz; + out[6] = zy + wx; + out[7] = 0; + + out[8] = zx + wy; + out[9] = zy - wx; + out[10] = 1 - xx - yy; + out[11] = 0; + + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; } /** - * Copy the values from one mat2d to another + * Generates a frustum matrix with the given bounds * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the source matrix - * @returns {mat2d} out + * @param {mat4} out mat4 frustum matrix will be written into + * @param {Number} left Left bound of the frustum + * @param {Number} right Right bound of the frustum + * @param {Number} bottom Bottom bound of the frustum + * @param {Number} top Top bound of the frustum + * @param {Number} near Near bound of the frustum + * @param {Number} far Far bound of the frustum + * @returns {mat4} out */ -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; +function frustum(out, left, right, bottom, top, near, far) { + let rl = 1 / (right - left); + let tb = 1 / (top - bottom); + let nf = 1 / (near - far); + out[0] = (near * 2) * rl; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = (near * 2) * tb; + out[6] = 0; + out[7] = 0; + out[8] = (right + left) * rl; + out[9] = (top + bottom) * tb; + out[10] = (far + near) * nf; + out[11] = -1; + out[12] = 0; + out[13] = 0; + out[14] = (far * near * 2) * nf; + out[15] = 0; return out; } /** - * Set a mat2d to the identity matrix + * Generates a perspective projection matrix with the given bounds * - * @param {mat2d} out the receiving matrix - * @returns {mat2d} out + * @param {mat4} out mat4 frustum matrix will be written into + * @param {number} fovy Vertical field of view in radians + * @param {number} aspect Aspect ratio. typically viewport width/height + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum + * @returns {mat4} out */ -function identity(out) { - out[0] = 1; +function perspective(out, fovy, aspect, near, far) { + let f = 1.0 / Math.tan(fovy / 2); + let nf = 1 / (near - far); + out[0] = f / aspect; out[1] = 0; out[2] = 0; - out[3] = 1; + out[3] = 0; out[4] = 0; - out[5] = 0; + out[5] = f; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = (far + near) * nf; + out[11] = -1; + out[12] = 0; + out[13] = 0; + out[14] = (2 * far * near) * nf; + out[15] = 0; return out; } /** - * Create a new mat2d with the given values + * Generates a perspective projection matrix with the given field of view. + * This is primarily useful for generating projection matrices to be used + * with the still experiemental WebVR API. * - * @param {Number} a Component A (index 0) - * @param {Number} b Component B (index 1) - * @param {Number} c Component C (index 2) - * @param {Number} d Component D (index 3) - * @param {Number} tx Component TX (index 4) - * @param {Number} ty Component TY (index 5) - * @returns {mat2d} A new mat2d + * @param {mat4} out mat4 frustum matrix will be written into + * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum + * @returns {mat4} out */ -function fromValues(a, b, c, d, tx, ty) { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](6); - out[0] = a; - out[1] = b; - out[2] = c; - out[3] = d; - out[4] = tx; - out[5] = ty; +function perspectiveFromFieldOfView(out, fov, near, far) { + let upTan = Math.tan(fov.upDegrees * Math.PI/180.0); + let downTan = Math.tan(fov.downDegrees * Math.PI/180.0); + let leftTan = Math.tan(fov.leftDegrees * Math.PI/180.0); + let rightTan = Math.tan(fov.rightDegrees * Math.PI/180.0); + let xScale = 2.0 / (leftTan + rightTan); + let yScale = 2.0 / (upTan + downTan); + + out[0] = xScale; + out[1] = 0.0; + out[2] = 0.0; + out[3] = 0.0; + out[4] = 0.0; + out[5] = yScale; + out[6] = 0.0; + out[7] = 0.0; + out[8] = -((leftTan - rightTan) * xScale * 0.5); + out[9] = ((upTan - downTan) * yScale * 0.5); + out[10] = far / (near - far); + out[11] = -1.0; + out[12] = 0.0; + out[13] = 0.0; + out[14] = (far * near) / (near - far); + out[15] = 0.0; return out; } /** - * Set the components of a mat2d to the given values + * Generates a orthogonal projection matrix with the given bounds * - * @param {mat2d} out the receiving matrix - * @param {Number} a Component A (index 0) - * @param {Number} b Component B (index 1) - * @param {Number} c Component C (index 2) - * @param {Number} d Component D (index 3) - * @param {Number} tx Component TX (index 4) - * @param {Number} ty Component TY (index 5) - * @returns {mat2d} out + * @param {mat4} out mat4 frustum matrix will be written into + * @param {number} left Left bound of the frustum + * @param {number} right Right bound of the frustum + * @param {number} bottom Bottom bound of the frustum + * @param {number} top Top bound of the frustum + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum + * @returns {mat4} out */ -function set(out, a, b, c, d, tx, ty) { - out[0] = a; - out[1] = b; - out[2] = c; - out[3] = d; - out[4] = tx; - out[5] = ty; +function ortho(out, left, right, bottom, top, near, far) { + let lr = 1 / (left - right); + let bt = 1 / (bottom - top); + let nf = 1 / (near - far); + out[0] = -2 * lr; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = -2 * bt; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 2 * nf; + out[11] = 0; + out[12] = (left + right) * lr; + out[13] = (top + bottom) * bt; + out[14] = (far + near) * nf; + out[15] = 1; return out; } /** - * Inverts a mat2d + * Generates a look-at matrix with the given eye position, focal point, and up axis * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the source matrix - * @returns {mat2d} out + * @param {mat4} out mat4 frustum matrix will be written into + * @param {vec3} eye Position of the viewer + * @param {vec3} center Point the viewer is looking at + * @param {vec3} up vec3 pointing up + * @returns {mat4} out */ -function invert(out, a) { - let aa = a[0], ab = a[1], ac = a[2], ad = a[3]; - let atx = a[4], aty = a[5]; +function lookAt(out, eye, center, up) { + let x0, x1, x2, y0, y1, y2, z0, z1, z2, len; + let eyex = eye[0]; + let eyey = eye[1]; + let eyez = eye[2]; + let upx = up[0]; + let upy = up[1]; + let upz = up[2]; + let centerx = center[0]; + let centery = center[1]; + let centerz = center[2]; - let det = aa * ad - ab * ac; - if(!det){ - return null; + if (Math.abs(eyex - centerx) < __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"] && + Math.abs(eyey - centery) < __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"] && + Math.abs(eyez - centerz) < __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]) { + return mat4.identity(out); } - det = 1.0 / det; - out[0] = ad * det; - out[1] = -ab * det; - out[2] = -ac * det; - out[3] = aa * det; - out[4] = (ac * aty - ad * atx) * det; - out[5] = (ab * atx - aa * aty) * det; - return out; -} + z0 = eyex - centerx; + z1 = eyey - centery; + z2 = eyez - centerz; -/** - * Calculates the determinant of a mat2d - * - * @param {mat2d} a the source matrix - * @returns {Number} determinant of a - */ -function determinant(a) { - return a[0] * a[3] - a[1] * a[2]; -} + len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); + z0 *= len; + z1 *= len; + z2 *= len; -/** - * Multiplies two mat2d's - * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the first operand - * @param {mat2d} b the second operand - * @returns {mat2d} out - */ -function multiply(out, a, b) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; - let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5]; - out[0] = a0 * b0 + a2 * b1; - out[1] = a1 * b0 + a3 * b1; - out[2] = a0 * b2 + a2 * b3; - out[3] = a1 * b2 + a3 * b3; - out[4] = a0 * b4 + a2 * b5 + a4; - out[5] = a1 * b4 + a3 * b5 + a5; - return out; -} + x0 = upy * z2 - upz * z1; + x1 = upz * z0 - upx * z2; + x2 = upx * z1 - upy * z0; + len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); + if (!len) { + x0 = 0; + x1 = 0; + x2 = 0; + } else { + len = 1 / len; + x0 *= len; + x1 *= len; + x2 *= len; + } -/** - * Rotates a mat2d by the given angle - * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2d} out - */ -function rotate(out, a, rad) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; - let s = Math.sin(rad); - let c = Math.cos(rad); - out[0] = a0 * c + a2 * s; - out[1] = a1 * c + a3 * s; - out[2] = a0 * -s + a2 * c; - out[3] = a1 * -s + a3 * c; - out[4] = a4; - out[5] = a5; - return out; -} + y0 = z1 * x2 - z2 * x1; + y1 = z2 * x0 - z0 * x2; + y2 = z0 * x1 - z1 * x0; -/** - * Scales the mat2d by the dimensions in the given vec2 - * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the matrix to translate - * @param {vec2} v the vec2 to scale the matrix by - * @returns {mat2d} out - **/ -function scale(out, a, v) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; - let v0 = v[0], v1 = v[1]; - out[0] = a0 * v0; - out[1] = a1 * v0; - out[2] = a2 * v1; - out[3] = a3 * v1; - out[4] = a4; - out[5] = a5; - return out; -} + len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); + if (!len) { + y0 = 0; + y1 = 0; + y2 = 0; + } else { + len = 1 / len; + y0 *= len; + y1 *= len; + y2 *= len; + } -/** - * Translates the mat2d by the dimensions in the given vec2 - * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the matrix to translate - * @param {vec2} v the vec2 to translate the matrix by - * @returns {mat2d} out - **/ -function translate(out, a, v) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; - let v0 = v[0], v1 = v[1]; - out[0] = a0; - out[1] = a1; - out[2] = a2; - out[3] = a3; - out[4] = a0 * v0 + a2 * v1 + a4; - out[5] = a1 * v0 + a3 * v1 + a5; - return out; -} + out[0] = x0; + out[1] = y0; + out[2] = z0; + out[3] = 0; + out[4] = x1; + out[5] = y1; + out[6] = z1; + out[7] = 0; + out[8] = x2; + out[9] = y2; + out[10] = z2; + out[11] = 0; + out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); + out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); + out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); + out[15] = 1; -/** - * Creates a matrix from a given angle - * This is equivalent to (but much faster than): - * - * mat2d.identity(dest); - * mat2d.rotate(dest, dest, rad); - * - * @param {mat2d} out mat2d receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2d} out - */ -function fromRotation(out, rad) { - let s = Math.sin(rad), c = Math.cos(rad); - out[0] = c; - out[1] = s; - out[2] = -s; - out[3] = c; - out[4] = 0; - out[5] = 0; return out; } /** - * Creates a matrix from a vector scaling - * This is equivalent to (but much faster than): - * - * mat2d.identity(dest); - * mat2d.scale(dest, dest, vec); + * Generates a matrix that makes something look at something else. * - * @param {mat2d} out mat2d receiving operation result - * @param {vec2} v Scaling vector - * @returns {mat2d} out + * @param {mat4} out mat4 frustum matrix will be written into + * @param {vec3} eye Position of the viewer + * @param {vec3} center Point the viewer is looking at + * @param {vec3} up vec3 pointing up + * @returns {mat4} out */ -function fromScaling(out, v) { - out[0] = v[0]; - out[1] = 0; - out[2] = 0; - out[3] = v[1]; - out[4] = 0; - out[5] = 0; - return out; -} +function targetTo(out, eye, target, up) { + let eyex = eye[0], + eyey = eye[1], + eyez = eye[2], + upx = up[0], + upy = up[1], + upz = up[2]; -/** - * Creates a matrix from a vector translation - * This is equivalent to (but much faster than): - * - * mat2d.identity(dest); - * mat2d.translate(dest, dest, vec); - * - * @param {mat2d} out mat2d receiving operation result - * @param {vec2} v Translation vector - * @returns {mat2d} out - */ -function fromTranslation(out, v) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 1; - out[4] = v[0]; - out[5] = v[1]; + let z0 = eyex - target[0], + z1 = eyey - target[1], + z2 = eyez - target[2]; + + let len = z0*z0 + z1*z1 + z2*z2; + if (len > 0) { + len = 1 / Math.sqrt(len); + z0 *= len; + z1 *= len; + z2 *= len; + } + + let x0 = upy * z2 - upz * z1, + x1 = upz * z0 - upx * z2, + x2 = upx * z1 - upy * z0; + + out[0] = x0; + out[1] = x1; + out[2] = x2; + out[3] = 0; + out[4] = z1 * x2 - z2 * x1; + out[5] = z2 * x0 - z0 * x2; + out[6] = z0 * x1 - z1 * x0; + out[7] = 0; + out[8] = z0; + out[9] = z1; + out[10] = z2; + out[11] = 0; + out[12] = eyex; + out[13] = eyey; + out[14] = eyez; + out[15] = 1; return out; -} +}; /** - * Returns a string representation of a mat2d + * Returns a string representation of a mat4 * - * @param {mat2d} a matrix to represent as a string + * @param {mat4} a matrix to represent as a string * @returns {String} string representation of the matrix */ function str(a) { - return 'mat2d(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + - a[3] + ', ' + a[4] + ', ' + a[5] + ')'; + return 'mat4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + + a[8] + ', ' + a[9] + ', ' + a[10] + ', ' + a[11] + ', ' + + a[12] + ', ' + a[13] + ', ' + a[14] + ', ' + a[15] + ')'; } /** - * Returns Frobenius norm of a mat2d + * Returns Frobenius norm of a mat4 * - * @param {mat2d} a the matrix to calculate Frobenius norm of + * @param {mat4} a the matrix to calculate Frobenius norm of * @returns {Number} Frobenius norm */ function frob(a) { - return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + 1)) + return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2) + Math.pow(a[9], 2) + Math.pow(a[10], 2) + Math.pow(a[11], 2) + Math.pow(a[12], 2) + Math.pow(a[13], 2) + Math.pow(a[14], 2) + Math.pow(a[15], 2) )) } /** - * Adds two mat2d's + * Adds two mat4's * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the first operand - * @param {mat2d} b the second operand - * @returns {mat2d} out + * @param {mat4} out the receiving matrix + * @param {mat4} a the first operand + * @param {mat4} b the second operand + * @returns {mat4} out */ function add(out, a, b) { out[0] = a[0] + b[0]; @@ -14194,16 +14748,26 @@ function add(out, a, b) { out[3] = a[3] + b[3]; out[4] = a[4] + b[4]; out[5] = a[5] + b[5]; + out[6] = a[6] + b[6]; + out[7] = a[7] + b[7]; + out[8] = a[8] + b[8]; + out[9] = a[9] + b[9]; + out[10] = a[10] + b[10]; + out[11] = a[11] + b[11]; + out[12] = a[12] + b[12]; + out[13] = a[13] + b[13]; + out[14] = a[14] + b[14]; + out[15] = a[15] + b[15]; return out; } /** * Subtracts matrix b from matrix a * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the first operand - * @param {mat2d} b the second operand - * @returns {mat2d} out + * @param {mat4} out the receiving matrix + * @param {mat4} a the first operand + * @param {mat4} b the second operand + * @returns {mat4} out */ function subtract(out, a, b) { out[0] = a[0] - b[0]; @@ -14212,16 +14776,26 @@ function subtract(out, a, b) { out[3] = a[3] - b[3]; out[4] = a[4] - b[4]; out[5] = a[5] - b[5]; + out[6] = a[6] - b[6]; + out[7] = a[7] - b[7]; + out[8] = a[8] - b[8]; + out[9] = a[9] - b[9]; + out[10] = a[10] - b[10]; + out[11] = a[11] - b[11]; + out[12] = a[12] - b[12]; + out[13] = a[13] - b[13]; + out[14] = a[14] - b[14]; + out[15] = a[15] - b[15]; return out; } /** * Multiply each element of the matrix by a scalar. * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the matrix to scale + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to scale * @param {Number} b amount to scale the matrix's elements by - * @returns {mat2d} out + * @returns {mat4} out */ function multiplyScalar(out, a, b) { out[0] = a[0] * b; @@ -14230,17 +14804,27 @@ function multiplyScalar(out, a, b) { out[3] = a[3] * b; out[4] = a[4] * b; out[5] = a[5] * b; + out[6] = a[6] * b; + out[7] = a[7] * b; + out[8] = a[8] * b; + out[9] = a[9] * b; + out[10] = a[10] * b; + out[11] = a[11] * b; + out[12] = a[12] * b; + out[13] = a[13] * b; + out[14] = a[14] * b; + out[15] = a[15] * b; return out; } /** - * Adds two mat2d's after multiplying each element of the second operand by a scalar value. + * Adds two mat4's after multiplying each element of the second operand by a scalar value. * - * @param {mat2d} out the receiving vector - * @param {mat2d} a the first operand - * @param {mat2d} b the second operand + * @param {mat4} out the receiving vector + * @param {mat4} a the first operand + * @param {mat4} b the second operand * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat2d} out + * @returns {mat4} out */ function multiplyScalarAndAdd(out, a, b, scale) { out[0] = a[0] + (b[0] * scale); @@ -14249,40 +14833,71 @@ function multiplyScalarAndAdd(out, a, b, scale) { out[3] = a[3] + (b[3] * scale); out[4] = a[4] + (b[4] * scale); out[5] = a[5] + (b[5] * scale); + out[6] = a[6] + (b[6] * scale); + out[7] = a[7] + (b[7] * scale); + out[8] = a[8] + (b[8] * scale); + out[9] = a[9] + (b[9] * scale); + out[10] = a[10] + (b[10] * scale); + out[11] = a[11] + (b[11] * scale); + out[12] = a[12] + (b[12] * scale); + out[13] = a[13] + (b[13] * scale); + out[14] = a[14] + (b[14] * scale); + out[15] = a[15] + (b[15] * scale); return out; } /** * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) * - * @param {mat2d} a The first matrix. - * @param {mat2d} b The second matrix. + * @param {mat4} a The first matrix. + * @param {mat4} b The second matrix. * @returns {Boolean} True if the matrices are equal, false otherwise. */ function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5]; + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && + a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && + a[8] === b[8] && a[9] === b[9] && a[10] === b[10] && a[11] === b[11] && + a[12] === b[12] && a[13] === b[13] && a[14] === b[14] && a[15] === b[15]; } /** * Returns whether or not the matrices have approximately the same elements in the same position. * - * @param {mat2d} a The first matrix. - * @param {mat2d} b The second matrix. + * @param {mat4} a The first matrix. + * @param {mat4} b The second matrix. * @returns {Boolean} True if the matrices are equal, false otherwise. */ function equals(a, b) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; - let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5]; + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + let a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7]; + let a8 = a[8], a9 = a[9], a10 = a[10], a11 = a[11]; + let a12 = a[12], a13 = a[13], a14 = a[14], a15 = a[15]; + + let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + let b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7]; + let b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11]; + let b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15]; + return (Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a4), Math.abs(b4)) && - Math.abs(a5 - b5) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a5), Math.abs(b5))); + Math.abs(a5 - b5) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a5), Math.abs(b5)) && + Math.abs(a6 - b6) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a6), Math.abs(b6)) && + Math.abs(a7 - b7) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a7), Math.abs(b7)) && + Math.abs(a8 - b8) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a8), Math.abs(b8)) && + Math.abs(a9 - b9) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a9), Math.abs(b9)) && + Math.abs(a10 - b10) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a10), Math.abs(b10)) && + Math.abs(a11 - b11) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a11), Math.abs(b11)) && + Math.abs(a12 - b12) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a12), Math.abs(b12)) && + Math.abs(a13 - b13) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a13), Math.abs(b13)) && + Math.abs(a14 - b14) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a14), Math.abs(b14)) && + Math.abs(a15 - b15) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a15), Math.abs(b15))); } /** - * Alias for {@link mat2d.multiply} + * Alias for {@link mat4.multiply} * @function */ const mul = multiply; @@ -14290,7 +14905,7 @@ const mul = multiply; /** - * Alias for {@link mat2d.subtract} + * Alias for {@link mat4.subtract} * @function */ const sub = subtract; @@ -14299,56 +14914,30 @@ const sub = subtract; /***/ }), -/* 69 */ +/* 71 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony export (immutable) */ __webpack_exports__["create"] = create; -/* harmony export (immutable) */ __webpack_exports__["clone"] = clone; -/* harmony export (immutable) */ __webpack_exports__["copy"] = copy; -/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues; -/* harmony export (immutable) */ __webpack_exports__["set"] = set; /* harmony export (immutable) */ __webpack_exports__["identity"] = identity; -/* harmony export (immutable) */ __webpack_exports__["transpose"] = transpose; -/* harmony export (immutable) */ __webpack_exports__["invert"] = invert; -/* harmony export (immutable) */ __webpack_exports__["adjoint"] = adjoint; -/* harmony export (immutable) */ __webpack_exports__["determinant"] = determinant; +/* harmony export (immutable) */ __webpack_exports__["setAxisAngle"] = setAxisAngle; +/* harmony export (immutable) */ __webpack_exports__["getAxisAngle"] = getAxisAngle; /* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply; -/* harmony export (immutable) */ __webpack_exports__["translate"] = translate; -/* harmony export (immutable) */ __webpack_exports__["scale"] = scale; -/* harmony export (immutable) */ __webpack_exports__["rotate"] = rotate; /* harmony export (immutable) */ __webpack_exports__["rotateX"] = rotateX; /* harmony export (immutable) */ __webpack_exports__["rotateY"] = rotateY; /* harmony export (immutable) */ __webpack_exports__["rotateZ"] = rotateZ; -/* harmony export (immutable) */ __webpack_exports__["fromTranslation"] = fromTranslation; -/* harmony export (immutable) */ __webpack_exports__["fromScaling"] = fromScaling; -/* harmony export (immutable) */ __webpack_exports__["fromRotation"] = fromRotation; -/* harmony export (immutable) */ __webpack_exports__["fromXRotation"] = fromXRotation; -/* harmony export (immutable) */ __webpack_exports__["fromYRotation"] = fromYRotation; -/* harmony export (immutable) */ __webpack_exports__["fromZRotation"] = fromZRotation; -/* harmony export (immutable) */ __webpack_exports__["fromRotationTranslation"] = fromRotationTranslation; -/* harmony export (immutable) */ __webpack_exports__["getTranslation"] = getTranslation; -/* harmony export (immutable) */ __webpack_exports__["getScaling"] = getScaling; -/* harmony export (immutable) */ __webpack_exports__["getRotation"] = getRotation; -/* harmony export (immutable) */ __webpack_exports__["fromRotationTranslationScale"] = fromRotationTranslationScale; -/* harmony export (immutable) */ __webpack_exports__["fromRotationTranslationScaleOrigin"] = fromRotationTranslationScaleOrigin; -/* harmony export (immutable) */ __webpack_exports__["fromQuat"] = fromQuat; -/* harmony export (immutable) */ __webpack_exports__["frustum"] = frustum; -/* harmony export (immutable) */ __webpack_exports__["perspective"] = perspective; -/* harmony export (immutable) */ __webpack_exports__["perspectiveFromFieldOfView"] = perspectiveFromFieldOfView; -/* harmony export (immutable) */ __webpack_exports__["ortho"] = ortho; -/* harmony export (immutable) */ __webpack_exports__["lookAt"] = lookAt; -/* harmony export (immutable) */ __webpack_exports__["targetTo"] = targetTo; +/* harmony export (immutable) */ __webpack_exports__["calculateW"] = calculateW; +/* harmony export (immutable) */ __webpack_exports__["slerp"] = slerp; +/* harmony export (immutable) */ __webpack_exports__["invert"] = invert; +/* harmony export (immutable) */ __webpack_exports__["conjugate"] = conjugate; +/* harmony export (immutable) */ __webpack_exports__["fromMat3"] = fromMat3; +/* harmony export (immutable) */ __webpack_exports__["fromEuler"] = fromEuler; /* harmony export (immutable) */ __webpack_exports__["str"] = str; -/* harmony export (immutable) */ __webpack_exports__["frob"] = frob; -/* harmony export (immutable) */ __webpack_exports__["add"] = add; -/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract; -/* harmony export (immutable) */ __webpack_exports__["multiplyScalar"] = multiplyScalar; -/* harmony export (immutable) */ __webpack_exports__["multiplyScalarAndAdd"] = multiplyScalarAndAdd; -/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals; -/* harmony export (immutable) */ __webpack_exports__["equals"] = equals; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__mat3__ = __webpack_require__(30); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__vec3__ = __webpack_require__(31); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__vec4__ = __webpack_require__(32); /* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. Permission is hereby granted, free of charge, to any person obtaining a copy @@ -14371,3879 +14960,3490 @@ THE SOFTWARE. */ + + + /** - * 4x4 Matrix - * @module mat4 + * Quaternion + * @module quat */ /** - * Creates a new identity mat4 + * Creates a new identity quat * - * @returns {mat4} a new 4x4 matrix + * @returns {quat} a new quaternion */ function create() { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](16); - out[0] = 1; + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](4); + out[0] = 0; out[1] = 0; out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = 1; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 1; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; + out[3] = 1; return out; } /** - * Creates a new mat4 initialized with values from an existing matrix + * Set a quat to the identity quaternion * - * @param {mat4} a matrix to clone - * @returns {mat4} a new 4x4 matrix + * @param {quat} out the receiving quaternion + * @returns {quat} out */ -function clone(a) { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](16); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; +function identity(out) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 1; return out; } /** - * Copy the values from one mat4 to another + * Sets a quat from the given angle and rotation axis, + * then returns it. * - * @param {mat4} out the receiving matrix - * @param {mat4} a the source matrix - * @returns {mat4} out + * @param {quat} out the receiving quaternion + * @param {vec3} axis the axis around which to rotate + * @param {Number} rad the angle in radians + * @returns {quat} out + **/ +function setAxisAngle(out, axis, rad) { + rad = rad * 0.5; + let s = Math.sin(rad); + out[0] = s * axis[0]; + out[1] = s * axis[1]; + out[2] = s * axis[2]; + out[3] = Math.cos(rad); + return out; +} + +/** + * Gets the rotation axis and angle for a given + * quaternion. If a quaternion is created with + * setAxisAngle, this method will return the same + * values as providied in the original parameter list + * OR functionally equivalent values. + * Example: The quaternion formed by axis [0, 0, 1] and + * angle -90 is the same as the quaternion formed by + * [0, 0, 1] and 270. This method favors the latter. + * @param {vec3} out_axis Vector receiving the axis of rotation + * @param {quat} q Quaternion to be decomposed + * @return {Number} Angle, in radians, of the rotation */ -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; +function getAxisAngle(out_axis, q) { + let rad = Math.acos(q[3]) * 2.0; + let s = Math.sin(rad / 2.0); + if (s != 0.0) { + out_axis[0] = q[0] / s; + out_axis[1] = q[1] / s; + out_axis[2] = q[2] / s; + } else { + // If s is zero, return any axis (no rotation - axis does not matter) + out_axis[0] = 1; + out_axis[1] = 0; + out_axis[2] = 0; + } + return rad; +} + +/** + * Multiplies two quat's + * + * @param {quat} out the receiving quaternion + * @param {quat} a the first operand + * @param {quat} b the second operand + * @returns {quat} out + */ +function multiply(out, a, b) { + let ax = a[0], ay = a[1], az = a[2], aw = a[3]; + let bx = b[0], by = b[1], bz = b[2], bw = b[3]; + + out[0] = ax * bw + aw * bx + ay * bz - az * by; + out[1] = ay * bw + aw * by + az * bx - ax * bz; + out[2] = az * bw + aw * bz + ax * by - ay * bx; + out[3] = aw * bw - ax * bx - ay * by - az * bz; return out; } /** - * Create a new mat4 with the given values + * Rotates a quaternion by the given angle about the X axis * - * @param {Number} m00 Component in column 0, row 0 position (index 0) - * @param {Number} m01 Component in column 0, row 1 position (index 1) - * @param {Number} m02 Component in column 0, row 2 position (index 2) - * @param {Number} m03 Component in column 0, row 3 position (index 3) - * @param {Number} m10 Component in column 1, row 0 position (index 4) - * @param {Number} m11 Component in column 1, row 1 position (index 5) - * @param {Number} m12 Component in column 1, row 2 position (index 6) - * @param {Number} m13 Component in column 1, row 3 position (index 7) - * @param {Number} m20 Component in column 2, row 0 position (index 8) - * @param {Number} m21 Component in column 2, row 1 position (index 9) - * @param {Number} m22 Component in column 2, row 2 position (index 10) - * @param {Number} m23 Component in column 2, row 3 position (index 11) - * @param {Number} m30 Component in column 3, row 0 position (index 12) - * @param {Number} m31 Component in column 3, row 1 position (index 13) - * @param {Number} m32 Component in column 3, row 2 position (index 14) - * @param {Number} m33 Component in column 3, row 3 position (index 15) - * @returns {mat4} A new mat4 + * @param {quat} out quat receiving operation result + * @param {quat} a quat to rotate + * @param {number} rad angle (in radians) to rotate + * @returns {quat} out */ -function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](16); - out[0] = m00; - out[1] = m01; - out[2] = m02; - out[3] = m03; - out[4] = m10; - out[5] = m11; - out[6] = m12; - out[7] = m13; - out[8] = m20; - out[9] = m21; - out[10] = m22; - out[11] = m23; - out[12] = m30; - out[13] = m31; - out[14] = m32; - out[15] = m33; +function rotateX(out, a, rad) { + rad *= 0.5; + + let ax = a[0], ay = a[1], az = a[2], aw = a[3]; + let bx = Math.sin(rad), bw = Math.cos(rad); + + out[0] = ax * bw + aw * bx; + out[1] = ay * bw + az * bx; + out[2] = az * bw - ay * bx; + out[3] = aw * bw - ax * bx; return out; } /** - * Set the components of a mat4 to the given values + * Rotates a quaternion by the given angle about the Y axis * - * @param {mat4} out the receiving matrix - * @param {Number} m00 Component in column 0, row 0 position (index 0) - * @param {Number} m01 Component in column 0, row 1 position (index 1) - * @param {Number} m02 Component in column 0, row 2 position (index 2) - * @param {Number} m03 Component in column 0, row 3 position (index 3) - * @param {Number} m10 Component in column 1, row 0 position (index 4) - * @param {Number} m11 Component in column 1, row 1 position (index 5) - * @param {Number} m12 Component in column 1, row 2 position (index 6) - * @param {Number} m13 Component in column 1, row 3 position (index 7) - * @param {Number} m20 Component in column 2, row 0 position (index 8) - * @param {Number} m21 Component in column 2, row 1 position (index 9) - * @param {Number} m22 Component in column 2, row 2 position (index 10) - * @param {Number} m23 Component in column 2, row 3 position (index 11) - * @param {Number} m30 Component in column 3, row 0 position (index 12) - * @param {Number} m31 Component in column 3, row 1 position (index 13) - * @param {Number} m32 Component in column 3, row 2 position (index 14) - * @param {Number} m33 Component in column 3, row 3 position (index 15) - * @returns {mat4} out + * @param {quat} out quat receiving operation result + * @param {quat} a quat to rotate + * @param {number} rad angle (in radians) to rotate + * @returns {quat} out */ -function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { - out[0] = m00; - out[1] = m01; - out[2] = m02; - out[3] = m03; - out[4] = m10; - out[5] = m11; - out[6] = m12; - out[7] = m13; - out[8] = m20; - out[9] = m21; - out[10] = m22; - out[11] = m23; - out[12] = m30; - out[13] = m31; - out[14] = m32; - out[15] = m33; +function rotateY(out, a, rad) { + rad *= 0.5; + + let ax = a[0], ay = a[1], az = a[2], aw = a[3]; + let by = Math.sin(rad), bw = Math.cos(rad); + + out[0] = ax * bw - az * by; + out[1] = ay * bw + aw * by; + out[2] = az * bw + ax * by; + out[3] = aw * bw - ay * by; + return out; +} + +/** + * Rotates a quaternion by the given angle about the Z axis + * + * @param {quat} out quat receiving operation result + * @param {quat} a quat to rotate + * @param {number} rad angle (in radians) to rotate + * @returns {quat} out + */ +function rotateZ(out, a, rad) { + rad *= 0.5; + + let ax = a[0], ay = a[1], az = a[2], aw = a[3]; + let bz = Math.sin(rad), bw = Math.cos(rad); + + out[0] = ax * bw + ay * bz; + out[1] = ay * bw - ax * bz; + out[2] = az * bw + aw * bz; + out[3] = aw * bw - az * bz; + return out; +} + +/** + * Calculates the W component of a quat from the X, Y, and Z components. + * Assumes that quaternion is 1 unit in length. + * Any existing W component will be ignored. + * + * @param {quat} out the receiving quaternion + * @param {quat} a quat to calculate W component of + * @returns {quat} out + */ +function calculateW(out, a) { + let x = a[0], y = a[1], z = a[2]; + + out[0] = x; + out[1] = y; + out[2] = z; + out[3] = Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z)); + return out; +} + +/** + * Performs a spherical linear interpolation between two quat + * + * @param {quat} out the receiving quaternion + * @param {quat} a the first operand + * @param {quat} b the second operand + * @param {Number} t interpolation amount between the two inputs + * @returns {quat} out + */ +function slerp(out, a, b, t) { + // benchmarks: + // http://jsperf.com/quaternion-slerp-implementations + let ax = a[0], ay = a[1], az = a[2], aw = a[3]; + let bx = b[0], by = b[1], bz = b[2], bw = b[3]; + + let omega, cosom, sinom, scale0, scale1; + + // calc cosine + cosom = ax * bx + ay * by + az * bz + aw * bw; + // adjust signs (if necessary) + if ( cosom < 0.0 ) { + cosom = -cosom; + bx = - bx; + by = - by; + bz = - bz; + bw = - bw; + } + // calculate coefficients + if ( (1.0 - cosom) > 0.000001 ) { + // standard case (slerp) + omega = Math.acos(cosom); + sinom = Math.sin(omega); + scale0 = Math.sin((1.0 - t) * omega) / sinom; + scale1 = Math.sin(t * omega) / sinom; + } else { + // "from" and "to" quaternions are very close + // ... so we can do a linear interpolation + scale0 = 1.0 - t; + scale1 = t; + } + // calculate final values + out[0] = scale0 * ax + scale1 * bx; + out[1] = scale0 * ay + scale1 * by; + out[2] = scale0 * az + scale1 * bz; + out[3] = scale0 * aw + scale1 * bw; + + return out; +} + +/** + * Calculates the inverse of a quat + * + * @param {quat} out the receiving quaternion + * @param {quat} a quat to calculate inverse of + * @returns {quat} out + */ +function invert(out, a) { + let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + let dot = a0*a0 + a1*a1 + a2*a2 + a3*a3; + let invDot = dot ? 1.0/dot : 0; + + // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 + + out[0] = -a0*invDot; + out[1] = -a1*invDot; + out[2] = -a2*invDot; + out[3] = a3*invDot; return out; } - /** - * Set a mat4 to the identity matrix + * Calculates the conjugate of a quat + * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result. * - * @param {mat4} out the receiving matrix - * @returns {mat4} out + * @param {quat} out the receiving quaternion + * @param {quat} a quat to calculate conjugate of + * @returns {quat} out */ -function identity(out) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = 1; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 1; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; +function conjugate(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + out[2] = -a[2]; + out[3] = a[3]; return out; } /** - * Transpose the values of a mat4 + * Creates a quaternion from the given 3x3 rotation matrix. * - * @param {mat4} out the receiving matrix - * @param {mat4} a the source matrix - * @returns {mat4} out + * NOTE: The resultant quaternion is not normalized, so you should be sure + * to renormalize the quaternion yourself where necessary. + * + * @param {quat} out the receiving quaternion + * @param {mat3} m rotation matrix + * @returns {quat} out + * @function */ -function transpose(out, a) { - // If we are transposing ourselves we can skip a few steps but have to cache some values - if (out === a) { - let a01 = a[1], a02 = a[2], a03 = a[3]; - let a12 = a[6], a13 = a[7]; - let a23 = a[11]; +function fromMat3(out, m) { + // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes + // article "Quaternion Calculus and Fast Animation". + let fTrace = m[0] + m[4] + m[8]; + let fRoot; - out[1] = a[4]; - out[2] = a[8]; - out[3] = a[12]; - out[4] = a01; - out[6] = a[9]; - out[7] = a[13]; - out[8] = a02; - out[9] = a12; - out[11] = a[14]; - out[12] = a03; - out[13] = a13; - out[14] = a23; + if ( fTrace > 0.0 ) { + // |w| > 1/2, may as well choose w > 1/2 + fRoot = Math.sqrt(fTrace + 1.0); // 2w + out[3] = 0.5 * fRoot; + fRoot = 0.5/fRoot; // 1/(4w) + out[0] = (m[5]-m[7])*fRoot; + out[1] = (m[6]-m[2])*fRoot; + out[2] = (m[1]-m[3])*fRoot; } else { - out[0] = a[0]; - out[1] = a[4]; - out[2] = a[8]; - out[3] = a[12]; - out[4] = a[1]; - out[5] = a[5]; - out[6] = a[9]; - out[7] = a[13]; - out[8] = a[2]; - out[9] = a[6]; - out[10] = a[10]; - out[11] = a[14]; - out[12] = a[3]; - out[13] = a[7]; - out[14] = a[11]; - out[15] = a[15]; + // |w| <= 1/2 + let i = 0; + if ( m[4] > m[0] ) + i = 1; + if ( m[8] > m[i*3+i] ) + i = 2; + let j = (i+1)%3; + let k = (i+2)%3; + + fRoot = Math.sqrt(m[i*3+i]-m[j*3+j]-m[k*3+k] + 1.0); + out[i] = 0.5 * fRoot; + fRoot = 0.5 / fRoot; + out[3] = (m[j*3+k] - m[k*3+j]) * fRoot; + out[j] = (m[j*3+i] + m[i*3+j]) * fRoot; + out[k] = (m[k*3+i] + m[i*3+k]) * fRoot; } return out; } /** - * Inverts a mat4 + * Creates a quaternion from the given euler angle x, y, z. * - * @param {mat4} out the receiving matrix - * @param {mat4} a the source matrix - * @returns {mat4} out + * @param {quat} out the receiving quaternion + * @param {x} Angle to rotate around X axis in degrees. + * @param {y} Angle to rotate around Y axis in degrees. + * @param {z} Angle to rotate around Z axis in degrees. + * @returns {quat} out + * @function */ -function invert(out, a) { - let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - - let b00 = a00 * a11 - a01 * a10; - let b01 = a00 * a12 - a02 * a10; - let b02 = a00 * a13 - a03 * a10; - let b03 = a01 * a12 - a02 * a11; - let b04 = a01 * a13 - a03 * a11; - let b05 = a02 * a13 - a03 * a12; - let b06 = a20 * a31 - a21 * a30; - let b07 = a20 * a32 - a22 * a30; - let b08 = a20 * a33 - a23 * a30; - let b09 = a21 * a32 - a22 * a31; - let b10 = a21 * a33 - a23 * a31; - let b11 = a22 * a33 - a23 * a32; - - // Calculate the determinant - let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; +function fromEuler(out, x, y, z) { + let halfToRad = 0.5 * Math.PI / 180.0; + x *= halfToRad; + y *= halfToRad; + z *= halfToRad; - if (!det) { - return null; - } - det = 1.0 / det; + let sx = Math.sin(x); + let cx = Math.cos(x); + let sy = Math.sin(y); + let cy = Math.cos(y); + let sz = Math.sin(z); + let cz = Math.cos(z); - out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; - out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; - out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; - out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; - out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; - out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; - out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; - out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; - out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; - out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; - out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; - out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; - out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; - out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; - out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; + out[0] = sx * cy * cz - cx * sy * sz; + out[1] = cx * sy * cz + sx * cy * sz; + out[2] = cx * cy * sz - sx * sy * cz; + out[3] = cx * cy * cz + sx * sy * sz; - return out; + return out; } /** - * Calculates the adjugate of a mat4 + * Returns a string representation of a quatenion * - * @param {mat4} out the receiving matrix - * @param {mat4} a the source matrix - * @returns {mat4} out + * @param {quat} a vector to represent as a string + * @returns {String} string representation of the vector */ -function adjoint(out, a) { - let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - - out[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22)); - out[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); - out[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12)); - out[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); - out[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); - out[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22)); - out[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); - out[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12)); - out[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21)); - out[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); - out[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11)); - out[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); - out[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); - out[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21)); - out[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); - out[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11)); - return out; +function str(a) { + return 'quat(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')'; } /** - * Calculates the determinant of a mat4 + * Creates a new quat initialized with values from an existing quaternion * - * @param {mat4} a the source matrix - * @returns {Number} determinant of a + * @param {quat} a quaternion to clone + * @returns {quat} a new quaternion + * @function */ -function determinant(a) { - let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - - let b00 = a00 * a11 - a01 * a10; - let b01 = a00 * a12 - a02 * a10; - let b02 = a00 * a13 - a03 * a10; - let b03 = a01 * a12 - a02 * a11; - let b04 = a01 * a13 - a03 * a11; - let b05 = a02 * a13 - a03 * a12; - let b06 = a20 * a31 - a21 * a30; - let b07 = a20 * a32 - a22 * a30; - let b08 = a20 * a33 - a23 * a30; - let b09 = a21 * a32 - a22 * a31; - let b10 = a21 * a33 - a23 * a31; - let b11 = a22 * a33 - a23 * a32; +const clone = __WEBPACK_IMPORTED_MODULE_3__vec4__["clone"]; +/* harmony export (immutable) */ __webpack_exports__["clone"] = clone; - // Calculate the determinant - return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; -} /** - * Multiplies two mat4s + * Creates a new quat initialized with the given values * - * @param {mat4} out the receiving matrix - * @param {mat4} a the first operand - * @param {mat4} b the second operand - * @returns {mat4} out + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {quat} a new quaternion + * @function */ -function multiply(out, a, b) { - let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - - // Cache only the current line of the second matrix - let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - out[0] = b0*a00 + b1*a10 + b2*a20 + b3*a30; - out[1] = b0*a01 + b1*a11 + b2*a21 + b3*a31; - out[2] = b0*a02 + b1*a12 + b2*a22 + b3*a32; - out[3] = b0*a03 + b1*a13 + b2*a23 + b3*a33; +const fromValues = __WEBPACK_IMPORTED_MODULE_3__vec4__["fromValues"]; +/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues; - b0 = b[4]; b1 = b[5]; b2 = b[6]; b3 = b[7]; - out[4] = b0*a00 + b1*a10 + b2*a20 + b3*a30; - out[5] = b0*a01 + b1*a11 + b2*a21 + b3*a31; - out[6] = b0*a02 + b1*a12 + b2*a22 + b3*a32; - out[7] = b0*a03 + b1*a13 + b2*a23 + b3*a33; - b0 = b[8]; b1 = b[9]; b2 = b[10]; b3 = b[11]; - out[8] = b0*a00 + b1*a10 + b2*a20 + b3*a30; - out[9] = b0*a01 + b1*a11 + b2*a21 + b3*a31; - out[10] = b0*a02 + b1*a12 + b2*a22 + b3*a32; - out[11] = b0*a03 + b1*a13 + b2*a23 + b3*a33; +/** + * Copy the values from one quat to another + * + * @param {quat} out the receiving quaternion + * @param {quat} a the source quaternion + * @returns {quat} out + * @function + */ +const copy = __WEBPACK_IMPORTED_MODULE_3__vec4__["copy"]; +/* harmony export (immutable) */ __webpack_exports__["copy"] = copy; - b0 = b[12]; b1 = b[13]; b2 = b[14]; b3 = b[15]; - out[12] = b0*a00 + b1*a10 + b2*a20 + b3*a30; - out[13] = b0*a01 + b1*a11 + b2*a21 + b3*a31; - out[14] = b0*a02 + b1*a12 + b2*a22 + b3*a32; - out[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33; - return out; -} /** - * Translate a mat4 by the given vector + * Set the components of a quat to the given values * - * @param {mat4} out the receiving matrix - * @param {mat4} a the matrix to translate - * @param {vec3} v vector to translate by - * @returns {mat4} out + * @param {quat} out the receiving quaternion + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {quat} out + * @function */ -function translate(out, a, v) { - let x = v[0], y = v[1], z = v[2]; - let a00, a01, a02, a03; - let a10, a11, a12, a13; - let a20, a21, a22, a23; +const set = __WEBPACK_IMPORTED_MODULE_3__vec4__["set"]; +/* harmony export (immutable) */ __webpack_exports__["set"] = set; - if (a === out) { - out[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; - out[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; - out[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; - out[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; - } else { - a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3]; - a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7]; - a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11]; - out[0] = a00; out[1] = a01; out[2] = a02; out[3] = a03; - out[4] = a10; out[5] = a11; out[6] = a12; out[7] = a13; - out[8] = a20; out[9] = a21; out[10] = a22; out[11] = a23; +/** + * Adds two quat's + * + * @param {quat} out the receiving quaternion + * @param {quat} a the first operand + * @param {quat} b the second operand + * @returns {quat} out + * @function + */ +const add = __WEBPACK_IMPORTED_MODULE_3__vec4__["add"]; +/* harmony export (immutable) */ __webpack_exports__["add"] = add; - out[12] = a00 * x + a10 * y + a20 * z + a[12]; - out[13] = a01 * x + a11 * y + a21 * z + a[13]; - out[14] = a02 * x + a12 * y + a22 * z + a[14]; - out[15] = a03 * x + a13 * y + a23 * z + a[15]; - } - return out; -} +/** + * Alias for {@link quat.multiply} + * @function + */ +const mul = multiply; +/* harmony export (immutable) */ __webpack_exports__["mul"] = mul; + /** - * Scales the mat4 by the dimensions in the given vec3 not using vectorization + * Scales a quat by a scalar number * - * @param {mat4} out the receiving matrix - * @param {mat4} a the matrix to scale - * @param {vec3} v the vec3 to scale the matrix by - * @returns {mat4} out - **/ -function scale(out, a, v) { - let x = v[0], y = v[1], z = v[2]; + * @param {quat} out the receiving vector + * @param {quat} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {quat} out + * @function + */ +const scale = __WEBPACK_IMPORTED_MODULE_3__vec4__["scale"]; +/* harmony export (immutable) */ __webpack_exports__["scale"] = scale; - out[0] = a[0] * x; - out[1] = a[1] * x; - out[2] = a[2] * x; - out[3] = a[3] * x; - out[4] = a[4] * y; - out[5] = a[5] * y; - out[6] = a[6] * y; - out[7] = a[7] * y; - out[8] = a[8] * z; - out[9] = a[9] * z; - out[10] = a[10] * z; - out[11] = a[11] * z; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - return out; -} /** - * Rotates a mat4 by the given angle around the given axis + * Calculates the dot product of two quat's * - * @param {mat4} out the receiving matrix - * @param {mat4} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @param {vec3} axis the axis to rotate around - * @returns {mat4} out + * @param {quat} a the first operand + * @param {quat} b the second operand + * @returns {Number} dot product of a and b + * @function */ -function rotate(out, a, rad, axis) { - let x = axis[0], y = axis[1], z = axis[2]; - let len = Math.sqrt(x * x + y * y + z * z); - let s, c, t; - let a00, a01, a02, a03; - let a10, a11, a12, a13; - let a20, a21, a22, a23; - let b00, b01, b02; - let b10, b11, b12; - let b20, b21, b22; +const dot = __WEBPACK_IMPORTED_MODULE_3__vec4__["dot"]; +/* harmony export (immutable) */ __webpack_exports__["dot"] = dot; - if (Math.abs(len) < __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]) { return null; } - len = 1 / len; - x *= len; - y *= len; - z *= len; +/** + * Performs a linear interpolation between two quat's + * + * @param {quat} out the receiving quaternion + * @param {quat} a the first operand + * @param {quat} b the second operand + * @param {Number} t interpolation amount between the two inputs + * @returns {quat} out + * @function + */ +const lerp = __WEBPACK_IMPORTED_MODULE_3__vec4__["lerp"]; +/* harmony export (immutable) */ __webpack_exports__["lerp"] = lerp; - s = Math.sin(rad); - c = Math.cos(rad); - t = 1 - c; - a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3]; - a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7]; - a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11]; +/** + * Calculates the length of a quat + * + * @param {quat} a vector to calculate length of + * @returns {Number} length of a + */ +const length = __WEBPACK_IMPORTED_MODULE_3__vec4__["length"]; +/* harmony export (immutable) */ __webpack_exports__["length"] = length; - // Construct the elements of the rotation matrix - b00 = x * x * t + c; b01 = y * x * t + z * s; b02 = z * x * t - y * s; - b10 = x * y * t - z * s; b11 = y * y * t + c; b12 = z * y * t + x * s; - b20 = x * z * t + y * s; b21 = y * z * t - x * s; b22 = z * z * t + c; - // Perform rotation-specific matrix multiplication - out[0] = a00 * b00 + a10 * b01 + a20 * b02; - out[1] = a01 * b00 + a11 * b01 + a21 * b02; - out[2] = a02 * b00 + a12 * b01 + a22 * b02; - out[3] = a03 * b00 + a13 * b01 + a23 * b02; - out[4] = a00 * b10 + a10 * b11 + a20 * b12; - out[5] = a01 * b10 + a11 * b11 + a21 * b12; - out[6] = a02 * b10 + a12 * b11 + a22 * b12; - out[7] = a03 * b10 + a13 * b11 + a23 * b12; - out[8] = a00 * b20 + a10 * b21 + a20 * b22; - out[9] = a01 * b20 + a11 * b21 + a21 * b22; - out[10] = a02 * b20 + a12 * b21 + a22 * b22; - out[11] = a03 * b20 + a13 * b21 + a23 * b22; +/** + * Alias for {@link quat.length} + * @function + */ +const len = length; +/* harmony export (immutable) */ __webpack_exports__["len"] = len; - if (a !== out) { // If the source and destination differ, copy the unchanged last row - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - } - return out; -} /** - * Rotates a matrix by the given angle around the X axis + * Calculates the squared length of a quat * - * @param {mat4} out the receiving matrix - * @param {mat4} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @param {quat} a vector to calculate squared length of + * @returns {Number} squared length of a + * @function */ -function rotateX(out, a, rad) { - let s = Math.sin(rad); - let c = Math.cos(rad); - let a10 = a[4]; - let a11 = a[5]; - let a12 = a[6]; - let a13 = a[7]; - let a20 = a[8]; - let a21 = a[9]; - let a22 = a[10]; - let a23 = a[11]; +const squaredLength = __WEBPACK_IMPORTED_MODULE_3__vec4__["squaredLength"]; +/* harmony export (immutable) */ __webpack_exports__["squaredLength"] = squaredLength; - if (a !== out) { // If the source and destination differ, copy the unchanged rows - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - } - // Perform axis-specific matrix multiplication - out[4] = a10 * c + a20 * s; - out[5] = a11 * c + a21 * s; - out[6] = a12 * c + a22 * s; - out[7] = a13 * c + a23 * s; - out[8] = a20 * c - a10 * s; - out[9] = a21 * c - a11 * s; - out[10] = a22 * c - a12 * s; - out[11] = a23 * c - a13 * s; - return out; -} +/** + * Alias for {@link quat.squaredLength} + * @function + */ +const sqrLen = squaredLength; +/* harmony export (immutable) */ __webpack_exports__["sqrLen"] = sqrLen; + /** - * Rotates a matrix by the given angle around the Y axis + * Normalize a quat * - * @param {mat4} out the receiving matrix - * @param {mat4} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @param {quat} out the receiving quaternion + * @param {quat} a quaternion to normalize + * @returns {quat} out + * @function */ -function rotateY(out, a, rad) { - let s = Math.sin(rad); - let c = Math.cos(rad); - let a00 = a[0]; - let a01 = a[1]; - let a02 = a[2]; - let a03 = a[3]; - let a20 = a[8]; - let a21 = a[9]; - let a22 = a[10]; - let a23 = a[11]; - - if (a !== out) { // If the source and destination differ, copy the unchanged rows - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - } +const normalize = __WEBPACK_IMPORTED_MODULE_3__vec4__["normalize"]; +/* harmony export (immutable) */ __webpack_exports__["normalize"] = normalize; - // Perform axis-specific matrix multiplication - out[0] = a00 * c - a20 * s; - out[1] = a01 * c - a21 * s; - out[2] = a02 * c - a22 * s; - out[3] = a03 * c - a23 * s; - out[8] = a00 * s + a20 * c; - out[9] = a01 * s + a21 * c; - out[10] = a02 * s + a22 * c; - out[11] = a03 * s + a23 * c; - return out; -} /** - * Rotates a matrix by the given angle around the Z axis + * Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===) * - * @param {mat4} out the receiving matrix - * @param {mat4} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @param {quat} a The first quaternion. + * @param {quat} b The second quaternion. + * @returns {Boolean} True if the vectors are equal, false otherwise. */ -function rotateZ(out, a, rad) { - let s = Math.sin(rad); - let c = Math.cos(rad); - let a00 = a[0]; - let a01 = a[1]; - let a02 = a[2]; - let a03 = a[3]; - let a10 = a[4]; - let a11 = a[5]; - let a12 = a[6]; - let a13 = a[7]; - - if (a !== out) { // If the source and destination differ, copy the unchanged last row - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - } +const exactEquals = __WEBPACK_IMPORTED_MODULE_3__vec4__["exactEquals"]; +/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals; - // Perform axis-specific matrix multiplication - out[0] = a00 * c + a10 * s; - out[1] = a01 * c + a11 * s; - out[2] = a02 * c + a12 * s; - out[3] = a03 * c + a13 * s; - out[4] = a10 * c - a00 * s; - out[5] = a11 * c - a01 * s; - out[6] = a12 * c - a02 * s; - out[7] = a13 * c - a03 * s; - return out; -} /** - * Creates a matrix from a vector translation - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.translate(dest, dest, vec); + * Returns whether or not the quaternions have approximately the same elements in the same position. * - * @param {mat4} out mat4 receiving operation result - * @param {vec3} v Translation vector - * @returns {mat4} out + * @param {quat} a The first vector. + * @param {quat} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. */ -function fromTranslation(out, v) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = 1; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 1; - out[11] = 0; - out[12] = v[0]; - out[13] = v[1]; - out[14] = v[2]; - out[15] = 1; - return out; -} +const equals = __WEBPACK_IMPORTED_MODULE_3__vec4__["equals"]; +/* harmony export (immutable) */ __webpack_exports__["equals"] = equals; + /** - * Creates a matrix from a vector scaling - * This is equivalent to (but much faster than): + * Sets a quaternion to represent the shortest rotation from one + * vector to another. * - * mat4.identity(dest); - * mat4.scale(dest, dest, vec); + * Both vectors are assumed to be unit length. * - * @param {mat4} out mat4 receiving operation result - * @param {vec3} v Scaling vector - * @returns {mat4} out + * @param {quat} out the receiving quaternion. + * @param {vec3} a the initial vector + * @param {vec3} b the destination vector + * @returns {quat} out */ -function fromScaling(out, v) { - out[0] = v[0]; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = v[1]; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = v[2]; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - return out; -} +const rotationTo = (function() { + let tmpvec3 = __WEBPACK_IMPORTED_MODULE_2__vec3__["create"](); + let xUnitVec3 = __WEBPACK_IMPORTED_MODULE_2__vec3__["fromValues"](1,0,0); + let yUnitVec3 = __WEBPACK_IMPORTED_MODULE_2__vec3__["fromValues"](0,1,0); + + return function(out, a, b) { + let dot = __WEBPACK_IMPORTED_MODULE_2__vec3__["dot"](a, b); + if (dot < -0.999999) { + __WEBPACK_IMPORTED_MODULE_2__vec3__["cross"](tmpvec3, xUnitVec3, a); + if (__WEBPACK_IMPORTED_MODULE_2__vec3__["len"](tmpvec3) < 0.000001) + __WEBPACK_IMPORTED_MODULE_2__vec3__["cross"](tmpvec3, yUnitVec3, a); + __WEBPACK_IMPORTED_MODULE_2__vec3__["normalize"](tmpvec3, tmpvec3); + setAxisAngle(out, tmpvec3, Math.PI); + return out; + } else if (dot > 0.999999) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 1; + return out; + } else { + __WEBPACK_IMPORTED_MODULE_2__vec3__["cross"](tmpvec3, a, b); + out[0] = tmpvec3[0]; + out[1] = tmpvec3[1]; + out[2] = tmpvec3[2]; + out[3] = 1 + dot; + return normalize(out, out); + } + }; +})(); +/* harmony export (immutable) */ __webpack_exports__["rotationTo"] = rotationTo; + /** - * Creates a matrix from a given angle around a given axis - * This is equivalent to (but much faster than): + * Performs a spherical linear interpolation with two control points * - * mat4.identity(dest); - * mat4.rotate(dest, dest, rad, axis); + * @param {quat} out the receiving quaternion + * @param {quat} a the first operand + * @param {quat} b the second operand + * @param {quat} c the third operand + * @param {quat} d the fourth operand + * @param {Number} t interpolation amount + * @returns {quat} out + */ +const sqlerp = (function () { + let temp1 = create(); + let temp2 = create(); + + return function (out, a, b, c, d, t) { + slerp(temp1, a, d, t); + slerp(temp2, b, c, t); + slerp(out, temp1, temp2, 2 * t * (1 - t)); + + return out; + }; +}()); +/* harmony export (immutable) */ __webpack_exports__["sqlerp"] = sqlerp; + + +/** + * Sets the specified quaternion with values corresponding to the given + * axes. Each axis is a vec3 and is expected to be unit length and + * perpendicular to all other specified axes. * - * @param {mat4} out mat4 receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @param {vec3} axis the axis to rotate around - * @returns {mat4} out + * @param {vec3} view the vector representing the viewing direction + * @param {vec3} right the vector representing the local "right" direction + * @param {vec3} up the vector representing the local "up" direction + * @returns {quat} out */ -function fromRotation(out, rad, axis) { - let x = axis[0], y = axis[1], z = axis[2]; - let len = Math.sqrt(x * x + y * y + z * z); - let s, c, t; +const setAxes = (function() { + let matr = __WEBPACK_IMPORTED_MODULE_1__mat3__["create"](); - if (Math.abs(len) < __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]) { return null; } + return function(out, view, right, up) { + matr[0] = right[0]; + matr[3] = right[1]; + matr[6] = right[2]; - len = 1 / len; - x *= len; - y *= len; - z *= len; + matr[1] = up[0]; + matr[4] = up[1]; + matr[7] = up[2]; + + matr[2] = -view[0]; + matr[5] = -view[1]; + matr[8] = -view[2]; + + return normalize(out, fromMat3(out, matr)); + }; +})(); +/* harmony export (immutable) */ __webpack_exports__["setAxes"] = setAxes; + + + +/***/ }), +/* 72 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +/* harmony export (immutable) */ __webpack_exports__["create"] = create; +/* harmony export (immutable) */ __webpack_exports__["clone"] = clone; +/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues; +/* harmony export (immutable) */ __webpack_exports__["copy"] = copy; +/* harmony export (immutable) */ __webpack_exports__["set"] = set; +/* harmony export (immutable) */ __webpack_exports__["add"] = add; +/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract; +/* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply; +/* harmony export (immutable) */ __webpack_exports__["divide"] = divide; +/* harmony export (immutable) */ __webpack_exports__["ceil"] = ceil; +/* harmony export (immutable) */ __webpack_exports__["floor"] = floor; +/* harmony export (immutable) */ __webpack_exports__["min"] = min; +/* harmony export (immutable) */ __webpack_exports__["max"] = max; +/* harmony export (immutable) */ __webpack_exports__["round"] = round; +/* harmony export (immutable) */ __webpack_exports__["scale"] = scale; +/* harmony export (immutable) */ __webpack_exports__["scaleAndAdd"] = scaleAndAdd; +/* harmony export (immutable) */ __webpack_exports__["distance"] = distance; +/* harmony export (immutable) */ __webpack_exports__["squaredDistance"] = squaredDistance; +/* harmony export (immutable) */ __webpack_exports__["length"] = length; +/* harmony export (immutable) */ __webpack_exports__["squaredLength"] = squaredLength; +/* harmony export (immutable) */ __webpack_exports__["negate"] = negate; +/* harmony export (immutable) */ __webpack_exports__["inverse"] = inverse; +/* harmony export (immutable) */ __webpack_exports__["normalize"] = normalize; +/* harmony export (immutable) */ __webpack_exports__["dot"] = dot; +/* harmony export (immutable) */ __webpack_exports__["cross"] = cross; +/* harmony export (immutable) */ __webpack_exports__["lerp"] = lerp; +/* harmony export (immutable) */ __webpack_exports__["random"] = random; +/* harmony export (immutable) */ __webpack_exports__["transformMat2"] = transformMat2; +/* harmony export (immutable) */ __webpack_exports__["transformMat2d"] = transformMat2d; +/* harmony export (immutable) */ __webpack_exports__["transformMat3"] = transformMat3; +/* harmony export (immutable) */ __webpack_exports__["transformMat4"] = transformMat4; +/* harmony export (immutable) */ __webpack_exports__["str"] = str; +/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals; +/* harmony export (immutable) */ __webpack_exports__["equals"] = equals; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(3); +/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. */ - s = Math.sin(rad); - c = Math.cos(rad); - t = 1 - c; - // Perform rotation-specific matrix multiplication - out[0] = x * x * t + c; - out[1] = y * x * t + z * s; - out[2] = z * x * t - y * s; - out[3] = 0; - out[4] = x * y * t - z * s; - out[5] = y * y * t + c; - out[6] = z * y * t + x * s; - out[7] = 0; - out[8] = x * z * t + y * s; - out[9] = y * z * t - x * s; - out[10] = z * z * t + c; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - return out; -} /** - * Creates a matrix from the given angle around the X axis - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.rotateX(dest, dest, rad); - * - * @param {mat4} out mat4 receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * 2 Dimensional Vector + * @module vec2 */ -function fromXRotation(out, rad) { - let s = Math.sin(rad); - let c = Math.cos(rad); - // Perform axis-specific matrix multiplication - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = c; - out[6] = s; - out[7] = 0; - out[8] = 0; - out[9] = -s; - out[10] = c; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; +/** + * Creates a new, empty vec2 + * + * @returns {vec2} a new 2D vector + */ +function create() { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](2); + out[0] = 0; + out[1] = 0; return out; } /** - * Creates a matrix from the given angle around the Y axis - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.rotateY(dest, dest, rad); + * Creates a new vec2 initialized with values from an existing vector * - * @param {mat4} out mat4 receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @param {vec2} a vector to clone + * @returns {vec2} a new 2D vector */ -function fromYRotation(out, rad) { - let s = Math.sin(rad); - let c = Math.cos(rad); - - // Perform axis-specific matrix multiplication - out[0] = c; - out[1] = 0; - out[2] = -s; - out[3] = 0; - out[4] = 0; - out[5] = 1; - out[6] = 0; - out[7] = 0; - out[8] = s; - out[9] = 0; - out[10] = c; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; +function clone(a) { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](2); + out[0] = a[0]; + out[1] = a[1]; return out; } /** - * Creates a matrix from the given angle around the Z axis - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.rotateZ(dest, dest, rad); + * Creates a new vec2 initialized with the given values * - * @param {mat4} out mat4 receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @param {Number} x X component + * @param {Number} y Y component + * @returns {vec2} a new 2D vector */ -function fromZRotation(out, rad) { - let s = Math.sin(rad); - let c = Math.cos(rad); - - // Perform axis-specific matrix multiplication - out[0] = c; - out[1] = s; - out[2] = 0; - out[3] = 0; - out[4] = -s; - out[5] = c; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 1; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; +function fromValues(x, y) { + let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](2); + out[0] = x; + out[1] = y; return out; } /** - * Creates a matrix from a quaternion rotation and vector translation - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.translate(dest, vec); - * let quatMat = mat4.create(); - * quat4.toMat4(quat, quatMat); - * mat4.multiply(dest, quatMat); + * Copy the values from one vec2 to another * - * @param {mat4} out mat4 receiving operation result - * @param {quat4} q Rotation quaternion - * @param {vec3} v Translation vector - * @returns {mat4} out - */ -function fromRotationTranslation(out, q, v) { - // Quaternion math - let x = q[0], y = q[1], z = q[2], w = q[3]; - let x2 = x + x; - let y2 = y + y; - let z2 = z + z; - - let xx = x * x2; - let xy = x * y2; - let xz = x * z2; - let yy = y * y2; - let yz = y * z2; - let zz = z * z2; - let wx = w * x2; - let wy = w * y2; - let wz = w * z2; - - out[0] = 1 - (yy + zz); - out[1] = xy + wz; - out[2] = xz - wy; - out[3] = 0; - out[4] = xy - wz; - out[5] = 1 - (xx + zz); - out[6] = yz + wx; - out[7] = 0; - out[8] = xz + wy; - out[9] = yz - wx; - out[10] = 1 - (xx + yy); - out[11] = 0; - out[12] = v[0]; - out[13] = v[1]; - out[14] = v[2]; - out[15] = 1; - + * @param {vec2} out the receiving vector + * @param {vec2} a the source vector + * @returns {vec2} out + */ +function copy(out, a) { + out[0] = a[0]; + out[1] = a[1]; return out; } /** - * Returns the translation vector component of a transformation - * matrix. If a matrix is built with fromRotationTranslation, - * the returned vector will be the same as the translation vector - * originally supplied. - * @param {vec3} out Vector to receive translation component - * @param {mat4} mat Matrix to be decomposed (input) - * @return {vec3} out + * Set the components of a vec2 to the given values + * + * @param {vec2} out the receiving vector + * @param {Number} x X component + * @param {Number} y Y component + * @returns {vec2} out */ -function getTranslation(out, mat) { - out[0] = mat[12]; - out[1] = mat[13]; - out[2] = mat[14]; - +function set(out, x, y) { + out[0] = x; + out[1] = y; return out; } /** - * Returns the scaling factor component of a transformation - * matrix. If a matrix is built with fromRotationTranslationScale - * with a normalized Quaternion paramter, the returned vector will be - * the same as the scaling vector - * originally supplied. - * @param {vec3} out Vector to receive scaling factor component - * @param {mat4} mat Matrix to be decomposed (input) - * @return {vec3} out + * Adds two vec2's + * + * @param {vec2} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {vec2} out */ -function getScaling(out, mat) { - let m11 = mat[0]; - let m12 = mat[1]; - let m13 = mat[2]; - let m21 = mat[4]; - let m22 = mat[5]; - let m23 = mat[6]; - let m31 = mat[8]; - let m32 = mat[9]; - let m33 = mat[10]; - - out[0] = Math.sqrt(m11 * m11 + m12 * m12 + m13 * m13); - out[1] = Math.sqrt(m21 * m21 + m22 * m22 + m23 * m23); - out[2] = Math.sqrt(m31 * m31 + m32 * m32 + m33 * m33); - +function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; return out; } /** - * Returns a quaternion representing the rotational component - * of a transformation matrix. If a matrix is built with - * fromRotationTranslation, the returned quaternion will be the - * same as the quaternion originally supplied. - * @param {quat} out Quaternion to receive the rotation component - * @param {mat4} mat Matrix to be decomposed (input) - * @return {quat} out + * Subtracts vector b from vector a + * + * @param {vec2} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {vec2} out */ -function getRotation(out, mat) { - // Algorithm taken from http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm - let trace = mat[0] + mat[5] + mat[10]; - let S = 0; - - if (trace > 0) { - S = Math.sqrt(trace + 1.0) * 2; - out[3] = 0.25 * S; - out[0] = (mat[6] - mat[9]) / S; - out[1] = (mat[8] - mat[2]) / S; - out[2] = (mat[1] - mat[4]) / S; - } else if ((mat[0] > mat[5])&(mat[0] > mat[10])) { - S = Math.sqrt(1.0 + mat[0] - mat[5] - mat[10]) * 2; - out[3] = (mat[6] - mat[9]) / S; - out[0] = 0.25 * S; - out[1] = (mat[1] + mat[4]) / S; - out[2] = (mat[8] + mat[2]) / S; - } else if (mat[5] > mat[10]) { - S = Math.sqrt(1.0 + mat[5] - mat[0] - mat[10]) * 2; - out[3] = (mat[8] - mat[2]) / S; - out[0] = (mat[1] + mat[4]) / S; - out[1] = 0.25 * S; - out[2] = (mat[6] + mat[9]) / S; - } else { - S = Math.sqrt(1.0 + mat[10] - mat[0] - mat[5]) * 2; - out[3] = (mat[1] - mat[4]) / S; - out[0] = (mat[8] + mat[2]) / S; - out[1] = (mat[6] + mat[9]) / S; - out[2] = 0.25 * S; - } - +function subtract(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; return out; } /** - * Creates a matrix from a quaternion rotation, vector translation and vector scale - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.translate(dest, vec); - * let quatMat = mat4.create(); - * quat4.toMat4(quat, quatMat); - * mat4.multiply(dest, quatMat); - * mat4.scale(dest, scale) + * Multiplies two vec2's * - * @param {mat4} out mat4 receiving operation result - * @param {quat4} q Rotation quaternion - * @param {vec3} v Translation vector - * @param {vec3} s Scaling vector - * @returns {mat4} out + * @param {vec2} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {vec2} out */ -function fromRotationTranslationScale(out, q, v, s) { - // Quaternion math - let x = q[0], y = q[1], z = q[2], w = q[3]; - let x2 = x + x; - let y2 = y + y; - let z2 = z + z; - - let xx = x * x2; - let xy = x * y2; - let xz = x * z2; - let yy = y * y2; - let yz = y * z2; - let zz = z * z2; - let wx = w * x2; - let wy = w * y2; - let wz = w * z2; - let sx = s[0]; - let sy = s[1]; - let sz = s[2]; - - out[0] = (1 - (yy + zz)) * sx; - out[1] = (xy + wz) * sx; - out[2] = (xz - wy) * sx; - out[3] = 0; - out[4] = (xy - wz) * sy; - out[5] = (1 - (xx + zz)) * sy; - out[6] = (yz + wx) * sy; - out[7] = 0; - out[8] = (xz + wy) * sz; - out[9] = (yz - wx) * sz; - out[10] = (1 - (xx + yy)) * sz; - out[11] = 0; - out[12] = v[0]; - out[13] = v[1]; - out[14] = v[2]; - out[15] = 1; - +function multiply(out, a, b) { + out[0] = a[0] * b[0]; + out[1] = a[1] * b[1]; return out; -} +}; /** - * Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.translate(dest, vec); - * mat4.translate(dest, origin); - * let quatMat = mat4.create(); - * quat4.toMat4(quat, quatMat); - * mat4.multiply(dest, quatMat); - * mat4.scale(dest, scale) - * mat4.translate(dest, negativeOrigin); + * Divides two vec2's * - * @param {mat4} out mat4 receiving operation result - * @param {quat4} q Rotation quaternion - * @param {vec3} v Translation vector - * @param {vec3} s Scaling vector - * @param {vec3} o The origin vector around which to scale and rotate - * @returns {mat4} out + * @param {vec2} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {vec2} out */ -function fromRotationTranslationScaleOrigin(out, q, v, s, o) { - // Quaternion math - let x = q[0], y = q[1], z = q[2], w = q[3]; - let x2 = x + x; - let y2 = y + y; - let z2 = z + z; - - let xx = x * x2; - let xy = x * y2; - let xz = x * z2; - let yy = y * y2; - let yz = y * z2; - let zz = z * z2; - let wx = w * x2; - let wy = w * y2; - let wz = w * z2; - - let sx = s[0]; - let sy = s[1]; - let sz = s[2]; - - let ox = o[0]; - let oy = o[1]; - let oz = o[2]; - - out[0] = (1 - (yy + zz)) * sx; - out[1] = (xy + wz) * sx; - out[2] = (xz - wy) * sx; - out[3] = 0; - out[4] = (xy - wz) * sy; - out[5] = (1 - (xx + zz)) * sy; - out[6] = (yz + wx) * sy; - out[7] = 0; - out[8] = (xz + wy) * sz; - out[9] = (yz - wx) * sz; - out[10] = (1 - (xx + yy)) * sz; - out[11] = 0; - out[12] = v[0] + ox - (out[0] * ox + out[4] * oy + out[8] * oz); - out[13] = v[1] + oy - (out[1] * ox + out[5] * oy + out[9] * oz); - out[14] = v[2] + oz - (out[2] * ox + out[6] * oy + out[10] * oz); - out[15] = 1; - +function divide(out, a, b) { + out[0] = a[0] / b[0]; + out[1] = a[1] / b[1]; return out; -} +}; /** - * Calculates a 4x4 matrix from the given quaternion - * - * @param {mat4} out mat4 receiving operation result - * @param {quat} q Quaternion to create matrix from + * Math.ceil the components of a vec2 * - * @returns {mat4} out + * @param {vec2} out the receiving vector + * @param {vec2} a vector to ceil + * @returns {vec2} out */ -function fromQuat(out, q) { - let x = q[0], y = q[1], z = q[2], w = q[3]; - let x2 = x + x; - let y2 = y + y; - let z2 = z + z; - - let xx = x * x2; - let yx = y * x2; - let yy = y * y2; - let zx = z * x2; - let zy = z * y2; - let zz = z * z2; - let wx = w * x2; - let wy = w * y2; - let wz = w * z2; - - out[0] = 1 - yy - zz; - out[1] = yx + wz; - out[2] = zx - wy; - out[3] = 0; - - out[4] = yx - wz; - out[5] = 1 - xx - zz; - out[6] = zy + wx; - out[7] = 0; - - out[8] = zx + wy; - out[9] = zy - wx; - out[10] = 1 - xx - yy; - out[11] = 0; - - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - +function ceil(out, a) { + out[0] = Math.ceil(a[0]); + out[1] = Math.ceil(a[1]); return out; -} +}; /** - * Generates a frustum matrix with the given bounds + * Math.floor the components of a vec2 * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {Number} left Left bound of the frustum - * @param {Number} right Right bound of the frustum - * @param {Number} bottom Bottom bound of the frustum - * @param {Number} top Top bound of the frustum - * @param {Number} near Near bound of the frustum - * @param {Number} far Far bound of the frustum - * @returns {mat4} out + * @param {vec2} out the receiving vector + * @param {vec2} a vector to floor + * @returns {vec2} out */ -function frustum(out, left, right, bottom, top, near, far) { - let rl = 1 / (right - left); - let tb = 1 / (top - bottom); - let nf = 1 / (near - far); - out[0] = (near * 2) * rl; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = (near * 2) * tb; - out[6] = 0; - out[7] = 0; - out[8] = (right + left) * rl; - out[9] = (top + bottom) * tb; - out[10] = (far + near) * nf; - out[11] = -1; - out[12] = 0; - out[13] = 0; - out[14] = (far * near * 2) * nf; - out[15] = 0; +function floor(out, a) { + out[0] = Math.floor(a[0]); + out[1] = Math.floor(a[1]); return out; -} +}; /** - * Generates a perspective projection matrix with the given bounds + * Returns the minimum of two vec2's * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {number} fovy Vertical field of view in radians - * @param {number} aspect Aspect ratio. typically viewport width/height - * @param {number} near Near bound of the frustum - * @param {number} far Far bound of the frustum - * @returns {mat4} out + * @param {vec2} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {vec2} out */ -function perspective(out, fovy, aspect, near, far) { - let f = 1.0 / Math.tan(fovy / 2); - let nf = 1 / (near - far); - out[0] = f / aspect; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = f; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = (far + near) * nf; - out[11] = -1; - out[12] = 0; - out[13] = 0; - out[14] = (2 * far * near) * nf; - out[15] = 0; +function min(out, a, b) { + out[0] = Math.min(a[0], b[0]); + out[1] = Math.min(a[1], b[1]); return out; -} +}; /** - * Generates a perspective projection matrix with the given field of view. - * This is primarily useful for generating projection matrices to be used - * with the still experiemental WebVR API. + * Returns the maximum of two vec2's * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees - * @param {number} near Near bound of the frustum - * @param {number} far Far bound of the frustum - * @returns {mat4} out + * @param {vec2} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {vec2} out */ -function perspectiveFromFieldOfView(out, fov, near, far) { - let upTan = Math.tan(fov.upDegrees * Math.PI/180.0); - let downTan = Math.tan(fov.downDegrees * Math.PI/180.0); - let leftTan = Math.tan(fov.leftDegrees * Math.PI/180.0); - let rightTan = Math.tan(fov.rightDegrees * Math.PI/180.0); - let xScale = 2.0 / (leftTan + rightTan); - let yScale = 2.0 / (upTan + downTan); - - out[0] = xScale; - out[1] = 0.0; - out[2] = 0.0; - out[3] = 0.0; - out[4] = 0.0; - out[5] = yScale; - out[6] = 0.0; - out[7] = 0.0; - out[8] = -((leftTan - rightTan) * xScale * 0.5); - out[9] = ((upTan - downTan) * yScale * 0.5); - out[10] = far / (near - far); - out[11] = -1.0; - out[12] = 0.0; - out[13] = 0.0; - out[14] = (far * near) / (near - far); - out[15] = 0.0; +function max(out, a, b) { + out[0] = Math.max(a[0], b[0]); + out[1] = Math.max(a[1], b[1]); return out; -} +}; /** - * Generates a orthogonal projection matrix with the given bounds + * Math.round the components of a vec2 * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {number} left Left bound of the frustum - * @param {number} right Right bound of the frustum - * @param {number} bottom Bottom bound of the frustum - * @param {number} top Top bound of the frustum - * @param {number} near Near bound of the frustum - * @param {number} far Far bound of the frustum - * @returns {mat4} out + * @param {vec2} out the receiving vector + * @param {vec2} a vector to round + * @returns {vec2} out */ -function ortho(out, left, right, bottom, top, near, far) { - let lr = 1 / (left - right); - let bt = 1 / (bottom - top); - let nf = 1 / (near - far); - out[0] = -2 * lr; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = -2 * bt; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 2 * nf; - out[11] = 0; - out[12] = (left + right) * lr; - out[13] = (top + bottom) * bt; - out[14] = (far + near) * nf; - out[15] = 1; +function round (out, a) { + out[0] = Math.round(a[0]); + out[1] = Math.round(a[1]); return out; -} +}; /** - * Generates a look-at matrix with the given eye position, focal point, and up axis + * Scales a vec2 by a scalar number * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {vec3} eye Position of the viewer - * @param {vec3} center Point the viewer is looking at - * @param {vec3} up vec3 pointing up - * @returns {mat4} out + * @param {vec2} out the receiving vector + * @param {vec2} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {vec2} out */ -function lookAt(out, eye, center, up) { - let x0, x1, x2, y0, y1, y2, z0, z1, z2, len; - let eyex = eye[0]; - let eyey = eye[1]; - let eyez = eye[2]; - let upx = up[0]; - let upy = up[1]; - let upz = up[2]; - let centerx = center[0]; - let centery = center[1]; - let centerz = center[2]; - - if (Math.abs(eyex - centerx) < __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"] && - Math.abs(eyey - centery) < __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"] && - Math.abs(eyez - centerz) < __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]) { - return mat4.identity(out); - } - - z0 = eyex - centerx; - z1 = eyey - centery; - z2 = eyez - centerz; +function scale(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + return out; +}; - len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); - z0 *= len; - z1 *= len; - z2 *= len; +/** + * Adds two vec2's after scaling the second operand by a scalar value + * + * @param {vec2} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @param {Number} scale the amount to scale b by before adding + * @returns {vec2} out + */ +function scaleAndAdd(out, a, b, scale) { + out[0] = a[0] + (b[0] * scale); + out[1] = a[1] + (b[1] * scale); + return out; +}; - x0 = upy * z2 - upz * z1; - x1 = upz * z0 - upx * z2; - x2 = upx * z1 - upy * z0; - len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); - if (!len) { - x0 = 0; - x1 = 0; - x2 = 0; - } else { - len = 1 / len; - x0 *= len; - x1 *= len; - x2 *= len; - } +/** + * Calculates the euclidian distance between two vec2's + * + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {Number} distance between a and b + */ +function distance(a, b) { + var x = b[0] - a[0], + y = b[1] - a[1]; + return Math.sqrt(x*x + y*y); +}; - y0 = z1 * x2 - z2 * x1; - y1 = z2 * x0 - z0 * x2; - y2 = z0 * x1 - z1 * x0; +/** + * Calculates the squared euclidian distance between two vec2's + * + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {Number} squared distance between a and b + */ +function squaredDistance(a, b) { + var x = b[0] - a[0], + y = b[1] - a[1]; + return x*x + y*y; +}; - len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); - if (!len) { - y0 = 0; - y1 = 0; - y2 = 0; - } else { - len = 1 / len; - y0 *= len; - y1 *= len; - y2 *= len; - } +/** + * Calculates the length of a vec2 + * + * @param {vec2} a vector to calculate length of + * @returns {Number} length of a + */ +function length(a) { + var x = a[0], + y = a[1]; + return Math.sqrt(x*x + y*y); +}; - out[0] = x0; - out[1] = y0; - out[2] = z0; - out[3] = 0; - out[4] = x1; - out[5] = y1; - out[6] = z1; - out[7] = 0; - out[8] = x2; - out[9] = y2; - out[10] = z2; - out[11] = 0; - out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); - out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); - out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); - out[15] = 1; +/** + * Calculates the squared length of a vec2 + * + * @param {vec2} a vector to calculate squared length of + * @returns {Number} squared length of a + */ +function squaredLength (a) { + var x = a[0], + y = a[1]; + return x*x + y*y; +}; +/** + * Negates the components of a vec2 + * + * @param {vec2} out the receiving vector + * @param {vec2} a vector to negate + * @returns {vec2} out + */ +function negate(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; return out; -} +}; /** - * Generates a matrix that makes something look at something else. + * Returns the inverse of the components of a vec2 * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {vec3} eye Position of the viewer - * @param {vec3} center Point the viewer is looking at - * @param {vec3} up vec3 pointing up - * @returns {mat4} out + * @param {vec2} out the receiving vector + * @param {vec2} a vector to invert + * @returns {vec2} out */ -function targetTo(out, eye, target, up) { - let eyex = eye[0], - eyey = eye[1], - eyez = eye[2], - upx = up[0], - upy = up[1], - upz = up[2]; - - let z0 = eyex - target[0], - z1 = eyey - target[1], - z2 = eyez - target[2]; +function inverse(out, a) { + out[0] = 1.0 / a[0]; + out[1] = 1.0 / a[1]; + return out; +}; - let len = z0*z0 + z1*z1 + z2*z2; +/** + * Normalize a vec2 + * + * @param {vec2} out the receiving vector + * @param {vec2} a vector to normalize + * @returns {vec2} out + */ +function normalize(out, a) { + var x = a[0], + y = a[1]; + var len = x*x + y*y; if (len > 0) { + //TODO: evaluate use of glm_invsqrt here? len = 1 / Math.sqrt(len); - z0 *= len; - z1 *= len; - z2 *= len; + out[0] = a[0] * len; + out[1] = a[1] * len; } + return out; +}; - let x0 = upy * z2 - upz * z1, - x1 = upz * z0 - upx * z2, - x2 = upx * z1 - upy * z0; +/** + * Calculates the dot product of two vec2's + * + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {Number} dot product of a and b + */ +function dot(a, b) { + return a[0] * b[0] + a[1] * b[1]; +}; - out[0] = x0; - out[1] = x1; - out[2] = x2; - out[3] = 0; - out[4] = z1 * x2 - z2 * x1; - out[5] = z2 * x0 - z0 * x2; - out[6] = z0 * x1 - z1 * x0; - out[7] = 0; - out[8] = z0; - out[9] = z1; - out[10] = z2; - out[11] = 0; - out[12] = eyex; - out[13] = eyey; - out[14] = eyez; - out[15] = 1; +/** + * Computes the cross product of two vec2's + * Note that the cross product must by definition produce a 3D vector + * + * @param {vec3} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @returns {vec3} out + */ +function cross(out, a, b) { + var z = a[0] * b[1] - a[1] * b[0]; + out[0] = out[1] = 0; + out[2] = z; return out; }; /** - * Returns a string representation of a mat4 + * Performs a linear interpolation between two vec2's * - * @param {mat4} a matrix to represent as a string - * @returns {String} string representation of the matrix + * @param {vec2} out the receiving vector + * @param {vec2} a the first operand + * @param {vec2} b the second operand + * @param {Number} t interpolation amount between the two inputs + * @returns {vec2} out */ -function str(a) { - return 'mat4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + - a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + - a[8] + ', ' + a[9] + ', ' + a[10] + ', ' + a[11] + ', ' + - a[12] + ', ' + a[13] + ', ' + a[14] + ', ' + a[15] + ')'; -} +function lerp(out, a, b, t) { + var ax = a[0], + ay = a[1]; + out[0] = ax + t * (b[0] - ax); + out[1] = ay + t * (b[1] - ay); + return out; +}; /** - * Returns Frobenius norm of a mat4 + * Generates a random vector with the given scale * - * @param {mat4} a the matrix to calculate Frobenius norm of - * @returns {Number} Frobenius norm + * @param {vec2} out the receiving vector + * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned + * @returns {vec2} out */ -function frob(a) { - return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2) + Math.pow(a[9], 2) + Math.pow(a[10], 2) + Math.pow(a[11], 2) + Math.pow(a[12], 2) + Math.pow(a[13], 2) + Math.pow(a[14], 2) + Math.pow(a[15], 2) )) -} +function random(out, scale) { + scale = scale || 1.0; + var r = __WEBPACK_IMPORTED_MODULE_0__common__["RANDOM"]() * 2.0 * Math.PI; + out[0] = Math.cos(r) * scale; + out[1] = Math.sin(r) * scale; + return out; +}; /** - * Adds two mat4's + * Transforms the vec2 with a mat2 * - * @param {mat4} out the receiving matrix - * @param {mat4} a the first operand - * @param {mat4} b the second operand - * @returns {mat4} out + * @param {vec2} out the receiving vector + * @param {vec2} a the vector to transform + * @param {mat2} m matrix to transform with + * @returns {vec2} out */ -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - out[3] = a[3] + b[3]; - out[4] = a[4] + b[4]; - out[5] = a[5] + b[5]; - out[6] = a[6] + b[6]; - out[7] = a[7] + b[7]; - out[8] = a[8] + b[8]; - out[9] = a[9] + b[9]; - out[10] = a[10] + b[10]; - out[11] = a[11] + b[11]; - out[12] = a[12] + b[12]; - out[13] = a[13] + b[13]; - out[14] = a[14] + b[14]; - out[15] = a[15] + b[15]; +function transformMat2(out, a, m) { + var x = a[0], + y = a[1]; + out[0] = m[0] * x + m[2] * y; + out[1] = m[1] * x + m[3] * y; return out; -} +}; /** - * Subtracts matrix b from matrix a + * Transforms the vec2 with a mat2d * - * @param {mat4} out the receiving matrix - * @param {mat4} a the first operand - * @param {mat4} b the second operand - * @returns {mat4} out + * @param {vec2} out the receiving vector + * @param {vec2} a the vector to transform + * @param {mat2d} m matrix to transform with + * @returns {vec2} out */ -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; - out[3] = a[3] - b[3]; - out[4] = a[4] - b[4]; - out[5] = a[5] - b[5]; - out[6] = a[6] - b[6]; - out[7] = a[7] - b[7]; - out[8] = a[8] - b[8]; - out[9] = a[9] - b[9]; - out[10] = a[10] - b[10]; - out[11] = a[11] - b[11]; - out[12] = a[12] - b[12]; - out[13] = a[13] - b[13]; - out[14] = a[14] - b[14]; - out[15] = a[15] - b[15]; +function transformMat2d(out, a, m) { + var x = a[0], + y = a[1]; + out[0] = m[0] * x + m[2] * y + m[4]; + out[1] = m[1] * x + m[3] * y + m[5]; return out; -} +}; /** - * Multiply each element of the matrix by a scalar. + * Transforms the vec2 with a mat3 + * 3rd vector component is implicitly '1' * - * @param {mat4} out the receiving matrix - * @param {mat4} a the matrix to scale - * @param {Number} b amount to scale the matrix's elements by - * @returns {mat4} out + * @param {vec2} out the receiving vector + * @param {vec2} a the vector to transform + * @param {mat3} m matrix to transform with + * @returns {vec2} out */ -function multiplyScalar(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - out[3] = a[3] * b; - out[4] = a[4] * b; - out[5] = a[5] * b; - out[6] = a[6] * b; - out[7] = a[7] * b; - out[8] = a[8] * b; - out[9] = a[9] * b; - out[10] = a[10] * b; - out[11] = a[11] * b; - out[12] = a[12] * b; - out[13] = a[13] * b; - out[14] = a[14] * b; - out[15] = a[15] * b; +function transformMat3(out, a, m) { + var x = a[0], + y = a[1]; + out[0] = m[0] * x + m[3] * y + m[6]; + out[1] = m[1] * x + m[4] * y + m[7]; return out; -} +}; /** - * Adds two mat4's after multiplying each element of the second operand by a scalar value. + * Transforms the vec2 with a mat4 + * 3rd vector component is implicitly '0' + * 4th vector component is implicitly '1' * - * @param {mat4} out the receiving vector - * @param {mat4} a the first operand - * @param {mat4} b the second operand - * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat4} out + * @param {vec2} out the receiving vector + * @param {vec2} a the vector to transform + * @param {mat4} m matrix to transform with + * @returns {vec2} out */ -function multiplyScalarAndAdd(out, a, b, scale) { - out[0] = a[0] + (b[0] * scale); - out[1] = a[1] + (b[1] * scale); - out[2] = a[2] + (b[2] * scale); - out[3] = a[3] + (b[3] * scale); - out[4] = a[4] + (b[4] * scale); - out[5] = a[5] + (b[5] * scale); - out[6] = a[6] + (b[6] * scale); - out[7] = a[7] + (b[7] * scale); - out[8] = a[8] + (b[8] * scale); - out[9] = a[9] + (b[9] * scale); - out[10] = a[10] + (b[10] * scale); - out[11] = a[11] + (b[11] * scale); - out[12] = a[12] + (b[12] * scale); - out[13] = a[13] + (b[13] * scale); - out[14] = a[14] + (b[14] * scale); - out[15] = a[15] + (b[15] * scale); +function transformMat4(out, a, m) { + let x = a[0]; + let y = a[1]; + out[0] = m[0] * x + m[4] * y + m[12]; + out[1] = m[1] * x + m[5] * y + m[13]; return out; } /** - * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * Returns a string representation of a vector * - * @param {mat4} a The first matrix. - * @param {mat4} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. + * @param {vec2} a vector to represent as a string + * @returns {String} string representation of the vector + */ +function str(a) { + return 'vec2(' + a[0] + ', ' + a[1] + ')'; +} + +/** + * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===) + * + * @param {vec2} a The first vector. + * @param {vec2} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. */ function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && - a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && - a[8] === b[8] && a[9] === b[9] && a[10] === b[10] && a[11] === b[11] && - a[12] === b[12] && a[13] === b[13] && a[14] === b[14] && a[15] === b[15]; + return a[0] === b[0] && a[1] === b[1]; } /** - * Returns whether or not the matrices have approximately the same elements in the same position. + * Returns whether or not the vectors have approximately the same elements in the same position. * - * @param {mat4} a The first matrix. - * @param {mat4} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. + * @param {vec2} a The first vector. + * @param {vec2} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. */ function equals(a, b) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - let a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7]; - let a8 = a[8], a9 = a[9], a10 = a[10], a11 = a[11]; - let a12 = a[12], a13 = a[13], a14 = a[14], a15 = a[15]; - - let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - let b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7]; - let b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11]; - let b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15]; - + let a0 = a[0], a1 = a[1]; + let b0 = b[0], b1 = b[1]; return (Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && - Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1)) && - Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a2), Math.abs(b2)) && - Math.abs(a3 - b3) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a3), Math.abs(b3)) && - Math.abs(a4 - b4) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a4), Math.abs(b4)) && - Math.abs(a5 - b5) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a5), Math.abs(b5)) && - Math.abs(a6 - b6) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a6), Math.abs(b6)) && - Math.abs(a7 - b7) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a7), Math.abs(b7)) && - Math.abs(a8 - b8) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a8), Math.abs(b8)) && - Math.abs(a9 - b9) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a9), Math.abs(b9)) && - Math.abs(a10 - b10) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a10), Math.abs(b10)) && - Math.abs(a11 - b11) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a11), Math.abs(b11)) && - Math.abs(a12 - b12) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a12), Math.abs(b12)) && - Math.abs(a13 - b13) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a13), Math.abs(b13)) && - Math.abs(a14 - b14) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a14), Math.abs(b14)) && - Math.abs(a15 - b15) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a15), Math.abs(b15))); + Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1))); } /** - * Alias for {@link mat4.multiply} + * Alias for {@link vec2.length} * @function */ -const mul = multiply; -/* harmony export (immutable) */ __webpack_exports__["mul"] = mul; +const len = length; +/* harmony export (immutable) */ __webpack_exports__["len"] = len; /** - * Alias for {@link mat4.subtract} + * Alias for {@link vec2.subtract} * @function */ const sub = subtract; /* harmony export (immutable) */ __webpack_exports__["sub"] = sub; +/** + * Alias for {@link vec2.multiply} + * @function + */ +const mul = multiply; +/* harmony export (immutable) */ __webpack_exports__["mul"] = mul; -/***/ }), -/* 70 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { -"use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony export (immutable) */ __webpack_exports__["create"] = create; -/* harmony export (immutable) */ __webpack_exports__["identity"] = identity; -/* harmony export (immutable) */ __webpack_exports__["setAxisAngle"] = setAxisAngle; -/* harmony export (immutable) */ __webpack_exports__["getAxisAngle"] = getAxisAngle; -/* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply; -/* harmony export (immutable) */ __webpack_exports__["rotateX"] = rotateX; -/* harmony export (immutable) */ __webpack_exports__["rotateY"] = rotateY; -/* harmony export (immutable) */ __webpack_exports__["rotateZ"] = rotateZ; -/* harmony export (immutable) */ __webpack_exports__["calculateW"] = calculateW; -/* harmony export (immutable) */ __webpack_exports__["slerp"] = slerp; -/* harmony export (immutable) */ __webpack_exports__["invert"] = invert; -/* harmony export (immutable) */ __webpack_exports__["conjugate"] = conjugate; -/* harmony export (immutable) */ __webpack_exports__["fromMat3"] = fromMat3; -/* harmony export (immutable) */ __webpack_exports__["fromEuler"] = fromEuler; -/* harmony export (immutable) */ __webpack_exports__["str"] = str; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__mat3__ = __webpack_require__(31); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__vec3__ = __webpack_require__(32); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__vec4__ = __webpack_require__(33); -/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. +/** + * Alias for {@link vec2.divide} + * @function + */ +const div = divide; +/* harmony export (immutable) */ __webpack_exports__["div"] = div; + + +/** + * Alias for {@link vec2.distance} + * @function + */ +const dist = distance; +/* harmony export (immutable) */ __webpack_exports__["dist"] = dist; + + +/** + * Alias for {@link vec2.squaredDistance} + * @function + */ +const sqrDist = squaredDistance; +/* harmony export (immutable) */ __webpack_exports__["sqrDist"] = sqrDist; + + +/** + * Alias for {@link vec2.squaredLength} + * @function + */ +const sqrLen = squaredLength; +/* harmony export (immutable) */ __webpack_exports__["sqrLen"] = sqrLen; + + +/** + * Perform some operation over an array of vec2s. + * + * @param {Array} a the array of vectors to iterate over + * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed + * @param {Number} offset Number of elements to skip at the beginning of the array + * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array + * @param {Function} fn Function to call for each vector in the array + * @param {Object} [arg] additional argument to pass to fn + * @returns {Array} a + * @function + */ +const forEach = (function() { + let vec = create(); + + return function(a, stride, offset, count, fn, arg) { + let i, l; + if(!stride) { + stride = 2; + } + + if(!offset) { + offset = 0; + } + + if(count) { + l = Math.min((count * stride) + offset, a.length); + } else { + l = a.length; + } + + for(i = offset; i < l; i += stride) { + vec[0] = a[i]; vec[1] = a[i+1]; + fn(vec, vec, arg); + a[i] = vec[0]; a[i+1] = vec[1]; + } -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: + return a; + }; +})(); +/* harmony export (immutable) */ __webpack_exports__["forEach"] = forEach; -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. */ +/***/ }), +/* 73 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.quat = undefined; +var _glMatrix = __webpack_require__(7); +exports.quat = _glMatrix.quat; -/** - * Quaternion - * @module quat +/** + * QuaternionExp + * + * @param {quat} out + * @param {quat|vec3} a + * @returns {quat} */ -/** - * Creates a new identity quat - * - * @returns {quat} a new quaternion +_glMatrix.quat.exp = function (out, a) { + var norm = Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]); + if (norm) { + out[0] = Math.sin(norm) * a[0] / norm; + out[1] = Math.sin(norm) * a[1] / norm; + out[2] = Math.sin(norm) * a[2] / norm; + out[3] = Math.cos(norm); + } else { + out[0] = 0.0; + out[1] = 0.0; + out[2] = 0.0; + out[3] = 1.0; + } + return out; +}; + +/** + * QuaternionLn + * + * @param {quat} out + * @param {quat} q + * @returns {quat} */ -function create() { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](4); - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 1; - return out; -} +_glMatrix.quat.ln = function (out, q) { + var norm = _glMatrix.quat.length(q); + if (norm > 1.0001 || norm < 0.99999) { + out[0] = q[0]; + out[1] = q[1]; + out[2] = q[2]; + out[3] = 0.0; + } else { + norm = Math.sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2]); + if (norm) { + var theta = Math.atan2(norm, q[3]) / norm; + out[0] = theta * q[0]; + out[1] = theta * q[1]; + out[2] = theta * q[2]; + out[3] = 0.0; + } else { + out[0] = 0.0; + out[1] = 0.0; + out[2] = 0.0; + out[3] = 0.0; + } + } + return out; +}; -/** - * Set a quat to the identity quaternion - * - * @param {quat} out the receiving quaternion - * @returns {quat} out +/** + * QuaternionPow + * + * @param {quat} out + * @param {quat} inq + * @param {number} exponent + * @returns {quat} */ -function identity(out) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 1; - return out; -} +_glMatrix.quat.pow = function (out, inq, exponent) { + if (exponent === 1) { + return _glMatrix.quat.copy(out, inq); + } -/** - * Sets a quat from the given angle and rotation axis, - * then returns it. - * - * @param {quat} out the receiving quaternion - * @param {vec3} axis the axis around which to rotate - * @param {Number} rad the angle in radians - * @returns {quat} out - **/ -function setAxisAngle(out, axis, rad) { - rad = rad * 0.5; - let s = Math.sin(rad); - out[0] = s * axis[0]; - out[1] = s * axis[1]; - out[2] = s * axis[2]; - out[3] = Math.cos(rad); - return out; -} + _glMatrix.quat.ln(out, inq); + out[0] *= exponent; + out[1] *= exponent; + out[2] *= exponent; + out[3] *= exponent; + _glMatrix.quat.exp(out, out); + return out; +}; -/** - * Gets the rotation axis and angle for a given - * quaternion. If a quaternion is created with - * setAxisAngle, this method will return the same - * values as providied in the original parameter list - * OR functionally equivalent values. - * Example: The quaternion formed by axis [0, 0, 1] and - * angle -90 is the same as the quaternion formed by - * [0, 0, 1] and 270. This method favors the latter. - * @param {vec3} out_axis Vector receiving the axis of rotation - * @param {quat} q Quaternion to be decomposed - * @return {Number} Angle, in radians, of the rotation - */ -function getAxisAngle(out_axis, q) { - let rad = Math.acos(q[3]) * 2.0; - let s = Math.sin(rad / 2.0); - if (s != 0.0) { - out_axis[0] = q[0] / s; - out_axis[1] = q[1] / s; - out_axis[2] = q[2] / s; - } else { - // If s is zero, return any axis (no rotation - axis does not matter) - out_axis[0] = 1; - out_axis[1] = 0; - out_axis[2] = 0; - } - return rad; -} +/***/ }), +/* 74 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * Multiplies two quat's - * - * @param {quat} out the receiving quaternion - * @param {quat} a the first operand - * @param {quat} b the second operand - * @returns {quat} out - */ -function multiply(out, a, b) { - let ax = a[0], ay = a[1], az = a[2], aw = a[3]; - let bx = b[0], by = b[1], bz = b[2], bw = b[3]; +"use strict"; - out[0] = ax * bw + aw * bx + ay * bz - az * by; - out[1] = ay * bw + aw * by + az * bx - ax * bz; - out[2] = az * bw + aw * bz + ax * by - ay * bx; - out[3] = aw * bw - ax * bx - ay * by - az * bz; - return out; -} -/** - * Rotates a quaternion by the given angle about the X axis - * - * @param {quat} out quat receiving operation result - * @param {quat} a quat to rotate - * @param {number} rad angle (in radians) to rotate - * @returns {quat} out - */ -function rotateX(out, a, rad) { - rad *= 0.5; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.mat3 = undefined; - let ax = a[0], ay = a[1], az = a[2], aw = a[3]; - let bx = Math.sin(rad), bw = Math.cos(rad); +var _glMatrix = __webpack_require__(7); - out[0] = ax * bw + aw * bx; - out[1] = ay * bw + az * bx; - out[2] = az * bw - ay * bx; - out[3] = aw * bw - ax * bx; - return out; -} +exports.mat3 = _glMatrix.mat3; -/** - * Rotates a quaternion by the given angle about the Y axis - * - * @param {quat} out quat receiving operation result - * @param {quat} a quat to rotate - * @param {number} rad angle (in radians) to rotate - * @returns {quat} out - */ -function rotateY(out, a, rad) { - rad *= 0.5; +/***/ }), +/* 75 */ +/***/ (function(module, exports, __webpack_require__) { - let ax = a[0], ay = a[1], az = a[2], aw = a[3]; - let by = Math.sin(rad), bw = Math.cos(rad); +"use strict"; - out[0] = ax * bw - az * by; - out[1] = ay * bw + aw * by; - out[2] = az * bw + ax * by; - out[3] = aw * bw - ay * by; - return out; -} -/** - * Rotates a quaternion by the given angle about the Z axis - * - * @param {quat} out quat receiving operation result - * @param {quat} a quat to rotate - * @param {number} rad angle (in radians) to rotate - * @returns {quat} out - */ -function rotateZ(out, a, rad) { - rad *= 0.5; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.mat4 = undefined; - let ax = a[0], ay = a[1], az = a[2], aw = a[3]; - let bz = Math.sin(rad), bw = Math.cos(rad); +var _glMatrix = __webpack_require__(7); - out[0] = ax * bw + ay * bz; - out[1] = ay * bw - ax * bz; - out[2] = az * bw + aw * bz; - out[3] = aw * bw - az * bz; - return out; -} +exports.mat4 = _glMatrix.mat4; -/** - * Calculates the W component of a quat from the X, Y, and Z components. - * Assumes that quaternion is 1 unit in length. - * Any existing W component will be ignored. - * - * @param {quat} out the receiving quaternion - * @param {quat} a quat to calculate W component of - * @returns {quat} out +/** + * arcFromForward + * @param {mat4} out + * @param {vec3} v + * @return {mat4} out */ -function calculateW(out, a) { - let x = a[0], y = a[1], z = a[2]; - out[0] = x; - out[1] = y; - out[2] = z; - out[3] = Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z)); - return out; -} +_glMatrix.mat4.arcFromForward = function () { + var vec3_0 = void 0; -/** - * Performs a spherical linear interpolation between two quat - * - * @param {quat} out the receiving quaternion - * @param {quat} a the first operand - * @param {quat} b the second operand - * @param {Number} t interpolation amount between the two inputs - * @returns {quat} out - */ -function slerp(out, a, b, t) { - // benchmarks: - // http://jsperf.com/quaternion-slerp-implementations - let ax = a[0], ay = a[1], az = a[2], aw = a[3]; - let bx = b[0], by = b[1], bz = b[2], bw = b[3]; + return function arcFromForward(out, v) { + if (!vec3_0) vec3_0 = _glMatrix.vec3.create(); - let omega, cosom, sinom, scale0, scale1; + var norm = _glMatrix.vec3.normalize(vec3_0, v); + _glMatrix.mat4.identity(out); - // calc cosine - cosom = ax * bx + ay * by + az * bz + aw * bw; - // adjust signs (if necessary) - if ( cosom < 0.0 ) { - cosom = -cosom; - bx = - bx; - by = - by; - bz = - bz; - bw = - bw; - } - // calculate coefficients - if ( (1.0 - cosom) > 0.000001 ) { - // standard case (slerp) - omega = Math.acos(cosom); - sinom = Math.sin(omega); - scale0 = Math.sin((1.0 - t) * omega) / sinom; - scale1 = Math.sin(t * omega) / sinom; - } else { - // "from" and "to" quaternions are very close - // ... so we can do a linear interpolation - scale0 = 1.0 - t; - scale1 = t; - } - // calculate final values - out[0] = scale0 * ax + scale1 * bx; - out[1] = scale0 * ay + scale1 * by; - out[2] = scale0 * az + scale1 * bz; - out[3] = scale0 * aw + scale1 * bw; + if (norm[2] < -0.99999) { + return out; + } - return out; -} + if (norm[2] > 0.99999) { + out[5] = -1.0; + out[10] = -1.0; + return out; + } -/** - * Calculates the inverse of a quat - * - * @param {quat} out the receiving quaternion - * @param {quat} a quat to calculate inverse of - * @returns {quat} out - */ -function invert(out, a) { - let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - let dot = a0*a0 + a1*a1 + a2*a2 + a3*a3; - let invDot = dot ? 1.0/dot : 0; + var h = (1 + norm[2]) / (norm[0] * norm[0] + norm[1] * norm[1]); + out[0] = h * norm[1] * norm[1] - norm[2]; + out[1] = -h * norm[0] * norm[1]; + out[2] = norm[0]; - // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 + out[4] = out[1]; + out[5] = h * norm[0] * norm[0] - norm[2]; + out[6] = norm[1]; - out[0] = -a0*invDot; - out[1] = -a1*invDot; - out[2] = -a2*invDot; - out[3] = a3*invDot; - return out; -} + out[8] = -norm[0]; + out[9] = -norm[1]; + out[10] = -norm[2]; -/** - * Calculates the conjugate of a quat - * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result. - * - * @param {quat} out the receiving quaternion - * @param {quat} a quat to calculate conjugate of - * @returns {quat} out + return out; + }; +}(); + +/** + * Copies the translation component from one mat4 to another + * @param {mat4} out + * @param {mat4} a + * @returns {mat4} out */ -function conjugate(out, a) { - out[0] = -a[0]; - out[1] = -a[1]; - out[2] = -a[2]; - out[3] = a[3]; - return out; -} +_glMatrix.mat4.copyTranslation = function (out, a) { + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + return out; +}; -/** - * Creates a quaternion from the given 3x3 rotation matrix. - * - * NOTE: The resultant quaternion is not normalized, so you should be sure - * to renormalize the quaternion yourself where necessary. - * - * @param {quat} out the receiving quaternion - * @param {mat3} m rotation matrix - * @returns {quat} out - * @function +/** + * Sets a mat4 from a mat4 + * @param {mat4} out + * @param {mat3} m + * @returns {mat4} out */ -function fromMat3(out, m) { - // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes - // article "Quaternion Calculus and Fast Animation". - let fTrace = m[0] + m[4] + m[8]; - let fRoot; +_glMatrix.mat4.fromMat3 = function (out, m) { + out[0] = m[0]; + out[1] = m[1]; + out[2] = m[2]; + out[4] = m[3]; + out[5] = m[4]; + out[6] = m[5]; + out[8] = m[6]; + out[9] = m[7]; + out[10] = m[8]; + out[3] = out[7] = out[11] = out[12] = out[13] = out[14] = 0; + out[15] = 1; + return out; +}; - if ( fTrace > 0.0 ) { - // |w| > 1/2, may as well choose w > 1/2 - fRoot = Math.sqrt(fTrace + 1.0); // 2w - out[3] = 0.5 * fRoot; - fRoot = 0.5/fRoot; // 1/(4w) - out[0] = (m[5]-m[7])*fRoot; - out[1] = (m[6]-m[2])*fRoot; - out[2] = (m[1]-m[3])*fRoot; - } else { - // |w| <= 1/2 - let i = 0; - if ( m[4] > m[0] ) - i = 1; - if ( m[8] > m[i*3+i] ) - i = 2; - let j = (i+1)%3; - let k = (i+2)%3; +/** + * Generates a look-at matrix with the given eye position, focal point, and up axis from a left handed coordinate system + * + * @param {mat4} out - mat4 frustum matrix will be written into + * @param {vec3} eye - Position of the viewer + * @param {vec3} center - Point the viewer is looking at + * @param {vec3} up - vec3 pointing up + * @returns {mat4} out + */ +_glMatrix.mat4.lookAtGL = function () { + var vec3_0 = void 0, + vec3_1 = void 0, + vec3_2 = void 0; - fRoot = Math.sqrt(m[i*3+i]-m[j*3+j]-m[k*3+k] + 1.0); - out[i] = 0.5 * fRoot; - fRoot = 0.5 / fRoot; - out[3] = (m[j*3+k] - m[k*3+j]) * fRoot; - out[j] = (m[j*3+i] + m[i*3+j]) * fRoot; - out[k] = (m[k*3+i] + m[i*3+k]) * fRoot; - } + return function lookAtGL(out, eye, center, up) { + if (!vec3_0) { + vec3_0 = _glMatrix.vec3.create(); + vec3_1 = _glMatrix.vec3.create(); + vec3_2 = _glMatrix.vec3.create(); + } - return out; -} + _glMatrix.vec3.subtract(vec3_2, eye, center); -/** - * Creates a quaternion from the given euler angle x, y, z. - * - * @param {quat} out the receiving quaternion - * @param {x} Angle to rotate around X axis in degrees. - * @param {y} Angle to rotate around Y axis in degrees. - * @param {z} Angle to rotate around Z axis in degrees. - * @returns {quat} out - * @function - */ -function fromEuler(out, x, y, z) { - let halfToRad = 0.5 * Math.PI / 180.0; - x *= halfToRad; - y *= halfToRad; - z *= halfToRad; + if (_glMatrix.vec3.squaredLength(vec3_2) === 0) { + vec3_2[2] = 1; + } + + _glMatrix.vec3.normalize(vec3_2, vec3_2); + _glMatrix.vec3.cross(vec3_0, up, vec3_2); + + if (_glMatrix.vec3.squaredLength(vec3_0) === 0) { + vec3_2[2] += 0.0001; + _glMatrix.vec3.cross(vec3_0, up, vec3_2); + } + + _glMatrix.vec3.normalize(vec3_0, vec3_0); + _glMatrix.vec3.cross(vec3_1, vec3_2, vec3_0); + + out[0] = vec3_0[0]; + out[1] = vec3_0[1]; + out[2] = vec3_0[2]; - let sx = Math.sin(x); - let cx = Math.cos(x); - let sy = Math.sin(y); - let cy = Math.cos(y); - let sz = Math.sin(z); - let cz = Math.cos(z); + out[4] = vec3_1[0]; + out[5] = vec3_1[1]; + out[6] = vec3_1[2]; - out[0] = sx * cy * cz - cx * sy * sz; - out[1] = cx * sy * cz + sx * cy * sz; - out[2] = cx * cy * sz - sx * sy * cz; - out[3] = cx * cy * cz + sx * sy * sz; + out[8] = vec3_2[0]; + out[9] = vec3_2[1]; + out[10] = vec3_2[2]; - return out; -} + return out; + }; +}(); -/** - * Returns a string representation of a quatenion - * - * @param {quat} a vector to represent as a string - * @returns {String} string representation of the vector +/** + * Sets a left handed co-ordinate system perspective from a right handed co-ordinate system + * @param {mat4} out - receiving mat4 + * @param {number} fovY - Vertical field of view in radians + * @param {number} aspect - Aspect ratio. typically viewport width/height + * @param {number} near - Near bound of the frustum + * @param {number} far - Far bound of the frustum + * @returns {mat4} out - receiving mat4 */ -function str(a) { - return 'quat(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')'; -} +_glMatrix.mat4.perspectiveGL = function (out, fovY, aspect, near, far) { + var fH = Math.tan(fovY / 360 * Math.PI) * near; + var fW = fH * aspect; + _glMatrix.mat4.frustum(out, -fW, fW, -fH, fH, near, far); + return out; +}; -/** - * Creates a new quat initialized with values from an existing quaternion - * - * @param {quat} a quaternion to clone - * @returns {quat} a new quaternion - * @function +/** + * Sets the translation component of a mat4 from a vec3 + * @param {mat4} out + * @param {vec3} v + * @returns {mat4} out */ -const clone = __WEBPACK_IMPORTED_MODULE_3__vec4__["clone"]; -/* harmony export (immutable) */ __webpack_exports__["clone"] = clone; - +_glMatrix.mat4.setTranslation = function (out, v) { + out[12] = v[0]; + out[13] = v[1]; + out[14] = v[2]; + return out; +}; -/** - * Creates a new quat initialized with the given values - * - * @param {Number} x X component - * @param {Number} y Y component - * @param {Number} z Z component - * @param {Number} w W component - * @returns {quat} a new quaternion - * @function +/** + * Sets the translation component of a mat4 from values + * @param {mat4} out + * @param {number} x + * @param {number} y + * @param {number} z + * @returns {mat4} out */ -const fromValues = __WEBPACK_IMPORTED_MODULE_3__vec4__["fromValues"]; -/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues; +_glMatrix.mat4.setTranslationFromValues = function (out, x, y, z) { + out[12] = x; + out[13] = y; + out[14] = z; + return out; +}; +/***/ }), +/* 76 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * Copy the values from one quat to another - * - * @param {quat} out the receiving quaternion - * @param {quat} a the source quaternion - * @returns {quat} out - * @function - */ -const copy = __WEBPACK_IMPORTED_MODULE_3__vec4__["copy"]; -/* harmony export (immutable) */ __webpack_exports__["copy"] = copy; +"use strict"; -/** - * Set the components of a quat to the given values - * - * @param {quat} out the receiving quaternion - * @param {Number} x X component - * @param {Number} y Y component - * @param {Number} z Z component - * @param {Number} w W component - * @returns {quat} out - * @function - */ -const set = __WEBPACK_IMPORTED_MODULE_3__vec4__["set"]; -/* harmony export (immutable) */ __webpack_exports__["set"] = set; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.noise = undefined; +var _vec = __webpack_require__(33); -/** - * Adds two quat's - * - * @param {quat} out the receiving quaternion - * @param {quat} a the first operand - * @param {quat} b the second operand - * @returns {quat} out - * @function - */ -const add = __WEBPACK_IMPORTED_MODULE_3__vec4__["add"]; -/* harmony export (immutable) */ __webpack_exports__["add"] = add; +var _vec2 = __webpack_require__(34); +var noise = exports.noise = {}; -/** - * Alias for {@link quat.multiply} - * @function +/** + * Generates turbulent noise + * + * @param {vec4} out + * @param {number} pos_0 + * @param {number} pos_1 + * @param {number} pos_2 + * @param {number} pos_3 + * @param {number} power + * @returns {vec4} out */ -const mul = multiply; -/* harmony export (immutable) */ __webpack_exports__["mul"] = mul; +noise.turbulence = function () { + var s_noiseLookup = [], + s_permutations = [], + s_globalNoiseTemps = []; + var s_initialized = false; -/** - * Scales a quat by a scalar number - * - * @param {quat} out the receiving vector - * @param {quat} a the vector to scale - * @param {Number} b amount to scale the vector by - * @returns {quat} out - * @function - */ -const scale = __WEBPACK_IMPORTED_MODULE_3__vec4__["scale"]; -/* harmony export (immutable) */ __webpack_exports__["scale"] = scale; + /** + * Initializes noise + */ + function initialize() { + for (var _i = 0; _i < 256; _i++) { + s_noiseLookup[_i] = _vec2.vec4.fromValues(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5); + s_permutations[_i] = _i; + } + var i = 256; + while (--i) { + var tmp = s_permutations[i], + index = Math.floor(Math.random() * 256); -/** - * Calculates the dot product of two quat's - * - * @param {quat} a the first operand - * @param {quat} b the second operand - * @returns {Number} dot product of a and b - * @function - */ -const dot = __WEBPACK_IMPORTED_MODULE_3__vec4__["dot"]; -/* harmony export (immutable) */ __webpack_exports__["dot"] = dot; + s_permutations[i] = s_permutations[index]; + s_permutations[index] = tmp; + } + for (var _i2 = 0; _i2 < 256; _i2++) { + s_permutations[256 + _i2] = s_permutations[_i2]; + s_noiseLookup[256 + _i2] = s_noiseLookup[_i2]; + s_noiseLookup[256 * 2 + _i2] = s_noiseLookup[_i2]; + } -/** - * Performs a linear interpolation between two quat's - * - * @param {quat} out the receiving quaternion - * @param {quat} a the first operand - * @param {quat} b the second operand - * @param {Number} t interpolation amount between the two inputs - * @returns {quat} out - * @function - */ -const lerp = __WEBPACK_IMPORTED_MODULE_3__vec4__["lerp"]; -/* harmony export (immutable) */ __webpack_exports__["lerp"] = lerp; + for (var _i3 = 0; _i3 < 15; ++_i3) { + s_globalNoiseTemps[_i3] = _vec.vec3.create(); + } + s_initialized = true; + } -/** - * Calculates the length of a quat - * - * @param {quat} a vector to calculate length of - * @returns {Number} length of a - */ -const length = __WEBPACK_IMPORTED_MODULE_3__vec4__["length"]; -/* harmony export (immutable) */ __webpack_exports__["length"] = length; + return function turbulence(out, pos_0, pos_1, pos_2, pos_3, power) { + if (!s_initialized) initialize(); + pos_0 += 4096; + pos_1 += 4096; + pos_2 += 4096; + pos_3 += 4096; -/** - * Alias for {@link quat.length} - * @function - */ -const len = length; -/* harmony export (immutable) */ __webpack_exports__["len"] = len; + var a_0 = Math.floor(pos_0), + a_1 = Math.floor(pos_1), + a_2 = Math.floor(pos_2), + a_3 = Math.floor(pos_3); + var t_0 = pos_0 - a_0, + t_1 = pos_1 - a_1, + t_2 = pos_2 - a_2, + t_3 = pos_3 - a_3; -/** - * Calculates the squared length of a quat - * - * @param {quat} a vector to calculate squared length of - * @returns {Number} squared length of a - * @function - */ -const squaredLength = __WEBPACK_IMPORTED_MODULE_3__vec4__["squaredLength"]; -/* harmony export (immutable) */ __webpack_exports__["squaredLength"] = squaredLength; + a_0 &= 255; + a_1 &= 255; + a_2 &= 255; + a_3 &= 255; + var b_0 = a_0 + 1, + b_1 = a_1 + 1, + b_2 = a_2 + 1, + b_3 = a_3 + 1; -/** - * Alias for {@link quat.squaredLength} - * @function - */ -const sqrLen = squaredLength; -/* harmony export (immutable) */ __webpack_exports__["sqrLen"] = sqrLen; + var i = s_permutations[a_0], + j = s_permutations[b_0]; + var b00 = s_permutations[i + a_1], + b10 = s_permutations[j + a_1], + b01 = s_permutations[i + b_1], + b11 = s_permutations[j + b_1]; -/** - * Normalize a quat - * - * @param {quat} out the receiving quaternion - * @param {quat} a quaternion to normalize - * @returns {quat} out - * @function - */ -const normalize = __WEBPACK_IMPORTED_MODULE_3__vec4__["normalize"]; -/* harmony export (immutable) */ __webpack_exports__["normalize"] = normalize; + var c00 = _vec.vec3.lerp(s_globalNoiseTemps[0], s_noiseLookup[b00 + a_2 + a_3], s_noiseLookup[b10 + a_2 + a_3], t_0); + var c10 = _vec.vec3.lerp(s_globalNoiseTemps[1], s_noiseLookup[b01 + a_2 + a_3], s_noiseLookup[b11 + a_2 + a_3], t_0); + var c01 = _vec.vec3.lerp(s_globalNoiseTemps[2], s_noiseLookup[b00 + b_2 + a_3], s_noiseLookup[b10 + b_2 + a_3], t_0); + var c11 = _vec.vec3.lerp(s_globalNoiseTemps[3], s_noiseLookup[b00 + b_2 + a_3], s_noiseLookup[b10 + b_2 + a_3], t_0); + var c0 = _vec.vec3.lerp(s_globalNoiseTemps[4], c00, c10, t_1); + var c1 = _vec.vec3.lerp(s_globalNoiseTemps[5], c01, c11, t_1); + var c = _vec.vec3.lerp(s_globalNoiseTemps[6], c0, c1, t_2); + + c00 = _vec.vec3.lerp(s_globalNoiseTemps[7], s_noiseLookup[b00 + a_2 + b_3], s_noiseLookup[b10 + a_2 + b_3], t_0); + c10 = _vec.vec3.lerp(s_globalNoiseTemps[8], s_noiseLookup[b01 + a_2 + b_3], s_noiseLookup[b11 + a_2 + b_3], t_0); + c01 = _vec.vec3.lerp(s_globalNoiseTemps[9], s_noiseLookup[b00 + b_2 + b_3], s_noiseLookup[b10 + b_2 + b_3], t_0); + c11 = _vec.vec3.lerp(s_globalNoiseTemps[10], s_noiseLookup[b00 + b_2 + b_3], s_noiseLookup[b10 + b_2 + b_3], t_0); + c0 = _vec.vec3.lerp(s_globalNoiseTemps[11], c00, c10, t_1); + c1 = _vec.vec3.lerp(s_globalNoiseTemps[12], c01, c11, t_1); + var d = _vec.vec3.lerp(s_globalNoiseTemps[13], c0, c1, t_2); + var r = _vec.vec3.lerp(s_globalNoiseTemps[14], c, d, t_3); + out[0] += r[0] * power; + out[1] += r[1] * power; + out[2] += r[2] * power; + return out; + }; +}(); -/** - * Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===) - * - * @param {quat} a The first quaternion. - * @param {quat} b The second quaternion. - * @returns {Boolean} True if the vectors are equal, false otherwise. +/** + * Perlin_noise1 + * + * @param {number} a + * @returns {number} */ -const exactEquals = __WEBPACK_IMPORTED_MODULE_3__vec4__["exactEquals"]; -/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals; +noise.perlin1 = function () { + var p_initialized = false, + p_B = 0x100, + p_BM = 0xff, + p_N = 0x1000, + p_p = null, + p_g1 = null; + /** + * Initializes Perlin Noise + */ + function initialize() { + p_p = new Array(p_B + p_B + 2); + p_g1 = new Array(p_B + p_B + 2); -/** - * Returns whether or not the quaternions have approximately the same elements in the same position. - * - * @param {quat} a The first vector. - * @param {quat} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. - */ -const equals = __WEBPACK_IMPORTED_MODULE_3__vec4__["equals"]; -/* harmony export (immutable) */ __webpack_exports__["equals"] = equals; + var i = 0, + j = 0, + k = 0; + for (i = 0; i < p_B; i++) { + p_p[i] = i; + p_g1[i] = Math.random() * 2 - 1; + } -/** - * Sets a quaternion to represent the shortest rotation from one - * vector to another. - * - * Both vectors are assumed to be unit length. - * - * @param {quat} out the receiving quaternion. - * @param {vec3} a the initial vector - * @param {vec3} b the destination vector - * @returns {quat} out - */ -const rotationTo = (function() { - let tmpvec3 = __WEBPACK_IMPORTED_MODULE_2__vec3__["create"](); - let xUnitVec3 = __WEBPACK_IMPORTED_MODULE_2__vec3__["fromValues"](1,0,0); - let yUnitVec3 = __WEBPACK_IMPORTED_MODULE_2__vec3__["fromValues"](0,1,0); + while (--i) { + k = p_p[i]; + p_p[i] = p_p[j = Math.floor(Math.random() * p_B)]; + p_p[j] = k; + } - return function(out, a, b) { - let dot = __WEBPACK_IMPORTED_MODULE_2__vec3__["dot"](a, b); - if (dot < -0.999999) { - __WEBPACK_IMPORTED_MODULE_2__vec3__["cross"](tmpvec3, xUnitVec3, a); - if (__WEBPACK_IMPORTED_MODULE_2__vec3__["len"](tmpvec3) < 0.000001) - __WEBPACK_IMPORTED_MODULE_2__vec3__["cross"](tmpvec3, yUnitVec3, a); - __WEBPACK_IMPORTED_MODULE_2__vec3__["normalize"](tmpvec3, tmpvec3); - setAxisAngle(out, tmpvec3, Math.PI); - return out; - } else if (dot > 0.999999) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 1; - return out; - } else { - __WEBPACK_IMPORTED_MODULE_2__vec3__["cross"](tmpvec3, a, b); - out[0] = tmpvec3[0]; - out[1] = tmpvec3[1]; - out[2] = tmpvec3[2]; - out[3] = 1 + dot; - return normalize(out, out); - } - }; -})(); -/* harmony export (immutable) */ __webpack_exports__["rotationTo"] = rotationTo; + for (i = 0; i < p_B + 2; i++) { + p_p[p_B + i] = p_p[i]; + p_g1[p_B + i] = p_g1[i]; + } + p_initialized = true; + } -/** - * Performs a spherical linear interpolation with two control points - * - * @param {quat} out the receiving quaternion - * @param {quat} a the first operand - * @param {quat} b the second operand - * @param {quat} c the third operand - * @param {quat} d the fourth operand - * @param {Number} t interpolation amount - * @returns {quat} out - */ -const sqlerp = (function () { - let temp1 = create(); - let temp2 = create(); + return function perlin1(a) { + if (!p_initialized) initialize(); - return function (out, a, b, c, d, t) { - slerp(temp1, a, d, t); - slerp(temp2, b, c, t); - slerp(out, temp1, temp2, 2 * t * (1 - t)); + var t = a + p_N, + bx0 = Math.floor(t) & p_BM, + bx1 = bx0 + 1 & p_BM, + rx0 = t - Math.floor(t), + rx1 = rx0 - 1; - return out; - }; -}()); -/* harmony export (immutable) */ __webpack_exports__["sqlerp"] = sqlerp; + var sx = rx0 * rx0 * (3.0 - 2.0 * rx0), + u = rx0 * p_g1[p_p[bx0]], + v = rx1 * p_g1[p_p[bx1]]; + return u + sx * (v - u); + }; +}(); -/** - * Sets the specified quaternion with values corresponding to the given - * axes. Each axis is a vec3 and is expected to be unit length and - * perpendicular to all other specified axes. - * - * @param {vec3} view the vector representing the viewing direction - * @param {vec3} right the vector representing the local "right" direction - * @param {vec3} up the vector representing the local "up" direction - * @returns {quat} out +/** + * PerlinNoise1D + * + * @param x + * @param alpha + * @param beta + * @param n + * @returns {number} */ -const setAxes = (function() { - let matr = __WEBPACK_IMPORTED_MODULE_1__mat3__["create"](); +noise.perlin1D = function (x, alpha, beta, n) { + var sum = 0, + p = x, + scale = 1; - return function(out, view, right, up) { - matr[0] = right[0]; - matr[3] = right[1]; - matr[6] = right[2]; + for (var i = 0; i < n; ++i) { + sum += noise.perlin1(p) / scale; + scale *= alpha; + p *= beta; + } + return sum; +}; - matr[1] = up[0]; - matr[4] = up[1]; - matr[7] = up[2]; +/***/ }), +/* 77 */ +/***/ (function(module, exports, __webpack_require__) { - matr[2] = -view[0]; - matr[5] = -view[1]; - matr[8] = -view[2]; +"use strict"; - return normalize(out, fromMat3(out, matr)); - }; -})(); -/* harmony export (immutable) */ __webpack_exports__["setAxes"] = setAxes; +Object.defineProperty(exports, "__esModule", { + value: true +}); +var curve = exports.curve = {}; + +/** + * Evaluates a curve + * + * @param {{}|Tw2GeometryCurve} curve + * @param {Array} curve.knots + * @param {number} curve.degree + * @param {Array} curve.controls + * @param {number} curve.dimension + * @param {number} time + * @param {*} value + * @param {boolean} cycle + * @param {number} duration + */ +curve.evaluate = function (curve, time, value, cycle, duration) { + var count = curve.knots.length; + var knot = count - 1; + var t = 0; + for (var i = 0; i < curve.knots.length; ++i) { + if (curve.knots[i] > time) { + knot = i; + break; + } + } + + if (curve.degree === 0) { + for (var _i = 0; _i < curve.dimension; ++_i) { + value[_i] = curve.controls[knot * curve.dimension + _i]; + } + } else if (curve.degree === 1) { + var knot0 = cycle ? (knot + count - 1) % count : knot === 0 ? 0 : knot - 1; + var dt = curve.knots[knot] - curve.knots[knot0]; + + if (dt < 0) { + dt += duration; + } + if (dt > 0) { + t = (time - curve.knots[curve.knots.length - 1]) / dt; + } -/***/ }), -/* 71 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + for (var _i2 = 0; _i2 < curve.dimension; ++_i2) { + value[_i2] = curve.controls[knot0 * curve.dimension + _i2] * (1 - t) + curve.controls[knot * curve.dimension + _i2] * t; + } + } else { + var k_2 = cycle ? (knot + count - 2) % count : knot === 0 ? 0 : knot - 2; + var k_1 = cycle ? (knot + count - 1) % count : knot === 0 ? 0 : knot - 1; -"use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony export (immutable) */ __webpack_exports__["create"] = create; -/* harmony export (immutable) */ __webpack_exports__["clone"] = clone; -/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues; -/* harmony export (immutable) */ __webpack_exports__["copy"] = copy; -/* harmony export (immutable) */ __webpack_exports__["set"] = set; -/* harmony export (immutable) */ __webpack_exports__["add"] = add; -/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract; -/* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply; -/* harmony export (immutable) */ __webpack_exports__["divide"] = divide; -/* harmony export (immutable) */ __webpack_exports__["ceil"] = ceil; -/* harmony export (immutable) */ __webpack_exports__["floor"] = floor; -/* harmony export (immutable) */ __webpack_exports__["min"] = min; -/* harmony export (immutable) */ __webpack_exports__["max"] = max; -/* harmony export (immutable) */ __webpack_exports__["round"] = round; -/* harmony export (immutable) */ __webpack_exports__["scale"] = scale; -/* harmony export (immutable) */ __webpack_exports__["scaleAndAdd"] = scaleAndAdd; -/* harmony export (immutable) */ __webpack_exports__["distance"] = distance; -/* harmony export (immutable) */ __webpack_exports__["squaredDistance"] = squaredDistance; -/* harmony export (immutable) */ __webpack_exports__["length"] = length; -/* harmony export (immutable) */ __webpack_exports__["squaredLength"] = squaredLength; -/* harmony export (immutable) */ __webpack_exports__["negate"] = negate; -/* harmony export (immutable) */ __webpack_exports__["inverse"] = inverse; -/* harmony export (immutable) */ __webpack_exports__["normalize"] = normalize; -/* harmony export (immutable) */ __webpack_exports__["dot"] = dot; -/* harmony export (immutable) */ __webpack_exports__["cross"] = cross; -/* harmony export (immutable) */ __webpack_exports__["lerp"] = lerp; -/* harmony export (immutable) */ __webpack_exports__["random"] = random; -/* harmony export (immutable) */ __webpack_exports__["transformMat2"] = transformMat2; -/* harmony export (immutable) */ __webpack_exports__["transformMat2d"] = transformMat2d; -/* harmony export (immutable) */ __webpack_exports__["transformMat3"] = transformMat3; -/* harmony export (immutable) */ __webpack_exports__["transformMat4"] = transformMat4; -/* harmony export (immutable) */ __webpack_exports__["str"] = str; -/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals; -/* harmony export (immutable) */ __webpack_exports__["equals"] = equals; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(5); -/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. + var p1 = k_2 * curve.dimension; + var p2 = k_1 * curve.dimension; + var p3 = knot * curve.dimension; -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: + var ti_2 = curve.knots[k_2]; + var ti_1 = curve.knots[k_1]; + var ti = curve.knots[knot]; + var ti1 = curve.knots[(knot + 1) % count]; -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. + if (ti_2 > ti) { + ti += duration; + ti1 += duration; + time += duration; + } -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. */ + if (ti_1 > ti) { + ti += duration; + ti1 += duration; + time += duration; + } + if (ti1 < ti) { + ti1 += duration; + } + var tmti_1 = time - ti_1; + var tmti_2 = time - ti_2; + var dL0 = ti - ti_1; + var dL1_1 = ti - ti_2; + var dL1_2 = ti1 - ti_1; -/** - * 2 Dimensional Vector - * @module vec2 - */ + var L0 = tmti_1 / dL0; + var L1_1 = tmti_2 / dL1_1; + var L1_2 = tmti_1 / dL1_2; -/** - * Creates a new, empty vec2 - * - * @returns {vec2} a new 2D vector - */ -function create() { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](2); - out[0] = 0; - out[1] = 0; - return out; -} + var ci_2 = L1_1 + L0 - L0 * L1_1; + var ci = L0 * L1_2; + var ci_1 = ci_2 - ci; + ci_2 = 1 - ci_2; -/** - * Creates a new vec2 initialized with values from an existing vector - * - * @param {vec2} a vector to clone - * @returns {vec2} a new 2D vector - */ -function clone(a) { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](2); - out[0] = a[0]; - out[1] = a[1]; - return out; -} + for (var _i3 = 0; _i3 < curve.dimension; ++_i3) { + value[_i3] = ci_2 * curve.controls[p1 + _i3] + ci_1 * curve.controls[p2 + _i3] + ci * curve.controls[p3 + _i3]; + } + } +}; -/** - * Creates a new vec2 initialized with the given values - * - * @param {Number} x X component - * @param {Number} y Y component - * @returns {vec2} a new 2D vector +/** + * ag_horner1 + * + * @param P + * @param deg + * @param s + * @returns {*} */ -function fromValues(x, y) { - let out = new __WEBPACK_IMPORTED_MODULE_0__common__["ARRAY_TYPE"](2); - out[0] = x; - out[1] = y; - return out; -} +curve.ag_horner1 = function (P, deg, s) { + var h = P[deg]; + while (--deg >= 0) { + h = s * h + P[deg]; + }return h; +}; -/** - * Copy the values from one vec2 to another - * - * @param {vec2} out the receiving vector - * @param {vec2} a the source vector - * @returns {vec2} out +/** + * ag_zeroin2 + * + * @param a + * @param b + * @param fa + * @param fb + * @param tol + * @param pars + * @returns {*} */ -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - return out; -} +curve.ag_zeroin2 = function (a, b, fa, fb, tol, pars) { + var test = void 0; + var c = void 0, + d = void 0, + e = void 0, + fc = void 0, + del = void 0, + m = void 0, + machtol = void 0, + p = void 0, + q = void 0, + r = void 0, + s = void 0; -/** - * Set the components of a vec2 to the given values - * - * @param {vec2} out the receiving vector - * @param {Number} x X component - * @param {Number} y Y component - * @returns {vec2} out - */ -function set(out, x, y) { - out[0] = x; - out[1] = y; - return out; -} + /* initialization */ + machtol = 1.192092896e-07; + var label1 = true; -/** - * Adds two vec2's - * - * @param {vec2} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {vec2} out - */ -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - return out; -} + /* start iteration */ + while (true) { + if (label1) { + c = a; + fc = fa; + d = b - a; + e = d; + } -/** - * Subtracts vector b from vector a - * - * @param {vec2} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {vec2} out - */ -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - return out; -} + if (Math.abs(fc) < Math.abs(fb)) { + a = b; + b = c; + c = a; + fa = fb; + fb = fc; + fc = fa; + } + label1 = false; -/** - * Multiplies two vec2's - * - * @param {vec2} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {vec2} out - */ -function multiply(out, a, b) { - out[0] = a[0] * b[0]; - out[1] = a[1] * b[1]; - return out; + /* convergence test */ + del = 2.0 * machtol * Math.abs(b) + 0.5 * tol; + m = 0.5 * (c - b); + test = Math.abs(m) > del && fb !== 0.0; + if (test) { + if (Math.abs(e) < del || Math.abs(fa) <= Math.abs(fb)) { + /* bisection */ + d = m; + e = d; + } else { + s = fb / fa; + if (a === c) { + /* linear interpolation */ + p = 2.0 * m * s; + q = 1.0 - s; + } else { + /* inverse quadratic interpolation */ + q = fa / fc; + r = fb / fc; + p = s * (2.0 * m * q * (q - r) - (b - a) * (r - 1.0)); + q = (q - 1.0) * (r - 1.0) * (s - 1.0); + } + /* adjust the sign */ + if (p > 0.0) q = -q;else p = -p; + /* check if interpolation is acceptable */ + s = e; + e = d; + if (2.0 * p < 3.0 * m * q - Math.abs(del * q) && p < Math.abs(0.5 * s * q)) { + d = p / q; + } else { + d = m; + e = d; + } + } + /* complete step */ + a = b; + fa = fb; + if (Math.abs(d) > del) b += d;else if (m > 0.0) b += del;else b -= del; + fb = curve.ag_horner1(pars.p, pars.deg, b); + if (fb * (fc / Math.abs(fc)) > 0.0) { + label1 = true; + } + } else { + break; + } + } + return b; }; -/** - * Divides two vec2's - * - * @param {vec2} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {vec2} out +/** + * ag_zeroin + * + * @param a + * @param b + * @param tol + * @param pars + * @returns {*} */ -function divide(out, a, b) { - out[0] = a[0] / b[0]; - out[1] = a[1] / b[1]; - return out; -}; +curve.ag_zeroin = function (a, b, tol, pars) { + var fa = void 0, + fb = void 0; -/** - * Math.ceil the components of a vec2 - * - * @param {vec2} out the receiving vector - * @param {vec2} a vector to ceil - * @returns {vec2} out - */ -function ceil(out, a) { - out[0] = Math.ceil(a[0]); - out[1] = Math.ceil(a[1]); - return out; -}; + fa = curve.ag_horner1(pars.p, pars.deg, a); + if (Math.abs(fa) < 1.192092896e-07) return a; -/** - * Math.floor the components of a vec2 - * - * @param {vec2} out the receiving vector - * @param {vec2} a vector to floor - * @returns {vec2} out - */ -function floor(out, a) { - out[0] = Math.floor(a[0]); - out[1] = Math.floor(a[1]); - return out; -}; + fb = curve.ag_horner1(pars.p, pars.deg, b); + if (Math.abs(fb) < 1.192092896e-07) return b; -/** - * Returns the minimum of two vec2's - * - * @param {vec2} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {vec2} out - */ -function min(out, a, b) { - out[0] = Math.min(a[0], b[0]); - out[1] = Math.min(a[1], b[1]); - return out; + return curve.ag_zeroin2(a, b, fa, fb, tol, pars); }; -/** - * Returns the maximum of two vec2's - * - * @param {vec2} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {vec2} out +/** + * polyZeroes + * + * @param Poly + * @param deg + * @param a + * @param a_closed + * @param b + * @param b_closed + * @param Roots + * @returns {*} */ -function max(out, a, b) { - out[0] = Math.max(a[0], b[0]); - out[1] = Math.max(a[1], b[1]); - return out; -}; +curve.polyZeroes = function (Poly, deg, a, a_closed, b, b_closed, Roots) { + var i = void 0, + left_ok = void 0, + right_ok = void 0, + nr = void 0, + ndr = void 0, + skip = void 0; -/** - * Math.round the components of a vec2 - * - * @param {vec2} out the receiving vector - * @param {vec2} a vector to round - * @returns {vec2} out - */ -function round (out, a) { - out[0] = Math.round(a[0]); - out[1] = Math.round(a[1]); - return out; -}; + var e = void 0, + f = void 0, + s = void 0, + pe = void 0, + ps = void 0, + tol = void 0, + p = void 0, + p_x = new Array(22), + d = void 0, + d_x = new Array(22), + dr = void 0, + dr_x = new Array(22); + + var ply = { + p: [], + deg: 0 + }; + + e = pe = 0.0; + f = 0.0; + + for (i = 0; i < deg + 1; ++i) { + f += Math.abs(Poly[i]); + } + tol = (Math.abs(a) + Math.abs(b)) * (deg + 1) * 1.192092896e-07; + + /* Zero polynomial to tolerance? */ + if (f <= tol) return -1; + + p = p_x; + d = d_x; + dr = dr_x; + for (i = 0; i < deg + 1; ++i) { + p[i] = 1.0 / f * Poly[i]; + } + + /* determine true degree */ + while (Math.abs(p[deg]) < tol) { + deg--; + } /* Identically zero poly already caught so constant fn !== 0 */ + nr = 0; + if (deg === 0) return nr; + + /* check for linear case */ + if (deg === 1) { + Roots[0] = -p[0] / p[1]; + left_ok = a_closed ? a < Roots[0] + tol : a < Roots[0] - tol; + right_ok = b_closed ? b > Roots[0] - tol : b > Roots[0] + tol; + nr = left_ok && right_ok ? 1 : 0; + if (nr) { + if (a_closed && Roots[0] < a) Roots[0] = a;else if (b_closed && Roots[0] > b) Roots[0] = b; + } + return nr; + } + /* handle non-linear case */ + else { + ply.p = p; + ply.deg = deg; + + /* compute derivative */ + for (i = 1; i <= deg; i++) { + d[i - 1] = i * p[i]; + } /* find roots of derivative */ + ndr = curve.polyZeroes(d, deg - 1, a, 0, b, 0, dr); + if (ndr.length === 0) return 0; + + /* find roots between roots of the derivative */ + for (i = skip = 0; i <= ndr; i++) { + if (nr > deg) return nr; + if (i === 0) { + s = a; + ps = curve.ag_horner1(p, deg, s); + if (Math.abs(ps) <= tol && a_closed) Roots[nr++] = a; + } else { + s = e; + ps = pe; + } + if (i === ndr) { + e = b; + skip = 0; + } else e = dr[i]; + pe = curve.ag_horner1(p, deg, e); + if (skip) skip = 0;else { + if (Math.abs(pe) < tol) { + if (i !== ndr || b_closed) { + Roots[nr++] = e; + skip = 1; + } + } else if (ps < 0 && pe > 0 || ps > 0 && pe < 0) { + Roots[nr++] = curve.ag_zeroin(s, e, 0.0, ply); + if (nr > 1 && Roots[nr - 2] >= Roots[nr - 1] - tol) { + Roots[nr - 2] = (Roots[nr - 2] + Roots[nr - 1]) * 0.5; + nr--; + } + } + } + } + } -/** - * Scales a vec2 by a scalar number - * - * @param {vec2} out the receiving vector - * @param {vec2} a the vector to scale - * @param {Number} b amount to scale the vector by - * @returns {vec2} out - */ -function scale(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - return out; + return nr; }; -/** - * Adds two vec2's after scaling the second operand by a scalar value - * - * @param {vec2} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @param {Number} scale the amount to scale b by before adding - * @returns {vec2} out - */ -function scaleAndAdd(out, a, b, scale) { - out[0] = a[0] + (b[0] * scale); - out[1] = a[1] + (b[1] * scale); - return out; -}; +/***/ }), +/* 78 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * Calculates the euclidian distance between two vec2's - * - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {Number} distance between a and b - */ -function distance(a, b) { - var x = b[0] - a[0], - y = b[1] - a[1]; - return Math.sqrt(x*x + y*y); -}; +"use strict"; -/** - * Calculates the squared euclidian distance between two vec2's - * - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {Number} squared distance between a and b - */ -function squaredDistance(a, b) { - var x = b[0] - a[0], - y = b[1] - a[1]; - return x*x + y*y; -}; -/** - * Calculates the length of a vec2 - * - * @param {vec2} a vector to calculate length of - * @returns {Number} length of a - */ -function length(a) { - var x = a[0], - y = a[1]; - return Math.sqrt(x*x + y*y); -}; +Object.defineProperty(exports, "__esModule", { + value: true +}); -/** - * Calculates the squared length of a vec2 - * - * @param {vec2} a vector to calculate squared length of - * @returns {Number} squared length of a - */ -function squaredLength (a) { - var x = a[0], - y = a[1]; - return x*x + y*y; -}; +var _Tw2Device = __webpack_require__(79); -/** - * Negates the components of a vec2 - * - * @param {vec2} out the receiving vector - * @param {vec2} a vector to negate - * @returns {vec2} out - */ -function negate(out, a) { - out[0] = -a[0]; - out[1] = -a[1]; - return out; -}; +Object.defineProperty(exports, 'device', { + enumerable: true, + get: function get() { + return _Tw2Device.device; + } +}); -/** - * Returns the inverse of the components of a vec2 - * - * @param {vec2} out the receiving vector - * @param {vec2} a vector to invert - * @returns {vec2} out - */ -function inverse(out, a) { - out[0] = 1.0 / a[0]; - out[1] = 1.0 / a[1]; - return out; -}; +var _Tw2ResMan = __webpack_require__(37); -/** - * Normalize a vec2 - * - * @param {vec2} out the receiving vector - * @param {vec2} a vector to normalize - * @returns {vec2} out - */ -function normalize(out, a) { - var x = a[0], - y = a[1]; - var len = x*x + y*y; - if (len > 0) { - //TODO: evaluate use of glm_invsqrt here? - len = 1 / Math.sqrt(len); - out[0] = a[0] * len; - out[1] = a[1] * len; +Object.defineProperty(exports, 'resMan', { + enumerable: true, + get: function get() { + return _Tw2ResMan.resMan; } - return out; -}; +}); -/** - * Calculates the dot product of two vec2's - * - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {Number} dot product of a and b - */ -function dot(a, b) { - return a[0] * b[0] + a[1] * b[1]; -}; +var _Tw2Store = __webpack_require__(19); -/** - * Computes the cross product of two vec2's - * Note that the cross product must by definition produce a 3D vector - * - * @param {vec3} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @returns {vec3} out - */ -function cross(out, a, b) { - var z = a[0] * b[1] - a[1] * b[0]; - out[0] = out[1] = 0; - out[2] = z; - return out; -}; +Object.defineProperty(exports, 'store', { + enumerable: true, + get: function get() { + return _Tw2Store.store; + } +}); -/** - * Performs a linear interpolation between two vec2's - * - * @param {vec2} out the receiving vector - * @param {vec2} a the first operand - * @param {vec2} b the second operand - * @param {Number} t interpolation amount between the two inputs - * @returns {vec2} out - */ -function lerp(out, a, b, t) { - var ax = a[0], - ay = a[1]; - out[0] = ax + t * (b[0] - ax); - out[1] = ay + t * (b[1] - ay); - return out; -}; +var _Tw2Logger = __webpack_require__(17); -/** - * Generates a random vector with the given scale - * - * @param {vec2} out the receiving vector - * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned - * @returns {vec2} out - */ -function random(out, scale) { - scale = scale || 1.0; - var r = __WEBPACK_IMPORTED_MODULE_0__common__["RANDOM"]() * 2.0 * Math.PI; - out[0] = Math.cos(r) * scale; - out[1] = Math.sin(r) * scale; - return out; -}; +Object.defineProperty(exports, 'logger', { + enumerable: true, + get: function get() { + return _Tw2Logger.logger; + } +}); -/** - * Transforms the vec2 with a mat2 - * - * @param {vec2} out the receiving vector - * @param {vec2} a the vector to transform - * @param {mat2} m matrix to transform with - * @returns {vec2} out - */ -function transformMat2(out, a, m) { - var x = a[0], - y = a[1]; - out[0] = m[0] * x + m[2] * y; - out[1] = m[1] * x + m[3] * y; - return out; -}; +/***/ }), +/* 79 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * Transforms the vec2 with a mat2d - * - * @param {vec2} out the receiving vector - * @param {vec2} a the vector to transform - * @param {mat2d} m matrix to transform with - * @returns {vec2} out - */ -function transformMat2d(out, a, m) { - var x = a[0], - y = a[1]; - out[0] = m[0] * x + m[2] * y + m[4]; - out[1] = m[1] * x + m[3] * y + m[5]; - return out; -}; +"use strict"; -/** - * Transforms the vec2 with a mat3 - * 3rd vector component is implicitly '1' - * - * @param {vec2} out the receiving vector - * @param {vec2} a the vector to transform - * @param {mat3} m matrix to transform with - * @returns {vec2} out - */ -function transformMat3(out, a, m) { - var x = a[0], - y = a[1]; - out[0] = m[0] * x + m[3] * y + m[6]; - out[1] = m[1] * x + m[4] * y + m[7]; - return out; -}; -/** - * Transforms the vec2 with a mat4 - * 3rd vector component is implicitly '0' - * 4th vector component is implicitly '1' - * - * @param {vec2} out the receiving vector - * @param {vec2} a the vector to transform - * @param {mat4} m matrix to transform with - * @returns {vec2} out - */ -function transformMat4(out, a, m) { - let x = a[0]; - let y = a[1]; - out[0] = m[0] * x + m[4] * y + m[12]; - out[1] = m[1] * x + m[5] * y + m[13]; - return out; -} +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.device = exports.Tw2Device = undefined; -/** - * Returns a string representation of a vector - * - * @param {vec2} a vector to represent as a string - * @returns {String} string representation of the vector - */ -function str(a) { - return 'vec2(' + a[0] + ', ' + a[1] + ')'; -} +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -/** - * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===) - * - * @param {vec2} a The first vector. - * @param {vec2} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. - */ -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1]; -} +var _math = __webpack_require__(18); -/** - * Returns whether or not the vectors have approximately the same elements in the same position. - * - * @param {vec2} a The first vector. - * @param {vec2} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. - */ -function equals(a, b) { - let a0 = a[0], a1 = a[1]; - let b0 = b[0], b1 = b[1]; - return (Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a0), Math.abs(b0)) && - Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common__["EPSILON"]*Math.max(1.0, Math.abs(a1), Math.abs(b1))); -} +var _Tw2Store = __webpack_require__(19); -/** - * Alias for {@link vec2.length} - * @function - */ -const len = length; -/* harmony export (immutable) */ __webpack_exports__["len"] = len; +var _Tw2Logger = __webpack_require__(17); +var _Tw2ResMan = __webpack_require__(37); -/** - * Alias for {@link vec2.subtract} - * @function - */ -const sub = subtract; -/* harmony export (immutable) */ __webpack_exports__["sub"] = sub; +var _Tw2Effect = __webpack_require__(41); +var _vertex = __webpack_require__(9); -/** - * Alias for {@link vec2.multiply} - * @function - */ -const mul = multiply; -/* harmony export (immutable) */ __webpack_exports__["mul"] = mul; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +var WebGLDebugUtil = __webpack_require__(88); -/** - * Alias for {@link vec2.divide} - * @function +/** + * Tw2Device + * + * @property {?WebGLRenderingContext|*} gl - The device's gl context + * @property {?number} glVersion - The device's gl version + * @property {?VRDisplay} vrDisplay - An optional VRDisplay context + * @property {?{}} ext - An object containing compatibility extensions + * @property {boolean} debugMode - Toggles debug mode + * @property {{}} debugUtils - Webgl debug utils + * @property {number} dt - Clock delta time + * @property {number} startTime - Clock start time + * @property {number} currentTime - Clock current time + * @property {?number} previousTime - Clock previous time + * @property {vec3} eyePosition - The device's current eye position + * @property {vec4} targetResolution - The device's current target resolution + * @property {mat4} world - The device's current world matrix + * @property {mat4} view - The device's current view matrix + * @property {mat4} viewInverse - The device's current inverse view matrix + * @property {mat4} viewTranspose - The device's current view matrix transposed + * @property {mat4} projection - The device's current projection matrix + * @property {mat4} projectionInverse - The device's current inverse projection matrix + * @property {mat4} projectionTranspose - The device's current projection matrix transposed + * @property {mat4} viewProjection - The device's current view projection matrix + * @property {mat4} viewProjectionTranspose - The device's current view projection matrix transposed + * @property {?HTMLCanvasElement} canvas - The html canvas the gl context was created from + * @property {number} viewportWidth - The canvas's current width + * @property {number} viewportHeight - The canvas's current height + * @property {number} viewportAspect - The canvas's current display aspect + * @property {number} viewportPixelRatio - The canvas's pixel ratio + * @property {string} effectDir - The directory used to translate ccp effect file paths + * @property {number} mipLevelSkipCount - Controls what quality ccp texture resource to load (mutates paths) + * @property {string} shaderModel - Controls what quality ccp effect resource to load (mutates paths) + * @property {boolean} enableAnisotropicFiltering - Enables anisotropic filtering + * @property {boolean} alphaBlendBackBuffer - Enables alpha blending (glParams.alpha) + * @property {boolean} antialiasing - Identifies if antialiasing is enabled + * @property {number} msaaSamples - The amount of samples used for antialiasing + * @property {number[]} wrapModes - texture wrap modes + * @property {*} shadowHandles - unused + * @property {Tw2PerObjectData} perObjectData - The current frame's per object data + * @property {?{}} _alphaBlendState - Alpha states for blending + * @property {?{}} _alphaTestState - Alpha test states + * @property {?{}} _depthOffsetState - Depth states + * @property {?Array} _blendTable - Webgl blend enum table + * @property {?Float32Array} _shadowStateBuffer - unused + * @property {Array} _scheduled - Functions that are scheduled to be called per frame + * @property {WebGLBuffer} _quadBuffer - Webgl buffer for full screen quad + * @property {Tw2VertexDeclaration} _quadDecl - Quad vertex declarations + * @property {WebGLBuffer} _cameraQuadBuffer - Webgl buffer for camera space quad + * @property {number} _currentRenderMode - The device's current render mode + * @property {WebGLTexture} _fallbackCube - A fallback cube texture + * @property {WebGLTexture} _fallbackTexture - A fallback texture + * @property {Tw2Effect} _blitEffect - The blit effect used for rendering textures + * @property {?Function} _onResize - An optional function which is called when the canvas resizes + * @class */ -const div = divide; -/* harmony export (immutable) */ __webpack_exports__["div"] = div; +var Tw2Device = exports.Tw2Device = function () { + function Tw2Device() { + _classCallCheck(this, Tw2Device); -/** - * Alias for {@link vec2.distance} - * @function - */ -const dist = distance; -/* harmony export (immutable) */ __webpack_exports__["dist"] = dist; + this.gl = null; + this.glVersion = Tw2Device.WebglVersion.NONE; + this.vrDisplay = null; + this.ext = null; + this.debugMode = false; + this.debugUtils = null; -/** - * Alias for {@link vec2.squaredDistance} - * @function - */ -const sqrDist = squaredDistance; -/* harmony export (immutable) */ __webpack_exports__["sqrDist"] = sqrDist; + this.dt = 0; + this.frameCounter = 0; + this.startTime = this.Now(); + this.currentTime = this.startTime; + this.previousTime = null; + this.eyePosition = _math.vec3.create(); + this.targetResolution = _math.vec4.create(); + this.world = _math.mat4.create(); + this.view = _math.mat4.create(); + this.viewInverse = _math.mat4.create(); + this.viewTranspose = _math.mat4.create(); + this.projection = _math.mat4.create(); + this.projectionInverse = _math.mat4.create(); + this.projectionTranspose = _math.mat4.create(); + this.viewProjection = _math.mat4.create(); + this.viewProjectionTranspose = _math.mat4.create(); -/** - * Alias for {@link vec2.squaredLength} - * @function - */ -const sqrLen = squaredLength; -/* harmony export (immutable) */ __webpack_exports__["sqrLen"] = sqrLen; + this.canvas = null; + this.viewportWidth = 0; + this.viewportHeight = 0; + this.viewportAspect = 0; + this.viewportPixelRatio = 'devicePixelRatio' in window ? window.devicePixelRatio : 1; + this.effectDir = '/effect.gles2/'; + this.mipLevelSkipCount = 0; + this.shaderModel = 'hi'; + this.enableAnisotropicFiltering = true; + this.alphaBlendBackBuffer = true; -/** - * Perform some operation over an array of vec2s. - * - * @param {Array} a the array of vectors to iterate over - * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed - * @param {Number} offset Number of elements to skip at the beginning of the array - * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array - * @param {Function} fn Function to call for each vector in the array - * @param {Object} [arg] additional argument to pass to fn - * @returns {Array} a - * @function - */ -const forEach = (function() { - let vec = create(); + this.antialiasing = true; + this.msaaSamples = 0; + this.wrapModes = []; + this.shadowHandles = null; + this.perObjectData = null; - return function(a, stride, offset, count, fn, arg) { - let i, l; - if(!stride) { - stride = 2; + this._alphaBlendState = null; + this._alphaTestState = null; + this._depthOffsetState = null; + this._blendTable = null; + this._shadowStateBuffer = null; + this._scheduled = []; + this._quadBuffer = null; + this._quadDecl = null; + this._cameraQuadBuffer = null; + this._currentRenderMode = this.RM_ANY; + this._fallbackCube = null; + this._fallbackTexture = null; + this._blitEffect = null; + this._onResize = null; } - if(!offset) { - offset = 0; - } + /** + * Gets the current device time + * @returns {number} + */ - if(count) { - l = Math.min((count * stride) + offset, a.length); - } else { - l = a.length; - } - for(i = offset; i < l; i += stride) { - vec[0] = a[i]; vec[1] = a[i+1]; - fn(vec, vec, arg); - a[i] = vec[0]; a[i+1] = vec[1]; - } + _createClass(Tw2Device, [{ + key: 'Now', + value: function Now() { + return this.constructor.Clock.now(); + } - return a; - }; -})(); -/* harmony export (immutable) */ __webpack_exports__["forEach"] = forEach; + /** + * Creates webgl Device + * @param {HTMLCanvasElement} canvas - The html canvas to create a webgl rendering context from + * @param {{}} [params] - Optional gl parameters + * @param {boolean} [params.webgl2] - Optional flag to enable a webgl2 rendering context + * @returns {number} - The webgl rendering context create (0 if failed) + */ + + }, { + key: 'CreateDevice', + value: function CreateDevice(canvas, params) { + this.gl = null; + this.glVersion = Tw2Device.WebglVersion.NONE; + this.effectDir = '/effect.gles2/'; + + // Try webgl2 if enabled + if (params && params.webgl2) { + this.gl = Tw2Device.CreateContext(canvas, params, Tw2Device.Webgl2ContextNames); + if (this.gl) this.glVersion = Tw2Device.WebglVersion.WEBGL2; + } + // Fallback to webgl + if (!this.gl) { + this.gl = Tw2Device.CreateContext(canvas, params, Tw2Device.WebglContextNames); + if (this.gl) this.glVersion = Tw2Device.WebglVersion.WEBGL; + } + this.ext = { + drawElementsInstanced: function drawElementsInstanced() { + return false; + }, + drawArraysInstanced: function drawArraysInstanced() { + return false; + }, + vertexAttribDivisor: function vertexAttribDivisor() { + return false; + }, + hasInstancedArrays: function hasInstancedArrays() { + return false; + } + }; + var gl = this.gl; -/***/ }), -/* 72 */ -/***/ (function(module, exports, __webpack_require__) { + switch (this.glVersion) { + case Tw2Device.WebglVersion.WEBGL2: + this.ext = { + drawElementsInstanced: function drawElementsInstanced(mode, count, type, offset, instanceCount) { + gl.drawElementsInstanced(mode, count, type, offset, instanceCount); + }, + drawArraysInstanced: function drawArraysInstanced(mode, first, count, instanceCount) { + gl.drawArraysInstanced(mode, first, count, instanceCount); + }, + vertexAttribDivisor: function vertexAttribDivisor(location, divisor) { + gl.vertexAttribDivisor(location, divisor); + }, + hasInstancedArrays: function hasInstancedArrays() { + return true; + } + }; + break; -"use strict"; + case Tw2Device.WebglVersion.WEBGL: + this.GetExtension('OES_standard_derivatives'); + this.GetExtension('OES_element_index_uint'); + this.GetExtension('OES_texture_float'); + this.GetExtension('EXT_shader_texture_lod'); + var instancedArrays = this.GetExtension('ANGLE_instanced_arrays'); + if (instancedArrays) { + this.ext = { + drawElementsInstanced: function drawElementsInstanced(mode, count, type, offset, instanceCount) { + instancedArrays['drawElementsInstancedANGLE'](mode, count, type, offset, instanceCount); + }, + drawArraysInstanced: function drawArraysInstanced(mode, first, count, instanceCount) { + instancedArrays['drawArraysInstancedANGLE'](mode, first, count, instanceCount); + }, + vertexAttribDivisor: function vertexAttribDivisor(location, divisor) { + instancedArrays['vertexAttribDivisorANGLE'](location, divisor); + }, + hasInstancedArrays: function hasInstancedArrays() { + return true; + } + }; + } + break; + default: + return this.glVersion; + } -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.quat = undefined; + if (gl && this.debugMode) { + this.debugUtils = WebGLDebugUtil; + this.gl = this.debugUtils.makeDebugContext(gl); + } -var _glMatrix = __webpack_require__(11); + _Tw2Logger.logger.log('webgl', { + log: 'warn', + type: 'Context created', + value: this.glVersion + }); -exports.quat = _glMatrix.quat; + // Optional extensions + this.ext.CompressedTexture = this.GetExtension('compressed_texture_s3tc'); + this.ext.AnisotropicFilter = this.GetExtension('EXT_texture_filter_anisotropic'); + if (this.ext.AnisotropicFilter) { + this.ext.AnisotropicFilter.maxAnisotropy = gl.getParameter(this.ext.AnisotropicFilter['MAX_TEXTURE_MAX_ANISOTROPY_EXT']); + } -/** - * QuaternionExp - * - * @param {quat} out - * @param {quat|vec3} a - * @returns {quat} - */ + // CCP mobile shader binary (is this depreciated?) + var shaderBinary = this.GetExtension('CCP_shader_binary'); + if (shaderBinary) { + var renderer = gl.getParameter(this.gl.RENDERER), + maliVer = renderer.match(/Mali-(\w+).*/); -_glMatrix.quat.exp = function (out, a) { - var norm = Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]); - if (norm) { - out[0] = Math.sin(norm) * a[0] / norm; - out[1] = Math.sin(norm) * a[1] / norm; - out[2] = Math.sin(norm) * a[2] / norm; - out[3] = Math.cos(norm); - } else { - out[0] = 0.0; - out[1] = 0.0; - out[2] = 0.0; - out[3] = 1.0; - } - return out; -}; + if (maliVer) { + this.effectDir = '/effect.gles2.mali' + maliVer[1] + '/'; + this.ext.ShaderBinary = shaderBinary; + } + } -/** - * QuaternionLn - * - * @param {quat} out - * @param {quat} q - * @returns {quat} - */ -_glMatrix.quat.ln = function (out, q) { - var norm = _glMatrix.quat.length(q); - if (norm > 1.0001 || norm < 0.99999) { - out[0] = q[0]; - out[1] = q[1]; - out[2] = q[2]; - out[3] = 0.0; - } else { - norm = Math.sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2]); - if (norm) { - var theta = Math.atan2(norm, q[3]) / norm; - out[0] = theta * q[0]; - out[1] = theta * q[1]; - out[2] = theta * q[2]; - out[3] = 0.0; - } else { - out[0] = 0.0; - out[1] = 0.0; - out[2] = 0.0; - out[3] = 0.0; - } - } - return out; -}; + // Quality + this.alphaBlendBackBuffer = !params || params['alpha'] === undefined || params['alpha']; + this.msaaSamples = this.gl.getParameter(this.gl.SAMPLES); + this.antialiasing = this.msaaSamples > 1; -/** - * QuaternionPow - * - * @param {quat} out - * @param {quat} inq - * @param {number} exponent - * @returns {quat} - */ -_glMatrix.quat.pow = function (out, inq, exponent) { - if (exponent === 1) { - return _glMatrix.quat.copy(out, inq); - } + this.canvas = canvas; + this.Resize(); - _glMatrix.quat.ln(out, inq); - out[0] *= exponent; - out[1] *= exponent; - out[2] *= exponent; - out[3] *= exponent; - _glMatrix.quat.exp(out, out); - return out; -}; + var vertices = [1.0, 1.0, 0.0, 1.0, 1.0, 1.0, -1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, -1.0, 0.0, 1.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, 0.0, 0.0]; -/***/ }), -/* 73 */ -/***/ (function(module, exports, __webpack_require__) { + this._quadBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this._quadBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + this._cameraQuadBuffer = gl.createBuffer(); + this._quadDecl = new _vertex.Tw2VertexDeclaration(); + this._quadDecl.elements.push(new _vertex.Tw2VertexElement(_vertex.Tw2VertexDeclaration.Type.POSITION, 0, gl.FLOAT, 4, 0)); + this._quadDecl.elements.push(new _vertex.Tw2VertexElement(_vertex.Tw2VertexDeclaration.Type.TEXCOORD, 0, gl.FLOAT, 2, 16)); + this._quadDecl.RebuildHash(); -"use strict"; + this._alphaTestState = {}; + this._alphaTestState.states = {}; + this._alphaTestState.states[this.RS_ALPHATESTENABLE] = 0; + this._alphaTestState.states[this.RS_ALPHAREF] = -1; + this._alphaTestState.states[this.RS_ALPHAFUNC] = this.CMP_GREATER; + this._alphaTestState.states[this.RS_CLIPPING] = 0; + this._alphaTestState.states[this.RS_CLIPPLANEENABLE] = 0; + this._alphaTestState.dirty = false; + this._alphaBlendState = {}; + this._alphaBlendState.states = {}; + this._alphaBlendState.states[this.RS_SRCBLEND] = this.BLEND_SRCALPHA; + this._alphaBlendState.states[this.RS_DESTBLEND] = this.BLEND_INVSRCALPHA; + this._alphaBlendState.states[this.RS_BLENDOP] = this.BLENDOP_ADD; + this._alphaBlendState.states[this.RS_SEPARATEALPHABLENDENABLE] = 0; + this._alphaBlendState.states[this.RS_BLENDOPALPHA] = this.BLENDOP_ADD; + this._alphaBlendState.states[this.RS_SRCBLENDALPHA] = this.BLEND_SRCALPHA; + this._alphaBlendState.states[this.RS_DESTBLENDALPHA] = this.BLEND_INVSRCALPHA; + this._alphaBlendState.dirty = false; -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.mat3 = undefined; + this._depthOffsetState = {}; + this._depthOffsetState.states = {}; + this._depthOffsetState.states[this.RS_SLOPESCALEDEPTHBIAS] = 0; + this._depthOffsetState.states[this.RS_DEPTHBIAS] = 0; + this._depthOffsetState.dirty = false; -var _glMatrix = __webpack_require__(11); + this.wrapModes = []; + this.wrapModes[0] = 0; + this.wrapModes[1] = gl.REPEAT; + this.wrapModes[2] = gl.MIRRORED_REPEAT; + this.wrapModes[3] = gl.CLAMP_TO_EDGE; + this.wrapModes[4] = gl.CLAMP_TO_EDGE; + this.wrapModes[5] = gl.CLAMP_TO_EDGE; -exports.mat3 = _glMatrix.mat3; + this._shadowStateBuffer = new Float32Array(24); -/***/ }), -/* 74 */ -/***/ (function(module, exports, __webpack_require__) { + // webgl to direct 3d blend table + this._blendTable = [-1, // -- + gl.ZERO, // D3DBLEND_ZERO + gl.ONE, // D3DBLEND_ONE + gl.SRC_COLOR, // D3DBLEND_SRCCOLOR + gl.ONE_MINUS_SRC_COLOR, // D3DBLEND_INVSRCCOLOR + gl.SRC_ALPHA, // D3DBLEND_SRCALPHA + gl.ONE_MINUS_SRC_ALPHA, // D3DBLEND_INVSRCALPHA + gl.DST_ALPHA, // D3DBLEND_DESTALPHA + gl.ONE_MINUS_DST_ALPHA, // D3DBLEND_INVDESTALPHA + gl.DST_COLOR, // D3DBLEND_DESTCOLOR + gl.ONE_MINUS_DST_COLOR, // D3DBLEND_INVDESTCOLOR + gl.SRC_ALPHA_SATURATE, // D3DBLEND_SRCALPHASAT + -1, // D3DBLEND_BOTHSRCALPHA + -1, // D3DBLEND_BOTHINVSRCALPHA + gl.CONSTANT_COLOR, // D3DBLEND_BLENDFACTOR + gl.ONE_MINUS_CONSTANT_COLOR // D3DBLEND_INVBLENDFACTOR + ]; -"use strict"; + return this.glVersion; + } + /** + * Schedules a function to be called per tick + * @param {Function} func + */ -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.mat4 = undefined; + }, { + key: 'Schedule', + value: function Schedule(func) { + if (!this._scheduled.includes(func)) { + this._scheduled.push(func); + } + } -var _glMatrix = __webpack_require__(11); + /** + * Sets a callback which is fired on canvas resizing + * @param {Function} func + */ -exports.mat4 = _glMatrix.mat4; + }, { + key: 'OnResize', + value: function OnResize(func) { + this._onResize = func; + } -/** - * arcFromForward - * @param {mat4} out - * @param {vec3} v - * @return {mat4} out - */ + /** + * Handles resize events + */ -_glMatrix.mat4.arcFromForward = function () { - var vec3_0 = void 0; + }, { + key: 'Resize', + value: function Resize() { + if (this.vrDisplay && this.vrDisplay['isPresenting']) { + var leftEye = this.vrDisplay['getEyeParameters']('left'), + rightEye = this.vrDisplay['getEyeParameters']('right'); - return function arcFromForward(out, v) { - if (!vec3_0) vec3_0 = _glMatrix.vec3.create(); + this.canvas.width = Math.max(leftEye['renderWidth'], rightEye['renderWidth']) * 2; + this.canvas.height = Math.max(rightEye['renderHeight'], rightEye['renderHeight']); + } else { + this.canvas.width = this.canvas.offsetWidth * this.viewportPixelRatio; + this.canvas.height = this.canvas.offsetHeight * this.viewportPixelRatio; + } - var norm = _glMatrix.vec3.normalize(vec3_0, v); - _glMatrix.mat4.identity(out); + this.viewportWidth = this.canvas.clientWidth; + this.viewportHeight = this.canvas.clientHeight; + this.viewportAspect = this.viewportWidth / this.viewportHeight; - if (norm[2] < -0.99999) { - return out; - } + if (this._onResize) { + this._onResize(this.viewportWidth, this.viewportHeight); + } - if (norm[2] > 0.99999) { - out[5] = -1.0; - out[10] = -1.0; - return out; + _Tw2Store.store.SetVariableValue('ViewportSize', [this.viewportWidth, this.viewportHeight, this.viewportWidth, this.viewportHeight]); } - var h = (1 + norm[2]) / (norm[0] * norm[0] + norm[1] * norm[1]); - out[0] = h * norm[1] * norm[1] - norm[2]; - out[1] = -h * norm[0] * norm[1]; - out[2] = norm[0]; + /** + * Per frame Tick + */ - out[4] = out[1]; - out[5] = h * norm[0] * norm[0] - norm[2]; - out[6] = norm[1]; + }, { + key: 'Tick', + value: function Tick() { + if (this.canvas.clientWidth !== this.viewportWidth || this.canvas.clientHeight !== this.viewportHeight) { + this.Resize(); + } - out[8] = -norm[0]; - out[9] = -norm[1]; - out[10] = -norm[2]; + var previousTime = this.previousTime === null ? 0 : this.previousTime, + now = this.Now(); - return out; - }; -}(); + this.currentTime = (now - this.startTime) * 0.001; + this.dt = this.previousTime === null ? 0 : (now - this.previousTime) * 0.001; + this.previousTime = now; -/** - * Copies the translation component from one mat4 to another - * @param {mat4} out - * @param {mat4} a - * @returns {mat4} out - */ -_glMatrix.mat4.copyTranslation = function (out, a) { - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - return out; -}; + _Tw2Store.store.SetVariableValue('Time', [this.currentTime, this.currentTime - Math.floor(this.currentTime), this.frameCounter, previousTime]); -/** - * Sets a mat4 from a mat4 - * @param {mat4} out - * @param {mat3} m - * @returns {mat4} out - */ -_glMatrix.mat4.fromMat3 = function (out, m) { - out[0] = m[0]; - out[1] = m[1]; - out[2] = m[2]; - out[4] = m[3]; - out[5] = m[4]; - out[6] = m[5]; - out[8] = m[6]; - out[9] = m[7]; - out[10] = m[8]; - out[3] = out[7] = out[11] = out[12] = out[13] = out[14] = 0; - out[15] = 1; - return out; -}; + _Tw2ResMan.resMan.PrepareLoop(this.dt); -/** - * Generates a look-at matrix with the given eye position, focal point, and up axis from a left handed coordinate system - * - * @param {mat4} out - mat4 frustum matrix will be written into - * @param {vec3} eye - Position of the viewer - * @param {vec3} center - Point the viewer is looking at - * @param {vec3} up - vec3 pointing up - * @returns {mat4} out - */ -_glMatrix.mat4.lookAtGL = function () { - var vec3_0 = void 0, - vec3_1 = void 0, - vec3_2 = void 0; + for (var i = 0; i < this._scheduled.length; ++i) { + if (!this._scheduled[i](this.dt)) { + this._scheduled.splice(i, 1); + --i; + } + } - return function lookAtGL(out, eye, center, up) { - if (!vec3_0) { - vec3_0 = _glMatrix.vec3.create(); - vec3_1 = _glMatrix.vec3.create(); - vec3_2 = _glMatrix.vec3.create(); + this.frameCounter++; } - _glMatrix.vec3.subtract(vec3_2, eye, center); + /** + * Requests an animation frame + * @param {Function} func + * @returns {number} + */ - if (_glMatrix.vec3.squaredLength(vec3_2) === 0) { - vec3_2[2] = 1; + }, { + key: 'RequestAnimationFrame', + value: function RequestAnimationFrame(func) { + return this.vrDisplay ? this.vrDisplay.requestAnimationFrame(func) : Tw2Device.RequestAnimationFrame(func); } - _glMatrix.vec3.normalize(vec3_2, vec3_2); - _glMatrix.vec3.cross(vec3_0, up, vec3_2); + /** + * Sets World transform matrix + * @param {mat4} matrix + */ - if (_glMatrix.vec3.squaredLength(vec3_0) === 0) { - vec3_2[2] += 0.0001; - _glMatrix.vec3.cross(vec3_0, up, vec3_2); + }, { + key: 'SetWorld', + value: function SetWorld(matrix) { + _math.mat4.copy(this.world, matrix); + //mat4.inverse(this.worldInverse, this.world); } - _glMatrix.vec3.normalize(vec3_0, vec3_0); - _glMatrix.vec3.cross(vec3_1, vec3_2, vec3_0); - - out[0] = vec3_0[0]; - out[1] = vec3_0[1]; - out[2] = vec3_0[2]; + /** + * Sets view matrix + * @param {mat4} matrix + */ - out[4] = vec3_1[0]; - out[5] = vec3_1[1]; - out[6] = vec3_1[2]; + }, { + key: 'SetView', + value: function SetView(matrix) { + _math.mat4.copy(this.view, matrix); + _math.mat4.invert(this.viewInverse, this.view); + _math.mat4.transpose(this.viewTranspose, this.view); + _math.mat4.getTranslation(this.eyePosition, this.viewInverse); + this.UpdateViewProjection(); + } - out[8] = vec3_2[0]; - out[9] = vec3_2[1]; - out[10] = vec3_2[2]; + /** + * Sets projection matrix + * @param {mat4} matrix + * @param {boolean} [forceUpdateViewProjection] + */ - return out; - }; -}(); + }, { + key: 'SetProjection', + value: function SetProjection(matrix, forceUpdateViewProjection) { + _math.mat4.copy(this.projection, matrix); + _math.mat4.transpose(this.projectionTranspose, this.projection); + _math.mat4.invert(this.projectionInverse, this.projection); + this.GetTargetResolution(this.targetResolution); + if (forceUpdateViewProjection) this.UpdateViewProjection(); + } -/** - * Sets a left handed co-ordinate system perspective from a right handed co-ordinate system - * @param {mat4} out - receiving mat4 - * @param {number} fovY - Vertical field of view in radians - * @param {number} aspect - Aspect ratio. typically viewport width/height - * @param {number} near - Near bound of the frustum - * @param {number} far - Far bound of the frustum - * @returns {mat4} out - receiving mat4 - */ -_glMatrix.mat4.perspectiveGL = function (out, fovY, aspect, near, far) { - var fH = Math.tan(fovY / 360 * Math.PI) * near; - var fW = fH * aspect; - _glMatrix.mat4.frustum(out, -fW, fW, -fH, fH, near, far); - return out; -}; + /** + * Updates view projection matrices + */ -/** - * Sets the translation component of a mat4 from a vec3 - * @param {mat4} out - * @param {vec3} v - * @returns {mat4} out - */ -_glMatrix.mat4.setTranslation = function (out, v) { - out[12] = v[0]; - out[13] = v[1]; - out[14] = v[2]; - return out; -}; + }, { + key: 'UpdateViewProjection', + value: function UpdateViewProjection() { + _math.mat4.multiply(this.viewProjection, this.projection, this.view); + _math.mat4.transpose(this.viewProjectionTranspose, this.viewProjection); + _Tw2Store.store.SetVariableValue('ViewProjectionMat', this.viewProjection); + } -/** - * Sets the translation component of a mat4 from values - * @param {mat4} out - * @param {number} x - * @param {number} y - * @param {number} z - * @returns {mat4} out - */ -_glMatrix.mat4.setTranslationFromValues = function (out, x, y, z) { - out[12] = x; - out[13] = y; - out[14] = z; - return out; -}; + /** + * Gets the device's target resolution + * @param {vec4} out + * @returns {vec4} out + */ -/***/ }), -/* 75 */ -/***/ (function(module, exports, __webpack_require__) { + }, { + key: 'GetTargetResolution', + value: function GetTargetResolution(out) { + var aspectRatio = this.projection[0] ? this.projection[5] / this.projection[0] : 0.0; + var aspectAdjustment = 1.0; + if (aspectRatio > 1.6) aspectAdjustment = aspectRatio / 1.6; + var fov = 2.0 * Math.atan(aspectAdjustment / this.projection[5]); + out[0] = this.viewportWidth; + out[1] = this.viewportHeight; + out[2] = fov; + out[3] = fov * aspectRatio; + return out; + } -"use strict"; + /** + * GetEyePosition + * @param {vec3} [out] + * @return {vec3} + */ + }, { + key: 'GetEyePosition', + value: function GetEyePosition(out) { + return _math.vec3.copy(out, this.eyePosition); + } -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.noise = undefined; + /** + * Returns whether or not Alpha Test is enabled + * return {Boolean} + */ -var _vec = __webpack_require__(34); + }, { + key: 'IsAlphaTestEnabled', + value: function IsAlphaTestEnabled() { + return this._alphaTestState.states[this.RS_ALPHATESTENABLE]; + } -var _vec2 = __webpack_require__(35); + /** + * Checks if a frame buffer is complete + * + * @param frameBuffer + * @returns {boolean} + */ -var noise = exports.noise = {}; + }, { + key: 'IsFrameBufferComplete', + value: function IsFrameBufferComplete(frameBuffer) { + return this.gl.checkFramebufferStatus(frameBuffer) === this.gl.FRAMEBUFFER_COMPLETE; + } -/** - * Generates turbulent noise - * - * @param {vec4} out - * @param {number} pos_0 - * @param {number} pos_1 - * @param {number} pos_2 - * @param {number} pos_3 - * @param {number} power - * @returns {vec4} out - */ -noise.turbulence = function () { - var s_noiseLookup = [], - s_permutations = [], - s_globalNoiseTemps = []; + /** + * Gets a gl extension + * @param {string} extension - The gl extension name + * @returns{*} + */ - var s_initialized = false; + }, { + key: 'GetExtension', + value: function GetExtension(extension) { + for (var prefix in Tw2Device.WebglVendorPrefixes) { + if (Tw2Device.WebglVendorPrefixes.hasOwnProperty(prefix)) { + var ext = this.gl.getExtension(Tw2Device.WebglVendorPrefixes[prefix] + extension); + if (ext) return ext; + } + } - /** - * Initializes noise - */ - function initialize() { - for (var _i = 0; _i < 256; _i++) { - s_noiseLookup[_i] = _vec2.vec4.fromValues(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5); - s_permutations[_i] = _i; + return null; } - var i = 256; - while (--i) { - var tmp = s_permutations[i], - index = Math.floor(Math.random() * 256); + /** + * Gets a fallback texture + * @returns {*} + */ - s_permutations[i] = s_permutations[index]; - s_permutations[index] = tmp; + }, { + key: 'GetFallbackTexture', + value: function GetFallbackTexture() { + if (!this._fallbackTexture) { + this._fallbackTexture = this.CreateSolidTexture(); + } + return this._fallbackTexture; } - for (var _i2 = 0; _i2 < 256; _i2++) { - s_permutations[256 + _i2] = s_permutations[_i2]; - s_noiseLookup[256 + _i2] = s_noiseLookup[_i2]; - s_noiseLookup[256 * 2 + _i2] = s_noiseLookup[_i2]; + /** + * Gets a fallback cube map + * @returns {*} + */ + + }, { + key: 'GetFallbackCubeMap', + value: function GetFallbackCubeMap() { + if (!this._fallbackCube) { + this._fallbackCube = this.CreateSolidCube(); + } + return this._fallbackCube; } - for (var _i3 = 0; _i3 < 15; ++_i3) { - s_globalNoiseTemps[_i3] = _vec.vec3.create(); + /** + * Creates a solid colored texture + * @param {vec4|Array} [rgba] - The colour to create, if omitted defaults to completely transparent + * @returns {WebGLTexture} + */ + + }, { + key: 'CreateSolidTexture', + value: function CreateSolidTexture() { + var rgba = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [0, 0, 0, 0]; + + var texture = this.gl.createTexture(); + this.gl.bindTexture(this.gl.TEXTURE_2D, texture); + this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, 1, 1, 0, this.gl.RGBA, this.gl.UNSIGNED_BYTE, new Uint8Array(rgba)); + this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE); + this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE); + this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.NEAREST); + this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.NEAREST); + this.gl.bindTexture(this.gl.TEXTURE_2D, null); + return texture; } - s_initialized = true; - } + /** + * Creates a solid coloured cube texture + * @param {vec4|Array} rgba + * @returns {WebGLTexture} + */ - return function turbulence(out, pos_0, pos_1, pos_2, pos_3, power) { - if (!s_initialized) initialize(); + }, { + key: 'CreateSolidCube', + value: function CreateSolidCube() { + var rgba = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [0, 0, 0, 0]; - pos_0 += 4096; - pos_1 += 4096; - pos_2 += 4096; - pos_3 += 4096; + var texture = this.gl.createTexture(); + this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP, texture); + for (var j = 0; j < 6; ++j) { + this.gl.texImage2D(this.gl.TEXTURE_CUBE_MAP_POSITIVE_X + j, 0, this.gl.RGBA, 1, 1, 0, this.gl.RGBA, this.gl.UNSIGNED_BYTE, new Uint8Array(rgba)); + } + this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE); + this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE); + this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP, this.gl.TEXTURE_MAG_FILTER, this.gl.NEAREST); + this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP, this.gl.TEXTURE_MIN_FILTER, this.gl.NEAREST); + //this.gl.generateMipmap(this.gl.TEXTURE_CUBE_MAP); + this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP, null); + return texture; + } - var a_0 = Math.floor(pos_0), - a_1 = Math.floor(pos_1), - a_2 = Math.floor(pos_2), - a_3 = Math.floor(pos_3); + /** + * RenderFullScreenQuad + * @param {Tw2Effect} effect + * @param {string} technique - Technique name + * @returns {boolean} + */ - var t_0 = pos_0 - a_0, - t_1 = pos_1 - a_1, - t_2 = pos_2 - a_2, - t_3 = pos_3 - a_3; + }, { + key: 'RenderFullScreenQuad', + value: function RenderFullScreenQuad(effect) { + var technique = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Main'; - a_0 &= 255; - a_1 &= 255; - a_2 &= 255; - a_3 &= 255; + if (!effect || !effect.IsGood()) return false; - var b_0 = a_0 + 1, - b_1 = a_1 + 1, - b_2 = a_2 + 1, - b_3 = a_3 + 1; + this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this._quadBuffer); + for (var pass = 0; pass < effect.GetPassCount(technique); ++pass) { + effect.ApplyPass(technique, pass); + if (!this._quadDecl.SetDeclaration(effect.GetPassInput(technique, pass), 24)) return false; + this.ApplyShadowState(); + this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4); + } + return true; + } - var i = s_permutations[a_0], - j = s_permutations[b_0]; + /** + * Renders a Texture to the screen + * @param {WebGLTexture} texture + * @returns {boolean} + */ - var b00 = s_permutations[i + a_1], - b10 = s_permutations[j + a_1], - b01 = s_permutations[i + b_1], - b11 = s_permutations[j + b_1]; + }, { + key: 'RenderTexture', + value: function RenderTexture(texture) { + if (this._blitEffect === null) { + this._blitEffect = _Tw2Effect.Tw2Effect.create({ + effectFilePath: 'res:/graphics/effect/managed/space/system/blit.fx', + textures: { + BlitSource: '' + } + }); + } - var c00 = _vec.vec3.lerp(s_globalNoiseTemps[0], s_noiseLookup[b00 + a_2 + a_3], s_noiseLookup[b10 + a_2 + a_3], t_0); - var c10 = _vec.vec3.lerp(s_globalNoiseTemps[1], s_noiseLookup[b01 + a_2 + a_3], s_noiseLookup[b11 + a_2 + a_3], t_0); - var c01 = _vec.vec3.lerp(s_globalNoiseTemps[2], s_noiseLookup[b00 + b_2 + a_3], s_noiseLookup[b10 + b_2 + a_3], t_0); - var c11 = _vec.vec3.lerp(s_globalNoiseTemps[3], s_noiseLookup[b00 + b_2 + a_3], s_noiseLookup[b10 + b_2 + a_3], t_0); - var c0 = _vec.vec3.lerp(s_globalNoiseTemps[4], c00, c10, t_1); - var c1 = _vec.vec3.lerp(s_globalNoiseTemps[5], c01, c11, t_1); - var c = _vec.vec3.lerp(s_globalNoiseTemps[6], c0, c1, t_2); + this._blitEffect.parameters['BlitSource'].textureRes = texture; + return this.RenderFullScreenQuad(this._blitEffect); + } - c00 = _vec.vec3.lerp(s_globalNoiseTemps[7], s_noiseLookup[b00 + a_2 + b_3], s_noiseLookup[b10 + a_2 + b_3], t_0); - c10 = _vec.vec3.lerp(s_globalNoiseTemps[8], s_noiseLookup[b01 + a_2 + b_3], s_noiseLookup[b11 + a_2 + b_3], t_0); - c01 = _vec.vec3.lerp(s_globalNoiseTemps[9], s_noiseLookup[b00 + b_2 + b_3], s_noiseLookup[b10 + b_2 + b_3], t_0); - c11 = _vec.vec3.lerp(s_globalNoiseTemps[10], s_noiseLookup[b00 + b_2 + b_3], s_noiseLookup[b10 + b_2 + b_3], t_0); - c0 = _vec.vec3.lerp(s_globalNoiseTemps[11], c00, c10, t_1); - c1 = _vec.vec3.lerp(s_globalNoiseTemps[12], c01, c11, t_1); - var d = _vec.vec3.lerp(s_globalNoiseTemps[13], c0, c1, t_2); - var r = _vec.vec3.lerp(s_globalNoiseTemps[14], c, d, t_3); + /** + * RenderCameraSpaceQuad + * @param {Tw2Effect} effect + * @param {string} technique - Technique name + * @returns {boolean} + */ - out[0] += r[0] * power; - out[1] += r[1] * power; - out[2] += r[2] * power; - return out; - }; -}(); + }, { + key: 'RenderCameraSpaceQuad', + value: function RenderCameraSpaceQuad(effect) { + var technique = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Main'; -/** - * Perlin_noise1 - * - * @param {number} a - * @returns {number} - */ -noise.perlin1 = function () { - var p_initialized = false, - p_B = 0x100, - p_BM = 0xff, - p_N = 0x1000, - p_p = null, - p_g1 = null; + if (!effect || !effect.IsGood()) return false; - /** - * Initializes Perlin Noise - */ - function initialize() { - p_p = new Array(p_B + p_B + 2); - p_g1 = new Array(p_B + p_B + 2); + var vertices = new Float32Array([1.0, 1.0, 0.0, 1.0, 1.0, 1.0, -1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, -1.0, 0.0, 1.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, 0.0, 0.0]); - var i = 0, - j = 0, - k = 0; + var projInv = this.projectionInverse; + for (var i = 0; i < 4; ++i) { + var vec = vertices.subarray(i * 6, i * 6 + 4); + _math.vec4.transformMat4(vec, vec, projInv); + _math.vec3.scale(vec, vec, 1 / vec[3]); + vec[3] = 1; + } - for (i = 0; i < p_B; i++) { - p_p[i] = i; - p_g1[i] = Math.random() * 2 - 1; + this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this._cameraQuadBuffer); + this.gl.bufferData(this.gl.ARRAY_BUFFER, vertices, this.gl.STATIC_DRAW); + for (var pass = 0; pass < effect.GetPassCount(technique); ++pass) { + effect.ApplyPass(technique, pass); + if (!this._quadDecl.SetDeclaration(effect.GetPassInput(technique, pass), 24)) return false; + this.ApplyShadowState(); + this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4); + } + return true; } - while (--i) { - k = p_p[i]; - p_p[i] = p_p[j = Math.floor(Math.random() * p_B)]; - p_p[j] = k; - } + /** + * Set a render state + * @param state + * @param value + */ - for (i = 0; i < p_B + 2; i++) { - p_p[p_B + i] = p_p[i]; - p_g1[p_B + i] = p_g1[i]; - } + }, { + key: 'SetRenderState', + value: function SetRenderState(state, value) { + this._currentRenderMode = this.RM_ANY; + var gl = this.gl; - p_initialized = true; - } + switch (state) { + case this.RS_ZENABLE: + if (value) { + gl.enable(gl.DEPTH_TEST); + } else { + gl.disable(gl.DEPTH_TEST); + } + return; - return function perlin1(a) { - if (!p_initialized) initialize(); + case this.RS_ZWRITEENABLE: + gl.depthMask(!!value); + return; - var t = a + p_N, - bx0 = Math.floor(t) & p_BM, - bx1 = bx0 + 1 & p_BM, - rx0 = t - Math.floor(t), - rx1 = rx0 - 1; + case this.RS_ALPHATESTENABLE: + case this.RS_ALPHAREF: + case this.RS_ALPHAFUNC: + case this.RS_CLIPPING: + case this.RS_CLIPPLANEENABLE: + if (this._alphaTestState[state] !== value) { + this._alphaTestState.states[state] = value; + this._alphaTestState.dirty = true; + } + return; - var sx = rx0 * rx0 * (3.0 - 2.0 * rx0), - u = rx0 * p_g1[p_p[bx0]], - v = rx1 * p_g1[p_p[bx1]]; + case this.RS_SRCBLEND: + case this.RS_DESTBLEND: + case this.RS_BLENDOP: + case this.RS_SEPARATEALPHABLENDENABLE: + case this.RS_BLENDOPALPHA: + case this.RS_SRCBLENDALPHA: + case this.RS_DESTBLENDALPHA: + if (this._alphaBlendState[state] !== value) { + this._alphaBlendState.states[state] = value; + this._alphaBlendState.dirty = true; + } + return; - return u + sx * (v - u); - }; -}(); + case this.RS_CULLMODE: + switch (value) { + case this.CULL_NONE: + gl.disable(gl.CULL_FACE); + return; -/** - * PerlinNoise1D - * - * @param x - * @param alpha - * @param beta - * @param n - * @returns {number} - */ -noise.perlin1D = function (x, alpha, beta, n) { - var sum = 0, - p = x, - scale = 1; + case this.CULL_CW: + gl.enable(gl.CULL_FACE); + gl.cullFace(gl.FRONT); + return; - for (var i = 0; i < n; ++i) { - sum += noise.perlin1(p) / scale; - scale *= alpha; - p *= beta; - } - return sum; -}; + case this.CULL_CCW: + gl.enable(gl.CULL_FACE); + gl.cullFace(gl.BACK); + return; + } + return; -/***/ }), -/* 76 */ -/***/ (function(module, exports, __webpack_require__) { + case this.RS_ZFUNC: + gl.depthFunc(0x0200 + value - 1); + return; -"use strict"; + case this.RS_ALPHABLENDENABLE: + if (value) gl.enable(gl.BLEND);else gl.disable(gl.BLEND); + return; + case this.RS_COLORWRITEENABLE: + gl.colorMask((value & 1) !== 0, (value & 2) !== 0, (value & 4) !== 0, (value & 8) !== 0); + return; -Object.defineProperty(exports, "__esModule", { - value: true -}); -var curve = exports.curve = {}; + case this.RS_SCISSORTESTENABLE: + if (value) gl.enable(gl.SCISSOR_TEST);else gl.disable(gl.SCISSOR_TEST); + return; -/** - * Evaluates a curve - * - * @param {{}|Tw2GeometryCurve} curve - * @param {Array} curve.knots - * @param {number} curve.degree - * @param {Array} curve.controls - * @param {number} curve.dimension - * @param {number} time - * @param {*} value - * @param {boolean} cycle - * @param {number} duration - */ -curve.evaluate = function (curve, time, value, cycle, duration) { - var count = curve.knots.length; - var knot = count - 1; - var t = 0; - for (var i = 0; i < curve.knots.length; ++i) { - if (curve.knots[i] > time) { - knot = i; - break; + case this.RS_SLOPESCALEDEPTHBIAS: + case this.RS_DEPTHBIAS: + value = Tw2Device.DwordToFloat(value); + if (this._depthOffsetState[state] !== value) { + this._depthOffsetState.states[state] = value; + this._depthOffsetState.dirty = true; + } + return; + } } - } - if (curve.degree === 0) { - for (var _i = 0; _i < curve.dimension; ++_i) { - value[_i] = curve.controls[knot * curve.dimension + _i]; - } - } else if (curve.degree === 1) { - var knot0 = cycle ? (knot + count - 1) % count : knot === 0 ? 0 : knot - 1; - var dt = curve.knots[knot] - curve.knots[knot0]; + /** + * ApplyShadowState + */ + + }, { + key: 'ApplyShadowState', + value: function ApplyShadowState() { + if (this._alphaBlendState.dirty) { + var blendOp = this.gl.FUNC_ADD; + if (this._alphaBlendState.states[this.RS_BLENDOP] === this.BLENDOP_SUBTRACT) { + blendOp = this.gl.FUNC_SUBTRACT; + } else if (this._alphaBlendState.states[this.RS_BLENDOP] === this.BLENDOP_REVSUBTRACT) { + blendOp = this.gl.FUNC_REVERSE_SUBTRACT; + } + + var srcBlend = this._blendTable[this._alphaBlendState.states[this.RS_SRCBLEND]], + destBlend = this._blendTable[this._alphaBlendState.states[this.RS_DESTBLEND]]; + + if (this._alphaBlendState.states[this.RS_SEPARATEALPHABLENDENABLE]) { + var blendOpAlpha = this.gl.FUNC_ADD; + if (this._alphaBlendState.states[this.RS_BLENDOP] === this.BLENDOP_SUBTRACT) { + blendOpAlpha = this.gl.FUNC_SUBTRACT; + } else if (this._alphaBlendState.states[this.RS_BLENDOP] === this.BLENDOP_REVSUBTRACT) { + blendOpAlpha = this.gl.FUNC_REVERSE_SUBTRACT; + } + + var srcBlendAlpha = this._blendTable[this._alphaBlendState.states[this.RS_SRCBLENDALPHA]], + destBlendAlpha = this._blendTable[this._alphaBlendState.states[this.RS_DESTBLENDALPHA]]; + + this.gl.blendEquationSeparate(blendOp, blendOpAlpha); + this.gl.blendFuncSeparate(srcBlend, destBlend, srcBlendAlpha, destBlendAlpha); + } else { + this.gl.blendEquation(blendOp); + this.gl.blendFunc(srcBlend, destBlend); + } + this._alphaBlendState.dirty = false; + } + + if (this._depthOffsetState.dirty) { + this.gl.polygonOffset(this._depthOffsetState.states[this.RS_SLOPESCALEDEPTHBIAS], this._depthOffsetState.states[this.RS_DEPTHBIAS]); + this._depthOffsetState.dirty = false; + } + + var alphaTestFunc = void 0, + invertedAlphaTest = void 0, + alphaTestRef = void 0; + + if (this.shadowHandles && this._alphaTestState.states[this.RS_ALPHATESTENABLE]) { + switch (this._alphaTestState.states[this.RS_ALPHAFUNC]) { + case this.CMP_NEVER: + alphaTestFunc = 0; + invertedAlphaTest = 1; + alphaTestRef = -256; + break; + + case this.CMP_LESS: + alphaTestFunc = 0; + invertedAlphaTest = -1; + alphaTestRef = this._alphaTestState.states[this.RS_ALPHAREF] - 1; + break; - if (dt < 0) { - dt += duration; - } + case this.CMP_EQUAL: + alphaTestFunc = 1; + invertedAlphaTest = 0; + alphaTestRef = this._alphaTestState.states[this.RS_ALPHAREF]; + break; - if (dt > 0) { - t = (time - curve.knots[curve.knots.length - 1]) / dt; - } + case this.CMP_LEQUAL: + alphaTestFunc = 0; + invertedAlphaTest = -1; + alphaTestRef = this._alphaTestState.states[this.RS_ALPHAREF]; + break; - for (var _i2 = 0; _i2 < curve.dimension; ++_i2) { - value[_i2] = curve.controls[knot0 * curve.dimension + _i2] * (1 - t) + curve.controls[knot * curve.dimension + _i2] * t; - } - } else { - var k_2 = cycle ? (knot + count - 2) % count : knot === 0 ? 0 : knot - 2; - var k_1 = cycle ? (knot + count - 1) % count : knot === 0 ? 0 : knot - 1; + case this.CMP_GREATER: + alphaTestFunc = 0; + invertedAlphaTest = 1; + alphaTestRef = -this._alphaTestState.states[this.RS_ALPHAREF] - 1; + break; - var p1 = k_2 * curve.dimension; - var p2 = k_1 * curve.dimension; - var p3 = knot * curve.dimension; + /*case this.CMP_NOTEQUAL: + var alphaTestFunc = 1; + var invertedAlphaTest = 1; + var alphaTestRef = this._alphaTestState.states[this.RS_ALPHAREF]; + break;*/ - var ti_2 = curve.knots[k_2]; - var ti_1 = curve.knots[k_1]; - var ti = curve.knots[knot]; - var ti1 = curve.knots[(knot + 1) % count]; + case this.CMP_GREATEREQUAL: + alphaTestFunc = 0; + invertedAlphaTest = 1; + alphaTestRef = -this._alphaTestState.states[this.RS_ALPHAREF]; + break; - if (ti_2 > ti) { - ti += duration; - ti1 += duration; - time += duration; - } + default: + alphaTestFunc = 0; + invertedAlphaTest = 0; + alphaTestRef = 1; + break; + } - if (ti_1 > ti) { - ti += duration; - ti1 += duration; - time += duration; + var clipPlaneEnable = 0; + this.gl.uniform4f(this.shadowHandles.shadowStateInt, invertedAlphaTest, alphaTestRef, alphaTestFunc, clipPlaneEnable); + //this._shadowStateBuffers + } } - if (ti1 < ti) { - ti1 += duration; - } + /** + * Sets a render mode + * @param {number} renderMode + */ - var tmti_1 = time - ti_1; - var tmti_2 = time - ti_2; - var dL0 = ti - ti_1; - var dL1_1 = ti - ti_2; - var dL1_2 = ti1 - ti_1; + }, { + key: 'SetStandardStates', + value: function SetStandardStates(renderMode) { + if (this._currentRenderMode === renderMode) return; - var L0 = tmti_1 / dL0; - var L1_1 = tmti_2 / dL1_1; - var L1_2 = tmti_1 / dL1_2; + this.gl.frontFace(this.gl.CW); + switch (renderMode) { + case this.RM_OPAQUE: + case this.RM_PICKABLE: + this.SetRenderState(this.RS_ZENABLE, true); + this.SetRenderState(this.RS_ZWRITEENABLE, true); + this.SetRenderState(this.RS_ZFUNC, this.CMP_LEQUAL); + this.SetRenderState(this.RS_CULLMODE, this.CULL_CW); + this.SetRenderState(this.RS_ALPHABLENDENABLE, false); + this.SetRenderState(this.RS_ALPHATESTENABLE, false); + this.SetRenderState(this.RS_SEPARATEALPHABLENDENABLE, false); + this.SetRenderState(this.RS_SLOPESCALEDEPTHBIAS, 0); + this.SetRenderState(this.RS_DEPTHBIAS, 0); + this.SetRenderState(this.RS_COLORWRITEENABLE, 0xf); + break; - var ci_2 = L1_1 + L0 - L0 * L1_1; - var ci = L0 * L1_2; - var ci_1 = ci_2 - ci; - ci_2 = 1 - ci_2; + case this.RM_DECAL: + this.SetRenderState(this.RS_ALPHABLENDENABLE, false); + this.SetRenderState(this.RS_ALPHATESTENABLE, true); + this.SetRenderState(this.RS_ALPHAFUNC, this.CMP_GREATER); + this.SetRenderState(this.RS_ALPHAREF, 127); + this.SetRenderState(this.RS_ZENABLE, true); + this.SetRenderState(this.RS_ZWRITEENABLE, true); + this.SetRenderState(this.RS_ZFUNC, this.CMP_LEQUAL); + this.SetRenderState(this.RS_CULLMODE, this.CULL_CW); + this.SetRenderState(this.RS_BLENDOP, this.BLENDOP_ADD); + this.SetRenderState(this.RS_SLOPESCALEDEPTHBIAS, 0); + this.SetRenderState(this.RS_DEPTHBIAS, 0); + this.SetRenderState(this.RS_SEPARATEALPHABLENDENABLE, false); + this.SetRenderState(this.RS_COLORWRITEENABLE, 0xf); + break; - for (var _i3 = 0; _i3 < curve.dimension; ++_i3) { - value[_i3] = ci_2 * curve.controls[p1 + _i3] + ci_1 * curve.controls[p2 + _i3] + ci * curve.controls[p3 + _i3]; - } - } -}; + case this.RM_TRANSPARENT: + this.SetRenderState(this.RS_CULLMODE, this.CULL_CW); + this.SetRenderState(this.RS_ALPHABLENDENABLE, true); + this.SetRenderState(this.RS_SRCBLEND, this.BLEND_SRCALPHA); + this.SetRenderState(this.RS_DESTBLEND, this.BLEND_INVSRCALPHA); + this.SetRenderState(this.RS_BLENDOP, this.BLENDOP_ADD); + this.SetRenderState(this.RS_ZENABLE, true); + this.SetRenderState(this.RS_ZWRITEENABLE, false); + this.SetRenderState(this.RS_ZFUNC, this.CMP_LEQUAL); + this.SetRenderState(this.RS_ALPHATESTENABLE, false); + this.SetRenderState(this.RS_SLOPESCALEDEPTHBIAS, 0); // -1.0 + this.SetRenderState(this.RS_DEPTHBIAS, 0); + this.SetRenderState(this.RS_SEPARATEALPHABLENDENABLE, false); + this.SetRenderState(this.RS_COLORWRITEENABLE, 0xf); + break; -/** - * ag_horner1 - * - * @param P - * @param deg - * @param s - * @returns {*} - */ -curve.ag_horner1 = function (P, deg, s) { - var h = P[deg]; - while (--deg >= 0) { - h = s * h + P[deg]; - }return h; -}; + case this.RM_ADDITIVE: + this.SetRenderState(this.RS_CULLMODE, this.CULL_NONE); + this.SetRenderState(this.RS_ALPHABLENDENABLE, true); + this.SetRenderState(this.RS_SRCBLEND, this.BLEND_ONE); + this.SetRenderState(this.RS_DESTBLEND, this.BLEND_ONE); + this.SetRenderState(this.RS_BLENDOP, this.BLENDOP_ADD); + this.SetRenderState(this.RS_ZENABLE, true); + this.SetRenderState(this.RS_ZWRITEENABLE, false); + this.SetRenderState(this.RS_ZFUNC, this.CMP_LEQUAL); + this.SetRenderState(this.RS_ALPHATESTENABLE, false); + this.SetRenderState(this.RS_SLOPESCALEDEPTHBIAS, 0); + this.SetRenderState(this.RS_DEPTHBIAS, 0); + this.SetRenderState(this.RS_SEPARATEALPHABLENDENABLE, false); + this.SetRenderState(this.RS_COLORWRITEENABLE, 0xf); + break; -/** - * ag_zeroin2 - * - * @param a - * @param b - * @param fa - * @param fb - * @param tol - * @param pars - * @returns {*} - */ -curve.ag_zeroin2 = function (a, b, fa, fb, tol, pars) { - var test = void 0; - var c = void 0, - d = void 0, - e = void 0, - fc = void 0, - del = void 0, - m = void 0, - machtol = void 0, - p = void 0, - q = void 0, - r = void 0, - s = void 0; + case this.RM_FULLSCREEN: + this.SetRenderState(this.RS_ALPHABLENDENABLE, false); + this.SetRenderState(this.RS_ALPHATESTENABLE, false); + this.SetRenderState(this.RS_CULLMODE, this.CULL_NONE); + this.SetRenderState(this.RS_ZENABLE, false); + this.SetRenderState(this.RS_ZWRITEENABLE, false); + this.SetRenderState(this.RS_ZFUNC, this.CMP_ALWAYS); + this.SetRenderState(this.RS_SLOPESCALEDEPTHBIAS, 0); + this.SetRenderState(this.RS_DEPTHBIAS, 0); + this.SetRenderState(this.RS_SEPARATEALPHABLENDENABLE, false); + this.SetRenderState(this.RS_COLORWRITEENABLE, 0xf); + break; - /* initialization */ - machtol = 1.192092896e-07; - var label1 = true; + default: + return; + } - /* start iteration */ - while (true) { - if (label1) { - c = a; - fc = fa; - d = b - a; - e = d; + this._currentRenderMode = renderMode; } - if (Math.abs(fc) < Math.abs(fb)) { - a = b; - b = c; - c = a; - fa = fb; - fb = fc; - fc = fa; + /** + * Converts a Dword to Float + * @param value + * @return {Number} + */ + + }], [{ + key: 'DwordToFloat', + value: function DwordToFloat(value) { + var b4 = value & 0xff, + b3 = (value & 0xff00) >> 8, + b2 = (value & 0xff0000) >> 16, + b1 = (value & 0xff000000) >> 24, + sign = 1 - 2 * (b1 >> 7), + // sign = bit 0 + exp = (b1 << 1 & 0xff | b2 >> 7) - 127, + // exponent = bits 1..8 + sig = (b2 & 0x7f) << 16 | b3 << 8 | b4; // significand = bits 9..31 + + if (sig === 0 && exp === -127) return 0.0; + return sign * (1 + sig * Math.pow(2, -23)) * Math.pow(2, exp); } - label1 = false; - /* convergence test */ - del = 2.0 * machtol * Math.abs(b) + 0.5 * tol; - m = 0.5 * (c - b); - test = Math.abs(m) > del && fb !== 0.0; - if (test) { - if (Math.abs(e) < del || Math.abs(fa) <= Math.abs(fb)) { - /* bisection */ - d = m; - e = d; - } else { - s = fb / fa; - if (a === c) { - /* linear interpolation */ - p = 2.0 * m * s; - q = 1.0 - s; - } else { - /* inverse quadratic interpolation */ - q = fa / fc; - r = fb / fc; - p = s * (2.0 * m * q * (q - r) - (b - a) * (r - 1.0)); - q = (q - 1.0) * (r - 1.0) * (s - 1.0); - } - /* adjust the sign */ - if (p > 0.0) q = -q;else p = -p; - /* check if interpolation is acceptable */ - s = e; - e = d; - if (2.0 * p < 3.0 * m * q - Math.abs(del * q) && p < Math.abs(0.5 * s * q)) { - d = p / q; - } else { - d = m; - e = d; + /** + * Creates a gl context + * + * @param {HTMLCanvasElement} canvas + * @param {*} [params] + * @param {*} [contextNames] + * @returns {*} + */ + + }, { + key: 'CreateContext', + value: function CreateContext(canvas, params, contextNames) { + contextNames = Array.isArray(contextNames) ? contextNames : [contextNames]; + for (var i = 0; i < contextNames.length; i++) { + try { + return canvas.getContext(contextNames[i], params); + } catch (err) { + /* eslint-disable-line no-empty */ } } - /* complete step */ - a = b; - fa = fb; - if (Math.abs(d) > del) b += d;else if (m > 0.0) b += del;else b -= del; - fb = curve.ag_horner1(pars.p, pars.deg, b); - if (fb * (fc / Math.abs(fc)) > 0.0) { - label1 = true; - } - } else { - break; + return null; } - } - return b; -}; + }]); + + return Tw2Device; +}(); /** - * ag_zeroin - * - * @param a - * @param b - * @param tol - * @param pars - * @returns {*} + * The constructor used to generate the time + * @type {DateConstructor} */ -curve.ag_zeroin = function (a, b, tol, pars) { - var fa = void 0, - fb = void 0; - fa = curve.ag_horner1(pars.p, pars.deg, a); - if (Math.abs(fa) < 1.192092896e-07) return a; - fb = curve.ag_horner1(pars.p, pars.deg, b); - if (Math.abs(fb) < 1.192092896e-07) return b; +Tw2Device.Clock = Date; - return curve.ag_zeroin2(a, b, fa, fb, tol, pars); -}; +var timeOuts = void 0; /** - * polyZeroes - * - * @param Poly - * @param deg - * @param a - * @param a_closed - * @param b - * @param b_closed - * @param Roots - * @returns {*} + * Requests and animation frame + * @param {Function} callback + * @returns {number} id */ -curve.polyZeroes = function (Poly, deg, a, a_closed, b, b_closed, Roots) { - var i = void 0, - left_ok = void 0, - right_ok = void 0, - nr = void 0, - ndr = void 0, - skip = void 0; - - var e = void 0, - f = void 0, - s = void 0, - pe = void 0, - ps = void 0, - tol = void 0, - p = void 0, - p_x = new Array(22), - d = void 0, - d_x = new Array(22), - dr = void 0, - dr_x = new Array(22); - - var ply = { - p: [], - deg: 0 +Tw2Device.RequestAnimationFrame = function () { + var requestFrame = window['requestAnimationFrame'] || window['webkitRequestAnimationFrame'] || window['mozRequestAnimationFrame'] || window['oRequestAnimationFrame'] || window['msRequestAnimationFrame'] || function (callback) { + if (!timeOuts) timeOuts = []; + timeOuts.push(window.setTimeout(callback, 1000 / 60)); + return timeOuts.length - 1; }; - e = pe = 0.0; - f = 0.0; - - for (i = 0; i < deg + 1; ++i) { - f += Math.abs(Poly[i]); - } - tol = (Math.abs(a) + Math.abs(b)) * (deg + 1) * 1.192092896e-07; - - /* Zero polynomial to tolerance? */ - if (f <= tol) return -1; + return function RequestAnimationFrame(callback) { + return requestFrame(callback); + }; +}(); - p = p_x; - d = d_x; - dr = dr_x; - for (i = 0; i < deg + 1; ++i) { - p[i] = 1.0 / f * Poly[i]; - } +/** + * Cancels an animation frame by it's id + * @param {number} id + */ +Tw2Device.CancelAnimationFrame = function () { + var cancelFrame = window['cancelAnimationFrame'] || window['webkitRequestAnimationFrame'] || window['mozRequestAnimationFrame'] || window['oRequestAnimationFrame'] || window['msRequestAnimationFrame'] || function (id) { + if (!timeOuts) timeOuts = []; + if (timeOuts[id] !== undefined) { + window.clearTimeout(timeOuts[id]); + timeOuts[id] = undefined; + return true; + } + }; - /* determine true degree */ - while (Math.abs(p[deg]) < tol) { - deg--; - } /* Identically zero poly already caught so constant fn !== 0 */ - nr = 0; - if (deg === 0) return nr; + return function CancelAnimationFrame(id) { + cancelFrame(id); + }; +}(); - /* check for linear case */ - if (deg === 1) { - Roots[0] = -p[0] / p[1]; - left_ok = a_closed ? a < Roots[0] + tol : a < Roots[0] - tol; - right_ok = b_closed ? b > Roots[0] - tol : b > Roots[0] + tol; - nr = left_ok && right_ok ? 1 : 0; - if (nr) { - if (a_closed && Roots[0] < a) Roots[0] = a;else if (b_closed && Roots[0] > b) Roots[0] = b; - } - return nr; - } - /* handle non-linear case */ - else { - ply.p = p; - ply.deg = deg; +// Webgl details +Tw2Device.WebglVendorPrefixes = ['', 'MOZ_', 'WEBKIT_', 'WEBGL_']; +Tw2Device.WebglContextNames = ['webgl', 'experimental-webgl']; +Tw2Device.Webgl2ContextNames = ['webgl2', 'experimental-webgl2']; +Tw2Device.WebglVersion = { + NONE: 0, + WEBGL: 1, + WEBGL2: 2 +}; - /* compute derivative */ - for (i = 1; i <= deg; i++) { - d[i - 1] = i * p[i]; - } /* find roots of derivative */ - ndr = curve.polyZeroes(d, deg - 1, a, 0, b, 0, dr); - if (ndr.length === 0) return 0; +// Render Modes +Tw2Device.prototype.RM_ANY = -1; +Tw2Device.prototype.RM_OPAQUE = 0; +Tw2Device.prototype.RM_DECAL = 1; +Tw2Device.prototype.RM_TRANSPARENT = 2; +Tw2Device.prototype.RM_ADDITIVE = 3; +Tw2Device.prototype.RM_DEPTH = 4; +Tw2Device.prototype.RM_FULLSCREEN = 5; +Tw2Device.prototype.RM_PICKABLE = 6; - /* find roots between roots of the derivative */ - for (i = skip = 0; i <= ndr; i++) { - if (nr > deg) return nr; - if (i === 0) { - s = a; - ps = curve.ag_horner1(p, deg, s); - if (Math.abs(ps) <= tol && a_closed) Roots[nr++] = a; - } else { - s = e; - ps = pe; - } - if (i === ndr) { - e = b; - skip = 0; - } else e = dr[i]; - pe = curve.ag_horner1(p, deg, e); - if (skip) skip = 0;else { - if (Math.abs(pe) < tol) { - if (i !== ndr || b_closed) { - Roots[nr++] = e; - skip = 1; - } - } else if (ps < 0 && pe > 0 || ps > 0 && pe < 0) { - Roots[nr++] = curve.ag_zeroin(s, e, 0.0, ply); - if (nr > 1 && Roots[nr - 2] >= Roots[nr - 1] - tol) { - Roots[nr - 2] = (Roots[nr - 2] + Roots[nr - 1]) * 0.5; - nr--; - } - } - } - } - } +// Render States +Tw2Device.prototype.RS_ZENABLE = 7; // D3DZBUFFERTYPE (or TRUE/FALSE for legacy) +Tw2Device.prototype.RS_FILLMODE = 8; // D3DFILLMODE +Tw2Device.prototype.RS_SHADEMODE = 9; // D3DSHADEMODE +Tw2Device.prototype.RS_ZWRITEENABLE = 14; // TRUE to enable z writes +Tw2Device.prototype.RS_ALPHATESTENABLE = 15; // TRUE to enable alpha tests +Tw2Device.prototype.RS_LASTPIXEL = 16; // TRUE for last-pixel on lines +Tw2Device.prototype.RS_SRCBLEND = 19; // D3DBLEND +Tw2Device.prototype.RS_DESTBLEND = 20; // D3DBLEND +Tw2Device.prototype.RS_CULLMODE = 22; // D3DCULL +Tw2Device.prototype.RS_ZFUNC = 23; // D3DCMPFUNC +Tw2Device.prototype.RS_ALPHAREF = 24; // D3DFIXED +Tw2Device.prototype.RS_ALPHAFUNC = 25; // D3DCMPFUNC +Tw2Device.prototype.RS_DITHERENABLE = 26; // TRUE to enable dithering +Tw2Device.prototype.RS_ALPHABLENDENABLE = 27; // TRUE to enable alpha blending +Tw2Device.prototype.RS_FOGENABLE = 28; // TRUE to enable fog blending +Tw2Device.prototype.RS_SPECULARENABLE = 29; // TRUE to enable specular +Tw2Device.prototype.RS_FOGCOLOR = 34; // D3DCOLOR +Tw2Device.prototype.RS_FOGTABLEMODE = 35; // D3DFOGMODE +Tw2Device.prototype.RS_FOGSTART = 36; // Fog start (for both vertex and pixel fog) +Tw2Device.prototype.RS_FOGEND = 37; // Fog end +Tw2Device.prototype.RS_FOGDENSITY = 38; // Fog density +Tw2Device.prototype.RS_RANGEFOGENABLE = 48; // Enables range-based fog +Tw2Device.prototype.RS_STENCILENABLE = 52; // BOOL enable/disable stenciling +Tw2Device.prototype.RS_STENCILFAIL = 53; // D3DSTENCILOP to do if stencil test fails +Tw2Device.prototype.RS_STENCILZFAIL = 54; // D3DSTENCILOP to do if stencil test passes and Z test fails +Tw2Device.prototype.RS_STENCILPASS = 55; // D3DSTENCILOP to do if both stencil and Z tests pass +Tw2Device.prototype.RS_STENCILFUNC = 56; // D3DCMPFUNC fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true +Tw2Device.prototype.RS_STENCILREF = 57; // Reference value used in stencil test +Tw2Device.prototype.RS_STENCILMASK = 58; // Mask value used in stencil test +Tw2Device.prototype.RS_STENCILWRITEMASK = 59; // Write mask applied to values written to stencil buffer +Tw2Device.prototype.RS_TEXTUREFACTOR = 60; // D3DCOLOR used for multi-texture blend +Tw2Device.prototype.RS_WRAP0 = 128; // wrap for 1st texture coord. set +Tw2Device.prototype.RS_WRAP1 = 129; // wrap for 2nd texture coord. set +Tw2Device.prototype.RS_WRAP2 = 130; // wrap for 3rd texture coord. set +Tw2Device.prototype.RS_WRAP3 = 131; // wrap for 4th texture coord. set +Tw2Device.prototype.RS_WRAP4 = 132; // wrap for 5th texture coord. set +Tw2Device.prototype.RS_WRAP5 = 133; // wrap for 6th texture coord. set +Tw2Device.prototype.RS_WRAP6 = 134; // wrap for 7th texture coord. set +Tw2Device.prototype.RS_WRAP7 = 135; // wrap for 8th texture coord. set +Tw2Device.prototype.RS_CLIPPING = 136; +Tw2Device.prototype.RS_LIGHTING = 137; +Tw2Device.prototype.RS_AMBIENT = 139; +Tw2Device.prototype.RS_FOGVERTEXMODE = 140; +Tw2Device.prototype.RS_COLORVERTEX = 141; +Tw2Device.prototype.RS_LOCALVIEWER = 142; +Tw2Device.prototype.RS_NORMALIZENORMALS = 143; +Tw2Device.prototype.RS_DIFFUSEMATERIALSOURCE = 145; +Tw2Device.prototype.RS_SPECULARMATERIALSOURCE = 146; +Tw2Device.prototype.RS_AMBIENTMATERIALSOURCE = 147; +Tw2Device.prototype.RS_EMISSIVEMATERIALSOURCE = 148; +Tw2Device.prototype.RS_VERTEXBLEND = 151; +Tw2Device.prototype.RS_CLIPPLANEENABLE = 152; +Tw2Device.prototype.RS_POINTSIZE = 154; // float point size +Tw2Device.prototype.RS_POINTSIZE_MIN = 155; // float point size min threshold +Tw2Device.prototype.RS_POINTSPRITEENABLE = 156; // BOOL point texture coord control +Tw2Device.prototype.RS_POINTSCALEENABLE = 157; // BOOL point size scale enable +Tw2Device.prototype.RS_POINTSCALE_A = 158; // float point attenuation A value +Tw2Device.prototype.RS_POINTSCALE_B = 159; // float point attenuation B value +Tw2Device.prototype.RS_POINTSCALE_C = 160; // float point attenuation C value +Tw2Device.prototype.RS_MULTISAMPLEANTIALIAS = 161; // BOOL - set to do FSAA with multisample buffer +Tw2Device.prototype.RS_MULTISAMPLEMASK = 162; // DWORD - per-sample enable/disable +Tw2Device.prototype.RS_PATCHEDGESTYLE = 163; // Sets whether patch edges will use float style tessellation +Tw2Device.prototype.RS_DEBUGMONITORTOKEN = 165; // DEBUG ONLY - token to debug monitor +Tw2Device.prototype.RS_POINTSIZE_MAX = 166; +// float point size max threshold +Tw2Device.prototype.RS_INDEXEDVERTEXBLENDENABLE = 167; +Tw2Device.prototype.RS_COLORWRITEENABLE = 168; // per-channel write enable +Tw2Device.prototype.RS_TWEENFACTOR = 170; // float tween factor +Tw2Device.prototype.RS_BLENDOP = 171; // D3DBLENDOP setting +Tw2Device.prototype.RS_POSITIONDEGREE = 172; // NPatch position interpolation degree. D3DDEGREE_LINEAR or D3DDEGREE_CUBIC (default) +Tw2Device.prototype.RS_NORMALDEGREE = 173; // NPatch normal interpolation degree. D3DDEGREE_LINEAR (default) or D3DDEGREE_QUADRATIC +Tw2Device.prototype.RS_SCISSORTESTENABLE = 174; +Tw2Device.prototype.RS_SLOPESCALEDEPTHBIAS = 175; +Tw2Device.prototype.RS_ANTIALIASEDLINEENABLE = 176; +Tw2Device.prototype.RS_TWOSIDEDSTENCILMODE = 185; // BOOL enable/disable 2 sided stenciling +Tw2Device.prototype.RS_CCW_STENCILFAIL = 186; // D3DSTENCILOP to do if ccw stencil test fails +Tw2Device.prototype.RS_CCW_STENCILZFAIL = 187; // D3DSTENCILOP to do if ccw stencil test passes and Z test fails +Tw2Device.prototype.RS_CCW_STENCILPASS = 188; // D3DSTENCILOP to do if both ccw stencil and Z tests pass +Tw2Device.prototype.RS_CCW_STENCILFUNC = 189; // D3DCMPFUNC fn. ccw Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true +Tw2Device.prototype.RS_COLORWRITEENABLE1 = 190; // Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS +Tw2Device.prototype.RS_COLORWRITEENABLE2 = 191; // Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS +Tw2Device.prototype.RS_COLORWRITEENABLE3 = 192; // Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS +Tw2Device.prototype.RS_BLENDFACTOR = 193; // D3DCOLOR used for a constant blend factor during alpha blending for devices that support D3DPBLENDCAPS_BLENDFACTOR +Tw2Device.prototype.RS_SRGBWRITEENABLE = 194; // Enable rendertarget writes to be DE-linearized to SRGB (for formats that expose D3DUSAGE_QUERY_SRGBWRITE) +Tw2Device.prototype.RS_DEPTHBIAS = 195; +Tw2Device.prototype.RS_SEPARATEALPHABLENDENABLE = 206; // TRUE to enable a separate blending function for the alpha channel +Tw2Device.prototype.RS_SRCBLENDALPHA = 207; // SRC blend factor for the alpha channel when RS_SEPARATEDESTALPHAENABLE is TRUE +Tw2Device.prototype.RS_DESTBLENDALPHA = 208; // DST blend factor for the alpha channel when RS_SEPARATEDESTALPHAENABLE is TRUE +Tw2Device.prototype.RS_BLENDOPALPHA = 209; // Blending operation for the alpha channel when RS_SEPARATEDESTALPHAENABLE is TRUE */// Cull Modes +Tw2Device.prototype.CULL_NONE = 1; +Tw2Device.prototype.CULL_CW = 2; +Tw2Device.prototype.CULL_CCW = 3; +// Compare +Tw2Device.prototype.CMP_NEVER = 1; +Tw2Device.prototype.CMP_LESS = 2; +Tw2Device.prototype.CMP_EQUAL = 3; +Tw2Device.prototype.CMP_LEQUAL = 4; +Tw2Device.prototype.CMP_GREATER = 5; +Tw2Device.prototype.CMP_NOTEQUAL = 6; +Tw2Device.prototype.CMP_GREATEREQUAL = 7; +Tw2Device.prototype.CMP_ALWAYS = 8; +// Blend +Tw2Device.prototype.BLEND_ZERO = 1; +Tw2Device.prototype.BLEND_ONE = 2; +Tw2Device.prototype.BLEND_SRCCOLOR = 3; +Tw2Device.prototype.BLEND_INVSRCCOLOR = 4; +Tw2Device.prototype.BLEND_SRCALPHA = 5; +Tw2Device.prototype.BLEND_INVSRCALPHA = 6; +Tw2Device.prototype.BLEND_DESTALPHA = 7; +Tw2Device.prototype.BLEND_INVDESTALPHA = 8; +Tw2Device.prototype.BLEND_DESTCOLOR = 9; +Tw2Device.prototype.BLEND_INVDESTCOLOR = 10; +Tw2Device.prototype.BLEND_SRCALPHASAT = 11; +Tw2Device.prototype.BLEND_BOTHSRCALPHA = 12; +Tw2Device.prototype.BLEND_BOTHINVSRCALPHA = 13; +Tw2Device.prototype.BLEND_BLENDFACTOR = 14; +Tw2Device.prototype.BLEND_INVBLENDFACTOR = 15; +// Blend Operations +Tw2Device.prototype.BLENDOP_ADD = 1; +Tw2Device.prototype.BLENDOP_SUBTRACT = 2; +Tw2Device.prototype.BLENDOP_REVSUBTRACT = 3; +Tw2Device.prototype.BLENDOP_MIN = 4; +Tw2Device.prototype.BLENDOP_MAX = 5; - return nr; -}; +var device = exports.device = new Tw2Device(); /***/ }), -/* 77 */ +/* 80 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -18252,29 +18452,12 @@ curve.polyZeroes = function (Poly, deg, a, a_closed, b, b_closed, Roots) { Object.defineProperty(exports, "__esModule", { value: true }); -var util = exports.util = {}; - -/** - * Adds arguments to an array if they don't already exist in it - * @param {Array} arr - * @param args - * @returns {boolean} true if something was added - */ -util.addToArray = function (arr) { - var added = false; +exports.assignIfExists = assignIfExists; +exports.get = get; - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } +var _type = __webpack_require__(20); - for (var i = 0; i < args.length; i++) { - if (arr.indexOf(args[i]) !== -1) { - arr.push(args[i]); - added = true; - } - } - return added; -}; +var _arr = __webpack_require__(35); /** * Assigns property values if they exist in a source object @@ -18284,28 +18467,60 @@ util.addToArray = function (arr) { * @param {*} src * @param {string|string[]} attrs */ -util.assignIfExists = function (dest, src, attrs) { +function assignIfExists(dest, src, attrs) { if (!src) return; - attrs = util.toArray(attrs); + attrs = (0, _arr.toArray)(attrs); for (var i = 0; i < attrs.length; i++) { var attr = attrs[i]; if (src[attr] !== undefined) { - if (util.isTyped(dest[attr])) { - if (dest[attr].length !== src[attr].length) { - dest[attr] = new dest[attr]['constructor'](src[attr]); + if ((0, _type.isArrayLike)(dest[attr])) { + if ((0, _type.isTyped)(dest[attr])) { + if (dest[attr].length !== src[attr].length) { + var Constructor = dest[attr].constructor; + dest[attr] = new Constructor(src[attr]); + } else { + dest[attr].set(src[attr]); + } } else { - dest[attr].set(src[attr]); + dest[attr] = dest[attr].splice(dest[attr].length, 0); + for (var _i = 0; _i < src[attr].length; _i++) { + dest[attr].push(src[attr][_i]); + } } - } else if (util.isTyped(src[attr])) { - dest[attr] = new src[attr]['constructor'](src[attr]); + } else if ((0, _type.isTyped)(src[attr])) { + var _Constructor = src[attr].constructor; + dest[attr] = new _Constructor(src[attr]); } else { dest[attr] = src[attr]; } } } -}; +} + +/** + * Gets a source's property value if it exists else returns a default value + * @param {*} src + * @param {string} prop + * @param {*} defaultValue + * @returns {*} + */ +function get(src, prop, defaultValue) { + return src && prop in src ? src[prop] : defaultValue; +} + +/***/ }), +/* 81 */ +/***/ (function(module, exports, __webpack_require__) { +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.enableUUID = enableUUID; +exports.generateID = generateID; /** * Identifies if UUIDs should be used for ID generation * @type {?boolean} @@ -18313,172 +18528,471 @@ util.assignIfExists = function (dest, src, attrs) { var USE_UUID = null; /** - * Generates an object id - * @returns {number} - * @private + * Internal object count + * @type {number} */ -var _generateObjectID = function () { - var OBJECT_COUNT = 0; - return function _generateObjectID() { - return OBJECT_COUNT++; - }; -}(); +var OBJECT_COUNT = 0; + +/** + * Stores uuid scratch + * @type {?Array} + */ +var LUT = null; /** * Generates a UUID * @author Three.js * @returns {string} - * @private */ -var _generateUUID = function () { - var lut = []; - for (var i = 0; i < 256; i++) { - lut[i] = (i < 16 ? '0' : '') + i.toString(16).toUpperCase(); - } +function generateUUID() { + var d0 = Math.random() * 0xffffffff | 0, + d1 = Math.random() * 0xffffffff | 0, + d2 = Math.random() * 0xffffffff | 0, + d3 = Math.random() * 0xffffffff | 0; - return function _generateUUID() { - var d0 = Math.random() * 0xffffffff | 0, - d1 = Math.random() * 0xffffffff | 0, - d2 = Math.random() * 0xffffffff | 0, - d3 = Math.random() * 0xffffffff | 0; - - return lut[d0 & 0xff] + lut[d0 >> 8 & 0xff] + lut[d0 >> 16 & 0xff] + lut[d0 >> 24 & 0xff] + '-' + lut[d1 & 0xff] + lut[d1 >> 8 & 0xff] + '-' + lut[d1 >> 16 & 0x0f | 0x40] + lut[d1 >> 24 & 0xff] + '-' + lut[d2 & 0x3f | 0x80] + lut[d2 >> 8 & 0xff] + '-' + lut[d2 >> 16 & 0xff] + lut[d2 >> 24 & 0xff] + lut[d3 & 0xff] + lut[d3 >> 8 & 0xff] + lut[d3 >> 16 & 0xff] + lut[d3 >> 24 & 0xff]; - }; -}(); + return LUT[d0 & 0xff] + LUT[d0 >> 8 & 0xff] + LUT[d0 >> 16 & 0xff] + LUT[d0 >> 24 & 0xff] + '-' + LUT[d1 & 0xff] + LUT[d1 >> 8 & 0xff] + '-' + LUT[d1 >> 16 & 0x0f | 0x40] + LUT[d1 >> 24 & 0xff] + '-' + LUT[d2 & 0x3f | 0x80] + LUT[d2 >> 8 & 0xff] + '-' + LUT[d2 >> 16 & 0xff] + LUT[d2 >> 24 & 0xff] + LUT[d3 & 0xff] + LUT[d3 >> 8 & 0xff] + LUT[d3 >> 16 & 0xff] + LUT[d3 >> 24 & 0xff]; +} /** * Enables UUID's for ID generation * @param {boolean} bool - * @throws When generateID have already been used and trying to set a different ID type + * @throws When generateID has already been used and trying to set a different ID type */ -util.enableUUID = function (bool) { - if (USE_UUID !== null && bool !== USE_UUID) { - throw new Error('Cannot change id generation type once used'); +function enableUUID(bool) { + if (bool === USE_UUID) { + return; + } + + if (USE_UUID !== null) { + throw new Error('Cannot change id generation type once set'); } + + if (bool) { + LUT = []; + for (var i = 0; i < 256; i++) { + LUT[i] = (i < 16 ? '0' : '') + i.toString(16).toUpperCase(); + } + } + USE_UUID = bool; -}; +} /** * Generates an id * - Defaults to Object IDs * @returns {string|number} */ -util.generateID = function () { - if (USE_UUID === null) USE_UUID = false; - return USE_UUID ? _generateUUID() : _generateObjectID(); -}; +function generateID() { + if (USE_UUID === null) { + USE_UUID = false; + } + + return USE_UUID ? generateUUID() : OBJECT_COUNT++; +} + +/***/ }), +/* 82 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getURL = getURL; +exports.getURLString = getURLString; +exports.getURLInteger = getURLInteger; +exports.getURLFloat = getURLFloat; +exports.getURLBoolean = getURLBoolean; + +var url = {}, + query = window.location.search.substring(1), + split = query.split('&'); + +for (var i = 0; i < split.length; i++) { + var result = split[i].split('='), + key = result[0].toLowerCase(), + value = unescape(result[1]); + + if (key) { + var v = value.toLowerCase(); + url[key] = v === 'true' ? true : v === 'false' ? false : value; + } +} /** - * Gets a source's property value if it exists else returns a default value - * @param {*} src - * @param {string} prop - * @param {*} defaultValue + * Gets the url as an object * @returns {*} */ -util.get = function (src, prop, defaultValue) { - return src && prop in src ? src[prop] : defaultValue; -}; +function getURL() { + return Object.assign({}, url); +} /** - * Checks if a value is an array - * @param {*} a - * @returns {boolean} + * Gets a string from the url, returning a default value if not found + * @param {string} key + * @param {string} defaultValue + * @returns {string} */ -util.isArray = Array.isArray; +function getURLString(key, defaultValue) { + key = key.toLowerCase(); + return key in url ? url[key] : defaultValue; +} /** - * Checks if a value is array like - * @param {*} a - * @returns {boolean} + * Gets an integer from the url, returning a default value if not found + * @param {string} key + * @param {number} defaultValue + * @returns {number} */ -util.isArrayLike = function (a) { - return a ? util.isArray(a) || util.isTyped(a) : false; -}; +function getURLInteger(key, defaultValue) { + key = key.toLowerCase(); + return key in url ? parseInt(url[key], 10) : defaultValue; +} /** - * Checks if a value is a vector - * @param {*} a + * Gets a float from the url, returning a default value if not found + * @param {string} key + * @param {number} defaultValue + * @returns {number} + */ +function getURLFloat(key, defaultValue) { + key = key.toLowerCase(); + return key in url ? parseFloat(url[key]) : defaultValue; +} + +/** + * Gets a boolean from the url, returning a default value if not found + * @param {string} key + * @param {boolean} defaultValue * @returns {boolean} */ -util.isVector = function (a) { - if (a) { - if (util.isTyped(a)) { - return true; +function getURLBoolean(key, defaultValue) { + key = key.toLowerCase(); + return key in url ? url[key] : defaultValue; +} + +/***/ }), +/* 83 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * Emitter privates + * @type {WeakMap} + */ +var PRIVATE = new WeakMap(); + +/** + * Tw2EventEmitter + * @class + */ + +var Tw2EventEmitter = exports.Tw2EventEmitter = function () { + function Tw2EventEmitter() { + _classCallCheck(this, Tw2EventEmitter); + } + + _createClass(Tw2EventEmitter, [{ + key: 'emit', + + /** + * Emits an event + * @param {string} eventName + * @param {*} [e={}] + * @returns {Tw2EventEmitter} + * @emit event_added { eventName: string} - the first time an event is emitted + */ + value: function emit(eventName) { + var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + if (PRIVATE.has(this)) { + var events = PRIVATE.get(this); + eventName = eventName.toLowerCase(); + + // Short cut to creating a log output + if (e.log && !e.log.logged) { + e.log = this.log(eventName, e.log); + } + + if (eventName in events) { + events[eventName].forEach(function (value, key) { + key.call(value.context, e); + if (value.once) events[eventName].delete(key); + }); + } else { + events[eventName] = new Set(); + this.emit('event_added', { eventName: eventName }); + } + } + return this; } - if (util.isArray(a)) { - for (var i = 0; i < a.length; i++) { - if (typeof a[i] !== 'number') return false; + /** + * Adds a listener to an event + * @param {Array|string} eventName + * @param {Function} listener + * @param {*} [context=undefined] + * @param {boolean} [once=false] + * @returns {Tw2EventEmitter} + */ + + }, { + key: 'on', + value: function on(eventName, listener) { + var _this = this; + + var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; + var once = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + + if (!PRIVATE.has(this)) PRIVATE.set(this, {}); + var events = PRIVATE.get(this); + + eventName = eventName.toLowerCase(); + if (!events[eventName]) { + events[eventName] = new Set(); + events[eventName].add(function () { + return _this.emit('event_added', { eventName: eventName }); + }, { once: true }); } - return true; + events[eventName].add(listener, { context: context, once: once }); + return this; } - } - return false; -}; -/** - * Checks if a value is a typed array - * @param {*} a - * @returns {boolean} - */ -util.isTyped = function (a) { - return a ? !!(a.buffer instanceof ArrayBuffer && a.BYTES_PER_ELEMENT) : false; -}; + /** + * Adds a listener to an event, and clears it after it's first emit + * @param {string} eventName + * @param {Function} listener + * @param {*} [context] + * @returns {Tw2EventEmitter} + */ + + }, { + key: 'once', + value: function once(eventName, listener, context) { + return this.on(eventName, listener, context, true); + } + + /** + * Removes a listener from a specific event or from all by passing '*' as the eventName + * @param {string} eventName + * @param {Function} listener + * @returns {Tw2EventEmitter} + */ + + }, { + key: 'off', + value: function off(eventName, listener) { + if (PRIVATE.has(this)) { + var events = PRIVATE.get(this); + eventName = eventName.toLowerCase(); + if (eventName in events) events[eventName].delete(listener); + } + return this; + } + + /** + * Deletes an event and it's listeners + * @param {string} eventName + * @returns {Tw2EventEmitter} + * @emit event_removed { eventName: String } + */ + + }, { + key: 'del', + value: function del(eventName) { + if (PRIVATE.has(this)) { + var events = PRIVATE.get(this); + eventName = eventName.toLowerCase(); + if (eventName in events) { + this.emit('event_removed', { eventName: eventName }); + delete events[eventName]; + } + } + return this; + } + + /** + * Clears a listener from all events + * @param {Function} listener + * @returns {Tw2EventEmitter} + */ + + }, { + key: 'clr', + value: function clr(listener) { + if (PRIVATE.has(this)) { + var events = PRIVATE.get(this); + for (var eventName in events) { + if (events.hasOwnProperty(eventName) && events[eventName].has(listener)) { + events[eventName].delete(listener); + } + } + } + return this; + } + + /** + * Kills all events and listeners from the emitter + * @returns {Tw2EventEmitter} + * @emit event_kill + */ + + }, { + key: 'kill', + value: function kill() { + if (PRIVATE.has(this)) { + this.emit('event_kill'); + PRIVATE.set(this, {}); + } + return this; + } + + /** + * Logs an event log + * @param {string} eventName + * @param {eventLog} eventLog + * @returns {eventLog} + */ + + }, { + key: 'log', + value: function log(eventName, eventLog) { + if (this.constructor.logger) { + this.constructor.logger.log(eventName, eventLog); + } + return eventLog; + } + + /** + * Assigns the event emitter's prototypes to a constructor/class + * @param Constructor + */ + + }], [{ + key: 'assign', + value: function assign(Constructor) { + Object.assign(Constructor.prototype, Tw2EventEmitter.prototype); + } + }]); + + return Tw2EventEmitter; +}(); /** - * Calls a function with arguments for each child in an array where that function exists - * @param {Array} arr - * @param {string} func - * @param args + * Global logger + * @type {*} */ -util.perArrayChild = function (arr, func) { - var len = arr.length; - for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { - args[_key2 - 2] = arguments[_key2]; + +Tw2EventEmitter.logger = null; + +/***/ }), +/* 84 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2Error = undefined; + +var _index = __webpack_require__(16); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +function _extendableBuiltin(cls) { + function ExtendableBuiltin() { + var instance = Reflect.construct(cls, Array.from(arguments)); + Object.setPrototypeOf(instance, Object.getPrototypeOf(this)); + return instance; } - for (var i = 0; i < len; i++) { - var _arr$i; + ExtendableBuiltin.prototype = Object.create(cls.prototype, { + constructor: { + value: cls, + enumerable: false, + writable: true, + configurable: true + } + }); - if (func in arr) (_arr$i = arr[i])[func].apply(_arr$i, args); + if (Object.setPrototypeOf) { + Object.setPrototypeOf(ExtendableBuiltin, cls); + } else { + ExtendableBuiltin.__proto__ = cls; } -}; + + return ExtendableBuiltin; +} + +var HAS_CAPTURE_STACK_TRACE = (0, _index.isFunction)(Error['captureStackTrace']); /** - * Removes arguments from an array if they exist in it - * @param {Array} arr - * @param args - * @returns {boolean} true if something was removed + * Extends standard errors + * @param {string|{}} data - Error message or an object containing relevant data + * @param {string} [defaultMessage] - The default error message */ -util.removeFromArray = function (arr) { - var removed = false; - for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { - args[_key3 - 1] = arguments[_key3]; - } +var Tw2Error = exports.Tw2Error = function (_extendableBuiltin2) { + _inherits(Tw2Error, _extendableBuiltin2); - for (var i = 0; i < args.length; i++) { - var index = arr.indexOf(args[i]); - if (index !== -1) { - arr.splice(index, 1); - removed = true; + function Tw2Error() { + var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var defaultMessage = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Undefined error'; + + _classCallCheck(this, Tw2Error); + + var _this = _possibleConstructorReturn(this, (Tw2Error.__proto__ || Object.getPrototypeOf(Tw2Error)).call(this)); + + if ((0, _index.isString)(data)) { + data = { message: data }; + } else { + data.message = data.message || defaultMessage; + } + + _this.message = data.message; + _this.name = _this.constructor.name; + _this.data = data; + + if (HAS_CAPTURE_STACK_TRACE) { + Error['captureStackTrace'](_this, Tw2Error); + } else { + _this.stack = new Error(data.message).stack; } + return _this; } - return removed; -}; + + return Tw2Error; +}(_extendableBuiltin(Error)); /** - * Returns a value if it is an array, or a new array with the object in it - * @param {*} a - * @returns {Array} + * Fallback if instanceof Error isn't supported by client + * @type {boolean} */ -util.toArray = function (a) { - return Array.isArray(a) ? a : [a]; -}; + + +Tw2Error.isError = true; /***/ }), -/* 78 */ +/* 85 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -18487,12 +19001,9 @@ util.toArray = function (a) { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2MotherLode = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2Logger = __webpack_require__(4); - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** @@ -18611,17 +19122,18 @@ var Tw2MotherLode = exports.Tw2MotherLode = function () { * @param {Number} curFrame - the current frame count * @param {Number} frameLimit - how many frames the object can stay alive for before being purged * @param {Number} frameDistance - how long the resource has been alive for + * @param {Tw2Logger} logger */ }, { key: 'PurgeInactive', - value: function PurgeInactive(curFrame, frameLimit, frameDistance) { + value: function PurgeInactive(curFrame, frameLimit, frameDistance, logger) { for (var path in this._loadedObjects) { if (this._loadedObjects.hasOwnProperty(path)) { var res = this._loadedObjects[path]; if (!res.doNotPurge) { if (res._isPurged) { - _Tw2Logger.logger.log('res.event', { + logger.log('res.event', { msg: 'Unloaded ', path: res.path, type: 'purged' @@ -18631,7 +19143,7 @@ var Tw2MotherLode = exports.Tw2MotherLode = function () { } if (res._isGood && (curFrame - res.activeFrame) % frameLimit >= frameDistance) { if (res.Unload()) { - _Tw2Logger.logger.log('res.event', { + logger.log('res.event', { msg: 'Unloaded ', path: res.path, type: 'unused' @@ -18649,7 +19161,7 @@ var Tw2MotherLode = exports.Tw2MotherLode = function () { }(); /***/ }), -/* 79 */ +/* 86 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -18660,9 +19172,9 @@ Object.defineProperty(exports, "__esModule", { }); exports.Tw2SamplerOverride = undefined; -var _Tw2Device = __webpack_require__(2); +var _global = __webpack_require__(0); -var _Tw2SamplerState = __webpack_require__(42); +var _Tw2SamplerState = __webpack_require__(43); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -18708,43 +19220,43 @@ var Tw2SamplerOverride = exports.Tw2SamplerOverride = function Tw2SamplerOverrid if (this.filter === 1) { switch (this.mipFilter) { case 0: - sampler.minFilter = _Tw2Device.device.gl.NEAREST; + sampler.minFilter = _global.device.gl.NEAREST; break; case 1: - sampler.minFilter = _Tw2Device.device.gl.NEAREST_MIPMAP_NEAREST; + sampler.minFilter = _global.device.gl.NEAREST_MIPMAP_NEAREST; break; default: - sampler.minFilter = _Tw2Device.device.gl.NEAREST_MIPMAP_LINEAR; + sampler.minFilter = _global.device.gl.NEAREST_MIPMAP_LINEAR; } - sampler.minFilterNoMips = _Tw2Device.device.gl.NEAREST; + sampler.minFilterNoMips = _global.device.gl.NEAREST; } else { switch (this.mipFilter) { case 0: - sampler.minFilter = _Tw2Device.device.gl.LINEAR; + sampler.minFilter = _global.device.gl.LINEAR; break; case 1: - sampler.minFilter = _Tw2Device.device.gl.LINEAR_MIPMAP_NEAREST; + sampler.minFilter = _global.device.gl.LINEAR_MIPMAP_NEAREST; break; default: - sampler.minFilter = _Tw2Device.device.gl.LINEAR_MIPMAP_LINEAR; + sampler.minFilter = _global.device.gl.LINEAR_MIPMAP_LINEAR; } - sampler.minFilterNoMips = _Tw2Device.device.gl.LINEAR; + sampler.minFilterNoMips = _global.device.gl.LINEAR; } if (this.filter === 3 || this.mipFilter === 3) { sampler.anisotropy = Math.max(this.maxAnisotropy, 1); } - sampler.magFilter = this.filter === 1 ? _Tw2Device.device.gl.NEAREST : _Tw2Device.device.gl.LINEAR; - sampler.addressU = _Tw2Device.device.wrapModes[this.addressU]; - sampler.addressV = _Tw2Device.device.wrapModes[this.addressV]; - sampler.addressW = _Tw2Device.device.wrapModes[this.addressW]; + sampler.magFilter = this.filter === 1 ? _global.device.gl.NEAREST : _global.device.gl.LINEAR; + sampler.addressU = _global.device.wrapModes[this.addressU]; + sampler.addressV = _global.device.wrapModes[this.addressV]; + sampler.addressW = _global.device.wrapModes[this.addressW]; sampler.samplerType = originalSampler.samplerType; sampler.isVolume = originalSampler.isVolume; sampler.ComputeHash(); @@ -18755,7 +19267,7 @@ var Tw2SamplerOverride = exports.Tw2SamplerOverride = function Tw2SamplerOverrid }; /***/ }), -/* 80 */ +/* 87 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -18768,9 +19280,9 @@ exports.Tw2VertexDeclaration = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2Device = __webpack_require__(2); +var _global = __webpack_require__(0); -var _Tw2VertexElement = __webpack_require__(43); +var _Tw2VertexElement = __webpack_require__(44); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -18858,8 +19370,8 @@ var Tw2VertexDeclaration = exports.Tw2VertexDeclaration = function () { while (true) { if (index >= this._elementsSorted.length) { - _Tw2Device.device.gl.disableVertexAttribArray(el.location); - _Tw2Device.device.gl.vertexAttrib4f(el.location, 0, 0, 0, 0); + _global.device.gl.disableVertexAttribArray(el.location); + _global.device.gl.vertexAttrib4f(el.location, 0, 0, 0, 0); break; } @@ -18867,8 +19379,8 @@ var Tw2VertexDeclaration = exports.Tw2VertexDeclaration = function () { cmp = Tw2VertexDeclaration.CompareDeclarationElements(input, el); if (cmp > 0) { - _Tw2Device.device.gl.disableVertexAttribArray(el.location); - _Tw2Device.device.gl.vertexAttrib4f(el.location, 0, 0, 0, 0); + _global.device.gl.disableVertexAttribArray(el.location); + _global.device.gl.vertexAttrib4f(el.location, 0, 0, 0, 0); break; } @@ -18876,8 +19388,8 @@ var Tw2VertexDeclaration = exports.Tw2VertexDeclaration = function () { if (input.customSetter) { input.customSetter(el); } else { - _Tw2Device.device.gl.enableVertexAttribArray(el.location); - _Tw2Device.device.gl.vertexAttribPointer(el.location, input.elements, input.type, false, stride, input.offset); + _global.device.gl.enableVertexAttribArray(el.location); + _global.device.gl.vertexAttribPointer(el.location, input.elements, input.type, false, stride, input.offset); } break; } @@ -18917,9 +19429,9 @@ var Tw2VertexDeclaration = exports.Tw2VertexDeclaration = function () { if (input.customSetter) { input.customSetter(el); } else { - _Tw2Device.device.gl.enableVertexAttribArray(el.location); - _Tw2Device.device.gl.vertexAttribPointer(el.location, input.elements, input.type, false, stride, input.offset); - _Tw2Device.device.ext.vertexAttribDivisor(el.location, divisor); + _global.device.gl.enableVertexAttribArray(el.location); + _global.device.gl.vertexAttribPointer(el.location, input.elements, input.type, false, stride, input.offset); + _global.device.ext.vertexAttribDivisor(el.location, divisor); if (divisor) { resetData.push(el.location); @@ -18928,8 +19440,8 @@ var Tw2VertexDeclaration = exports.Tw2VertexDeclaration = function () { break; } else if (cmp > 0) { if (!divisor) { - _Tw2Device.device.gl.disableVertexAttribArray(el.location); - _Tw2Device.device.gl.vertexAttrib4f(el.location, 0, 0, 0, 0); + _global.device.gl.disableVertexAttribArray(el.location); + _global.device.gl.vertexAttrib4f(el.location, 0, 0, 0, 0); } break; } @@ -18937,8 +19449,8 @@ var Tw2VertexDeclaration = exports.Tw2VertexDeclaration = function () { index++; if (index >= this._elementsSorted.length) { if (!divisor) { - _Tw2Device.device.gl.disableVertexAttribArray(el.location); - _Tw2Device.device.gl.vertexAttrib4f(el.location, 0, 0, 0, 0); + _global.device.gl.disableVertexAttribArray(el.location); + _global.device.gl.vertexAttrib4f(el.location, 0, 0, 0, 0); } return resetData; } @@ -18957,7 +19469,7 @@ var Tw2VertexDeclaration = exports.Tw2VertexDeclaration = function () { value: function ResetInstanceDivisors(resetData) { if (resetData) { for (var i = 0; i < resetData.length; ++i) { - _Tw2Device.device.ext.vertexAttribDivisor(resetData[i], 0); + _global.device.ext.vertexAttribDivisor(resetData[i], 0); } } } @@ -18981,29 +19493,33 @@ var Tw2VertexDeclaration = exports.Tw2VertexDeclaration = function () { elements = void 0, offset = void 0; - if (Array.isArray(decl)) { + if (_global.util.isArray(decl)) { usage = decl[0]; usageIndex = decl[1]; - type = decl[2]; - elements = decl[3]; + elements = decl[2]; + type = decl[3]; offset = decl[4]; } else { usage = decl.usage; usageIndex = decl.usageIndex; - type = decl.type; elements = decl.elements; + type = decl.type; offset = decl.offset; } - if (typeof usage === 'string') { + if (_global.util.isString(usage)) { usage = Tw2VertexDeclaration.Type[usage.toUpperCase()]; } - if (typeof type === 'string') { - type = _Tw2Device.device.gl[type.toUpperCase()]; + if (_global.util.isNoU(type)) { + type = 'FLOAT'; } - if (offset === undefined) { + if (_global.util.isString(type)) { + type = _global.device.gl[type.toUpperCase()]; + } + + if (_global.util.isNoU(offset)) { offset = currentOffset; } @@ -19057,7 +19573,7 @@ Tw2VertexDeclaration.Type = { }; /***/ }), -/* 81 */ +/* 88 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global) {/* @@ -20261,10 +20777,10 @@ return { module.exports = WebGLDebugUtils; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(82))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(89))) /***/ }), -/* 82 */ +/* 89 */ /***/ (function(module, exports) { var g; @@ -20291,7 +20807,7 @@ module.exports = g; /***/ }), -/* 83 */ +/* 90 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -20349,7 +20865,7 @@ var Tw2ForwardingRenderBatch = exports.Tw2ForwardingRenderBatch = function (_Tw2 }(_Tw2RenderBatch2.Tw2RenderBatch); /***/ }), -/* 84 */ +/* 91 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -20403,7 +20919,7 @@ var Tw2GeometryLineBatch = exports.Tw2GeometryLineBatch = function (_Tw2Geometry }(_Tw2GeometryBatch2.Tw2GeometryBatch); /***/ }), -/* 85 */ +/* 92 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -20461,7 +20977,7 @@ var Tw2InstancedMeshBatch = exports.Tw2InstancedMeshBatch = function (_Tw2Geomet }(_Tw2GeometryBatch2.Tw2GeometryBatch); /***/ }), -/* 86 */ +/* 93 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -20471,7 +20987,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2CurveSet = __webpack_require__(87); +var _Tw2CurveSet = __webpack_require__(94); Object.keys(_Tw2CurveSet).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -20483,7 +20999,7 @@ Object.keys(_Tw2CurveSet).forEach(function (key) { }); }); -var _Tw2ValueBinding = __webpack_require__(88); +var _Tw2ValueBinding = __webpack_require__(95); Object.keys(_Tw2ValueBinding).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -20496,7 +21012,7 @@ Object.keys(_Tw2ValueBinding).forEach(function (key) { }); /***/ }), -/* 87 */ +/* 94 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -20509,7 +21025,7 @@ exports.Tw2CurveSet = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -20529,7 +21045,7 @@ var Tw2CurveSet = exports.Tw2CurveSet = function () { function Tw2CurveSet() { _classCallCheck(this, Tw2CurveSet); - this._id = _math.util.generateID(); + this._id = _global.util.generateID(); this.name = ''; this.curves = []; this.bindings = []; @@ -20629,7 +21145,7 @@ var Tw2CurveSet = exports.Tw2CurveSet = function () { }(); /***/ }), -/* 88 */ +/* 95 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -20644,9 +21160,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); -var _parameter = __webpack_require__(24); +var _parameter = __webpack_require__(45); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -20671,7 +21187,7 @@ var Tw2ValueBinding = exports.Tw2ValueBinding = function () { function Tw2ValueBinding() { _classCallCheck(this, Tw2ValueBinding); - this._id = _math.util.generateID(); + this._id = _global.util.generateID(); this.name = ''; this.sourceObject = null; this.sourceAttribute = ''; @@ -20682,7 +21198,7 @@ var Tw2ValueBinding = exports.Tw2ValueBinding = function () { this._destinationElement = null; this.destinationIsArray = null; this.scale = 1; - this.offset = _math.quat.create(); + this.offset = _global.quat.create(); this._copyFunc = null; } @@ -20778,8 +21294,8 @@ var Tw2ValueBinding = exports.Tw2ValueBinding = function () { return; } - this.sourceIsArray = _math.util.isArrayLike(this.sourceObject[this.sourceAttribute]); - this.destinationIsArray = _math.util.isArrayLike(this.destinationObject[this.destinationAttribute]); + this.sourceIsArray = _global.util.isArrayLike(this.sourceObject[this.sourceAttribute]); + this.destinationIsArray = _global.util.isArrayLike(this.destinationObject[this.destinationAttribute]); if (this.sourceIsArray === this.destinationIsArray && _typeof(this.sourceObject[this.sourceAttribute]) === _typeof(this.destinationObject[this.destinationAttribute])) { if (this.sourceIsArray) { @@ -20799,15 +21315,15 @@ var Tw2ValueBinding = exports.Tw2ValueBinding = function () { } else { this._copyFunc = Tw2ValueBinding.CopyValueToValue; } - } else if (this.sourceIsArray && srcSwizzled && typeof this.destinationObject[this.destinationAttribute] === 'number') { + } else if (this.sourceIsArray && srcSwizzled && _global.util.isNumber(this.destinationObject[this.destinationAttribute])) { this._copyFunc = Tw2ValueBinding.CopyElementToValue; - } else if (this.destinationIsArray && typeof this.sourceObject[this.sourceAttribute] === 'number') { + } else if (this.destinationIsArray && _global.util.isNumber(this.sourceObject[this.sourceAttribute])) { if (destSwizzled) { this._copyFunc = Tw2ValueBinding.CopyValueToElement; } else { this._copyFunc = Tw2ValueBinding.ReplicateValue; } - } else if (typeof this.sourceObject[this.sourceAttribute] === 'number' && typeof this.destinationObject[this.destinationAttribute] === 'boolean') { + } else if (_global.util.isNumber(this.sourceObject[this.sourceAttribute]) && _global.util.isBoolean(this.destinationObject[this.destinationAttribute])) { this._copyFunc = Tw2ValueBinding.CopyFloatToBoolean; } } @@ -20934,7 +21450,7 @@ var Tw2ValueBinding = exports.Tw2ValueBinding = function () { }(); /***/ }), -/* 89 */ +/* 96 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -20947,9 +21463,9 @@ exports.Tw2FloatParameter = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2Parameter2 = __webpack_require__(7); +var _Tw2Parameter2 = __webpack_require__(4); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -20979,7 +21495,7 @@ var Tw2FloatParameter = exports.Tw2FloatParameter = function (_Tw2Parameter) { var _this = _possibleConstructorReturn(this, (Tw2FloatParameter.__proto__ || Object.getPrototypeOf(Tw2FloatParameter)).call(this, name)); - _this.value = _math.util.isArrayLike(value) ? value[0] : value; + _this.value = _global.util.isArrayLike(value) ? value[0] : value; _this.constantBuffer = null; _this.offset = null; return _this; @@ -21048,25 +21564,31 @@ var Tw2FloatParameter = exports.Tw2FloatParameter = function (_Tw2Parameter) { } /** - * Checks if a value is a valid value - * @param {number} value + * Checks if a value is a valid parameter value + * @param {number} a * @returns {boolean} */ }], [{ - key: 'is', - value: function is(value) { - return typeof value === 'number'; + key: 'isValue', + value: function isValue(a) { + return _global.util.isNumber(a); } }]); return Tw2FloatParameter; }(_Tw2Parameter2.Tw2Parameter); -Tw2FloatParameter.size = 1; +/** + * Float parameter's constant buffer size + * @type {number} + */ + + +Tw2FloatParameter.constantBufferSize = 1; /***/ }), -/* 90 */ +/* 97 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -21079,9 +21601,9 @@ exports.Tw2MatrixParameter = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); -var _Tw2Parameter = __webpack_require__(7); +var _Tw2Parameter = __webpack_require__(4); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -21101,7 +21623,7 @@ var Tw2MatrixParameter = exports.Tw2MatrixParameter = function (_Tw2VectorParame function Tw2MatrixParameter() { var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _math.mat4.create(); + var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _global.mat4.create(); _classCallCheck(this, Tw2MatrixParameter); @@ -21123,7 +21645,7 @@ var Tw2MatrixParameter = exports.Tw2MatrixParameter = function (_Tw2VectorParame if ('value' in translation) translation = translation['value']; if ('value' in scaling) scaling = scaling['value']; - _math.mat4.fromRotationTranslationScale(this.value, rotation, translation, scaling); + _global.mat4.fromRotationTranslationScale(this.value, rotation, translation, scaling); this.OnValueChanged(); } @@ -21137,9 +21659,9 @@ var Tw2MatrixParameter = exports.Tw2MatrixParameter = function (_Tw2VectorParame }, { key: 'Decompose', value: function Decompose(rotation, translation, scaling) { - _math.mat4.getRotation('value' in rotation ? rotation.value : rotation, this.value); - _math.mat4.getTranslation('value' in translation ? translation.value : translation, this.value); - _math.mat4.getScaling('value' in scaling ? scaling.value : scaling, this.value); + _global.mat4.getRotation('value' in rotation ? rotation.value : rotation, this.value); + _global.mat4.getTranslation('value' in translation ? translation.value : translation, this.value); + _global.mat4.getScaling('value' in scaling ? scaling.value : scaling, this.value); if ('OnValueChanged' in rotation) rotation.OnValueChanged(); if ('OnValueChanged' in translation) translation.OnValueChanged(); @@ -21213,7 +21735,7 @@ var Tw2MatrixParameter = exports.Tw2MatrixParameter = function (_Tw2VectorParame Tw2MatrixParameter.constantBufferSize = 16; /***/ }), -/* 91 */ +/* 98 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -21228,9 +21750,9 @@ var _createClass = function () { function defineProperties(target, props) { for var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); -var _Tw2Parameter2 = __webpack_require__(7); +var _Tw2Parameter2 = __webpack_require__(4); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -21260,12 +21782,12 @@ var Tw2TransformParameter = exports.Tw2TransformParameter = function (_Tw2Parame var _this = _possibleConstructorReturn(this, (Tw2TransformParameter.__proto__ || Object.getPrototypeOf(Tw2TransformParameter)).call(this, name)); - _this.scaling = _math.vec3.fromValues(1, 1, 1); - _this.rotationCenter = _math.vec3.create(); - _this.rotation = _math.quat.create(); - _this.translation = _math.vec3.create(); - _this.transform = _math.mat4.create(); - _this.worldTransform = _math.mat4.create(); + _this.scaling = _global.vec3.fromValues(1, 1, 1); + _this.rotationCenter = _global.vec3.create(); + _this.rotation = _global.quat.create(); + _this.translation = _global.vec3.create(); + _this.transform = _global.mat4.create(); + _this.worldTransform = _global.mat4.create(); _this.constantBuffer = null; _this.offset = null; return _this; @@ -21303,8 +21825,8 @@ var Tw2TransformParameter = exports.Tw2TransformParameter = function (_Tw2Parame }, { key: 'OnValueChanged', value: function OnValueChanged(controller, properties) { - _math.mat4.fromRotationTranslationScaleOrigin(this.transform, this.rotation, this.translation, this.scaling, this.rotationCenter); - _math.mat4.transpose(this.worldTransform, this.transform); + _global.mat4.fromRotationTranslationScaleOrigin(this.transform, this.rotation, this.translation, this.scaling, this.rotationCenter); + _global.mat4.transpose(this.worldTransform, this.transform); _get(Tw2TransformParameter.prototype.__proto__ || Object.getPrototypeOf(Tw2TransformParameter.prototype), 'OnValueChanged', this).call(this, controller, properties); } @@ -21355,10 +21877,10 @@ var Tw2TransformParameter = exports.Tw2TransformParameter = function (_Tw2Parame key: 'Copy', value: function Copy(parameter, includeName) { if (includeName) this.name = parameter.name; - _math.quat.copy(this.rotation, parameter.rotation); - _math.vec3.copy(this.translation, parameter.translation); - _math.vec3.copy(this.scaling, parameter.scaling); - _math.vec3.copy(this.rotationCenter, parameter.rotationCenter); + _global.quat.copy(this.rotation, parameter.rotation); + _global.vec3.copy(this.translation, parameter.translation); + _global.vec3.copy(this.scaling, parameter.scaling); + _global.vec3.copy(this.rotationCenter, parameter.rotationCenter); this.OnValueChanged(); } }]); @@ -21375,7 +21897,7 @@ var Tw2TransformParameter = exports.Tw2TransformParameter = function (_Tw2Parame Tw2TransformParameter.constantBufferSize = 16; /***/ }), -/* 92 */ +/* 99 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -21388,9 +21910,9 @@ exports.Tw2VariableParameter = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2Store = __webpack_require__(16); +var _global = __webpack_require__(0); -var _Tw2Parameter2 = __webpack_require__(7); +var _Tw2Parameter2 = __webpack_require__(4); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -21437,7 +21959,7 @@ var Tw2VariableParameter = exports.Tw2VariableParameter = function (_Tw2Paramete * @returns {?*} */ value: function GetValue(serialize) { - return _Tw2Store.store.GetVariableValue(this.variableName, serialize); + return _global.store.GetVariableValue(this.variableName, serialize); } /** @@ -21481,7 +22003,7 @@ var Tw2VariableParameter = exports.Tw2VariableParameter = function (_Tw2Paramete }, { key: 'variable', get: function get() { - return _Tw2Store.store.GetVariable(this.variableName); + return _global.store.GetVariable(this.variableName); } /** @@ -21500,7 +22022,7 @@ var Tw2VariableParameter = exports.Tw2VariableParameter = function (_Tw2Paramete }(_Tw2Parameter2.Tw2Parameter); /***/ }), -/* 93 */ +/* 100 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -21513,9 +22035,9 @@ exports.Tw2Vector2Parameter = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); -var _Tw2Parameter = __webpack_require__(7); +var _Tw2Parameter = __webpack_require__(4); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -21535,7 +22057,7 @@ var Tw2Vector2Parameter = exports.Tw2Vector2Parameter = function (_Tw2VectorPara function Tw2Vector2Parameter() { var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _math.vec2.fromValues(1, 1); + var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _global.vec2.fromValues(1, 1); _classCallCheck(this, Tw2Vector2Parameter); @@ -21596,7 +22118,7 @@ var Tw2Vector2Parameter = exports.Tw2Vector2Parameter = function (_Tw2VectorPara Tw2Vector2Parameter.constantBufferSize = 2; /***/ }), -/* 94 */ +/* 101 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -21609,9 +22131,9 @@ exports.Tw2Vector3Parameter = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); -var _Tw2Parameter = __webpack_require__(7); +var _Tw2Parameter = __webpack_require__(4); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -21631,7 +22153,7 @@ var Tw2Vector3Parameter = exports.Tw2Vector3Parameter = function (_Tw2VectorPara function Tw2Vector3Parameter() { var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _math.vec3.fromValues(1, 1, 1); + var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _global.vec3.fromValues(1, 1, 1); _classCallCheck(this, Tw2Vector3Parameter); @@ -21712,7 +22234,7 @@ var Tw2Vector3Parameter = exports.Tw2Vector3Parameter = function (_Tw2VectorPara Tw2Vector3Parameter.constantBufferSize = 3; /***/ }), -/* 95 */ +/* 102 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -21725,9 +22247,9 @@ exports.Tw2Vector4Parameter = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); -var _Tw2Parameter = __webpack_require__(7); +var _Tw2Parameter = __webpack_require__(4); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -21747,7 +22269,7 @@ var Tw2Vector4Parameter = exports.Tw2Vector4Parameter = function (_Tw2VectorPara function Tw2Vector4Parameter() { var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _math.vec4.fromValues(1, 1, 1, 1); + var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _global.vec4.fromValues(1, 1, 1, 1); _classCallCheck(this, Tw2Vector4Parameter); @@ -21848,7 +22370,7 @@ var Tw2Vector4Parameter = exports.Tw2Vector4Parameter = function (_Tw2VectorPara Tw2Vector4Parameter.constantBufferSize = 4; /***/ }), -/* 96 */ +/* 103 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -21858,7 +22380,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2BasicPerObjectData = __webpack_require__(97); +var _Tw2BasicPerObjectData = __webpack_require__(104); Object.keys(_Tw2BasicPerObjectData).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -21870,7 +22392,7 @@ Object.keys(_Tw2BasicPerObjectData).forEach(function (key) { }); }); -var _Tw2PerObjectData = __webpack_require__(44); +var _Tw2PerObjectData = __webpack_require__(46); Object.keys(_Tw2PerObjectData).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -21882,557 +22404,20 @@ Object.keys(_Tw2PerObjectData).forEach(function (key) { }); }); -var _Tw2RawData = __webpack_require__(25); - -Object.keys(_Tw2RawData).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2RawData[key]; - } - }); -}); - -/***/ }), -/* 97 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.EveBasicPerObjectData = exports.Tw2BasicPerObjectData = undefined; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - -var _Tw2Device = __webpack_require__(2); - -var _Tw2PerObjectData2 = __webpack_require__(44); - -var _Tw2RawData = __webpack_require__(25); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * Tw2BasicPerObjectData - * - * @param {RawDataObject} [rawDataObject] - An optional object containing raw data declarations - * @parameter {?Tw2RawData} perObjectFFEData - Fixed Function Emulation data - * @class - */ -var Tw2BasicPerObjectData = exports.Tw2BasicPerObjectData = function (_Tw2PerObjectData) { - _inherits(Tw2BasicPerObjectData, _Tw2PerObjectData); - - function Tw2BasicPerObjectData(rawDataObject) { - _classCallCheck(this, Tw2BasicPerObjectData); - - var _this = _possibleConstructorReturn(this, (Tw2BasicPerObjectData.__proto__ || Object.getPrototypeOf(Tw2BasicPerObjectData)).call(this)); - - _this.perObjectFFEData = null; - - if (rawDataObject) _this.DeclareFromObject(rawDataObject); - return _this; - } - - /** - * Sets per object data to the device - * @param constantBufferHandles - */ - - - _createClass(Tw2BasicPerObjectData, [{ - key: 'SetPerObjectDataToDevice', - value: function SetPerObjectDataToDevice(constantBufferHandles) { - _get(Tw2BasicPerObjectData.prototype.__proto__ || Object.getPrototypeOf(Tw2BasicPerObjectData.prototype), 'SetPerObjectDataToDevice', this).call(this, constantBufferHandles); - - if (this.perObjectFFEData && constantBufferHandles[5]) { - _Tw2Device.device.gl.uniform4fv(constantBufferHandles[5], this.perObjectFFEData.data); - } - } - - /** - * Defines and creates raw data from an object - * @param {RawDataObject} rawDataObject - */ - - }, { - key: 'DeclareFromObject', - value: function DeclareFromObject() { - var rawDataObject = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - _get(Tw2BasicPerObjectData.prototype.__proto__ || Object.getPrototypeOf(Tw2BasicPerObjectData.prototype), 'DeclareFromObject', this).call(this, rawDataObject); - - if (rawDataObject.FFEData) { - this.perObjectFFEData = new _Tw2RawData.Tw2RawData(rawDataObject.FFEData); - } - } - }]); - - return Tw2BasicPerObjectData; -}(_Tw2PerObjectData2.Tw2PerObjectData); - -exports.EveBasicPerObjectData = Tw2BasicPerObjectData; - -/***/ }), -/* 98 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _Tw2RuntimeInstanceData = __webpack_require__(99); - -Object.keys(_Tw2RuntimeInstanceData).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2RuntimeInstanceData[key]; - } - }); -}); - -var _Tw2VariableStore = __webpack_require__(117); - -Object.keys(_Tw2VariableStore).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2VariableStore[key]; - } - }); -}); - -/***/ }), -/* 99 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2RuntimeInstanceData = Tw2RuntimeInstanceData; - -var _Tw2Device = __webpack_require__(2); - -var _vertex = __webpack_require__(9); - -var _particle = __webpack_require__(45); - -/** - * Tw2RuntimeInstanceData - * @property {string} name - * @property {number} count - * @constructor - */ -function Tw2RuntimeInstanceData() { - this.name = ''; - this.count = 0; - - var declaration = null; - var vb = null; - var vertexStride = 0; - var count = 0; - var data = null; - var dataDirty = true; - - /** - * GetMaxInstanceCount - * @returns {number} - * @method - */ - this.GetMaxInstanceCount = function () { - return data ? data.length : 1; - }; - - /** - * SetElementLayout - * @param decl - * @method - */ - this.SetElementLayout = function (decl) { - if (vb) { - _Tw2Device.device.gl.deleteBuffer(vb); - vb = null; - } - - vertexStride = 0; - declaration = new _vertex.Tw2VertexDeclaration(); - - for (var i = 0; i < decl.length; ++i) { - var element = new _particle.Tw2ParticleElementDeclaration(); - element.elementType = decl[i][0]; - element.dimension = decl[i][2]; - element.usageIndex = decl[i][1]; - - var d = element.GetDeclaration(); - d.offset = vertexStride * 4; - declaration.elements.push(d); - vertexStride += element.dimension; - } - - declaration.RebuildHash(); - }; - - /** - * SetData - * @param data_ - * @constructor - */ - this.SetData = function (data_) { - if (!declaration) { - return; - } - data = data_; - count = data.length; - dataDirty = true; - this.UpdateData(); - }; - - /** - * SetItemElement - * @param index - * @param elementIndex - * @param value - * @constructor - */ - this.SetItemElement = function (index, elementIndex, value) { - if (declaration.elements[elementIndex].elements > 1) { - for (var i = 0; i < declaration.elements[elementIndex].elements; ++i) { - data[index][elementIndex][i] = value[i]; - } - } else { - data[index][elementIndex] = value; - } - - dataDirty = true; - }; - - /** - * SetItemElementRef - * @param index - * @param elementIndex - * @param value - * @constructor - */ - this.SetItemElementRef = function (index, elementIndex, value) { - data[index][elementIndex] = value; - dataDirty = true; - }; - - /** - * GetItemElement - * @param index - * @param elementIndex - * @returns {*} - * @method - */ - this.GetItemElement = function (index, elementIndex) { - return data[index][elementIndex]; - }; - - /** - * UpdateData - * @method - */ - this.UpdateData = function () { - if (!dataDirty || !declaration) { - return; - } - - var vbData = new Float32Array(data.length * vertexStride); - var offset = 0; - var i, j, k; - - for (i = 0; i < data.length; ++i) { - for (j = 0; j < declaration.elements.length; ++j) { - if (declaration.elements[j].elements === 1) { - vbData[offset++] = data[i][j]; - } else { - for (k = 0; k < declaration.elements[j].elements; ++k) { - vbData[offset++] = data[i][j][k]; - } - } - } - } - - if (!vb) { - vb = _Tw2Device.device.gl.createBuffer(); - } - - _Tw2Device.device.gl.bindBuffer(_Tw2Device.device.gl.ARRAY_BUFFER, vb); - _Tw2Device.device.gl.bufferData(_Tw2Device.device.gl.ARRAY_BUFFER, vbData, _Tw2Device.device.gl.STATIC_DRAW); - _Tw2Device.device.gl.bindBuffer(_Tw2Device.device.gl.ARRAY_BUFFER, null); - dataDirty = false; - }; - - /** - * Unloads the webgl buffer - * @method - */ - this.Unload = function () { - if (vb) { - _Tw2Device.device.gl.deleteBuffer(vb); - vb = null; - } - }; - - /** - * GetInstanceBuffer - * @returns {WebglArrayBuffer} - * @method - */ - this.GetInstanceBuffer = function () { - return vb; - }; - - /** - * GetInstanceDeclaration - * @returns {Tw2VertexDeclaration} - * @method - */ - this.GetInstanceDeclaration = function () { - return declaration; - }; - - /** - * GetInstanceStride - * @returns {number} - * @method - */ - this.GetInstanceStride = function () { - return vertexStride * 4; - }; - - /** - * GetInstanceCount - * @returns {number} - * @method - */ - this.GetInstanceCount = function () { - return count; - }; -} - -/***/ }), -/* 100 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _Tw2StaticEmitter = __webpack_require__(101); - -Object.keys(_Tw2StaticEmitter).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2StaticEmitter[key]; - } - }); -}); - -var _Tw2DynamicEmitter = __webpack_require__(102); - -Object.keys(_Tw2DynamicEmitter).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2DynamicEmitter[key]; - } - }); -}); - -var _Tw2GpuUniqueEmitter = __webpack_require__(103); - -Object.keys(_Tw2GpuUniqueEmitter).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2GpuUniqueEmitter[key]; - } - }); -}); - -/***/ }), -/* 101 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2StaticEmitter = undefined; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _core = __webpack_require__(1); - -var _Tw2ParticleEmitter2 = __webpack_require__(26); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * Tw2StaticEmitter - * - * @property {string} name - * @property {string} geometryResourcePath - * @property {Tw2GeometryRes} geometryResource - * @property {Number} geometryIndex - * @property {Boolean} _spawned - * @inherits Tw2ParticleEmitter - * @class - */ -var Tw2StaticEmitter = exports.Tw2StaticEmitter = function (_Tw2ParticleEmitter) { - _inherits(Tw2StaticEmitter, _Tw2ParticleEmitter); - - function Tw2StaticEmitter() { - _classCallCheck(this, Tw2StaticEmitter); - - var _this = _possibleConstructorReturn(this, (Tw2StaticEmitter.__proto__ || Object.getPrototypeOf(Tw2StaticEmitter)).call(this)); - - _this.geometryResourcePath = ''; - _this.geometryResource = null; - _this.geometryIndex = 0; - _this._spawned = false; - return _this; - } - - /** - * Initializes the particle emitter - */ - - - _createClass(Tw2StaticEmitter, [{ - key: 'Initialize', - value: function Initialize() { - if (this.geometryResourcePath !== '') { - this.geometryResource = _core.resMan.GetResource(this.geometryResourcePath); - this.geometryResource.systemMirror = true; - this.geometryResource.RegisterNotification(this); - } - this._spawned = false; - } - - /** - * Rebuilds cached data - */ - - }, { - key: 'RebuildCachedData', - value: function RebuildCachedData() { - if (this.geometryResource && this.geometryResource.meshes.length) { - if (!this.geometryResource.meshes[0].bufferData) { - this.geometryResource.systemMirror = true; - this.geometryResource.Reload(); - } - } - } - - /** - * Per frame update - */ - - }, { - key: 'Update', - value: function Update() { - if (!this._spawned && this.particleSystem && this.geometryResource && this.geometryResource.IsGood() && this.geometryResource.meshes.length > this.geometryIndex && this.geometryResource.meshes[this.geometryIndex].bufferData) { - this._spawned = true; - - var mesh = this.geometryResource.meshes[this.geometryIndex], - elts = this.particleSystem.elements, - inputs = new Array(elts.length); - - for (var i = 0; i < elts.length; ++i) { - var d = elts[i].GetDeclaration(), - input = mesh.declaration.FindUsage(d.usage, d.usageIndex - 8); - - if (input === null) { - _core.logger.log('res.error', { - log: 'error', - src: ['Tw2StaticEmitter', 'Update'], - msg: 'Input geometry mesh lacks element required by particle system', - path: this.geometryResource.path, - type: 'geometry.elements', - data: { - elementUsage: d.usage, - elementUsageIndex: d.usageIndex - } - }); - return; - } - - if (input.elements < d.elements) { - _core.logger.log('res.error', { - log: 'error', - src: ['Tw2StaticEmitter', 'Update'], - msg: 'Input geometry mesh elements do not have the required number of components', - path: this.geometryResource.path, - type: 'geometry.elementcomponents', - data: { - inputCount: input.elements, - elementCount: d.elements, - elementUsage: d.usage, - elementUsageIndex: d.usageIndex - } - }); - return; - } - - inputs[i] = input.offset / 4; - } - - var vertexCount = mesh.bufferData.length / mesh.declaration.stride * 4; - for (var _i = 0; _i < vertexCount; ++_i) { - var index = this.particleSystem.BeginSpawnParticle(); - if (index === null) break; - - for (var j = 0; j < this.particleSystem._elements.length; ++j) { - var e = this.particleSystem._elements[j]; - for (var k = 0; k < e.dimension; ++k) { - e.buffer[e.instanceStride * index + e.startOffset + k] = mesh.bufferData[inputs[j] + k + _i * mesh.declaration.stride / 4]; - } - } - this.particleSystem.EndSpawnParticle(); - } - } - } - }]); +var _Tw2RawData = __webpack_require__(24); - return Tw2StaticEmitter; -}(_Tw2ParticleEmitter2.Tw2ParticleEmitter); +Object.keys(_Tw2RawData).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2RawData[key]; + } + }); +}); /***/ }), -/* 102 */ +/* 104 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22441,11 +22426,17 @@ var Tw2StaticEmitter = exports.Tw2StaticEmitter = function (_Tw2ParticleEmitter) Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2DynamicEmitter = undefined; +exports.EveBasicPerObjectData = exports.Tw2BasicPerObjectData = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2ParticleEmitter2 = __webpack_require__(26); +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + +var _global = __webpack_require__(0); + +var _Tw2PerObjectData2 = __webpack_require__(46); + +var _Tw2RawData = __webpack_require__(24); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -22454,104 +22445,67 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2DynamicEmitter + * Tw2BasicPerObjectData * - * @property {string} name - * @property {number} rate - * @property {boolean} isValid - * @property {number} _accumulatedRate - * @property {Array}} generators - * @inherits Tw2ParticleEmitter + * @param {RawDataObject} [rawDataObject] - An optional object containing raw data declarations + * @parameter {?Tw2RawData} perObjectFFEData - Fixed Function Emulation data * @class */ -var Tw2DynamicEmitter = exports.Tw2DynamicEmitter = function (_Tw2ParticleEmitter) { - _inherits(Tw2DynamicEmitter, _Tw2ParticleEmitter); +var Tw2BasicPerObjectData = exports.Tw2BasicPerObjectData = function (_Tw2PerObjectData) { + _inherits(Tw2BasicPerObjectData, _Tw2PerObjectData); - function Tw2DynamicEmitter() { - _classCallCheck(this, Tw2DynamicEmitter); + function Tw2BasicPerObjectData(rawDataObject) { + _classCallCheck(this, Tw2BasicPerObjectData); - var _this = _possibleConstructorReturn(this, (Tw2DynamicEmitter.__proto__ || Object.getPrototypeOf(Tw2DynamicEmitter)).call(this)); + var _this = _possibleConstructorReturn(this, (Tw2BasicPerObjectData.__proto__ || Object.getPrototypeOf(Tw2BasicPerObjectData)).call(this)); - _this.rate = 0; - _this.isValid = false; - _this._accumulatedRate = 0; - _this.generators = []; + _this.perObjectFFEData = null; + + if (rawDataObject) _this.DeclareFromObject(rawDataObject); return _this; } /** - * Initializes the particle emitter + * Sets per object data to the device + * @param constantBufferHandles */ - _createClass(Tw2DynamicEmitter, [{ - key: 'Initialize', - value: function Initialize() { - this.Rebind(); - } - - /** - * Per frame update - * @param {number} dt - delta time - */ - - }, { - key: 'Update', - value: function Update(dt) { - this.SpawnParticles(null, null, Math.min(dt, 0.1)); - } - - /** - * Rebinds the emitter's generators to it's particle system - */ - - }, { - key: 'Rebind', - value: function Rebind() { - this.isValid = false; - if (!this.particleSystem) return; + _createClass(Tw2BasicPerObjectData, [{ + key: 'SetPerObjectDataToDevice', + value: function SetPerObjectDataToDevice(constantBufferHandles) { + _get(Tw2BasicPerObjectData.prototype.__proto__ || Object.getPrototypeOf(Tw2BasicPerObjectData.prototype), 'SetPerObjectDataToDevice', this).call(this, constantBufferHandles); - for (var i = 0; i < this.generators.length; ++i) { - if (!this.generators[i].Bind(this.particleSystem)) return; + if (this.perObjectFFEData && constantBufferHandles[5]) { + _global.device.gl.uniform4fv(constantBufferHandles[5], this.perObjectFFEData.data); } - - this.isValid = true; } /** - * Spawn particles - * @param position - * @param velocity - * @param rateModifier + * Defines and creates raw data from an object + * @param {RawDataObject} rawDataObject */ }, { - key: 'SpawnParticles', - value: function SpawnParticles(position, velocity, rateModifier) { - if (!this.isValid) return; - - this._accumulatedRate += this.rate * rateModifier; - var count = Math.floor(this._accumulatedRate); - this._accumulatedRate -= count; - - for (var i = 0; i < count; ++i) { - var index = this.particleSystem.BeginSpawnParticle(); - if (index === null) break; + key: 'DeclareFromObject', + value: function DeclareFromObject() { + var rawDataObject = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - for (var j = 0; j < this.generators.length; ++j) { - this.generators[j].Generate(position, velocity, index); - } + _get(Tw2BasicPerObjectData.prototype.__proto__ || Object.getPrototypeOf(Tw2BasicPerObjectData.prototype), 'DeclareFromObject', this).call(this, rawDataObject); - this.particleSystem.EndSpawnParticle(); + if (rawDataObject.FFEData) { + this.perObjectFFEData = new _Tw2RawData.Tw2RawData(rawDataObject.FFEData); } } }]); - return Tw2DynamicEmitter; -}(_Tw2ParticleEmitter2.Tw2ParticleEmitter); + return Tw2BasicPerObjectData; +}(_Tw2PerObjectData2.Tw2PerObjectData); + +exports.EveBasicPerObjectData = Tw2BasicPerObjectData; /***/ }), -/* 103 */ +/* 105 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22560,175 +22514,61 @@ var Tw2DynamicEmitter = exports.Tw2DynamicEmitter = function (_Tw2ParticleEmitte Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tr2GpuUniqueEmitter = exports.Tw2GpuUniqueEmitter = undefined; - -var _math = __webpack_require__(0); +exports.Tw2BlendShapeData = undefined; -var _Tw2ParticleEmitter2 = __webpack_require__(26); +var _vertex = __webpack_require__(9); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - /** - * Tr2GpuUniqueEmitter - not implemented yet + * Tw2BlendShapeData * - * @property {number} angle - * @property {number} innerAngle - * @property {number} drag - * @property {number} rate - * @property {number} radius - * @property {number} gravity - * @property {number} maxSpeed - * @property {number} minSpeed - * @property {number} minLifeTime - * @property {number} maxLifeTime - * @property {number} sizeVariance - * @property {vec3} attractorPosition - * @property {number} attractorStrength - * @property {number} textureIndex - * @property {number} turbulenceAmplitude - * @property {number} turbulenceFrequency - * @property {vec3} sizes - * @property {vec4} color0 - * @property {vec4} color1 - * @property {vec4} color2 - * @property {vec4} color3 - * @class + * @property {String} name + * @property {Tw2VertexDeclaration} declaration + * @property {Array} buffers + * @property indexes + * @property weightProxy */ -var Tw2GpuUniqueEmitter = exports.Tw2GpuUniqueEmitter = function (_Tw2ParticleEmitter) { - _inherits(Tw2GpuUniqueEmitter, _Tw2ParticleEmitter); - - function Tw2GpuUniqueEmitter() { - _classCallCheck(this, Tw2GpuUniqueEmitter); - - var _this = _possibleConstructorReturn(this, (Tw2GpuUniqueEmitter.__proto__ || Object.getPrototypeOf(Tw2GpuUniqueEmitter)).call(this)); - - _this.angle = 0; - _this.innerAngle = 0; - _this.drag = 0; - _this.rate = 0; - _this.radius = 0; - _this.gravity = 0; - _this.maxSpeed = 0; - _this.minSpeed = 0; - _this.minLifeTime = 0; - _this.maxLifeTime = 0; - _this.sizeVariance = 0; - _this.attractorPosition = _math.vec3.create(); - _this.attractorStrength = 0; - _this.turbulenceAmplitude = 0; - _this.turbulenceFrequency = 0; - _this.textureIndex = 0; - _this.sizes = _math.vec3.create(); - _this.position = _math.vec3.create(); - _this.color0 = _math.vec4.create(); - _this.color1 = _math.vec4.create(); - _this.color2 = _math.vec4.create(); - _this.color3 = _math.vec4.create(); - - //this.maxDisplacement=null; - //this.emissionDensity=null; - //this.velocityStretchRotation=null; - //this.inheritVelocity=null; - return _this; - } - - return Tw2GpuUniqueEmitter; -}(_Tw2ParticleEmitter2.Tw2ParticleEmitter); - -// Temporary alias - +var Tw2BlendShapeData = exports.Tw2BlendShapeData = function Tw2BlendShapeData() { + _classCallCheck(this, Tw2BlendShapeData); -exports.Tr2GpuUniqueEmitter = Tw2GpuUniqueEmitter; + this.name = ''; + this.declaration = new _vertex.Tw2VertexDeclaration(); + this.buffers = []; + this.indexes = null; + this.weightProxy = null; +}; /***/ }), -/* 104 */ +/* 106 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _Tw2ParticleAttractorForce = __webpack_require__(105); - -Object.keys(_Tw2ParticleAttractorForce).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2ParticleAttractorForce[key]; - } - }); -}); - -var _Tw2ParticleDirectForce = __webpack_require__(106); - -Object.keys(_Tw2ParticleDirectForce).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2ParticleDirectForce[key]; - } - }); -}); - -var _Tw2ParticleDragForce = __webpack_require__(107); - -Object.keys(_Tw2ParticleDragForce).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2ParticleDragForce[key]; - } - }); -}); - -var _Tw2ParticleFluidDragForce = __webpack_require__(108); - -Object.keys(_Tw2ParticleFluidDragForce).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2ParticleFluidDragForce[key]; - } - }); + value: true }); -var _Tw2ParticleSpring = __webpack_require__(109); - -Object.keys(_Tw2ParticleSpring).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2ParticleSpring[key]; - } - }); -}); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var _Tw2ParticleTurbulenceForce = __webpack_require__(110); +/** + * Tw2GeometryAnimation + * + * @property {string} name + * @property {number} duration + * @property {Array.} trackGroups + */ +var Tw2GeometryAnimation = exports.Tw2GeometryAnimation = function Tw2GeometryAnimation() { + _classCallCheck(this, Tw2GeometryAnimation); -Object.keys(_Tw2ParticleTurbulenceForce).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2ParticleTurbulenceForce[key]; - } - }); -}); + this.name = ''; + this.duration = 0; + this.trackGroups = []; +}; /***/ }), -/* 105 */ +/* 107 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22737,70 +22577,74 @@ Object.keys(_Tw2ParticleTurbulenceForce).forEach(function (key) { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2ParticleAttractorForce = undefined; +exports.Tw2GeometryBone = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); - -var _Tw2ParticleForce2 = __webpack_require__(13); +var _global = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - /** - * Tw2ParticleAttractorForce + * Tw2GeometryBone * - * @property {number} magnitude + * @property {string} name + * @property {number} parentIndex * @property {vec3} position - * @property {vec3} _tempVec - * @inherits Tw2ParticleForce - * @class + * @property {quat} orientation + * @property {mat3} scaleShear + * @property {mat4} localTransform + * @property {mat4} worldTransform + * @property {mat4} worldTransformInv */ -var Tw2ParticleAttractorForce = exports.Tw2ParticleAttractorForce = function (_Tw2ParticleForce) { - _inherits(Tw2ParticleAttractorForce, _Tw2ParticleForce); - - function Tw2ParticleAttractorForce() { - _classCallCheck(this, Tw2ParticleAttractorForce); - - var _this = _possibleConstructorReturn(this, (Tw2ParticleAttractorForce.__proto__ || Object.getPrototypeOf(Tw2ParticleAttractorForce)).call(this)); +var Tw2GeometryBone = exports.Tw2GeometryBone = function () { + function Tw2GeometryBone() { + _classCallCheck(this, Tw2GeometryBone); - _this.magnitude = 0; - _this.position = _math.vec3.create(); - return _this; + this.name = ''; + this.parentIndex = -1; + this.position = _global.vec3.create(); + this.orientation = _global.quat.create(); + this.scaleShear = _global.mat3.create(); + this.localTransform = _global.mat4.create(); + this.worldTransform = _global.mat4.create(); + this.worldTransformInv = _global.mat4.create(); } /** - * ApplyForce - * @param {Tw2ParticleElement} position - * @param {Tw2ParticleElement} velocity - * @param {Tw2ParticleElement} force + * Updates the Bone's transform + * @returns {mat4} */ - _createClass(Tw2ParticleAttractorForce, [{ - key: 'ApplyForce', - value: function ApplyForce(position, velocity, force) { - var vec3_0 = _Tw2ParticleForce2.Tw2ParticleForce.global.vec3_0; - - vec3_0[0] = this.position[0] - position.buffer[position.offset]; - vec3_0[1] = this.position[1] - position.buffer[position.offset + 1]; - vec3_0[2] = this.position[2] - position.buffer[position.offset + 2]; - - _math.vec3.normalize(vec3_0, vec3_0); - _math.vec3.scale(vec3_0, vec3_0, this.magnitude); - _math.vec3.add(force, force, vec3_0); + _createClass(Tw2GeometryBone, [{ + key: 'UpdateTransform', + value: function UpdateTransform() { + _global.mat4.fromMat3(this.localTransform, this.scaleShear); + _global.quat.normalize(this.orientation, this.orientation); + var rm = _global.mat4.fromQuat(Tw2GeometryBone.global.mat4_0, this.orientation); + _global.mat4.multiply(this.localTransform, this.localTransform, rm); + this.localTransform[12] = this.position[0]; + this.localTransform[13] = this.position[1]; + this.localTransform[14] = this.position[2]; + return this.localTransform; } }]); - return Tw2ParticleAttractorForce; -}(_Tw2ParticleForce2.Tw2ParticleForce); + return Tw2GeometryBone; +}(); + +/** + * Class global variables and scratch + */ + + +Tw2GeometryBone.global = { + mat4_0: _global.mat4.create() +}; /***/ }), -/* 106 */ +/* 108 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22809,59 +22653,85 @@ var Tw2ParticleAttractorForce = exports.Tw2ParticleAttractorForce = function (_T Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2ParticleDirectForce = undefined; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _math = __webpack_require__(0); - -var _Tw2ParticleForce2 = __webpack_require__(13); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - /** - * Tw2ParticleDirectForce + * Tw2GeometryCurve * - * @property {vec3} force - * @inherits Tw2ParticleForce - * @class + * @property {number} dimension + * @property {number} degree + * @property {Float32Array} knots + * @property {Float32Array} controls */ -var Tw2ParticleDirectForce = exports.Tw2ParticleDirectForce = function (_Tw2ParticleForce) { - _inherits(Tw2ParticleDirectForce, _Tw2ParticleForce); +var Tw2GeometryCurve = exports.Tw2GeometryCurve = function Tw2GeometryCurve() { + _classCallCheck(this, Tw2GeometryCurve); - function Tw2ParticleDirectForce() { - _classCallCheck(this, Tw2ParticleDirectForce); + this.dimension = 0; + this.degree = 0; + this.knots = null; + this.controls = null; +}; - var _this = _possibleConstructorReturn(this, (Tw2ParticleDirectForce.__proto__ || Object.getPrototypeOf(Tw2ParticleDirectForce)).call(this)); +/***/ }), +/* 109 */ +/***/ (function(module, exports, __webpack_require__) { - _this.force = _math.vec3.create(); - return _this; - } +"use strict"; - /** - * ApplyForce - * @param {Tw2ParticleElement} position - * @param {Tw2ParticleElement} velocity - * @param {Tw2ParticleElement} force - */ +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2GeometryMesh = undefined; + +var _global = __webpack_require__(0); - _createClass(Tw2ParticleDirectForce, [{ - key: 'ApplyForce', - value: function ApplyForce(position, velocity, force) { - _math.vec3.add(force, force, this.force); - } - }]); +var _vertex = __webpack_require__(9); - return Tw2ParticleDirectForce; -}(_Tw2ParticleForce2.Tw2ParticleForce); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * Tw2GeometryMesh + * + * @property {string} name + * @property {Tw2VertexDeclaration} declaration + * @property {Array.} areas + * @property {WebGLBuffer} buffer + * @property {number} bufferLength + * @property bufferData + * @property {WebGLBuffer} indexes + * @property indexData + * @property {number} indexType + * @property {vec3} minBounds + * @property {vec3} maxBounds + * @property {vec3} boundsSpherePosition + * @property {number} boundsSphereRadius + * @property {Array} bones + * @property {Array.} boneBindings + */ +var Tw2GeometryMesh = exports.Tw2GeometryMesh = function Tw2GeometryMesh() { + _classCallCheck(this, Tw2GeometryMesh); + + this.name = ''; + this.declaration = new _vertex.Tw2VertexDeclaration(); + this.areas = []; + this.buffer = null; + this.bufferLength = 0; + this.bufferData = null; + this.indexes = null; + this.indexData = null; + this.indexType = 0; + this.minBounds = _global.vec3.create(); + this.maxBounds = _global.vec3.create(); + this.boundsSpherePosition = _global.vec3.create(); + this.boundsSphereRadius = 0; + this.bones = []; + this.boneBindings = []; +}; /***/ }), -/* 107 */ +/* 110 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22870,59 +22740,63 @@ var Tw2ParticleDirectForce = exports.Tw2ParticleDirectForce = function (_Tw2Part Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2ParticleDragForce = undefined; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +exports.Tw2GeometryMeshArea = undefined; -var _Tw2ParticleForce2 = __webpack_require__(13); +var _global = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - /** - * Tw2ParticleDragForce + * Tw2GeometryMeshArea * - * @property {number} drag - * @inherits Tw2ParticleForce - * @class + * @property {string} name + * @property {number} start + * @property {number} count + * @property {vec3} minBounds + * @property {vec3} maxBounds + * @property {vec3} boundsSpherePosition + * @property {number} boundsSphereRadius */ -var Tw2ParticleDragForce = exports.Tw2ParticleDragForce = function (_Tw2ParticleForce) { - _inherits(Tw2ParticleDragForce, _Tw2ParticleForce); +var Tw2GeometryMeshArea = exports.Tw2GeometryMeshArea = function Tw2GeometryMeshArea() { + _classCallCheck(this, Tw2GeometryMeshArea); - function Tw2ParticleDragForce() { - _classCallCheck(this, Tw2ParticleDragForce); + this.name = ''; + this.start = 0; + this.count = 0; + this.minBounds = _global.vec3.create(); + this.maxBounds = _global.vec3.create(); + this.boundsSpherePosition = _global.vec3.create(); + this.boundsSphereRadius = 0; +}; - var _this = _possibleConstructorReturn(this, (Tw2ParticleDragForce.__proto__ || Object.getPrototypeOf(Tw2ParticleDragForce)).call(this)); +/***/ }), +/* 111 */ +/***/ (function(module, exports, __webpack_require__) { - _this.drag = 0.1; - return _this; - } +"use strict"; - /** - * Applies forces - * @param {Tw2ParticleElement} position - * @param {Tw2ParticleElement} velocity - * @param {Tw2ParticleElement} force - */ +Object.defineProperty(exports, "__esModule", { + value: true +}); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - _createClass(Tw2ParticleDragForce, [{ - key: 'ApplyForce', - value: function ApplyForce(position, velocity, force) { - force[0] += velocity.buffer[velocity.offset] * -this.drag; - force[1] += velocity.buffer[velocity.offset + 1] * -this.drag; - force[2] += velocity.buffer[velocity.offset + 2] * -this.drag; - } - }]); +/** + * Tw2GeometryMeshBinding + * + * @property {Tw2GeometryMesh} mesh + * @property {Array.} bones + */ +var Tw2GeometryMeshBinding = exports.Tw2GeometryMeshBinding = function Tw2GeometryMeshBinding() { + _classCallCheck(this, Tw2GeometryMeshBinding); - return Tw2ParticleDragForce; -}(_Tw2ParticleForce2.Tw2ParticleForce); + this.mesh = null; + this.bones = []; +}; /***/ }), -/* 108 */ +/* 112 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22931,84 +22805,56 @@ var Tw2ParticleDragForce = exports.Tw2ParticleDragForce = function (_Tw2Particle Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2ParticleFluidDragForce = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); - -var _Tw2ParticleForce2 = __webpack_require__(13); - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - /** - * Tw2ParticleFluidDragForce + * Tw2GeometryModel * - * @property {number} drag - * @property {vec3} _tempVec - * @property {vec3} _tempVec2 - * @inherits Tw2ParticleForce - * @class + * @property {string} name + * @property {Array.} meshBindings + * @property {Tw2GeometrySkeleton} skeleton */ -var Tw2ParticleFluidDragForce = exports.Tw2ParticleFluidDragForce = function (_Tw2ParticleForce) { - _inherits(Tw2ParticleFluidDragForce, _Tw2ParticleForce); - - function Tw2ParticleFluidDragForce() { - _classCallCheck(this, Tw2ParticleFluidDragForce); - - var _this = _possibleConstructorReturn(this, (Tw2ParticleFluidDragForce.__proto__ || Object.getPrototypeOf(Tw2ParticleFluidDragForce)).call(this)); +var Tw2GeometryModel = exports.Tw2GeometryModel = function () { + function Tw2GeometryModel() { + _classCallCheck(this, Tw2GeometryModel); - _this.drag = 0.1; - return _this; + this.name = ''; + this.meshBindings = []; + this.skeleton = null; } /** - * Applies forces - * @param {Tw2ParticleElement} position - * @param {Tw2ParticleElement} velocity - * @param {Tw2ParticleElement} force - * @param {number} dt - delta time - * @param { number} mass + * Finds a bone by it's name + * @param {string} name + * @returns {Tw2GeometryBone|null} */ - _createClass(Tw2ParticleFluidDragForce, [{ - key: 'ApplyForce', - value: function ApplyForce(position, velocity, force, dt, mass) { - var vec3_0 = _Tw2ParticleForce2.Tw2ParticleForce.global.vec3_0, - vec3_1 = _Tw2ParticleForce2.Tw2ParticleForce.global.vec3_1, - speed = Math.sqrt(velocity.buffer[velocity.offset] * velocity.buffer[velocity.offset] + velocity.buffer[velocity.offset + 1] * velocity.buffer[velocity.offset + 1] + velocity.buffer[velocity.offset + 2] * velocity.buffer[velocity.offset + 2]); - - vec3_0[0] = velocity.buffer[velocity.offset] * -speed * this.drag; - vec3_0[1] = velocity.buffer[velocity.offset + 1] * -speed * this.drag; - vec3_0[2] = velocity.buffer[velocity.offset + 2] * -speed * this.drag; - - _math.vec3.scale(vec3_1, vec3_0, dt * mass); - vec3_1[0] += velocity.buffer[velocity.offset]; - vec3_1[1] += velocity.buffer[velocity.offset + 1]; - vec3_1[2] += velocity.buffer[velocity.offset + 2]; - - var dot = velocity.buffer[velocity.offset] * vec3_1[0] + velocity.buffer[velocity.offset + 1] * vec3_1[1] + velocity.buffer[velocity.offset + 2] * vec3_1[2]; + _createClass(Tw2GeometryModel, [{ + key: 'FindBoneByName', + value: function FindBoneByName(name) { + if (!this.skeleton) { + return null; + } - if (dot < 0) { - force[0] = -velocity.buffer[velocity.offset] / dt / mass; - force[1] = -velocity.buffer[velocity.offset + 1] / dt / mass; - force[2] = -velocity.buffer[velocity.offset + 2] / dt / mass; - } else { - _math.vec3.copy(force, vec3_0); + for (var i = 0; i < this.skeleton.bones.length; ++i) { + if (this.skeleton.bones[i].name === name) { + return this.skeleton.bones[i]; + } } + + return null; } }]); - return Tw2ParticleFluidDragForce; -}(_Tw2ParticleForce2.Tw2ParticleForce); + return Tw2GeometryModel; +}(); /***/ }), -/* 109 */ +/* 113 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -23017,63 +22863,80 @@ var Tw2ParticleFluidDragForce = exports.Tw2ParticleFluidDragForce = function (_T Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2ParticleSpring = undefined; -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * Tw2GeometrySkeleton + * + * @property {Array.} bones + */ +var Tw2GeometrySkeleton = exports.Tw2GeometrySkeleton = function Tw2GeometrySkeleton() { + _classCallCheck(this, Tw2GeometrySkeleton); -var _math = __webpack_require__(0); + this.bones = []; +}; -var _Tw2ParticleForce2 = __webpack_require__(13); +/***/ }), +/* 114 */ +/***/ (function(module, exports, __webpack_require__) { -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +"use strict"; -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } +Object.defineProperty(exports, "__esModule", { + value: true +}); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** - * Tw2ParticleSpring + * Tw2GeometryTrackGroup * - * @property {number} springConstant - * @property {vec3} position - * @inherits Tw2ParticleForce - * @class + * @property {string} name + * @property {Tw2GeometryModel} model + * @property {Array.} transformTracks */ -var Tw2ParticleSpring = exports.Tw2ParticleSpring = function (_Tw2ParticleForce) { - _inherits(Tw2ParticleSpring, _Tw2ParticleForce); +var Tw2GeometryTrackGroup = exports.Tw2GeometryTrackGroup = function Tw2GeometryTrackGroup() { + _classCallCheck(this, Tw2GeometryTrackGroup); - function Tw2ParticleSpring() { - _classCallCheck(this, Tw2ParticleSpring); + this.name = ''; + this.model = null; + this.transformTracks = []; +}; - var _this = _possibleConstructorReturn(this, (Tw2ParticleSpring.__proto__ || Object.getPrototypeOf(Tw2ParticleSpring)).call(this)); +/***/ }), +/* 115 */ +/***/ (function(module, exports, __webpack_require__) { - _this.springConstant = 0; - _this.position = _math.vec3.create(); - return _this; - } +"use strict"; - /** - * Applies forces - * @param {Tw2ParticleElement} position - * @param {Tw2ParticleElement} velocity - * @param {Tw2ParticleElement} force - */ +Object.defineProperty(exports, "__esModule", { + value: true +}); - _createClass(Tw2ParticleSpring, [{ - key: 'ApplyForce', - value: function ApplyForce(position, velocity, force) { - force[0] += (this.position[0] - position.buffer[position.offset]) * this.springConstant; - force[1] += (this.position[1] - position.buffer[position.offset + 1]) * this.springConstant; - force[2] += (this.position[2] - position.buffer[position.offset + 2]) * this.springConstant; - } - }]); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - return Tw2ParticleSpring; -}(_Tw2ParticleForce2.Tw2ParticleForce); +/** + * Tw2GeometryTransformTrack + * + * @property {string} name + * @property {Tw2GeometryCurve} position + * @property {Tw2GeometryCurve} orientation + * @property scaleShear + */ +var Tw2GeometryTransformTrack = exports.Tw2GeometryTransformTrack = function Tw2GeometryTransformTrack() { + _classCallCheck(this, Tw2GeometryTransformTrack); + + this.name = ''; + this.position = null; + this.orientation = null; + this.scaleShear = null; +}; /***/ }), -/* 110 */ +/* 116 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -23082,13 +22945,17 @@ var Tw2ParticleSpring = exports.Tw2ParticleSpring = function (_Tw2ParticleForce) Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2ParticleTurbulenceForce = undefined; +exports.Tw2InstancedMesh = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + +var _global = __webpack_require__(0); + +var _batch = __webpack_require__(15); -var _Tw2ParticleForce2 = __webpack_require__(13); +var _Tw2Mesh2 = __webpack_require__(49); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -23097,152 +22964,145 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2ParticleTurbulenceForce + * Tw2InstancedMesh * - * @property {number} noiseLevel - * @property {number} noiseRatio - * @property {vec3} amplitude - * @property {quat} frequency - * @property {number} _time - * @inherits Tw2ParticleForce + * @property instanceGeometryResource + * @property {string} instanceGeometryResPath + * @property {number} instanceMeshIndex + * @property {vec3} minBounds + * @property {vec3} maxBounds * @class */ -var Tw2ParticleTurbulenceForce = exports.Tw2ParticleTurbulenceForce = function (_Tw2ParticleForce) { - _inherits(Tw2ParticleTurbulenceForce, _Tw2ParticleForce); +var Tw2InstancedMesh = exports.Tw2InstancedMesh = function (_Tw2Mesh) { + _inherits(Tw2InstancedMesh, _Tw2Mesh); - function Tw2ParticleTurbulenceForce() { - _classCallCheck(this, Tw2ParticleTurbulenceForce); + function Tw2InstancedMesh() { + _classCallCheck(this, Tw2InstancedMesh); - var _this = _possibleConstructorReturn(this, (Tw2ParticleTurbulenceForce.__proto__ || Object.getPrototypeOf(Tw2ParticleTurbulenceForce)).call(this)); + var _this = _possibleConstructorReturn(this, (Tw2InstancedMesh.__proto__ || Object.getPrototypeOf(Tw2InstancedMesh)).call(this)); - _this.noiseLevel = 3; - _this.noiseRatio = 0.5; - _this.amplitude = _math.vec3.fromValues(1, 1, 1); - _this.frequency = _math.vec4.fromValues(1, 1, 1, 1); - _this._time = 0; + _this.instanceGeometryResource = null; + _this.instanceGeometryResPath = ''; + _this.instanceMeshIndex = 0; + _this.minBounds = _global.vec3.create(); + _this.maxBounds = _global.vec3.create(); return _this; } /** - * ApplyForce - * @param {Tw2ParticleElement} position - * @param {Tw2ParticleElement} velocity - * @param {Tw2ParticleElement} force + * Initializes the instanced mesh */ - _createClass(Tw2ParticleTurbulenceForce, [{ - key: 'ApplyForce', - value: function ApplyForce(position, velocity, force) { - if (this.noiseLevel === 0) return; - - var pos_0 = position.buffer[position.offset] * this.frequency[0], - pos_1 = position.buffer[position.offset + 1] * this.frequency[1], - pos_2 = position.buffer[position.offset + 2] * this.frequency[2], - pos_3 = this._time * this.frequency[3]; - - var sum = 0, - power = 0.5, - frequency = 1 / this.noiseRatio; - - var out = _math.vec4.set(_Tw2ParticleForce2.Tw2ParticleForce.global.vec4_0, 0, 0, 0, 0); - - for (var i = 0; i < this.noiseLevel; ++i) { - _math.noise.turbulence(out, pos_0, pos_1, pos_2, pos_3, power); - sum += power; - pos_0 *= frequency; - pos_1 *= frequency; - pos_2 *= frequency; - pos_3 *= frequency; - power *= this.noiseRatio; + _createClass(Tw2InstancedMesh, [{ + key: 'Initialize', + value: function Initialize() { + _get(Tw2InstancedMesh.prototype.__proto__ || Object.getPrototypeOf(Tw2InstancedMesh.prototype), 'Initialize', this).call(this); + if (this.instanceGeometryResPath !== '') { + this.instanceGeometryResource = _global.resMan.GetResource(this.instanceGeometryResPath); } - - force[0] += out[0] * this.amplitude[0] * sum; - force[1] += out[1] * this.amplitude[1] * sum; - force[2] += out[2] * this.amplitude[2] * sum; } /** - * Per frame update (Called before ApplyForce) - * @param {number} dt - delta Time + * Checks if the instances meshes' resources are good + * @returns {boolean} */ }, { - key: 'Update', - value: function Update(dt) { - this._time += dt; - } - }]); - - return Tw2ParticleTurbulenceForce; -}(_Tw2ParticleForce2.Tw2ParticleForce); + key: 'IsGood', + value: function IsGood() { + var instanced = this.instanceGeometryResource, + isResGood = _get(Tw2InstancedMesh.prototype.__proto__ || Object.getPrototypeOf(Tw2InstancedMesh.prototype), 'IsGood', this).call(this), + isInstancedResGood = !instanced ? false : instanced.IsGood ? instanced.IsGood() : true; -/***/ }), -/* 111 */ -/***/ (function(module, exports, __webpack_require__) { + return isResGood && isInstancedResGood; + } -"use strict"; + /** + * Gets mesh resources + * @param {Array} [out=[]] - Optional receiving array + * @returns {Array.} [out] + */ + }, { + key: 'GetResources', + value: function GetResources() { + var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; -Object.defineProperty(exports, "__esModule", { - value: true -}); + _get(Tw2InstancedMesh.prototype.__proto__ || Object.getPrototypeOf(Tw2InstancedMesh.prototype), 'GetResources', this).call(this, out); + if (this.instanceGeometryResource && 'GetResources' in this.instanceGeometryResource) { + this.instanceGeometryResource.GetResources(out); + } + return out; + } -var _Tw2RandomIntegerAttributeGenerator = __webpack_require__(112); + /** + * RenderAreas + * @param {number} meshIx + * @param {number} start + * @param {number} count + * @param {Tw2Effect} effect + * @param {string} technique + */ -Object.keys(_Tw2RandomIntegerAttributeGenerator).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2RandomIntegerAttributeGenerator[key]; - } - }); -}); + }, { + key: 'RenderAreas', + value: function RenderAreas(meshIx, start, count, effect, technique) { + if (!this.IsGood()) return; -var _Tw2RandomUniformAttributeGenerator = __webpack_require__(113); + var buffer = this.instanceGeometryResource.GetInstanceBuffer(this.instanceMeshIndex); + if (buffer) { + this.geometryResource.RenderAreasInstanced(meshIx, start, count, effect, technique, buffer, this.instanceGeometryResource.GetInstanceDeclaration(this.instanceMeshIndex), this.instanceGeometryResource.GetInstanceStride(this.instanceMeshIndex), this.instanceGeometryResource.GetInstanceCount(this.instanceMeshIndex)); + } + } -Object.keys(_Tw2RandomUniformAttributeGenerator).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2RandomUniformAttributeGenerator[key]; - } - }); -}); + /** + * Gets area batches + * @param {Tw2InstancedMesh} mesh + * @param {Array.} areas + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator + * @param {Tw2PerObjectData} perObjectData + */ -var _Tw2SphereShapeAttributeGenerator = __webpack_require__(114); + }], [{ + key: 'GetAreaBatches', + value: function GetAreaBatches(mesh, areas, mode, accumulator, perObjectData) { + for (var i = 0; i < areas.length; ++i) { + var area = areas[i]; + if (area.effect && area.display) { + var batch = new _batch.Tw2InstancedMeshBatch(); + batch.renderMode = mode; + batch.perObjectData = perObjectData; + batch.instanceMesh = mesh; + batch.meshIx = area.meshIndex; + batch.start = area.index; + batch.count = area.count; + batch.effect = area.effect; + accumulator.Commit(batch); + } + } + } + }]); -Object.keys(_Tw2SphereShapeAttributeGenerator).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2SphereShapeAttributeGenerator[key]; - } - }); -}); + return Tw2InstancedMesh; +}(_Tw2Mesh2.Tw2Mesh); /***/ }), -/* 112 */ +/* 117 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { - value: true + value: true }); -exports.Tw2RandomIntegerAttributeGenerator = undefined; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _math = __webpack_require__(0); +exports.Tw2MeshLineArea = undefined; -var _Tw2ParticleElement = __webpack_require__(18); +var _batch = __webpack_require__(15); -var _Tw2ParticleAttributeGenerator = __webpack_require__(27); +var _Tw2MeshArea2 = __webpack_require__(50); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -23251,163 +23111,115 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2RandomIntegerAttributeGenerator + * Tw2MeshLineArea * - * @property {number} elementType - * @property {string} customName - * @property {vec4} minRange - * @property {vec4} maxRange - * @property {Tw2ParticleElement} _element - * @inherits Tw2ParticleAttributeGenerator * @class */ -var Tw2RandomIntegerAttributeGenerator = exports.Tw2RandomIntegerAttributeGenerator = function (_Tw2ParticleAttribute) { - _inherits(Tw2RandomIntegerAttributeGenerator, _Tw2ParticleAttribute); - - function Tw2RandomIntegerAttributeGenerator() { - _classCallCheck(this, Tw2RandomIntegerAttributeGenerator); - - var _this = _possibleConstructorReturn(this, (Tw2RandomIntegerAttributeGenerator.__proto__ || Object.getPrototypeOf(Tw2RandomIntegerAttributeGenerator)).call(this)); - - _this.elementType = _Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.CUSTOM; - _this.customName = ''; - _this.minRange = _math.vec4.create(); - _this.maxRange = _math.vec4.create(); - _this._element = null; - return _this; - } +var Tw2MeshLineArea = exports.Tw2MeshLineArea = function (_Tw2MeshArea) { + _inherits(Tw2MeshLineArea, _Tw2MeshArea); - /** - * Binds a particle system element to the generator - * @param {Tw2ParticleSystem} ps - * @returns {boolean} True if successfully bound - */ + function Tw2MeshLineArea() { + _classCallCheck(this, Tw2MeshLineArea); + return _possibleConstructorReturn(this, (Tw2MeshLineArea.__proto__ || Object.getPrototypeOf(Tw2MeshLineArea)).call(this)); + } - _createClass(Tw2RandomIntegerAttributeGenerator, [{ - key: 'Bind', - value: function Bind(ps) { - for (var i = 0; i < ps._elements.length; ++i) { - if (ps._elements[i].elementType === this.elementType && (this.elementType !== _Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.CUSTOM || ps._elements[i].customName === this.customName)) { - this._element = ps._elements[i]; - return true; - } - } - return false; - } + return Tw2MeshLineArea; +}(_Tw2MeshArea2.Tw2MeshArea); - /** - * Generates the attributes - * @param {Tw2ParticleElement} position - * @param {Tw2ParticleElement} velocity - * @param {number} index - */ +/** + * Render Batch Constructor + * @type {Tw2RenderBatch} + */ - }, { - key: 'Generate', - value: function Generate(position, velocity, index) { - for (var i = 0; i < this._element.dimension; ++i) { - this._element.buffer[this._element.instanceStride * index + this._element.startOffset + i] = Math.floor(this.minRange[i] + Math.random() * (this.maxRange[i] - this.minRange[i]) + 0.5); - } - } - }]); - return Tw2RandomIntegerAttributeGenerator; -}(_Tw2ParticleAttributeGenerator.Tw2ParticleAttributeGenerator); +Tw2MeshLineArea.batchType = _batch.Tw2GeometryLineBatch; /***/ }), -/* 113 */ +/* 118 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { - value: true + value: true }); -exports.Tw2RandomUniformAttributeGenerator = undefined; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _math = __webpack_require__(0); - -var _Tw2ParticleElement = __webpack_require__(18); - -var _Tw2ParticleAttributeGenerator = __webpack_require__(27); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } +var _Tw2Animation = __webpack_require__(51); -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } +Object.keys(_Tw2Animation).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2Animation[key]; + } + }); +}); -/** - * Tw2RandomUniformAttributeGenerator - * - * @property {number} elementType - * @property {string} customName - * @property {vec4} minRange - * @property {vec4} maxRange - * @property {Tw2ParticleElement} _element - * @inherits Tw2ParticleAttributeGenerator - * @class - */ -var Tw2RandomUniformAttributeGenerator = exports.Tw2RandomUniformAttributeGenerator = function (_Tw2ParticleAttribute) { - _inherits(Tw2RandomUniformAttributeGenerator, _Tw2ParticleAttribute); +var _Tw2AnimationController = __webpack_require__(119); - function Tw2RandomUniformAttributeGenerator() { - _classCallCheck(this, Tw2RandomUniformAttributeGenerator); +Object.keys(_Tw2AnimationController).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2AnimationController[key]; + } + }); +}); - var _this = _possibleConstructorReturn(this, (Tw2RandomUniformAttributeGenerator.__proto__ || Object.getPrototypeOf(Tw2RandomUniformAttributeGenerator)).call(this)); +var _Tw2Bone = __webpack_require__(53); - _this.elementType = _Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.CUSTOM; - _this.customName = ''; - _this.minRange = _math.vec4.create(); - _this.maxRange = _math.vec4.create(); - _this._element = null; - return _this; +Object.keys(_Tw2Bone).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2Bone[key]; } + }); +}); - /** - * Binds a particle system element to the generator - * @param {Tw2ParticleSystem} ps - * @returns {boolean} True if successfully bound - */ +var _Tw2Model = __webpack_require__(54); +Object.keys(_Tw2Model).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2Model[key]; + } + }); +}); - _createClass(Tw2RandomUniformAttributeGenerator, [{ - key: 'Bind', - value: function Bind(ps) { - for (var i = 0; i < ps._elements.length; ++i) { - if (ps._elements[i].elementType === this.elementType && (this.elementType !== _Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.CUSTOM || ps._elements[i].customName === this.customName)) { - this._element = ps._elements[i]; - return true; - } - } - return false; - } +var _Tw2Track = __webpack_require__(55); - /** - * Generates the attributes - * @param {Tw2ParticleElement} position - * @param {Tw2ParticleElement} velocity - * @param {number} index - */ +Object.keys(_Tw2Track).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2Track[key]; + } + }); +}); - }, { - key: 'Generate', - value: function Generate(position, velocity, index) { - for (var i = 0; i < this._element.dimension; ++i) { - this._element.buffer[this._element.instanceStride * index + this._element.startOffset + i] = this.minRange[i] + Math.random() * (this.maxRange[i] - this.minRange[i]); - } - } - }]); +var _Tw2TrackGroup = __webpack_require__(56); - return Tw2RandomUniformAttributeGenerator; -}(_Tw2ParticleAttributeGenerator.Tw2ParticleAttributeGenerator); +Object.keys(_Tw2TrackGroup).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2TrackGroup[key]; + } + }); +}); /***/ }), -/* 114 */ +/* 119 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -23416,951 +23228,819 @@ var Tw2RandomUniformAttributeGenerator = exports.Tw2RandomUniformAttributeGenera Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2SphereShapeAttributeGenerator = undefined; +exports.Tw2AnimationController = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); -var _Tw2ParticleElement = __webpack_require__(18); +var _resource = __webpack_require__(25); -var _Tw2ParticleAttributeGenerator = __webpack_require__(27); +var _Tw2Animation = __webpack_require__(51); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +var _Tw2Bone = __webpack_require__(53); -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } +var _Tw2Model = __webpack_require__(54); -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } +var _Tw2Track = __webpack_require__(55); + +var _Tw2TrackGroup = __webpack_require__(56); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** - * Tw2SphereShapeAttributeGenerator + * Tw2AnimationController * - * @property {number} minRadius - * @property {number} maxRadius - * @property {number} minPhi - * @property {number} maxPhi - * @property {number} minTheta - * @property {number} maxTheta - * @property {boolean} controlPosition - * @property {boolean} controlVelocity - * @property {number} minSpeed - * @property {number} maxSpeed - * @property {number} parentVelocityFactor - * @property {vec3} position - * @property {quat} rotation - * @property {?Tw2ParticleElement} _position - * @property {?Tw2ParticleElement}_velocity - * @inherits Tw2ParticleAttributeGenerator + * @param {Tw2GeometryRes} [geometryResource] + * @property {Array.} geometryResources + * @property {Array.} models + * @property {Array.} animations + * @property {Array} meshBindings + * @property {boolean} loaded + * @property {boolean} update + * @property _geometryResource + * @property {Array} pendingCommands + * @property {Function} [onLoaded] an optional callback fired when any commands are cleared + * @class */ -var Tw2SphereShapeAttributeGenerator = exports.Tw2SphereShapeAttributeGenerator = function (_Tw2ParticleAttribute) { - _inherits(Tw2SphereShapeAttributeGenerator, _Tw2ParticleAttribute); - - function Tw2SphereShapeAttributeGenerator() { - _classCallCheck(this, Tw2SphereShapeAttributeGenerator); +var Tw2AnimationController = exports.Tw2AnimationController = function () { + function Tw2AnimationController(geometryResource) { + _classCallCheck(this, Tw2AnimationController); - var _this = _possibleConstructorReturn(this, (Tw2SphereShapeAttributeGenerator.__proto__ || Object.getPrototypeOf(Tw2SphereShapeAttributeGenerator)).call(this)); + this.geometryResources = []; + this.models = []; + this.animations = []; + this.meshBindings = []; + this.loaded = false; + this.update = true; + this.pendingCommands = []; + this.onPendingCleared = null; + this._geometryResource = null; - _this.minRadius = 0; - _this.maxRadius = 0; - _this.minPhi = 0; - _this.maxPhi = 360; - _this.minTheta = 0; - _this.maxTheta = 360; - _this.controlPosition = true; - _this.controlVelocity = true; - _this.minSpeed = 0; - _this.maxSpeed = 0; - _this.parentVelocityFactor = 1; - _this.position = _math.vec3.create(); - _this.rotation = _math.quat.create(); - _this._position = null; - _this._velocity = null; - return _this; + if (geometryResource) { + this.SetGeometryResource(geometryResource); + } } /** - * Binds a particle system element to the generator - * @param {Tw2ParticleSystem} ps - * @returns {boolean} True if successfully bound + * Gets a loaded Tw2Animation by it's name + * @returns {?{ string: Tw2Animation}} an object containing animation names and animations, or null if not loaded */ - _createClass(Tw2SphereShapeAttributeGenerator, [{ - key: 'Bind', - value: function Bind(ps) { - this._position = null; - this._velocity = null; + _createClass(Tw2AnimationController, [{ + key: 'GetAnimationsByName', + value: function GetAnimationsByName() { + if (!this.loaded) return null; - for (var i = 0; i < ps._elements.length; ++i) { - if (ps._elements[i].elementType === _Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION && this.controlPosition) { - this._position = ps._elements[i]; - } else if (ps._elements[i].elementType === _Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.VELOCITY && this.controlVelocity) { - this._velocity = ps._elements[i]; - } + var animations = {}; + for (var i = 0; i < this.animations.length; i++) { + animations[this.animations[i].animationRes.name] = this.animations[i]; } - return (!this.controlPosition || this._position !== null) && (!this.controlVelocity || this._velocity !== null); + return animations; } /** - * Generates the attributes - * @param {Tw2ParticleElement} position - * @param {Tw2ParticleElement} velocity - * @param {number} index + * Gets a loaded Tw2Animation by it's name + * @param {String} name + * @returns {?Tw2Animation} Returns the animation if found */ }, { - key: 'Generate', - value: function Generate(position, velocity, index) { - var phi = (this.minPhi + Math.random() * (this.maxPhi - this.minPhi)) / 180 * Math.PI, - theta = (this.minTheta + Math.random() * (this.maxTheta - this.minTheta)) / 180 * Math.PI, - rv = _Tw2ParticleAttributeGenerator.Tw2ParticleAttributeGenerator.global.vec3_0; - - rv[0] = Math.sin(phi) * Math.cos(theta); - rv[1] = -Math.cos(phi); - rv[2] = Math.sin(phi) * Math.sin(theta); - _math.vec3.transformQuat(rv, rv, this.rotation); - - if (this._velocity) { - var speed = this.minSpeed + Math.random() * (this.maxSpeed - this.minSpeed), - offset = this._velocity.instanceStride * index + this._velocity.startOffset; - - this._velocity.buffer[offset] = rv[0] * speed; - this._velocity.buffer[offset + 1] = rv[1] * speed; - this._velocity.buffer[offset + 2] = rv[2] * speed; - - if (velocity) { - this._velocity.buffer[offset] += velocity.buffer[velocity.offset] * this.parentVelocityFactor; - this._velocity.buffer[offset + 1] += velocity.buffer[velocity.offset + 1] * this.parentVelocityFactor; - this._velocity.buffer[offset + 2] += velocity.buffer[velocity.offset + 2] * this.parentVelocityFactor; + key: 'GetAnimation', + value: function GetAnimation(name) { + for (var i = 0; i < this.animations.length; i++) { + if (this.animations[i].animationRes.name === name) { + return this.animations[i]; } } + return null; + } - if (this._position) { - _math.vec3.scale(rv, rv, this.minRadius + Math.random() * (this.maxRadius - this.minRadius)); - _math.vec3.add(rv, rv, this.position); - - if (position) { - rv[0] += position.buffer[position.offset]; - rv[1] += position.buffer[position.offset + 1]; - rv[2] += position.buffer[position.offset + 2]; - } + /** + * Resets a Tw2Animation by it's name + * @param {String} name + * @return {boolean} + */ - var _offset = this._position.instanceStride * index + this._position.startOffset; - this._position.buffer[_offset] = rv[0]; - this._position.buffer[_offset + 1] = rv[1]; - this._position.buffer[_offset + 2] = rv[2]; + }, { + key: 'ResetAnimation', + value: function ResetAnimation(name) { + var animation = this.GetAnimation(name); + if (animation) { + animation.time = 0; + animation.isPlaying = false; + animation.callback = null; + return true; } } - }]); - - return Tw2SphereShapeAttributeGenerator; -}(_Tw2ParticleAttributeGenerator.Tw2ParticleAttributeGenerator); - -/***/ }), -/* 115 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -/***/ }), -/* 116 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2ParticleSystem = undefined; -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _math = __webpack_require__(0); - -var _core = __webpack_require__(1); + /** + * Plays a specific animation by it's name + * @param {string} name - Animation's Name + * @param {boolean} [cycle] + * @param {Function} [callback] - Optional callback which is fired once the animation has completed + * @return {boolean} + */ -var _Tw2ParticleElement = __webpack_require__(18); + }, { + key: 'PlayAnimation', + value: function PlayAnimation(name, cycle, callback) { + if (this.animations.length === 0) { + this.pendingCommands.push({ + 'func': this.PlayAnimation, + 'args': [name, cycle, callback] + }); + return true; + } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + var animation = this.GetAnimation(name); + if (animation) { + animation.time = 0; + animation.isPlaying = true; -/** - * Tw2ParticleSystem - * - * @property {number|string} id - * @property {string} name - * @property {number} aliveCount - * @property {number} maxParticleCount - * @property {*} emitParticleOnDeathEmitter - * @property {*} emitParticleDuringLifeEmitter - * @property {Array.} elements - * @property {boolean} isValid - * @property {boolean} requiresSorting - * @property {boolean} updateSimulation - * @property {boolean} applyForce - * @property {boolean} applyAging - * @property {boolean} isGlobal - * @property {Array} forces - * @property {Array} constraints - * @property {boolean} updateBoundingBox - * @property {vec3} aabbMin - * @property {vec3} aabbMax - * @property {number} peakAliveCount - * @property {boolean} bufferDirty - * @property {WebGLBuffer} _vb - * @property {Tw2VertexDeclaration} _declaration - * @property {Array} _stdElements - * @property {Array} _elements - * @property {Array} instanceStride - * @property {Array} vertexStride - * @property {Array} buffers - * @class - */ -var Tw2ParticleSystem = exports.Tw2ParticleSystem = function () { - function Tw2ParticleSystem() { - _classCallCheck(this, Tw2ParticleSystem); + if (!_global.util.isUndefined(cycle)) { + animation.cycle = cycle; + } - this._id = _math.util.generateID(); - this.name = ''; - this.aliveCount = 0; - this.maxParticleCount = 0; - this.emitParticleOnDeathEmitter = null; - this.emitParticleDuringLifeEmitter = null; - this.elements = []; - this.isValid = false; - this.requiresSorting = false; - this.updateSimulation = true; - this.applyForce = true; - this.applyAging = true; - this.isGlobal = false; - this.forces = []; - this.constraints = []; - this.updateBoundingBox = false; - this.aabbMin = _math.vec3.create(); - this.aabbMax = _math.vec3.create(); - this.peakAliveCount = 0; + if (callback) { + animation.callback = callback; + } - this.bufferDirty = false; + return true; + } + } - this._vb = null; - this._declaration = null; + /** + * Plays a specific animation from a specific time + * @param {string} name - Animation's Name + * @param {number} from - Time to play from + * @param {boolean} [cycle] + * @param {Function} [callback] - Optional callback which is fired once the animation has completed + * @returns {boolean} + */ - this._stdElements = [null, null, null, null]; - this._elements = []; - this.instanceStride = [null, null]; - this.vertexStride = [null, null]; - this.buffers = [null, null]; + }, { + key: 'PlayAnimationFrom', + value: function PlayAnimationFrom(name, from, cycle, callback) { + if (this.animations.length === 0) { + this.pendingCommands.push({ + 'func': this.PlayAnimationFrom, + 'args': [name, from, cycle, callback] + }); + return true; + } - Tw2ParticleSystem.init(); - } + var animation = this.GetAnimation(name); + if (animation) { + animation.time = Math.max(Math.min(from, animation.animationRes.duration), 0); + animation.isPlaying = true; - /** - * Initializes the Particle System - */ + if (!_global.util.isUndefined(cycle)) { + animation.cycle = cycle; + } + if (callback) { + animation.callback = callback; + } - _createClass(Tw2ParticleSystem, [{ - key: 'Initialize', - value: function Initialize() { - this.UpdateElementDeclaration(); + return true; + } } /** - * Updates Element Declarations + * Gets an array of all the currently playing animations by name + * @returns {Array} */ }, { - key: 'UpdateElementDeclaration', - value: function UpdateElementDeclaration() { - this.isValid = false; - - if (this._vb) { - _core.device.gl.deleteBuffer(this._vb); - this._vb = null; + key: 'GetPlayingAnimations', + value: function GetPlayingAnimations() { + var result = []; + for (var i = 0; i < this.animations.length; i++) { + if (this.animations[i].isPlaying) { + result.push(this.animations[i].animationRes.name); + } } + return result; + } - this._declaration = null; - this.aliveCount = 0; + /** + * Stops an animation or an array of animations from playing + * @param {String| Array.} names - Animation Name, or Array of Animation Names + */ - if (this.elements.length === 0) return; + }, { + key: 'StopAnimation', + value: function StopAnimation(names) { + if (this.animations.length === 0) { + this.pendingCommands.push({ + 'func': this.StopAnimation, + 'args': names + }); + return; + } - this._stdElements = [null, null, null, null]; - this._elements = []; - this.instanceStride = [0, 0]; - this.vertexStride = [0, 0]; - this._declaration = new _core.Tw2VertexDeclaration(); - this.buffers = [null, null]; + names = _global.util.toArray(names); - for (var i = 0; i < this.elements.length; ++i) { - var bufferIndex = this.elements[i].usedByGPU ? 0 : 1, - el = new _Tw2ParticleElement.Tw2ParticleElement(this.elements[i]); - //el.buffer = this.buffers[bufferIndex]; + var toStop = {}; + for (var n = 0; n < names.length; n++) { + toStop[names[n]] = true; + } - el.startOffset = this.vertexStride[bufferIndex]; - el.offset = el.startOffset; - if (this.elements[i].elementType !== _Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.CUSTOM) { - this._stdElements[this.elements[i].elementType] = el; - } - this.vertexStride[bufferIndex] += el.dimension; - this._elements.push(el); - if (bufferIndex === 0) { - var d = this.elements[i].GetDeclaration(); - d.offset = el.startOffset * 4; - this._declaration.elements.push(d); + for (var i = 0; i < this.animations.length; ++i) { + if (this.animations[i].animationRes.name in toStop) { + this.animations[i].isPlaying = false; } } + } - this._declaration.RebuildHash(); + /** + * Stops all animations from playing + */ - for (var _i = 0; _i < this._elements.length; ++_i) { - var _bufferIndex = this._elements[_i].usedByGPU ? 0 : 1; - this._elements[_i].vertexStride = this.vertexStride[_bufferIndex]; + }, { + key: 'StopAllAnimations', + value: function StopAllAnimations() { + if (this.animations.length === 0) { + this.pendingCommands.push({ + 'func': this.StopAllAnimations, + 'args': null + }); + return; } - this.instanceStride[0] = this.vertexStride[0] * 4; - this.instanceStride[1] = this.vertexStride[1] * 4; - - for (var _i2 = 0; _i2 < this._elements.length; ++_i2) { - var _bufferIndex2 = this._elements[_i2].usedByGPU ? 0 : 1; - this._elements[_i2].instanceStride = this.instanceStride[_bufferIndex2]; + for (var i = 0; i < this.animations.length; ++i) { + this.animations[i].isPlaying = false; } + } - this.buffers = [null, null]; - if (this.instanceStride[0] && this.maxParticleCount) { - this.buffers[0] = new Float32Array(this.instanceStride[0] * this.maxParticleCount); - this._vb = _core.device.gl.createBuffer(); - _core.device.gl.bindBuffer(_core.device.gl.ARRAY_BUFFER, this._vb); - _core.device.gl.bufferData(_core.device.gl.ARRAY_BUFFER, this.buffers[0].length, _core.device.gl.DYNAMIC_DRAW); - _core.device.gl.bindBuffer(_core.device.gl.ARRAY_BUFFER, null); - } + /** + * Stops all but the supplied list of animations + * @param {String| Array.} names - Animation Names + */ - if (this.instanceStride[1]) { - this.buffers[1] = new Float32Array(this.instanceStride[1] * this.maxParticleCount); + }, { + key: 'StopAllAnimationsExcept', + value: function StopAllAnimationsExcept(names) { + if (this.animations.length === 0) { + this.pendingCommands.push({ + 'func': this.StopAllAnimationsExcept, + 'args': names + }); + return; } - for (var _i3 = 0; _i3 < this._elements.length; ++_i3) { - var _bufferIndex3 = this._elements[_i3].usedByGPU ? 0 : 1; - this._elements[_i3].buffer = this.buffers[_bufferIndex3]; - } + _global.util.toArray(names); - if (this.requiresSorting) { - this._sortedIndexes = new Array(this.maxParticleCount); - this._sortedBuffer = new Float32Array(this.instanceStride[0] * this.maxParticleCount); - this._distancesBuffer = new Float32Array(this.maxParticleCount); + var keepAnimating = {}; + for (var n = 0; n < names.length; n++) { + keepAnimating[names[n]] = true; } - this.isValid = true; - this.bufferDirty = true; + for (var i = 0; i < this.animations.length; ++i) { + if (!(this.animations[i].animationRes.name in keepAnimating)) { + this.animations[i].isPlaying = false; + } + } } /** - * Checks if an element type exists - * @param {number} type - * @returns {boolean} + * Clears any existing resources and loads the supplied geometry resource + * @param {Tw2GeometryRes} geometryResource */ }, { - key: 'HasElement', - value: function HasElement(type) { - return this._stdElements[type] !== null; - } + key: 'SetGeometryResource', + value: function SetGeometryResource(geometryResource) { + this.models = []; + this.animations = []; + this.meshBindings = []; - /** - * Gets an element by it's type - * @param {number} type - * @returns {Tw2ParticleElement} - */ + for (var i = 0; i < this.geometryResources.length; ++i) { + this.geometryResources[i].UnregisterNotification(this); + } - }, { - key: 'GetElement', - value: function GetElement(type) { - if (this._stdElements[type]) { - this._stdElements[type].offset = this._stdElements[type].startOffset; + this.loaded = false; + this.geometryResources = []; + + if (geometryResource) { + this.geometryResources.push(geometryResource); + geometryResource.RegisterNotification(this); } - return this._stdElements[type]; } /** - * Begins particle spawning - * @returns {?number} + * Adds a Geometry Resource + * @param {Tw2GeometryRes} geometryResource */ }, { - key: 'BeginSpawnParticle', - value: function BeginSpawnParticle() { - if (!this.isValid || this.aliveCount >= this.maxParticleCount) return null; - return this.aliveCount++; + key: 'AddGeometryResource', + value: function AddGeometryResource(geometryResource) { + for (var i = 0; i < this.geometryResources.length; ++i) { + if (this.geometryResources[i] === geometryResource) { + return; + } + } + this.geometryResources.push(geometryResource); + geometryResource.RegisterNotification(this); } /** - * Ends particle spawning + * Adds animations from a resource + * @param {Tw2GeometryRes} resource */ }, { - key: 'EndSpawnParticle', - value: function EndSpawnParticle() { - this.bufferDirty = true; - } + key: 'AddAnimationsFromRes', + value: function AddAnimationsFromRes(resource) { + for (var i = 0; i < resource.animations.length; ++i) { + var animation = null; + for (var j = 0; j < this.animations.length; ++j) { + if (this.animations[j].animationRes === resource.animations[i]) { + animation = this.animations[i]; + break; + } + } - /** - * Per frame update - * @param {number} dt - delta time - */ + if (!animation) { + animation = new _Tw2Animation.Tw2Animation(); + animation.animationRes = resource.animations[i]; + this.animations.push(animation); + } - }, { - key: 'Update', - value: function Update(dt) { - dt = Math.min(dt, 0.1); + for (var _j = 0; _j < animation.animationRes.trackGroups.length; ++_j) { + var found = false; + for (var k = 0; k < animation.trackGroups.length; ++k) { + if (animation.trackGroups[k].trackGroupRes === animation.animationRes.trackGroups[_j]) { + found = true; + break; + } + } - if (this.applyAging && this.HasElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.LIFETIME)) { - var lifetime = this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.LIFETIME), - position = this.emitParticleOnDeathEmitter ? this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION) : null, - velocity = this.emitParticleOnDeathEmitter ? this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.VELOCITY) : null; + if (found) { + continue; + } - for (var i = 0; i < this.aliveCount; ++i) { - lifetime.buffer[lifetime.offset] += dt / lifetime.buffer[lifetime.offset + 1]; - if (lifetime.buffer[lifetime.offset] > 1) { - if (this.emitParticleOnDeathEmitter) { - this.emitParticleOnDeathEmitter.SpawnParticles(position, velocity, 1); + var model = null; + for (var _k = 0; _k < this.models.length; ++_k) { + if (this.models[_k].modelRes.name === animation.animationRes.trackGroups[_j].name) { + model = this.models[_k]; + break; } + } - this.aliveCount--; - if (i < this.aliveCount) { - for (var j = 0; j < 2; ++j) { - if (this.buffers[j]) { - this.buffers[j].set(this.buffers[j].subarray(this.instanceStride[j] * this.aliveCount, this.instanceStride[j] * this.aliveCount + this.instanceStride[j]), i * this.instanceStride[j]); + if (model !== null) { + var group = new _Tw2TrackGroup.Tw2TrackGroup(); + group.trackGroupRes = animation.animationRes.trackGroups[_j]; + for (var _k2 = 0; _k2 < group.trackGroupRes.transformTracks.length; ++_k2) { + for (var m = 0; m < model.bones.length; ++m) { + if (model.bones[m].boneRes.name === group.trackGroupRes.transformTracks[_k2].name) { + var track = new _Tw2Track.Tw2Track(); + track.trackRes = group.trackGroupRes.transformTracks[_k2]; + track.bone = model.bones[m]; + group.transformTracks.push(track); + break; } } - --i; - this.bufferDirty = true; } - } else { - lifetime.offset += lifetime.instanceStride; - if (position) position.offset += position.instanceStride; - if (velocity) velocity.offset += velocity.instanceStride; + animation.trackGroups.push(group); } } - lifetime.dirty = true; } + } - var vec3_0 = Tw2ParticleSystem.global.vec3_0; + /** + * Resets the bone transforms + */ - if (this.updateSimulation && this.HasElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION) && this.HasElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.VELOCITY)) { - var hasForces = this.applyForce && this.forces.length; - for (var _i4 = 0; _i4 < this.forces.length; ++_i4) { - this.forces[_i4].Update(dt); - } + }, { + key: 'ResetBoneTransforms', + value: function ResetBoneTransforms() { + for (var i = 0; i < this.models.length; ++i) { + for (var j = 0; j < this.models[i].bones.length; ++j) { + var bone = this.models[i].bones[j], + boneRes = bone.boneRes; - var _position = this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION), - _velocity = this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.VELOCITY), - mass = hasForces ? this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.MASS) : null; + _global.mat4.copy(bone.localTransform, boneRes.localTransform); - for (var _i5 = 0; _i5 < this.aliveCount; ++_i5) { - if (hasForces) { - var amass = mass ? mass.buffer[mass.offset] : 1, - force = _math.vec3.set(vec3_0, 0, 0, 0); + if (boneRes.parentIndex !== -1) { + _global.mat4.multiply(bone.worldTransform, bone.localTransform, this.models[i].bones[bone.boneRes.parentIndex].worldTransform); + } else { + _global.mat4.set(bone.worldTransform, bone.localTransform); + } + _global.mat4.identity(bone.offsetTransform); + } + } - for (var _j = 0; _j < this.forces.length; ++_j) { - this.forces[_j].ApplyForce(_position, _velocity, force, dt, amass); + var id = _global.mat4.identity(Tw2AnimationController.scratch.mat4_0); + for (var _i = 0; _i < this.meshBindings.length; ++_i) { + for (var _j2 = 0; _j2 < this.meshBindings[_i].length; ++_j2) { + for (var k = 0; k * 16 < this.meshBindings[_i][_j2].length; ++k) { + for (var m = 0; m < 16; ++m) { + this.meshBindings[_i][_j2][k * 16 + m] = id[m]; } - - if (mass) _math.vec3.scale(force, force, 1 / mass.buffer[mass.offset]); - - _velocity.buffer[_velocity.offset] += force[0] * dt; - _velocity.buffer[_velocity.offset + 1] += force[1] * dt; - _velocity.buffer[_velocity.offset + 2] += force[2] * dt; } + } + } + } - _position.buffer[_position.offset] += _velocity.buffer[_velocity.offset] * dt; - _position.buffer[_position.offset + 1] += _velocity.buffer[_velocity.offset + 1] * dt; - _position.buffer[_position.offset + 2] += _velocity.buffer[_velocity.offset + 2] * dt; - - if (this.emitParticleDuringLifeEmitter) { - this.emitParticleDuringLifeEmitter.SpawnParticles(_position, _velocity, dt); - } + /** + * GetBoneMatrices + * @param {number} meshIndex + * @param {Tw2GeometryRes} [geometryResource=this.geometryResources[0]] + * @returns {Float32Array} + */ - _position.offset += _position.instanceStride; - _velocity.offset += _velocity.instanceStride; + }, { + key: 'GetBoneMatrices', + value: function GetBoneMatrices(meshIndex, geometryResource) { + if (this.geometryResources.length === 0) { + return new Float32Array(); + } - if (mass) mass.offset += mass.instanceStride; - } - _position.dirty = true; - _velocity.dirty = true; + if (!geometryResource) { + geometryResource = this.geometryResources[0]; } - if (this.updateSimulation && this.constraints.length) { - for (var _i6 = 0; _i6 < this.constraints.length; ++_i6) { - this.constraints[_i6].ApplyConstraint(this.buffers, this.instanceStride, this.aliveCount, dt); - } + var meshBindings = Tw2AnimationController.FindMeshBindings(this, geometryResource); + if (meshBindings && meshIndex < meshBindings.length) { + return meshBindings[meshIndex]; } + return new Float32Array(); + } - if (this.updateBoundingBox) { - this.GetBoundingBox(this.aabbMin, this.aabbMax); + /** + * FindModelForMesh + * @param {number} meshIndex + * @param {Tw2GeometryRes} [geometryResource=this.geometryResources[0]] + * @returns {Tw2Model|null} Returns the Tw2Model for the mesh if found and is good, else returns null + */ + + }, { + key: 'FindModelForMesh', + value: function FindModelForMesh(meshIndex, geometryResource) { + if (this.geometryResources.length === 0) { + return null; } - if (this.emitParticleDuringLifeEmitter && !(this.HasElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION) && this.HasElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.VELOCITY)) && this.updateSimulation) { - var _position2 = this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION), - _velocity2 = this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.VELOCITY); + if (!geometryResource) { + geometryResource = this.geometryResources[0]; + } - for (var _i7 = 0; _i7 < this.aliveCount; ++_i7) { - this.emitParticleDuringLifeEmitter.SpawnParticles(_position2, _velocity2, 1); - if (_position2) _position2.offset += _position2.instanceStride; - if (_velocity2) _velocity2.offset += _velocity2.instanceStride; - } + if (!geometryResource.IsGood()) { + return null; } - for (var _i8 = 0; _i8 < this._elements.length; ++_i8) { - var el = this._elements[_i8]; - el.offset = el.startOffset; - if (el.dirty) { - this.bufferDirty = true; - el.dirty = false; + var mesh = geometryResource.meshes[meshIndex]; + for (var i = 0; i < this.models.length; ++i) { + for (var j = 0; j < this.models[i].modelRes.meshBindings.length; ++i) { + if (this.models[i].modelRes.meshBindings[j].mesh === mesh) { + return this.models[i]; + } } } + return null; } /** - * Gets bounding box - * @param {vec3} aabbMin - * @param {vec3} aabbMax - * @returns {boolean} + * Gets all animation controller res objects + * @param {Array} [out=[]] - Optional receiving array + * @returns {Array.} [out] */ }, { - key: 'GetBoundingBox', - value: function GetBoundingBox(aabbMin, aabbMax) { - if (this.aliveCount && this.HasElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION)) { - var position = this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION); - aabbMin[0] = position.buffer[position.offset]; - aabbMin[1] = position.buffer[position.offset + 1]; - aabbMin[2] = position.buffer[position.offset + 2]; - aabbMax[0] = position.buffer[position.offset]; - aabbMax[1] = position.buffer[position.offset + 1]; - aabbMax[2] = position.buffer[position.offset + 2]; - for (var i = 0; i < this.aliveCount; ++i) { - aabbMin[0] = Math.min(aabbMin[0], position.buffer[position.offset]); - aabbMin[1] = Math.min(aabbMin[1], position.buffer[position.offset + 1]); - aabbMin[2] = Math.min(aabbMin[2], position.buffer[position.offset + 2]); - aabbMax[0] = Math.max(aabbMax[0], position.buffer[position.offset]); - aabbMax[1] = Math.max(aabbMax[1], position.buffer[position.offset + 1]); - aabbMax[2] = Math.max(aabbMax[2], position.buffer[position.offset + 2]); - position.offset += position.instanceStride; + key: 'GetResources', + value: function GetResources() { + var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + + for (var i = 0; i < this.geometryResources.length; i++) { + if (!out.includes(this.geometryResources[i])) { + out.push(this.geometryResources[i]); } - return true; } - return false; + return out; } /** - * _Sort - * @private + * Rebuilds the cached data for a resource (unless it doesn't exist or is already good) + * @param {Tw2GeometryRes} resource */ }, { - key: '_Sort', - value: function _Sort() { - var eye = _math.mat4.multiply(Tw2ParticleSystem.global.mat4_0, _core.device.projection, _core.device.view), - //device.viewInverse; - position = this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION), - count = this.aliveCount, - distances = this._distancesBuffer; - - for (var i = 0; i < count; ++i) { - var o0 = position.offset + position.instanceStride * i; - var dd = position.buffer[o0] - eye[12], - l0 = dd * dd; + key: 'RebuildCachedData', + value: function RebuildCachedData(resource) { + var found = false; + for (var i = 0; i < this.geometryResources.length; ++i) { + if (this.geometryResources[i] === resource) { + found = true; + break; + } + } - dd = position.buffer[o0 + 1] - eye[13]; - l0 += dd * dd; - dd = position.buffer[o0 + 2] - eye[14]; - l0 += dd * dd; - distances[i] = l0; + if (!found) { + return; } - /** - * sortItems - * @param a - * @param b - * @returns {number} - * @private - */ - function sortItems(a, b) { - if (a >= count && b >= count) { - if (a < b) return -1; - if (a > b) return 1; - return 0; + for (var _i2 = 0; _i2 < this.geometryResources.length; ++_i2) { + if (!this.geometryResources[_i2].IsGood()) { + return; } - - if (a >= count) return 1; - if (b >= count) return -1; - - var l0 = distances[a], - l1 = distances[b]; - - if (l0 < l1) return 1; - if (l0 > l1) return -1; - return 0; } - for (var _i9 = 0; _i9 < this.maxParticleCount; ++_i9) { - this._sortedIndexes[_i9] = _i9; + for (var _i3 = 0; _i3 < this.geometryResources.length; ++_i3) { + Tw2AnimationController.DoRebuildCachedData(this, this.geometryResources[_i3]); } - - this._sortedIndexes.sort(sortItems); } /** - * Updates and gets the particle system's InstanceBuffer - * @returns {?WebGLBuffer} + * Internal render/update function which is called every frame + * @param {number} dt - Delta Time */ }, { - key: 'GetInstanceBuffer', - value: function GetInstanceBuffer() { - if (this.aliveCount === 0) return undefined; + key: 'Update', + value: function Update(dt) { + if (!this.models || !this.update) { + return; + } - var d = _core.device; - if (this.requiresSorting && this.HasElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION) && this.buffers) { - this._Sort(); + for (var i = 0; i < this.geometryResources.length; ++i) { + this.geometryResources[i].KeepAlive(); + } - var stride = this.instanceStride[0], - gpuBuffer = this.buffers[0]; + var g = Tw2AnimationController.scratch, + rotationMat = g.mat4_0, + orientation = g.quat_0, + position = g.vec3_0, + scale = g.mat3_0; - for (var i = 0; i < this.aliveCount; ++i) { - var toOffset = i * stride, - fromOffset = this._sortedIndexes[i] * stride; + //var updateBones = false; + for (var _i4 = 0; _i4 < this.animations.length; ++_i4) { + var animation = this.animations[_i4]; + if (animation.isPlaying) { + var res = animation.animationRes; + animation.time += dt * animation.timeScale; + if (animation.time > res.duration) { + if (animation.callback) { + animation.callback(this, animation); + } - for (var j = 0; j < stride; ++j) { - this._sortedBuffer[toOffset + j] = gpuBuffer[j + fromOffset]; + if (animation.cycle) { + animation.time = animation.time % res.duration; + } else { + animation.isPlaying = false; + animation.time = res.duration; + } } - } - - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vb); - d.gl.bufferSubData(d.gl.ARRAY_BUFFER, 0, this._sortedBuffer.subarray(0, this.vertexStride[0] * this.aliveCount)); - this.bufferDirty = false; - } else if (this.bufferDirty) { - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vb); - d.gl.bufferSubData(d.gl.ARRAY_BUFFER, 0, this.buffers[0].subarray(0, this.vertexStride[0] * this.aliveCount)); - this.bufferDirty = false; - } - return this._vb; - } + for (var j = 0; j < animation.trackGroups.length; ++j) { + for (var k = 0; k < animation.trackGroups[j].transformTracks.length; ++k) { + var track = animation.trackGroups[j].transformTracks[k]; + if (track.trackRes.position) { + _global.curve.evaluate(track.trackRes.position, animation.time, position, animation.cycle, res.duration); + } else { + position[0] = position[1] = position[2] = 0; + } + if (track.trackRes.orientation) { + _global.curve.evaluate(track.trackRes.orientation, animation.time, orientation, animation.cycle, res.duration); + _global.quat.normalize(orientation, orientation); + } else { + _global.quat.identity(orientation); + } + if (track.trackRes.scaleShear) { + _global.curve.evaluate(track.trackRes.scaleShear, animation.time, scale, animation.cycle, res.duration); + } else { + _global.mat3.identity(scale); + } - /** - * Gets the particle system's InstanceDeclaration - * @returns {Tw2VertexDeclaration} - */ + _global.mat4.fromMat3(track.bone.localTransform, scale); + _global.mat4.multiply(track.bone.localTransform, track.bone.localTransform, _global.mat4.fromQuat(rotationMat, orientation)); + track.bone.localTransform[12] = position[0]; + track.bone.localTransform[13] = position[1]; + track.bone.localTransform[14] = position[2]; + } + } + } + } - }, { - key: 'GetInstanceDeclaration', - value: function GetInstanceDeclaration() { - return this._declaration; - } + for (var _i5 = 0; _i5 < this.models.length; ++_i5) { + for (var _j3 = 0; _j3 < this.models[_i5].bones.length; ++_j3) { + var bone = this.models[_i5].bones[_j3]; + if (bone.boneRes.parentIndex !== -1) { + _global.mat4.multiply(bone.worldTransform, this.models[_i5].bones[bone.boneRes.parentIndex].worldTransform, bone.localTransform); + } else { + _global.mat4.copy(bone.worldTransform, bone.localTransform); + } + _global.mat4.multiply(bone.offsetTransform, bone.worldTransform, bone.boneRes.worldTransformInv); + if (bone.bindingArrays) { + for (var a = 0; a < bone.bindingArrays.length; ++a) { + bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 0] = bone.offsetTransform[0]; + bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 1] = bone.offsetTransform[4]; + bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 2] = bone.offsetTransform[8]; + bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 3] = bone.offsetTransform[12]; - /** - * Gets the particle system's InstanceStride - * @returns {number} - */ + bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 4] = bone.offsetTransform[1]; + bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 5] = bone.offsetTransform[5]; + bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 6] = bone.offsetTransform[9]; + bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 7] = bone.offsetTransform[13]; - }, { - key: 'GetInstanceStride', - value: function GetInstanceStride() { - return this.instanceStride[0]; + bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 8] = bone.offsetTransform[2]; + bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 9] = bone.offsetTransform[6]; + bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 10] = bone.offsetTransform[10]; + bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 11] = bone.offsetTransform[14]; + } + } + } + } } /** - * Gets the particle system's InstanceCount - * @returns {number} + * RenderDebugInfo + * TODO: Fix commented out code + * @param {function} debugHelper */ }, { - key: 'GetInstanceCount', - value: function GetInstanceCount() { - return this.aliveCount; + key: 'RenderDebugInfo', + value: function RenderDebugInfo(debugHelper) { + /*for (var i = 0; i < this.geometryResources.length; ++i) + { + this.geometryResources[i].RenderDebugInfo(debugHelper); + }*/ + for (var i = 0; i < this.models.length; ++i) { + for (var j = 0; j < this.models[i].bones.length; ++j) { + var b0 = this.models[i].bones[j]; + if (b0.boneRes.parentIndex >= 0) { + var b1 = this.models[i].bones[b0.boneRes.parentIndex]; + debugHelper['AddLine']([b0.worldTransform[12], b0.worldTransform[13], b0.worldTransform[14]], [b1.worldTransform[12], b1.worldTransform[13], b1.worldTransform[14]]); + } + } + } } /** - * Initializes class globals + * Adds a model resource to an animation controller + * @param {Tw2AnimationController} animationController + * @param {Tw2GeometryModel} modelRes + * @returns {null|Tw2Model} Returns a newly created Tw2Model if the model resource doesn't already exist, and null if it does */ - }], [{ - key: 'init', - value: function init() { - if (!Tw2ParticleSystem.global) { - Tw2ParticleSystem.global = { - vec3_0: _math.vec3.create(), - mat4_0: _math.mat4.create() - }; - } - } - }]); - - return Tw2ParticleSystem; -}(); - -/** - * Class globals - */ - - -Tw2ParticleSystem.global = null; - -/***/ }), -/* 117 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2VariableStore = undefined; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _math = __webpack_require__(0); - -var _index = __webpack_require__(24); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Tw2VariableStore - * @property {Object.< string, Parameter>} _variables - * @constructor - */ -var Tw2VariableStore = exports.Tw2VariableStore = function () { - function Tw2VariableStore() { - _classCallCheck(this, Tw2VariableStore); - - this._variables = {}; - } - - /** - * Registers a variable - * @param {string} name - * @param {string|number|Float32Array|vec3|mat4} value - * @param {Parameter} type - * @returns {Parameter} - * @constructor - */ - + }], [{ + key: 'AddModel', + value: function AddModel(animationController, modelRes) { + for (var i = 0; i < animationController.models.length; ++i) { + if (animationController.models[i].modelRes.name === modelRes.name) { + return null; + } + } - _createClass(Tw2VariableStore, [{ - key: 'RegisterVariableWithType', - value: function RegisterVariableWithType(name, value, type) { - return this._variables[name] = new type(name, value); + var model = new _Tw2Model.Tw2Model(); + model.modelRes = modelRes; + var skeleton = modelRes.skeleton; + if (skeleton !== null) { + for (var j = 0; j < skeleton.bones.length; ++j) { + var bone = new _Tw2Bone.Tw2Bone(); + bone.boneRes = skeleton.bones[j]; + model.bones.push(bone); + model.bonesByName[bone.boneRes.name] = bone; + } + } + animationController.models.push(model); + return model; } /** - * Registers a variable without a value - * @param {string} name - * @param {Parameter} type - * @returns {Parameter} - * @constructor + * Finds a mesh binding for a supplied resource from an animation controller + * @param {Tw2AnimationController} animationController + * @param {Tw2GeometryRes} resource + * @returns {Object|null} Returns the mesh binding of a resource if it exists, null if it doesn't + * @private */ }, { - key: 'RegisterType', - value: function RegisterType(name, type) { - return this._variables[name] = new type(name); + key: 'FindMeshBindings', + value: function FindMeshBindings(animationController, resource) { + for (var i = 0; i < animationController.meshBindings.length; ++i) { + if (animationController.meshBindings[i].resource === resource) { + return animationController.meshBindings[i]; + } + } + return null; } /** - * Registers a variable without a type - * @param {string} name - * @param {string|number|Float32Array} value - * @returns {Parameter} + * DoRebuildCachedData + * @param {Tw2AnimationController) animationController + * @param {Tw2GeometryRes} resource */ }, { - key: 'RegisterVariable', - value: function RegisterVariable(name, value) { - var Type = Tw2VariableStore.GetTw2ParameterType(value); - return Type ? this.RegisterVariableWithType(name, value, Type) : null; - } - - /** - * Gets A Tw2 parameter constructor from a supplied value - * @param {Number|String|Array.|Float32Array} value - * @returns {null|Parameter} - */ - - }], [{ - key: 'GetTw2ParameterType', - value: function GetTw2ParameterType(value) { - if (_math.util.isArrayLike(value)) { - switch (value.length) { - case 16: - return _index.Tw2MatrixParameter; - - case 4: - return _index.Tw2Vector4Parameter; - - case 3: - return _index.Tw2Vector3Parameter; - - case 2: - return _index.Tw2Vector2Parameter; - - case 1: - return _index.Tw2FloatParameter; + key: 'DoRebuildCachedData', + value: function DoRebuildCachedData(animationController, resource) { + var newModels = []; + if (resource.meshes.length) { + for (var i = 0; i < resource.models.length; ++i) { + var model = Tw2AnimationController.AddModel(animationController, resource.models[i]); + if (model) { + newModels.push(model); + } } - } else if (typeof value === 'number') { - return _index.Tw2FloatParameter; - } else if (typeof value === 'string') { - return _index.Tw2TextureParameter; } - } - }]); - - return Tw2VariableStore; -}(); - -/***/ }), -/* 118 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2BlendShapeData = undefined; - -var _vertex = __webpack_require__(9); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Tw2BlendShapeData - * - * @property {String} name - * @property {Tw2VertexDeclaration} declaration - * @property {Array} buffers - * @property indexes - * @property weightProxy - */ -var Tw2BlendShapeData = exports.Tw2BlendShapeData = function Tw2BlendShapeData() { - _classCallCheck(this, Tw2BlendShapeData); - - this.name = ''; - this.declaration = new _vertex.Tw2VertexDeclaration(); - this.buffers = []; - this.indexes = null; - this.weightProxy = null; -}; - -/***/ }), -/* 119 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Tw2GeometryAnimation - * - * @property {string} name - * @property {number} duration - * @property {Array.} trackGroups - */ -var Tw2GeometryAnimation = exports.Tw2GeometryAnimation = function Tw2GeometryAnimation() { - _classCallCheck(this, Tw2GeometryAnimation); - - this.name = ''; - this.duration = 0; - this.trackGroups = []; -}; - -/***/ }), -/* 120 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; + for (var _i6 = 0; _i6 < animationController.geometryResources.length; ++_i6) { + animationController.AddAnimationsFromRes(animationController.geometryResources[_i6]); + } -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2GeometryBone = undefined; + if (resource.models.length === 0) { + for (var _i7 = 0; _i7 < resource.meshes.length; ++_i7) { + _resource.Tw2GeometryRes.BindMeshToModel(resource.meshes[_i7], animationController.geometryResources[0].models[0], resource); + } + resource.models.push(animationController.geometryResources[0].models[0]); + } -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + for (var _i8 = 0; _i8 < resource.models.length; ++_i8) { + var _model = null; + for (var j = 0; j < animationController.models.length; ++j) { + if (animationController.models[j].modelRes.name === resource.models[_i8].name) { + _model = animationController.models[j]; + break; + } + } -var _math = __webpack_require__(0); + if (_model === null) { + continue; + } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + for (var _j4 = 0; _j4 < resource.models[_i8].meshBindings.length; ++_j4) { + var meshIx = resource.meshes.indexOf(resource.models[_i8].meshBindings[_j4].mesh); + var meshBindings = Tw2AnimationController.FindMeshBindings(animationController, resource); -/** - * Tw2GeometryBone - * - * @property {string} name - * @property {number} parentIndex - * @property {vec3} position - * @property {quat} orientation - * @property {mat3} scaleShear - * @property {mat4} localTransform - * @property {mat4} worldTransform - * @property {mat4} worldTransformInv - */ -var Tw2GeometryBone = exports.Tw2GeometryBone = function () { - function Tw2GeometryBone() { - _classCallCheck(this, Tw2GeometryBone); + if (meshBindings === null) { + meshBindings = []; + meshBindings.resource = resource; + animationController.meshBindings.push(meshBindings); + } - this.name = ''; - this.parentIndex = -1; - this.position = _math.vec3.create(); - this.orientation = _math.quat.create(); - this.scaleShear = _math.mat3.create(); - this.localTransform = _math.mat4.create(); - this.worldTransform = _math.mat4.create(); - this.worldTransformInv = _math.mat4.create(); - } + meshBindings[meshIx] = new Float32Array(resource.models[_i8].meshBindings[_j4].bones.length * 12); + for (var k = 0; k < resource.models[_i8].meshBindings[_j4].bones.length; ++k) { + for (var n = 0; n < _model.bones.length; ++n) { + if (_model.bones[n].boneRes.name === resource.models[_i8].meshBindings[_j4].bones[k].name) { + if (!_model.bones[n].bindingArrays) { + _model.bones[n].bindingArrays = []; + } - /** - * Updates the Bone's transform - * @returns {mat4} - */ + _model.bones[n].bindingArrays[_model.bones[n].bindingArrays.length] = { + 'array': meshBindings[meshIx], + 'offset': k * 12 + }; + //meshBindings[meshIx][k] = model.bones[n].offsetTransform; + break; + } + } + } + } + } + if (resource.meshes.length && resource.models.length) { + animationController.ResetBoneTransforms(); + } - _createClass(Tw2GeometryBone, [{ - key: 'UpdateTransform', - value: function UpdateTransform() { - _math.mat4.fromMat3(this.localTransform, this.scaleShear); - _math.quat.normalize(this.orientation, this.orientation); - var rm = _math.mat4.fromQuat(Tw2GeometryBone.global.mat4_0, this.orientation); - _math.mat4.multiply(this.localTransform, this.localTransform, rm); - this.localTransform[12] = this.position[0]; - this.localTransform[13] = this.position[1]; - this.localTransform[14] = this.position[2]; - return this.localTransform; + animationController.loaded = true; + if (animationController.animations.length) { + if (animationController.pendingCommands.length) { + for (var _i9 = 0; _i9 < animationController.pendingCommands.length; ++_i9) { + if (!animationController.pendingCommands[_i9].args) { + animationController.pendingCommands[_i9].func.apply(animationController); + } else { + animationController.pendingCommands[_i9].func.apply(animationController, animationController.pendingCommands[_i9].args); + } + } + } + animationController.pendingCommands = []; + if (animationController.onPendingCleared) animationController.onPendingCleared(animationController); + } } }]); - return Tw2GeometryBone; + return Tw2AnimationController; }(); /** - * Class global variables and scratch + * Scratch variables */ -Tw2GeometryBone.global = { - mat4_0: _math.mat4.create() +Tw2AnimationController.scratch = { + vec3_0: _global.vec3.create(), + quat_0: _global.quat.create(), + mat3_0: _global.mat3.create(), + mat4_0: _global.mat4.create() }; /***/ }), -/* 121 */ +/* 120 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -24369,208 +24049,250 @@ Tw2GeometryBone.global = { Object.defineProperty(exports, "__esModule", { value: true }); +exports.Tw2EffectRes = undefined; -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Tw2GeometryCurve - * - * @property {number} dimension - * @property {number} degree - * @property {Float32Array} knots - * @property {Float32Array} controls - */ -var Tw2GeometryCurve = exports.Tw2GeometryCurve = function Tw2GeometryCurve() { - _classCallCheck(this, Tw2GeometryCurve); - - this.dimension = 0; - this.degree = 0; - this.knots = null; - this.controls = null; -}; - -/***/ }), -/* 122 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _global = __webpack_require__(0); -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2GeometryMesh = undefined; +var _reader = __webpack_require__(26); -var _math = __webpack_require__(0); +var _Tw2Resource2 = __webpack_require__(8); -var _vertex = __webpack_require__(9); +var _Tw2Shader = __webpack_require__(121); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -/** - * Tw2GeometryMesh - * - * @property {string} name - * @property {Tw2VertexDeclaration} declaration - * @property {Array.} areas - * @property {WebGLBuffer} buffer - * @property {number} bufferLength - * @property bufferData - * @property {WebGLBuffer} indexes - * @property indexData - * @property {number} indexType - * @property {vec3} minBounds - * @property {vec3} maxBounds - * @property {vec3} boundsSpherePosition - * @property {number} boundsSphereRadius - * @property {Array} bones - * @property {Array.} boneBindings - */ -var Tw2GeometryMesh = exports.Tw2GeometryMesh = function Tw2GeometryMesh() { - _classCallCheck(this, Tw2GeometryMesh); - - this.name = ''; - this.declaration = new _vertex.Tw2VertexDeclaration(); - this.areas = []; - this.buffer = null; - this.bufferLength = 0; - this.bufferData = null; - this.indexes = null; - this.indexData = null; - this.indexType = 0; - this.minBounds = _math.vec3.create(); - this.maxBounds = _math.vec3.create(); - this.boundsSpherePosition = _math.vec3.create(); - this.boundsSphereRadius = 0; - this.bones = []; - this.boneBindings = []; -}; - -/***/ }), -/* 123 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2GeometryMeshArea = undefined; - -var _math = __webpack_require__(0); +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2GeometryMeshArea + * Tw2EffectRes * - * @property {string} name - * @property {number} start - * @property {number} count - * @property {vec3} minBounds - * @property {vec3} maxBounds - * @property {vec3} boundsSpherePosition - * @property {number} boundsSphereRadius + * @property {Array} passes + * @inherits Tw2Resource */ -var Tw2GeometryMeshArea = exports.Tw2GeometryMeshArea = function Tw2GeometryMeshArea() { - _classCallCheck(this, Tw2GeometryMeshArea); +var Tw2EffectRes = exports.Tw2EffectRes = function (_Tw2Resource) { + _inherits(Tw2EffectRes, _Tw2Resource); - this.name = ''; - this.start = 0; - this.count = 0; - this.minBounds = _math.vec3.create(); - this.maxBounds = _math.vec3.create(); - this.boundsSpherePosition = _math.vec3.create(); - this.boundsSphereRadius = 0; -}; + function Tw2EffectRes() { + _classCallCheck(this, Tw2EffectRes); -/***/ }), -/* 124 */ -/***/ (function(module, exports, __webpack_require__) { + var _this = _possibleConstructorReturn(this, (Tw2EffectRes.__proto__ || Object.getPrototypeOf(Tw2EffectRes)).call(this)); -"use strict"; + _this.passes = []; + _this.annotations = {}; + _this.permutations = []; + _this.offsets = []; + _this.reader = null; + _this.version = 0; + _this.stringTable = ''; + _this.shaders = {}; + return _this; + } + /** + * Prepares the effect + * - Creates Shaders + * - Sets shadow states for shaders + * - Parses Jessica shader annotations + * @param data + */ -Object.defineProperty(exports, "__esModule", { - value: true -}); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + _createClass(Tw2EffectRes, [{ + key: 'Prepare', + value: function Prepare(data) { + this.permutations = []; + this.offsets = []; + this.passes = []; + this.annotations = {}; + this.reader = null; + this.version = 0; + this.stringTable = ''; + this.shaders = {}; -/** - * Tw2GeometryMeshBinding - * - * @property {Tw2GeometryMesh} mesh - * @property {Array.} bones - */ -var Tw2GeometryMeshBinding = exports.Tw2GeometryMeshBinding = function Tw2GeometryMeshBinding() { - _classCallCheck(this, Tw2GeometryMeshBinding); + var reader = new _reader.Tw2BinaryReader(new Uint8Array(data)); + var stringTable = ''; - this.mesh = null; - this.bones = []; -}; + /** + * ReadString + * @returns {string} + * @private + */ + function ReadString() { + var offset = reader.ReadUInt32(); + var end = offset; + while (stringTable.charCodeAt(end)) { + ++end; + } + return stringTable.substr(offset, end - offset); + } -/***/ }), -/* 125 */ -/***/ (function(module, exports, __webpack_require__) { + var version = reader.ReadUInt32(); + if (version < 2 || version > 7) { + _global.logger.log('res.error', { + log: 'error', + src: ['Tw2EffectRes', 'CreateProgram'], + msg: 'Invalid version of effect file', + type: 'shader.effectversion', + path: this.path, + value: version + }); -"use strict"; + this.PrepareFinished(false); + return; + } + var headerSize = void 0, + stringTableSize = void 0; -Object.defineProperty(exports, "__esModule", { - value: true -}); + if (version < 5) { + headerSize = reader.ReadUInt32(); + if (headerSize === 0) { + _global.logger.log('res.error', { + log: 'error', + src: ['Tw2EffectRes', 'CreateProgram'], + msg: 'File contains no compiled effects', + path: this.path, + type: 'shader.effectheadersize', + value: 0 + }); -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + this.PrepareFinished(false); + return; + } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + /* let permutation = */ + reader.ReadUInt32(); + var offset = reader.ReadUInt32(); + reader.cursor = 2 * 4 + headerSize * 3 * 4; + stringTableSize = reader.ReadUInt32(); + this.stringTableOffset = reader.cursor; + stringTable = String.fromCharCode.apply(null, reader.data.subarray(reader.cursor, reader.cursor + stringTableSize)); + reader.cursor = offset; + } else { + stringTableSize = reader.ReadUInt32(); + this.stringTableOffset = reader.cursor; + stringTable = String.fromCharCode.apply(null, reader.data.subarray(reader.cursor, reader.cursor + stringTableSize)); + reader.cursor += stringTableSize; + var permutationCount = reader.ReadUInt8(); + for (var perm = 0; perm < permutationCount; ++perm) { + var permutation = { + name: ReadString(), + defaultOption: reader.ReadUInt8(), + description: ReadString(), + type: reader.ReadUInt8(), + options: {}, + optionCount: reader.ReadUInt8() + }; + for (var j = 0; j < permutation.optionCount; ++j) { + permutation.options[ReadString()] = j; + } + this.permutations.push(permutation); + } -/** - * Tw2GeometryModel - * - * @property {string} name - * @property {Array.} meshBindings - * @property {Tw2GeometrySkeleton} skeleton - */ -var Tw2GeometryModel = exports.Tw2GeometryModel = function () { - function Tw2GeometryModel() { - _classCallCheck(this, Tw2GeometryModel); + headerSize = reader.ReadUInt32(); + if (headerSize === 0) { + _global.logger.log('res.error', { + log: 'error', + src: ['Tw2EffectRes', 'CreateProgram'], + msg: 'File contains no compiled effects', + path: this.path, + type: 'shader.effectheadersize', + value: 0 + }); - this.name = ''; - this.meshBindings = []; - this.skeleton = null; - } + this.PrepareFinished(false); + return; + } + for (var i = 0; i < headerSize; ++i) { + this.offsets.push({ + index: reader.ReadUInt32(), + offset: reader.ReadUInt32(), + size: reader.ReadUInt32() + }); + } + + reader.ReadUInt32(); + reader.cursor = reader.ReadUInt32(); + } + this.reader = reader; + this.version = version; + this.stringTable = stringTable; - /** - * Finds a bone by it's name - * @param {string} name - * @returns {Tw2GeometryBone|null} - */ + this.PrepareFinished(true); + } + /** + * Gets/creates a shader for the given permutation options + * + * @param {Object.} options - Permutation options + * @returns {Tw2Shader|null} + */ - _createClass(Tw2GeometryModel, [{ - key: 'FindBoneByName', - value: function FindBoneByName(name) { - if (!this.skeleton) { + }, { + key: 'GetShader', + value: function GetShader(options) { + if (!this.IsGood()) { return null; } - for (var i = 0; i < this.skeleton.bones.length; ++i) { - if (this.skeleton.bones[i].name === name) { - return this.skeleton.bones[i]; + var index = 0; + var multiplier = 1; + + for (var i = 0; i < this.permutations.length; ++i) { + var permutation = this.permutations[i]; + var value = permutation.defaultOption; + if (options.hasOwnProperty(permutation.name)) { + var valueName = options[permutation.name]; + if (!permutation.options.hasOwnProperty(valueName)) { + _global.logger.log('res.error', { + log: 'error', + src: ['Tw2EffectRes', 'GetShader'], + msg: 'Invalid shader permutation value', + path: this.path, + name: permutation.name, + value: valueName + }); + return null; + } + value = permutation.options[valueName]; } + index += value * multiplier; + multiplier *= permutation.optionCount; } - return null; + if (this.shaders.hasOwnProperty(index)) { + return this.shaders[index]; + } + + this.reader.cursor = this.offsets[index].offset; + var shader = null; + try { + shader = new _Tw2Shader.Tw2Shader(this.reader, this.version, this.stringTable, this.stringTableOffset); + } catch (error) { + return null; + } + this.shaders[index] = shader; + return shader; } }]); - return Tw2GeometryModel; -}(); + return Tw2EffectRes; +}(_Tw2Resource2.Tw2Resource); + +/** + * Request Response Type + * @type {string} + */ + + +Tw2EffectRes.prototype.requestResponseType = 'arraybuffer'; /***/ }), -/* 126 */ +/* 121 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -24579,365 +24301,524 @@ var Tw2GeometryModel = exports.Tw2GeometryModel = function () { Object.defineProperty(exports, "__esModule", { value: true }); +exports.Tw2Shader = undefined; + +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _global = __webpack_require__(0); + +var _vertex = __webpack_require__(9); + +var _sampler = __webpack_require__(21); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** - * Tw2GeometrySkeleton + * Tw2Shader * - * @property {Array.} bones + * @property {Object.} techniques + * @property {Object.} annotations + * @class */ -var Tw2GeometrySkeleton = exports.Tw2GeometrySkeleton = function Tw2GeometrySkeleton() { - _classCallCheck(this, Tw2GeometrySkeleton); +var Tw2Shader = exports.Tw2Shader = function () { + function Tw2Shader(reader, version, stringTable, stringTableOffset, path) { + _classCallCheck(this, Tw2Shader); - this.bones = []; -}; + /** + * ReadString + * @returns {string} + * @private + */ + function ReadString() { + var offset = reader.ReadUInt32(); + var end = offset; + while (stringTable.charCodeAt(end)) { + ++end; + } + return stringTable.substr(offset, end - offset); + } -/***/ }), -/* 127 */ -/***/ (function(module, exports, __webpack_require__) { + this.techniques = {}; + this.annotations = {}; -"use strict"; + var d = _global.device; + var techniqueCount = 1; + if (version > 6) { + techniqueCount = reader.ReadUInt8(); + } + for (var t = 0; t < techniqueCount; ++t) { + var technique = { + name: 'Main', + passes: [] + }; + if (version > 6) { + technique.name = ReadString(); + } + this.techniques[technique.name] = technique; -Object.defineProperty(exports, "__esModule", { - value: true -}); + var passCount = reader.ReadUInt8(); + for (var passIx = 0; passIx < passCount; ++passIx) { + var pass = {}; + pass.stages = [{}, {}]; + var stageCount = reader.ReadUInt8(); + var validShadowShader = true; -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + for (var stageIx = 0; stageIx < stageCount; ++stageIx) { + var stage = {}; + stage.inputDefinition = new _vertex.Tw2VertexDeclaration(); + stage.constants = []; + stage.textures = []; + stage.samplers = []; -/** - * Tw2GeometryTrackGroup - * - * @property {string} name - * @property {Tw2GeometryModel} model - * @property {Array.} transformTracks - */ -var Tw2GeometryTrackGroup = exports.Tw2GeometryTrackGroup = function Tw2GeometryTrackGroup() { - _classCallCheck(this, Tw2GeometryTrackGroup); + var stageType = reader.ReadUInt8(), + inputCount = reader.ReadUInt8(); - this.name = ''; - this.model = null; - this.transformTracks = []; -}; + for (var inputIx = 0; inputIx < inputCount; ++inputIx) { + var usage = reader.ReadUInt8(); + /* let registerIndex = */ + reader.ReadUInt8(); + var usageIndex = reader.ReadUInt8(); + /* let usedMask = */ + reader.ReadUInt8(); + stage.inputDefinition.elements[inputIx] = new _vertex.Tw2VertexElement(usage, usageIndex, 0); + } + stage.inputDefinition.RebuildHash(); -/***/ }), -/* 128 */ -/***/ (function(module, exports, __webpack_require__) { + var shaderSize = void 0, + shaderCode = void 0, + shadowShaderSize = void 0, + shadowShaderCode = void 0; -"use strict"; + if (version < 5) { + shaderSize = reader.ReadUInt32(); + shaderCode = reader.data.subarray(reader.cursor, reader.cursor + shaderSize); + reader.cursor += shaderSize; + shadowShaderSize = reader.ReadUInt32(); + shadowShaderCode = reader.data.subarray(reader.cursor, reader.cursor + shadowShaderSize); + reader.cursor += shadowShaderSize; + } else { + shaderSize = reader.ReadUInt32(); + var so = reader.ReadUInt32(); + shaderCode = stringTable.substr(so, shaderSize); + shadowShaderSize = reader.ReadUInt32(); + so = reader.ReadUInt32(); + shadowShaderCode = stringTable.substr(so, shadowShaderSize); + } -Object.defineProperty(exports, "__esModule", { - value: true -}); + stage.shader = Tw2Shader.CompileShader(stageType, '', shaderCode, path); + if (stage.shader === null) { + throw new Error(); + } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + if (validShadowShader) { + if (shadowShaderSize === 0) { + stage.shadowShader = Tw2Shader.CompileShader(stageType, '\n#define PS\n', shaderCode, path); + } else { + stage.shadowShader = Tw2Shader.CompileShader(stageType, '', shadowShaderCode, path); + } -/** - * Tw2GeometryTransformTrack - * - * @property {string} name - * @property {Tw2GeometryCurve} position - * @property {Tw2GeometryCurve} orientation - * @property scaleShear - */ -var Tw2GeometryTransformTrack = exports.Tw2GeometryTransformTrack = function Tw2GeometryTransformTrack() { - _classCallCheck(this, Tw2GeometryTransformTrack); + if (stage.shadowShader === null) { + validShadowShader = false; + } + } else { + stage.shadowShader = null; + } - this.name = ''; - this.position = null; - this.orientation = null; - this.scaleShear = null; -}; + if (version >= 3) { + reader.ReadUInt32(); + reader.ReadUInt32(); + reader.ReadUInt32(); + } -/***/ }), -/* 129 */ -/***/ (function(module, exports, __webpack_require__) { + stage.constantSize = 0; + var constantCount = reader.ReadUInt32(); + for (var constantIx = 0; constantIx < constantCount; ++constantIx) { + var constant = {}; + constant.name = ReadString(); + constant.offset = reader.ReadUInt32() / 4; + constant.size = reader.ReadUInt32() / 4; + constant.type = reader.ReadUInt8(); + constant.dimension = reader.ReadUInt8(); + constant.elements = reader.ReadUInt32(); + constant.isSRGB = reader.ReadUInt8(); + constant.isAutoregister = reader.ReadUInt8(); + stage.constants[constantIx] = constant; -"use strict"; + if (Tw2Shader.ConstantIgnore.includes(constant.name)) continue; + var last = constant.offset + constant.size; + if (last > stage.constantSize) stage.constantSize = last; + } -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2InstancedMesh = undefined; + var constantValueSize = reader.ReadUInt32() / 4; + stage.constantValues = new Float32Array(constantValueSize); + if (version < 5) { + for (var i = 0; i < constantValueSize; ++i) { + stage.constantValues[i] = reader.ReadFloat32(); + } + } else { + var co = reader.ReadUInt32(), + bo = reader.cursor; -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + reader.cursor = stringTableOffset + co; + for (var _i = 0; _i < constantValueSize; ++_i) { + stage.constantValues[_i] = reader.ReadFloat32(); + } + reader.cursor = bo; + } + stage.constantSize = Math.max(stage.constantSize, constantValueSize); -var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + var textureCount = reader.ReadUInt8(); + for (var textureIx = 0; textureIx < textureCount; ++textureIx) { + var texture = {}; + texture.registerIndex = reader.ReadUInt8(); + texture.name = ReadString(); + texture.type = reader.ReadUInt8(); + texture.isSRGB = reader.ReadUInt8(); + texture.isAutoregister = reader.ReadUInt8(); + stage.textures.push(texture); + } -var _Tw2ResMan = __webpack_require__(6); + var samplerCount = reader.ReadUInt8(); + for (var samplerIx = 0; samplerIx < samplerCount; ++samplerIx) { + var registerIndex = reader.ReadUInt8(), + samplerName = version >= 4 ? ReadString() : ''; -var _math = __webpack_require__(0); + reader.ReadUInt8(); // comparison -var _batch = __webpack_require__(20); + var minFilter = reader.ReadUInt8(), + magFilter = reader.ReadUInt8(), + mipFilter = reader.ReadUInt8(), + addressU = reader.ReadUInt8(), + addressV = reader.ReadUInt8(), + addressW = reader.ReadUInt8(); -var _Tw2Mesh2 = __webpack_require__(48); + reader.ReadFloat32(); // mipLODBias -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + var maxAnisotropy = reader.ReadUInt8(); -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + reader.ReadUInt8(); //comparisonFunc -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + var borderColor = _global.quat.create(); + borderColor[0] = reader.ReadFloat32(); + borderColor[1] = reader.ReadFloat32(); + borderColor[2] = reader.ReadFloat32(); + borderColor[3] = reader.ReadFloat32(); -/** - * Tw2InstancedMesh - * - * @property instanceGeometryResource - * @property {string} instanceGeometryResPath - * @property {number} instanceMeshIndex - * @property {vec3} minBounds - * @property {vec3} maxBounds - * @class - */ -var Tw2InstancedMesh = exports.Tw2InstancedMesh = function (_Tw2Mesh) { - _inherits(Tw2InstancedMesh, _Tw2Mesh); + reader.ReadFloat32(); //minLOD + reader.ReadFloat32(); //maxLOD - function Tw2InstancedMesh() { - _classCallCheck(this, Tw2InstancedMesh); + if (version < 4) reader.ReadUInt8(); - var _this = _possibleConstructorReturn(this, (Tw2InstancedMesh.__proto__ || Object.getPrototypeOf(Tw2InstancedMesh)).call(this)); + var sampler = new _sampler.Tw2SamplerState(); + sampler.registerIndex = registerIndex; + sampler.name = samplerName; - _this.instanceGeometryResource = null; - _this.instanceGeometryResPath = ''; - _this.instanceMeshIndex = 0; - _this.minBounds = _math.vec3.create(); - _this.maxBounds = _math.vec3.create(); - return _this; - } + if (minFilter === 1) { + switch (mipFilter) { + case 0: + sampler.minFilter = d.gl.NEAREST; + break; - /** - * Initializes the instanced mesh - */ + case 1: + sampler.minFilter = d.gl.NEAREST_MIPMAP_NEAREST; + break; + default: + sampler.minFilter = d.gl.NEAREST_MIPMAP_LINEAR; + } + sampler.minFilterNoMips = d.gl.NEAREST; + } else { + switch (mipFilter) { + case 0: + sampler.minFilter = d.gl.LINEAR; + break; - _createClass(Tw2InstancedMesh, [{ - key: 'Initialize', - value: function Initialize() { - _get(Tw2InstancedMesh.prototype.__proto__ || Object.getPrototypeOf(Tw2InstancedMesh.prototype), 'Initialize', this).call(this); - if (this.instanceGeometryResPath !== '') { - this.instanceGeometryResource = _Tw2ResMan.resMan.GetResource(this.instanceGeometryResPath); - } - } + case 1: + sampler.minFilter = d.gl.LINEAR_MIPMAP_NEAREST; + break; - /** - * Checks if the instances meshes' resources are good - * @returns {boolean} - */ + default: + sampler.minFilter = d.gl.LINEAR_MIPMAP_LINEAR; + } + sampler.minFilterNoMips = d.gl.LINEAR; + } - }, { - key: 'IsGood', - value: function IsGood() { - var instanced = this.instanceGeometryResource, - isResGood = _get(Tw2InstancedMesh.prototype.__proto__ || Object.getPrototypeOf(Tw2InstancedMesh.prototype), 'IsGood', this).call(this), - isInstancedResGood = !instanced ? false : instanced.IsGood ? instanced.IsGood() : true; + sampler.magFilter = magFilter === 1 ? d.gl.NEAREST : d.gl.LINEAR; + sampler.addressU = d.wrapModes[addressU]; + sampler.addressV = d.wrapModes[addressV]; + sampler.addressW = d.wrapModes[addressW]; - return isResGood && isInstancedResGood; - } + if (minFilter === 3 || magFilter === 3 || mipFilter === 3) { + sampler.anisotropy = Math.max(maxAnisotropy, 1); + } - /** - * Gets mesh resources - * @param {Array} [out=[]] - Optional receiving array - * @returns {Array.} [out] - */ + for (var n = 0; n < stage.textures.length; ++n) { + if (stage.textures[n].registerIndex === sampler.registerIndex) { + sampler.samplerType = stage.textures[n].type === 4 ? d.gl.TEXTURE_CUBE_MAP : d.gl.TEXTURE_2D; + sampler.isVolume = stage.textures[n].type === 3; + break; + } + } - }, { - key: 'GetResources', - value: function GetResources() { - var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + sampler.ComputeHash(); + stage.samplers.push(sampler); + } - _get(Tw2InstancedMesh.prototype.__proto__ || Object.getPrototypeOf(Tw2InstancedMesh.prototype), 'GetResources', this).call(this, out); - if (this.instanceGeometryResource && 'GetResources' in this.instanceGeometryResource) { - this.instanceGeometryResource.GetResources(out); - } - return out; - } + if (version >= 3) reader.ReadUInt8(); - /** - * RenderAreas - * @param {number} meshIx - * @param {number} start - * @param {number} count - * @param {Tw2Effect} effect - * @param {string} technique - */ + pass.stages[stageType] = stage; + } - }, { - key: 'RenderAreas', - value: function RenderAreas(meshIx, start, count, effect, technique) { - if (!this.IsGood()) return; + pass.states = []; + var stateCount = reader.ReadUInt8(); + for (var stateIx = 0; stateIx < stateCount; ++stateIx) { + var state = reader.ReadUInt32(), + value = reader.ReadUInt32(); - var buffer = this.instanceGeometryResource.GetInstanceBuffer(this.instanceMeshIndex); - if (buffer) { - this.geometryResource.RenderAreasInstanced(meshIx, start, count, effect, technique, buffer, this.instanceGeometryResource.GetInstanceDeclaration(this.instanceMeshIndex), this.instanceGeometryResource.GetInstanceStride(this.instanceMeshIndex), this.instanceGeometryResource.GetInstanceCount(this.instanceMeshIndex)); - } - } + pass.states.push({ + 'state': state, + 'value': value + }); + } - /** - * Gets area batches - * @param {Tw2InstancedMesh} mesh - * @param {Array.} areas - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator - * @param {Tw2PerObjectData} perObjectData - */ + pass.shaderProgram = Tw2Shader.CreateProgram(pass.stages[0].shader, pass.stages[1].shader, pass, path); + if (pass.shaderProgram === null) { + throw new Error(); + } - }], [{ - key: 'GetAreaBatches', - value: function GetAreaBatches(mesh, areas, mode, accumulator, perObjectData) { - for (var i = 0; i < areas.length; ++i) { - var area = areas[i]; - if (area.effect && area.display) { - var batch = new _batch.Tw2InstancedMeshBatch(); - batch.renderMode = mode; - batch.perObjectData = perObjectData; - batch.instanceMesh = mesh; - batch.meshIx = area.meshIndex; - batch.start = area.index; - batch.count = area.count; - batch.effect = area.effect; - accumulator.Commit(batch); + if (validShadowShader) { + pass.shadowShaderProgram = Tw2Shader.CreateProgram(pass.stages[0].shadowShader, pass.stages[1].shadowShader, pass, path); + if (pass.shadowShaderProgram === null) { + pass.shadowShaderProgram = pass.shaderProgram; + } + } else { + pass.shadowShaderProgram = pass.shaderProgram; } + + technique.passes[passIx] = pass; } } - }]); - - return Tw2InstancedMesh; -}(_Tw2Mesh2.Tw2Mesh); - -/***/ }), -/* 130 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; + var parameterCount = reader.ReadUInt16(); + for (var paramIx = 0; paramIx < parameterCount; ++paramIx) { + var name = ReadString(), + annotations = [], + annotationCount = reader.ReadUInt8(); + for (var annotationIx = 0; annotationIx < annotationCount; ++annotationIx) { + annotations[annotationIx] = {}; + annotations[annotationIx].name = ReadString(); + annotations[annotationIx].type = reader.ReadUInt8(); + switch (annotations[annotationIx].type) { + case 0: + annotations[annotationIx].value = reader.ReadUInt32() !== 0; + break; -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2MeshLineArea = undefined; + case 1: + annotations[annotationIx].value = reader.ReadInt32(); + break; -var _batch = __webpack_require__(20); + case 2: + annotations[annotationIx].value = reader.ReadFloat32(); + break; -var _Tw2MeshArea2 = __webpack_require__(49); + default: + annotations[annotationIx].value = ReadString(); + } + } + this.annotations[name] = annotations; + } + } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + /** + * Applies an Effect Pass + * @param {String} technique - technique name + * @param {number} pass - effect.passes index + */ -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + _createClass(Tw2Shader, [{ + key: 'ApplyPass', + value: function ApplyPass(technique, pass) { + var d = _global.device; + pass = this.techniques[technique].passes[pass]; -/** - * Tw2MeshLineArea - * - * @class - */ -var Tw2MeshLineArea = exports.Tw2MeshLineArea = function (_Tw2MeshArea) { - _inherits(Tw2MeshLineArea, _Tw2MeshArea); + for (var i = 0; i < pass.states.length; ++i) { + d.SetRenderState(pass.states[i].state, pass.states[i].value); + } - function Tw2MeshLineArea() { - _classCallCheck(this, Tw2MeshLineArea); + if (d.IsAlphaTestEnabled()) { + d.gl.useProgram(pass.shadowShaderProgram.program); + d.shadowHandles = pass.shadowShaderProgram; + } else { + d.gl.useProgram(pass.shaderProgram.program); + d.shadowHandles = null; + } + } - return _possibleConstructorReturn(this, (Tw2MeshLineArea.__proto__ || Object.getPrototypeOf(Tw2MeshLineArea)).call(this)); - } + /** + * Finds out if a parameter name is a valid shader input + * @param {string} name - An Effect Parameter name + * @returns {Boolean} + */ - return Tw2MeshLineArea; -}(_Tw2MeshArea2.Tw2MeshArea); + }, { + key: 'IsValidParameter', + value: function IsValidParameter(name) { + return name in this.annotations; + } -/** - * Render Batch Constructor - * @type {Tw2RenderBatch} - */ + /** + * Returns an array of valid parameter names for a specific annotation group + * - Compatible with pre V5 shaders + * @param {string} groupName - The name of an annotation group + * @returns {Array.< string >} + */ + }, { + key: 'GetParametersByGroup', + value: function GetParametersByGroup(groupName) { + var parameters = []; + for (var param in this.annotations) { + if (this.annotations.hasOwnProperty(param)) { + for (var i = 0; i < this.annotations[param].length; i++) { + if (this.annotations[param][i].name.toLowerCase() === 'group' && this.annotations[param][i].value.toLowerCase() === groupName.toLowerCase()) { + parameters.push(param); + } + } + } + } + return parameters; + } -Tw2MeshLineArea.batchType = _batch.Tw2GeometryLineBatch; + /** + * Compiles shader + * @param {number} stageType + * @param {string} prefix + * @param shaderCode + * @param {string} path - Shader path + * @returns {*} + */ -/***/ }), -/* 131 */ -/***/ (function(module, exports, __webpack_require__) { + }], [{ + key: 'CompileShader', + value: function CompileShader(stageType, prefix, shaderCode, path) { + var d = _global.device, + shader = d.gl.createShader(stageType === 0 ? d.gl.VERTEX_SHADER : d.gl.FRAGMENT_SHADER); -"use strict"; + if (d.ext.ShaderBinary) { + d.ext.ShaderBinary['shaderBinary'](shader, shaderCode); + } else { + var source = prefix + (_global.util.isString(shaderCode) ? shaderCode : String.fromCharCode.apply(null, shaderCode)); + source = source.substr(0, source.length - 1); + d.gl.shaderSource(shader, source); + d.gl.compileShader(shader); + } + if (!d.gl.getShaderParameter(shader, d.gl.COMPILE_STATUS)) { + _global.logger.log('res.error', { + log: 'error', + src: ['Tw2Shader', 'CompileShader'], + msg: 'Error compiling shader', + path: path, + type: 'shader.compile', + value: stageType === 0 ? 'VERTEX' : 'FRAGMENT', + data: _global.device.gl.getShaderInfoLog(shader) + }); + return null; + } + return shader; + } -Object.defineProperty(exports, "__esModule", { - value: true -}); + /** + * Creates shader program + * @param vertexShader + * @param fragmentShader + * @param pass + * @param {string} path - Shader path + * @returns {*} + */ -var _Tw2Animation = __webpack_require__(50); + }, { + key: 'CreateProgram', + value: function CreateProgram(vertexShader, fragmentShader, pass, path) { + var d = _global.device, + program = {}; -Object.keys(_Tw2Animation).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2Animation[key]; - } - }); -}); + program.program = d.gl.createProgram(); + d.gl.attachShader(program.program, vertexShader); + d.gl.attachShader(program.program, fragmentShader); + d.gl.linkProgram(program.program); -var _Tw2AnimationController = __webpack_require__(132); + if (!d.gl.getProgramParameter(program.program, d.gl.LINK_STATUS)) { + _global.logger.log('res.error', { + log: 'error', + src: ['Tw2Shader', 'CreateProgram'], + msg: 'Error linking shaders', + path: path, + type: 'shader.linkstatus', + data: _global.device.gl.getProgramInfoLog(program.program) + }); + return null; + } -Object.keys(_Tw2AnimationController).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2AnimationController[key]; - } - }); -}); + d.gl.useProgram(program.program); + program.constantBufferHandles = []; + for (var j = 0; j < 16; ++j) { + program.constantBufferHandles[j] = d.gl.getUniformLocation(program.program, 'cb' + j); + } -var _Tw2Bone = __webpack_require__(52); + program.samplerHandles = []; + for (var _j = 0; _j < 16; ++_j) { + program.samplerHandles[_j] = d.gl.getUniformLocation(program.program, 's' + _j); + d.gl.uniform1i(program.samplerHandles[_j], _j); + } -Object.keys(_Tw2Bone).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2Bone[key]; - } - }); -}); + for (var _j2 = 0; _j2 < 16; ++_j2) { + program.samplerHandles[_j2 + 12] = d.gl.getUniformLocation(program.program, 'vs' + _j2); + d.gl.uniform1i(program.samplerHandles[_j2 + 12], _j2 + 12); + } -var _Tw2Model = __webpack_require__(53); + program.input = new _vertex.Tw2VertexDeclaration(); + for (var _j3 = 0; _j3 < pass.stages[0].inputDefinition.elements.length; ++_j3) { + var location = d.gl.getAttribLocation(program.program, 'attr' + _j3); + if (location >= 0) { + var el = new _vertex.Tw2VertexElement(pass.stages[0].inputDefinition.elements[_j3].usage, pass.stages[0].inputDefinition.elements[_j3].usageIndex); + el.location = location; + program.input.elements.push(el); + } + } + program.input.RebuildHash(); -Object.keys(_Tw2Model).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2Model[key]; - } - }); -}); + program.shadowStateInt = d.gl.getUniformLocation(program.program, 'ssi'); + program.shadowStateFloat = d.gl.getUniformLocation(program.program, 'ssf'); + program.shadowStateYFlip = d.gl.getUniformLocation(program.program, 'ssyf'); + d.gl.uniform3f(program.shadowStateYFlip, 0, 0, 1); + program.volumeSlices = []; + for (var _j4 = 0; _j4 < pass.stages[1].samplers.length; ++_j4) { + if (pass.stages[1].samplers[_j4].isVolume) { + program.volumeSlices[pass.stages[1].samplers[_j4].registerIndex] = d.gl.getUniformLocation(program.program, 's' + pass.stages[1].samplers[_j4].registerIndex + 'sl'); + } + } + return program; + } + }]); -var _Tw2Track = __webpack_require__(54); + return Tw2Shader; +}(); -Object.keys(_Tw2Track).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2Track[key]; - } - }); -}); +/** + * Constant names that are ignored + * @type {string[]} + */ -var _Tw2TrackGroup = __webpack_require__(55); -Object.keys(_Tw2TrackGroup).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2TrackGroup[key]; - } - }); -}); +Tw2Shader.ConstantIgnore = ['PerFrameVS', 'PerObjectVS', 'PerFramePS', 'PerObjectPS']; /***/ }), -/* 132 */ +/* 122 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -24946,422 +24827,501 @@ Object.keys(_Tw2TrackGroup).forEach(function (key) { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2AnimationController = undefined; +exports.Tw2GeometryRes = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); -var _resource = __webpack_require__(28); +var _reader = __webpack_require__(26); -var _Tw2Animation = __webpack_require__(50); +var _vertex = __webpack_require__(9); -var _Tw2Bone = __webpack_require__(52); +var _Tw2Resource2 = __webpack_require__(8); -var _Tw2Model = __webpack_require__(53); +var _geometry = __webpack_require__(47); -var _Tw2Track = __webpack_require__(54); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var _Tw2TrackGroup = __webpack_require__(55); +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2AnimationController + * Tw2GeometryRes * - * @param {Tw2GeometryRes} [geometryResource] - * @property {Array.} geometryResources - * @property {Array.} models - * @property {Array.} animations - * @property {Array} meshBindings - * @property {boolean} loaded - * @property {boolean} update - * @property _geometryResource - * @property {Array} pendingCommands - * @property {Function} [onLoaded] an optional callback fired when any commands are cleared - * @class + * @property {Array} meshes + * @property {vec3} minBounds + * @property {vec3} maxBounds + * @property {vec3} boundsSpherePosition + * @property {number} boundsSphereRadius + * @property {Array} models + * @property {Array} animations + * @property {Boolean} systemMirror + * @inherit Tw2Resource */ -var Tw2AnimationController = exports.Tw2AnimationController = function () { - function Tw2AnimationController(geometryResource) { - _classCallCheck(this, Tw2AnimationController); +var Tw2GeometryRes = exports.Tw2GeometryRes = function (_Tw2Resource) { + _inherits(Tw2GeometryRes, _Tw2Resource); - this.geometryResources = []; - this.models = []; - this.animations = []; - this.meshBindings = []; - this.loaded = false; - this.update = true; - this.pendingCommands = []; - this.onPendingCleared = null; - this._geometryResource = null; + function Tw2GeometryRes() { + _classCallCheck(this, Tw2GeometryRes); - if (geometryResource) { - this.SetGeometryResource(geometryResource); - } + var _this = _possibleConstructorReturn(this, (Tw2GeometryRes.__proto__ || Object.getPrototypeOf(Tw2GeometryRes)).call(this)); + + _this.meshes = []; + _this.minBounds = _global.vec3.create(); + _this.maxBounds = _global.vec3.create(); + _this.boundsSpherePosition = _global.vec3.create(); + _this.boundsSphereRadius = 0; + _this.models = []; + _this.animations = []; + _this.systemMirror = false; + return _this; } /** - * Gets a loaded Tw2Animation by it's name - * @returns {?{ string: Tw2Animation}} an object containing animation names and animations, or null if not loaded + * GetInstanceBuffer + * @param {number} meshIndex + * @returns {*} */ - _createClass(Tw2AnimationController, [{ - key: 'GetAnimationsByName', - value: function GetAnimationsByName() { - if (!this.loaded) return null; + _createClass(Tw2GeometryRes, [{ + key: 'GetInstanceBuffer', + value: function GetInstanceBuffer(meshIndex) { + return meshIndex < this.meshes.length ? this.meshes[meshIndex].buffer : undefined; + } - var animations = {}; - for (var i = 0; i < this.animations.length; i++) { - animations[this.animations[i].animationRes.name] = this.animations[i]; - } - return animations; + /** + * GetInstanceDeclaration + * @param {number} meshIndex + * @returns {Tw2VertexDeclaration} + */ + + }, { + key: 'GetInstanceDeclaration', + value: function GetInstanceDeclaration(meshIndex) { + return this.meshes[meshIndex].declaration; } /** - * Gets a loaded Tw2Animation by it's name - * @param {String} name - * @returns {?Tw2Animation} Returns the animation if found + * GetInstanceStride + * @param {number} meshIndex + * @returns {number} */ }, { - key: 'GetAnimation', - value: function GetAnimation(name) { - for (var i = 0; i < this.animations.length; i++) { - if (this.animations[i].animationRes.name === name) { - return this.animations[i]; - } - } - return null; + key: 'GetInstanceStride', + value: function GetInstanceStride(meshIndex) { + return this.meshes[meshIndex].declaration.stride; } /** - * Resets a Tw2Animation by it's name - * @param {String} name - * @return {boolean} + * GetInstanceCount + * @param {number} meshIndex + * @returns {number} */ }, { - key: 'ResetAnimation', - value: function ResetAnimation(name) { - var animation = this.GetAnimation(name); - if (animation) { - animation.time = 0; - animation.isPlaying = false; - animation.callback = null; - return true; - } + key: 'GetInstanceCount', + value: function GetInstanceCount(meshIndex) { + return this.meshes[meshIndex].bufferLength * 4 / this.meshes[meshIndex].declaration.stride; } /** - * Plays a specific animation by it's name - * @param {string} name - Animation's Name - * @param {boolean} [cycle] - * @param {Function} [callback] - Optional callback which is fired once the animation has completed - * @return {boolean} + * Prepare + * @param data */ }, { - key: 'PlayAnimation', - value: function PlayAnimation(name, cycle, callback) { - if (this.animations.length === 0) { - this.pendingCommands.push({ - 'func': this.PlayAnimation, - 'args': [name, cycle, callback] - }); - return true; - } + key: 'Prepare', + value: function Prepare(data) { + var d = _global.device, + reader = new _reader.Tw2BinaryReader(new Uint8Array(data)); - var animation = this.GetAnimation(name); - if (animation) { - animation.time = 0; - animation.isPlaying = true; + /* let fileVersion = */ + reader.ReadUInt8(); + var meshCount = reader.ReadUInt8(); + for (var meshIx = 0; meshIx < meshCount; ++meshIx) { + var mesh = new _geometry.Tw2GeometryMesh(); + mesh.name = reader.ReadString(); + var buffer = Tw2GeometryRes.ReadVertexBuffer(reader, mesh.declaration); - if (typeof cycle !== 'undefined') { - animation.cycle = cycle; + if (buffer) { + mesh.bufferLength = buffer.length; + mesh.buffer = d.gl.createBuffer(); + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, mesh.buffer); + d.gl.bufferData(d.gl.ARRAY_BUFFER, buffer, d.gl.STATIC_DRAW); + } else { + mesh.buffer = null; } - if (callback) { - animation.callback = callback; + var indexes = Tw2GeometryRes.ReadIndexBuffer(reader); + if (indexes) { + mesh.indexes = d.gl.createBuffer(); + mesh.indexType = indexes.BYTES_PER_ELEMENT === 2 ? d.gl.UNSIGNED_SHORT : d.gl.UNSIGNED_INT; + d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); + d.gl.bufferData(d.gl.ELEMENT_ARRAY_BUFFER, indexes, d.gl.STATIC_DRAW); + } else { + mesh.indexes = null; } - return true; - } - } - - /** - * Plays a specific animation from a specific time - * @param {string} name - Animation's Name - * @param {number} from - Time to play from - * @param {boolean} [cycle] - * @param {Function} [callback] - Optional callback which is fired once the animation has completed - * @returns {boolean} - */ - - }, { - key: 'PlayAnimationFrom', - value: function PlayAnimationFrom(name, from, cycle, callback) { - if (this.animations.length === 0) { - this.pendingCommands.push({ - 'func': this.PlayAnimationFrom, - 'args': [name, from, cycle, callback] - }); - return true; - } + var areaCount = reader.ReadUInt8(); + for (var i = 0; i < areaCount; ++i) { + mesh.areas[i] = new _geometry.Tw2GeometryMeshArea(); + mesh.areas[i].name = reader.ReadString(); + mesh.areas[i].start = reader.ReadUInt32() * indexes.BYTES_PER_ELEMENT; + mesh.areas[i].count = reader.ReadUInt32() * 3; + mesh.areas[i].minBounds = _global.vec3.fromValues(reader.ReadFloat32(), reader.ReadFloat32(), reader.ReadFloat32()); + mesh.areas[i].maxBounds = _global.vec3.fromValues(reader.ReadFloat32(), reader.ReadFloat32(), reader.ReadFloat32()); + } - var animation = this.GetAnimation(name); - if (animation) { - animation.time = Math.max(Math.min(from, animation.animationRes.duration), 0); - animation.isPlaying = true; + var boneBindingCount = reader.ReadUInt8(); + mesh.boneBindings = []; + for (var _i = 0; _i < boneBindingCount; ++_i) { + mesh.boneBindings[_i] = reader.ReadString(); + } - if (typeof cycle !== 'undefined') { - animation.cycle = cycle; + var annotationSetCount = reader.ReadUInt16(); + if (annotationSetCount || this.systemMirror) { + mesh.bufferData = buffer; + mesh.indexData = indexes; } - if (callback) { - animation.callback = callback; + if (annotationSetCount) { + mesh.blendShapes = []; + for (var _i2 = 0; _i2 < annotationSetCount; ++_i2) { + mesh.blendShapes[_i2] = new _geometry.Tw2BlendShapeData(); + mesh.blendShapes[_i2].name = reader.ReadString(); + mesh.blendShapes[_i2].buffer = Tw2GeometryRes.ReadVertexBuffer(reader, mesh.blendShapes[_i2].declaration); + mesh.blendShapes[_i2].indexes = Tw2GeometryRes.ReadIndexBuffer(reader); + } } - return true; + this.meshes[meshIx] = mesh; } - } - /** - * Gets an array of all the currently playing animations by name - * @returns {Array} - */ + var modelCount = reader.ReadUInt8(); + for (var modelIx = 0; modelIx < modelCount; ++modelIx) { + var model = new _geometry.Tw2GeometryModel(); + model.name = reader.ReadString(); + model.skeleton = new _geometry.Tw2GeometrySkeleton(); + var boneCount = reader.ReadUInt8(); - }, { - key: 'GetPlayingAnimations', - value: function GetPlayingAnimations() { - var result = []; - for (var i = 0; i < this.animations.length; i++) { - if (this.animations[i].isPlaying) { - result.push(this.animations[i].animationRes.name); + for (var _i3 = 0; _i3 < boneCount; ++_i3) { + var bone = new _geometry.Tw2GeometryBone(); + bone.name = reader.ReadString(); + var flags = reader.ReadUInt8(); + bone.parentIndex = reader.ReadUInt8(); + if (bone.parentIndex === 255) bone.parentIndex = -1; + + if ((flags & 1) != 0) { + _global.vec3.set(bone.position, reader.ReadFloat32(), reader.ReadFloat32(), reader.ReadFloat32()); + } else { + _global.vec3.set(bone.position, 0, 0, 0); + } + + if ((flags & 2) != 0) { + _global.quat.set(bone.orientation, reader.ReadFloat32(), reader.ReadFloat32(), reader.ReadFloat32(), reader.ReadFloat32()); + } else { + _global.quat.identity(bone.orientation); + } + + if ((flags & 4) != 0) { + for (var k = 0; k < 9; ++k) { + bone.scaleShear[k] = reader.ReadFloat32(); + } + } else { + _global.mat3.identity(bone.scaleShear); + } + model.skeleton.bones[_i3] = bone; + } + + for (var _i4 = 0; _i4 < model.skeleton.bones.length; ++_i4) { + model.skeleton.bones[_i4].UpdateTransform(); + if (model.skeleton.bones[_i4].parentIndex !== -1) { + _global.mat4.multiply(model.skeleton.bones[_i4].worldTransform, model.skeleton.bones[model.skeleton.bones[_i4].parentIndex].worldTransform, model.skeleton.bones[_i4].localTransform); + } else { + _global.mat4.copy(model.skeleton.bones[_i4].worldTransform, model.skeleton.bones[_i4].localTransform); + } + _global.mat4.invert(model.skeleton.bones[_i4].worldTransformInv, model.skeleton.bones[_i4].worldTransform); } - } - return result; - } - - /** - * Stops an animation or an array of animations from playing - * @param {String| Array.} names - Animation Name, or Array of Animation Names - */ - }, { - key: 'StopAnimation', - value: function StopAnimation(names) { - if (this.animations.length === 0) { - this.pendingCommands.push({ - 'func': this.StopAnimation, - 'args': names - }); - return; + var meshBindingCount = reader.ReadUInt8(); + for (var _i5 = 0; _i5 < meshBindingCount; ++_i5) { + var _mesh = reader.ReadUInt8(); + if (_mesh < this.meshes.length) { + Tw2GeometryRes.BindMeshToModel(this.meshes[_mesh], model, this); + } + } + this.models[this.models.length] = model; } - if (typeof names === 'string' || names instanceof String) { - names = [names]; - } + var animationCount = reader.ReadUInt8(); + for (var _i6 = 0; _i6 < animationCount; ++_i6) { + var animation = new _geometry.Tw2GeometryAnimation(); + animation.name = reader.ReadString(); + animation.duration = reader.ReadFloat32(); + var groupCount = reader.ReadUInt8(); + for (var j = 0; j < groupCount; ++j) { + var group = new _geometry.Tw2GeometryTrackGroup(); + group.name = reader.ReadString(); + for (var m = 0; m < this.models.length; ++m) { + if (this.models[m].name === group.name) { + group.model = this.models[m]; + break; + } + } - var toStop = {}; - for (var n = 0; n < names.length; n++) { - toStop[names[n]] = true; - } + var transformTrackCount = reader.ReadUInt8(); + for (var _k = 0; _k < transformTrackCount; ++_k) { + var track = new _geometry.Tw2GeometryTransformTrack(); + track.name = reader.ReadString(); + track.orientation = Tw2GeometryRes.ReadCurve(reader); + track.position = Tw2GeometryRes.ReadCurve(reader); + track.scaleShear = Tw2GeometryRes.ReadCurve(reader); - for (var i = 0; i < this.animations.length; ++i) { - if (this.animations[i].animationRes.name in toStop) { - this.animations[i].isPlaying = false; + if (track.orientation) { + var lastX = 0; + var lastY = 0; + var lastZ = 0; + var lastW = 0; + for (var n = 0; n < track.orientation.controls.length; n += 4) { + var x = track.orientation.controls[n]; + var y = track.orientation.controls[n + 1]; + var z = track.orientation.controls[n + 2]; + var w = track.orientation.controls[n + 3]; + if (lastX * x + lastY * y + lastZ * z + lastW * w < 0) { + track.orientation.controls[n] = -x; + track.orientation.controls[n + 1] = -y; + track.orientation.controls[n + 2] = -z; + track.orientation.controls[n + 3] = -w; + } + lastX = x; + lastY = y; + lastZ = z; + lastW = w; + } + } + group.transformTracks[group.transformTracks.length] = track; + } + animation.trackGroups[animation.trackGroups.length] = group; } + this.animations[this.animations.length] = animation; } + + this.PrepareFinished(true); } /** - * Stops all animations from playing + * BindMeshToModel + * @param {Tw2GeometryMesh} mesh + * @param {Tw2GeometryModel} model + * @param {Tw2GeometryRes} res */ }, { - key: 'StopAllAnimations', - value: function StopAllAnimations() { - if (this.animations.length === 0) { - this.pendingCommands.push({ - 'func': this.StopAllAnimations, - 'args': null - }); - return; - } + key: 'RenderAreasInstanced', - for (var i = 0; i < this.animations.length; ++i) { - this.animations[i].isPlaying = false; - } - } /** - * Stops all but the supplied list of animations - * @param {String| Array.} names - Animation Names + * RenderAreasInstanced + * @param {number} meshIx + * @param {number} start + * @param {number} count + * @param {Tw2Effect} effect + * @param {string} technique + * @param instanceVB + * @param instanceDecl + * @param instanceStride + * @param instanceCount + * @returns {Boolean} */ + value: function RenderAreasInstanced(meshIx, start, count, effect, technique, instanceVB, instanceDecl, instanceStride, instanceCount) { + this.KeepAlive(); + if (!this.IsGood() || !effect.IsGood() || meshIx >= this.meshes.length) return false; - }, { - key: 'StopAllAnimationsExcept', - value: function StopAllAnimationsExcept(names) { - if (this.animations.length === 0) { - this.pendingCommands.push({ - 'func': this.StopAllAnimationsExcept, - 'args': names - }); - return; - } + var d = _global.device, + mesh = this.meshes[meshIx], + passCount = effect.GetPassCount(technique); - if (typeof names === 'string' || names instanceof String) { - names = [names]; - } + d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); - var keepAnimating = {}; - for (var n = 0; n < names.length; n++) { - keepAnimating[names[n]] = true; - } + for (var pass = 0; pass < passCount; ++pass) { + effect.ApplyPass(technique, pass); + var passInput = effect.GetPassInput(technique, pass); + if (passInput.elements.length === 0) continue; - for (var i = 0; i < this.animations.length; ++i) { - if (!(this.animations[i].animationRes.name in keepAnimating)) { - this.animations[i].isPlaying = false; + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, mesh.buffer); + mesh.declaration.SetPartialDeclaration(passInput, mesh.declaration.stride); + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, instanceVB); + var resetData = instanceDecl.SetPartialDeclaration(passInput, instanceStride, 8, 1); + d.ApplyShadowState(); + + for (var i = 0; i < count; ++i) { + if (i + start < mesh.areas.length) { + var area = mesh.areas[i + start], + areaStart = area.start, + acount = area.count; + + while (i + 1 < count) { + area = mesh.areas[i + 1 + start]; + if (area.start !== areaStart + acount * 2) break; + acount += area.count; + ++i; + } + d.ext.drawElementsInstanced(d.gl.TRIANGLES, acount, mesh.indexType, areaStart, instanceCount); + } } + instanceDecl.ResetInstanceDivisors(resetData); } + return true; } /** - * Clears any existing resources and loads the supplied geometry resource - * @param {Tw2GeometryRes} geometryResource + * RenderAreas + * @param {number} meshIx + * @param {number} start + * @param {number} count + * @param {Tw2Effect} effect + * @param {string} technique + * @returns {Boolean} */ }, { - key: 'SetGeometryResource', - value: function SetGeometryResource(geometryResource) { - this.models = []; - this.animations = []; - this.meshBindings = []; + key: 'RenderAreas', + value: function RenderAreas(meshIx, start, count, effect, technique) { + this.KeepAlive(); + if (!this.IsGood() || !effect.IsGood() || meshIx >= this.meshes.length) return false; - for (var i = 0; i < this.geometryResources.length; ++i) { - this.geometryResources[i].UnregisterNotification(this); - } + var d = _global.device, + mesh = this.meshes[meshIx] || this.meshes[0], + passCount = effect.GetPassCount(technique); - this.loaded = false; - this.geometryResources = []; + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, mesh.buffer); + d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); - if (geometryResource) { - this.geometryResources.push(geometryResource); - geometryResource.RegisterNotification(this); - } - } + for (var pass = 0; pass < passCount; ++pass) { + effect.ApplyPass(technique, pass); + var passInput = effect.GetPassInput(technique, pass); + if (!mesh.declaration.SetDeclaration(passInput, mesh.declaration.stride)) { + _global.logger.log('res.error', { + log: 'error', + src: ['Tw2GeometryRes', 'RenderLines'], + msg: 'Error binding mesh to effect', + path: this.path, + type: 'geometry.meshbind', + data: { + pass: pass, + passInput: passInput, + meshStride: mesh.declaration.stride + } + }); + return false; + } - /** - * Adds a Geometry Resource - * @param {Tw2GeometryRes} geometryResource - */ + d.ApplyShadowState(); - }, { - key: 'AddGeometryResource', - value: function AddGeometryResource(geometryResource) { - for (var i = 0; i < this.geometryResources.length; ++i) { - if (this.geometryResources[i] === geometryResource) { - return; + for (var i = 0; i < count; ++i) { + if (i + start < mesh.areas.length) { + var area = mesh.areas[i + start], + areaStart = area.start, + acount = area.count; + + while (i + 1 < count) { + area = mesh.areas[i + 1 + start]; + if (area.start !== areaStart + acount * 2) break; + acount += area.count; + ++i; + } + d.gl.drawElements(d.gl.TRIANGLES, acount, mesh.indexType, areaStart); + } } } - this.geometryResources.push(geometryResource); - geometryResource.RegisterNotification(this); + return true; } /** - * Adds animations from a resource - * @param {Tw2GeometryRes} resource + * RenderLines + * @param {number} meshIx + * @param {number} start + * @param {number} count + * @param {Tw2Effect} effect + * @param {string} technique + * @returns {Boolean} */ }, { - key: 'AddAnimationsFromRes', - value: function AddAnimationsFromRes(resource) { - for (var i = 0; i < resource.animations.length; ++i) { - var animation = null; - for (var j = 0; j < this.animations.length; ++j) { - if (this.animations[j].animationRes === resource.animations[i]) { - animation = this.animations[i]; - break; - } - } + key: 'RenderLines', + value: function RenderLines(meshIx, start, count, effect, technique) { + this.KeepAlive(); + if (!this.IsGood() || !effect.IsGood() || meshIx >= this.meshes.length) return false; - if (!animation) { - animation = new _Tw2Animation.Tw2Animation(); - animation.animationRes = resource.animations[i]; - this.animations.push(animation); - } + var d = _global.device, + mesh = this.meshes[meshIx], + passCount = effect.GetPassCount(technique); - for (var _j = 0; _j < animation.animationRes.trackGroups.length; ++_j) { - var found = false; - for (var k = 0; k < animation.trackGroups.length; ++k) { - if (animation.trackGroups[k].trackGroupRes === animation.animationRes.trackGroups[_j]) { - found = true; - break; + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, mesh.buffer); + d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); + + for (var pass = 0; pass < passCount; ++pass) { + effect.ApplyPass(technique, pass); + var passInput = effect.GetPassInput(technique, pass); + if (!mesh.declaration.SetDeclaration(passInput, mesh.declaration.stride)) { + _global.logger.log('res.error', { + log: 'error', + src: ['Tw2GeometryRes', 'RenderLines'], + msg: 'Error binding mesh to effect', + path: this.path, + type: 'geometry.meshbind', + data: { + pass: pass, + passInput: passInput, + meshStride: mesh.declaration.stride } - } + }); + return false; + } - if (found) { - continue; - } + d.ApplyShadowState(); - var model = null; - for (var _k = 0; _k < this.models.length; ++_k) { - if (this.models[_k].modelRes.name === animation.animationRes.trackGroups[_j].name) { - model = this.models[_k]; - break; - } - } + for (var i = 0; i < count; ++i) { + if (i + start < mesh.areas.length) { + var area = mesh.areas[i + start], + areaStart = area.start, + acount = area.count; - if (model !== null) { - var group = new _Tw2TrackGroup.Tw2TrackGroup(); - group.trackGroupRes = animation.animationRes.trackGroups[_j]; - for (var _k2 = 0; _k2 < group.trackGroupRes.transformTracks.length; ++_k2) { - for (var m = 0; m < model.bones.length; ++m) { - if (model.bones[m].boneRes.name === group.trackGroupRes.transformTracks[_k2].name) { - var track = new _Tw2Track.Tw2Track(); - track.trackRes = group.trackGroupRes.transformTracks[_k2]; - track.bone = model.bones[m]; - group.transformTracks.push(track); - break; - } - } + while (i + 1 < count) { + area = mesh.areas[i + 1 + start]; + if (area.start !== areaStart + acount * 2) break; + acount += area.count; + ++i; } - animation.trackGroups.push(group); + d.gl.drawElements(d.gl.LINES, acount, mesh.indexType, areaStart); } } } + return true; } /** - * Resets the bone transforms + * RenderDebugInfo + * @param {function} debugHelper + * @returns {Boolean} */ }, { - key: 'ResetBoneTransforms', - value: function ResetBoneTransforms() { - for (var i = 0; i < this.models.length; ++i) { - for (var j = 0; j < this.models[i].bones.length; ++j) { - var bone = this.models[i].bones[j], - boneRes = bone.boneRes; - - _math.mat4.copy(bone.localTransform, boneRes.localTransform); - - if (boneRes.parentIndex !== -1) { - _math.mat4.multiply(bone.worldTransform, bone.localTransform, this.models[i].bones[bone.boneRes.parentIndex].worldTransform); - } else { - _math.mat4.set(bone.worldTransform, bone.localTransform); - } - _math.mat4.identity(bone.offsetTransform); - } - } + key: 'RenderDebugInfo', + value: function RenderDebugInfo(debugHelper) { + if (!this.IsGood()) return false; - var id = _math.mat4.identity(Tw2AnimationController.scratch.mat4_0); - for (var _i = 0; _i < this.meshBindings.length; ++_i) { - for (var _j2 = 0; _j2 < this.meshBindings[_i].length; ++_j2) { - for (var k = 0; k * 16 < this.meshBindings[_i][_j2].length; ++k) { - for (var m = 0; m < 16; ++m) { - this.meshBindings[_i][_j2][k * 16 + m] = id[m]; + for (var i = 0; i < this.models.length; ++i) { + if (this.models[i].skeleton) { + for (var j = 0; j < this.models[i].skeleton.bones.length; ++j) { + var b0 = this.models[i].skeleton.bones[j]; + if (b0.parentIndex >= 0) { + var b1 = this.models[i].skeleton.bones[b0.parentIndex]; + debugHelper['AddLine']([b0.worldTransform[12], b0.worldTransform[13], b0.worldTransform[14]], [b1.worldTransform[12], b1.worldTransform[13], b1.worldTransform[14]], [0, 0.7, 0, 1], [0, 0.7, 0, 1]); } } } @@ -25369,400 +25329,561 @@ var Tw2AnimationController = exports.Tw2AnimationController = function () { } /** - * GetBoneMatrices - * @param {number} meshIndex - * @param {Tw2GeometryRes} [geometryResource=this.geometryResources[0]] - * @returns {Float32Array} + * Unloads webgl and javascript resources + * @returns {Boolean} */ }, { - key: 'GetBoneMatrices', - value: function GetBoneMatrices(meshIndex, geometryResource) { - if (this.geometryResources.length === 0) { - return new Float32Array(); - } + key: 'Unload', + value: function Unload() { + for (var i = 0; i < this.meshes.length; ++i) { + if (this.meshes[i].buffer) { + _global.device.gl.deleteBuffer(this.meshes[i].buffer); + this.meshes[i].buffer = null; + } - if (!geometryResource) { - geometryResource = this.geometryResources[0]; + if (this.meshes[i].indexes) { + _global.device.gl.deleteBuffer(this.meshes[i].indexes); + this.meshes[i].indexes = null; + } } - var meshBindings = Tw2AnimationController.FindMeshBindings(this, geometryResource); - if (meshBindings && meshIndex < meshBindings.length) { - return meshBindings[meshIndex]; - } - return new Float32Array(); + this._isPurged = true; + this._isGood = false; + return true; } /** - * FindModelForMesh - * @param {number} meshIndex - * @param {Tw2GeometryRes} [geometryResource=this.geometryResources[0]] - * @returns {Tw2Model|null} Returns the Tw2Model for the mesh if found and is good, else returns null + * ReadVertexBuffer + * @param {Tw2BinaryReader} reader + * @param {Tw2VertexDeclaration} declaration + * @returns {?Float32Array} */ + }], [{ + key: 'BindMeshToModel', + value: function BindMeshToModel(mesh, model, res) { + var binding = new _geometry.Tw2GeometryMeshBinding(); + binding.mesh = mesh; + for (var b = 0; b < binding.mesh.boneBindings.length; ++b) { + var name = binding.mesh.boneBindings[b], + bone = model.FindBoneByName(name); + + if (!bone) { + _global.logger.log('res.error', { + log: 'error', + src: ['Tw2GeometryRes', 'BindMeshToModel'], + msg: 'Mesh has invalid bone name for model', + path: res.path, + type: 'geometry.invalidbone', + data: { + mesh: binding.mesh.name, + bone: name, + model: model.name + } + }); + } else { + binding.bones[binding.bones.length] = bone; + } + } + model.meshBindings[model.meshBindings.length] = binding; + } }, { - key: 'FindModelForMesh', - value: function FindModelForMesh(meshIndex, geometryResource) { - if (this.geometryResources.length === 0) { - return null; + key: 'ReadVertexBuffer', + value: function ReadVertexBuffer(reader, declaration) { + var declCount = reader.ReadUInt8(); + var vertexSize = 0; + + for (var declIx = 0; declIx < declCount; ++declIx) { + var element = new _vertex.Tw2VertexElement(); + element.usage = reader.ReadUInt8(); + element.usageIndex = reader.ReadUInt8(); + element.fileType = reader.ReadUInt8(); + element.type = _global.device.gl.FLOAT; + element.elements = (element.fileType >> 5) + 1; + element.offset = vertexSize * 4; + declaration.elements[declIx] = element; + vertexSize += element.elements; } + declaration.RebuildHash(); + declaration.stride = vertexSize * 4; + + var vertexCount = reader.ReadUInt32(); + if (vertexCount === 0) return null; + + var buffer = new Float32Array(vertexSize * vertexCount); + var index = 0; + for (var vtxIx = 0; vtxIx < vertexCount; ++vtxIx) { + for (var _declIx = 0; _declIx < declCount; ++_declIx) { + var el = declaration.elements[_declIx]; + switch (el.fileType & 0xf) { + case 0: + if ((el.fileType & 0x10) != 0) { + for (var i = 0; i < el.elements; ++i) { + buffer[index++] = reader.ReadInt8() / 127.0; + } + } else { + for (var _i7 = 0; _i7 < el.elements; ++_i7) { + buffer[index++] = reader.ReadInt8(); + } + } + break; + + case 1: + if ((el.fileType & 0x10) != 0) { + for (var _i8 = 0; _i8 < el.elements; ++_i8) { + buffer[index++] = reader.ReadInt8() / 32767.0; + } + } else { + for (var _i9 = 0; _i9 < el.elements; ++_i9) { + buffer[index++] = reader.ReadInt16(); + } + } + break; + + case 2: + for (var _i10 = 0; _i10 < el.elements; ++_i10) { + buffer[index++] = reader.ReadInt32(); + } + break; + + case 3: + for (var _i11 = 0; _i11 < el.elements; ++_i11) { + buffer[index++] = reader.ReadFloat16(); + } + break; + + case 4: + for (var _i12 = 0; _i12 < el.elements; ++_i12) { + buffer[index++] = reader.ReadFloat32(); + } + break; + + case 8: + if ((el.fileType & 0x10) != 0) { + for (var _i13 = 0; _i13 < el.elements; ++_i13) { + buffer[index++] = reader.ReadUInt8() / 255.0; + } + } else { + for (var _i14 = 0; _i14 < el.elements; ++_i14) { + buffer[index++] = reader.ReadUInt8(); + } + } + break; - if (!geometryResource) { - geometryResource = this.geometryResources[0]; - } + case 9: + if ((el.fileType & 0x10) != 0) { + for (var _i15 = 0; _i15 < declaration.elements[_declIx].elements; ++_i15) { + buffer[index++] = reader.ReadUInt8() / 65535.0; + } + } else { + for (var _i16 = 0; _i16 < el.elements; ++_i16) { + buffer[index++] = reader.ReadUInt16(); + } + } + break; - if (!geometryResource.IsGood()) { - return null; - } + case 10: + for (var _i17 = 0; _i17 < el.elements; ++_i17) { + buffer[index++] = reader.ReadUInt32(); + } + break; - var mesh = geometryResource.meshes[meshIndex]; - for (var i = 0; i < this.models.length; ++i) { - for (var j = 0; j < this.models[i].modelRes.meshBindings.length; ++i) { - if (this.models[i].modelRes.meshBindings[j].mesh === mesh) { - return this.models[i]; + default: + _global.logger.log('res.error', { + log: 'error', + src: ['Tw2GeometryRes', 'ReadVertexBuffer'], + msg: 'Error loading wbg data', + path: self.path, + type: 'geometry.filetype', + value: el.fileType & 0xf + }); + throw 1; } } } - return null; + return buffer; } /** - * Gets all animation controller res objects - * @param {Array} [out=[]] - Optional receiving array - * @returns {Array.} [out] + * ReadIndexBuffer + * @property {Tw2BinaryReader} + * @returns {Uint16Array|Uint32Array} + * @private */ }, { - key: 'GetResources', - value: function GetResources() { - var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + key: 'ReadIndexBuffer', + value: function ReadIndexBuffer(reader) { + var ibType = reader.ReadUInt8(), + indexCount = reader.ReadUInt32(); - for (var i = 0; i < this.geometryResources.length; i++) { - if (!out.includes(this.geometryResources[i])) { - out.push(this.geometryResources[i]); + if (ibType === 0) { + var indexes = new Uint16Array(indexCount); + for (var i = 0; i < indexCount; ++i) { + indexes[i] = reader.ReadUInt16(); + } + return indexes; + } else { + var _indexes = new Uint32Array(indexCount); + for (var _i18 = 0; _i18 < indexCount; ++_i18) { + _indexes[_i18] = reader.ReadUInt32(); } + return _indexes; } - return out; } /** - * Rebuilds the cached data for a resource (unless it doesn't exist or is already good) - * @param {Tw2GeometryRes} resource + * ReadCurve + * @returns {Tw2GeometryCurve} */ }, { - key: 'RebuildCachedData', - value: function RebuildCachedData(resource) { - var found = false; - for (var i = 0; i < this.geometryResources.length; ++i) { - if (this.geometryResources[i] === resource) { - found = true; - break; - } - } - - if (!found) { - return; - } + key: 'ReadCurve', + value: function ReadCurve(reader) { + var type = reader.ReadUInt8(); + if (type === 0) return null; - for (var _i2 = 0; _i2 < this.geometryResources.length; ++_i2) { - if (!this.geometryResources[_i2].IsGood()) { - return; - } + var curve = new _geometry.Tw2GeometryCurve(); + curve.dimension = reader.ReadUInt8(); + curve.degree = reader.ReadUInt8(); + var knotCount = reader.ReadUInt32(); + curve.knots = new Float32Array(knotCount); + for (var i = 0; i < knotCount; ++i) { + curve.knots[i] = reader.ReadFloat32(); } - - for (var _i3 = 0; _i3 < this.geometryResources.length; ++_i3) { - Tw2AnimationController.DoRebuildCachedData(this, this.geometryResources[_i3]); + var controlCount = reader.ReadUInt32(); + curve.controls = new Float32Array(controlCount); + for (var _i19 = 0; _i19 < controlCount; ++_i19) { + curve.controls[_i19] = reader.ReadFloat32(); } + return curve; } + }]); - /** - * Internal render/update function which is called every frame - * @param {number} dt - Delta Time - */ + return Tw2GeometryRes; +}(_Tw2Resource2.Tw2Resource); - }, { - key: 'Update', - value: function Update(dt) { - if (!this.models || !this.update) { - return; - } +/** + * Request Response Type + * @type {string} + */ - for (var i = 0; i < this.geometryResources.length; ++i) { - this.geometryResources[i].KeepAlive(); - } - var g = Tw2AnimationController.scratch, - rotationMat = g.mat4_0, - orientation = g.quat_0, - position = g.vec3_0, - scale = g.mat3_0; +Tw2GeometryRes.prototype.requestResponseType = 'arraybuffer'; - //var updateBones = false; - for (var _i4 = 0; _i4 < this.animations.length; ++_i4) { - var animation = this.animations[_i4]; - if (animation.isPlaying) { - var res = animation.animationRes; - animation.time += dt * animation.timeScale; - if (animation.time > res.duration) { - if (animation.callback) { - animation.callback(this, animation); - } +/***/ }), +/* 123 */ +/***/ (function(module, exports, __webpack_require__) { - if (animation.cycle) { - animation.time = animation.time % res.duration; - } else { - animation.isPlaying = false; - animation.time = res.duration; - } - } +"use strict"; - for (var j = 0; j < animation.trackGroups.length; ++j) { - for (var k = 0; k < animation.trackGroups[j].transformTracks.length; ++k) { - var track = animation.trackGroups[j].transformTracks[k]; - if (track.trackRes.position) { - _math.curve.evaluate(track.trackRes.position, animation.time, position, animation.cycle, res.duration); - } else { - position[0] = position[1] = position[2] = 0; - } - if (track.trackRes.orientation) { - _math.curve.evaluate(track.trackRes.orientation, animation.time, orientation, animation.cycle, res.duration); - _math.quat.normalize(orientation, orientation); - } else { - _math.quat.identity(orientation); - } - if (track.trackRes.scaleShear) { - _math.curve.evaluate(track.trackRes.scaleShear, animation.time, scale, animation.cycle, res.duration); - } else { - _math.mat3.identity(scale); - } - _math.mat4.fromMat3(track.bone.localTransform, scale); - _math.mat4.multiply(track.bone.localTransform, track.bone.localTransform, _math.mat4.fromQuat(rotationMat, orientation)); - track.bone.localTransform[12] = position[0]; - track.bone.localTransform[13] = position[1]; - track.bone.localTransform[14] = position[2]; - } - } - } - } +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2VideoRes = undefined; - for (var _i5 = 0; _i5 < this.models.length; ++_i5) { - for (var _j3 = 0; _j3 < this.models[_i5].bones.length; ++_j3) { - var bone = this.models[_i5].bones[_j3]; - if (bone.boneRes.parentIndex !== -1) { - _math.mat4.multiply(bone.worldTransform, this.models[_i5].bones[bone.boneRes.parentIndex].worldTransform, bone.localTransform); - } else { - _math.mat4.copy(bone.worldTransform, bone.localTransform); - } - _math.mat4.multiply(bone.offsetTransform, bone.worldTransform, bone.boneRes.worldTransformInv); - if (bone.bindingArrays) { - for (var a = 0; a < bone.bindingArrays.length; ++a) { - bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 0] = bone.offsetTransform[0]; - bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 1] = bone.offsetTransform[4]; - bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 2] = bone.offsetTransform[8]; - bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 3] = bone.offsetTransform[12]; +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 4] = bone.offsetTransform[1]; - bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 5] = bone.offsetTransform[5]; - bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 6] = bone.offsetTransform[9]; - bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 7] = bone.offsetTransform[13]; +var _global = __webpack_require__(0); - bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 8] = bone.offsetTransform[2]; - bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 9] = bone.offsetTransform[6]; - bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 10] = bone.offsetTransform[10]; - bone.bindingArrays[a].array[bone.bindingArrays[a].offset + 11] = bone.offsetTransform[14]; - } - } - } - } +var _Tw2Resource2 = __webpack_require__(8); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +/** + * Tw2VideoRes + * + * @property {?WebGLTexture} texture - The video's webgl texture + * @property {?HTMLVideoElement} video - The video + * @property {number} width - The texture's width + * @property {number} height - The texture's height + * @property {boolean} cycle - Enables video looping + * @property {boolean} playOnLoad - Plays the video as soon as it is able to + * @property {number} _currentSampler - The current sampler's hash + * @property {number} _currentTime - The video's current time + * @property {boolean} _playable - Identifies if the video is playable + * @property {boolean} _isPlaying - Identifies if the video is playing + * @property {?Function} _onPlaying - An optional callback which is fired when the video is playing + * @property {?Function} _onPause - An optional callback which is fired when the video is paused + * @property {?Function} _onEnded - An optional callback which is fired when the video has ended + * @class + */ +var Tw2VideoRes = exports.Tw2VideoRes = function (_Tw2Resource) { + _inherits(Tw2VideoRes, _Tw2Resource); + + function Tw2VideoRes() { + _classCallCheck(this, Tw2VideoRes); + + var _this = _possibleConstructorReturn(this, (Tw2VideoRes.__proto__ || Object.getPrototypeOf(Tw2VideoRes)).call(this)); + + _this.texture = null; + _this.video = null; + _this.width = 0; + _this.height = 0; + _this.cycle = true; + _this.playOnLoad = true; + + _this._currentSampler = 0; + _this._currentTime = -1; + _this._playable = false; + _this._isPlaying = false; + + _this._onPlaying = null; + _this._onPause = null; + _this._onEnded = null; + return _this; + } + + /** + * Checks if the resource is good + * @returns {boolean} + */ + + + _createClass(Tw2VideoRes, [{ + key: 'IsGood', + value: function IsGood() { + this.KeepAlive(); + return this._isGood && this.video && this._playable; } /** - * RenderDebugInfo - * TODO: Fix commented out code - * @param {function} debugHelper + * Keeps the resource alive */ }, { - key: 'RenderDebugInfo', - value: function RenderDebugInfo(debugHelper) { - /*for (var i = 0; i < this.geometryResources.length; ++i) - { - this.geometryResources[i].RenderDebugInfo(debugHelper); - }*/ - for (var i = 0; i < this.models.length; ++i) { - for (var j = 0; j < this.models[i].bones.length; ++j) { - var b0 = this.models[i].bones[j]; - if (b0.boneRes.parentIndex >= 0) { - var b1 = this.models[i].bones[b0.boneRes.parentIndex]; - debugHelper['AddLine']([b0.worldTransform[12], b0.worldTransform[13], b0.worldTransform[14]], [b1.worldTransform[12], b1.worldTransform[13], b1.worldTransform[14]]); - } - } - } + key: 'KeepAlive', + value: function KeepAlive() { + this.activeFrame = _global.resMan.activeFrame; } /** - * Adds a model resource to an animation controller - * @param {Tw2AnimationController} animationController - * @param {Tw2GeometryModel} modelRes - * @returns {null|Tw2Model} Returns a newly created Tw2Model if the model resource doesn't already exist, and null if it does + * Plays the animation + * @param {boolean} [cycle] Sets playing to loop + * @param {Function|null} [onFinished=null] Optional callback to fire when the video has finished */ - }], [{ - key: 'AddModel', - value: function AddModel(animationController, modelRes) { - for (var i = 0; i < animationController.models.length; ++i) { - if (animationController.models[i].modelRes.name === modelRes.name) { - return null; - } - } + }, { + key: 'Play', + value: function Play() { + var cycle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + var onFinished = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - var model = new _Tw2Model.Tw2Model(); - model.modelRes = modelRes; - var skeleton = modelRes.skeleton; - if (skeleton !== null) { - for (var j = 0; j < skeleton.bones.length; ++j) { - var bone = new _Tw2Bone.Tw2Bone(); - bone.boneRes = skeleton.bones[j]; - model.bones.push(bone); - model.bonesByName[bone.boneRes.name] = bone; - } + this.cycle = cycle; + this._onEnded = onFinished; + + if (this.video && this._playable) { + this.video.loop = this.cycle; + this.video.play(); + } else { + this.playOnLoad = true; } - animationController.models.push(model); - return model; } /** - * Finds a mesh binding for a supplied resource from an animation controller - * @param {Tw2AnimationController} animationController - * @param {Tw2GeometryRes} resource - * @returns {Object|null} Returns the mesh binding of a resource if it exists, null if it doesn't - * @private + * Pauses the video */ }, { - key: 'FindMeshBindings', - value: function FindMeshBindings(animationController, resource) { - for (var i = 0; i < animationController.meshBindings.length; ++i) { - if (animationController.meshBindings[i].resource === resource) { - return animationController.meshBindings[i]; - } + key: 'Pause', + value: function Pause() { + if (this.video) { + this.video.pause(); + } else { + this.playOnLoad = false; } - return null; } /** - * DoRebuildCachedData - * @param {Tw2AnimationController) animationController - * @param {Tw2GeometryRes} resource + * Prepares the resource + * @param {string} text */ }, { - key: 'DoRebuildCachedData', - value: function DoRebuildCachedData(animationController, resource) { - var newModels = []; - if (resource.meshes.length) { - for (var i = 0; i < resource.models.length; ++i) { - var model = Tw2AnimationController.AddModel(animationController, resource.models[i]); - if (model) { - newModels.push(model); - } - } - } + key: 'Prepare', + value: function Prepare(text) { + var gl = _global.device.gl; - for (var _i6 = 0; _i6 < animationController.geometryResources.length; ++_i6) { - animationController.AddAnimationsFromRes(animationController.geometryResources[_i6]); + switch (text) { + case 'mp4': + case 'webm': + case 'ogg': + this.texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.video); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.bindTexture(gl.TEXTURE_2D, null); + this.width = this.video.width; + this.height = this.video.height; + this.video.loop = this.cycle; + if (this.playOnLoad) this.video.play(); + this.PrepareFinished(true); } + } - if (resource.models.length === 0) { - for (var _i7 = 0; _i7 < resource.meshes.length; ++_i7) { - _resource.Tw2GeometryRes.BindMeshToModel(resource.meshes[_i7], animationController.geometryResources[0].models[0], resource); - } - resource.models.push(animationController.geometryResources[0].models[0]); - } + /** + * Loads the resource from a path + * + * @param {string} path + * @returns {boolean} returns true to tell the resMan not to handle http requests + */ - for (var _i8 = 0; _i8 < resource.models.length; ++_i8) { - var _model = null; - for (var j = 0; j < animationController.models.length; ++j) { - if (animationController.models[j].modelRes.name === resource.models[_i8].name) { - _model = animationController.models[j]; - break; - } - } + }, { + key: 'DoCustomLoad', + value: function DoCustomLoad(path) { + var _this2 = this; - if (_model === null) { - continue; - } + var ext = _global.resMan.constructor.GetPathExt(path); + this.LoadStarted(); + _global.resMan._pendingLoads++; - for (var _j4 = 0; _j4 < resource.models[_i8].meshBindings.length; ++_j4) { - var meshIx = resource.meshes.indexOf(resource.models[_i8].meshBindings[_j4].mesh); - var meshBindings = Tw2AnimationController.FindMeshBindings(animationController, resource); + this.video = document.createElement('video'); + this.video.crossOrigin = 'anonymous'; + this.video.muted = true; - if (meshBindings === null) { - meshBindings = []; - meshBindings.resource = resource; - animationController.meshBindings.push(meshBindings); - } + /** + * Fires on errors + */ + this.video.onerror = function () { + _global.resMan._pendingLoads--; + _global.logger.log('res.error', { + log: 'error', + src: ['Tw2TextureRes', 'DoCustomLoad'], + msg: 'Error loading resource', + type: 'http.error', + path: path + }); + _this2.LoadFinished(false); + _this2.PrepareFinished(false); + _this2.video = null; + }; - meshBindings[meshIx] = new Float32Array(resource.models[_i8].meshBindings[_j4].bones.length * 12); - for (var k = 0; k < resource.models[_i8].meshBindings[_j4].bones.length; ++k) { - for (var n = 0; n < _model.bones.length; ++n) { - if (_model.bones[n].boneRes.name === resource.models[_i8].meshBindings[_j4].bones[k].name) { - if (!_model.bones[n].bindingArrays) { - _model.bones[n].bindingArrays = []; - } + /** + * Fires when the video is playable + */ + this.video.oncanplay = function () { + _this2._playable = true; + _this2.video.oncanplay = null; + _global.resMan._pendingLoads--; + _global.resMan._prepareQueue.push([_this2, ext, null]); + _this2.LoadFinished(true); + }; + + /** + * Fires when the video has ended + */ + this.video.onended = function () { + _this2._isPlaying = false; + if (_this2._onEnded) _this2._onEnded(_this2); + }; + + /** + * Fires when the video is paused + */ + this.video.onpause = function () { + _this2._isPlaying = false; + if (_this2._onPause) _this2._onPause(_this2); + }; + + /** + * Fires when the video is playing + */ + this.video.onplaying = function () { + _this2._isPlaying = true; + if (_this2._onPlaying) _this2._onPlaying(_this2); + }; + + this.video.src = path; + return true; + } + + /** + * Unloads the video and texture from memory + */ + + }, { + key: 'Unload', + value: function Unload() { + if (this.texture) { + _global.device.gl.deleteTexture(this.texture); + this.texture = null; + } + + this._isPlaying = false; + this._playable = false; + this.playOnLoad = true; + this.video = null; + return true; + } + + /** + * Bind + * @param {Tw2SamplerState} sampler + */ + + }, { + key: 'Bind', + value: function Bind(sampler) { + var d = _global.device; + + this.KeepAlive(); + var targetType = sampler.samplerType; + if (targetType !== d.gl.TEXTURE_2D) return; - _model.bones[n].bindingArrays[_model.bones[n].bindingArrays.length] = { - 'array': meshBindings[meshIx], - 'offset': k * 12 - }; - //meshBindings[meshIx][k] = model.bones[n].offsetTransform; - break; - } - } - } - } + if (!this.texture) { + d.gl.bindTexture(d.gl.TEXTURE_2D, d.GetFallbackTexture()); + return; } - if (resource.meshes.length && resource.models.length) { - animationController.ResetBoneTransforms(); - } + this._currentTime = this.video.currentTime; + d.gl.bindTexture(d.gl.TEXTURE_2D, this.texture); + d.gl.texImage2D(d.gl.TEXTURE_2D, 0, d.gl.RGBA, d.gl.RGBA, d.gl.UNSIGNED_BYTE, this.video); + d.gl.bindTexture(d.gl.TEXTURE_2D, null); - animationController.loaded = true; - if (animationController.animations.length) { - if (animationController.pendingCommands.length) { - for (var _i9 = 0; _i9 < animationController.pendingCommands.length; ++_i9) { - if (!animationController.pendingCommands[_i9].args) { - animationController.pendingCommands[_i9].func.apply(animationController); - } else { - animationController.pendingCommands[_i9].func.apply(animationController, animationController.pendingCommands[_i9].args); - } - } - } - animationController.pendingCommands = []; - if (animationController.onPendingCleared) animationController.onPendingCleared(animationController); + d.gl.bindTexture(targetType, this.texture); + if (sampler.hash !== this._currentSampler) { + sampler.Apply(false); + this._currentSampler = sampler.hash; } } }]); - return Tw2AnimationController; -}(); + return Tw2VideoRes; +}(_Tw2Resource2.Tw2Resource); -/** - * Scratch variables - */ +/***/ }), +/* 124 */ +/***/ (function(module, exports, __webpack_require__) { +"use strict"; -Tw2AnimationController.scratch = { - vec3_0: _math.vec3.create(), - quat_0: _math.quat.create(), - mat3_0: _math.mat3.create(), - mat4_0: _math.mat4.create() -}; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _Tw2PostProcess = __webpack_require__(125); + +Object.keys(_Tw2PostProcess).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2PostProcess[key]; + } + }); +}); /***/ }), -/* 133 */ +/* 125 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -25771,250 +25892,212 @@ Tw2AnimationController.scratch = { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2EffectRes = undefined; +exports.Tw2PostProcess = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2Logger = __webpack_require__(4); +var _global = __webpack_require__(0); -var _reader = __webpack_require__(29); +var _Tw2RenderTarget = __webpack_require__(57); -var _Tw2Resource2 = __webpack_require__(12); +var _mesh = __webpack_require__(48); -var _Tw2Shader = __webpack_require__(134); +var _resource = __webpack_require__(25); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - /** - * Tw2EffectRes + * Creates a bloom post effect * - * @property {Array} passes - * @inherits Tw2Resource + * @property {number} width + * @property {number} height + * @property {Tw2TextureRes} texture + * @property {Tw2RenderTarget} quadRT0 + * @property {Tw2RenderTarget} quadRT1 + * @property {Array.} steps + * @class */ -var Tw2EffectRes = exports.Tw2EffectRes = function (_Tw2Resource) { - _inherits(Tw2EffectRes, _Tw2Resource); - - function Tw2EffectRes() { - _classCallCheck(this, Tw2EffectRes); - - var _this = _possibleConstructorReturn(this, (Tw2EffectRes.__proto__ || Object.getPrototypeOf(Tw2EffectRes)).call(this)); +var Tw2PostProcess = exports.Tw2PostProcess = function () { + function Tw2PostProcess() { + _classCallCheck(this, Tw2PostProcess); - _this.passes = []; - _this.annotations = {}; - _this.permutations = []; - _this.offsets = []; - _this.reader = null; - _this.version = 0; - _this.stringTable = ''; - _this.shaders = {}; - return _this; + this.width = 0; + this.height = 0; + this.texture = null; + this.quadRT0 = new _Tw2RenderTarget.Tw2RenderTarget(); + this.quadRT1 = new _Tw2RenderTarget.Tw2RenderTarget(); + this.steps = [{ + 'effect': _mesh.Tw2Effect.create({ + effectFilePath: 'res:/Graphics/Effect/Managed/Space/PostProcess/ColorDownFilter4.fx', + parameters: { + 'g_texelSize': [1, 1, 1, 1], + 'BlitCurrent': '' + } + }), + 'rt': this.quadRT1, + 'inputs': { + 'BlitCurrent': null + } + }, { + 'effect': _mesh.Tw2Effect.create({ + effectFilePath: 'res:/Graphics/Effect/Managed/Space/PostProcess/ColorHighPassFilter.fx', + parameters: { + 'LuminanceThreshold': 0.85, + 'LuminanceScale': 2, + 'BlitCurrent': '' + } + }), + 'rt': this.quadRT0, + 'inputs': { + 'BlitCurrent': this.quadRT1 + } + }, { + 'effect': _mesh.Tw2Effect.create({ + effectFilePath: 'res:/Graphics/Effect/Managed/Space/PostProcess/ColorExpBlurHorizontalBig.fx', + parameters: { + 'g_texelSize': [1, 1, 1, 1], + 'BlitCurrent': '' + } + }), + 'rt': this.quadRT1, + 'inputs': { + 'BlitCurrent': this.quadRT0 + } + }, { + 'effect': _mesh.Tw2Effect.create({ + effectFilePath: 'res:/Graphics/Effect/Managed/Space/PostProcess/ColorExpBlurVerticalBig.fx', + parameters: { + 'g_texelSize': [1, 1, 1, 1], + 'BlitCurrent': '' + } + }), + 'rt': this.quadRT0, + 'inputs': { + 'BlitCurrent': this.quadRT1 + } + }, { + 'effect': _mesh.Tw2Effect.create({ + effectFilePath: 'res:/Graphics/Effect/Managed/Space/PostProcess/ColorUpFilter4_Add.fx', + parameters: { + 'g_texelSize': [1, 1, 1, 1], + 'ScalingFactor': 1, + 'BlitCurrent': '', + 'BlitOriginal': '' + } + }), + 'rt': null, + 'inputs': { + 'BlitCurrent': this.quadRT0, + 'BlitOriginal': null + } + }]; } /** - * Prepares the effect - * - Creates Shaders - * - Sets shadow states for shaders - * - Parses Jessica shader annotations - * @param data + * Internal render/update function. It is called every frame. */ - _createClass(Tw2EffectRes, [{ - key: 'Prepare', - value: function Prepare(data) { - this.permutations = []; - this.offsets = []; - this.passes = []; - this.annotations = {}; - this.reader = null; - this.version = 0; - this.stringTable = ''; - this.shaders = {}; + _createClass(Tw2PostProcess, [{ + key: 'Render', + value: function Render() { + var width = _global.device.viewportWidth, + height = _global.device.viewportHeight; - var reader = new _reader.Tw2BinaryReader(new Uint8Array(data)); - var stringTable = ''; + if (width <= 0 || height <= 0) return; - /** - * ReadString - * @returns {string} - * @private - */ - function ReadString() { - var offset = reader.ReadUInt32(); - var end = offset; - while (stringTable.charCodeAt(end)) { - ++end; - } - return stringTable.substr(offset, end - offset); + if (this.texture === null) { + this.texture = new _resource.Tw2TextureRes(); + this.texture.Attach(_global.device.gl.createTexture()); } - var version = reader.ReadUInt32(); - if (version < 2 || version > 7) { - _Tw2Logger.logger.log('res.error', { - log: 'error', - src: ['Tw2EffectRes', 'CreateProgram'], - msg: 'Invalid version of effect file', - type: 'shader.effectversion', - path: this.path, - value: version - }); + if (width !== this.width || height !== this.height) { + _global.device.gl.bindTexture(_global.device.gl.TEXTURE_2D, this.texture.texture); + _global.device.gl.texImage2D(_global.device.gl.TEXTURE_2D, 0, _global.device.gl.RGBA, width, height, 0, _global.device.gl.RGBA, _global.device.gl.UNSIGNED_BYTE, null); + _global.device.gl.bindTexture(_global.device.gl.TEXTURE_2D, null); - this.PrepareFinished(false); - return; - } + this.quadRT0.Create(width / 4, height / 4, false); + this.quadRT1.Create(width / 4, height / 4, false); - var headerSize = void 0, - stringTableSize = void 0; + this.width = width; + this.height = height; - if (version < 5) { - headerSize = reader.ReadUInt32(); - if (headerSize === 0) { - _Tw2Logger.logger.log('res.error', { - log: 'error', - src: ['Tw2EffectRes', 'CreateProgram'], - msg: 'File contains no compiled effects', - path: this.path, - type: 'shader.effectheadersize', - value: 0 - }); + for (var i = 0; i < this.steps.length; ++i) { + var step = this.steps[i]; + for (var name in step.inputs) { + if (step.inputs.hasOwnProperty(name)) { + if (step.inputs[name]) { + step.effect.parameters[name].textureRes = step.inputs[name].texture; + } else { + step.effect.parameters[name].textureRes = this.texture; + } + } + } - this.PrepareFinished(false); - return; - } + if ('g_texelSize' in step.effect.parameters && 'BlitCurrent' in step.inputs) { + var size = step.effect.parameters['g_texelSize'], + rt = step.inputs['BlitCurrent']; - /* let permutation = */ - reader.ReadUInt32(); - var offset = reader.ReadUInt32(); - reader.cursor = 2 * 4 + headerSize * 3 * 4; - stringTableSize = reader.ReadUInt32(); - this.stringTableOffset = reader.cursor; - stringTable = String.fromCharCode.apply(null, reader.data.subarray(reader.cursor, reader.cursor + stringTableSize)); - reader.cursor = offset; - } else { - stringTableSize = reader.ReadUInt32(); - this.stringTableOffset = reader.cursor; - stringTable = String.fromCharCode.apply(null, reader.data.subarray(reader.cursor, reader.cursor + stringTableSize)); - reader.cursor += stringTableSize; - var permutationCount = reader.ReadUInt8(); - for (var perm = 0; perm < permutationCount; ++perm) { - var permutation = { - name: ReadString(), - defaultOption: reader.ReadUInt8(), - description: ReadString(), - type: reader.ReadUInt8(), - options: {}, - optionCount: reader.ReadUInt8() - }; - for (var j = 0; j < permutation.optionCount; ++j) { - permutation.options[ReadString()] = j; + if (rt) { + size.value[0] = 1.0 / rt.width; + size.value[1] = 1.0 / rt.width; + } else { + size.value[0] = 1.0 / width; + size.value[1] = 1.0 / width; + } + size.OnValueChanged(); } - this.permutations.push(permutation); } + } - headerSize = reader.ReadUInt32(); - if (headerSize === 0) { - _Tw2Logger.logger.log('res.error', { - log: 'error', - src: ['Tw2EffectRes', 'CreateProgram'], - msg: 'File contains no compiled effects', - path: this.path, - type: 'shader.effectheadersize', - value: 0 - }); + _global.device.gl.bindTexture(_global.device.gl.TEXTURE_2D, this.texture.texture); + _global.device.gl.copyTexImage2D(_global.device.gl.TEXTURE_2D, 0, _global.device.alphaBlendBackBuffer ? _global.device.gl.RGBA : _global.device.gl.RGB, 0, 0, width, height, 0); + _global.device.gl.bindTexture(_global.device.gl.TEXTURE_2D, null); + _global.device.SetStandardStates(_global.device.RM_OPAQUE); - this.PrepareFinished(false); - return; - } - for (var i = 0; i < headerSize; ++i) { - this.offsets.push({ - index: reader.ReadUInt32(), - offset: reader.ReadUInt32(), - size: reader.ReadUInt32() - }); + for (var _i = 0; _i < this.steps.length; ++_i) { + var _step = this.steps[_i]; + if (_step.rt !== null) { + _step.rt.Set(); + } else { + _global.device.gl.bindFramebuffer(_global.device.gl.FRAMEBUFFER, null); + _global.device.gl.viewport(0, 0, width, height); } - - reader.ReadUInt32(); - reader.cursor = reader.ReadUInt32(); + _global.device.RenderFullScreenQuad(_step.effect); } - this.reader = reader; - this.version = version; - this.stringTable = stringTable; - - this.PrepareFinished(true); } + }]); - /** - * Gets/creates a shader for the given permutation options - * - * @param {Object.} options - Permutation options - * @returns {Tw2Shader|null} - */ - - }, { - key: 'GetShader', - value: function GetShader(options) { - if (!this.IsGood()) { - return null; - } + return Tw2PostProcess; +}(); - var index = 0; - var multiplier = 1; +/***/ }), +/* 126 */ +/***/ (function(module, exports, __webpack_require__) { - for (var i = 0; i < this.permutations.length; ++i) { - var permutation = this.permutations[i]; - var value = permutation.defaultOption; - if (options.hasOwnProperty(permutation.name)) { - var valueName = options[permutation.name]; - if (!permutation.options.hasOwnProperty(valueName)) { - _Tw2Logger.logger.log('res.error', { - log: 'error', - src: ['Tw2EffectRes', 'GetShader'], - msg: 'Invalid shader permutation value', - path: this.path, - name: permutation.name, - value: valueName - }); - return null; - } - value = permutation.options[valueName]; - } - index += value * multiplier; - multiplier *= permutation.optionCount; - } +"use strict"; - if (this.shaders.hasOwnProperty(index)) { - return this.shaders[index]; - } - this.reader.cursor = this.offsets[index].offset; - var shader = null; - try { - shader = new _Tw2Shader.Tw2Shader(this.reader, this.version, this.stringTable, this.stringTableOffset); - } catch (error) { - return null; - } - this.shaders[index] = shader; - return shader; - } - }]); +Object.defineProperty(exports, "__esModule", { + value: true +}); - return Tw2EffectRes; -}(_Tw2Resource2.Tw2Resource); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** - * Request Response Type - * @type {string} + * Tw2Float + * + * @property {number} value + * @class */ +var Tw2Float = exports.Tw2Float = function Tw2Float() { + _classCallCheck(this, Tw2Float); - -Tw2EffectRes.prototype.requestResponseType = 'arraybuffer'; + this.value = 0; +}; /***/ }), -/* 134 */ +/* 127 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -26023,528 +26106,392 @@ Tw2EffectRes.prototype.requestResponseType = 'arraybuffer'; Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2Shader = undefined; +exports.Tw2Frustum = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2Device = __webpack_require__(2); - -var _global = __webpack_require__(17); - -var _vertex = __webpack_require__(9); - -var _math = __webpack_require__(0); - -var _sampler = __webpack_require__(21); +var _global = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** - * Tw2Shader + * Tw2Frustum * - * @property {Object.} techniques - * @property {Object.} annotations + * @property {Array.} planes + * @property {vec3} viewPos + * @property {vec3} viewDir + * @property {number} halfWidthProjection * @class */ -var Tw2Shader = exports.Tw2Shader = function () { - function Tw2Shader(reader, version, stringTable, stringTableOffset, path) { - _classCallCheck(this, Tw2Shader); - - /** - * ReadString - * @returns {string} - * @private - */ - function ReadString() { - var offset = reader.ReadUInt32(); - var end = offset; - while (stringTable.charCodeAt(end)) { - ++end; - } - return stringTable.substr(offset, end - offset); - } - - this.techniques = {}; - this.annotations = {}; - - var d = _Tw2Device.device; - - var techniqueCount = 1; - if (version > 6) { - techniqueCount = reader.ReadUInt8(); - } - for (var t = 0; t < techniqueCount; ++t) { - var technique = { - name: 'Main', - passes: [] - }; - if (version > 6) { - technique.name = ReadString(); - } - this.techniques[technique.name] = technique; - - var passCount = reader.ReadUInt8(); - for (var passIx = 0; passIx < passCount; ++passIx) { - var pass = {}; - pass.stages = [{}, {}]; - var stageCount = reader.ReadUInt8(); - var validShadowShader = true; - - for (var stageIx = 0; stageIx < stageCount; ++stageIx) { - var stage = {}; - stage.inputDefinition = new _vertex.Tw2VertexDeclaration(); - stage.constants = []; - stage.textures = []; - stage.samplers = []; - - var stageType = reader.ReadUInt8(), - inputCount = reader.ReadUInt8(); +var Tw2Frustum = exports.Tw2Frustum = function () { + function Tw2Frustum() { + _classCallCheck(this, Tw2Frustum); - for (var inputIx = 0; inputIx < inputCount; ++inputIx) { - var usage = reader.ReadUInt8(); - /* let registerIndex = */ - reader.ReadUInt8(); - var usageIndex = reader.ReadUInt8(); - /* let usedMask = */ - reader.ReadUInt8(); - stage.inputDefinition.elements[inputIx] = new _vertex.Tw2VertexElement(usage, usageIndex, 0); - } - stage.inputDefinition.RebuildHash(); + this.planes = [_global.vec4.create(), _global.vec4.create(), _global.vec4.create(), _global.vec4.create(), _global.vec4.create(), _global.vec4.create()]; + this.viewPos = _global.vec3.create(); + this.viewDir = _global.vec3.create(); + this.halfWidthProjection = 1; + } - var shaderSize = void 0, - shaderCode = void 0, - shadowShaderSize = void 0, - shadowShaderCode = void 0; + /** + * Initializes the Tw2Frustum + * + * @param {mat4} view - View Matrix + * @param {mat4} proj - Projection Matrix + * @param {number} viewportSize + * @param {mat4} [viewInverse] Optional viewInverse matrix + * @param {mat4} [viewProjection] Optional viewProjection matrix + */ - if (version < 5) { - shaderSize = reader.ReadUInt32(); - shaderCode = reader.data.subarray(reader.cursor, reader.cursor + shaderSize); - reader.cursor += shaderSize; - shadowShaderSize = reader.ReadUInt32(); - shadowShaderCode = reader.data.subarray(reader.cursor, reader.cursor + shadowShaderSize); - reader.cursor += shadowShaderSize; - } else { - shaderSize = reader.ReadUInt32(); - var so = reader.ReadUInt32(); - shaderCode = stringTable.substr(so, shaderSize); - shadowShaderSize = reader.ReadUInt32(); - so = reader.ReadUInt32(); - shadowShaderCode = stringTable.substr(so, shadowShaderSize); - } + _createClass(Tw2Frustum, [{ + key: 'Initialize', + value: function Initialize(view, proj, viewportSize, viewInverse, viewProjection) { + var mat4_0 = Tw2Frustum.global.mat4_0; - stage.shader = Tw2Shader.CompileShader(stageType, '', shaderCode, path); - if (stage.shader === null) { - throw new Error(); - } + var viewInv = viewInverse ? viewInverse : _global.mat4.invert(mat4_0, view); + this.viewPos.set(viewInv.subarray(12, 14)); + this.viewDir.set(viewInv.subarray(8, 10)); + this.halfWidthProjection = proj[0] * viewportSize * 0.5; - if (validShadowShader) { - if (shadowShaderSize === 0) { - stage.shadowShader = Tw2Shader.CompileShader(stageType, '\n#define PS\n', shaderCode, path); - } else { - stage.shadowShader = Tw2Shader.CompileShader(stageType, '', shadowShaderCode, path); - } + var viewProj = viewProjection ? viewProjection : _global.mat4.multiply(mat4_0, proj, view); + this.planes[0][0] = viewProj[2]; + this.planes[0][1] = viewProj[6]; + this.planes[0][2] = viewProj[10]; + this.planes[0][3] = viewProj[14]; - if (stage.shadowShader === null) { - validShadowShader = false; - } - } else { - stage.shadowShader = null; - } + this.planes[1][0] = viewProj[3] + viewProj[0]; + this.planes[1][1] = viewProj[7] + viewProj[4]; + this.planes[1][2] = viewProj[11] + viewProj[8]; + this.planes[1][3] = viewProj[15] + viewProj[12]; - if (version >= 3) { - reader.ReadUInt32(); - reader.ReadUInt32(); - reader.ReadUInt32(); - } + this.planes[2][0] = viewProj[3] - viewProj[1]; + this.planes[2][1] = viewProj[7] - viewProj[5]; + this.planes[2][2] = viewProj[11] - viewProj[9]; + this.planes[2][3] = viewProj[15] - viewProj[13]; - stage.constantSize = 0; - var constantCount = reader.ReadUInt32(); - for (var constantIx = 0; constantIx < constantCount; ++constantIx) { - var constant = {}; - constant.name = ReadString(); - constant.offset = reader.ReadUInt32() / 4; - constant.size = reader.ReadUInt32() / 4; - constant.type = reader.ReadUInt8(); - constant.dimension = reader.ReadUInt8(); - constant.elements = reader.ReadUInt32(); - constant.isSRGB = reader.ReadUInt8(); - constant.isAutoregister = reader.ReadUInt8(); - stage.constants[constantIx] = constant; + this.planes[3][0] = viewProj[3] - viewProj[0]; + this.planes[3][1] = viewProj[7] - viewProj[4]; + this.planes[3][2] = viewProj[11] - viewProj[8]; + this.planes[3][3] = viewProj[15] - viewProj[12]; - if (Tw2Shader.ConstantIgnore.includes(constant.name)) continue; + this.planes[4][0] = viewProj[3] + viewProj[1]; + this.planes[4][1] = viewProj[7] + viewProj[5]; + this.planes[4][2] = viewProj[11] + viewProj[9]; + this.planes[4][3] = viewProj[15] + viewProj[13]; - var last = constant.offset + constant.size; - if (last > stage.constantSize) stage.constantSize = last; - } + this.planes[5][0] = viewProj[3] - viewProj[2]; + this.planes[5][1] = viewProj[7] - viewProj[6]; + this.planes[5][2] = viewProj[11] - viewProj[10]; + this.planes[5][3] = viewProj[15] - viewProj[14]; - var constantValueSize = reader.ReadUInt32() / 4; - stage.constantValues = new Float32Array(constantValueSize); - if (version < 5) { - for (var i = 0; i < constantValueSize; ++i) { - stage.constantValues[i] = reader.ReadFloat32(); - } - } else { - var co = reader.ReadUInt32(), - bo = reader.cursor; + for (var i = 0; i < 6; ++i) { + var len = _global.vec3.length(this.planes[i]); + this.planes[i][0] /= len; + this.planes[i][1] /= len; + this.planes[i][2] /= len; + this.planes[i][3] /= len; + } + } - reader.cursor = stringTableOffset + co; - for (var _i = 0; _i < constantValueSize; ++_i) { - stage.constantValues[_i] = reader.ReadFloat32(); - } - reader.cursor = bo; - } - stage.constantSize = Math.max(stage.constantSize, constantValueSize); + /** + * Checks to see if a sphere is visible within the frustum + * + * @param {vec3} center + * @param {number} radius + * @returns {boolean} + */ - var textureCount = reader.ReadUInt8(); - for (var textureIx = 0; textureIx < textureCount; ++textureIx) { - var texture = {}; - texture.registerIndex = reader.ReadUInt8(); - texture.name = ReadString(); - texture.type = reader.ReadUInt8(); - texture.isSRGB = reader.ReadUInt8(); - texture.isAutoregister = reader.ReadUInt8(); - stage.textures.push(texture); - } + }, { + key: 'IsSphereVisible', + value: function IsSphereVisible(center, radius) { + for (var i = 0; i < 6; ++i) { + if (this.planes[i][0] * center[0] + this.planes[i][1] * center[1] + this.planes[i][2] * center[2] + this.planes[i][3] < -radius) { + return false; + } + } + return true; + } - var samplerCount = reader.ReadUInt8(); - for (var samplerIx = 0; samplerIx < samplerCount; ++samplerIx) { - var registerIndex = reader.ReadUInt8(), - samplerName = version >= 4 ? ReadString() : ''; + /** + * GetPixelSizeAcross + * + * @param {vec3} center + * @param {number} radius + * @returns {number} + */ - reader.ReadUInt8(); // comparison + }, { + key: 'GetPixelSizeAcross', + value: function GetPixelSizeAcross(center, radius) { + var d = _global.vec3.subtract(Tw2Frustum.global.vec3_0, this.viewPos, center); - var minFilter = reader.ReadUInt8(), - magFilter = reader.ReadUInt8(), - mipFilter = reader.ReadUInt8(), - addressU = reader.ReadUInt8(), - addressV = reader.ReadUInt8(), - addressW = reader.ReadUInt8(); + var depth = _global.vec3.dot(this.viewDir, d), + epsilon = 1e-5; - reader.ReadFloat32(); // mipLODBias + if (depth < epsilon) depth = epsilon; + if (radius < epsilon) return 0; - var maxAnisotropy = reader.ReadUInt8(); + var ratio = radius / depth; + return ratio * this.halfWidthProjection * 2; + } + }]); - reader.ReadUInt8(); //comparisonFunc + return Tw2Frustum; +}(); - var borderColor = _math.quat.create(); - borderColor[0] = reader.ReadFloat32(); - borderColor[1] = reader.ReadFloat32(); - borderColor[2] = reader.ReadFloat32(); - borderColor[3] = reader.ReadFloat32(); +/** + * global variables + */ - reader.ReadFloat32(); //minLOD - reader.ReadFloat32(); //maxLOD - if (version < 4) reader.ReadUInt8(); +Tw2Frustum.global = { + vec3_0: _global.vec3.create(), + mat4_0: _global.mat4.create() +}; - var sampler = new _sampler.Tw2SamplerState(); - sampler.registerIndex = registerIndex; - sampler.name = samplerName; +/***/ }), +/* 128 */ +/***/ (function(module, exports, __webpack_require__) { - if (minFilter === 1) { - switch (mipFilter) { - case 0: - sampler.minFilter = d.gl.NEAREST; - break; +"use strict"; - case 1: - sampler.minFilter = d.gl.NEAREST_MIPMAP_NEAREST; - break; - default: - sampler.minFilter = d.gl.NEAREST_MIPMAP_LINEAR; - } - sampler.minFilterNoMips = d.gl.NEAREST; - } else { - switch (mipFilter) { - case 0: - sampler.minFilter = d.gl.LINEAR; - break; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2ColorCurve = exports.Tw2ColorKey = undefined; - case 1: - sampler.minFilter = d.gl.LINEAR_MIPMAP_NEAREST; - break; +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - default: - sampler.minFilter = d.gl.LINEAR_MIPMAP_LINEAR; - } - sampler.minFilterNoMips = d.gl.LINEAR; - } +var _global = __webpack_require__(0); - sampler.magFilter = magFilter === 1 ? d.gl.NEAREST : d.gl.LINEAR; - sampler.addressU = d.wrapModes[addressU]; - sampler.addressV = d.wrapModes[addressV]; - sampler.addressW = d.wrapModes[addressW]; +var _Tw2Curve2 = __webpack_require__(2); - if (minFilter === 3 || magFilter === 3 || mipFilter === 3) { - sampler.anisotropy = Math.max(maxAnisotropy, 1); - } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - for (var n = 0; n < stage.textures.length; ++n) { - if (stage.textures[n].registerIndex === sampler.registerIndex) { - sampler.samplerType = stage.textures[n].type === 4 ? d.gl.TEXTURE_CUBE_MAP : d.gl.TEXTURE_2D; - sampler.isVolume = stage.textures[n].type === 3; - break; - } - } +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - sampler.ComputeHash(); - stage.samplers.push(sampler); - } +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - if (version >= 3) reader.ReadUInt8(); +/** + * Tw2ColorKey + * + * @property {vec4} value + * @property {vec4} left + * @property {vec4} right + * @property {number} interpolation + * @class + */ +var Tw2ColorKey = exports.Tw2ColorKey = function (_Tw2CurveKey) { + _inherits(Tw2ColorKey, _Tw2CurveKey); - pass.stages[stageType] = stage; - } + function Tw2ColorKey() { + _classCallCheck(this, Tw2ColorKey); - pass.states = []; - var stateCount = reader.ReadUInt8(); - for (var stateIx = 0; stateIx < stateCount; ++stateIx) { - var state = reader.ReadUInt32(), - value = reader.ReadUInt32(); + var _this = _possibleConstructorReturn(this, (Tw2ColorKey.__proto__ || Object.getPrototypeOf(Tw2ColorKey)).call(this)); - pass.states.push({ - 'state': state, - 'value': value - }); - } + _this.value = _global.vec4.create(); + _this.left = _global.vec4.create(); + _this.right = _global.vec4.create(); + _this.interpolation = 0; + return _this; + } - pass.shaderProgram = Tw2Shader.CreateProgram(pass.stages[0].shader, pass.stages[1].shader, pass, path); - if (pass.shaderProgram === null) { - throw new Error(); - } + return Tw2ColorKey; +}(_Tw2Curve2.Tw2CurveKey); - if (validShadowShader) { - pass.shadowShaderProgram = Tw2Shader.CreateProgram(pass.stages[0].shadowShader, pass.stages[1].shadowShader, pass, path); - if (pass.shadowShaderProgram === null) { - pass.shadowShaderProgram = pass.shaderProgram; - } - } else { - pass.shadowShaderProgram = pass.shaderProgram; - } +/** + * Tw2ColorCurve + * + * @property {number} start + * @property {vec4} currentValue + * @property {number} extrapolation + * @property {Array.} keys + * @property {number} _currentKey + * @property {number} length + * @class + */ - technique.passes[passIx] = pass; - } - } - var parameterCount = reader.ReadUInt16(); - for (var paramIx = 0; paramIx < parameterCount; ++paramIx) { - var name = ReadString(), - annotations = [], - annotationCount = reader.ReadUInt8(); - for (var annotationIx = 0; annotationIx < annotationCount; ++annotationIx) { - annotations[annotationIx] = {}; - annotations[annotationIx].name = ReadString(); - annotations[annotationIx].type = reader.ReadUInt8(); - switch (annotations[annotationIx].type) { - case 0: - annotations[annotationIx].value = reader.ReadUInt32() !== 0; - break; +var Tw2ColorCurve = exports.Tw2ColorCurve = function (_Tw2Curve) { + _inherits(Tw2ColorCurve, _Tw2Curve); - case 1: - annotations[annotationIx].value = reader.ReadInt32(); - break; + function Tw2ColorCurve() { + _classCallCheck(this, Tw2ColorCurve); - case 2: - annotations[annotationIx].value = reader.ReadFloat32(); - break; + var _this2 = _possibleConstructorReturn(this, (Tw2ColorCurve.__proto__ || Object.getPrototypeOf(Tw2ColorCurve)).call(this)); - default: - annotations[annotationIx].value = ReadString(); - } - } - this.annotations[name] = annotations; - } + _this2.start = 0; + _this2.value = _global.vec4.create(); + _this2.extrapolation = 0; + _this2.keys = []; + _this2._currentKey = 1; + _this2.length = 0; + return _this2; } /** - * Applies an Effect Pass - * @param {String} technique - technique name - * @param {number} pass - effect.passes index + * Sorts the curve's keys */ - _createClass(Tw2Shader, [{ - key: 'ApplyPass', - value: function ApplyPass(technique, pass) { - var d = _Tw2Device.device; - pass = this.techniques[technique].passes[pass]; - - for (var i = 0; i < pass.states.length; ++i) { - d.SetRenderState(pass.states[i].state, pass.states[i].value); - } - - if (d.IsAlphaTestEnabled()) { - d.gl.useProgram(pass.shadowShaderProgram.program); - d.shadowHandles = pass.shadowShaderProgram; - } else { - d.gl.useProgram(pass.shaderProgram.program); - d.shadowHandles = null; - } + _createClass(Tw2ColorCurve, [{ + key: 'Sort', + value: function Sort() { + _Tw2Curve2.Tw2Curve.Sort(this); } /** - * Finds out if a parameter name is a valid shader input - * @param {string} name - An Effect Parameter name - * @returns {Boolean} + * Gets the curve's length + * @returns {number} */ }, { - key: 'IsValidParameter', - value: function IsValidParameter(name) { - return name in this.annotations; + key: 'GetLength', + value: function GetLength() { + return this.length; } /** - * Returns an array of valid parameter names for a specific annotation group - * - Compatible with pre V5 shaders - * @param {string} groupName - The name of an annotation group - * @returns {Array.< string >} + * Updates the current value at the given time + * @param {number} time */ }, { - key: 'GetParametersByGroup', - value: function GetParametersByGroup(groupName) { - var parameters = []; - for (var param in this.annotations) { - if (this.annotations.hasOwnProperty(param)) { - for (var i = 0; i < this.annotations[param].length; i++) { - if (this.annotations[param][i].name.toLowerCase() === 'group' && this.annotations[param][i].value.toLowerCase() === groupName.toLowerCase()) { - parameters.push(param); - } - } - } - } - return parameters; + key: 'UpdateValue', + value: function UpdateValue(time) { + this.GetValueAt(time, this.value); } /** - * Compiles shader - * @param {number} stageType - * @param {string} prefix - * @param shaderCode - * @param {string} path - Shader path - * @returns {*} + * Gets a value at a specific time + * @param {number} time + * @param {vec4} value + * @returns {vec4} value */ - }], [{ - key: 'CompileShader', - value: function CompileShader(stageType, prefix, shaderCode, path) { - var d = _Tw2Device.device, - shader = d.gl.createShader(stageType === 0 ? d.gl.VERTEX_SHADER : d.gl.FRAGMENT_SHADER); - - if (d.ext.ShaderBinary) { - d.ext.ShaderBinary['shaderBinary'](shader, shaderCode); - } else { - var source = prefix + (typeof shaderCode === 'string' ? shaderCode : String.fromCharCode.apply(null, shaderCode)); - source = source.substr(0, source.length - 1); - d.gl.shaderSource(shader, source); - d.gl.compileShader(shader); + }, { + key: 'GetValueAt', + value: function GetValueAt(time, value) { + if (this.length === 0) { + return _global.vec4.copy(value, this.value); } - if (!d.gl.getShaderParameter(shader, d.gl.COMPILE_STATUS)) { - _global.logger.log('res.error', { - log: 'error', - src: ['Tw2Shader', 'CompileShader'], - msg: 'Error compiling shader', - path: path, - type: 'shader.compile', - value: stageType === 0 ? 'VERTEX' : 'FRAGMENT', - data: _Tw2Device.device.gl.getShaderInfoLog(shader) - }); - return null; - } - return shader; - } + var firstKey = this.keys[0], + lastKey = this.keys[this.keys.length - 1]; - /** - * Creates shader program - * @param vertexShader - * @param fragmentShader - * @param pass - * @param {string} path - Shader path - * @returns {*} - */ + if (time >= lastKey.time) { + switch (this.extrapolation) { + case Tw2ColorCurve.Extrapolation.NONE: + return _global.vec4.copy(value, this.value); - }, { - key: 'CreateProgram', - value: function CreateProgram(vertexShader, fragmentShader, pass, path) { - var d = _Tw2Device.device, - program = {}; + case Tw2ColorCurve.Extrapolation.CONSTANT: + return _global.vec4.copy(value, lastKey.value); - program.program = d.gl.createProgram(); - d.gl.attachShader(program.program, vertexShader); - d.gl.attachShader(program.program, fragmentShader); - d.gl.linkProgram(program.program); + case Tw2ColorCurve.Extrapolation.GRADIENT: + return _global.vec4.scaleAndAdd(value, lastKey.value, lastKey.right, time - lastKey.time); - if (!d.gl.getProgramParameter(program.program, d.gl.LINK_STATUS)) { - _global.logger.log('res.error', { - log: 'error', - src: ['Tw2Shader', 'CreateProgram'], - msg: 'Error linking shaders', - path: path, - type: 'shader.linkstatus', - data: _Tw2Device.device.gl.getProgramInfoLog(program.program) - }); - return null; - } + default: + time = time % lastKey.time; + } + } else if (time < 0 || time < firstKey.time) { + switch (this.extrapolation) { + case Tw2ColorCurve.Extrapolation.NONE: + return _global.vec4.copy(value, this.value); - d.gl.useProgram(program.program); - program.constantBufferHandles = []; - for (var j = 0; j < 16; ++j) { - program.constantBufferHandles[j] = d.gl.getUniformLocation(program.program, 'cb' + j); - } + case Tw2ColorCurve.Extrapolation.GRADIENT: + return _global.vec4.scaleAndAdd(value, firstKey.value, firstKey.left, time * this.length - lastKey.time); - program.samplerHandles = []; - for (var _j = 0; _j < 16; ++_j) { - program.samplerHandles[_j] = d.gl.getUniformLocation(program.program, 's' + _j); - d.gl.uniform1i(program.samplerHandles[_j], _j); + default: + return _global.vec4.copy(value, firstKey.value); + } } - for (var _j2 = 0; _j2 < 16; ++_j2) { - program.samplerHandles[_j2 + 12] = d.gl.getUniformLocation(program.program, 'vs' + _j2); - d.gl.uniform1i(program.samplerHandles[_j2 + 12], _j2 + 12); - } + var ck = this.keys[this._currentKey], + ck_1 = this.keys[this._currentKey - 1]; - program.input = new _vertex.Tw2VertexDeclaration(); - for (var _j3 = 0; _j3 < pass.stages[0].inputDefinition.elements.length; ++_j3) { - var location = d.gl.getAttribLocation(program.program, 'attr' + _j3); - if (location >= 0) { - var el = new _vertex.Tw2VertexElement(pass.stages[0].inputDefinition.elements[_j3].usage, pass.stages[0].inputDefinition.elements[_j3].usageIndex); - el.location = location; - program.input.elements.push(el); - } + while (time >= ck.time || time < ck_1.time) { + if (time < ck_1.time) this._currentKey = 0; + this._currentKey++; + ck = this.keys[this._currentKey]; + ck_1 = this.keys[this._currentKey - 1]; } - program.input.RebuildHash(); - program.shadowStateInt = d.gl.getUniformLocation(program.program, 'ssi'); - program.shadowStateFloat = d.gl.getUniformLocation(program.program, 'ssf'); - program.shadowStateYFlip = d.gl.getUniformLocation(program.program, 'ssyf'); - d.gl.uniform3f(program.shadowStateYFlip, 0, 0, 1); - program.volumeSlices = []; - for (var _j4 = 0; _j4 < pass.stages[1].samplers.length; ++_j4) { - if (pass.stages[1].samplers[_j4].isVolume) { - program.volumeSlices[pass.stages[1].samplers[_j4].registerIndex] = d.gl.getUniformLocation(program.program, 's' + pass.stages[1].samplers[_j4].registerIndex + 'sl'); - } + var nt = (time - ck_1.time) / (ck.time - ck_1.time); + + switch (ck_1.interpolation) { + case Tw2ColorCurve.Interpolation.CONSTANT: + return _global.vec4.copy(value, ck_1.value); + + default: + value[0] = ck_1.value[0] * (1 - nt) + ck.value[0] * nt; + value[1] = ck_1.value[1] * (1 - nt) + ck.value[1] * nt; + value[2] = ck_1.value[2] * (1 - nt) + ck.value[2] * nt; + value[3] = ck_1.value[3] * (1 - nt) + ck.value[3] * nt; + return value; } - return program; } }]); - return Tw2Shader; -}(); + return Tw2ColorCurve; +}(_Tw2Curve2.Tw2Curve); /** - * Constant names that are ignored - * @type {string[]} + * The curve's key dimension + * @type {number} */ -Tw2Shader.ConstantIgnore = ['PerFrameVS', 'PerObjectVS', 'PerFramePS', 'PerObjectPS']; +Tw2ColorCurve.inputDimension = 4; + +/** + * The curve's dimension + * @type {number} + */ +Tw2ColorCurve.ouputDimension = 4; + +/** + * The curve's current value property + * @type {string} + */ +Tw2ColorCurve.valueProperty = 'value'; + +/** + * The curve's type + * @type {number} + */ +Tw2ColorCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE; + +/** + * The curve's key constructor + * @type {Tw2ColorKey} + */ +Tw2ColorCurve.Key = Tw2ColorKey; + +/** + * Extrapolation types + * @type {{NONE: number, CONSTANT: number, GRADIENT: number, CYCLE: number}} + */ +Tw2ColorCurve.Extrapolation = { + NONE: 0, + CONSTANT: 1, + GRADIENT: 2, + CYCLE: 3 +}; + +/** + * Interpolation types + * @type {{NONE: number, CONSTANT: number, LINEAR: number}} + */ +Tw2ColorCurve.Interpolation = { + NONE: 0, + CONSTANT: 1, + LINEAR: 2 +}; /***/ }), -/* 135 */ +/* 129 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -26553,757 +26500,547 @@ Tw2Shader.ConstantIgnore = ['PerFrameVS', 'PerObjectVS', 'PerFramePS', 'PerObjec Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2GeometryRes = undefined; +exports.Tw2ColorCurve2 = exports.Tw2ColorKey2 = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); -var _Tw2Device = __webpack_require__(2); +var _Tw2Curve2 = __webpack_require__(2); -var _Tw2Logger = __webpack_require__(4); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var _reader = __webpack_require__(29); +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } -var _vertex = __webpack_require__(9); +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var _Tw2Resource2 = __webpack_require__(12); +/** + * Tw2ColorKey2 + * + * @property {number} time + * @property {vec4} value + * @property {vec4} leftTangent + * @property {vec4} rightTangent + * @property {number} interpolation + * @class + */ +var Tw2ColorKey2 = exports.Tw2ColorKey2 = function (_Tw2CurveKey) { + _inherits(Tw2ColorKey2, _Tw2CurveKey); -var _geometry = __webpack_require__(46); + function Tw2ColorKey2() { + _classCallCheck(this, Tw2ColorKey2); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + var _this = _possibleConstructorReturn(this, (Tw2ColorKey2.__proto__ || Object.getPrototypeOf(Tw2ColorKey2)).call(this)); -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + _this.value = _global.vec4.create(); + _this.leftTangent = _global.vec4.create(); + _this.rightTangent = _global.vec4.create(); + _this.interpolation = 1; + return _this; + } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + return Tw2ColorKey2; +}(_Tw2Curve2.Tw2CurveKey); /** - * Tw2GeometryRes + * Tw2ColorCurve2 * - * @property {Array} meshes - * @property {vec3} minBounds - * @property {vec3} maxBounds - * @property {vec3} boundsSpherePosition - * @property {number} boundsSphereRadius - * @property {Array} models - * @property {Array} animations - * @property {Boolean} systemMirror - * @inherit Tw2Resource + * @property {boolean} cycle + * @property {boolean} reversed + * @property {number} timeOffset + * @property {number} timeScale + * @property {vec4} startValue=[0,0,0,1] + * @property {vec4} currentValue=[0,0,0,1] + * @property {vec4} endValue=[0,0,0,1] + * @property {vec4} startTangent + * @property {vec4} endTangent + * @property {number} interpolation + * @property {Array.} keys + * @class */ -var Tw2GeometryRes = exports.Tw2GeometryRes = function (_Tw2Resource) { - _inherits(Tw2GeometryRes, _Tw2Resource); - function Tw2GeometryRes() { - _classCallCheck(this, Tw2GeometryRes); - var _this = _possibleConstructorReturn(this, (Tw2GeometryRes.__proto__ || Object.getPrototypeOf(Tw2GeometryRes)).call(this)); +var Tw2ColorCurve2 = exports.Tw2ColorCurve2 = function (_Tw2Curve) { + _inherits(Tw2ColorCurve2, _Tw2Curve); - _this.meshes = []; - _this.minBounds = _math.vec3.create(); - _this.maxBounds = _math.vec3.create(); - _this.boundsSpherePosition = _math.vec3.create(); - _this.boundsSphereRadius = 0; - _this.models = []; - _this.animations = []; - _this.systemMirror = false; - return _this; + function Tw2ColorCurve2() { + _classCallCheck(this, Tw2ColorCurve2); + + var _this2 = _possibleConstructorReturn(this, (Tw2ColorCurve2.__proto__ || Object.getPrototypeOf(Tw2ColorCurve2)).call(this)); + + _this2.cycle = false; + _this2.reversed = false; + _this2.timeOffset = 0; + _this2.timeScale = 1; + _this2.startValue = _global.vec4.fromValues(0, 0, 0, 1); + _this2.currentValue = _global.vec4.fromValues(0, 0, 0, 1); + _this2.endValue = _global.vec4.fromValues(0, 0, 0, 1); + _this2.startTangent = _global.vec4.create(); + _this2.endTangent = _global.vec4.create(); + _this2.interpolation = 1; + _this2.keys = []; + _this2.length = 0; + return _this2; } /** - * GetInstanceBuffer - * @param {number} meshIndex - * @returns {*} + * Sorts the curve's keys */ - _createClass(Tw2GeometryRes, [{ - key: 'GetInstanceBuffer', - value: function GetInstanceBuffer(meshIndex) { - return meshIndex < this.meshes.length ? this.meshes[meshIndex].buffer : undefined; - } - - /** - * GetInstanceDeclaration - * @param {number} meshIndex - * @returns {Tw2VertexDeclaration} - */ - - }, { - key: 'GetInstanceDeclaration', - value: function GetInstanceDeclaration(meshIndex) { - return this.meshes[meshIndex].declaration; + _createClass(Tw2ColorCurve2, [{ + key: 'Sort', + value: function Sort() { + _Tw2Curve2.Tw2Curve.Sort2(this); } /** - * GetInstanceStride - * @param {number} meshIndex + * Gets the curve's length * @returns {number} */ }, { - key: 'GetInstanceStride', - value: function GetInstanceStride(meshIndex) { - return this.meshes[meshIndex].declaration.stride; + key: 'GetLength', + value: function GetLength() { + return this.length; } /** - * GetInstanceCount - * @param {number} meshIndex - * @returns {number} + * Updates the current value at the given time + * @param {number} time */ }, { - key: 'GetInstanceCount', - value: function GetInstanceCount(meshIndex) { - return this.meshes[meshIndex].bufferLength * 4 / this.meshes[meshIndex].declaration.stride; + key: 'UpdateValue', + value: function UpdateValue(time) { + this.GetValueAt(time, this.currentValue); } /** - * Prepare - * @param data + * Gets a value at a specific time + * @param {number} time + * @param {vec4} value + * @returns {vec4} */ }, { - key: 'Prepare', - value: function Prepare(data) { - var d = _Tw2Device.device, - reader = new _reader.Tw2BinaryReader(new Uint8Array(data)); - - /* let fileVersion = */ - reader.ReadUInt8(); - var meshCount = reader.ReadUInt8(); - for (var meshIx = 0; meshIx < meshCount; ++meshIx) { - var mesh = new _geometry.Tw2GeometryMesh(); - mesh.name = reader.ReadString(); - var buffer = Tw2GeometryRes.ReadVertexBuffer(reader, mesh.declaration); - - if (buffer) { - mesh.bufferLength = buffer.length; - mesh.buffer = d.gl.createBuffer(); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, mesh.buffer); - d.gl.bufferData(d.gl.ARRAY_BUFFER, buffer, d.gl.STATIC_DRAW); - } else { - mesh.buffer = null; - } + key: 'GetValueAt', + value: function GetValueAt(time, value) { + time = time / this.timeScale + this.timeOffset; + if (this.length <= 0 || time <= 0) { + return _global.vec4.copy(value, this.startValue); + } - var indexes = Tw2GeometryRes.ReadIndexBuffer(reader); - if (indexes) { - mesh.indexes = d.gl.createBuffer(); - mesh.indexType = indexes.BYTES_PER_ELEMENT === 2 ? d.gl.UNSIGNED_SHORT : d.gl.UNSIGNED_INT; - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); - d.gl.bufferData(d.gl.ELEMENT_ARRAY_BUFFER, indexes, d.gl.STATIC_DRAW); + if (time > this.length) { + if (this.cycle) { + time = time % this.length; + } else if (this.reversed) { + return _global.vec4.copy(value, this.startValue); } else { - mesh.indexes = null; + return _global.vec4.copy(value, this.endValue); } + } - var areaCount = reader.ReadUInt8(); - for (var i = 0; i < areaCount; ++i) { - mesh.areas[i] = new _geometry.Tw2GeometryMeshArea(); - mesh.areas[i].name = reader.ReadString(); - mesh.areas[i].start = reader.ReadUInt32() * indexes.BYTES_PER_ELEMENT; - mesh.areas[i].count = reader.ReadUInt32() * 3; - mesh.areas[i].minBounds = _math.vec3.fromValues(reader.ReadFloat32(), reader.ReadFloat32(), reader.ReadFloat32()); - mesh.areas[i].maxBounds = _math.vec3.fromValues(reader.ReadFloat32(), reader.ReadFloat32(), reader.ReadFloat32()); - } + if (this.reversed) { + time = this.length - time; + } - var boneBindingCount = reader.ReadUInt8(); - mesh.boneBindings = []; - for (var _i = 0; _i < boneBindingCount; ++_i) { - mesh.boneBindings[_i] = reader.ReadString(); - } + if (this.keys.length === 0) { + return this.Interpolate(time, null, null, value); + } - var annotationSetCount = reader.ReadUInt16(); - if (annotationSetCount || this.systemMirror) { - mesh.bufferData = buffer; - mesh.indexData = indexes; - } + var startKey = this.keys[0], + endKey = this.keys[this.keys.length - 1]; - if (annotationSetCount) { - mesh.blendShapes = []; - for (var _i2 = 0; _i2 < annotationSetCount; ++_i2) { - mesh.blendShapes[_i2] = new _geometry.Tw2BlendShapeData(); - mesh.blendShapes[_i2].name = reader.ReadString(); - mesh.blendShapes[_i2].buffer = Tw2GeometryRes.ReadVertexBuffer(reader, mesh.blendShapes[_i2].declaration); - mesh.blendShapes[_i2].indexes = Tw2GeometryRes.ReadIndexBuffer(reader); - } - } + if (time <= startKey.time) { + return this.Interpolate(time, null, startKey, value); + } else if (time >= endKey.time) { + return this.Interpolate(time, endKey, null, value); + } - this.meshes[meshIx] = mesh; + for (var i = 0; i + 1 < this.keys.length; ++i) { + startKey = this.keys[i]; + endKey = this.keys[i + 1]; + if (startKey.time <= time && endKey.time > time) break; } - var modelCount = reader.ReadUInt8(); - for (var modelIx = 0; modelIx < modelCount; ++modelIx) { - var model = new _geometry.Tw2GeometryModel(); - model.name = reader.ReadString(); - model.skeleton = new _geometry.Tw2GeometrySkeleton(); - var boneCount = reader.ReadUInt8(); + return this.Interpolate(time, startKey, endKey, value); + } - for (var _i3 = 0; _i3 < boneCount; ++_i3) { - var bone = new _geometry.Tw2GeometryBone(); - bone.name = reader.ReadString(); - var flags = reader.ReadUInt8(); - bone.parentIndex = reader.ReadUInt8(); - if (bone.parentIndex === 255) bone.parentIndex = -1; + /** + * Interpolate + * @param {number} time + * @param {Tw2ColorKey2} lastKey + * @param {Tw2ColorKey2} nextKey + * @param {vec4} value + * @returns {vec4} value + */ - if ((flags & 1) != 0) { - _math.vec3.set(bone.position, reader.ReadFloat32(), reader.ReadFloat32(), reader.ReadFloat32()); - } else { - _math.vec3.set(bone.position, 0, 0, 0); - } + }, { + key: 'Interpolate', + value: function Interpolate(time, lastKey, nextKey, value) { + _global.vec4.copy(value, this.startValue); - if ((flags & 2) != 0) { - _math.quat.set(bone.orientation, reader.ReadFloat32(), reader.ReadFloat32(), reader.ReadFloat32(), reader.ReadFloat32()); - } else { - _math.quat.identity(bone.orientation); - } + var startValue = this.startValue, + endValue = this.endValue, + interp = this.interpolation, + deltaTime = this.length; - if ((flags & 4) != 0) { - for (var k = 0; k < 9; ++k) { - bone.scaleShear[k] = reader.ReadFloat32(); - } - } else { - _math.mat3.identity(bone.scaleShear); - } - model.skeleton.bones[_i3] = bone; - } + if (lastKey !== null) { + interp = lastKey.interpolation; + time -= lastKey.time; + } - for (var _i4 = 0; _i4 < model.skeleton.bones.length; ++_i4) { - model.skeleton.bones[_i4].UpdateTransform(); - if (model.skeleton.bones[_i4].parentIndex !== -1) { - _math.mat4.multiply(model.skeleton.bones[_i4].worldTransform, model.skeleton.bones[model.skeleton.bones[_i4].parentIndex].worldTransform, model.skeleton.bones[_i4].localTransform); - } else { - _math.mat4.copy(model.skeleton.bones[_i4].worldTransform, model.skeleton.bones[_i4].localTransform); + switch (interp) { + case Tw2ColorCurve2.Interpolation.LINEAR: + if (lastKey && nextKey) { + startValue = lastKey.value; + endValue = nextKey.value; + deltaTime = nextKey.time - lastKey.time; + } else if (nextKey) { + endValue = nextKey.value; + deltaTime = nextKey.time; + } else if (lastKey) { + startValue = lastKey.value; + deltaTime = this.length - lastKey.time; } - _math.mat4.invert(model.skeleton.bones[_i4].worldTransformInv, model.skeleton.bones[_i4].worldTransform); - } + value[0] = startValue[0] + (endValue[0] - startValue[0]) * (time / deltaTime); + value[1] = startValue[1] + (endValue[1] - startValue[1]) * (time / deltaTime); + value[2] = startValue[2] + (endValue[2] - startValue[2]) * (time / deltaTime); + value[3] = startValue[3] + (endValue[3] - startValue[3]) * (time / deltaTime); + return value; - var meshBindingCount = reader.ReadUInt8(); - for (var _i5 = 0; _i5 < meshBindingCount; ++_i5) { - var _mesh = reader.ReadUInt8(); - if (_mesh < this.meshes.length) { - Tw2GeometryRes.BindMeshToModel(this.meshes[_mesh], model, this); - } - } - this.models[this.models.length] = model; + default: + return value; } + } + }]); - var animationCount = reader.ReadUInt8(); - for (var _i6 = 0; _i6 < animationCount; ++_i6) { - var animation = new _geometry.Tw2GeometryAnimation(); - animation.name = reader.ReadString(); - animation.duration = reader.ReadFloat32(); - var groupCount = reader.ReadUInt8(); - for (var j = 0; j < groupCount; ++j) { - var group = new _geometry.Tw2GeometryTrackGroup(); - group.name = reader.ReadString(); - for (var m = 0; m < this.models.length; ++m) { - if (this.models[m].name === group.name) { - group.model = this.models[m]; - break; - } - } - - var transformTrackCount = reader.ReadUInt8(); - for (var _k = 0; _k < transformTrackCount; ++_k) { - var track = new _geometry.Tw2GeometryTransformTrack(); - track.name = reader.ReadString(); - track.orientation = Tw2GeometryRes.ReadCurve(reader); - track.position = Tw2GeometryRes.ReadCurve(reader); - track.scaleShear = Tw2GeometryRes.ReadCurve(reader); + return Tw2ColorCurve2; +}(_Tw2Curve2.Tw2Curve); - if (track.orientation) { - var lastX = 0; - var lastY = 0; - var lastZ = 0; - var lastW = 0; - for (var n = 0; n < track.orientation.controls.length; n += 4) { - var x = track.orientation.controls[n]; - var y = track.orientation.controls[n + 1]; - var z = track.orientation.controls[n + 2]; - var w = track.orientation.controls[n + 3]; - if (lastX * x + lastY * y + lastZ * z + lastW * w < 0) { - track.orientation.controls[n] = -x; - track.orientation.controls[n + 1] = -y; - track.orientation.controls[n + 2] = -z; - track.orientation.controls[n + 3] = -w; - } - lastX = x; - lastY = y; - lastZ = z; - lastW = w; - } - } - group.transformTracks[group.transformTracks.length] = track; - } - animation.trackGroups[animation.trackGroups.length] = group; - } - this.animations[this.animations.length] = animation; - } +/** + * The curve's key dimension + * @type {number} + */ - this.PrepareFinished(true); - } - /** - * BindMeshToModel - * @param {Tw2GeometryMesh} mesh - * @param {Tw2GeometryModel} model - * @param {Tw2GeometryRes} res - */ +Tw2ColorCurve2.inputDimension = 4; - }, { - key: 'RenderAreasInstanced', +/** + * The curve's dimension + * @type {number} + */ +Tw2ColorCurve2.outputDimension = 4; +/** + * The curve's current value property + * @type {string} + */ +Tw2ColorCurve2.valueProperty = 'currentValue'; - /** - * RenderAreasInstanced - * @param {number} meshIx - * @param {number} start - * @param {number} count - * @param {Tw2Effect} effect - * @param {string} technique - * @param instanceVB - * @param instanceDecl - * @param instanceStride - * @param instanceCount - * @returns {Boolean} - */ - value: function RenderAreasInstanced(meshIx, start, count, effect, technique, instanceVB, instanceDecl, instanceStride, instanceCount) { - this.KeepAlive(); - if (!this.IsGood() || !effect.IsGood() || meshIx >= this.meshes.length) return false; +/** + * The curve's type + * @type {number} + */ +Tw2ColorCurve2.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE2; - var d = _Tw2Device.device, - mesh = this.meshes[meshIx], - passCount = effect.GetPassCount(technique); +/** + * The curve's key constructor + * @type {Tw2ColorKey2} + */ +Tw2ColorCurve2.Key = Tw2ColorKey2; - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); +/** + * Interpolation types + * @type {{CONSTANT: number, LINEAR: number}} + */ +Tw2ColorCurve2.Interpolation = { + CONSTANT: 0, + LINEAR: 1 +}; - for (var pass = 0; pass < passCount; ++pass) { - effect.ApplyPass(technique, pass); - var passInput = effect.GetPassInput(technique, pass); - if (passInput.elements.length === 0) continue; +/***/ }), +/* 130 */ +/***/ (function(module, exports, __webpack_require__) { - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, mesh.buffer); - mesh.declaration.SetPartialDeclaration(passInput, mesh.declaration.stride); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, instanceVB); - var resetData = instanceDecl.SetPartialDeclaration(passInput, instanceStride, 8, 1); - d.ApplyShadowState(); +"use strict"; - for (var i = 0; i < count; ++i) { - if (i + start < mesh.areas.length) { - var area = mesh.areas[i + start], - areaStart = area.start, - acount = area.count; - while (i + 1 < count) { - area = mesh.areas[i + 1 + start]; - if (area.start !== areaStart + acount * 2) break; - acount += area.count; - ++i; - } - d.ext.drawElementsInstanced(d.gl.TRIANGLES, acount, mesh.indexType, areaStart, instanceCount); - } - } - instanceDecl.ResetInstanceDivisors(resetData); - } - return true; - } +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2EventCurve = exports.Tw2EventKey = undefined; - /** - * RenderAreas - * @param {number} meshIx - * @param {number} start - * @param {number} count - * @param {Tw2Effect} effect - * @param {string} technique - * @returns {Boolean} - */ +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - }, { - key: 'RenderAreas', - value: function RenderAreas(meshIx, start, count, effect, technique) { - this.KeepAlive(); - if (!this.IsGood() || !effect.IsGood() || meshIx >= this.meshes.length) return false; +var _Tw2Curve2 = __webpack_require__(2); - var d = _Tw2Device.device, - mesh = this.meshes[meshIx] || this.meshes[0], - passCount = effect.GetPassCount(technique); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, mesh.buffer); - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - for (var pass = 0; pass < passCount; ++pass) { - effect.ApplyPass(technique, pass); - var passInput = effect.GetPassInput(technique, pass); - if (!mesh.declaration.SetDeclaration(passInput, mesh.declaration.stride)) { - _Tw2Logger.logger.log('res.error', { - log: 'error', - src: ['Tw2GeometryRes', 'RenderLines'], - msg: 'Error binding mesh to effect', - path: this.path, - type: 'geometry.meshbind', - data: { - pass: pass, - passInput: passInput, - meshStride: mesh.declaration.stride - } - }); - return false; - } +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - d.ApplyShadowState(); +/** + * Tw2EventKey + * + * @property {string} value + * @class + */ +var Tw2EventKey = exports.Tw2EventKey = function (_Tw2CurveKey) { + _inherits(Tw2EventKey, _Tw2CurveKey); - for (var i = 0; i < count; ++i) { - if (i + start < mesh.areas.length) { - var area = mesh.areas[i + start], - areaStart = area.start, - acount = area.count; + function Tw2EventKey() { + _classCallCheck(this, Tw2EventKey); - while (i + 1 < count) { - area = mesh.areas[i + 1 + start]; - if (area.start !== areaStart + acount * 2) break; - acount += area.count; - ++i; - } - d.gl.drawElements(d.gl.TRIANGLES, acount, mesh.indexType, areaStart); - } - } - } - return true; - } + var _this = _possibleConstructorReturn(this, (Tw2EventKey.__proto__ || Object.getPrototypeOf(Tw2EventKey)).call(this)); - /** - * RenderLines - * @param {number} meshIx - * @param {number} start - * @param {number} count - * @param {Tw2Effect} effect - * @param {string} technique - * @returns {Boolean} - */ + _this.value = ''; + return _this; + } - }, { - key: 'RenderLines', - value: function RenderLines(meshIx, start, count, effect, technique) { - this.KeepAlive(); - if (!this.IsGood() || !effect.IsGood() || meshIx >= this.meshes.length) return false; + return Tw2EventKey; +}(_Tw2Curve2.Tw2CurveKey); - var d = _Tw2Device.device, - mesh = this.meshes[meshIx], - passCount = effect.GetPassCount(technique); +/** + * Tw2EventCurve + * + * @property {string} value + * @property {Array.} keys + * @property {number} extrapolation + * @property {number} _time + * @property {number} _currentKey + * @property {number} _length + * @class + */ - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, mesh.buffer); - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); - for (var pass = 0; pass < passCount; ++pass) { - effect.ApplyPass(technique, pass); - var passInput = effect.GetPassInput(technique, pass); - if (!mesh.declaration.SetDeclaration(passInput, mesh.declaration.stride)) { - _Tw2Logger.logger.log('res.error', { - log: 'error', - src: ['Tw2GeometryRes', 'RenderLines'], - msg: 'Error binding mesh to effect', - path: this.path, - type: 'geometry.meshbind', - data: { - pass: pass, - passInput: passInput, - meshStride: mesh.declaration.stride - } - }); - return false; - } +var Tw2EventCurve = exports.Tw2EventCurve = function (_Tw2Curve) { + _inherits(Tw2EventCurve, _Tw2Curve); - d.ApplyShadowState(); + function Tw2EventCurve() { + _classCallCheck(this, Tw2EventCurve); - for (var i = 0; i < count; ++i) { - if (i + start < mesh.areas.length) { - var area = mesh.areas[i + start], - areaStart = area.start, - acount = area.count; + var _this2 = _possibleConstructorReturn(this, (Tw2EventCurve.__proto__ || Object.getPrototypeOf(Tw2EventCurve)).call(this)); - while (i + 1 < count) { - area = mesh.areas[i + 1 + start]; - if (area.start !== areaStart + acount * 2) break; - acount += area.count; - ++i; - } - d.gl.drawElements(d.gl.LINES, acount, mesh.indexType, areaStart); - } - } + _this2.value = ''; + _this2.keys = []; + _this2.extrapolation = 0; + _this2._time = 0; + _this2._currentKey = 0; + _this2._length = 0; + return _this2; + } + + /** + * Sorts the curve's keys + */ + + + _createClass(Tw2EventCurve, [{ + key: 'Sort', + value: function Sort() { + if (this.keys.length) { + this.keys.sort(_Tw2Curve2.Tw2Curve.Compare); + this._length = this.keys[this.keys.length - 1].time; } - return true; } /** - * RenderDebugInfo - * @param {function} debugHelper - * @returns {Boolean} + * Gets the curve's length + * @returns {number} */ }, { - key: 'RenderDebugInfo', - value: function RenderDebugInfo(debugHelper) { - if (!this.IsGood()) return false; - - for (var i = 0; i < this.models.length; ++i) { - if (this.models[i].skeleton) { - for (var j = 0; j < this.models[i].skeleton.bones.length; ++j) { - var b0 = this.models[i].skeleton.bones[j]; - if (b0.parentIndex >= 0) { - var b1 = this.models[i].skeleton.bones[b0.parentIndex]; - debugHelper['AddLine']([b0.worldTransform[12], b0.worldTransform[13], b0.worldTransform[14]], [b1.worldTransform[12], b1.worldTransform[13], b1.worldTransform[14]], [0, 0.7, 0, 1], [0, 0.7, 0, 1]); - } - } - } - } + key: 'GetLength', + value: function GetLength() { + return this._length; } /** - * Unloads webgl and javascript resources - * @returns {Boolean} + * Gets a value at the given time + * @param {number} time */ }, { - key: 'Unload', - value: function Unload() { - for (var i = 0; i < this.meshes.length; ++i) { - if (this.meshes[i].buffer) { - _Tw2Device.device.gl.deleteBuffer(this.meshes[i].buffer); - this.meshes[i].buffer = null; - } + key: 'UpdateValue', + value: function UpdateValue(time) { + if (this._length <= 0) { + return this.value; + } - if (this.meshes[i].indexes) { - _Tw2Device.device.gl.deleteBuffer(this.meshes[i].indexes); - this.meshes[i].indexes = null; - } + var before = this._time; + this._time = time; + if (this._time < before) { + this._currentKey = 0; } - this._isPurged = true; - this._isGood = false; - return true; + if (this.extrapolation === Tw2EventCurve.Extrapolation.CYCLE) { + var now = this._time % this._length; + if (now < before) this._currentKey = 0; + this._time = now; + } + + while (this._currentKey < this.keys.length && this._time >= this.keys[this._currentKey].time) { + this.value = this.keys[this._currentKey].value; + ++this._currentKey; + } } + }]); - /** - * ReadVertexBuffer - * @param {Tw2BinaryReader} reader - * @param {Tw2VertexDeclaration} declaration - * @returns {?Float32Array} - */ + return Tw2EventCurve; +}(_Tw2Curve2.Tw2Curve); - }], [{ - key: 'BindMeshToModel', - value: function BindMeshToModel(mesh, model, res) { - var binding = new _geometry.Tw2GeometryMeshBinding(); - binding.mesh = mesh; - for (var b = 0; b < binding.mesh.boneBindings.length; ++b) { - var name = binding.mesh.boneBindings[b], - bone = model.FindBoneByName(name); +/** + * The curve's key dimension + * @type {number} + */ - if (!bone) { - _Tw2Logger.logger.log('res.error', { - log: 'error', - src: ['Tw2GeometryRes', 'BindMeshToModel'], - msg: 'Mesh has invalid bone name for model', - path: res.path, - type: 'geometry.invalidbone', - data: { - mesh: binding.mesh.name, - bone: name, - model: model.name - } - }); - } else { - binding.bones[binding.bones.length] = bone; - } - } - model.meshBindings[model.meshBindings.length] = binding; - } - }, { - key: 'ReadVertexBuffer', - value: function ReadVertexBuffer(reader, declaration) { - var declCount = reader.ReadUInt8(); - var vertexSize = 0; - for (var declIx = 0; declIx < declCount; ++declIx) { - var element = new _vertex.Tw2VertexElement(); - element.usage = reader.ReadUInt8(); - element.usageIndex = reader.ReadUInt8(); - element.fileType = reader.ReadUInt8(); - element.type = _Tw2Device.device.gl.FLOAT; - element.elements = (element.fileType >> 5) + 1; - element.offset = vertexSize * 4; - declaration.elements[declIx] = element; - vertexSize += element.elements; - } - declaration.RebuildHash(); - declaration.stride = vertexSize * 4; +Tw2EventCurve.dimension = 1; - var vertexCount = reader.ReadUInt32(); - if (vertexCount === 0) return null; +/** + * The curve's output dimension + * @type {number} + */ +Tw2EventCurve.outputDimension = 1; - var buffer = new Float32Array(vertexSize * vertexCount); - var index = 0; - for (var vtxIx = 0; vtxIx < vertexCount; ++vtxIx) { - for (var _declIx = 0; _declIx < declCount; ++_declIx) { - var el = declaration.elements[_declIx]; - switch (el.fileType & 0xf) { - case 0: - if ((el.fileType & 0x10) != 0) { - for (var i = 0; i < el.elements; ++i) { - buffer[index++] = reader.ReadInt8() / 127.0; - } - } else { - for (var _i7 = 0; _i7 < el.elements; ++_i7) { - buffer[index++] = reader.ReadInt8(); - } - } - break; +/** + * The curve's current value property + * @type {string} + */ +Tw2EventCurve.valueProperty = 'value'; - case 1: - if ((el.fileType & 0x10) != 0) { - for (var _i8 = 0; _i8 < el.elements; ++_i8) { - buffer[index++] = reader.ReadInt8() / 32767.0; - } - } else { - for (var _i9 = 0; _i9 < el.elements; ++_i9) { - buffer[index++] = reader.ReadInt16(); - } - } - break; +/** + * The curve's type + * @type {number} + */ +Tw2EventCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE; - case 2: - for (var _i10 = 0; _i10 < el.elements; ++_i10) { - buffer[index++] = reader.ReadInt32(); - } - break; +/** + * The curve's key constructor + * @type {Tw2EventKey} + */ +Tw2EventCurve.Key = Tw2EventKey; - case 3: - for (var _i11 = 0; _i11 < el.elements; ++_i11) { - buffer[index++] = reader.ReadFloat16(); - } - break; +/** + * Extrapolation types + * @type {{NONE: number, CYCLE: number}} + */ +Tw2EventCurve.Extrapolation = { + NONE: 0, + CYCLE: 3 +}; - case 4: - for (var _i12 = 0; _i12 < el.elements; ++_i12) { - buffer[index++] = reader.ReadFloat32(); - } - break; +/***/ }), +/* 131 */ +/***/ (function(module, exports, __webpack_require__) { - case 8: - if ((el.fileType & 0x10) != 0) { - for (var _i13 = 0; _i13 < el.elements; ++_i13) { - buffer[index++] = reader.ReadUInt8() / 255.0; - } - } else { - for (var _i14 = 0; _i14 < el.elements; ++_i14) { - buffer[index++] = reader.ReadUInt8(); - } - } - break; +"use strict"; - case 9: - if ((el.fileType & 0x10) != 0) { - for (var _i15 = 0; _i15 < declaration.elements[_declIx].elements; ++_i15) { - buffer[index++] = reader.ReadUInt8() / 65535.0; - } - } else { - for (var _i16 = 0; _i16 < el.elements; ++_i16) { - buffer[index++] = reader.ReadUInt16(); - } - } - break; - case 10: - for (var _i17 = 0; _i17 < el.elements; ++_i17) { - buffer[index++] = reader.ReadUInt32(); - } - break; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2PerlinCurve = undefined; - default: - _Tw2Logger.logger.log('res.error', { - log: 'error', - src: ['Tw2GeometryRes', 'ReadVertexBuffer'], - msg: 'Error loading wbg data', - path: self.path, - type: 'geometry.filetype', - value: el.fileType & 0xf - }); - throw 1; - } - } - } - return buffer; - } +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - /** - * ReadIndexBuffer - * @property {Tw2BinaryReader} - * @returns {Uint16Array|Uint32Array} - * @private - */ +var _global = __webpack_require__(0); - }, { - key: 'ReadIndexBuffer', - value: function ReadIndexBuffer(reader) { - var ibType = reader.ReadUInt8(), - indexCount = reader.ReadUInt32(); +var _Tw2Curve2 = __webpack_require__(2); - if (ibType === 0) { - var indexes = new Uint16Array(indexCount); - for (var i = 0; i < indexCount; ++i) { - indexes[i] = reader.ReadUInt16(); - } - return indexes; - } else { - var _indexes = new Uint32Array(indexCount); - for (var _i18 = 0; _i18 < indexCount; ++_i18) { - _indexes[_i18] = reader.ReadUInt32(); - } - return _indexes; - } - } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - /** - * ReadCurve - * @returns {Tw2GeometryCurve} - */ +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - }, { - key: 'ReadCurve', - value: function ReadCurve(reader) { - var type = reader.ReadUInt8(); - if (type === 0) return null; +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - var curve = new _geometry.Tw2GeometryCurve(); - curve.dimension = reader.ReadUInt8(); - curve.degree = reader.ReadUInt8(); - var knotCount = reader.ReadUInt32(); - curve.knots = new Float32Array(knotCount); - for (var i = 0; i < knotCount; ++i) { - curve.knots[i] = reader.ReadFloat32(); - } - var controlCount = reader.ReadUInt32(); - curve.controls = new Float32Array(controlCount); - for (var _i19 = 0; _i19 < controlCount; ++_i19) { - curve.controls[_i19] = reader.ReadFloat32(); - } - return curve; - } - }]); +/** + * Tw2PerlinCurve + * + * @property {number} start + * @property {number} speed + * @property {number} alpha + * @property {number} beta + * @property {number} offset + * @property {number} scale + * @property {number} N + * @property {number} _startOffset + * @class + */ +var Tw2PerlinCurve = exports.Tw2PerlinCurve = function (_Tw2Curve) { + _inherits(Tw2PerlinCurve, _Tw2Curve); - return Tw2GeometryRes; -}(_Tw2Resource2.Tw2Resource); + function Tw2PerlinCurve() { + _classCallCheck(this, Tw2PerlinCurve); + + var _this = _possibleConstructorReturn(this, (Tw2PerlinCurve.__proto__ || Object.getPrototypeOf(Tw2PerlinCurve)).call(this)); + + _this.value = 0; + _this.start = 0; + _this.speed = 1; + _this.alpha = 1.1; + _this.beta = 2; + _this.offset = 0; + _this.scale = 1; + _this.N = 3; + _this._startOffset = Math.random() * 100; + return _this; + } + + /** + * Updates the current value at the given time + * @param {number} time + */ + + + _createClass(Tw2PerlinCurve, [{ + key: 'UpdateValue', + value: function UpdateValue(time) { + this.value = this.GetValueAt(time); + } + + /** + * Gets a value at a specific time + * @param {number} time + * @returns {number} + */ + + }, { + key: 'GetValueAt', + value: function GetValueAt(time) { + time -= this._startOffset; + return (_global.noise.perlin1D(time * this.speed, this.alpha, this.beta, this.N) + 1) / 2 * this.scale + this.offset; + } + }]); + + return Tw2PerlinCurve; +}(_Tw2Curve2.Tw2Curve); + +/** + * The curve's dimension + * @type {number} + */ + + +Tw2PerlinCurve.outputDimension = 1; /** - * Request Response Type + * The curve's current value property * @type {string} */ +Tw2PerlinCurve.valueProperty = 'value'; - -Tw2GeometryRes.prototype.requestResponseType = 'arraybuffer'; +/** + * The curve's type + * @type {number} + */ +Tw2PerlinCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE_NO_KEYS; /***/ }), -/* 136 */ +/* 132 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -27312,17 +27049,13 @@ Tw2GeometryRes.prototype.requestResponseType = 'arraybuffer'; Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2VideoRes = undefined; +exports.Tw2QuaternionCurve = exports.Tw2QuaternionKey2 = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2Device = __webpack_require__(2); - -var _Tw2ResMan = __webpack_require__(6); +var _global = __webpack_require__(0); -var _Tw2Logger = __webpack_require__(4); - -var _Tw2Resource2 = __webpack_require__(12); +var _Tw2Curve2 = __webpack_require__(2); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -27331,270 +27064,263 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2VideoRes + * Tw2QuaternionKey2 * - * @property {?WebGLTexture} texture - The video's webgl texture - * @property {?HTMLVideoElement} video - The video - * @property {number} width - The texture's width - * @property {number} height - The texture's height - * @property {boolean} cycle - Enables video looping - * @property {boolean} playOnLoad - Plays the video as soon as it is able to - * @property {number} _currentSampler - The current sampler's hash - * @property {number} _currentTime - The video's current time - * @property {boolean} _playable - Identifies if the video is playable - * @property {boolean} _isPlaying - Identifies if the video is playing - * @property {?Function} _onPlaying - An optional callback which is fired when the video is playing - * @property {?Function} _onPause - An optional callback which is fired when the video is paused - * @property {?Function} _onEnded - An optional callback which is fired when the video has ended + * @property {quat} value + * @property {vec4} leftTangent + * @property {vec4} rightTangent + * @property {number} interpolation * @class */ -var Tw2VideoRes = exports.Tw2VideoRes = function (_Tw2Resource) { - _inherits(Tw2VideoRes, _Tw2Resource); - - function Tw2VideoRes() { - _classCallCheck(this, Tw2VideoRes); - - var _this = _possibleConstructorReturn(this, (Tw2VideoRes.__proto__ || Object.getPrototypeOf(Tw2VideoRes)).call(this)); +var Tw2QuaternionKey2 = exports.Tw2QuaternionKey2 = function (_Tw2CurveKey) { + _inherits(Tw2QuaternionKey2, _Tw2CurveKey); - _this.texture = null; - _this.video = null; - _this.width = 0; - _this.height = 0; - _this.cycle = true; - _this.playOnLoad = true; + function Tw2QuaternionKey2() { + _classCallCheck(this, Tw2QuaternionKey2); - _this._currentSampler = 0; - _this._currentTime = -1; - _this._playable = false; - _this._isPlaying = false; + var _this = _possibleConstructorReturn(this, (Tw2QuaternionKey2.__proto__ || Object.getPrototypeOf(Tw2QuaternionKey2)).call(this)); - _this._onPlaying = null; - _this._onPause = null; - _this._onEnded = null; + _this.value = _global.quat.create(); + _this.leftTangent = _global.vec4.create(); + _this.rightTangent = _global.vec4.create(); + _this.interpolation = 1; return _this; } - /** - * Checks if the resource is good - * @returns {boolean} - */ + return Tw2QuaternionKey2; +}(_Tw2Curve2.Tw2CurveKey); +/** + * Tw2QuaternionCurve + * + * @property {boolean} cycle + * @property {boolean} reversed + * @property {number} timeOffset + * @property {number} timeScale + * @property {quat} startValue + * @property {quat} currentValue + * @property {quat} endValue + * @property {vec4} startTangent + * @property {vec4} endTangent + * @property {number} interpolation + * @property {Array.} keys + * @property {number} length + * @class + */ - _createClass(Tw2VideoRes, [{ - key: 'IsGood', - value: function IsGood() { - this.KeepAlive(); - return this._isGood && this.video && this._playable; - } - /** - * Keeps the resource alive - */ +var Tw2QuaternionCurve = exports.Tw2QuaternionCurve = function (_Tw2Curve) { + _inherits(Tw2QuaternionCurve, _Tw2Curve); - }, { - key: 'KeepAlive', - value: function KeepAlive() { - this.activeFrame = _Tw2ResMan.resMan.activeFrame; - } + function Tw2QuaternionCurve() { + _classCallCheck(this, Tw2QuaternionCurve); - /** - * Plays the animation - * @param {boolean} [cycle] Sets playing to loop - * @param {Function|null} [onFinished=null] Optional callback to fire when the video has finished - */ + var _this2 = _possibleConstructorReturn(this, (Tw2QuaternionCurve.__proto__ || Object.getPrototypeOf(Tw2QuaternionCurve)).call(this)); - }, { - key: 'Play', - value: function Play() { - var cycle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - var onFinished = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + _this2.cycle = false; + _this2.reversed = false; + _this2.timeOffset = 0; + _this2.timeScale = 1; + _this2.startValue = _global.quat.create(); + _this2.currentValue = _global.quat.create(); + _this2.endValue = _global.quat.create(); + _this2.startTangent = _global.vec4.create(); + _this2.endTangent = _global.vec4.create(); + _this2.interpolation = 1; + _this2.keys = []; + _this2.length = 0; + return _this2; + } - this.cycle = cycle; - this._onEnded = onFinished; + /** + * Sorts the curve's keys + */ - if (this.video && this._playable) { - this.video.loop = this.cycle; - this.video.play(); - } else { - this.playOnLoad = true; - } + + _createClass(Tw2QuaternionCurve, [{ + key: 'Sort', + value: function Sort() { + _Tw2Curve2.Tw2Curve.Sort2(this); } /** - * Pauses the video + * Gets the curve's length + * @returns {number} */ }, { - key: 'Pause', - value: function Pause() { - if (this.video) { - this.video.pause(); - } else { - this.playOnLoad = false; - } + key: 'GetLength', + value: function GetLength() { + return this.length; } /** - * Prepares the resource - * @param {string} text + * Updates the current value at the given time + * @param {number} time */ }, { - key: 'Prepare', - value: function Prepare(text) { - var gl = _Tw2Device.device.gl; - - switch (text) { - case 'mp4': - case 'webm': - case 'ogg': - this.texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.video); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.bindTexture(gl.TEXTURE_2D, null); - this.width = this.video.width; - this.height = this.video.height; - this.video.loop = this.cycle; - if (this.playOnLoad) this.video.play(); - this.PrepareFinished(true); - } + key: 'UpdateValue', + value: function UpdateValue(time) { + this.GetValueAt(time, this.currentValue); } /** - * Loads the resource from a path - * - * @param {string} path - * @returns {boolean} returns true to tell the resMan not to handle http requests + * Gets a value at a specific time + * @param {number} time + * @param {quat} value + * @returns {quat} */ }, { - key: 'DoCustomLoad', - value: function DoCustomLoad(path) { - var _this2 = this; - - var ext = _Tw2ResMan.resMan.constructor.GetPathExt(path); - this.LoadStarted(); - _Tw2ResMan.resMan._pendingLoads++; - - this.video = document.createElement('video'); - this.video.crossOrigin = 'anonymous'; - this.video.muted = true; - - /** - * Fires on errors - */ - this.video.onerror = function () { - _Tw2ResMan.resMan._pendingLoads--; - _Tw2Logger.logger.log('res.error', { - log: 'error', - src: ['Tw2TextureRes', 'DoCustomLoad'], - msg: 'Error loading resource', - type: 'http.error', - path: path - }); - _this2.LoadFinished(false); - _this2.PrepareFinished(false); - _this2.video = null; - }; + key: 'GetValueAt', + value: function GetValueAt(time, value) { + time = time / this.timeScale + this.timeOffset; - /** - * Fires when the video is playable - */ - this.video.oncanplay = function () { - _this2._playable = true; - _this2.video.oncanplay = null; - _Tw2ResMan.resMan._pendingLoads--; - _Tw2ResMan.resMan._prepareQueue.push([_this2, ext, null]); - _this2.LoadFinished(true); - }; + if (this.length <= 0 || time <= 0) { + value[0] = this.startValue[0]; + value[1] = this.startValue[1]; + value[2] = this.startValue[2]; + return value; + } - /** - * Fires when the video has ended - */ - this.video.onended = function () { - _this2._isPlaying = false; - if (_this2._onEnded) _this2._onEnded(_this2); - }; + if (time > this.length) { + if (this.cycle) { + time = time % this.length; + } else if (this.reversed) { + value[0] = this.startValue[0]; + value[1] = this.startValue[1]; + value[2] = this.startValue[2]; + return value; + } else { + value[0] = this.endValue[0]; + value[1] = this.endValue[1]; + value[2] = this.endValue[2]; + return value; + } + } - /** - * Fires when the video is paused - */ - this.video.onpause = function () { - _this2._isPlaying = false; - if (_this2._onPause) _this2._onPause(_this2); - }; + if (this.reversed) { + time = this.length - time; + } - /** - * Fires when the video is playing - */ - this.video.onplaying = function () { - _this2._isPlaying = true; - if (_this2._onPlaying) _this2._onPlaying(_this2); - }; + if (this.keys.length === 0) { + return this.Interpolate(time, null, null, value); + } - this.video.src = path; - return true; - } + var startKey = this.keys[0], + endKey = this.keys[this.keys.length - 1]; - /** - * Unloads the video and texture from memory - */ + if (time <= startKey.time) { + return this.Interpolate(time, null, startKey, value); + } else if (time >= endKey.time) { + return this.Interpolate(time, endKey, null, value); + } - }, { - key: 'Unload', - value: function Unload() { - if (this.texture) { - _Tw2Device.device.gl.deleteTexture(this.texture); - this.texture = null; + for (var i = 0; i + 1 < this.keys.length; ++i) { + startKey = this.keys[i]; + endKey = this.keys[i + 1]; + if (startKey.time <= time && endKey.time > time) break; } - this._isPlaying = false; - this._playable = false; - this.playOnLoad = true; - this.video = null; - return true; + return this.Interpolate(time, startKey, endKey, value); } /** - * Bind - * @param {Tw2SamplerState} sampler + * Interpolate + * @param {number} time + * @param {null|Tw2QuaternionKey} lastKey + * @param {null|Tw2QuaternionKey} nextKey + * @param {quat} value + * @returns {*} */ }, { - key: 'Bind', - value: function Bind(sampler) { - var d = _Tw2Device.device; + key: 'Interpolate', + value: function Interpolate(time, lastKey, nextKey, value) { + value[0] = this.startValue[0]; + value[1] = this.startValue[1]; + value[2] = this.startValue[2]; - this.KeepAlive(); - var targetType = sampler.samplerType; - if (targetType !== d.gl.TEXTURE_2D) return; + var startValue = this.startValue, + endValue = this.endValue, + interp = this.interpolation, + deltaTime = this.length; - if (!this.texture) { - d.gl.bindTexture(d.gl.TEXTURE_2D, d.GetFallbackTexture()); - return; + if (lastKey !== null) { + interp = lastKey.interpolation; + time -= lastKey.time; } - this._currentTime = this.video.currentTime; - d.gl.bindTexture(d.gl.TEXTURE_2D, this.texture); - d.gl.texImage2D(d.gl.TEXTURE_2D, 0, d.gl.RGBA, d.gl.RGBA, d.gl.UNSIGNED_BYTE, this.video); - d.gl.bindTexture(d.gl.TEXTURE_2D, null); + switch (interp) { + case Tw2QuaternionCurve.Interpolation.SPHERICAL_LINEAR: + if (lastKey && nextKey) { + startValue = lastKey.value; + endValue = nextKey.value; + deltaTime = nextKey.time - lastKey.time; + } else if (nextKey) { + endValue = nextKey.value; + deltaTime = nextKey.time; + } else if (lastKey) { + startValue = lastKey.value; + deltaTime = this.length - lastKey.time; + } - d.gl.bindTexture(targetType, this.texture); - if (sampler.hash !== this._currentSampler) { - sampler.Apply(false); - this._currentSampler = sampler.hash; + _global.quat.slerp(value, startValue, endValue, time / deltaTime); + return value; + + default: + return value; } } }]); - return Tw2VideoRes; -}(_Tw2Resource2.Tw2Resource); + return Tw2QuaternionCurve; +}(_Tw2Curve2.Tw2Curve); + +/** + * The curve's key dimension + * @type {number} + */ + + +Tw2QuaternionCurve.inputDimension = 4; + +/** + * The curve's dimension + * @type {number} + */ +Tw2QuaternionCurve.outputDimension = 4; + +/** + * The curve's current value property + * @type {string} + */ +Tw2QuaternionCurve.valueProperty = 'currentValue'; + +/** + * The curve's type + * @type {number} + */ +Tw2QuaternionCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE2; + +/** + * The curve's key constructor + * @type {Tw2QuaternionKey2} + */ +Tw2QuaternionCurve.Key = Tw2QuaternionKey2; + +/** + * Interpolation types + * @type {{CONSTANT: number, SPHERICAL_LINEAR: number}} + */ +Tw2QuaternionCurve.Interpolation = { + CONSTANT: 0, + SPHERICAL_LINEAR: 4 +}; /***/ }), -/* 137 */ +/* 133 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -27603,21 +27329,90 @@ var Tw2VideoRes = exports.Tw2VideoRes = function (_Tw2Resource) { Object.defineProperty(exports, "__esModule", { value: true }); +exports.Tw2RandomConstantCurve = undefined; + +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2PostProcess = __webpack_require__(138); +var _Tw2Curve2 = __webpack_require__(2); -Object.keys(_Tw2PostProcess).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2PostProcess[key]; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +/** + * Tw2RandomConstantCurve + * + * @property {number} currentValue + * @property {number} min + * @property {number} max + * @property {boolean} hold + * @class + */ +var Tw2RandomConstantCurve = exports.Tw2RandomConstantCurve = function (_Tw2Curve) { + _inherits(Tw2RandomConstantCurve, _Tw2Curve); + + function Tw2RandomConstantCurve() { + _classCallCheck(this, Tw2RandomConstantCurve); + + var _this = _possibleConstructorReturn(this, (Tw2RandomConstantCurve.__proto__ || Object.getPrototypeOf(Tw2RandomConstantCurve)).call(this)); + + _this.value = 0; + _this.min = 0; + _this.max = 1; + _this.hold = true; + return _this; + } + + /** + * Updates the current value at the given time + */ + + + _createClass(Tw2RandomConstantCurve, [{ + key: 'UpdateValue', + value: function UpdateValue() { + this.value = this.GetValueAt(); } - }); -}); + + /** + * Gets a value at a specific time + * @returns {number} + */ + + }, { + key: 'GetValueAt', + value: function GetValueAt() { + return this.hold ? this.value : this.min + (this.max - this.min) * Math.random(); + } + }]); + + return Tw2RandomConstantCurve; +}(_Tw2Curve2.Tw2Curve); + +/** + * The curve's dimension + * @type {number} + */ + + +Tw2RandomConstantCurve.outputDimension = 1; + +/** + * The curve's current value property + * @type {string} + */ +Tw2RandomConstantCurve.valueProperty = 'value'; + +/** + * The curve's type + * @type {number} + */ +Tw2RandomConstantCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE_NO_KEYS; /***/ }), -/* 138 */ +/* 134 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -27626,212 +27421,183 @@ Object.keys(_Tw2PostProcess).forEach(function (key) { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2PostProcess = undefined; +exports.Tw2RigidOrientation = exports.Tw2Torque = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _global = __webpack_require__(17); +var _global = __webpack_require__(0); + +var _Tw2Curve2 = __webpack_require__(2); -var _Tw2RenderTarget = __webpack_require__(56); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var _mesh = __webpack_require__(47); +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } -var _resource = __webpack_require__(28); +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +/** + * Tw2Torque + * + * @property {quat} rot0 + * @property {vec3} omega0 + * @property {vec3} torque + * @class + */ +var Tw2Torque = exports.Tw2Torque = function (_Tw2CurveKey) { + _inherits(Tw2Torque, _Tw2CurveKey); + + function Tw2Torque() { + _classCallCheck(this, Tw2Torque); + + var _this = _possibleConstructorReturn(this, (Tw2Torque.__proto__ || Object.getPrototypeOf(Tw2Torque)).call(this)); + + _this.rot0 = _global.quat.create(); + _this.omega0 = _global.vec3.create(); + _this.torque = _global.vec3.create(); + return _this; + } + + return Tw2Torque; +}(_Tw2Curve2.Tw2CurveKey); /** - * Creates a bloom post effect + * Tw2RigidOrientation * - * @property {number} width - * @property {number} height - * @property {Tw2TextureRes} texture - * @property {Tw2RenderTarget} quadRT0 - * @property {Tw2RenderTarget} quadRT1 - * @property {Array.} steps + * @property {string} name + * @property {number} I + * @property {number} drag + * @property {quat} value + * @property {number} start + * @property {Array.} states + * @property {number} length * @class */ -var Tw2PostProcess = exports.Tw2PostProcess = function () { - function Tw2PostProcess() { - _classCallCheck(this, Tw2PostProcess); - this.width = 0; - this.height = 0; - this.texture = null; - this.quadRT0 = new _Tw2RenderTarget.Tw2RenderTarget(); - this.quadRT1 = new _Tw2RenderTarget.Tw2RenderTarget(); - this.steps = [{ - 'effect': _mesh.Tw2Effect.create({ - effectFilePath: 'res:/Graphics/Effect/Managed/Space/PostProcess/ColorDownFilter4.fx', - parameters: { - 'g_texelSize': [1, 1, 1, 1], - 'BlitCurrent': '' - } - }), - 'rt': this.quadRT1, - 'inputs': { - 'BlitCurrent': null - } - }, { - 'effect': _mesh.Tw2Effect.create({ - effectFilePath: 'res:/Graphics/Effect/Managed/Space/PostProcess/ColorHighPassFilter.fx', - parameters: { - 'LuminanceThreshold': 0.85, - 'LuminanceScale': 2, - 'BlitCurrent': '' - } - }), - 'rt': this.quadRT0, - 'inputs': { - 'BlitCurrent': this.quadRT1 - } - }, { - 'effect': _mesh.Tw2Effect.create({ - effectFilePath: 'res:/Graphics/Effect/Managed/Space/PostProcess/ColorExpBlurHorizontalBig.fx', - parameters: { - 'g_texelSize': [1, 1, 1, 1], - 'BlitCurrent': '' - } - }), - 'rt': this.quadRT1, - 'inputs': { - 'BlitCurrent': this.quadRT0 - } - }, { - 'effect': _mesh.Tw2Effect.create({ - effectFilePath: 'res:/Graphics/Effect/Managed/Space/PostProcess/ColorExpBlurVerticalBig.fx', - parameters: { - 'g_texelSize': [1, 1, 1, 1], - 'BlitCurrent': '' - } - }), - 'rt': this.quadRT0, - 'inputs': { - 'BlitCurrent': this.quadRT1 - } - }, { - 'effect': _mesh.Tw2Effect.create({ - effectFilePath: 'res:/Graphics/Effect/Managed/Space/PostProcess/ColorUpFilter4_Add.fx', - parameters: { - 'g_texelSize': [1, 1, 1, 1], - 'ScalingFactor': 1, - 'BlitCurrent': '', - 'BlitOriginal': '' - } - }), - 'rt': null, - 'inputs': { - 'BlitCurrent': this.quadRT0, - 'BlitOriginal': null - } - }]; + +var Tw2RigidOrientation = exports.Tw2RigidOrientation = function (_Tw2Curve) { + _inherits(Tw2RigidOrientation, _Tw2Curve); + + function Tw2RigidOrientation() { + _classCallCheck(this, Tw2RigidOrientation); + + var _this2 = _possibleConstructorReturn(this, (Tw2RigidOrientation.__proto__ || Object.getPrototypeOf(Tw2RigidOrientation)).call(this)); + + _this2.name = ''; + _this2.I = 1; + _this2.drag = 1; + _this2.value = _global.quat.create(); + _this2.start = 0; + _this2.states = []; + _this2.length = 0; + return _this2; } /** - * Internal render/update function. It is called every frame. + * Sorts the curve's keys */ - _createClass(Tw2PostProcess, [{ - key: 'Render', - value: function Render() { - var width = _global.device.viewportWidth, - height = _global.device.viewportHeight; - - if (width <= 0 || height <= 0) return; + _createClass(Tw2RigidOrientation, [{ + key: 'Sort', + value: function Sort() { + _Tw2Curve2.Tw2Curve.Sort(this, this.states); + } - if (this.texture === null) { - this.texture = new _resource.Tw2TextureRes(); - this.texture.Attach(_global.device.gl.createTexture()); - } + /** + * Gets the curve's length + * @returns {number} + */ - if (width !== this.width || height !== this.height) { - _global.device.gl.bindTexture(_global.device.gl.TEXTURE_2D, this.texture.texture); - _global.device.gl.texImage2D(_global.device.gl.TEXTURE_2D, 0, _global.device.gl.RGBA, width, height, 0, _global.device.gl.RGBA, _global.device.gl.UNSIGNED_BYTE, null); - _global.device.gl.bindTexture(_global.device.gl.TEXTURE_2D, null); + }, { + key: 'GetLength', + value: function GetLength() { + return this.length; + } - this.quadRT0.Create(width / 4, height / 4, false); - this.quadRT1.Create(width / 4, height / 4, false); + /** + * Updates the current value at the given time + * @param {number} time + */ - this.width = width; - this.height = height; + }, { + key: 'UpdateValue', + value: function UpdateValue(time) { + this.GetValueAt(time, this.value); + } - for (var i = 0; i < this.steps.length; ++i) { - var step = this.steps[i]; - for (var name in step.inputs) { - if (step.inputs.hasOwnProperty(name)) { - if (step.inputs[name]) { - step.effect.parameters[name].textureRes = step.inputs[name].texture; - } else { - step.effect.parameters[name].textureRes = this.texture; - } - } - } + /** + * Gets a value at a specific time + * @param {number} time + * @param {quat} value + * @returns {quat} + */ - if ('g_texelSize' in step.effect.parameters && 'BlitCurrent' in step.inputs) { - var size = step.effect.parameters['g_texelSize'], - rt = step.inputs['BlitCurrent']; + }, { + key: 'GetValueAt', + value: function GetValueAt(time, value) { + if (this.states.length === 0 || time < 0 || time < this.states[0].time) { + return _global.quat.copy(value, this.value); + } - if (rt) { - size.value[0] = 1.0 / rt.width; - size.value[1] = 1.0 / rt.width; - } else { - size.value[0] = 1.0 / width; - size.value[1] = 1.0 / width; - } - size.OnValueChanged(); + var key = 0; + if (time >= this.states[this.states.length - 1].time) { + key = this.states.length - 1; + } else { + for (; key + 1 < this.states.length; ++key) { + if (time >= this.states[key].time && time < this.states[key + 1].time) { + break; } } } - _global.device.gl.bindTexture(_global.device.gl.TEXTURE_2D, this.texture.texture); - _global.device.gl.copyTexImage2D(_global.device.gl.TEXTURE_2D, 0, _global.device.alphaBlendBackBuffer ? _global.device.gl.RGBA : _global.device.gl.RGB, 0, 0, width, height, 0); - _global.device.gl.bindTexture(_global.device.gl.TEXTURE_2D, null); - _global.device.SetStandardStates(_global.device.RM_OPAQUE); + var vec3_0 = _Tw2Curve2.Tw2Curve.global.vec3_0, + quat_0 = _Tw2Curve2.Tw2Curve.global.quat_0; - for (var _i = 0; _i < this.steps.length; ++_i) { - var _step = this.steps[_i]; - if (_step.rt !== null) { - _step.rt.Set(); - } else { - _global.device.gl.bindFramebuffer(_global.device.gl.FRAMEBUFFER, null); - _global.device.gl.viewport(0, 0, width, height); - } - _global.device.RenderFullScreenQuad(_step.effect); - } + var ck = this.states[key]; + _global.vec3.exponentialDecay(vec3_0, ck.omega0, ck.torque, this.I, this.drag, time - ck.time); + _global.quat.exp(quat_0, vec3_0); + _global.quat.multiply(value, this.states[key].rot0, quat_0); + return value; } }]); - return Tw2PostProcess; -}(); + return Tw2RigidOrientation; +}(_Tw2Curve2.Tw2Curve); -/***/ }), -/* 139 */ -/***/ (function(module, exports, __webpack_require__) { +/** + * The curve's key dimension + * @type {number} + */ -"use strict"; +Tw2RigidOrientation.inputDimension = 4; -Object.defineProperty(exports, "__esModule", { - value: true -}); +/** + * The curve's dimension + * @type {number} + */ +Tw2RigidOrientation.outputDimension = 4; -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +/** + * The curve's current value property + * @type {string} + */ +Tw2RigidOrientation.valueProperty = 'value'; /** - * Tw2Float - * - * @property {number} value - * @class + * The curve's type + * @type {number} */ -var Tw2Float = exports.Tw2Float = function Tw2Float() { - _classCallCheck(this, Tw2Float); +Tw2RigidOrientation.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE; - this.value = 0; -}; +/** + * The curve's key constructor + * @type {Tw2Torque} + */ +Tw2RigidOrientation.Key = Tw2Torque; /***/ }), -/* 140 */ +/* 135 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -27840,152 +27606,259 @@ var Tw2Float = exports.Tw2Float = function Tw2Float() { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2Frustum = undefined; +exports.Tw2RotationCurve = exports.Tw2QuaternionKey = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); + +var _Tw2Curve2 = __webpack_require__(2); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + /** - * Tw2Frustum + * Tw2QuaternionKey * - * @property {Array.} planes - * @property {vec3} viewPos - * @property {vec3} viewDir - * @property {number} halfWidthProjection + * @property {number} time + * @property {quat} value + * @property {vec4} leftTangent + * @property {vec4} rightTangent + * @property {number} interpolation * @class */ -var Tw2Frustum = exports.Tw2Frustum = function () { - function Tw2Frustum() { - _classCallCheck(this, Tw2Frustum); +var Tw2QuaternionKey = exports.Tw2QuaternionKey = function (_Tw2CurveKey) { + _inherits(Tw2QuaternionKey, _Tw2CurveKey); - this.planes = [_math.vec4.create(), _math.vec4.create(), _math.vec4.create(), _math.vec4.create(), _math.vec4.create(), _math.vec4.create()]; - this.viewPos = _math.vec3.create(); - this.viewDir = _math.vec3.create(); - this.halfWidthProjection = 1; + function Tw2QuaternionKey() { + _classCallCheck(this, Tw2QuaternionKey); + + var _this = _possibleConstructorReturn(this, (Tw2QuaternionKey.__proto__ || Object.getPrototypeOf(Tw2QuaternionKey)).call(this)); + + _this.value = _global.quat.create(); + _this.left = _global.vec4.create(); + _this.right = _global.vec4.create(); + _this.interpolation = 5; + return _this; } - /** - * Initializes the Tw2Frustum - * - * @param {mat4} view - View Matrix - * @param {mat4} proj - Projection Matrix - * @param {number} viewportSize - * @param {mat4} [viewInverse] Optional viewInverse matrix - * @param {mat4} [viewProjection] Optional viewProjection matrix - */ + return Tw2QuaternionKey; +}(_Tw2Curve2.Tw2CurveKey); +/** + * Tw2RotationCurve + * + * @property {number} start + * @property {quat} value + * @property {number} extrapolation + * @property {Array.} keys + * @property {number} _currentKey + * @property {number} length + * @class` + */ - _createClass(Tw2Frustum, [{ - key: 'Initialize', - value: function Initialize(view, proj, viewportSize, viewInverse, viewProjection) { - var mat4_0 = Tw2Frustum.global.mat4_0; - var viewInv = viewInverse ? viewInverse : _math.mat4.invert(mat4_0, view); - this.viewPos.set(viewInv.subarray(12, 14)); - this.viewDir.set(viewInv.subarray(8, 10)); - this.halfWidthProjection = proj[0] * viewportSize * 0.5; +var Tw2RotationCurve = exports.Tw2RotationCurve = function (_Tw2Curve) { + _inherits(Tw2RotationCurve, _Tw2Curve); - var viewProj = viewProjection ? viewProjection : _math.mat4.multiply(mat4_0, proj, view); - this.planes[0][0] = viewProj[2]; - this.planes[0][1] = viewProj[6]; - this.planes[0][2] = viewProj[10]; - this.planes[0][3] = viewProj[14]; + function Tw2RotationCurve() { + _classCallCheck(this, Tw2RotationCurve); - this.planes[1][0] = viewProj[3] + viewProj[0]; - this.planes[1][1] = viewProj[7] + viewProj[4]; - this.planes[1][2] = viewProj[11] + viewProj[8]; - this.planes[1][3] = viewProj[15] + viewProj[12]; + var _this2 = _possibleConstructorReturn(this, (Tw2RotationCurve.__proto__ || Object.getPrototypeOf(Tw2RotationCurve)).call(this)); - this.planes[2][0] = viewProj[3] - viewProj[1]; - this.planes[2][1] = viewProj[7] - viewProj[5]; - this.planes[2][2] = viewProj[11] - viewProj[9]; - this.planes[2][3] = viewProj[15] - viewProj[13]; + _this2.start = 0; + _this2.value = _global.quat.create(); + _this2.extrapolation = 0; + _this2.keys = []; + _this2._currentKey = 1; + _this2.length = 0; + return _this2; + } - this.planes[3][0] = viewProj[3] - viewProj[0]; - this.planes[3][1] = viewProj[7] - viewProj[4]; - this.planes[3][2] = viewProj[11] - viewProj[8]; - this.planes[3][3] = viewProj[15] - viewProj[12]; + /** + * Sorts the curve's children + */ - this.planes[4][0] = viewProj[3] + viewProj[1]; - this.planes[4][1] = viewProj[7] + viewProj[5]; - this.planes[4][2] = viewProj[11] + viewProj[9]; - this.planes[4][3] = viewProj[15] + viewProj[13]; - this.planes[5][0] = viewProj[3] - viewProj[2]; - this.planes[5][1] = viewProj[7] - viewProj[6]; - this.planes[5][2] = viewProj[11] - viewProj[10]; - this.planes[5][3] = viewProj[15] - viewProj[14]; + _createClass(Tw2RotationCurve, [{ + key: 'Sort', + value: function Sort() { + _Tw2Curve2.Tw2Curve.Sort(this); + } - for (var i = 0; i < 6; ++i) { - var len = _math.vec3.length(this.planes[i]); - this.planes[i][0] /= len; - this.planes[i][1] /= len; - this.planes[i][2] /= len; - this.planes[i][3] /= len; - } + /** + * Gets the curve's length + * @returns {number} + */ + + }, { + key: 'GetLength', + value: function GetLength() { + return this.length; } /** - * Checks to see if a sphere is visible within the frustum - * - * @param {vec3} center - * @param {number} radius - * @returns {boolean} + * Updates the current value at the given time + * @param {number} time */ }, { - key: 'IsSphereVisible', - value: function IsSphereVisible(center, radius) { - for (var i = 0; i < 6; ++i) { - if (this.planes[i][0] * center[0] + this.planes[i][1] * center[1] + this.planes[i][2] * center[2] + this.planes[i][3] < -radius) { - return false; - } - } - return true; + key: 'UpdateValue', + value: function UpdateValue(time) { + this.GetValueAt(time, this.value); } /** - * GetPixelSizeAcross - * - * @param {vec3} center - * @param {number} radius - * @returns {number} + * Gets a value at a specific time + * @param {number} time + * @param {quat} value + * @returns {quat} */ }, { - key: 'GetPixelSizeAcross', - value: function GetPixelSizeAcross(center, radius) { - var d = _math.vec3.subtract(Tw2Frustum.global.vec3_0, this.viewPos, center); + key: 'GetValueAt', + value: function GetValueAt(time, value) { + if (this.length === 0) { + return _global.quat.copy(value, this.value); + } - var depth = _math.vec3.dot(this.viewDir, d), - epsilon = 1e-5; + var scratch = _Tw2Curve2.Tw2Curve.global, + firstKey = this.keys[0], + lastKey = this.keys[this.keys.length - 1]; - if (depth < epsilon) depth = epsilon; - if (radius < epsilon) return 0; + if (time >= lastKey.time) { + switch (this.extrapolation) { + case Tw2RotationCurve.Extrapolation.NONE: + return _global.quat.copy(value, this.value); - var ratio = radius / depth; - return ratio * this.halfWidthProjection * 2; + case Tw2RotationCurve.Extrapolation.CONSTANT: + return _global.quat.copy(value, lastKey.value); + + default: + time = time % lastKey.time; + } + } else if (time < 0 || time < firstKey.time) { + switch (this.extrapolation) { + case Tw2RotationCurve.Extrapolation.NONE: + return _global.quat.copy(value, this.value); + + default: + return _global.quat.copy(value, firstKey.value); + } + } + + var ck = this.keys[this._currentKey], + ck_1 = this.keys[this._currentKey - 1]; + + while (time >= ck.time || time < ck_1.time) { + if (time < ck_1.time) this._currentKey = 0; + this._currentKey++; + ck = this.keys[this._currentKey]; + ck_1 = this.keys[this._currentKey - 1]; + } + + var nt = (time - ck_1.time) / (ck.time - ck_1.time); + switch (ck_1.interpolation) { + case Tw2RotationCurve.Interpolation.CONSTANT: + return _global.quat.copy(value, ck_1.value); + + case Tw2RotationCurve.Interpolation.LINEAR: + value[0] = ck_1.value[0] * (1 - nt) + ck.value[0] * nt; + value[1] = ck_1.value[1] * (1 - nt) + ck.value[1] * nt; + value[2] = ck_1.value[2] * (1 - nt) + ck.value[2] * nt; + value[3] = ck_1.value[3] * (1 - nt) + ck.value[3] * nt; + return value; + + case Tw2RotationCurve.Interpolation.HERMITE: + var collect = _global.quat.identity(scratch.quat_0), + arr = [ck_1.value, ck_1.right, ck.left, ck.value]; + + for (var i = 3; i > 0; i--) { + var power = _global.num.biCumulative(nt, i); + if (power > 1) _global.quat.multiply(value, collect, arr[i]); + value[0] = -arr[i - 1][0]; + value[1] = -arr[i - 1][1]; + value[2] = -arr[i - 1][2]; + value[3] = arr[i - 1][3]; + _global.quat.multiply(value, value, arr[i]); + _global.quat.pow(value, value, power); + _global.quat.multiply(collect, collect, value); + } + return _global.quat.multiply(value, collect, ck_1.value); + + case Tw2RotationCurve.Interpolation.SLERP: + return _global.quat.slerp(value, ck_1.value, ck.value, nt); + + default: + return _global.quat.sqlerp(value, ck_1.value, ck_1.right, ck.left, ck.value, nt); + } } }]); - return Tw2Frustum; -}(); + return Tw2RotationCurve; +}(_Tw2Curve2.Tw2Curve); /** - * global variables + * The curve's key dimension + * @type {number} */ -Tw2Frustum.global = { - vec3_0: _math.vec3.create(), - mat4_0: _math.mat4.create() +Tw2RotationCurve.outputDimention = 4; + +/** + * The curve's dimension + * @type {number} + */ +Tw2RotationCurve.inputDimension = 4; + +/** + * The curve's current value property + * @type {string} + */ +Tw2RotationCurve.valueProperty = 'value'; + +/** + * The curve's type + * @type {number} + */ +Tw2RotationCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE; + +/** + * The curve's key constructor + * @type {Tw2QuaternionKey} + */ +Tw2RotationCurve.Child = Tw2QuaternionKey; + +/** + * Extrapolation types + * @type {{NONE: number, CONSTANT: number, GRADIENT: number, CYCLE: number}} + */ +Tw2RotationCurve.Extrapolation = { + NONE: 0, + CONSTANT: 1, + GRADIENT: 2, + CYCLE: 3 +}; + +/** + * Interpolation types + * @type {{NONE: number, CONSTANT: number, LINEAR: number, HERMITE: number, SLERP: number, SQUAD: number}} + */ +Tw2RotationCurve.Interpolation = { + NONE: 0, + CONSTANT: 1, + LINEAR: 2, + HERMITE: 3, + SLERP: 5, + SQUAD: 6 }; /***/ }), -/* 141 */ +/* 136 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -27994,13 +27867,11 @@ Tw2Frustum.global = { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2ColorCurve = exports.Tw2ColorKey = undefined; +exports.Tw2ScalarCurve = exports.Tw2ScalarKey = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); - -var _Tw2Curve2 = __webpack_require__(3); +var _Tw2Curve2 = __webpack_require__(2); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -28009,55 +27880,59 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2ColorKey + * Tw2ScalarKey * - * @property {vec4} value - * @property {vec4} left - * @property {vec4} right + * @property {number} value + * @property {number} left + * @property {number} right * @property {number} interpolation * @class */ -var Tw2ColorKey = exports.Tw2ColorKey = function (_Tw2CurveKey) { - _inherits(Tw2ColorKey, _Tw2CurveKey); +var Tw2ScalarKey = exports.Tw2ScalarKey = function (_Tw2CurveKey) { + _inherits(Tw2ScalarKey, _Tw2CurveKey); - function Tw2ColorKey() { - _classCallCheck(this, Tw2ColorKey); + function Tw2ScalarKey() { + _classCallCheck(this, Tw2ScalarKey); - var _this = _possibleConstructorReturn(this, (Tw2ColorKey.__proto__ || Object.getPrototypeOf(Tw2ColorKey)).call(this)); + var _this = _possibleConstructorReturn(this, (Tw2ScalarKey.__proto__ || Object.getPrototypeOf(Tw2ScalarKey)).call(this)); - _this.value = _math.vec4.create(); - _this.left = _math.vec4.create(); - _this.right = _math.vec4.create(); + _this.value = 0; + _this.left = 0; + _this.right = 0; _this.interpolation = 0; return _this; } - return Tw2ColorKey; + return Tw2ScalarKey; }(_Tw2Curve2.Tw2CurveKey); /** - * Tw2ColorCurve + * Tw2ScalarCurve * * @property {number} start - * @property {vec4} currentValue + * @property {number} timeScale + * @property {number} timeOffset + * @property {number} value * @property {number} extrapolation - * @property {Array.} keys + * @property {Array.} keys * @property {number} _currentKey * @property {number} length * @class */ -var Tw2ColorCurve = exports.Tw2ColorCurve = function (_Tw2Curve) { - _inherits(Tw2ColorCurve, _Tw2Curve); +var Tw2ScalarCurve = exports.Tw2ScalarCurve = function (_Tw2Curve) { + _inherits(Tw2ScalarCurve, _Tw2Curve); - function Tw2ColorCurve() { - _classCallCheck(this, Tw2ColorCurve); + function Tw2ScalarCurve() { + _classCallCheck(this, Tw2ScalarCurve); - var _this2 = _possibleConstructorReturn(this, (Tw2ColorCurve.__proto__ || Object.getPrototypeOf(Tw2ColorCurve)).call(this)); + var _this2 = _possibleConstructorReturn(this, (Tw2ScalarCurve.__proto__ || Object.getPrototypeOf(Tw2ScalarCurve)).call(this)); _this2.start = 0; - _this2.value = _math.vec4.create(); + _this2.timeScale = 1; + _this2.timeOffset = 0; + _this2.value = 0; _this2.extrapolation = 0; _this2.keys = []; _this2._currentKey = 1; @@ -28070,7 +27945,7 @@ var Tw2ColorCurve = exports.Tw2ColorCurve = function (_Tw2Curve) { */ - _createClass(Tw2ColorCurve, [{ + _createClass(Tw2ScalarCurve, [{ key: 'Sort', value: function Sort() { _Tw2Curve2.Tw2Curve.Sort(this); @@ -28095,21 +27970,22 @@ var Tw2ColorCurve = exports.Tw2ColorCurve = function (_Tw2Curve) { }, { key: 'UpdateValue', value: function UpdateValue(time) { - this.GetValueAt(time, this.value); + this.value = this.GetValueAt(time); } /** * Gets a value at a specific time * @param {number} time - * @param {vec4} value - * @returns {vec4} value + * @returns {number} */ }, { key: 'GetValueAt', - value: function GetValueAt(time, value) { + value: function GetValueAt(time) { + time = time / this.timeScale - this.timeOffset; + if (this.length === 0) { - return _math.vec4.copy(value, this.value); + return this.value; } var firstKey = this.keys[0], @@ -28117,28 +27993,28 @@ var Tw2ColorCurve = exports.Tw2ColorCurve = function (_Tw2Curve) { if (time >= lastKey.time) { switch (this.extrapolation) { - case Tw2ColorCurve.Extrapolation.NONE: - return _math.vec4.copy(value, this.value); + case Tw2ScalarCurve.Extrapolation.NONE: + return this.value; - case Tw2ColorCurve.Extrapolation.CONSTANT: - return _math.vec4.copy(value, lastKey.value); + case Tw2ScalarCurve.Extrapolation.CONSTANT: + return lastKey.value; - case Tw2ColorCurve.Extrapolation.GRADIENT: - return _math.vec4.scaleAndAdd(value, lastKey.value, lastKey.right, time - lastKey.time); + case Tw2ScalarCurve.Extrapolation.GRADIENT: + return lastKey.value + (time - lastKey.time) * lastKey.right; default: time = time % lastKey.time; } } else if (time < 0 || time < firstKey.time) { switch (this.extrapolation) { - case Tw2ColorCurve.Extrapolation.NONE: - return _math.vec4.copy(value, this.value); + case Tw2ScalarCurve.Extrapolation.NONE: + return this.value; - case Tw2ColorCurve.Extrapolation.GRADIENT: - return _math.vec4.scaleAndAdd(value, firstKey.value, firstKey.left, time * this.length - lastKey.time); + case Tw2ScalarCurve.Extrapolation.GRADIENT: + return firstKey.value + (time * this.length - lastKey.time) * firstKey.left; default: - return _math.vec4.copy(value, firstKey.value); + return firstKey.value; } } @@ -28153,22 +28029,30 @@ var Tw2ColorCurve = exports.Tw2ColorCurve = function (_Tw2Curve) { } var nt = (time - ck_1.time) / (ck.time - ck_1.time); - switch (ck_1.interpolation) { - case Tw2ColorCurve.Interpolation.CONSTANT: - return _math.vec4.copy(value, ck_1.value); + case Tw2ScalarCurve.Interpolation.CONSTANT: + return ck_1.value; + + case Tw2ScalarCurve.Interpolation.LINEAR: + return ck_1.value * (1 - nt) + ck.value * nt; + + case Tw2ScalarCurve.Interpolation.HERMITE: + var k3 = 2 * nt * nt * nt - 3 * nt * nt + 1, + k2 = -2 * nt * nt * nt + 3 * nt * nt, + k1 = nt * nt * nt - 2 * nt * nt + nt, + k0 = nt * nt * nt - nt * nt; + return k3 * ck_1.value + k2 * ck.value + k1 * ck_1.right + k0 * ck.left; default: - value[0] = ck_1.value[0] * (1 - nt) + ck.value[0] * nt; - value[1] = ck_1.value[1] * (1 - nt) + ck.value[1] * nt; - value[2] = ck_1.value[2] * (1 - nt) + ck.value[2] * nt; - value[3] = ck_1.value[3] * (1 - nt) + ck.value[3] * nt; - return value; + var sq = Math.sqrt(ck_1.value / ck.value), + exponent = Math.exp(-time / ck_1.right), + ret = 1.0 + (sq - 1.0) * exponent; + return ret * ret * ck.value; } } }]); - return Tw2ColorCurve; + return Tw2ScalarCurve; }(_Tw2Curve2.Tw2Curve); /** @@ -28177,37 +28061,37 @@ var Tw2ColorCurve = exports.Tw2ColorCurve = function (_Tw2Curve) { */ -Tw2ColorCurve.inputDimension = 4; +Tw2ScalarCurve.inputDimension = 1; /** * The curve's dimension * @type {number} */ -Tw2ColorCurve.ouputDimension = 4; +Tw2ScalarCurve.outputDimension = 1; /** * The curve's current value property * @type {string} */ -Tw2ColorCurve.valueProperty = 'value'; +Tw2ScalarCurve.valueProperty = 'value'; /** * The curve's type * @type {number} */ -Tw2ColorCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE; +Tw2ScalarCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE; /** * The curve's key constructor - * @type {Tw2ColorKey} + * @type {Tw2ScalarKey} */ -Tw2ColorCurve.Key = Tw2ColorKey; +Tw2ScalarCurve.Key = Tw2ScalarKey; /** * Extrapolation types * @type {{NONE: number, CONSTANT: number, GRADIENT: number, CYCLE: number}} */ -Tw2ColorCurve.Extrapolation = { +Tw2ScalarCurve.Extrapolation = { NONE: 0, CONSTANT: 1, GRADIENT: 2, @@ -28215,17 +28099,405 @@ Tw2ColorCurve.Extrapolation = { }; /** - * Interpolation types - * @type {{NONE: number, CONSTANT: number, LINEAR: number}} + * Interpolation types + * @type {{NONE: number, CONSTANT: number, LINEAR: number, HERMITE: number, CATMULROM: number}} + */ +Tw2ScalarCurve.Interpolation = { + NONE: 0, + CONSTANT: 1, + LINEAR: 2, + HERMITE: 3, + CATMULROM: 4 +}; + +/***/ }), +/* 137 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2ScalarCurve2 = exports.Tw2ScalarKey2 = undefined; + +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _Tw2Curve2 = __webpack_require__(2); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +/** + * Tw2ScalarKey2 + * + * @property {number} value + * @property {number} leftTangent + * @property {number} rightTangent + * @property {number} interpolation + * @class + */ +var Tw2ScalarKey2 = exports.Tw2ScalarKey2 = function (_Tw2CurveKey) { + _inherits(Tw2ScalarKey2, _Tw2CurveKey); + + function Tw2ScalarKey2() { + _classCallCheck(this, Tw2ScalarKey2); + + var _this = _possibleConstructorReturn(this, (Tw2ScalarKey2.__proto__ || Object.getPrototypeOf(Tw2ScalarKey2)).call(this)); + + _this.value = 0; + _this.leftTangent = 0; + _this.rightTangent = 0; + _this.interpolation = 1; + return _this; + } + + return Tw2ScalarKey2; +}(_Tw2Curve2.Tw2CurveKey); + +/** + * Tw2ScalarCurve2 + * + * @property {boolean} cycle + * @property {boolean} reversed + * @property {number} timeOffset + * @property {number} timeScale + * @property {number} startValue + * @property {number} currentValue + * @property {number} endValue + * @property {number} startTangent + * @property {number} endTangent + * @property {number} interpolation + * @property {Array.} keys + * @property {number} length + * @class + */ + + +var Tw2ScalarCurve2 = exports.Tw2ScalarCurve2 = function (_Tw2Curve) { + _inherits(Tw2ScalarCurve2, _Tw2Curve); + + function Tw2ScalarCurve2() { + _classCallCheck(this, Tw2ScalarCurve2); + + var _this2 = _possibleConstructorReturn(this, (Tw2ScalarCurve2.__proto__ || Object.getPrototypeOf(Tw2ScalarCurve2)).call(this)); + + _this2.cycle = false; + _this2.reversed = false; + _this2.timeOffset = 0; + _this2.timeScale = 1; + _this2.startValue = 0; + _this2.currentValue = 0; + _this2.endValue = 0; + _this2.startTangent = 0; + _this2.endTangent = 0; + _this2.interpolation = 1; + _this2.keys = []; + _this2.length = 0; + return _this2; + } + + /** + * Sorts the curve's keys + */ + + + _createClass(Tw2ScalarCurve2, [{ + key: 'Sort', + value: function Sort() { + _Tw2Curve2.Tw2Curve.Sort2(this); + } + + /** + * Gets the curve's length + * @returns {number} + */ + + }, { + key: 'GetLength', + value: function GetLength() { + return this.length; + } + + /** + * Updates the current value at the given time + * @param {number} time + */ + + }, { + key: 'UpdateValue', + value: function UpdateValue(time) { + this.currentValue = this.GetValueAt(time); + } + + /** + * Gets a value at a specific time + * @param {number} time + * @returns {number} + */ + + }, { + key: 'GetValueAt', + value: function GetValueAt(time) { + time = time / this.timeScale + this.timeOffset; + if (this.length <= 0 || time <= 0) { + return this.startValue; + } + + if (time > this.length) { + if (this.cycle) { + time = time % this.length; + } else if (this.reversed) { + return this.startValue; + } else { + return this.endValue; + } + } + + if (this.reversed) { + time = this.length - time; + } + + if (this.keys.length === 0) { + return this.Interpolate(time, null, null); + } + + var startKey = this.keys[0], + endKey = this.keys[this.keys.length - 1]; + + if (time <= startKey.time) { + return this.Interpolate(time, null, startKey); + } else if (time >= endKey.time) { + return this.Interpolate(time, endKey, null); + } + + for (var i = 0; i + 1 < this.keys.length; ++i) { + startKey = this.keys[i]; + endKey = this.keys[i + 1]; + if (startKey.time <= time && endKey.time > time) break; + } + + return this.Interpolate(time, startKey, endKey); + } + + /** + * Interpolate + * @param {number} time + * @param {Tw2ScalarKey2} lastKey + * @param {Tw2ScalarKey2} nextKey + * @returns {number} + */ + + }, { + key: 'Interpolate', + value: function Interpolate(time, lastKey, nextKey) { + var startValue = this.startValue, + endValue = this.endValue, + interp = this.interpolation, + deltaTime = this.length; + + if (lastKey !== null) { + interp = lastKey.interpolation; + time -= lastKey.time; + } + + switch (interp) { + case Tw2ScalarCurve2.Interpolation.LINEAR: + if (lastKey && nextKey) { + startValue = lastKey.value; + endValue = nextKey.value; + deltaTime = nextKey.time - lastKey.time; + } else if (nextKey) { + endValue = nextKey.value; + deltaTime = nextKey.time; + } else if (lastKey) { + startValue = lastKey.value; + deltaTime = this.length - lastKey.time; + } + return startValue + (endValue - startValue) * (time / deltaTime); + + case Tw2ScalarCurve2.Interpolation.HERMITE: + var inTangent = this.startTangent, + outTangent = this.endTangent; + + if (lastKey && nextKey) { + startValue = lastKey.value; + inTangent = lastKey.rightTangent; + endValue = nextKey.value; + outTangent = nextKey.leftTangent; + deltaTime = nextKey.time - lastKey.time; + } else if (nextKey) { + endValue = nextKey.value; + outTangent = nextKey.leftTangent; + deltaTime = nextKey.time; + } else if (lastKey) { + startValue = lastKey.value; + inTangent = lastKey.rightTangent; + deltaTime = this.length - lastKey.time; + } + + var s = time / deltaTime, + s2 = s * s, + s3 = s2 * s; + + var c2 = -2.0 * s3 + 3.0 * s2, + c1 = 1.0 - c2, + c4 = s3 - s2, + c3 = s + c4 - s2; + + return startValue * c1 + endValue * c2 + inTangent * c3 + outTangent * c4; + + default: + return this.startValue; + } + } + }]); + + return Tw2ScalarCurve2; +}(_Tw2Curve2.Tw2Curve); + +/** + * The curve's key dimension + * @type {number} + */ + + +Tw2ScalarCurve2.inputDimension = 1; + +/** + * The curve's dimension + * @type {number} + */ +Tw2ScalarCurve2.outputDimension = 1; + +/** + * The curve's current value property + * @type {string} + */ +Tw2ScalarCurve2.valueProperty = 'currentValue'; + +/** + * The curve's type + * @type {number} + */ +Tw2ScalarCurve2.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE2; + +/** + * The curve's key constructor + * @type {Tw2ScalarKey2} + */ +Tw2ScalarCurve2.Key = Tw2ScalarKey2; + +/** + * Interpolation types + * @type {{CONSTANT: number, LINEAR: number, HERMITE: number}} + */ +Tw2ScalarCurve2.Interpolation = { + CONSTANT: 0, + LINEAR: 1, + HERMITE: 2 +}; + +/***/ }), +/* 138 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2SineCurve = undefined; + +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _Tw2Curve2 = __webpack_require__(2); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +/** + * Tw2SineCurve + * + * @property {string} name + * @property {number} value + * @property {number} offset + * @property {number} scale + * @property {number} speed + */ +var Tw2SineCurve = exports.Tw2SineCurve = function (_Tw2Curve) { + _inherits(Tw2SineCurve, _Tw2Curve); + + function Tw2SineCurve() { + _classCallCheck(this, Tw2SineCurve); + + var _this = _possibleConstructorReturn(this, (Tw2SineCurve.__proto__ || Object.getPrototypeOf(Tw2SineCurve)).call(this)); + + _this.value = 0; + _this.offset = 0; + _this.scale = 1; + _this.speed = 1; + return _this; + } + + /** + * Updates the current value at the given time + * @param {number} time + */ + + + _createClass(Tw2SineCurve, [{ + key: 'UpdateValue', + value: function UpdateValue(time) { + this.value = this.GetValueAt(time); + } + + /** + * Gets a value at a specific time + * @param {number} time + * @returns {number} + */ + + }, { + key: 'GetValueAt', + value: function GetValueAt(time) { + return Math.sin(time * Math.PI * 2 * this.speed) * this.scale + this.offset; + } + }]); + + return Tw2SineCurve; +}(_Tw2Curve2.Tw2Curve); + +/** + * THe curve's dimension + * @type {number} + */ + + +Tw2SineCurve.outputDimension = 1; + +/** + * The curve's current value property + * @type {string} + */ +Tw2SineCurve.valueProperty = 'value'; + +/** + * The curve's type + * @type {number} */ -Tw2ColorCurve.Interpolation = { - NONE: 0, - CONSTANT: 1, - LINEAR: 2 -}; +Tw2SineCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE_NO_KEYS; /***/ }), -/* 142 */ +/* 139 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -28234,13 +28506,13 @@ Tw2ColorCurve.Interpolation = { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2ColorCurve2 = exports.Tw2ColorKey2 = undefined; +exports.Tw2Vector2Curve = exports.Tw2Vector2Key = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); -var _Tw2Curve2 = __webpack_require__(3); +var _Tw2Curve2 = __webpack_require__(2); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -28249,68 +28521,68 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2ColorKey2 + * Tw2Vector2Key * - * @property {number} time - * @property {vec4} value - * @property {vec4} leftTangent - * @property {vec4} rightTangent + * @property {vec2} value + * @property {vec2} leftTangent + * @property {vec2} rightTangent * @property {number} interpolation * @class */ -var Tw2ColorKey2 = exports.Tw2ColorKey2 = function (_Tw2CurveKey) { - _inherits(Tw2ColorKey2, _Tw2CurveKey); +var Tw2Vector2Key = exports.Tw2Vector2Key = function (_Tw2CurveKey) { + _inherits(Tw2Vector2Key, _Tw2CurveKey); - function Tw2ColorKey2() { - _classCallCheck(this, Tw2ColorKey2); + function Tw2Vector2Key() { + _classCallCheck(this, Tw2Vector2Key); - var _this = _possibleConstructorReturn(this, (Tw2ColorKey2.__proto__ || Object.getPrototypeOf(Tw2ColorKey2)).call(this)); + var _this = _possibleConstructorReturn(this, (Tw2Vector2Key.__proto__ || Object.getPrototypeOf(Tw2Vector2Key)).call(this)); - _this.value = _math.vec4.create(); - _this.leftTangent = _math.vec4.create(); - _this.rightTangent = _math.vec4.create(); + _this.value = _global.vec2.create(); + _this.leftTangent = _global.vec2.create(); + _this.rightTangent = _global.vec2.create(); _this.interpolation = 1; return _this; } - return Tw2ColorKey2; + return Tw2Vector2Key; }(_Tw2Curve2.Tw2CurveKey); /** - * Tw2ColorCurve2 + * Tw2Vector2Curve * * @property {boolean} cycle * @property {boolean} reversed * @property {number} timeOffset * @property {number} timeScale - * @property {vec4} startValue=[0,0,0,1] - * @property {vec4} currentValue=[0,0,0,1] - * @property {vec4} endValue=[0,0,0,1] - * @property {vec4} startTangent - * @property {vec4} endTangent + * @property {vec2} startValue - vec2 array + * @property {vec2} currentValue - vec2 array + * @property {vec2} endValue - vec2 array + * @property {vec2} startTangent - vec2 array + * @property {vec2} endTangent - vec2 array * @property {number} interpolation - * @property {Array.} keys + * @property {Array.} keys + * @property {number} length * @class */ -var Tw2ColorCurve2 = exports.Tw2ColorCurve2 = function (_Tw2Curve) { - _inherits(Tw2ColorCurve2, _Tw2Curve); +var Tw2Vector2Curve = exports.Tw2Vector2Curve = function (_Tw2Curve) { + _inherits(Tw2Vector2Curve, _Tw2Curve); - function Tw2ColorCurve2() { - _classCallCheck(this, Tw2ColorCurve2); + function Tw2Vector2Curve() { + _classCallCheck(this, Tw2Vector2Curve); - var _this2 = _possibleConstructorReturn(this, (Tw2ColorCurve2.__proto__ || Object.getPrototypeOf(Tw2ColorCurve2)).call(this)); + var _this2 = _possibleConstructorReturn(this, (Tw2Vector2Curve.__proto__ || Object.getPrototypeOf(Tw2Vector2Curve)).call(this)); _this2.cycle = false; _this2.reversed = false; _this2.timeOffset = 0; _this2.timeScale = 1; - _this2.startValue = _math.vec4.fromValues(0, 0, 0, 1); - _this2.currentValue = _math.vec4.fromValues(0, 0, 0, 1); - _this2.endValue = _math.vec4.fromValues(0, 0, 0, 1); - _this2.startTangent = _math.vec4.create(); - _this2.endTangent = _math.vec4.create(); + _this2.startValue = _global.vec2.create(); + _this2.currentValue = _global.vec2.create(); + _this2.endValue = _global.vec2.create(); + _this2.startTangent = _global.vec2.create(); + _this2.endTangent = _global.vec2.create(); _this2.interpolation = 1; _this2.keys = []; _this2.length = 0; @@ -28322,7 +28594,7 @@ var Tw2ColorCurve2 = exports.Tw2ColorCurve2 = function (_Tw2Curve) { */ - _createClass(Tw2ColorCurve2, [{ + _createClass(Tw2Vector2Curve, [{ key: 'Sort', value: function Sort() { _Tw2Curve2.Tw2Curve.Sort2(this); @@ -28353,8 +28625,9 @@ var Tw2ColorCurve2 = exports.Tw2ColorCurve2 = function (_Tw2Curve) { /** * Gets a value at a specific time * @param {number} time - * @param {vec4} value - * @returns {vec4} + * @param {vec2} value - vec2 array + * @returns {vec2} vec2 array + * @prototype */ }, { @@ -28362,16 +28635,16 @@ var Tw2ColorCurve2 = exports.Tw2ColorCurve2 = function (_Tw2Curve) { value: function GetValueAt(time, value) { time = time / this.timeScale + this.timeOffset; if (this.length <= 0 || time <= 0) { - return _math.vec4.copy(value, this.startValue); + return _global.vec2.copy(value, this.startValue); } if (time > this.length) { if (this.cycle) { time = time % this.length; } else if (this.reversed) { - return _math.vec4.copy(value, this.startValue); + return _global.vec2.copy(value, this.startValue); } else { - return _math.vec4.copy(value, this.endValue); + return _global.vec2.copy(value, this.endValue); } } @@ -28404,16 +28677,16 @@ var Tw2ColorCurve2 = exports.Tw2ColorCurve2 = function (_Tw2Curve) { /** * Interpolate * @param {number} time - * @param {Tw2ColorKey2} lastKey - * @param {Tw2ColorKey2} nextKey - * @param {vec4} value - * @returns {vec4} value + * @param {Tw2Vector2Key} lastKey + * @param {Tw2Vector2Key} nextKey + * @param {vec2} value - vec2 array + * @returns {vec2} vec2 array */ }, { key: 'Interpolate', value: function Interpolate(time, lastKey, nextKey, value) { - _math.vec4.copy(value, this.startValue); + _global.vec2.copy(value, this.startValue); var startValue = this.startValue, endValue = this.endValue, @@ -28426,7 +28699,7 @@ var Tw2ColorCurve2 = exports.Tw2ColorCurve2 = function (_Tw2Curve) { } switch (interp) { - case Tw2ColorCurve2.Interpolation.LINEAR: + case Tw2Vector2Curve.Interpolation.LINEAR: if (lastKey && nextKey) { startValue = lastKey.value; endValue = nextKey.value; @@ -28440,8 +28713,39 @@ var Tw2ColorCurve2 = exports.Tw2ColorCurve2 = function (_Tw2Curve) { } value[0] = startValue[0] + (endValue[0] - startValue[0]) * (time / deltaTime); value[1] = startValue[1] + (endValue[1] - startValue[1]) * (time / deltaTime); - value[2] = startValue[2] + (endValue[2] - startValue[2]) * (time / deltaTime); - value[3] = startValue[3] + (endValue[3] - startValue[3]) * (time / deltaTime); + return value; + + case Tw2Vector2Curve.Interpolation.HERMITE: + var inTangent = this.startTangent, + outTangent = this.endTangent; + + if (lastKey && nextKey) { + startValue = lastKey.value; + inTangent = lastKey.rightTangent; + endValue = nextKey.value; + outTangent = nextKey.leftTangent; + deltaTime = nextKey.time - lastKey.time; + } else if (nextKey) { + endValue = nextKey.value; + outTangent = nextKey.leftTangent; + deltaTime = nextKey.time; + } else if (lastKey) { + startValue = lastKey.value; + inTangent = lastKey.rightTangent; + deltaTime = this.length - lastKey.time; + } + + var s = time / deltaTime, + s2 = s * s, + s3 = s2 * s; + + var c2 = -2.0 * s3 + 3.0 * s2, + c1 = 1.0 - c2, + c4 = s3 - s2, + c3 = s + c4 - s2; + + value[0] = startValue[0] * c1 + endValue[0] * c2 + inTangent[0] * c3 + outTangent[0] * c4; + value[1] = startValue[1] * c1 + endValue[1] * c2 + inTangent[1] * c3 + outTangent[1] * c4; return value; default: @@ -28450,7 +28754,7 @@ var Tw2ColorCurve2 = exports.Tw2ColorCurve2 = function (_Tw2Curve) { } }]); - return Tw2ColorCurve2; + return Tw2Vector2Curve; }(_Tw2Curve2.Tw2Curve); /** @@ -28459,43 +28763,44 @@ var Tw2ColorCurve2 = exports.Tw2ColorCurve2 = function (_Tw2Curve) { */ -Tw2ColorCurve2.inputDimension = 4; +Tw2Vector2Curve.inputDimension = 2; /** * The curve's dimension * @type {number} */ -Tw2ColorCurve2.outputDimension = 4; +Tw2Vector2Curve.outputDimension = 2; /** * The curve's current value property * @type {string} */ -Tw2ColorCurve2.valueProperty = 'currentValue'; +Tw2Vector2Curve.valueProperty = 'value'; /** * The curve's type * @type {number} */ -Tw2ColorCurve2.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE2; +Tw2Vector2Curve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE2; /** * The curve's key constructor - * @type {Tw2ColorKey2} + * @type {Tw2Vector2Key} */ -Tw2ColorCurve2.Key = Tw2ColorKey2; +Tw2Vector2Curve.Key = Tw2Vector2Key; /** * Interpolation types - * @type {{CONSTANT: number, LINEAR: number}} + * @type {{CONSTANT: number, LINEAR: number, HERMITE: number}} */ -Tw2ColorCurve2.Interpolation = { +Tw2Vector2Curve.Interpolation = { CONSTANT: 0, - LINEAR: 1 + LINEAR: 1, + HERMITE: 2 }; /***/ }), -/* 143 */ +/* 140 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -28504,11 +28809,13 @@ Tw2ColorCurve2.Interpolation = { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2EventCurve = exports.Tw2EventKey = undefined; +exports.Tw2Vector3Curve = exports.Tw2Vector3Key = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2Curve2 = __webpack_require__(3); +var _global = __webpack_require__(0); + +var _Tw2Curve2 = __webpack_require__(2); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -28517,53 +28824,72 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2EventKey + * Tw2Vector3Key * - * @property {string} value + * @property {number} time + * @property {vec3} value + * @property {vec3} leftTangent + * @property {vec3} rightTangent + * @property {number} interpolation * @class */ -var Tw2EventKey = exports.Tw2EventKey = function (_Tw2CurveKey) { - _inherits(Tw2EventKey, _Tw2CurveKey); +var Tw2Vector3Key = exports.Tw2Vector3Key = function (_Tw2CurveKey) { + _inherits(Tw2Vector3Key, _Tw2CurveKey); - function Tw2EventKey() { - _classCallCheck(this, Tw2EventKey); + function Tw2Vector3Key() { + _classCallCheck(this, Tw2Vector3Key); - var _this = _possibleConstructorReturn(this, (Tw2EventKey.__proto__ || Object.getPrototypeOf(Tw2EventKey)).call(this)); + var _this = _possibleConstructorReturn(this, (Tw2Vector3Key.__proto__ || Object.getPrototypeOf(Tw2Vector3Key)).call(this)); - _this.value = ''; + _this.value = _global.vec3.create(); + _this.leftTangent = _global.vec3.create(); + _this.rightTangent = _global.vec3.create(); + _this.interpolation = 1; return _this; } - return Tw2EventKey; + return Tw2Vector3Key; }(_Tw2Curve2.Tw2CurveKey); /** - * Tw2EventCurve + * Tw2Vector3Curve * - * @property {string} value - * @property {Array.} keys - * @property {number} extrapolation - * @property {number} _time - * @property {number} _currentKey - * @property {number} _length + * @property {boolean} cycle + * @property {boolean} reversed + * @property {number} timeOffset + * @property {number} timeScale + * @property {vec3} startValue + * @property {vec3} currentValue + * @property {vec3} endValue + * @property {vec3} startTangent + * @property {vec3} endTangent + * @property {number} interpolation + * @property {Array.} keys + * @property {number} length * @class */ -var Tw2EventCurve = exports.Tw2EventCurve = function (_Tw2Curve) { - _inherits(Tw2EventCurve, _Tw2Curve); +var Tw2Vector3Curve = exports.Tw2Vector3Curve = function (_Tw2Curve) { + _inherits(Tw2Vector3Curve, _Tw2Curve); - function Tw2EventCurve() { - _classCallCheck(this, Tw2EventCurve); + function Tw2Vector3Curve() { + _classCallCheck(this, Tw2Vector3Curve); - var _this2 = _possibleConstructorReturn(this, (Tw2EventCurve.__proto__ || Object.getPrototypeOf(Tw2EventCurve)).call(this)); + var _this2 = _possibleConstructorReturn(this, (Tw2Vector3Curve.__proto__ || Object.getPrototypeOf(Tw2Vector3Curve)).call(this)); - _this2.value = ''; + _this2.cycle = false; + _this2.reversed = false; + _this2.timeOffset = 0; + _this2.timeScale = 1; + _this2.startValue = _global.vec3.create(); + _this2.currentValue = _global.vec3.create(); + _this2.endValue = _global.vec3.create(); + _this2.startTangent = _global.vec3.create(); + _this2.endTangent = _global.vec3.create(); + _this2.interpolation = 1; _this2.keys = []; - _this2.extrapolation = 0; - _this2._time = 0; - _this2._currentKey = 0; - _this2._length = 0; + _this2.length = 0; return _this2; } @@ -28572,13 +28898,10 @@ var Tw2EventCurve = exports.Tw2EventCurve = function (_Tw2Curve) { */ - _createClass(Tw2EventCurve, [{ + _createClass(Tw2Vector3Curve, [{ key: 'Sort', value: function Sort() { - if (this.keys.length) { - this.keys.sort(_Tw2Curve2.Tw2Curve.Compare); - this._length = this.keys[this.keys.length - 1].time; - } + _Tw2Curve2.Tw2Curve.Sort2(this); } /** @@ -28589,192 +28912,201 @@ var Tw2EventCurve = exports.Tw2EventCurve = function (_Tw2Curve) { }, { key: 'GetLength', value: function GetLength() { - return this._length; + return this.length; } /** - * Gets a value at the given time + * Updates the current value at the given time * @param {number} time */ }, { key: 'UpdateValue', value: function UpdateValue(time) { - if (this._length <= 0) { - return this.value; - } + this.GetValueAt(time, this.currentValue); + } - var before = this._time; - this._time = time; - if (this._time < before) { - this._currentKey = 0; - } + /** + * Gets a value at a specific time + * @param {number} time + * @param {vec3} value + * @returns {vec3} + */ - if (this.extrapolation === Tw2EventCurve.Extrapolation.CYCLE) { - var now = this._time % this._length; - if (now < before) this._currentKey = 0; - this._time = now; + }, { + key: 'GetValueAt', + value: function GetValueAt(time, value) { + time = time / this.timeScale + this.timeOffset; + if (this.length <= 0 || time <= 0) { + return _global.vec3.copy(value, this.startValue); } - while (this._currentKey < this.keys.length && this._time >= this.keys[this._currentKey].time) { - this.value = this.keys[this._currentKey].value; - ++this._currentKey; + if (time > this.length) { + if (this.cycle) { + time = time % this.length; + } else if (this.reversed) { + return _global.vec3.copy(value, this.startValue); + } else { + return _global.vec3.copy(value, this.endValue); + } } - } - }]); - return Tw2EventCurve; -}(_Tw2Curve2.Tw2Curve); + if (this.reversed) { + time = this.length - time; + } -/** - * The curve's key dimension - * @type {number} - */ + if (this.keys.length === 0) { + return this.Interpolate(time, null, null, value); + } + var startKey = this.keys[0], + endKey = this.keys[this.keys.length - 1]; -Tw2EventCurve.dimension = 1; + if (time <= startKey.time) { + return this.Interpolate(time, null, startKey, value); + } else if (time >= endKey.time) { + return this.Interpolate(time, endKey, null, value); + } -/** - * The curve's output dimension - * @type {number} - */ -Tw2EventCurve.outputDimension = 1; + for (var i = 0; i + 1 < this.keys.length; ++i) { + startKey = this.keys[i]; + endKey = this.keys[i + 1]; + if (startKey.time <= time && endKey.time > time) break; + } -/** - * The curve's current value property - * @type {string} - */ -Tw2EventCurve.valueProperty = 'value'; + return this.Interpolate(time, startKey, endKey, value); + } -/** - * The curve's type - * @type {number} - */ -Tw2EventCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE; + /** + * Interpolate + * @param {number} time + * @param {Tw2Vector3Key} lastKey + * @param {Tw2Vector3Key} nextKey + * @param {vec3} value + * @returns {vec3} + */ -/** - * The curve's key constructor - * @type {Tw2EventKey} - */ -Tw2EventCurve.Key = Tw2EventKey; + }, { + key: 'Interpolate', + value: function Interpolate(time, lastKey, nextKey, value) { + _global.vec3.copy(value, this.startValue); -/** - * Extrapolation types - * @type {{NONE: number, CYCLE: number}} - */ -Tw2EventCurve.Extrapolation = { - NONE: 0, - CYCLE: 3 -}; + var startValue = this.startValue, + endValue = this.endValue, + interp = this.interpolation, + deltaTime = this.length; -/***/ }), -/* 144 */ -/***/ (function(module, exports, __webpack_require__) { + if (lastKey !== null) { + interp = lastKey.interpolation; + time -= lastKey.time; + } -"use strict"; + switch (interp) { + case Tw2Vector3Curve.Interpolation.LINEAR: + if (lastKey && nextKey) { + startValue = lastKey.value; + endValue = nextKey.value; + deltaTime = nextKey.time - lastKey.time; + } else if (nextKey) { + endValue = nextKey.value; + deltaTime = nextKey.time; + } else if (lastKey) { + startValue = lastKey.value; + deltaTime = this.length - lastKey.time; + } + value[0] = startValue[0] + (endValue[0] - startValue[0]) * (time / deltaTime); + value[1] = startValue[1] + (endValue[1] - startValue[1]) * (time / deltaTime); + value[2] = startValue[2] + (endValue[2] - startValue[2]) * (time / deltaTime); + return value; -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2PerlinCurve = undefined; + case Tw2Vector3Curve.Interpolation.HERMITE: + var inTangent = this.startTangent, + outTangent = this.endTangent; -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + if (lastKey && nextKey) { + startValue = lastKey.value; + inTangent = lastKey.rightTangent; + endValue = nextKey.value; + outTangent = nextKey.leftTangent; + deltaTime = nextKey.time - lastKey.time; + } else if (nextKey) { + endValue = nextKey.value; + outTangent = nextKey.leftTangent; + deltaTime = nextKey.time; + } else if (lastKey) { + startValue = lastKey.value; + inTangent = lastKey.rightTangent; + deltaTime = this.length - lastKey.time; + } -var _math = __webpack_require__(0); + var s = time / deltaTime, + s2 = s * s, + s3 = s2 * s; -var _Tw2Curve2 = __webpack_require__(3); + var c2 = -2.0 * s3 + 3.0 * s2, + c1 = 1.0 - c2, + c4 = s3 - s2, + c3 = s + c4 - s2; -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + value[0] = startValue[0] * c1 + endValue[0] * c2 + inTangent[0] * c3 + outTangent[0] * c4; + value[1] = startValue[1] * c1 + endValue[1] * c2 + inTangent[1] * c3 + outTangent[1] * c4; + value[2] = startValue[2] * c1 + endValue[2] * c2 + inTangent[2] * c3 + outTangent[2] * c4; + return value; -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + default: + return value; + } + } + }]); -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + return Tw2Vector3Curve; +}(_Tw2Curve2.Tw2Curve); /** - * Tw2PerlinCurve - * - * @property {number} start - * @property {number} speed - * @property {number} alpha - * @property {number} beta - * @property {number} offset - * @property {number} scale - * @property {number} N - * @property {number} _startOffset - * @class + * The curve's key dimension + * @type {number} */ -var Tw2PerlinCurve = exports.Tw2PerlinCurve = function (_Tw2Curve) { - _inherits(Tw2PerlinCurve, _Tw2Curve); - - function Tw2PerlinCurve() { - _classCallCheck(this, Tw2PerlinCurve); - - var _this = _possibleConstructorReturn(this, (Tw2PerlinCurve.__proto__ || Object.getPrototypeOf(Tw2PerlinCurve)).call(this)); - - _this.value = 0; - _this.start = 0; - _this.speed = 1; - _this.alpha = 1.1; - _this.beta = 2; - _this.offset = 0; - _this.scale = 1; - _this.N = 3; - _this._startOffset = Math.random() * 100; - return _this; - } - - /** - * Updates the current value at the given time - * @param {number} time - */ - - - _createClass(Tw2PerlinCurve, [{ - key: 'UpdateValue', - value: function UpdateValue(time) { - this.value = this.GetValueAt(time); - } - /** - * Gets a value at a specific time - * @param {number} time - * @returns {number} - */ - - }, { - key: 'GetValueAt', - value: function GetValueAt(time) { - time -= this._startOffset; - return (_math.noise.perlin1D(time * this.speed, this.alpha, this.beta, this.N) + 1) / 2 * this.scale + this.offset; - } - }]); - return Tw2PerlinCurve; -}(_Tw2Curve2.Tw2Curve); +Tw2Vector3Curve.inputDimension = 3; /** * The curve's dimension * @type {number} */ - - -Tw2PerlinCurve.outputDimension = 1; +Tw2Vector3Curve.outputDimension = 3; /** * The curve's current value property * @type {string} */ -Tw2PerlinCurve.valueProperty = 'value'; +Tw2Vector3Curve.valueProperty = 'currentValue'; /** * The curve's type * @type {number} */ -Tw2PerlinCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE_NO_KEYS; +Tw2Vector3Curve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE2; + +/** + * The curve's key constructor + * @type {Tw2Vector3Key} + */ +Tw2Vector3Curve.Key = Tw2Vector3Key; + +/** + * Interpolation types + * @type {{CONSTANT: number, LINEAR: number, HERMITE: number}} + */ +Tw2Vector3Curve.Interpolation = { + CONSTANT: 0, + LINEAR: 1, + HERMITE: 2 +}; /***/ }), -/* 145 */ +/* 141 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -28783,13 +29115,13 @@ Tw2PerlinCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE_NO_KEYS; Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2QuaternionCurve = exports.Tw2QuaternionKey2 = undefined; +exports.Tw2VectorCurve = exports.Tw2VectorKey = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); -var _Tw2Curve2 = __webpack_require__(3); +var _Tw2Curve2 = __webpack_require__(2); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -28798,70 +29130,60 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2QuaternionKey2 + * Tw2VectorKey * - * @property {quat} value - * @property {vec4} leftTangent - * @property {vec4} rightTangent + * @property {vec3} value + * @property {vec3} left + * @property {vec3} right * @property {number} interpolation + * @inherits Tw2CurveKey * @class */ -var Tw2QuaternionKey2 = exports.Tw2QuaternionKey2 = function (_Tw2CurveKey) { - _inherits(Tw2QuaternionKey2, _Tw2CurveKey); +var Tw2VectorKey = exports.Tw2VectorKey = function (_Tw2CurveKey) { + _inherits(Tw2VectorKey, _Tw2CurveKey); - function Tw2QuaternionKey2() { - _classCallCheck(this, Tw2QuaternionKey2); + function Tw2VectorKey() { + _classCallCheck(this, Tw2VectorKey); - var _this = _possibleConstructorReturn(this, (Tw2QuaternionKey2.__proto__ || Object.getPrototypeOf(Tw2QuaternionKey2)).call(this)); + var _this = _possibleConstructorReturn(this, (Tw2VectorKey.__proto__ || Object.getPrototypeOf(Tw2VectorKey)).call(this)); - _this.value = _math.quat.create(); - _this.leftTangent = _math.vec4.create(); - _this.rightTangent = _math.vec4.create(); - _this.interpolation = 1; + _this.value = _global.vec3.create(); + _this.left = _global.vec3.create(); + _this.right = _global.vec3.create(); + _this.interpolation = 0; return _this; } - return Tw2QuaternionKey2; + return Tw2VectorKey; }(_Tw2Curve2.Tw2CurveKey); -/** - * Tw2QuaternionCurve - * - * @property {boolean} cycle - * @property {boolean} reversed - * @property {number} timeOffset - * @property {number} timeScale - * @property {quat} startValue - * @property {quat} currentValue - * @property {quat} endValue - * @property {vec4} startTangent - * @property {vec4} endTangent - * @property {number} interpolation - * @property {Array.} keys +/** + * Tw2Vector3Curve + * + * @property {string} name + * @property {number} start + * @property {vec3} value + * @property {number} extrapolation + * @property {Array.} keys + * @property {number} _currentKey * @property {number} length * @class */ -var Tw2QuaternionCurve = exports.Tw2QuaternionCurve = function (_Tw2Curve) { - _inherits(Tw2QuaternionCurve, _Tw2Curve); +var Tw2VectorCurve = exports.Tw2VectorCurve = function (_Tw2Curve) { + _inherits(Tw2VectorCurve, _Tw2Curve); - function Tw2QuaternionCurve() { - _classCallCheck(this, Tw2QuaternionCurve); + function Tw2VectorCurve() { + _classCallCheck(this, Tw2VectorCurve); - var _this2 = _possibleConstructorReturn(this, (Tw2QuaternionCurve.__proto__ || Object.getPrototypeOf(Tw2QuaternionCurve)).call(this)); + var _this2 = _possibleConstructorReturn(this, (Tw2VectorCurve.__proto__ || Object.getPrototypeOf(Tw2VectorCurve)).call(this)); - _this2.cycle = false; - _this2.reversed = false; - _this2.timeOffset = 0; - _this2.timeScale = 1; - _this2.startValue = _math.quat.create(); - _this2.currentValue = _math.quat.create(); - _this2.endValue = _math.quat.create(); - _this2.startTangent = _math.vec4.create(); - _this2.endTangent = _math.vec4.create(); - _this2.interpolation = 1; + _this2.start = 0; + _this2.value = _global.vec3.create(); + _this2.extrapolation = 0; _this2.keys = []; + _this2._currentKey = 1; _this2.length = 0; return _this2; } @@ -28871,10 +29193,10 @@ var Tw2QuaternionCurve = exports.Tw2QuaternionCurve = function (_Tw2Curve) { */ - _createClass(Tw2QuaternionCurve, [{ + _createClass(Tw2VectorCurve, [{ key: 'Sort', value: function Sort() { - _Tw2Curve2.Tw2Curve.Sort2(this); + _Tw2Curve2.Tw2Curve.Sort(this); } /** @@ -28896,111 +29218,83 @@ var Tw2QuaternionCurve = exports.Tw2QuaternionCurve = function (_Tw2Curve) { }, { key: 'UpdateValue', value: function UpdateValue(time) { - this.GetValueAt(time, this.currentValue); + this.GetValueAt(time, this.value); } /** * Gets a value at a specific time * @param {number} time - * @param {quat} value - * @returns {quat} + * @param {vec3} value + * @returns {vec3} */ }, { key: 'GetValueAt', value: function GetValueAt(time, value) { - time = time / this.timeScale + this.timeOffset; - - if (this.length <= 0 || time <= 0) { - value[0] = this.startValue[0]; - value[1] = this.startValue[1]; - value[2] = this.startValue[2]; - return value; + if (this.length === 0) { + return _global.vec3.copy(value, this.value); } - if (time > this.length) { - if (this.cycle) { - time = time % this.length; - } else if (this.reversed) { - value[0] = this.startValue[0]; - value[1] = this.startValue[1]; - value[2] = this.startValue[2]; - return value; - } else { - value[0] = this.endValue[0]; - value[1] = this.endValue[1]; - value[2] = this.endValue[2]; - return value; - } - } + var firstKey = this.keys[0], + lastKey = this.keys[this.keys.length - 1]; - if (this.reversed) { - time = this.length - time; - } + if (time >= lastKey.time) { + switch (this.extrapolation) { + case Tw2VectorCurve.Extrapolation.NONE: + return _global.vec3.copy(value, this.value); - if (this.keys.length === 0) { - return this.Interpolate(time, null, null, value); - } + case Tw2VectorCurve.Extrapolation.CONSTANT: + return _global.vec3.copy(value, lastKey.value); - var startKey = this.keys[0], - endKey = this.keys[this.keys.length - 1]; + case Tw2VectorCurve.Extrapolation.GRADIENT: + return _global.vec3.scaleAndAdd(value, lastKey.value, lastKey.right, time - lastKey.time); - if (time <= startKey.time) { - return this.Interpolate(time, null, startKey, value); - } else if (time >= endKey.time) { - return this.Interpolate(time, endKey, null, value); - } + default: + time = time % lastKey.time; + } + } else if (time < 0 || time < firstKey.time) { + switch (this.extrapolation) { + case Tw2VectorCurve.Extrapolation.NONE: + return _global.vec3.copy(value, this.value); - for (var i = 0; i + 1 < this.keys.length; ++i) { - startKey = this.keys[i]; - endKey = this.keys[i + 1]; - if (startKey.time <= time && endKey.time > time) break; - } + case Tw2VectorCurve.Extrapolation.GRADIENT: + return _global.vec3.scaleAndAdd(value, firstKey.value, firstKey.left, time * this.length - lastKey.time); - return this.Interpolate(time, startKey, endKey, value); - } + default: + return _global.vec3.copy(value, firstKey.value); + } + } - /** - * Interpolate - * @param {number} time - * @param {null|Tw2QuaternionKey} lastKey - * @param {null|Tw2QuaternionKey} nextKey - * @param {quat} value - * @returns {*} - */ + var ck = this.keys[this._currentKey], + ck_1 = this.keys[this._currentKey - 1]; - }, { - key: 'Interpolate', - value: function Interpolate(time, lastKey, nextKey, value) { - value[0] = this.startValue[0]; - value[1] = this.startValue[1]; - value[2] = this.startValue[2]; + while (time >= ck.time || time < ck_1.time) { + if (time < ck_1.time) this._currentKey = 0; + this._currentKey++; + ck = this.keys[this._currentKey]; + ck_1 = this.keys[this._currentKey - 1]; + } - var startValue = this.startValue, - endValue = this.endValue, - interp = this.interpolation, - deltaTime = this.length; + var nt = (time - ck_1.time) / (ck.time - ck_1.time); + switch (ck_1.interpolation) { + case Tw2VectorCurve.Interpolation.CONSTANT: + return _global.vec3.copy(value, ck_1.value); - if (lastKey !== null) { - interp = lastKey.interpolation; - time -= lastKey.time; - } + case Tw2VectorCurve.Interpolation.LINEAR: + value[0] = ck_1.value[0] * (1 - nt) + ck.value[0] * nt; + value[1] = ck_1.value[1] * (1 - nt) + ck.value[1] * nt; + value[2] = ck_1.value[2] * (1 - nt) + ck.value[2] * nt; + return value; - switch (interp) { - case Tw2QuaternionCurve.Interpolation.SPHERICAL_LINEAR: - if (lastKey && nextKey) { - startValue = lastKey.value; - endValue = nextKey.value; - deltaTime = nextKey.time - lastKey.time; - } else if (nextKey) { - endValue = nextKey.value; - deltaTime = nextKey.time; - } else if (lastKey) { - startValue = lastKey.value; - deltaTime = this.length - lastKey.time; - } + case Tw2VectorCurve.Interpolation.HERMITE: + var k3 = 2 * nt * nt * nt - 3 * nt * nt + 1, + k2 = -2 * nt * nt * nt + 3 * nt * nt, + k1 = nt * nt * nt - 2 * nt * nt + nt, + k0 = nt * nt * nt - nt * nt; - _math.quat.slerp(value, startValue, endValue, time / deltaTime); + value[0] = k3 * ck_1.value[0] + k2 * ck.value[0] + k1 * ck_1.right[0] + k0 * ck.left[0]; + value[1] = k3 * ck_1.value[1] + k2 * ck.value[1] + k1 * ck_1.right[1] + k0 * ck.left[1]; + value[2] = k3 * ck_1.value[2] + k2 * ck.value[2] + k1 * ck_1.right[2] + k0 * ck.left[2]; return value; default: @@ -29009,7 +29303,7 @@ var Tw2QuaternionCurve = exports.Tw2QuaternionCurve = function (_Tw2Curve) { } }]); - return Tw2QuaternionCurve; + return Tw2VectorCurve; }(_Tw2Curve2.Tw2Curve); /** @@ -29018,43 +29312,56 @@ var Tw2QuaternionCurve = exports.Tw2QuaternionCurve = function (_Tw2Curve) { */ -Tw2QuaternionCurve.inputDimension = 4; +Tw2VectorCurve.inputDimension = 3; /** * The curve's dimension * @type {number} */ -Tw2QuaternionCurve.outputDimension = 4; +Tw2VectorCurve.outputDimension = 3; /** * The curve's current value property * @type {string} */ -Tw2QuaternionCurve.valueProperty = 'currentValue'; +Tw2VectorCurve.valueProperty = 'value'; /** * The curve's type * @type {number} */ -Tw2QuaternionCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE2; +Tw2VectorCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE; /** * The curve's key constructor - * @type {Tw2QuaternionKey2} + * @type {Tw2VectorKey} */ -Tw2QuaternionCurve.Key = Tw2QuaternionKey2; +Tw2VectorCurve.Key = Tw2VectorKey; + +/** + * Extrapolation types + * @type {{NONE: number, CONSTANT: number, GRADIENT: number, CYCLE: number}} + */ +Tw2VectorCurve.Extrapolation = { + NONE: 0, + CONSTANT: 1, + GRADIENT: 2, + CYCLE: 3 +}; /** * Interpolation types - * @type {{CONSTANT: number, SPHERICAL_LINEAR: number}} + * @type {{NONE: number, CONSTANT: number, LINEAR: number, HERMITE: number}} */ -Tw2QuaternionCurve.Interpolation = { - CONSTANT: 0, - SPHERICAL_LINEAR: 4 +Tw2VectorCurve.Interpolation = { + NONE: 0, + CONSTANT: 1, + LINEAR: 2, + HERMITE: 3 }; /***/ }), -/* 146 */ +/* 142 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -29063,11 +29370,120 @@ Tw2QuaternionCurve.Interpolation = { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2RandomConstantCurve = undefined; + +var _Tw2ColorSequencer = __webpack_require__(143); + +Object.keys(_Tw2ColorSequencer).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2ColorSequencer[key]; + } + }); +}); + +var _Tw2EulerRotation = __webpack_require__(144); + +Object.keys(_Tw2EulerRotation).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2EulerRotation[key]; + } + }); +}); + +var _Tw2QuaternionSequencer = __webpack_require__(145); + +Object.keys(_Tw2QuaternionSequencer).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2QuaternionSequencer[key]; + } + }); +}); + +var _Tw2RGBAScalarSequencer = __webpack_require__(146); + +Object.keys(_Tw2RGBAScalarSequencer).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2RGBAScalarSequencer[key]; + } + }); +}); + +var _Tw2ScalarSequencer = __webpack_require__(147); + +Object.keys(_Tw2ScalarSequencer).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2ScalarSequencer[key]; + } + }); +}); + +var _Tw2VectorSequencer = __webpack_require__(148); + +Object.keys(_Tw2VectorSequencer).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2VectorSequencer[key]; + } + }); +}); + +var _Tw2XYZScalarSequencer = __webpack_require__(149); + +Object.keys(_Tw2XYZScalarSequencer).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2XYZScalarSequencer[key]; + } + }); +}); + +var _Tw2YPRSequencer = __webpack_require__(150); + +Object.keys(_Tw2YPRSequencer).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2YPRSequencer[key]; + } + }); +}); + +/***/ }), +/* 143 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2ColorSequencer = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2Curve2 = __webpack_require__(3); +var _global = __webpack_require__(0); + +var _Tw2CurveSequencer2 = __webpack_require__(5); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -29076,77 +29492,146 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2RandomConstantCurve + * Tw2ColorSequencer * - * @property {number} currentValue - * @property {number} min - * @property {number} max - * @property {boolean} hold + * @property {number} start + * @property {vec4} value + * @property {number} operator + * @property {Array} functions * @class */ -var Tw2RandomConstantCurve = exports.Tw2RandomConstantCurve = function (_Tw2Curve) { - _inherits(Tw2RandomConstantCurve, _Tw2Curve); - - function Tw2RandomConstantCurve() { - _classCallCheck(this, Tw2RandomConstantCurve); - - var _this = _possibleConstructorReturn(this, (Tw2RandomConstantCurve.__proto__ || Object.getPrototypeOf(Tw2RandomConstantCurve)).call(this)); - - _this.value = 0; - _this.min = 0; - _this.max = 1; - _this.hold = true; - return _this; - } +var Tw2ColorSequencer = exports.Tw2ColorSequencer = function (_Tw2CurveSequencer) { + _inherits(Tw2ColorSequencer, _Tw2CurveSequencer); - /** - * Updates the current value at the given time - */ + function Tw2ColorSequencer() { + _classCallCheck(this, Tw2ColorSequencer); + var _this = _possibleConstructorReturn(this, (Tw2ColorSequencer.__proto__ || Object.getPrototypeOf(Tw2ColorSequencer)).call(this)); - _createClass(Tw2RandomConstantCurve, [{ - key: 'UpdateValue', - value: function UpdateValue() { - this.value = this.GetValueAt(); + _this.start = 0; + _this.value = _global.vec4.create(); + _this.operator = 0; + _this.functions = []; + return _this; } /** - * Gets a value at a specific time - * @returns {number} + * Sorts the sequencer */ - }, { - key: 'GetValueAt', - value: function GetValueAt() { - return this.hold ? this.value : this.min + (this.max - this.min) * Math.random(); - } - }]); - return Tw2RandomConstantCurve; -}(_Tw2Curve2.Tw2Curve); + _createClass(Tw2ColorSequencer, [{ + key: 'Sort', + value: function Sort() { + _Tw2CurveSequencer2.Tw2CurveSequencer.Sort(this); + } + + /** + * Gets sequencer length + * @returns {number} + */ + + }, { + key: 'GetLength', + value: function GetLength() { + var len = 0; + for (var i = 0; i < this.functions.length; ++i) { + if ('GetLength' in this.functions[i]) { + len = Math.max(len, this.functions[i].GetLength()); + } + } + return len; + } + + /** + * Updates a value at a specific time + * @param {number} time + */ + + }, { + key: 'UpdateValue', + value: function UpdateValue(time) { + this.GetValueAt(time, this.value); + } + + /** + * Gets a value at a specific time + * @param {number} time + * @param {vec4} value + * @returns {vec4} + */ + + }, { + key: 'GetValueAt', + value: function GetValueAt(time, value) { + var vec4_0 = _Tw2CurveSequencer2.Tw2CurveSequencer.global.vec4_0; + + switch (this.operator) { + case Tw2ColorSequencer.Operator.MULTIPLY: + _global.vec4.set(value, 1, 1, 1, 1); + for (var i = 0; i < this.functions.length; ++i) { + this.functions[i].GetValueAt(time, vec4_0); + _global.vec4.multiply(value, value, vec4_0); + } + return value; + + default: + _global.vec4.set(value, 0, 0, 0, 0); + for (var _i = 0; _i < this.functions.length; ++_i) { + this.functions[_i].GetValueAt(time, vec4_0); + _global.vec4.add(value, value, vec4_0); + } + return value; + } + } + }]); + + return Tw2ColorSequencer; +}(_Tw2CurveSequencer2.Tw2CurveSequencer); /** - * The curve's dimension + * The sequencer's curve dimension * @type {number} */ -Tw2RandomConstantCurve.outputDimension = 1; +Tw2ColorSequencer.inputDimension = 4; /** - * The curve's current value property + * The sequencer's dimension + * @type {number} + */ +Tw2ColorSequencer.outputDimension = 4; + +/** + * The sequencer's current value property * @type {string} */ -Tw2RandomConstantCurve.valueProperty = 'value'; +Tw2ColorSequencer.valueProperty = 'value'; /** - * The curve's type + * The sequencer's type * @type {number} */ -Tw2RandomConstantCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE_NO_KEYS; +Tw2ColorSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCER; + +/** + * The sequencer's curve array + * @type {string} + */ +Tw2ColorSequencer.childArray = 'functions'; + +/** + * Operators + * @type {{MULTIPLY: number, ADD: number}} + */ +Tw2ColorSequencer.Operator = { + MULTIPLY: 0, + ADD: 1 +}; /***/ }), -/* 147 */ +/* 144 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -29155,13 +29640,13 @@ Tw2RandomConstantCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE_NO_KEYS; Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2RigidOrientation = exports.Tw2Torque = undefined; +exports.Tw2EulerRotation = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); -var _Tw2Curve2 = __webpack_require__(3); +var _Tw2CurveSequencer2 = __webpack_require__(5); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -29170,93 +29655,65 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2Torque - * - * @property {quat} rot0 - * @property {vec3} omega0 - * @property {vec3} torque - * @class - */ -var Tw2Torque = exports.Tw2Torque = function (_Tw2CurveKey) { - _inherits(Tw2Torque, _Tw2CurveKey); - - function Tw2Torque() { - _classCallCheck(this, Tw2Torque); - - var _this = _possibleConstructorReturn(this, (Tw2Torque.__proto__ || Object.getPrototypeOf(Tw2Torque)).call(this)); - - _this.rot0 = _math.quat.create(); - _this.omega0 = _math.vec3.create(); - _this.torque = _math.vec3.create(); - return _this; - } - - return Tw2Torque; -}(_Tw2Curve2.Tw2CurveKey); - -/** - * Tw2RigidOrientation + * Tw2EulerRotation * * @property {string} name - * @property {number} I - * @property {number} drag - * @property {quat} value - * @property {number} start - * @property {Array.} states - * @property {number} length + * @property {Tw2Curve} [yawCurve] + * @property {Tw2Curve} [pitchCurve] + * @property {Tw2Curve} [rollCurve] + * @property {quat} currentValue=[0,0,0,1] * @class */ +var Tw2EulerRotation = exports.Tw2EulerRotation = function (_Tw2CurveSequencer) { + _inherits(Tw2EulerRotation, _Tw2CurveSequencer); + function Tw2EulerRotation() { + _classCallCheck(this, Tw2EulerRotation); -var Tw2RigidOrientation = exports.Tw2RigidOrientation = function (_Tw2Curve) { - _inherits(Tw2RigidOrientation, _Tw2Curve); - - function Tw2RigidOrientation() { - _classCallCheck(this, Tw2RigidOrientation); - - var _this2 = _possibleConstructorReturn(this, (Tw2RigidOrientation.__proto__ || Object.getPrototypeOf(Tw2RigidOrientation)).call(this)); + var _this = _possibleConstructorReturn(this, (Tw2EulerRotation.__proto__ || Object.getPrototypeOf(Tw2EulerRotation)).call(this)); - _this2.name = ''; - _this2.I = 1; - _this2.drag = 1; - _this2.value = _math.quat.create(); - _this2.start = 0; - _this2.states = []; - _this2.length = 0; - return _this2; + _this.yawCurve = null; + _this.pitchCurve = null; + _this.rollCurve = null; + _this.currentValue = _global.quat.create(); + return _this; } /** - * Sorts the curve's keys + * Sorts the sequencer */ - _createClass(Tw2RigidOrientation, [{ + _createClass(Tw2EulerRotation, [{ key: 'Sort', value: function Sort() { - _Tw2Curve2.Tw2Curve.Sort(this, this.states); + _Tw2CurveSequencer2.Tw2CurveSequencer.Sort2(this); } /** - * Gets the curve's length + * Gets sequencer length * @returns {number} */ }, { key: 'GetLength', value: function GetLength() { - return this.length; + var len = 0; + if (this.yawCurve && 'GetLength' in this.yawCurve) len = this.yawCurve.GetLength(); + if (this.pitchCurve && 'GetLength' in this.pitchCurve) len = Math.max(len, this.pitchCurve.GetLength()); + if (this.rollCurve && 'GetLength' in this.rollCurve) len = Math.max(len, this.rollCurve.GetLength()); + return len; } /** - * Updates the current value at the given time + * Updates the current value at a specific time * @param {number} time */ }, { key: 'UpdateValue', value: function UpdateValue(time) { - this.GetValueAt(time, this.value); + this.GetValueAt(time, this.currentValue); } /** @@ -29269,69 +29726,63 @@ var Tw2RigidOrientation = exports.Tw2RigidOrientation = function (_Tw2Curve) { }, { key: 'GetValueAt', value: function GetValueAt(time, value) { - if (this.states.length === 0 || time < 0 || time < this.states[0].time) { - return _math.quat.copy(value, this.value); - } + var yaw = this.yawCurve ? this.yawCurve.GetValueAt(time) : 0.0, + pitch = this.pitchCurve ? this.pitchCurve.GetValueAt(time) : 0.0, + roll = this.rollCurve ? this.rollCurve.GetValueAt(time) : 0.0; - var key = 0; - if (time >= this.states[this.states.length - 1].time) { - key = this.states.length - 1; - } else { - for (; key + 1 < this.states.length; ++key) { - if (time >= this.states[key].time && time < this.states[key + 1].time) { - break; - } - } - } + var sinYaw = Math.sin(yaw / 2.0), + cosYaw = Math.cos(yaw / 2.0), + sinPitch = Math.sin(pitch / 2.0), + cosPitch = Math.cos(pitch / 2.0), + sinRoll = Math.sin(roll / 2.0), + cosRoll = Math.cos(roll / 2.0); - var vec3_0 = _Tw2Curve2.Tw2Curve.global.vec3_0, - quat_0 = _Tw2Curve2.Tw2Curve.global.quat_0; + value[0] = sinYaw * cosPitch * sinRoll + cosYaw * sinPitch * cosRoll; + value[1] = sinYaw * cosPitch * cosRoll - cosYaw * sinPitch * sinRoll; + value[2] = cosYaw * cosPitch * sinRoll - sinYaw * sinPitch * cosRoll; + value[3] = cosYaw * cosPitch * cosRoll + sinYaw * sinPitch * sinRoll; - var ck = this.states[key]; - _math.vec3.exponentialDecay(vec3_0, ck.omega0, ck.torque, this.I, this.drag, time - ck.time); - _math.quat.exp(quat_0, vec3_0); - _math.quat.multiply(value, this.states[key].rot0, quat_0); return value; } }]); - return Tw2RigidOrientation; -}(_Tw2Curve2.Tw2Curve); + return Tw2EulerRotation; +}(_Tw2CurveSequencer2.Tw2CurveSequencer); /** - * The curve's key dimension + * The sequencer's curve dimension * @type {number} */ -Tw2RigidOrientation.inputDimension = 4; +Tw2EulerRotation.inputDimension = 1; /** - * The curve's dimension + * The sequencer's dimension * @type {number} */ -Tw2RigidOrientation.outputDimension = 4; +Tw2EulerRotation.outputDimension = 3; /** - * The curve's current value property + * The sequencer's current value property * @type {string} */ -Tw2RigidOrientation.valueProperty = 'value'; +Tw2EulerRotation.valueProperty = 'currentValue'; /** - * The curve's type + * The sequencer's type * @type {number} */ -Tw2RigidOrientation.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE; +Tw2EulerRotation.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCER2; /** - * The curve's key constructor - * @type {Tw2Torque} + * The sequencer's curve property names + * @type {string[]} */ -Tw2RigidOrientation.Key = Tw2Torque; +Tw2EulerRotation.childProperties = ['yawCurve', 'pitchCurve', 'rollCurve']; /***/ }), -/* 148 */ +/* 145 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -29340,13 +29791,13 @@ Tw2RigidOrientation.Key = Tw2Torque; Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2RotationCurve = exports.Tw2QuaternionKey = undefined; +exports.Tw2QuaternionSequencer = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); -var _Tw2Curve2 = __webpack_require__(3); +var _Tw2CurveSequencer2 = __webpack_require__(5); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -29355,87 +29806,58 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2QuaternionKey + * Tw2QuaternionSequencer * - * @property {number} time + * @property {string} name + * @property {number} start * @property {quat} value - * @property {vec4} leftTangent - * @property {vec4} rightTangent - * @property {number} interpolation + * @property {Array} functions * @class */ -var Tw2QuaternionKey = exports.Tw2QuaternionKey = function (_Tw2CurveKey) { - _inherits(Tw2QuaternionKey, _Tw2CurveKey); +var Tw2QuaternionSequencer = exports.Tw2QuaternionSequencer = function (_Tw2CurveSequencer) { + _inherits(Tw2QuaternionSequencer, _Tw2CurveSequencer); - function Tw2QuaternionKey() { - _classCallCheck(this, Tw2QuaternionKey); + function Tw2QuaternionSequencer() { + _classCallCheck(this, Tw2QuaternionSequencer); - var _this = _possibleConstructorReturn(this, (Tw2QuaternionKey.__proto__ || Object.getPrototypeOf(Tw2QuaternionKey)).call(this)); + var _this = _possibleConstructorReturn(this, (Tw2QuaternionSequencer.__proto__ || Object.getPrototypeOf(Tw2QuaternionSequencer)).call(this)); - _this.value = _math.quat.create(); - _this.left = _math.vec4.create(); - _this.right = _math.vec4.create(); - _this.interpolation = 5; + _this.start = 0; + _this.value = _global.quat.create(); + _this.functions = []; return _this; } - return Tw2QuaternionKey; -}(_Tw2Curve2.Tw2CurveKey); - -/** - * Tw2RotationCurve - * - * @property {number} start - * @property {quat} value - * @property {number} extrapolation - * @property {Array.} keys - * @property {number} _currentKey - * @property {number} length - * @class` - */ - - -var Tw2RotationCurve = exports.Tw2RotationCurve = function (_Tw2Curve) { - _inherits(Tw2RotationCurve, _Tw2Curve); - - function Tw2RotationCurve() { - _classCallCheck(this, Tw2RotationCurve); - - var _this2 = _possibleConstructorReturn(this, (Tw2RotationCurve.__proto__ || Object.getPrototypeOf(Tw2RotationCurve)).call(this)); - - _this2.start = 0; - _this2.value = _math.quat.create(); - _this2.extrapolation = 0; - _this2.keys = []; - _this2._currentKey = 1; - _this2.length = 0; - return _this2; - } - /** - * Sorts the curve's children + * Sorts the sequencer */ - _createClass(Tw2RotationCurve, [{ + _createClass(Tw2QuaternionSequencer, [{ key: 'Sort', value: function Sort() { - _Tw2Curve2.Tw2Curve.Sort(this); + _Tw2CurveSequencer2.Tw2CurveSequencer.Sort(this); } /** - * Gets the curve's length + * Gets sequencer length * @returns {number} */ }, { key: 'GetLength', value: function GetLength() { - return this.length; + var len = 0; + for (var i = 0; i < this.functions.length; ++i) { + if ('GetLength' in this.functions[i]) { + len = Math.max(len, this.functions[i].GetLength()); + } + } + return len; } /** - * Updates the current value at the given time + * Updates a value at a specific time * @param {number} time */ @@ -29455,144 +29877,194 @@ var Tw2RotationCurve = exports.Tw2RotationCurve = function (_Tw2Curve) { }, { key: 'GetValueAt', value: function GetValueAt(time, value) { - if (this.length === 0) { - return _math.quat.copy(value, this.value); + _global.quat.identity(value); + var quat_0 = _Tw2CurveSequencer2.Tw2CurveSequencer.global.quat_0; + for (var i = 0; i < this.functions.length; ++i) { + this.functions[i].GetValueAt(time, quat_0); + _global.quat.multiply(value, value, quat_0); } + return value; + } + }]); - var scratch = _Tw2Curve2.Tw2Curve.global, - firstKey = this.keys[0], - lastKey = this.keys[this.keys.length - 1]; + return Tw2QuaternionSequencer; +}(_Tw2CurveSequencer2.Tw2CurveSequencer); - if (time >= lastKey.time) { - switch (this.extrapolation) { - case Tw2RotationCurve.Extrapolation.NONE: - return _math.quat.copy(value, this.value); +/** + * The sequencer's curve dimension + * @type {number} + */ - case Tw2RotationCurve.Extrapolation.CONSTANT: - return _math.quat.copy(value, lastKey.value); - default: - time = time % lastKey.time; - } - } else if (time < 0 || time < firstKey.time) { - switch (this.extrapolation) { - case Tw2RotationCurve.Extrapolation.NONE: - return _math.quat.copy(value, this.value); +Tw2QuaternionSequencer.inputDimension = 4; - default: - return _math.quat.copy(value, firstKey.value); - } - } +/** + * The sequencer's dimension + * @type {number} + */ +Tw2QuaternionSequencer.outputDimension = 4; - var ck = this.keys[this._currentKey], - ck_1 = this.keys[this._currentKey - 1]; +/** + * The sequencer's current value property + * @type {string} + */ +Tw2QuaternionSequencer.valueProperty = 'value'; - while (time >= ck.time || time < ck_1.time) { - if (time < ck_1.time) this._currentKey = 0; - this._currentKey++; - ck = this.keys[this._currentKey]; - ck_1 = this.keys[this._currentKey - 1]; - } +/** + * The sequencer's type + * @type {number} + */ +Tw2QuaternionSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCER; - var nt = (time - ck_1.time) / (ck.time - ck_1.time); - switch (ck_1.interpolation) { - case Tw2RotationCurve.Interpolation.CONSTANT: - return _math.quat.copy(value, ck_1.value); +/** + * The sequencer's curve array + * @type {string} + */ +Tw2QuaternionSequencer.childArray = 'functions'; - case Tw2RotationCurve.Interpolation.LINEAR: - value[0] = ck_1.value[0] * (1 - nt) + ck.value[0] * nt; - value[1] = ck_1.value[1] * (1 - nt) + ck.value[1] * nt; - value[2] = ck_1.value[2] * (1 - nt) + ck.value[2] * nt; - value[3] = ck_1.value[3] * (1 - nt) + ck.value[3] * nt; - return value; +/***/ }), +/* 146 */ +/***/ (function(module, exports, __webpack_require__) { - case Tw2RotationCurve.Interpolation.HERMITE: - var collect = _math.quat.identity(scratch.quat_0), - arr = [ck_1.value, ck_1.right, ck.left, ck.value]; +"use strict"; - for (var i = 3; i > 0; i--) { - var power = _math.num.biCumulative(nt, i); - if (power > 1) _math.quat.multiply(value, collect, arr[i]); - value[0] = -arr[i - 1][0]; - value[1] = -arr[i - 1][1]; - value[2] = -arr[i - 1][2]; - value[3] = arr[i - 1][3]; - _math.quat.multiply(value, value, arr[i]); - _math.quat.pow(value, value, power); - _math.quat.multiply(collect, collect, value); - } - return _math.quat.multiply(value, collect, ck_1.value); - case Tw2RotationCurve.Interpolation.SLERP: - return _math.quat.slerp(value, ck_1.value, ck.value, nt); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2RGBAScalarSequencer = undefined; - default: - return _math.quat.sqlerp(value, ck_1.value, ck_1.right, ck.left, ck.value, nt); - } - } - }]); +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - return Tw2RotationCurve; -}(_Tw2Curve2.Tw2Curve); +var _global = __webpack_require__(0); + +var _Tw2CurveSequencer2 = __webpack_require__(5); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * The curve's key dimension - * @type {number} + * Tw2RGBAScalarSequencer + * + * @property {vec4} value + * @property {Tw2Curve} RedCurve + * @property {Tw2Curve} GreenCurve + * @property {Tw2Curve} BlueCurve + * @property {Tw2Curve} AlphaCurve + * @class */ +var Tw2RGBAScalarSequencer = exports.Tw2RGBAScalarSequencer = function (_Tw2CurveSequencer) { + _inherits(Tw2RGBAScalarSequencer, _Tw2CurveSequencer); + + function Tw2RGBAScalarSequencer() { + _classCallCheck(this, Tw2RGBAScalarSequencer); + var _this = _possibleConstructorReturn(this, (Tw2RGBAScalarSequencer.__proto__ || Object.getPrototypeOf(Tw2RGBAScalarSequencer)).call(this)); -Tw2RotationCurve.outputDimention = 4; + _this.value = _global.vec4.create(); + _this.RedCurve = null; + _this.GreenCurve = null; + _this.BlueCurve = null; + _this.AlphaCurve = null; + return _this; + } + + /** + * Sorts the sequencer + */ + + + _createClass(Tw2RGBAScalarSequencer, [{ + key: 'Sort', + value: function Sort() { + _Tw2CurveSequencer2.Tw2CurveSequencer.Sort2(this); + } + + /** + * Gets sequencer length + * @returns {number} + */ + + }, { + key: 'GetLength', + value: function GetLength() { + var len = 0; + if (this.RedCurve && 'GetLength' in this.RedCurve) len = this.RedCurve.GetLength(); + if (this.GreenCurve && 'GetLength' in this.GreenCurve) len = Math.max(len, this.GreenCurve.GetLength()); + if (this.BlueCurve && 'GetLength' in this.BlueCurve) len = Math.max(len, this.BlueCurve.GetLength()); + if (this.AlphaCurve && 'GetLength' in this.AlphaCurve) len = Math.max(len, this.AlphaCurve.GetLength()); + return len; + } + + /** + * Updates the current value at a specific time + * @param {number} time + */ + + }, { + key: 'UpdateValue', + value: function UpdateValue(time) { + this.GetValueAt(time, this.value); + } + + /** + * Gets a value at a specific time + * @param {number} time + * @param {vec4} value + * @returns {vec4} + */ + + }, { + key: 'GetValueAt', + value: function GetValueAt(time, value) { + value[0] = this.RedCurve ? this.RedCurve.GetValueAt(time) : 0; + value[1] = this.GreenCurve ? this.GreenCurve.GetValueAt(time) : 0; + value[2] = this.BlueCurve ? this.BlueCurve.GetValueAt(time) : 0; + value[3] = this.AlphaCurve ? this.AlphaCurve.GetValueAt(time) : 0; + return value; + } + }]); + + return Tw2RGBAScalarSequencer; +}(_Tw2CurveSequencer2.Tw2CurveSequencer); /** - * The curve's dimension + * The sequencer's curve dimension * @type {number} */ -Tw2RotationCurve.inputDimension = 4; -/** - * The curve's current value property - * @type {string} - */ -Tw2RotationCurve.valueProperty = 'value'; + +Tw2RGBAScalarSequencer.inputDimension = 1; /** - * The curve's type + * The sequencer's dimension * @type {number} */ -Tw2RotationCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE; +Tw2RGBAScalarSequencer.outputDimension = 4; /** - * The curve's key constructor - * @type {Tw2QuaternionKey} + * The sequencer's current value property + * @type {string} */ -Tw2RotationCurve.Child = Tw2QuaternionKey; +Tw2RGBAScalarSequencer.valueProperty = 'value'; /** - * Extrapolation types - * @type {{NONE: number, CONSTANT: number, GRADIENT: number, CYCLE: number}} + * The sequencer's type + * @type {number} */ -Tw2RotationCurve.Extrapolation = { - NONE: 0, - CONSTANT: 1, - GRADIENT: 2, - CYCLE: 3 -}; +Tw2RGBAScalarSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCER2; /** - * Interpolation types - * @type {{NONE: number, CONSTANT: number, LINEAR: number, HERMITE: number, SLERP: number, SQUAD: number}} + * The sequencer's curve property names + * @type {string[]} */ -Tw2RotationCurve.Interpolation = { - NONE: 0, - CONSTANT: 1, - LINEAR: 2, - HERMITE: 3, - SLERP: 5, - SQUAD: 6 -}; +Tw2RGBAScalarSequencer.childProperties = ['RedCurve', 'GreenCurve', 'BlueCurve', 'AlphaCurve']; /***/ }), -/* 149 */ +/* 147 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -29601,11 +30073,11 @@ Tw2RotationCurve.Interpolation = { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2ScalarCurve = exports.Tw2ScalarKey = undefined; +exports.Tw2ScalarSequencer = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2Curve2 = __webpack_require__(3); +var _Tw2CurveSequencer2 = __webpack_require__(5); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -29614,90 +30086,69 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2ScalarKey + * Tw2ScalarSequencer * + * @property {string} name * @property {number} value - * @property {number} left - * @property {number} right - * @property {number} interpolation + * @property {number} operator + * @property {Array} functions + * @property {number} inMinClamp + * @property {number} inMaxClamp + * @property {number} outMinClamp + * @property {number} outMaxClamp + * @property {boolean} clamping * @class */ -var Tw2ScalarKey = exports.Tw2ScalarKey = function (_Tw2CurveKey) { - _inherits(Tw2ScalarKey, _Tw2CurveKey); +var Tw2ScalarSequencer = exports.Tw2ScalarSequencer = function (_Tw2CurveSequencer) { + _inherits(Tw2ScalarSequencer, _Tw2CurveSequencer); - function Tw2ScalarKey() { - _classCallCheck(this, Tw2ScalarKey); + function Tw2ScalarSequencer() { + _classCallCheck(this, Tw2ScalarSequencer); - var _this = _possibleConstructorReturn(this, (Tw2ScalarKey.__proto__ || Object.getPrototypeOf(Tw2ScalarKey)).call(this)); + var _this = _possibleConstructorReturn(this, (Tw2ScalarSequencer.__proto__ || Object.getPrototypeOf(Tw2ScalarSequencer)).call(this)); _this.value = 0; - _this.left = 0; - _this.right = 0; - _this.interpolation = 0; + _this.operator = 0; + _this.functions = []; + _this.inMinClamp = 0; + _this.inMaxClamp = 1; + _this.outMinClamp = 0; + _this.outMaxClamp = 1; + _this.clamping = false; return _this; } - return Tw2ScalarKey; -}(_Tw2Curve2.Tw2CurveKey); - -/** - * Tw2ScalarCurve - * - * @property {number} start - * @property {number} timeScale - * @property {number} timeOffset - * @property {number} value - * @property {number} extrapolation - * @property {Array.} keys - * @property {number} _currentKey - * @property {number} length - * @class - */ - - -var Tw2ScalarCurve = exports.Tw2ScalarCurve = function (_Tw2Curve) { - _inherits(Tw2ScalarCurve, _Tw2Curve); - - function Tw2ScalarCurve() { - _classCallCheck(this, Tw2ScalarCurve); - - var _this2 = _possibleConstructorReturn(this, (Tw2ScalarCurve.__proto__ || Object.getPrototypeOf(Tw2ScalarCurve)).call(this)); - - _this2.start = 0; - _this2.timeScale = 1; - _this2.timeOffset = 0; - _this2.value = 0; - _this2.extrapolation = 0; - _this2.keys = []; - _this2._currentKey = 1; - _this2.length = 0; - return _this2; - } - /** - * Sorts the curve's keys + * Sorts the sequencer */ - _createClass(Tw2ScalarCurve, [{ + _createClass(Tw2ScalarSequencer, [{ key: 'Sort', value: function Sort() { - _Tw2Curve2.Tw2Curve.Sort(this); + _Tw2CurveSequencer2.Tw2CurveSequencer.Sort(this); } /** - * Gets the curve's length + * Gets sequencer length * @returns {number} */ }, { key: 'GetLength', value: function GetLength() { - return this.length; + var len = 0; + for (var i = 0; i < this.functions.length; ++i) { + if ('GetLength' in this.functions[i]) { + len = Math.max(len, this.functions[i].GetLength()); + } + } + return len; } /** - * Updates the current value at the given time + * Updates a value at a specific time + * * @param {number} time */ @@ -29709,143 +30160,93 @@ var Tw2ScalarCurve = exports.Tw2ScalarCurve = function (_Tw2Curve) { /** * Gets a value at a specific time + * * @param {number} time * @returns {number} */ }, { key: 'GetValueAt', - value: function GetValueAt(time) { - time = time / this.timeScale - this.timeOffset; - - if (this.length === 0) { - return this.value; - } - - var firstKey = this.keys[0], - lastKey = this.keys[this.keys.length - 1]; - - if (time >= lastKey.time) { - switch (this.extrapolation) { - case Tw2ScalarCurve.Extrapolation.NONE: - return this.value; - - case Tw2ScalarCurve.Extrapolation.CONSTANT: - return lastKey.value; - - case Tw2ScalarCurve.Extrapolation.GRADIENT: - return lastKey.value + (time - lastKey.time) * lastKey.right; - - default: - time = time % lastKey.time; - } - } else if (time < 0 || time < firstKey.time) { - switch (this.extrapolation) { - case Tw2ScalarCurve.Extrapolation.NONE: - return this.value; - - case Tw2ScalarCurve.Extrapolation.GRADIENT: - return firstKey.value + (time * this.length - lastKey.time) * firstKey.left; - - default: - return firstKey.value; - } - } - - var ck = this.keys[this._currentKey], - ck_1 = this.keys[this._currentKey - 1]; - - while (time >= ck.time || time < ck_1.time) { - if (time < ck_1.time) this._currentKey = 0; - this._currentKey++; - ck = this.keys[this._currentKey]; - ck_1 = this.keys[this._currentKey - 1]; - } - - var nt = (time - ck_1.time) / (ck.time - ck_1.time); - switch (ck_1.interpolation) { - case Tw2ScalarCurve.Interpolation.CONSTANT: - return ck_1.value; - - case Tw2ScalarCurve.Interpolation.LINEAR: - return ck_1.value * (1 - nt) + ck.value * nt; + value: function GetValueAt(time) { + var value = void 0; - case Tw2ScalarCurve.Interpolation.HERMITE: - var k3 = 2 * nt * nt * nt - 3 * nt * nt + 1, - k2 = -2 * nt * nt * nt + 3 * nt * nt, - k1 = nt * nt * nt - 2 * nt * nt + nt, - k0 = nt * nt * nt - nt * nt; - return k3 * ck_1.value + k2 * ck.value + k1 * ck_1.right + k0 * ck.left; + switch (this.operator) { + case Tw2ScalarSequencer.Operator.MULTIPLY: + value = 1; + for (var i = 0; i < this.functions.length; ++i) { + var v = this.functions[i].GetValueAt(time); + if (this.clamping) { + v = Math.min(Math.max(v, this.inMinClamp), this.inMaxClamp); + } + value *= v; + } + break; default: - var sq = Math.sqrt(ck_1.value / ck.value), - exponent = Math.exp(-time / ck_1.right), - ret = 1.0 + (sq - 1.0) * exponent; - return ret * ret * ck.value; + value = 0; + for (var _i = 0; _i < this.functions.length; ++_i) { + var _v = this.functions[_i].GetValueAt(time); + if (this.clamping) { + _v = Math.min(Math.max(_v, this.inMinClamp), this.inMaxClamp); + } + value += _v; + } + } + + if (this.clamping) { + value = Math.min(Math.max(value, this.outMinClamp), this.outMaxClamp); } + + return value; } }]); - return Tw2ScalarCurve; -}(_Tw2Curve2.Tw2Curve); + return Tw2ScalarSequencer; +}(_Tw2CurveSequencer2.Tw2CurveSequencer); /** - * The curve's key dimension + * The sequencer's curve dimension * @type {number} */ -Tw2ScalarCurve.inputDimension = 1; +Tw2ScalarSequencer.inputDimension = 1; /** - * The curve's dimension + * The sequencer's dimension * @type {number} */ -Tw2ScalarCurve.outputDimension = 1; +Tw2ScalarSequencer.outputDimension = 1; /** - * The curve's current value property + * The sequencer's current value property * @type {string} */ -Tw2ScalarCurve.valueProperty = 'value'; +Tw2ScalarSequencer.valueProperty = 'value'; /** - * The curve's type + * The sequencer's type * @type {number} */ -Tw2ScalarCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE; - -/** - * The curve's key constructor - * @type {Tw2ScalarKey} - */ -Tw2ScalarCurve.Key = Tw2ScalarKey; +Tw2ScalarSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCER; /** - * Extrapolation types - * @type {{NONE: number, CONSTANT: number, GRADIENT: number, CYCLE: number}} + * The sequencer's curve properties + * @type {string} */ -Tw2ScalarCurve.Extrapolation = { - NONE: 0, - CONSTANT: 1, - GRADIENT: 2, - CYCLE: 3 -}; +Tw2ScalarSequencer.childArray = 'functions'; /** - * Interpolation types - * @type {{NONE: number, CONSTANT: number, LINEAR: number, HERMITE: number, CATMULROM: number}} + * Operator types + * @type {{MULTIPLY: number, ADD: number}} */ -Tw2ScalarCurve.Interpolation = { - NONE: 0, - CONSTANT: 1, - LINEAR: 2, - HERMITE: 3, - CATMULROM: 4 +Tw2ScalarSequencer.Operator = { + MULTIPLY: 0, + ADD: 1 }; /***/ }), -/* 150 */ +/* 148 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -29854,11 +30255,13 @@ Tw2ScalarCurve.Interpolation = { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2ScalarCurve2 = exports.Tw2ScalarKey2 = undefined; +exports.Tw2VectorSequencer = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2Curve2 = __webpack_require__(3); +var _global = __webpack_require__(0); + +var _Tw2CurveSequencer2 = __webpack_require__(5); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -29867,277 +30270,285 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2ScalarKey2 + * Tw2VectorSequencer * - * @property {number} value - * @property {number} leftTangent - * @property {number} rightTangent - * @property {number} interpolation + * @property {string} name + * @property {number} start + * @property {vec3} value + * @property {number} operator + * @property {Array.} functions * @class */ -var Tw2ScalarKey2 = exports.Tw2ScalarKey2 = function (_Tw2CurveKey) { - _inherits(Tw2ScalarKey2, _Tw2CurveKey); +var Tw2VectorSequencer = exports.Tw2VectorSequencer = function (_Tw2CurveSequencer) { + _inherits(Tw2VectorSequencer, _Tw2CurveSequencer); - function Tw2ScalarKey2() { - _classCallCheck(this, Tw2ScalarKey2); + function Tw2VectorSequencer() { + _classCallCheck(this, Tw2VectorSequencer); - var _this = _possibleConstructorReturn(this, (Tw2ScalarKey2.__proto__ || Object.getPrototypeOf(Tw2ScalarKey2)).call(this)); + var _this = _possibleConstructorReturn(this, (Tw2VectorSequencer.__proto__ || Object.getPrototypeOf(Tw2VectorSequencer)).call(this)); - _this.value = 0; - _this.leftTangent = 0; - _this.rightTangent = 0; - _this.interpolation = 1; + _this.start = 0; + _this.value = _global.vec3.create(); + _this.operator = 0; + _this.functions = []; return _this; } - return Tw2ScalarKey2; -}(_Tw2Curve2.Tw2CurveKey); - -/** - * Tw2ScalarCurve2 - * - * @property {boolean} cycle - * @property {boolean} reversed - * @property {number} timeOffset - * @property {number} timeScale - * @property {number} startValue - * @property {number} currentValue - * @property {number} endValue - * @property {number} startTangent - * @property {number} endTangent - * @property {number} interpolation - * @property {Array.} keys - * @property {number} length - * @class - */ - - -var Tw2ScalarCurve2 = exports.Tw2ScalarCurve2 = function (_Tw2Curve) { - _inherits(Tw2ScalarCurve2, _Tw2Curve); - - function Tw2ScalarCurve2() { - _classCallCheck(this, Tw2ScalarCurve2); - - var _this2 = _possibleConstructorReturn(this, (Tw2ScalarCurve2.__proto__ || Object.getPrototypeOf(Tw2ScalarCurve2)).call(this)); - - _this2.cycle = false; - _this2.reversed = false; - _this2.timeOffset = 0; - _this2.timeScale = 1; - _this2.startValue = 0; - _this2.currentValue = 0; - _this2.endValue = 0; - _this2.startTangent = 0; - _this2.endTangent = 0; - _this2.interpolation = 1; - _this2.keys = []; - _this2.length = 0; - return _this2; - } - /** - * Sorts the curve's keys + * Sorts the sequencer */ - _createClass(Tw2ScalarCurve2, [{ + _createClass(Tw2VectorSequencer, [{ key: 'Sort', value: function Sort() { - _Tw2Curve2.Tw2Curve.Sort2(this); + _Tw2CurveSequencer2.Tw2CurveSequencer.Sort(this); } /** - * Gets the curve's length + * Gets sequencer length * @returns {number} */ }, { key: 'GetLength', value: function GetLength() { - return this.length; + var len = 0; + for (var i = 0; i < this.functions.length; ++i) { + if ('GetLength' in this.functions[i]) { + len = Math.max(len, this.functions[i].GetLength()); + } + } + return len; } /** - * Updates the current value at the given time + * Updates the current value at a specific time * @param {number} time */ }, { key: 'UpdateValue', value: function UpdateValue(time) { - this.currentValue = this.GetValueAt(time); + this.GetValueAt(time, this.value); } /** * Gets a value at a specific time * @param {number} time - * @returns {number} + * @param {vec3} value + * @returns {vec3} */ }, { key: 'GetValueAt', - value: function GetValueAt(time) { - time = time / this.timeScale + this.timeOffset; - if (this.length <= 0 || time <= 0) { - return this.startValue; - } + value: function GetValueAt(time, value) { + var vec3_0 = _Tw2CurveSequencer2.Tw2CurveSequencer.global.vec3_0; - if (time > this.length) { - if (this.cycle) { - time = time % this.length; - } else if (this.reversed) { - return this.startValue; - } else { - return this.endValue; - } - } + switch (this.operator) { + case Tw2VectorSequencer.Operator.MULTIPLY: + _global.vec3.set(value, 1, 1, 1); + for (var i = 0; i < this.functions.length; ++i) { + this.functions[i].GetValueAt(time, vec3_0); + _global.vec3.multiply(value, value, vec3_0); + } + return value; - if (this.reversed) { - time = this.length - time; + default: + _global.vec3.set(value, 0, 0, 0); + for (var _i = 0; _i < this.functions.length; ++_i) { + this.functions[_i].GetValueAt(time, vec3_0); + _global.vec3.add(value, value, vec3_0); + } + return value; } + } + }]); - if (this.keys.length === 0) { - return this.Interpolate(time, null, null); - } + return Tw2VectorSequencer; +}(_Tw2CurveSequencer2.Tw2CurveSequencer); - var startKey = this.keys[0], - endKey = this.keys[this.keys.length - 1]; +/** + * The sequencer's curve dimension + * @type {number} + */ - if (time <= startKey.time) { - return this.Interpolate(time, null, startKey); - } else if (time >= endKey.time) { - return this.Interpolate(time, endKey, null); - } - for (var i = 0; i + 1 < this.keys.length; ++i) { - startKey = this.keys[i]; - endKey = this.keys[i + 1]; - if (startKey.time <= time && endKey.time > time) break; - } +Tw2VectorSequencer.inputDimension = 3; - return this.Interpolate(time, startKey, endKey); - } +/** + * The sequencer's dimension + * @type {number} + */ +Tw2VectorSequencer.outputDimension = 3; - /** - * Interpolate - * @param {number} time - * @param {Tw2ScalarKey2} lastKey - * @param {Tw2ScalarKey2} nextKey - * @returns {number} - */ +/** + * The sequencer's current value property + * @type {string} + */ +Tw2VectorSequencer.valueProperty = 'value'; - }, { - key: 'Interpolate', - value: function Interpolate(time, lastKey, nextKey) { - var startValue = this.startValue, - endValue = this.endValue, - interp = this.interpolation, - deltaTime = this.length; +/** + * The sequencer's type + * @type {number} + */ +Tw2VectorSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCER; - if (lastKey !== null) { - interp = lastKey.interpolation; - time -= lastKey.time; - } +/** + * The sequencer's curve properties + * @type {string} + */ +Tw2VectorSequencer.childArray = 'functions'; - switch (interp) { - case Tw2ScalarCurve2.Interpolation.LINEAR: - if (lastKey && nextKey) { - startValue = lastKey.value; - endValue = nextKey.value; - deltaTime = nextKey.time - lastKey.time; - } else if (nextKey) { - endValue = nextKey.value; - deltaTime = nextKey.time; - } else if (lastKey) { - startValue = lastKey.value; - deltaTime = this.length - lastKey.time; - } - return startValue + (endValue - startValue) * (time / deltaTime); +/** + * Operator types + * @type {{MULTIPLY: number, ADD: number}} + */ +Tw2VectorSequencer.Operator = { + MULTIPLY: 0, + ADD: 1 +}; - case Tw2ScalarCurve2.Interpolation.HERMITE: - var inTangent = this.startTangent, - outTangent = this.endTangent; +/***/ }), +/* 149 */ +/***/ (function(module, exports, __webpack_require__) { - if (lastKey && nextKey) { - startValue = lastKey.value; - inTangent = lastKey.rightTangent; - endValue = nextKey.value; - outTangent = nextKey.leftTangent; - deltaTime = nextKey.time - lastKey.time; - } else if (nextKey) { - endValue = nextKey.value; - outTangent = nextKey.leftTangent; - deltaTime = nextKey.time; - } else if (lastKey) { - startValue = lastKey.value; - inTangent = lastKey.rightTangent; - deltaTime = this.length - lastKey.time; - } +"use strict"; - var s = time / deltaTime, - s2 = s * s, - s3 = s2 * s; - var c2 = -2.0 * s3 + 3.0 * s2, - c1 = 1.0 - c2, - c4 = s3 - s2, - c3 = s + c4 - s2; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2XYZScalarSequencer = undefined; - return startValue * c1 + endValue * c2 + inTangent * c3 + outTangent * c4; +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - default: - return this.startValue; - } - } - }]); +var _global = __webpack_require__(0); - return Tw2ScalarCurve2; -}(_Tw2Curve2.Tw2Curve); +var _Tw2CurveSequencer2 = __webpack_require__(5); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * The curve's key dimension - * @type {number} + * Tw2XYZScalarSequencer + * + * @property {string} name + * @property {vec3} value + * @property {Tw2CurveSequencer} XCurve + * @property {Tw2CurveSequencer} YCurve + * @property {Tw2CurveSequencer} ZCurve + * @class */ +var Tw2XYZScalarSequencer = exports.Tw2XYZScalarSequencer = function (_Tw2CurveSequencer) { + _inherits(Tw2XYZScalarSequencer, _Tw2CurveSequencer); + + function Tw2XYZScalarSequencer() { + _classCallCheck(this, Tw2XYZScalarSequencer); + var _this = _possibleConstructorReturn(this, (Tw2XYZScalarSequencer.__proto__ || Object.getPrototypeOf(Tw2XYZScalarSequencer)).call(this)); -Tw2ScalarCurve2.inputDimension = 1; + _this.value = _global.vec3.create(); + _this.XCurve = null; + _this.YCurve = null; + _this.ZCurve = null; + return _this; + } + + /** + * Sorts the sequencer + */ + + + _createClass(Tw2XYZScalarSequencer, [{ + key: 'Sort', + value: function Sort() { + _Tw2CurveSequencer2.Tw2CurveSequencer.Sort2(this); + } + + /** + * Gets sequencer length + * @returns {number} + */ + + }, { + key: 'GetLength', + value: function GetLength() { + var len = 0; + if (this.XCurve && 'GetLength' in this.XCurve) len = this.XCurve.GetLength(); + if (this.YCurve && 'GetLength' in this.YCurve) len = Math.max(len, this.YCurve.GetLength()); + if (this.ZCurve && 'GetLength' in this.ZCurve) len = Math.max(len, this.ZCurve.GetLength()); + return len; + } + + /** + * Updates a value at a specific time + * @param {number} time + */ + + }, { + key: 'UpdateValue', + value: function UpdateValue(time) { + this.GetValueAt(time, this.value); + } + + /** + * Gets a value at a specific time + * @param {number} time + * @param {vec3} value + * @returns {vec3} + */ + + }, { + key: 'GetValueAt', + value: function GetValueAt(time, value) { + value[0] = this.XCurve ? this.XCurve.GetValueAt(time) : 0; + value[1] = this.YCurve ? this.YCurve.GetValueAt(time) : 0; + value[2] = this.ZCurve ? this.ZCurve.GetValueAt(time) : 0; + return value; + } + }]); + + return Tw2XYZScalarSequencer; +}(_Tw2CurveSequencer2.Tw2CurveSequencer); /** - * The curve's dimension + * The sequencer's curve dimension * @type {number} */ -Tw2ScalarCurve2.outputDimension = 1; + + +Tw2XYZScalarSequencer.inputDimension = 1; /** - * The curve's current value property - * @type {string} + * The sequencer's dimension + * @type {number} */ -Tw2ScalarCurve2.valueProperty = 'currentValue'; +Tw2XYZScalarSequencer.outputDimension = 3; /** - * The curve's type - * @type {number} + * The sequencer's current value property + * @type {string} */ -Tw2ScalarCurve2.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE2; +Tw2XYZScalarSequencer.valueProperty = 'value'; /** - * The curve's key constructor - * @type {Tw2ScalarKey2} + * The sequencer's type + * @type {number} */ -Tw2ScalarCurve2.Key = Tw2ScalarKey2; +Tw2XYZScalarSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCER2; /** - * Interpolation types - * @type {{CONSTANT: number, LINEAR: number, HERMITE: number}} + * The sequencer's curve property names + * @type {string[]} */ -Tw2ScalarCurve2.Interpolation = { - CONSTANT: 0, - LINEAR: 1, - HERMITE: 2 -}; +Tw2XYZScalarSequencer.childProperties = ['XCurve', 'YCurve', 'ZCurve']; /***/ }), -/* 151 */ +/* 150 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -30146,11 +30557,13 @@ Tw2ScalarCurve2.Interpolation = { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2SineCurve = undefined; +exports.Tw2YPRSequencer = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2Curve2 = __webpack_require__(3); +var _global = __webpack_require__(0); + +var _Tw2CurveSequencer2 = __webpack_require__(5); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -30159,379 +30572,335 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2SineCurve + * Tw2YPRSequencer * - * @property {string} name - * @property {number} value - * @property {number} offset - * @property {number} scale - * @property {number} speed + * @property {quat} value + * @property {vec3} YawPitchRoll + * @property {Tw2Curve} YawCurve + * @property {Tw2Curve} PitchCurve + * @property {Tw2Curve} RollCurve + * @class */ -var Tw2SineCurve = exports.Tw2SineCurve = function (_Tw2Curve) { - _inherits(Tw2SineCurve, _Tw2Curve); +var Tw2YPRSequencer = exports.Tw2YPRSequencer = function (_Tw2CurveSequencer) { + _inherits(Tw2YPRSequencer, _Tw2CurveSequencer); - function Tw2SineCurve() { - _classCallCheck(this, Tw2SineCurve); + function Tw2YPRSequencer() { + _classCallCheck(this, Tw2YPRSequencer); - var _this = _possibleConstructorReturn(this, (Tw2SineCurve.__proto__ || Object.getPrototypeOf(Tw2SineCurve)).call(this)); + var _this = _possibleConstructorReturn(this, (Tw2YPRSequencer.__proto__ || Object.getPrototypeOf(Tw2YPRSequencer)).call(this)); - _this.value = 0; - _this.offset = 0; - _this.scale = 1; - _this.speed = 1; + _this.value = _global.quat.create(); + _this.YawPitchRoll = _global.vec3.create(); + _this.YawCurve = null; + _this.PitchCurve = null; + _this.RollCurve = null; return _this; } - /** - * Updates the current value at the given time - * @param {number} time - */ + /** + * Sorts the sequencer + */ + + + _createClass(Tw2YPRSequencer, [{ + key: 'Sort', + value: function Sort() { + _Tw2CurveSequencer2.Tw2CurveSequencer.Sort2(this); + } + + /** + * Gets sequencer length + * @returns {number} + */ + + }, { + key: 'GetLength', + value: function GetLength() { + var len = 0; + if (this.YawCurve && 'GetLength' in this.YawCurve) len = this.YawCurve.GetLength(); + if (this.PitchCurve && 'GetLength' in this.PitchCurve) len = Math.max(len, this.PitchCurve.GetLength()); + if (this.RollCurve && 'GetLength' in this.RollCurve) len = Math.max(len, this.RollCurve.GetLength()); + return len; + } + /** + * Updates a value at a specific time + * + * @param {number} time + */ - _createClass(Tw2SineCurve, [{ + }, { key: 'UpdateValue', value: function UpdateValue(time) { - this.value = this.GetValueAt(time); + this.GetValueAt(time, this.value); } /** * Gets a value at a specific time + * * @param {number} time - * @returns {number} + * @param {quat} value + * @returns {quat} */ }, { key: 'GetValueAt', - value: function GetValueAt(time) { - return Math.sin(time * Math.PI * 2 * this.speed) * this.scale + this.offset; + value: function GetValueAt(time, value) { + if (this.YawCurve) this.YawPitchRoll[0] = this.YawCurve.GetValueAt(time); + if (this.PitchCurve) this.YawPitchRoll[1] = this.PitchCurve.GetValueAt(time); + if (this.RollCurve) this.YawPitchRoll[2] = this.RollCurve.GetValueAt(time); + + var sinYaw = Math.sin(this.YawPitchRoll[0] / 180 * Math.PI / 2.0), + cosYaw = Math.cos(this.YawPitchRoll[0] / 180 * Math.PI / 2.0), + sinPitch = Math.sin(this.YawPitchRoll[1] / 180 * Math.PI / 2.0), + cosPitch = Math.cos(this.YawPitchRoll[1] / 180 * Math.PI / 2.0), + sinRoll = Math.sin(this.YawPitchRoll[2] / 180 * Math.PI / 2.0), + cosRoll = Math.cos(this.YawPitchRoll[2] / 180 * Math.PI / 2.0); + + value[0] = sinYaw * cosPitch * sinRoll + cosYaw * sinPitch * cosRoll; + value[1] = sinYaw * cosPitch * cosRoll - cosYaw * sinPitch * sinRoll; + value[2] = cosYaw * cosPitch * sinRoll - sinYaw * sinPitch * cosRoll; + value[3] = cosYaw * cosPitch * cosRoll + sinYaw * sinPitch * sinRoll; + + return value; } }]); - return Tw2SineCurve; -}(_Tw2Curve2.Tw2Curve); + return Tw2YPRSequencer; +}(_Tw2CurveSequencer2.Tw2CurveSequencer); /** - * THe curve's dimension + * The sequencer's curve dimension * @type {number} */ -Tw2SineCurve.outputDimension = 1; +Tw2YPRSequencer.inputDimension = 1; /** - * The curve's current value property + * The sequencer's dimension + * @type {number} + */ +Tw2YPRSequencer.outputDimension = 4; + +/** + * The sequencer's current value property * @type {string} */ -Tw2SineCurve.valueProperty = 'value'; +Tw2YPRSequencer.valueProperty = 'value'; /** - * The curve's type + * The sequencer's type * @type {number} */ -Tw2SineCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE_NO_KEYS; +Tw2YPRSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCER2; + +/** + * The sequencer's curve property names + * @type {string[]} + */ +Tw2YPRSequencer.childProperties = ['YawCurve', 'PitchCurve', 'RollCurve']; /***/ }), -/* 152 */ +/* 151 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { - value: true + value: true }); -exports.Tw2Vector2Curve = exports.Tw2Vector2Key = undefined; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _Tw2WbgTrack = __webpack_require__(152); -var _Tw2Curve2 = __webpack_require__(3); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +Object.keys(_Tw2WbgTrack).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2WbgTrack[key]; + } + }); +}); -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } +var _Tw2TransformTrack = __webpack_require__(153); -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } +Object.keys(_Tw2TransformTrack).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2TransformTrack[key]; + } + }); +}); -/** - * Tw2Vector2Key - * - * @property {vec2} value - * @property {vec2} leftTangent - * @property {vec2} rightTangent - * @property {number} interpolation - * @class - */ -var Tw2Vector2Key = exports.Tw2Vector2Key = function (_Tw2CurveKey) { - _inherits(Tw2Vector2Key, _Tw2CurveKey); +/***/ }), +/* 152 */ +/***/ (function(module, exports, __webpack_require__) { - function Tw2Vector2Key() { - _classCallCheck(this, Tw2Vector2Key); +"use strict"; - var _this = _possibleConstructorReturn(this, (Tw2Vector2Key.__proto__ || Object.getPrototypeOf(Tw2Vector2Key)).call(this)); - _this.value = _math.vec2.create(); - _this.leftTangent = _math.vec2.create(); - _this.rightTangent = _math.vec2.create(); - _this.interpolation = 1; - return _this; - } +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2WbgTrack = Tw2WbgTrack; +exports.Tw2WbgTransformTrack = Tw2WbgTransformTrack; - return Tw2Vector2Key; -}(_Tw2Curve2.Tw2CurveKey); +var _global = __webpack_require__(0); /** - * Tw2Vector2Curve + * Tw2WbgTrack * + * @property {string|number} _id + * @property {string} name + * @property {string} geometryResPath + * @property {Object} geometryRes + * @property {string} group + * @property {number} duration * @property {boolean} cycle - * @property {boolean} reversed - * @property {number} timeOffset - * @property {number} timeScale - * @property {vec2} startValue - vec2 array - * @property {vec2} currentValue - vec2 array - * @property {vec2} endValue - vec2 array - * @property {vec2} startTangent - vec2 array - * @property {vec2} endTangent - vec2 array - * @property {number} interpolation - * @property {Array.} keys - * @property {number} length - * @class */ - - -var Tw2Vector2Curve = exports.Tw2Vector2Curve = function (_Tw2Curve) { - _inherits(Tw2Vector2Curve, _Tw2Curve); - - function Tw2Vector2Curve() { - _classCallCheck(this, Tw2Vector2Curve); - - var _this2 = _possibleConstructorReturn(this, (Tw2Vector2Curve.__proto__ || Object.getPrototypeOf(Tw2Vector2Curve)).call(this)); - - _this2.cycle = false; - _this2.reversed = false; - _this2.timeOffset = 0; - _this2.timeScale = 1; - _this2.startValue = _math.vec2.create(); - _this2.currentValue = _math.vec2.create(); - _this2.endValue = _math.vec2.create(); - _this2.startTangent = _math.vec2.create(); - _this2.endTangent = _math.vec2.create(); - _this2.interpolation = 1; - _this2.keys = []; - _this2.length = 0; - return _this2; - } +function Tw2WbgTrack() { + this._id = _global.util.generateID(); + this.name = ''; + this.geometryResPath = ''; + this.geometryRes = null; + this.group = ''; + this.duration = 0; + this.cycle = false; /** - * Sorts the curve's keys + * SetCurves + * @param self + * @private */ - - - _createClass(Tw2Vector2Curve, [{ - key: 'Sort', - value: function Sort() { - _Tw2Curve2.Tw2Curve.Sort2(this); - } - - /** - * Gets the curve's length - * @returns {number} - */ - - }, { - key: 'GetLength', - value: function GetLength() { - return this.length; - } - - /** - * Updates the current value at the given time - * @param {number} time - */ - - }, { - key: 'UpdateValue', - value: function UpdateValue(time) { - this.GetValueAt(time, this.currentValue); + function SetCurves(self) { + if (!self.name || !self.group || !self.geometryRes) { + return; } - /** - * Gets a value at a specific time - * @param {number} time - * @param {vec2} value - vec2 array - * @returns {vec2} vec2 array - * @prototype - */ - - }, { - key: 'GetValueAt', - value: function GetValueAt(time, value) { - time = time / this.timeScale + this.timeOffset; - if (this.length <= 0 || time <= 0) { - return _math.vec2.copy(value, this.startValue); - } - - if (time > this.length) { - if (this.cycle) { - time = time % this.length; - } else if (this.reversed) { - return _math.vec2.copy(value, this.startValue); - } else { - return _math.vec2.copy(value, this.endValue); + for (var i = 0; i < self.geometryRes.animations.length; ++i) { + var animation = self.geometryRes.animations[i]; + for (var j = 0; j < animation.trackGroups.length; ++j) { + if (animation.trackGroups[j].name === self.group) { + self._ApplyTracks(animation.trackGroups[j], animation.duration); } } - - if (this.reversed) { - time = this.length - time; - } - - if (this.keys.length === 0) { - return this.Interpolate(time, null, null, value); - } - - var startKey = this.keys[0], - endKey = this.keys[this.keys.length - 1]; - - if (time <= startKey.time) { - return this.Interpolate(time, null, startKey, value); - } else if (time >= endKey.time) { - return this.Interpolate(time, endKey, null, value); - } - - for (var i = 0; i + 1 < this.keys.length; ++i) { - startKey = this.keys[i]; - endKey = this.keys[i + 1]; - if (startKey.time <= time && endKey.time > time) break; - } - - return this.Interpolate(time, startKey, endKey, value); } + } - /** - * Interpolate - * @param {number} time - * @param {Tw2Vector2Key} lastKey - * @param {Tw2Vector2Key} nextKey - * @param {vec2} value - vec2 array - * @returns {vec2} vec2 array - */ - - }, { - key: 'Interpolate', - value: function Interpolate(time, lastKey, nextKey, value) { - _math.vec2.copy(value, this.startValue); - - var startValue = this.startValue, - endValue = this.endValue, - interp = this.interpolation, - deltaTime = this.length; - - if (lastKey !== null) { - interp = lastKey.interpolation; - time -= lastKey.time; - } - - switch (interp) { - case Tw2Vector2Curve.Interpolation.LINEAR: - if (lastKey && nextKey) { - startValue = lastKey.value; - endValue = nextKey.value; - deltaTime = nextKey.time - lastKey.time; - } else if (nextKey) { - endValue = nextKey.value; - deltaTime = nextKey.time; - } else if (lastKey) { - startValue = lastKey.value; - deltaTime = this.length - lastKey.time; - } - value[0] = startValue[0] + (endValue[0] - startValue[0]) * (time / deltaTime); - value[1] = startValue[1] + (endValue[1] - startValue[1]) * (time / deltaTime); - return value; - - case Tw2Vector2Curve.Interpolation.HERMITE: - var inTangent = this.startTangent, - outTangent = this.endTangent; - - if (lastKey && nextKey) { - startValue = lastKey.value; - inTangent = lastKey.rightTangent; - endValue = nextKey.value; - outTangent = nextKey.leftTangent; - deltaTime = nextKey.time - lastKey.time; - } else if (nextKey) { - endValue = nextKey.value; - outTangent = nextKey.leftTangent; - deltaTime = nextKey.time; - } else if (lastKey) { - startValue = lastKey.value; - inTangent = lastKey.rightTangent; - deltaTime = this.length - lastKey.time; - } - - var s = time / deltaTime, - s2 = s * s, - s3 = s2 * s; - - var c2 = -2.0 * s3 + 3.0 * s2, - c1 = 1.0 - c2, - c4 = s3 - s2, - c3 = s + c4 - s2; - - value[0] = startValue[0] * c1 + endValue[0] * c2 + inTangent[0] * c3 + outTangent[0] * c4; - value[1] = startValue[1] * c1 + endValue[1] * c2 + inTangent[1] * c3 + outTangent[1] * c4; - return value; - - default: - return value; - } + /** + * Initialize + * @method + */ + this.Initialize = function () { + if (this.geometryResPath) { + this.geometryRes = _global.resMan.GetResource(this.geometryResPath); + var self = this; + var notification = { + OnResPrepared: function OnResPrepared() { + SetCurves(self); + } + }; + this.geometryRes.RegisterNotification(notification); } - }]); + }; - return Tw2Vector2Curve; -}(_Tw2Curve2.Tw2Curve); + /** + * Updates a value at a specific time + * @param {number} time + * @prototype + */ + this.UpdateValue = function (time) { + if (!this._TracksReady()) return; + if (this.cycle) time = time % this.duration; + if (time <= this.duration && time >= 0) this._UpdateValue(time); + }; +} /** - * The curve's key dimension - * @type {number} + * Tw2WbgTransformTrack + * + * @property {string|number} _id + * @property {vec3} translation + * @property {quat} rotation + * @property {vec3} scale + * @variable {*} positionCurve + * @variable {*} rotationCurve + * @variable {*} scaleCurve + * @variable {mat4} scaleShear */ +function Tw2WbgTransformTrack() { + this._id = _global.util.generateID(); + this.translation = _global.vec3.create(); + this.rotation = _global.quat.create(); + this.rotation[3] = 1; + this.scale = _global.vec3.create(); + var positionCurve = null; + var rotationCurve = null; + var scaleCurve = null; + var scaleShear = _global.mat4.create(); + /** + * _TracksReady + * @returns {*} + * @private + */ + this._TracksReady = function () { + return positionCurve || rotationCurve || scaleCurve; + }; -Tw2Vector2Curve.inputDimension = 2; + /** + * _ApplyTracks + * @param trackGroup + * @param duration + * @private + */ + this._ApplyTracks = function (trackGroup, duration) { + for (var i = 0; i < trackGroup.transformTracks.length; ++i) { + var track = trackGroup.transformTracks[i]; + if (track.name === this.name) { + this.duration = duration; + positionCurve = track.position; + rotationCurve = track.orientation; + scaleCurve = track.scaleShear; + } + } + this.UpdateValue(0); + }; -/** - * The curve's dimension - * @type {number} - */ -Tw2Vector2Curve.outputDimension = 2; + /** + * Updates a value at a specific time + * @param {number} time + * @prototype + */ + this._UpdateValue = function (time) { + if (positionCurve) { + _global.curve.evaluate(positionCurve, time, this.translation, this.cycle, this.duration); + } -/** - * The curve's current value property - * @type {string} - */ -Tw2Vector2Curve.valueProperty = 'value'; + if (rotationCurve) { + _global.curve.evaluate(rotationCurve, time, this.rotation, this.cycle, this.duration); + _global.quat.normalize(this.rotation, this.rotation); + } -/** - * The curve's type - * @type {number} - */ -Tw2Vector2Curve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE2; + if (scaleCurve) { + _global.curve.evaluate(scaleCurve, time, scaleShear, this.cycle, this.duration); + } -/** - * The curve's key constructor - * @type {Tw2Vector2Key} - */ -Tw2Vector2Curve.Key = Tw2Vector2Key; + this.scale[0] = scaleShear[0]; + this.scale[1] = scaleShear[5]; + this.scale[2] = scaleShear[10]; + }; +} /** - * Interpolation types - * @type {{CONSTANT: number, LINEAR: number, HERMITE: number}} + * @type {Tw2WbgTrack} + * @prototype */ -Tw2Vector2Curve.Interpolation = { - CONSTANT: 0, - LINEAR: 1, - HERMITE: 2 -}; +Tw2WbgTransformTrack.prototype = new Tw2WbgTrack(); /***/ }), /* 153 */ @@ -30543,304 +30912,195 @@ Tw2Vector2Curve.Interpolation = { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2Vector3Curve = exports.Tw2Vector3Key = undefined; +exports.Tw2TransformTrack = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); - -var _Tw2Curve2 = __webpack_require__(3); +var _global = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * Tw2Vector3Key - * - * @property {number} time - * @property {vec3} value - * @property {vec3} leftTangent - * @property {vec3} rightTangent - * @property {number} interpolation - * @class - */ -var Tw2Vector3Key = exports.Tw2Vector3Key = function (_Tw2CurveKey) { - _inherits(Tw2Vector3Key, _Tw2CurveKey); - - function Tw2Vector3Key() { - _classCallCheck(this, Tw2Vector3Key); - - var _this = _possibleConstructorReturn(this, (Tw2Vector3Key.__proto__ || Object.getPrototypeOf(Tw2Vector3Key)).call(this)); - - _this.value = _math.vec3.create(); - _this.leftTangent = _math.vec3.create(); - _this.rightTangent = _math.vec3.create(); - _this.interpolation = 1; - return _this; - } - - return Tw2Vector3Key; -}(_Tw2Curve2.Tw2CurveKey); - /** - * Tw2Vector3Curve + * Tw2TransformTrack * - * @property {boolean} cycle - * @property {boolean} reversed - * @property {number} timeOffset - * @property {number} timeScale - * @property {vec3} startValue - * @property {vec3} currentValue - * @property {vec3} endValue - * @property {vec3} startTangent - * @property {vec3} endTangent - * @property {number} interpolation - * @property {Array.} keys - * @property {number} length + * @property {string|number} _id + * @property {string} name + * @property {string} resPath + * @property {Object} res + * @property {string} group + * @property {boolean} cycle + * @property {number} duration + * @property {vec3} translation + * @property {quat} rotation + * @property {vec3} scale + * @property positionCurve + * @property orientationCurve + * @property scaleCurve + * @property {mat4} _scaleShear * @class */ +var Tw2TransformTrack = exports.Tw2TransformTrack = function () { + function Tw2TransformTrack() { + _classCallCheck(this, Tw2TransformTrack); - -var Tw2Vector3Curve = exports.Tw2Vector3Curve = function (_Tw2Curve) { - _inherits(Tw2Vector3Curve, _Tw2Curve); - - function Tw2Vector3Curve() { - _classCallCheck(this, Tw2Vector3Curve); - - var _this2 = _possibleConstructorReturn(this, (Tw2Vector3Curve.__proto__ || Object.getPrototypeOf(Tw2Vector3Curve)).call(this)); - - _this2.cycle = false; - _this2.reversed = false; - _this2.timeOffset = 0; - _this2.timeScale = 1; - _this2.startValue = _math.vec3.create(); - _this2.currentValue = _math.vec3.create(); - _this2.endValue = _math.vec3.create(); - _this2.startTangent = _math.vec3.create(); - _this2.endTangent = _math.vec3.create(); - _this2.interpolation = 1; - _this2.keys = []; - _this2.length = 0; - return _this2; + this._id = _global.util.generateID(); + this.name = ''; + this.resPath = ''; + this.res = null; + this.group = ''; + this.cycle = false; + this.duration = 0; + this.translation = _global.vec3.create(); + this.rotation = _global.quat.create(); + this.scale = _global.vec3.fromValues(0, 0, 0); + this.scaleShear = _global.mat4.create(); + this.positionCurve = null; + this.orientationCurve = null; + this.scaleCurve = null; } /** - * Sorts the curve's keys + * Initializes the Curve */ - _createClass(Tw2Vector3Curve, [{ - key: 'Sort', - value: function Sort() { - _Tw2Curve2.Tw2Curve.Sort2(this); + _createClass(Tw2TransformTrack, [{ + key: 'Initialize', + value: function Initialize() { + if (this.resPath !== '') { + this.res = _global.resMan.GetResource(this.resPath); + } } /** - * Gets the curve's length + * Gets curve length + * * @returns {number} */ }, { key: 'GetLength', value: function GetLength() { - return this.length; + return this.duration; } /** - * Updates the current value at the given time + * Updates a value at a specific time + * * @param {number} time */ }, { key: 'UpdateValue', value: function UpdateValue(time) { - this.GetValueAt(time, this.currentValue); + if (!this.res || !this.res.IsGood()) return; + if (!this.positionCurve) this.FindTracks(); + if (!this.positionCurve) return; + if (this.cycle) time = time % this.duration; + if (time > this.duration || time < 0) return; + + _global.curve.evaluate(this.positionCurve, time, this.translation, this.cycle, this.duration); + _global.curve.evaluate(this.orientationCurve, time, this.rotation, this.cycle, this.duration); + _global.quat.normalize(this.rotation, this.rotation); + _global.curve.evaluate(this.scaleCurve, time, this.scaleShear, this.cycle, this.duration); + _global.mat4.getScaling(this.scale, this.scaleCurve); } /** - * Gets a value at a specific time - * @param {number} time - * @param {vec3} value - * @returns {vec3} + * FindTracks */ }, { - key: 'GetValueAt', - value: function GetValueAt(time, value) { - time = time / this.timeScale + this.timeOffset; - if (this.length <= 0 || time <= 0) { - return _math.vec3.copy(value, this.startValue); - } - - if (time > this.length) { - if (this.cycle) { - time = time % this.length; - } else if (this.reversed) { - return _math.vec3.copy(value, this.startValue); - } else { - return _math.vec3.copy(value, this.endValue); + key: 'FindTracks', + value: function FindTracks() { + var group = null; + for (var i = 0; i < this.res.animations.length; ++i) { + for (var j = 0; j < this.res.animations[i].trackGroups.length; ++j) { + if (this.res.animations[i].trackGroups[j].name === this.group) { + this.duration = this.res.animations[i].duration; + group = this.res.animations[i].trackGroups[j]; + break; + } } } - if (this.reversed) { - time = this.length - time; - } - - if (this.keys.length === 0) { - return this.Interpolate(time, null, null, value); - } - - var startKey = this.keys[0], - endKey = this.keys[this.keys.length - 1]; - - if (time <= startKey.time) { - return this.Interpolate(time, null, startKey, value); - } else if (time >= endKey.time) { - return this.Interpolate(time, endKey, null, value); - } + if (!group) return; - for (var i = 0; i + 1 < this.keys.length; ++i) { - startKey = this.keys[i]; - endKey = this.keys[i + 1]; - if (startKey.time <= time && endKey.time > time) break; + for (var _i = 0; _i < group.transformTracks.length; ++_i) { + if (this.name === group.transformTracks[_i].name) { + this.positionCurve = group.transformTracks[_i].position; + this.orientationCurve = group.transformTracks[_i].orientation; + this.scaleCurve = group.transformTracks[_i].scaleShear; + break; + } } - - return this.Interpolate(time, startKey, endKey, value); } + }]); - /** - * Interpolate - * @param {number} time - * @param {Tw2Vector3Key} lastKey - * @param {Tw2Vector3Key} nextKey - * @param {vec3} value - * @returns {vec3} - */ - - }, { - key: 'Interpolate', - value: function Interpolate(time, lastKey, nextKey, value) { - _math.vec3.copy(value, this.startValue); - - var startValue = this.startValue, - endValue = this.endValue, - interp = this.interpolation, - deltaTime = this.length; - - if (lastKey !== null) { - interp = lastKey.interpolation; - time -= lastKey.time; - } - - switch (interp) { - case Tw2Vector3Curve.Interpolation.LINEAR: - if (lastKey && nextKey) { - startValue = lastKey.value; - endValue = nextKey.value; - deltaTime = nextKey.time - lastKey.time; - } else if (nextKey) { - endValue = nextKey.value; - deltaTime = nextKey.time; - } else if (lastKey) { - startValue = lastKey.value; - deltaTime = this.length - lastKey.time; - } - - value[0] = startValue[0] + (endValue[0] - startValue[0]) * (time / deltaTime); - value[1] = startValue[1] + (endValue[1] - startValue[1]) * (time / deltaTime); - value[2] = startValue[2] + (endValue[2] - startValue[2]) * (time / deltaTime); - return value; - - case Tw2Vector3Curve.Interpolation.HERMITE: - var inTangent = this.startTangent, - outTangent = this.endTangent; - - if (lastKey && nextKey) { - startValue = lastKey.value; - inTangent = lastKey.rightTangent; - endValue = nextKey.value; - outTangent = nextKey.leftTangent; - deltaTime = nextKey.time - lastKey.time; - } else if (nextKey) { - endValue = nextKey.value; - outTangent = nextKey.leftTangent; - deltaTime = nextKey.time; - } else if (lastKey) { - startValue = lastKey.value; - inTangent = lastKey.rightTangent; - deltaTime = this.length - lastKey.time; - } - - var s = time / deltaTime, - s2 = s * s, - s3 = s2 * s; + return Tw2TransformTrack; +}(); - var c2 = -2.0 * s3 + 3.0 * s2, - c1 = 1.0 - c2, - c4 = s3 - s2, - c3 = s + c4 - s2; +/***/ }), +/* 154 */ +/***/ (function(module, exports, __webpack_require__) { - value[0] = startValue[0] * c1 + endValue[0] * c2 + inTangent[0] * c3 + outTangent[0] * c4; - value[1] = startValue[1] * c1 + endValue[1] * c2 + inTangent[1] * c3 + outTangent[1] * c4; - value[2] = startValue[2] * c1 + endValue[2] * c2 + inTangent[2] * c3 + outTangent[2] * c4; - return value; +"use strict"; - default: - return value; - } - } - }]); - return Tw2Vector3Curve; -}(_Tw2Curve2.Tw2Curve); +Object.defineProperty(exports, "__esModule", { + value: true +}); -/** - * The curve's key dimension - * @type {number} - */ +var _Tw2MayaEulerRotationCurve = __webpack_require__(155); +Object.keys(_Tw2MayaEulerRotationCurve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2MayaEulerRotationCurve[key]; + } + }); +}); -Tw2Vector3Curve.inputDimension = 3; +var _Tw2MayaScalarCurve = __webpack_require__(156); -/** - * The curve's dimension - * @type {number} - */ -Tw2Vector3Curve.outputDimension = 3; +Object.keys(_Tw2MayaScalarCurve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2MayaScalarCurve[key]; + } + }); +}); -/** - * The curve's current value property - * @type {string} - */ -Tw2Vector3Curve.valueProperty = 'currentValue'; +var _Tw2MayaVector3Curve = __webpack_require__(157); -/** - * The curve's type - * @type {number} - */ -Tw2Vector3Curve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE2; +Object.keys(_Tw2MayaVector3Curve).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2MayaVector3Curve[key]; + } + }); +}); -/** - * The curve's key constructor - * @type {Tw2Vector3Key} - */ -Tw2Vector3Curve.Key = Tw2Vector3Key; +var _Tw2MayaAnimationEngine = __webpack_require__(158); -/** - * Interpolation types - * @type {{CONSTANT: number, LINEAR: number, HERMITE: number}} - */ -Tw2Vector3Curve.Interpolation = { - CONSTANT: 0, - LINEAR: 1, - HERMITE: 2 -}; +Object.keys(_Tw2MayaAnimationEngine).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2MayaAnimationEngine[key]; + } + }); +}); /***/ }), -/* 154 */ +/* 155 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -30849,13 +31109,13 @@ Tw2Vector3Curve.Interpolation = { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2VectorCurve = exports.Tw2VectorKey = undefined; +exports.Tw2MayaEulerRotationCurve = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); -var _Tw2Curve2 = __webpack_require__(3); +var _curves = __webpack_require__(13); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -30864,73 +31124,47 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2VectorKey - * - * @property {vec3} value - * @property {vec3} left - * @property {vec3} right - * @property {number} interpolation - * @inherits Tw2CurveKey - * @class - */ -var Tw2VectorKey = exports.Tw2VectorKey = function (_Tw2CurveKey) { - _inherits(Tw2VectorKey, _Tw2CurveKey); - - function Tw2VectorKey() { - _classCallCheck(this, Tw2VectorKey); - - var _this = _possibleConstructorReturn(this, (Tw2VectorKey.__proto__ || Object.getPrototypeOf(Tw2VectorKey)).call(this)); - - _this.value = _math.vec3.create(); - _this.left = _math.vec3.create(); - _this.right = _math.vec3.create(); - _this.interpolation = 0; - return _this; - } - - return Tw2VectorKey; -}(_Tw2Curve2.Tw2CurveKey); - -/** - * Tw2Vector3Curve + * Tw2MayaEulerRotationCurve * + * @property {number} xIndex + * @property {number} yIndex + * @property {number} zIndex + * @property {?Tw2MayaAnimationEngine} animationEngine * @property {string} name - * @property {number} start - * @property {vec3} value - * @property {number} extrapolation - * @property {Array.} keys - * @property {number} _currentKey + * @property {vec3} eulerValue + * @property {boolean} updateQuaternion + * @property {quat} quatValue * @property {number} length * @class */ +var Tw2MayaEulerRotationCurve = exports.Tw2MayaEulerRotationCurve = function (_Tw2Curve) { + _inherits(Tw2MayaEulerRotationCurve, _Tw2Curve); + function Tw2MayaEulerRotationCurve() { + _classCallCheck(this, Tw2MayaEulerRotationCurve); -var Tw2VectorCurve = exports.Tw2VectorCurve = function (_Tw2Curve) { - _inherits(Tw2VectorCurve, _Tw2Curve); - - function Tw2VectorCurve() { - _classCallCheck(this, Tw2VectorCurve); - - var _this2 = _possibleConstructorReturn(this, (Tw2VectorCurve.__proto__ || Object.getPrototypeOf(Tw2VectorCurve)).call(this)); + var _this = _possibleConstructorReturn(this, (Tw2MayaEulerRotationCurve.__proto__ || Object.getPrototypeOf(Tw2MayaEulerRotationCurve)).call(this)); - _this2.start = 0; - _this2.value = _math.vec3.create(); - _this2.extrapolation = 0; - _this2.keys = []; - _this2._currentKey = 1; - _this2.length = 0; - return _this2; + _this.xIndex = -1; + _this.yIndex = -1; + _this.zIndex = -1; + _this.animationEngine = null; + _this.eulerValue = _global.vec3.create(); + _this.updateQuaternion = false; + _this.quatValue = _global.quat.create(); + _this.length = 0; + return _this; } /** - * Sorts the curve's keys + * Sorts the curve */ - _createClass(Tw2VectorCurve, [{ + _createClass(Tw2MayaEulerRotationCurve, [{ key: 'Sort', value: function Sort() { - _Tw2Curve2.Tw2Curve.Sort(this); + this.ComputeLength(); } /** @@ -30945,261 +31179,96 @@ var Tw2VectorCurve = exports.Tw2VectorCurve = function (_Tw2Curve) { } /** - * Updates the current value at the given time + * Updates a value at a specific time * @param {number} time */ }, { key: 'UpdateValue', - value: function UpdateValue(time) { - this.GetValueAt(time, this.value); - } - - /** - * Gets a value at a specific time - * @param {number} time - * @param {vec3} value - * @returns {vec3} - */ - - }, { - key: 'GetValueAt', - value: function GetValueAt(time, value) { - if (this.length === 0) { - return _math.vec3.copy(value, this.value); - } - - var firstKey = this.keys[0], - lastKey = this.keys[this.keys.length - 1]; - - if (time >= lastKey.time) { - switch (this.extrapolation) { - case Tw2VectorCurve.Extrapolation.NONE: - return _math.vec3.copy(value, this.value); - - case Tw2VectorCurve.Extrapolation.CONSTANT: - return _math.vec3.copy(value, lastKey.value); - - case Tw2VectorCurve.Extrapolation.GRADIENT: - return _math.vec3.scaleAndAdd(value, lastKey.value, lastKey.right, time - lastKey.time); - - default: - time = time % lastKey.time; - } - } else if (time < 0 || time < firstKey.time) { - switch (this.extrapolation) { - case Tw2VectorCurve.Extrapolation.NONE: - return _math.vec3.copy(value, this.value); - - case Tw2VectorCurve.Extrapolation.GRADIENT: - return _math.vec3.scaleAndAdd(value, firstKey.value, firstKey.left, time * this.length - lastKey.time); - - default: - return _math.vec3.copy(value, firstKey.value); - } - } - - var ck = this.keys[this._currentKey], - ck_1 = this.keys[this._currentKey - 1]; - - while (time >= ck.time || time < ck_1.time) { - if (time < ck_1.time) this._currentKey = 0; - this._currentKey++; - ck = this.keys[this._currentKey]; - ck_1 = this.keys[this._currentKey - 1]; - } - - var nt = (time - ck_1.time) / (ck.time - ck_1.time); - switch (ck_1.interpolation) { - case Tw2VectorCurve.Interpolation.CONSTANT: - return _math.vec3.copy(value, ck_1.value); - - case Tw2VectorCurve.Interpolation.LINEAR: - value[0] = ck_1.value[0] * (1 - nt) + ck.value[0] * nt; - value[1] = ck_1.value[1] * (1 - nt) + ck.value[1] * nt; - value[2] = ck_1.value[2] * (1 - nt) + ck.value[2] * nt; - return value; - - case Tw2VectorCurve.Interpolation.HERMITE: - var k3 = 2 * nt * nt * nt - 3 * nt * nt + 1, - k2 = -2 * nt * nt * nt + 3 * nt * nt, - k1 = nt * nt * nt - 2 * nt * nt + nt, - k0 = nt * nt * nt - nt * nt; - - value[0] = k3 * ck_1.value[0] + k2 * ck.value[0] + k1 * ck_1.right[0] + k0 * ck.left[0]; - value[1] = k3 * ck_1.value[1] + k2 * ck.value[1] + k1 * ck_1.right[1] + k0 * ck.left[1]; - value[2] = k3 * ck_1.value[2] + k2 * ck.value[2] + k1 * ck_1.right[2] + k0 * ck.left[2]; - return value; - - default: - return value; - } - } - }]); - - return Tw2VectorCurve; -}(_Tw2Curve2.Tw2Curve); - -/** - * The curve's key dimension - * @type {number} - */ - - -Tw2VectorCurve.inputDimension = 3; - -/** - * The curve's dimension - * @type {number} - */ -Tw2VectorCurve.outputDimension = 3; - -/** - * The curve's current value property - * @type {string} - */ -Tw2VectorCurve.valueProperty = 'value'; - -/** - * The curve's type - * @type {number} - */ -Tw2VectorCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE; - -/** - * The curve's key constructor - * @type {Tw2VectorKey} - */ -Tw2VectorCurve.Key = Tw2VectorKey; - -/** - * Extrapolation types - * @type {{NONE: number, CONSTANT: number, GRADIENT: number, CYCLE: number}} - */ -Tw2VectorCurve.Extrapolation = { - NONE: 0, - CONSTANT: 1, - GRADIENT: 2, - CYCLE: 3 -}; - -/** - * Interpolation types - * @type {{NONE: number, CONSTANT: number, LINEAR: number, HERMITE: number}} - */ -Tw2VectorCurve.Interpolation = { - NONE: 0, - CONSTANT: 1, - LINEAR: 2, - HERMITE: 3 -}; - -/***/ }), -/* 155 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _Tw2ColorSequencer = __webpack_require__(156); - -Object.keys(_Tw2ColorSequencer).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2ColorSequencer[key]; - } - }); -}); + value: function UpdateValue(time) { + if (this.animationEngine) { + if (this.xIndex) { + this.eulerValue[0] = this.animationEngine.Evaluate(this.xIndex, time); + } -var _Tw2EulerRotation = __webpack_require__(157); + if (this.yIndex) { + if (this.yIndex === this.xIndex) { + this.eulerValue[1] = this.eulerValue[0]; + } else { + this.eulerValue[1] = this.animationEngine.Evaluate(this.yIndex, time); + } + } -Object.keys(_Tw2EulerRotation).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2EulerRotation[key]; - } - }); -}); + if (this.zIndex) { + if (this.zIndex === this.xIndex) { + this.eulerValue[2] = this.eulerValue[0]; + } else { + this.eulerValue[2] = this.animationEngine.Evaluate(this.zIndex, time); + } + } -var _Tw2QuaternionSequencer = __webpack_require__(158); + if (this.updateQuaternion) { + var sinYaw = Math.sin(this.eulerValue[0] / 2), + cosYaw = Math.cos(this.eulerValue[0] / 2), + sinPitch = Math.sin(this.eulerValue[1] / 2), + cosPitch = Math.cos(this.eulerValue[1] / 2), + sinRoll = Math.sin(this.eulerValue[2] / 2), + cosRoll = Math.cos(this.eulerValue[2] / 2); -Object.keys(_Tw2QuaternionSequencer).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2QuaternionSequencer[key]; - } - }); -}); + this.quatValue[0] = sinYaw * cosPitch * sinRoll + cosYaw * sinPitch * cosRoll; + this.quatValue[1] = sinYaw * cosPitch * cosRoll - cosYaw * sinPitch * sinRoll; + this.quatValue[2] = cosYaw * cosPitch * sinRoll - sinYaw * sinPitch * cosRoll; + this.quatValue[3] = cosYaw * cosPitch * cosRoll + sinYaw * sinPitch * sinRoll; + } + } + } -var _Tw2RGBAScalarSequencer = __webpack_require__(159); + /** + * Computes curve Length + */ -Object.keys(_Tw2RGBAScalarSequencer).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2RGBAScalarSequencer[key]; - } - }); -}); + }, { + key: 'ComputeLength', + value: function ComputeLength() { + if (!this.animationEngine || this.animationEngine.GetNumberOfCurves() === 0) return; -var _Tw2ScalarSequencer = __webpack_require__(160); + this.length = 0; + if (this.xIndex >= 0) { + this.length = this.animationEngine.GetLength(this.xIndex); + } -Object.keys(_Tw2ScalarSequencer).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2ScalarSequencer[key]; - } - }); -}); + if (this.yIndex >= 0) { + this.length = Math.max(this.length, this.animationEngine.GetLength(this.yIndex)); + } -var _Tw2VectorSequencer = __webpack_require__(161); + if (this.zIndex >= 0) { + this.length = Math.max(this.length, this.animationEngine.GetLength(this.zIndex)); + } + } + }]); -Object.keys(_Tw2VectorSequencer).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2VectorSequencer[key]; - } - }); -}); + return Tw2MayaEulerRotationCurve; +}(_curves.Tw2Curve); -var _Tw2XYZScalarSequencer = __webpack_require__(162); +/** + * The curve's dimension + * @type {number} + */ -Object.keys(_Tw2XYZScalarSequencer).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2XYZScalarSequencer[key]; - } - }); -}); -var _Tw2YPRSequencer = __webpack_require__(163); +Tw2MayaEulerRotationCurve.outputDimension = 3; -Object.keys(_Tw2YPRSequencer).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2YPRSequencer[key]; - } - }); -}); +/** + * The curve's current value property + * @type {string} + */ +Tw2MayaEulerRotationCurve.valueProperty = 'eulerValue'; + +/** + * The curve's type + * @type {number} + */ +Tw2MayaEulerRotationCurve.curveType = _curves.Tw2Curve.Type.CURVE_MAYA; /***/ }), /* 156 */ @@ -31211,13 +31280,11 @@ Object.keys(_Tw2YPRSequencer).forEach(function (key) { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2ColorSequencer = undefined; +exports.Tw2MayaScalarCurve = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); - -var _Tw2CurveSequencer2 = __webpack_require__(8); +var _curves = __webpack_require__(13); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -31226,55 +31293,49 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2ColorSequencer + * Tw2MayaScalarCurve * - * @property {number} start - * @property {vec4} value - * @property {number} operator - * @property {Array} functions + * @property {number} index + * @property {null|Tw2MayaAnimationEngine} animationEngine + * @property {number} value + * @property {number} length * @class */ -var Tw2ColorSequencer = exports.Tw2ColorSequencer = function (_Tw2CurveSequencer) { - _inherits(Tw2ColorSequencer, _Tw2CurveSequencer); +var Tw2MayaScalarCurve = exports.Tw2MayaScalarCurve = function (_Tw2Curve) { + _inherits(Tw2MayaScalarCurve, _Tw2Curve); - function Tw2ColorSequencer() { - _classCallCheck(this, Tw2ColorSequencer); + function Tw2MayaScalarCurve() { + _classCallCheck(this, Tw2MayaScalarCurve); - var _this = _possibleConstructorReturn(this, (Tw2ColorSequencer.__proto__ || Object.getPrototypeOf(Tw2ColorSequencer)).call(this)); + var _this = _possibleConstructorReturn(this, (Tw2MayaScalarCurve.__proto__ || Object.getPrototypeOf(Tw2MayaScalarCurve)).call(this)); - _this.start = 0; - _this.value = _math.vec4.create(); - _this.operator = 0; - _this.functions = []; + _this.index = -1; + _this.animationEngine = null; + _this.value = 0; + _this.length = 0; return _this; } /** - * Sorts the sequencer + * Sorts the curve */ - _createClass(Tw2ColorSequencer, [{ + _createClass(Tw2MayaScalarCurve, [{ key: 'Sort', value: function Sort() { - _Tw2CurveSequencer2.Tw2CurveSequencer.Sort(this); + this.ComputeLength(); } /** - * Gets sequencer length + * Gets the curve's length * @returns {number} */ }, { key: 'GetLength', value: function GetLength() { - var len = 0; - for (var i = 0; i < this.functions.length; ++i) { - if ('GetLength' in this.functions[i]) { - len = Math.max(len, this.functions[i].GetLength()); - } - } - return len; + return this.length; } /** @@ -31285,84 +31346,45 @@ var Tw2ColorSequencer = exports.Tw2ColorSequencer = function (_Tw2CurveSequencer }, { key: 'UpdateValue', value: function UpdateValue(time) { - this.GetValueAt(time, this.value); + if (this.animationEngine) { + this.value = this.animationEngine.Evaluate(this.index, time); + } } /** - * Gets a value at a specific time - * @param {number} time - * @param {vec4} value - * @returns {vec4} + * Computes curve Length */ }, { - key: 'GetValueAt', - value: function GetValueAt(time, value) { - var vec4_0 = _Tw2CurveSequencer2.Tw2CurveSequencer.global.vec4_0; - - switch (this.operator) { - case Tw2ColorSequencer.Operator.MULTIPLY: - _math.vec4.set(value, 1, 1, 1, 1); - for (var i = 0; i < this.functions.length; ++i) { - this.functions[i].GetValueAt(time, vec4_0); - _math.vec4.multiply(value, value, vec4_0); - } - return value; - - default: - _math.vec4.set(value, 0, 0, 0, 0); - for (var _i = 0; _i < this.functions.length; ++_i) { - this.functions[_i].GetValueAt(time, vec4_0); - _math.vec4.add(value, value, vec4_0); - } - return value; - } + key: 'ComputeLength', + value: function ComputeLength() { + if (!this.animationEngine || this.animationEngine.GetNumberOfCurves() === 0) return; + if (this.index >= 0) this.length = this.animationEngine.GetLength(this.index); } }]); - return Tw2ColorSequencer; -}(_Tw2CurveSequencer2.Tw2CurveSequencer); + return Tw2MayaScalarCurve; +}(_curves.Tw2Curve); /** - * The sequencer's curve dimension + * The curve's dimension * @type {number} */ -Tw2ColorSequencer.inputDimension = 4; - -/** - * The sequencer's dimension - * @type {number} - */ -Tw2ColorSequencer.outputDimension = 4; +Tw2MayaScalarCurve.outputDimension = 1; /** - * The sequencer's current value property + * The curve's current value property * @type {string} */ -Tw2ColorSequencer.valueProperty = 'value'; +Tw2MayaScalarCurve.valueProperty = 'value'; /** - * The sequencer's type + * The curve's type * @type {number} */ -Tw2ColorSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCER; - -/** - * The sequencer's curve array - * @type {string} - */ -Tw2ColorSequencer.childArray = 'functions'; - -/** - * Operators - * @type {{MULTIPLY: number, ADD: number}} - */ -Tw2ColorSequencer.Operator = { - MULTIPLY: 0, - ADD: 1 -}; +Tw2MayaScalarCurve.curveType = _curves.Tw2Curve.Type.CURVE_MAYA; /***/ }), /* 157 */ @@ -31374,13 +31396,13 @@ Tw2ColorSequencer.Operator = { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2EulerRotation = undefined; +exports.Tw2MayaVector3Curve = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); -var _Tw2CurveSequencer2 = __webpack_require__(8); +var _curves = __webpack_require__(13); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -31389,131 +31411,132 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2EulerRotation + * Tw2MayaVector3Curve * + * @property {number} xIndex + * @property {number} yIndex + * @property {number} zIndex + * @property {null|Tw2MayaAnimationEngine} animationEngine * @property {string} name - * @property {Tw2Curve} [yawCurve] - * @property {Tw2Curve} [pitchCurve] - * @property {Tw2Curve} [rollCurve] - * @property {quat} currentValue=[0,0,0,1] - * @class + * @property {vec3} value + * @property {number} length */ -var Tw2EulerRotation = exports.Tw2EulerRotation = function (_Tw2CurveSequencer) { - _inherits(Tw2EulerRotation, _Tw2CurveSequencer); +var Tw2MayaVector3Curve = exports.Tw2MayaVector3Curve = function (_Tw2Curve) { + _inherits(Tw2MayaVector3Curve, _Tw2Curve); - function Tw2EulerRotation() { - _classCallCheck(this, Tw2EulerRotation); + function Tw2MayaVector3Curve() { + _classCallCheck(this, Tw2MayaVector3Curve); - var _this = _possibleConstructorReturn(this, (Tw2EulerRotation.__proto__ || Object.getPrototypeOf(Tw2EulerRotation)).call(this)); + var _this = _possibleConstructorReturn(this, (Tw2MayaVector3Curve.__proto__ || Object.getPrototypeOf(Tw2MayaVector3Curve)).call(this)); - _this.yawCurve = null; - _this.pitchCurve = null; - _this.rollCurve = null; - _this.currentValue = _math.quat.create(); + _this.xIndex = -1; + _this.yIndex = -1; + _this.zIndex = -1; + _this.animationEngine = null; + _this.value = _global.vec3.create(); + _this.length = 0; return _this; } /** - * Sorts the sequencer + * Sorts the curve's keys */ - _createClass(Tw2EulerRotation, [{ + _createClass(Tw2MayaVector3Curve, [{ key: 'Sort', value: function Sort() { - _Tw2CurveSequencer2.Tw2CurveSequencer.Sort2(this); + this.ComputeLength(); } /** - * Gets sequencer length + * Gets the curve's length * @returns {number} */ }, { key: 'GetLength', value: function GetLength() { - var len = 0; - if (this.yawCurve && 'GetLength' in this.yawCurve) len = this.yawCurve.GetLength(); - if (this.pitchCurve && 'GetLength' in this.pitchCurve) len = Math.max(len, this.pitchCurve.GetLength()); - if (this.rollCurve && 'GetLength' in this.rollCurve) len = Math.max(len, this.rollCurve.GetLength()); - return len; + return this.length; } /** - * Updates the current value at a specific time + * Updates a value at a specific time * @param {number} time */ }, { key: 'UpdateValue', value: function UpdateValue(time) { - this.GetValueAt(time, this.currentValue); + if (this.animationEngine) { + if (this.xIndex) { + this.value[0] = this.animationEngine.Evaluate(this.xIndex, time); + } + + if (this.yIndex) { + if (this.yIndex === this.xIndex) { + this.value[1] = this.value[0]; + } else { + this.value[1] = this.animationEngine.Evaluate(this.yIndex, time); + } + } + + if (this.zIndex) { + if (this.zIndex === this.xIndex) { + this.value[2] = this.value[0]; + } else { + this.value[2] = this.animationEngine.Evaluate(this.zIndex, time); + } + } + } } /** - * Gets a value at a specific time - * @param {number} time - * @param {quat} value - * @returns {quat} + * Computes curve Length */ }, { - key: 'GetValueAt', - value: function GetValueAt(time, value) { - var yaw = this.yawCurve ? this.yawCurve.GetValueAt(time) : 0.0, - pitch = this.pitchCurve ? this.pitchCurve.GetValueAt(time) : 0.0, - roll = this.rollCurve ? this.rollCurve.GetValueAt(time) : 0.0; + key: 'ComputeLength', + value: function ComputeLength() { + if (!this.animationEngine || this.animationEngine.GetNumberOfCurves() === 0) return; - var sinYaw = Math.sin(yaw / 2.0), - cosYaw = Math.cos(yaw / 2.0), - sinPitch = Math.sin(pitch / 2.0), - cosPitch = Math.cos(pitch / 2.0), - sinRoll = Math.sin(roll / 2.0), - cosRoll = Math.cos(roll / 2.0); + this.length = 0; + if (this.xIndex >= 0) { + this.length = this.animationEngine.GetLength(this.xIndex); + } - value[0] = sinYaw * cosPitch * sinRoll + cosYaw * sinPitch * cosRoll; - value[1] = sinYaw * cosPitch * cosRoll - cosYaw * sinPitch * sinRoll; - value[2] = cosYaw * cosPitch * sinRoll - sinYaw * sinPitch * cosRoll; - value[3] = cosYaw * cosPitch * cosRoll + sinYaw * sinPitch * sinRoll; + if (this.yIndex >= 0) { + this.length = Math.max(this.length, this.animationEngine.GetLength(this.yIndex)); + } - return value; + if (this.zIndex >= 0) { + this.length = Math.max(this.length, this.animationEngine.GetLength(this.zIndex)); + } } }]); - return Tw2EulerRotation; -}(_Tw2CurveSequencer2.Tw2CurveSequencer); + return Tw2MayaVector3Curve; +}(_curves.Tw2Curve); /** - * The sequencer's curve dimension + * The curve's dimension * @type {number} */ -Tw2EulerRotation.inputDimension = 1; - -/** - * The sequencer's dimension - * @type {number} - */ -Tw2EulerRotation.outputDimension = 3; +Tw2MayaVector3Curve.outputDimension = 3; /** - * The sequencer's current value property + * The curve's current value property * @type {string} */ -Tw2EulerRotation.valueProperty = 'currentValue'; +Tw2MayaVector3Curve.valueProperty = 'value'; /** - * The sequencer's type + * The curve's type * @type {number} */ -Tw2EulerRotation.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCER2; - -/** - * The sequencer's curve property names - * @type {string[]} - */ -Tw2EulerRotation.childProperties = ['yawCurve', 'pitchCurve', 'rollCurve']; +Tw2MayaVector3Curve.curveType = _curves.Tw2Curve.Type.CURVE_MAYA; /***/ }), /* 158 */ @@ -31522,139 +31545,375 @@ Tw2EulerRotation.childProperties = ['yawCurve', 'pitchCurve', 'rollCurve']; "use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2QuaternionSequencer = undefined; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2MayaAnimationEngine = undefined; + +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _global = __webpack_require__(0); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * Tw2MayaAnimationEngine + * TODO: Complete the prototype `_EvaluteBezier` + * + * @property {number|string} id + * @property {Array} curves + * @property {Array} hermiteSegments + * @property {Array} bezierSegments + * @property {number} _currentCurveIndex + * @property _evalCache + */ +var Tw2MayaAnimationEngine = exports.Tw2MayaAnimationEngine = function () { + function Tw2MayaAnimationEngine() { + _classCallCheck(this, Tw2MayaAnimationEngine); + + this._id = _global.util.generateID(); + this.curves = []; + this.hermiteSegments = []; + this.bezierSegments = []; + this._currentCurveIndex = 0; + this._evalCache = null; + } + + /** + * Evaluate + * @param curveIndex + * @param time + * @returns {*} + */ + + + _createClass(Tw2MayaAnimationEngine, [{ + key: 'Evaluate', + value: function Evaluate(curveIndex, time) { + if (this.curves.length <= curveIndex) return 0; + + this._currentCurveIndex = curveIndex; + if (!this._evalCache) { + this._evalCache = new Array(this.curves.length); + for (var i = 0; i < this._evalCache.length; ++i) { + this._evalCache[i] = -1; + } + } + + var animCurve = this.curves[curveIndex]; + var firstSegment = animCurve[Tw2MayaAnimationEngine.AnimCurveFields.SEGMENT_OFFSET]; + var segments = null; + + if (animCurve[Tw2MayaAnimationEngine.AnimCurveFields.IS_WEIGHTED]) { + segments = this.bezierSegments; + } else { + segments = this.hermiteSegments; + } + + if (time < segments[firstSegment][Tw2MayaAnimationEngine.AnimSegment.TIME]) { + if (animCurve[Tw2MayaAnimationEngine.AnimCurveFields.PRE_INFINITY] === Tw2MayaAnimationEngine.INFINITY) { + return segments[firstSegment][Tw2MayaAnimationEngine.AnimSegment.VALUE]; + } + return this._EvaluateInfinities(animCurve, segments, firstSegment, time, true); + } + + if (time > animCurve[Tw2MayaAnimationEngine.AnimCurveFields.END_TIME]) { + if (animCurve[Tw2MayaAnimationEngine.AnimCurveFields.POST_INFINITY] === Tw2MayaAnimationEngine.INFINITY) { + return animCurve[Tw2MayaAnimationEngine.AnimCurveFields.END_VALUE]; + } + return this._EvaluateInfinities(animCurve, segments, firstSegment, time, false); + } + + return this._EvaluateImpl(animCurve, segments, firstSegment, time); + } + + /** + * _EvaluateImpl + * @param animCurve + * @param segments + * @param firstSegment + * @param time + * @returns {*} + */ + + }, { + key: '_EvaluateImpl', + value: function _EvaluateImpl(animCurve, segments, firstSegment, time) { + var withinInterval = false, + nextSegment = null, + lastSegment = null, + index = void 0; + + if (this._evalCache[this._currentCurveIndex] >= 0) { + lastSegment = firstSegment + this._evalCache[this._currentCurveIndex]; + if (this._evalCache[this._currentCurveIndex] < animCurve[Tw2MayaAnimationEngine.AnimCurveFields.NUM_SEGMENTS - 1] && time > segments[lastSegment][Tw2MayaAnimationEngine.AnimSegment.TIME]) { + nextSegment = firstSegment + this._evalCache[this._currentCurveIndex] + 1; + if (time === segments[nextSegment][Tw2MayaAnimationEngine.AnimSegment.TIME]) { + this._evalCache[this._currentCurveIndex]++; + return segments[nextSegment][Tw2MayaAnimationEngine.AnimSegment.VALUE]; + } else if (time < segments[nextSegment][Tw2MayaAnimationEngine.AnimSegment.TIME]) { + index = this._evalCache[this._currentCurveIndex] + 1; + withinInterval = true; + } else { + nextSegment = null; + } + } else if (this._evalCache[this._currentCurveIndex] > 0 && time < segments[lastSegment][Tw2MayaAnimationEngine.AnimSegment.TIME]) { + var prevSegment = firstSegment + this._evalCache[this._currentCurveIndex] - 1; + if (time > segments[prevSegment][Tw2MayaAnimationEngine.AnimSegment.TIME]) { + index = this._evalCache[this._currentCurveIndex]; + withinInterval = true; + } else if (time === segments[prevSegment][Tw2MayaAnimationEngine.AnimSegment.TIME]) { + this._evalCache[this._currentCurveIndex]--; + return segments[prevSegment][Tw2MayaAnimationEngine.AnimSegment.VALUE]; + } + } + } + + if (!withinInterval) { + var result = this._Find(animCurve, time, segments, firstSegment); + index = result[1]; + if (result[0] || index === 0) { + if (index === animCurve[Tw2MayaAnimationEngine.AnimCurveFields.NUM_SEGMENTS]) { + index--; + this._evalCache[this._currentCurveIndex] = index; + return animCurve[Tw2MayaAnimationEngine.AnimCurveFields.END_VALUE]; + } else { + this._evalCache[this._currentCurveIndex] = index; + return segments[firstSegment + index][Tw2MayaAnimationEngine.AnimSegment.VALUE]; + } + } else if (index === animCurve[Tw2MayaAnimationEngine.AnimCurveFields.NUM_SEGMENTS] + 1) { + this._evalCache[this._currentCurveIndex] = 0; + return animCurve[Tw2MayaAnimationEngine.AnimCurveFields.END_VALUE]; + } + } + + if (this._evalCache[this._currentCurveIndex] !== index - 1) { + this._evalCache[this._currentCurveIndex] = index - 1; + lastSegment = firstSegment + this._evalCache[this._currentCurveIndex]; + if (nextSegment === null) nextSegment = firstSegment + index; + } -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + if (animCurve[Tw2MayaAnimationEngine.AnimCurveFields.IS_WEIGHTED]) { + var bSegment = segments[lastSegment]; + if (bSegment[Tw2MayaAnimationEngine.BezierSegment.IS_STEP]) { + return bSegment[Tw2MayaAnimationEngine.BezierSegment.VALUE]; + } else if (bSegment[Tw2MayaAnimationEngine.BezierSegment.IS_STEP_NEXT]) { + if (nextSegment === null) { + return animCurve[Tw2MayaAnimationEngine.AnimCurveFields.END_VALUE]; + } + return segments[nextSegment][Tw2MayaAnimationEngine.BezierSegment.VALUE]; + } else { + var nextKeyTime = animCurve[Tw2MayaAnimationEngine.AnimCurveFields.END_TIME]; + if (this._evalCache[this._currentCurveIndex] + 1 < animCurve[Tw2MayaAnimationEngine.AnimCurveFields.NUM_SEGMENTS]) { + nextKeyTime = segments[nextSegment][Tw2MayaAnimationEngine.BezierSegment.TIME]; + } + return this._EvaluateBezier(bSegment, time, nextKeyTime); + } + } else { + var hSegment = segments[lastSegment]; + if (hSegment[Tw2MayaAnimationEngine.HermiteSegment.IS_STEP]) { + return hSegment[Tw2MayaAnimationEngine.HermiteSegment.VALUE]; + } else if (hSegment[Tw2MayaAnimationEngine.HermiteSegment.IS_STEP_NEXT]) { + if (nextSegment === null) { + return animCurve[Tw2MayaAnimationEngine.AnimCurveFields.END_VALUE]; + } + return segments[nextSegment][Tw2MayaAnimationEngine.HermiteSegment.VALUE]; + } else { + return this._EvaluateHermite(hSegment, time); + } + } + } -var _math = __webpack_require__(0); + /* eslint-disable no-unused-vars */ -var _Tw2CurveSequencer2 = __webpack_require__(8); + /** + * A static helper function to evaluate the infinity portion of an animation curve. + * The infinity portion is the parts of the animation curve outside the range of keys. + * @param curve - The animation curve to evaluate + * @param segments + * @param startSegment + * @param {time} time + * @param {boolean} bool - false: evaluate the post-infinity portion, true: evaluate the pre-infinity portion + */ -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + }, { + key: '_EvaluateInfinities', + value: function _EvaluateInfinities(curve, segments, startSegment, time, bool) { -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + throw new Error('_EvaluateInfinities not implemented'); + } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + /* eslint-enable no-unused-vars */ -/** - * Tw2QuaternionSequencer - * - * @property {string} name - * @property {number} start - * @property {quat} value - * @property {Array} functions - * @class - */ -var Tw2QuaternionSequencer = exports.Tw2QuaternionSequencer = function (_Tw2CurveSequencer) { - _inherits(Tw2QuaternionSequencer, _Tw2CurveSequencer); + /** + * _EvaluateHermite + * @param segment + * @param time + * @returns {*} + */ - function Tw2QuaternionSequencer() { - _classCallCheck(this, Tw2QuaternionSequencer); + }, { + key: '_EvaluateHermite', + value: function _EvaluateHermite(segment, time) { + var t = time - segment[Tw2MayaAnimationEngine.HermiteSegment.TIME]; + var coeff = segment[Tw2MayaAnimationEngine.HermiteSegment.COEFF]; + return t * (t * (t * coeff[0] + coeff[1]) + coeff[2]) + coeff[3]; + } - var _this = _possibleConstructorReturn(this, (Tw2QuaternionSequencer.__proto__ || Object.getPrototypeOf(Tw2QuaternionSequencer)).call(this)); + /** + * _EvaluateBezier + * @param segment + * @param time + * @param nextSegmentTime + * @returns {*} + */ - _this.start = 0; - _this.value = _math.quat.create(); - _this.functions = []; - return _this; - } + }, { + key: '_EvaluateBezier', + value: function _EvaluateBezier(segment, time, nextSegmentTime) { + var t = void 0, + s = void 0; - /** - * Sorts the sequencer - */ + s = (time - segment[Tw2MayaAnimationEngine.BezierSegment.TIME]) / (nextSegmentTime - segment[Tw2MayaAnimationEngine.BezierSegment.TIME]); + if (segment[Tw2MayaAnimationEngine.BezierSegment.IS_LINEAR]) { + t = s; + } else { + var _poly = _global.vec4.create(); + _poly[3] = segment[Tw2MayaAnimationEngine.BezierSegment.COEFF][3]; + _poly[2] = segment[Tw2MayaAnimationEngine.BezierSegment.COEFF][2]; + _poly[1] = segment[Tw2MayaAnimationEngine.BezierSegment.COEFF][1]; + _poly[0] = segment[Tw2MayaAnimationEngine.BezierSegment.COEFF][0] - s; + var roots = []; + if (_global.curve.polyZeroes(_poly, 3, 0.0, 1, 1.0, 1, roots) === 1) t = roots[0];else t = 0.0; + } - _createClass(Tw2QuaternionSequencer, [{ - key: 'Sort', - value: function Sort() { - _Tw2CurveSequencer2.Tw2CurveSequencer.Sort(this); + var poly = segment[Tw2MayaAnimationEngine.BezierSegment.POLYY]; + return t * (t * (t * poly[3] + poly[2]) + poly[1]) + poly[0]; } /** - * Gets sequencer length - * @returns {number} + * _Find + * @param animCurve + * @param time + * @param segments + * @param firstSegment + * @returns {*} */ }, { - key: 'GetLength', - value: function GetLength() { - var len = 0; - for (var i = 0; i < this.functions.length; ++i) { - if ('GetLength' in this.functions[i]) { - len = Math.max(len, this.functions[i].GetLength()); - } + key: '_Find', + value: function _Find(animCurve, time, segments, firstSegment) { + var len = void 0, + mid = void 0, + low = void 0, + high = void 0; + + /* use a binary search to find the key */ + var index = 0; + len = animCurve[Tw2MayaAnimationEngine.AnimCurveFields.NUM_SEGMENTS] + 1; + var segment = null; + var stime = 0.0; + + if (len > 0) { + low = 0; + high = len - 1; + do { + mid = low + high >> 1; + if (mid < len - 1) { + segment = firstSegment + mid; + stime = segments[segment][Tw2MayaAnimationEngine.AnimSegment.TIME]; + } else { + stime = animCurve[Tw2MayaAnimationEngine.AnimCurveFields.END_TIME]; + } + + if (time < stime) { + high = mid - 1; + } else if (time > stime) { + low = mid + 1; + } else { + index = mid; + return [true, index]; + } + } while (low <= high); + index = low; } - return len; + return [false, index]; } /** - * Updates a value at a specific time - * @param {number} time + * Returns the total number of curves + * @returns {number} */ }, { - key: 'UpdateValue', - value: function UpdateValue(time) { - this.GetValueAt(time, this.value); + key: 'GetNumberOfCurves', + value: function GetNumberOfCurves() { + return this.curves.length; } /** - * Gets a value at a specific time - * @param {number} time - * @param {quat} value - * @returns {quat} + * Gets specific curve's length + * @property {number} index + * @returns {number} */ }, { - key: 'GetValueAt', - value: function GetValueAt(time, value) { - _math.quat.identity(value); - var quat_0 = _Tw2CurveSequencer2.Tw2CurveSequencer.global.quat_0; - for (var i = 0; i < this.functions.length; ++i) { - this.functions[i].GetValueAt(time, quat_0); - _math.quat.multiply(value, value, quat_0); + key: 'GetLength', + value: function GetLength(index) { + if (index < 0 || index >= this.curves.length) return 0; + var curve = this.curves[index]; + var firstSegment = void 0; + + if (curve[Tw2MayaAnimationEngine.AnimCurveFields.IS_WEIGHTED]) { + firstSegment = this.bezierSegments[curve[Tw2MayaAnimationEngine.AnimCurveFields.SEGMENT_OFFSET]]; + } else { + firstSegment = this.hermiteSegments[curve[Tw2MayaAnimationEngine.AnimCurveFields.SEGMENT_OFFSET]]; } - return value; + + return curve[Tw2MayaAnimationEngine.AnimCurveFields.END_TIME] - firstSegment[Tw2MayaAnimationEngine.AnimSegment.TIME]; } }]); - return Tw2QuaternionSequencer; -}(_Tw2CurveSequencer2.Tw2CurveSequencer); - -/** - * The sequencer's curve dimension - * @type {number} - */ - + return Tw2MayaAnimationEngine; +}(); -Tw2QuaternionSequencer.inputDimension = 4; +Tw2MayaAnimationEngine.AnimCurveFields = { + NUM_SEGMENTS: 0, + SEGMENT_OFFSET: 1, + END_TIME: 2, + END_VALUE: 3, + IN_TANGENT: 4, + OUT_TANGENT: 5, + PRE_INFINITY: 6, + POST_INFINITY: 7, + IS_WEIGHTED: 8 +}; -/** - * The sequencer's dimension - * @type {number} - */ -Tw2QuaternionSequencer.outputDimension = 4; +Tw2MayaAnimationEngine.AnimSegment = { + TIME: 0, + VALUE: 1 +}; -/** - * The sequencer's current value property - * @type {string} - */ -Tw2QuaternionSequencer.valueProperty = 'value'; +Tw2MayaAnimationEngine.HermiteSegment = { + TIME: 0, + VALUE: 1, + COEFF: 2, + IS_STEP: 3, + IS_STEP_NEXT: 4 +}; -/** - * The sequencer's type - * @type {number} - */ -Tw2QuaternionSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCER; +Tw2MayaAnimationEngine.BezierSegment = { + TIME: 0, + VALUE: 1, + COEFF: 2, + POLYY: 3, + IS_STEP: 4, + IS_STEP_NEXT: 5, + IS_LINEAR: 6 +}; -/** - * The sequencer's curve array - * @type {string} - */ -Tw2QuaternionSequencer.childArray = 'functions'; +Tw2MayaAnimationEngine.INFINITY = 0; /***/ }), /* 159 */ @@ -31666,136 +31925,78 @@ Tw2QuaternionSequencer.childArray = 'functions'; Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2RGBAScalarSequencer = undefined; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _math = __webpack_require__(0); - -var _Tw2CurveSequencer2 = __webpack_require__(8); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * Tw2RGBAScalarSequencer - * - * @property {vec4} value - * @property {Tw2Curve} RedCurve - * @property {Tw2Curve} GreenCurve - * @property {Tw2Curve} BlueCurve - * @property {Tw2Curve} AlphaCurve - * @class - */ -var Tw2RGBAScalarSequencer = exports.Tw2RGBAScalarSequencer = function (_Tw2CurveSequencer) { - _inherits(Tw2RGBAScalarSequencer, _Tw2CurveSequencer); - - function Tw2RGBAScalarSequencer() { - _classCallCheck(this, Tw2RGBAScalarSequencer); - - var _this = _possibleConstructorReturn(this, (Tw2RGBAScalarSequencer.__proto__ || Object.getPrototypeOf(Tw2RGBAScalarSequencer)).call(this)); - - _this.value = _math.vec4.create(); - _this.RedCurve = null; - _this.GreenCurve = null; - _this.BlueCurve = null; - _this.AlphaCurve = null; - return _this; - } - - /** - * Sorts the sequencer - */ +var _child = __webpack_require__(59); - _createClass(Tw2RGBAScalarSequencer, [{ - key: 'Sort', - value: function Sort() { - _Tw2CurveSequencer2.Tw2CurveSequencer.Sort2(this); +Object.keys(_child).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _child[key]; } + }); +}); - /** - * Gets sequencer length - * @returns {number} - */ +var _effect = __webpack_require__(165); - }, { - key: 'GetLength', - value: function GetLength() { - var len = 0; - if (this.RedCurve && 'GetLength' in this.RedCurve) len = this.RedCurve.GetLength(); - if (this.GreenCurve && 'GetLength' in this.GreenCurve) len = Math.max(len, this.GreenCurve.GetLength()); - if (this.BlueCurve && 'GetLength' in this.BlueCurve) len = Math.max(len, this.BlueCurve.GetLength()); - if (this.AlphaCurve && 'GetLength' in this.AlphaCurve) len = Math.max(len, this.AlphaCurve.GetLength()); - return len; +Object.keys(_effect).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _effect[key]; } + }); +}); - /** - * Updates the current value at a specific time - * @param {number} time - */ +var _object = __webpack_require__(61); - }, { - key: 'UpdateValue', - value: function UpdateValue(time) { - this.GetValueAt(time, this.value); +Object.keys(_object).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _object[key]; } + }); +}); - /** - * Gets a value at a specific time - * @param {number} time - * @param {vec4} value - * @returns {vec4} - */ +var _item = __webpack_require__(64); - }, { - key: 'GetValueAt', - value: function GetValueAt(time, value) { - value[0] = this.RedCurve ? this.RedCurve.GetValueAt(time) : 0; - value[1] = this.GreenCurve ? this.GreenCurve.GetValueAt(time) : 0; - value[2] = this.BlueCurve ? this.BlueCurve.GetValueAt(time) : 0; - value[3] = this.AlphaCurve ? this.AlphaCurve.GetValueAt(time) : 0; - return value; +Object.keys(_item).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _item[key]; } - }]); - - return Tw2RGBAScalarSequencer; -}(_Tw2CurveSequencer2.Tw2CurveSequencer); - -/** - * The sequencer's curve dimension - * @type {number} - */ - - -Tw2RGBAScalarSequencer.inputDimension = 1; + }); +}); -/** - * The sequencer's dimension - * @type {number} - */ -Tw2RGBAScalarSequencer.outputDimension = 4; +var _EveSpaceScene = __webpack_require__(183); -/** - * The sequencer's current value property - * @type {string} - */ -Tw2RGBAScalarSequencer.valueProperty = 'value'; +Object.keys(_EveSpaceScene).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _EveSpaceScene[key]; + } + }); +}); -/** - * The sequencer's type - * @type {number} - */ -Tw2RGBAScalarSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCER2; +var _EveSOF = __webpack_require__(184); -/** - * The sequencer's curve property names - * @type {string[]} - */ -Tw2RGBAScalarSequencer.childProperties = ['RedCurve', 'GreenCurve', 'BlueCurve', 'AlphaCurve']; +Object.keys(_EveSOF).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _EveSOF[key]; + } + }); +}); /***/ }), /* 160 */ @@ -31807,11 +32008,17 @@ Tw2RGBAScalarSequencer.childProperties = ['RedCurve', 'GreenCurve', 'BlueCurve', Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2ScalarSequencer = undefined; +exports.EveChildBillboard = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _Tw2CurveSequencer2 = __webpack_require__(8); +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + +var _global = __webpack_require__(0); + +var _core = __webpack_require__(1); + +var _EveChild2 = __webpack_require__(10); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -31820,164 +32027,92 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2ScalarSequencer + * Mesh attachment to space object and oriented towards the camera * - * @property {string} name - * @property {number} value - * @property {number} operator - * @property {Array} functions - * @property {number} inMinClamp - * @property {number} inMaxClamp - * @property {number} outMinClamp - * @property {number} outMaxClamp - * @property {boolean} clamping + * @property {Tw2Mesh|Tw2InstancedMesh} mesh + * @property {Tw2BasicPerObjectData} _perObjectData * @class */ -var Tw2ScalarSequencer = exports.Tw2ScalarSequencer = function (_Tw2CurveSequencer) { - _inherits(Tw2ScalarSequencer, _Tw2CurveSequencer); +var EveChildBillboard = exports.EveChildBillboard = function (_EveChild) { + _inherits(EveChildBillboard, _EveChild); - function Tw2ScalarSequencer() { - _classCallCheck(this, Tw2ScalarSequencer); + function EveChildBillboard() { + _classCallCheck(this, EveChildBillboard); - var _this = _possibleConstructorReturn(this, (Tw2ScalarSequencer.__proto__ || Object.getPrototypeOf(Tw2ScalarSequencer)).call(this)); + var _this = _possibleConstructorReturn(this, (EveChildBillboard.__proto__ || Object.getPrototypeOf(EveChildBillboard)).call(this)); - _this.value = 0; - _this.operator = 0; - _this.functions = []; - _this.inMinClamp = 0; - _this.inMaxClamp = 1; - _this.outMinClamp = 0; - _this.outMaxClamp = 1; - _this.clamping = false; + _this.mesh = null; + _this._perObjectData = new _core.Tw2BasicPerObjectData(); + _this._perObjectData.perObjectFFEData = new _core.Tw2RawData(); + _this._perObjectData.perObjectFFEData.Declare('world', 16); + _this._perObjectData.perObjectFFEData.Declare('worldInverseTranspose', 16); + _this._perObjectData.perObjectFFEData.Create(); return _this; } /** - * Sorts the sequencer + * Gets the child's resources + * @param {Array} [out=[]] + * @returns {Array.} out */ - _createClass(Tw2ScalarSequencer, [{ - key: 'Sort', - value: function Sort() { - _Tw2CurveSequencer2.Tw2CurveSequencer.Sort(this); - } - - /** - * Gets sequencer length - * @returns {number} - */ - - }, { - key: 'GetLength', - value: function GetLength() { - var len = 0; - for (var i = 0; i < this.functions.length; ++i) { - if ('GetLength' in this.functions[i]) { - len = Math.max(len, this.functions[i].GetLength()); - } - } - return len; + _createClass(EveChildBillboard, [{ + key: 'GetResources', + value: function GetResources(out) { + if (this.mesh) this.mesh.GetResources(out); + return out; } /** - * Updates a value at a specific time - * - * @param {number} time + * Per frame update + * @param {number} dt + * @param {mat4} parentTransform */ }, { - key: 'UpdateValue', - value: function UpdateValue(time) { - this.value = this.GetValueAt(time); + key: 'Update', + value: function Update(dt, parentTransform) { + _get(EveChildBillboard.prototype.__proto__ || Object.getPrototypeOf(EveChildBillboard.prototype), 'Update', this).call(this, dt, parentTransform); + + var viewInverse = _EveChild2.EveChild.global.mat4_0, + finalScale = _EveChild2.EveChild.global.vec3_0; + + _global.mat4.lookAt(viewInverse, _global.device.eyePosition, this.worldTransform.subarray(12), [0, 1, 0]); + _global.mat4.transpose(viewInverse, viewInverse); + _global.mat4.getScaling(finalScale, parentTransform); + _global.vec3.multiply(finalScale, finalScale, this.scaling); + + this.worldTransform[0] = viewInverse[0] * finalScale[0]; + this.worldTransform[1] = viewInverse[1] * finalScale[0]; + this.worldTransform[2] = viewInverse[2] * finalScale[0]; + this.worldTransform[4] = viewInverse[4] * finalScale[1]; + this.worldTransform[5] = viewInverse[5] * finalScale[1]; + this.worldTransform[6] = viewInverse[6] * finalScale[1]; + this.worldTransform[8] = viewInverse[8] * finalScale[2]; + this.worldTransform[9] = viewInverse[9] * finalScale[2]; + this.worldTransform[10] = viewInverse[10] * finalScale[2]; } /** - * Gets a value at a specific time - * - * @param {number} time - * @returns {number} + * Gets render batches + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator */ }, { - key: 'GetValueAt', - value: function GetValueAt(time) { - var value = void 0; - - switch (this.operator) { - case Tw2ScalarSequencer.Operator.MULTIPLY: - value = 1; - for (var i = 0; i < this.functions.length; ++i) { - var v = this.functions[i].GetValueAt(time); - if (this.clamping) { - v = Math.min(Math.max(v, this.inMinClamp), this.inMaxClamp); - } - value *= v; - } - break; - - default: - value = 0; - for (var _i = 0; _i < this.functions.length; ++_i) { - var _v = this.functions[_i].GetValueAt(time); - if (this.clamping) { - _v = Math.min(Math.max(_v, this.inMinClamp), this.inMaxClamp); - } - value += _v; - } - } - - if (this.clamping) { - value = Math.min(Math.max(value, this.outMinClamp), this.outMaxClamp); + key: 'GetBatches', + value: function GetBatches(mode, accumulator) { + if (this.display && this.mesh) { + _global.mat4.transpose(this._perObjectData.perObjectFFEData.Get('world'), this.worldTransform); + _global.mat4.invert(this._perObjectData.perObjectFFEData.Get('worldInverseTranspose'), this.worldTransform); + this.mesh.GetBatches(mode, accumulator, this._perObjectData); } - - return value; } }]); - return Tw2ScalarSequencer; -}(_Tw2CurveSequencer2.Tw2CurveSequencer); - -/** - * The sequencer's curve dimension - * @type {number} - */ - - -Tw2ScalarSequencer.inputDimension = 1; - -/** - * The sequencer's dimension - * @type {number} - */ -Tw2ScalarSequencer.outputDimension = 1; - -/** - * The sequencer's current value property - * @type {string} - */ -Tw2ScalarSequencer.valueProperty = 'value'; - -/** - * The sequencer's type - * @type {number} - */ -Tw2ScalarSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCER; - -/** - * The sequencer's curve properties - * @type {string} - */ -Tw2ScalarSequencer.childArray = 'functions'; - -/** - * Operator types - * @type {{MULTIPLY: number, ADD: number}} - */ -Tw2ScalarSequencer.Operator = { - MULTIPLY: 0, - ADD: 1 -}; + return EveChildBillboard; +}(_EveChild2.EveChild); /***/ }), /* 161 */ @@ -31989,13 +32124,13 @@ Tw2ScalarSequencer.Operator = { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2VectorSequencer = undefined; +exports.EveChildContainer = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; -var _Tw2CurveSequencer2 = __webpack_require__(8); +var _EveChild2 = __webpack_require__(10); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -32004,162 +32139,142 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2VectorSequencer + * Container for other child effects * - * @property {string} name - * @property {number} start - * @property {vec3} value - * @property {number} operator - * @property {Array.} functions + * @parameter {Array.<{}>} objects + * @parameter {Array.} curveSets * @class */ -var Tw2VectorSequencer = exports.Tw2VectorSequencer = function (_Tw2CurveSequencer) { - _inherits(Tw2VectorSequencer, _Tw2CurveSequencer); +var EveChildContainer = exports.EveChildContainer = function (_EveChild) { + _inherits(EveChildContainer, _EveChild); - function Tw2VectorSequencer() { - _classCallCheck(this, Tw2VectorSequencer); + function EveChildContainer() { + _classCallCheck(this, EveChildContainer); - var _this = _possibleConstructorReturn(this, (Tw2VectorSequencer.__proto__ || Object.getPrototypeOf(Tw2VectorSequencer)).call(this)); + var _this = _possibleConstructorReturn(this, (EveChildContainer.__proto__ || Object.getPrototypeOf(EveChildContainer)).call(this)); - _this.start = 0; - _this.value = _math.vec3.create(); - _this.operator = 0; - _this.functions = []; + _this.objects = []; + _this.curveSets = []; return _this; } /** - * Sorts the sequencer + * Gets the child's resources + * @param {Array} [out=[]] + * @returns {Array} out */ - _createClass(Tw2VectorSequencer, [{ - key: 'Sort', - value: function Sort() { - _Tw2CurveSequencer2.Tw2CurveSequencer.Sort(this); - } - - /** - * Gets sequencer length - * @returns {number} - */ + _createClass(EveChildContainer, [{ + key: 'GetResources', + value: function GetResources() { + var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - }, { - key: 'GetLength', - value: function GetLength() { - var len = 0; - for (var i = 0; i < this.functions.length; ++i) { - if ('GetLength' in this.functions[i]) { - len = Math.max(len, this.functions[i].GetLength()); + for (var i = 0; i < this.objects.length; i++) { + if ('GetResources' in this.objects[i]) { + this.objects[i].GetResources(out); } } - return len; + return out; } /** - * Updates the current value at a specific time - * @param {number} time + * Per frame update + * @param {number} dt + * @param {mat4} parentTransform */ }, { - key: 'UpdateValue', - value: function UpdateValue(time) { - this.GetValueAt(time, this.value); + key: 'Update', + value: function Update(dt, parentTransform) { + _get(EveChildContainer.prototype.__proto__ || Object.getPrototypeOf(EveChildContainer.prototype), 'Update', this).call(this, dt, parentTransform); + + for (var i = 0; i < this.curveSets.length; i++) { + this.curveSets[i].Update(dt); + } + + for (var _i = 0; _i < this.objects.length; _i++) { + this.objects[_i].Update(dt, this.worldTransform); + } } /** - * Gets a value at a specific time - * @param {number} time - * @param {vec3} value - * @returns {vec3} + * Gets render batches + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator + * @param {Tw2PerObjectData} perObjectData */ }, { - key: 'GetValueAt', - value: function GetValueAt(time, value) { - var vec3_0 = _Tw2CurveSequencer2.Tw2CurveSequencer.global.vec3_0; - - switch (this.operator) { - case Tw2VectorSequencer.Operator.MULTIPLY: - _math.vec3.set(value, 1, 1, 1); - for (var i = 0; i < this.functions.length; ++i) { - this.functions[i].GetValueAt(time, vec3_0); - _math.vec3.multiply(value, value, vec3_0); - } - return value; - - default: - _math.vec3.set(value, 0, 0, 0); - for (var _i = 0; _i < this.functions.length; ++_i) { - this.functions[_i].GetValueAt(time, vec3_0); - _math.vec3.add(value, value, vec3_0); - } - return value; + key: 'GetBatches', + value: function GetBatches(mode, accumulator, perObjectData) { + if (this.display) { + for (var i = 0; i < this.objects.length; i++) { + this.objects[i].GetBatches(mode, accumulator, perObjectData); + } } } }]); - return Tw2VectorSequencer; -}(_Tw2CurveSequencer2.Tw2CurveSequencer); + return EveChildContainer; +}(_EveChild2.EveChild); -/** - * The sequencer's curve dimension - * @type {number} - */ +/***/ }), +/* 162 */ +/***/ (function(module, exports, __webpack_require__) { +"use strict"; -Tw2VectorSequencer.inputDimension = 3; -/** - * The sequencer's dimension - * @type {number} - */ -Tw2VectorSequencer.outputDimension = 3; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.EveChildExplosion = undefined; -/** - * The sequencer's current value property - * @type {string} - */ -Tw2VectorSequencer.valueProperty = 'value'; +var _EveChild2 = __webpack_require__(10); -/** - * The sequencer's type - * @type {number} - */ -Tw2VectorSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCER; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -/** - * The sequencer's curve properties - * @type {string} - */ -Tw2VectorSequencer.childArray = 'functions'; +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Operator types - * @type {{MULTIPLY: number, ADD: number}} + * 'Complex' explosion object. Not implemented. + * + * @class */ -Tw2VectorSequencer.Operator = { - MULTIPLY: 0, - ADD: 1 -}; +var EveChildExplosion = exports.EveChildExplosion = function (_EveChild) { + _inherits(EveChildExplosion, _EveChild); + + function EveChildExplosion() { + _classCallCheck(this, EveChildExplosion); + + return _possibleConstructorReturn(this, (EveChildExplosion.__proto__ || Object.getPrototypeOf(EveChildExplosion)).call(this)); + } + + return EveChildExplosion; +}(_EveChild2.EveChild); /***/ }), -/* 162 */ +/* 163 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { - value: true + value: true }); -exports.Tw2XYZScalarSequencer = undefined; +exports.EveChildMesh = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); + +var _core = __webpack_require__(1); -var _Tw2CurveSequencer2 = __webpack_require__(8); +var _EveChild2 = __webpack_require__(10); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -32168,136 +32283,111 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2XYZScalarSequencer + * Mesh attachment to space object * - * @property {string} name - * @property {vec3} value - * @property {Tw2CurveSequencer} XCurve - * @property {Tw2CurveSequencer} YCurve - * @property {Tw2CurveSequencer} ZCurve + * @property {Tw2Mesh|Tw2InstancedMesh} mesh + * @property {boolean} useSpaceObjectData * @class */ -var Tw2XYZScalarSequencer = exports.Tw2XYZScalarSequencer = function (_Tw2CurveSequencer) { - _inherits(Tw2XYZScalarSequencer, _Tw2CurveSequencer); - - function Tw2XYZScalarSequencer() { - _classCallCheck(this, Tw2XYZScalarSequencer); - - var _this = _possibleConstructorReturn(this, (Tw2XYZScalarSequencer.__proto__ || Object.getPrototypeOf(Tw2XYZScalarSequencer)).call(this)); - - _this.value = _math.vec3.create(); - _this.XCurve = null; - _this.YCurve = null; - _this.ZCurve = null; - return _this; - } - - /** - * Sorts the sequencer - */ - +var EveChildMesh = exports.EveChildMesh = function (_EveChild) { + _inherits(EveChildMesh, _EveChild); - _createClass(Tw2XYZScalarSequencer, [{ - key: 'Sort', - value: function Sort() { - _Tw2CurveSequencer2.Tw2CurveSequencer.Sort2(this); - } + function EveChildMesh() { + _classCallCheck(this, EveChildMesh); - /** - * Gets sequencer length - * @returns {number} - */ + var _this = _possibleConstructorReturn(this, (EveChildMesh.__proto__ || Object.getPrototypeOf(EveChildMesh)).call(this)); - }, { - key: 'GetLength', - value: function GetLength() { - var len = 0; - if (this.XCurve && 'GetLength' in this.XCurve) len = this.XCurve.GetLength(); - if (this.YCurve && 'GetLength' in this.YCurve) len = Math.max(len, this.YCurve.GetLength()); - if (this.ZCurve && 'GetLength' in this.ZCurve) len = Math.max(len, this.ZCurve.GetLength()); - return len; + _this.mesh = null; + _this.useSpaceObjectData = true; + return _this; } /** - * Updates a value at a specific time - * @param {number} time + * Gets the child's resources + * @param {Array} [out=[]] + * @returns {Array.} out */ - }, { - key: 'UpdateValue', - value: function UpdateValue(time) { - this.GetValueAt(time, this.value); - } - /** - * Gets a value at a specific time - * @param {number} time - * @param {vec3} value - * @returns {vec3} - */ + _createClass(EveChildMesh, [{ + key: 'GetResources', + value: function GetResources(out) { + if (this.mesh) this.mesh.GetResources(out); + return out; + } - }, { - key: 'GetValueAt', - value: function GetValueAt(time, value) { - value[0] = this.XCurve ? this.XCurve.GetValueAt(time) : 0; - value[1] = this.YCurve ? this.YCurve.GetValueAt(time) : 0; - value[2] = this.ZCurve ? this.ZCurve.GetValueAt(time) : 0; - return value; - } - }]); + /** + * Gets render batches + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator + * @param {Tw2PerObjectData} perObjectData + */ - return Tw2XYZScalarSequencer; -}(_Tw2CurveSequencer2.Tw2CurveSequencer); + }, { + key: 'GetBatches', + value: function GetBatches(mode, accumulator, perObjectData) { + if (!this.display || !this.mesh) return; -/** - * The sequencer's curve dimension - * @type {number} - */ + if (this.useSpaceObjectData) { + if (!this._perObjectData) { + this._perObjectData = new _core.Tw2PerObjectData(); + this._perObjectData.perObjectVSData = new _core.Tw2RawData(); + this._perObjectData.perObjectVSData.data = new Float32Array(perObjectData.perObjectVSData.data.length); + this._perObjectData.perObjectVSData.data[33] = 1; + this._perObjectData.perObjectVSData.data[35] = 1; -Tw2XYZScalarSequencer.inputDimension = 1; + this._perObjectData.perObjectPSData = new _core.Tw2RawData(); + this._perObjectData.perObjectPSData.data = new Float32Array(perObjectData.perObjectPSData.data.length); -/** - * The sequencer's dimension - * @type {number} - */ -Tw2XYZScalarSequencer.outputDimension = 3; + this._perObjectData.perObjectPSData.data[1] = 1; + this._perObjectData.perObjectPSData.data[3] = 1; + } + this._perObjectData.perObjectVSData.data.set(perObjectData.perObjectVSData.data); + this._perObjectData.perObjectPSData.data.set(perObjectData.perObjectPSData.data); -/** - * The sequencer's current value property - * @type {string} - */ -Tw2XYZScalarSequencer.valueProperty = 'value'; + _global.mat4.transpose(this._perObjectData.perObjectVSData.data, this.worldTransform); + _global.mat4.transpose(this._perObjectData.perObjectVSData.data.subarray(16), this.worldTransformLast); + } else { + if (!this._perObjectData) { + this._perObjectData = new _core.Tw2BasicPerObjectData(); + this._perObjectData.perObjectFFEData = new _core.Tw2RawData(); + this._perObjectData.perObjectFFEData.Declare('world', 16); + this._perObjectData.perObjectFFEData.Declare('worldInverseTranspose', 16); + this._perObjectData.perObjectFFEData.Create(); + } + _global.mat4.transpose(this._perObjectData.perObjectFFEData.Get('world'), this.worldTransform); + _global.mat4.invert(this._perObjectData.perObjectFFEData.Get('worldInverseTranspose'), this.worldTransform); + } -/** - * The sequencer's type - * @type {number} - */ -Tw2XYZScalarSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCER2; + this.mesh.GetBatches(mode, accumulator, this._perObjectData); + } + }]); -/** - * The sequencer's curve property names - * @type {string[]} - */ -Tw2XYZScalarSequencer.childProperties = ['XCurve', 'YCurve', 'ZCurve']; + return EveChildMesh; +}(_EveChild2.EveChild); /***/ }), -/* 163 */ +/* 164 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { - value: true + value: true }); -exports.Tw2YPRSequencer = undefined; +exports.EveChildParticleSystem = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + +var _global = __webpack_require__(0); + +var _core = __webpack_require__(1); -var _Tw2CurveSequencer2 = __webpack_require__(8); +var _EveChild2 = __webpack_require__(10); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -32306,137 +32396,89 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Tw2YPRSequencer + * Particle system attachment to space object * - * @property {quat} value - * @property {vec3} YawPitchRoll - * @property {Tw2Curve} YawCurve - * @property {Tw2Curve} PitchCurve - * @property {Tw2Curve} RollCurve + * @property {Tw2Mesh} mesh + * @property {Array} particleEmitters + * @property {Array} particleSystems + * @property {Tw2BasicPerObjectData} _perObjectData * @class */ -var Tw2YPRSequencer = exports.Tw2YPRSequencer = function (_Tw2CurveSequencer) { - _inherits(Tw2YPRSequencer, _Tw2CurveSequencer); - - function Tw2YPRSequencer() { - _classCallCheck(this, Tw2YPRSequencer); - - var _this = _possibleConstructorReturn(this, (Tw2YPRSequencer.__proto__ || Object.getPrototypeOf(Tw2YPRSequencer)).call(this)); - - _this.value = _math.quat.create(); - _this.YawPitchRoll = _math.vec3.create(); - _this.YawCurve = null; - _this.PitchCurve = null; - _this.RollCurve = null; - return _this; - } - - /** - * Sorts the sequencer - */ - - - _createClass(Tw2YPRSequencer, [{ - key: 'Sort', - value: function Sort() { - _Tw2CurveSequencer2.Tw2CurveSequencer.Sort2(this); - } - - /** - * Gets sequencer length - * @returns {number} - */ +var EveChildParticleSystem = exports.EveChildParticleSystem = function (_EveChild) { + _inherits(EveChildParticleSystem, _EveChild); - }, { - key: 'GetLength', - value: function GetLength() { - var len = 0; - if (this.YawCurve && 'GetLength' in this.YawCurve) len = this.YawCurve.GetLength(); - if (this.PitchCurve && 'GetLength' in this.PitchCurve) len = Math.max(len, this.PitchCurve.GetLength()); - if (this.RollCurve && 'GetLength' in this.RollCurve) len = Math.max(len, this.RollCurve.GetLength()); - return len; - } + function EveChildParticleSystem() { + _classCallCheck(this, EveChildParticleSystem); - /** - * Updates a value at a specific time - * - * @param {number} time - */ + var _this = _possibleConstructorReturn(this, (EveChildParticleSystem.__proto__ || Object.getPrototypeOf(EveChildParticleSystem)).call(this)); - }, { - key: 'UpdateValue', - value: function UpdateValue(time) { - this.GetValueAt(time, this.value); + _this.mesh = null; + _this.particleEmitters = []; + _this.particleSystems = []; + _this._perObjectData = new _core.Tw2BasicPerObjectData(); + _this._perObjectData.perObjectFFEData = new _core.Tw2RawData(); + _this._perObjectData.perObjectFFEData.Declare('world', 16); + _this._perObjectData.perObjectFFEData.Declare('worldInverseTranspose', 16); + _this._perObjectData.perObjectFFEData.Create(); + return _this; } /** - * Gets a value at a specific time - * - * @param {number} time - * @param {quat} value - * @returns {quat} + * Gets the child's resources + * @param {Array} [out=[]] + * @returns {Array.} out */ - }, { - key: 'GetValueAt', - value: function GetValueAt(time, value) { - if (this.YawCurve) this.YawPitchRoll[0] = this.YawCurve.GetValueAt(time); - if (this.PitchCurve) this.YawPitchRoll[1] = this.PitchCurve.GetValueAt(time); - if (this.RollCurve) this.YawPitchRoll[2] = this.RollCurve.GetValueAt(time); - - var sinYaw = Math.sin(this.YawPitchRoll[0] / 180 * Math.PI / 2.0), - cosYaw = Math.cos(this.YawPitchRoll[0] / 180 * Math.PI / 2.0), - sinPitch = Math.sin(this.YawPitchRoll[1] / 180 * Math.PI / 2.0), - cosPitch = Math.cos(this.YawPitchRoll[1] / 180 * Math.PI / 2.0), - sinRoll = Math.sin(this.YawPitchRoll[2] / 180 * Math.PI / 2.0), - cosRoll = Math.cos(this.YawPitchRoll[2] / 180 * Math.PI / 2.0); - - value[0] = sinYaw * cosPitch * sinRoll + cosYaw * sinPitch * cosRoll; - value[1] = sinYaw * cosPitch * cosRoll - cosYaw * sinPitch * sinRoll; - value[2] = cosYaw * cosPitch * sinRoll - sinYaw * sinPitch * cosRoll; - value[3] = cosYaw * cosPitch * cosRoll + sinYaw * sinPitch * sinRoll; - - return value; - } - }]); - return Tw2YPRSequencer; -}(_Tw2CurveSequencer2.Tw2CurveSequencer); + _createClass(EveChildParticleSystem, [{ + key: 'GetResources', + value: function GetResources(out) { + if (this.mesh) this.mesh.GetResources(out); + return out; + } -/** - * The sequencer's curve dimension - * @type {number} - */ + /** + * Per frame update + * @param {number} dt + * @param {mat4} parentTransform + */ + }, { + key: 'Update', + value: function Update(dt, parentTransform) { + _get(EveChildParticleSystem.prototype.__proto__ || Object.getPrototypeOf(EveChildParticleSystem.prototype), 'Update', this).call(this, dt, parentTransform); -Tw2YPRSequencer.inputDimension = 1; + for (var i = 0; i < this.particleEmitters.length; ++i) { + this.particleEmitters[i].Update(dt); + } -/** - * The sequencer's dimension - * @type {number} - */ -Tw2YPRSequencer.outputDimension = 4; + for (var _i = 0; _i < this.particleSystems.length; ++_i) { + this.particleSystems[_i].Update(dt); + } + } -/** - * The sequencer's current value property - * @type {string} - */ -Tw2YPRSequencer.valueProperty = 'value'; + /** + * Gets render batches + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator + */ -/** - * The sequencer's type - * @type {number} - */ -Tw2YPRSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCER2; + }, { + key: 'GetBatches', + value: function GetBatches(mode, accumulator) { + if (this.display && this.mesh) { + _global.mat4.transpose(this._perObjectData.perObjectFFEData.Get('world'), this.worldTransform); + _global.mat4.invert(this._perObjectData.perObjectFFEData.Get('worldInverseTranspose'), this.worldTransform); + this.mesh.GetBatches(mode, accumulator, this._perObjectData); + } + } + }]); -/** - * The sequencer's curve property names - * @type {string[]} - */ -Tw2YPRSequencer.childProperties = ['YawCurve', 'PitchCurve', 'RollCurve']; + return EveChildParticleSystem; +}(_EveChild2.EveChild); /***/ }), -/* 164 */ +/* 165 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32446,32 +32488,80 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2WbgTrack = __webpack_require__(165); +var _EveLensflare = __webpack_require__(166); -Object.keys(_Tw2WbgTrack).forEach(function (key) { +Object.keys(_EveLensflare).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { - return _Tw2WbgTrack[key]; + return _EveLensflare[key]; } }); }); -var _Tw2TransformTrack = __webpack_require__(166); +var _EveMeshOverlayEffect = __webpack_require__(167); -Object.keys(_Tw2TransformTrack).forEach(function (key) { +Object.keys(_EveMeshOverlayEffect).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { - return _Tw2TransformTrack[key]; + return _EveMeshOverlayEffect[key]; + } + }); +}); + +var _EveOccluder = __webpack_require__(60); + +Object.keys(_EveOccluder).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _EveOccluder[key]; + } + }); +}); + +var _EveStretch = __webpack_require__(168); + +Object.keys(_EveStretch).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _EveStretch[key]; + } + }); +}); + +var _EveTurretFiringFX = __webpack_require__(169); + +Object.keys(_EveTurretFiringFX).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _EveTurretFiringFX[key]; + } + }); +}); + +var _EveStarField = __webpack_require__(170); + +Object.keys(_EveStarField).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _EveStarField[key]; } }); }); /***/ }), -/* 165 */ +/* 166 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32480,166 +32570,339 @@ Object.keys(_Tw2TransformTrack).forEach(function (key) { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2WbgTrack = Tw2WbgTrack; -exports.Tw2WbgTransformTrack = Tw2WbgTransformTrack; +exports.EveLensflare = undefined; + +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); var _core = __webpack_require__(1); +var _EveOccluder = __webpack_require__(60); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + /** - * Tw2WbgTrack + * EveLensFlare * - * @property {string|number} _id - * @property {string} name - * @property {string} geometryResPath - * @property {Object} geometryRes - * @property {string} group - * @property {number} duration - * @property {boolean} cycle + * @property {number|string} _id + * @property {String} name= + * @property {boolean} display + * @property {boolean} update + * @property {boolean} doOcclusionQueries + * @property {number} cameraFactor + * @property {vec3} position + * @property {Array} flares + * @property {Array.} occluders + * @property {Array.} backgroundOccluders + * @property {number} occlusionIntensity + * @property {number} backgroundOcclusionIntensity + * @property {Array} distanceToEdgeCurves + * @property {Array} distanceToCenterCurves + * @property {Array} radialAngleCurves + * @property {Array} xDistanceToCenter + * @property {Array} yDistanceToCenter + * @property {Array} bindings + * @property {Array.} curveSets + * @property {?Tw2Mesh} mesh + * @property {vec3} _direction + * @property {mat4} _transform + * @property {*} _backBuffer + * @class */ -function Tw2WbgTrack() { - this._id = _math.util.generateID(); - this.name = ''; - this.geometryResPath = ''; - this.geometryRes = null; - this.group = ''; - this.duration = 0; - this.cycle = false; +var EveLensflare = exports.EveLensflare = function () { + function EveLensflare() { + _classCallCheck(this, EveLensflare); + + this._id = _global.util.generateID(); + this.name = ''; + this.display = true; + this.update = true; + this.doOcclusionQueries = true; + this.cameraFactor = 20; + this.position = _global.vec3.create(); + this.flares = []; + this.occluders = []; + this.backgroundOccluders = []; + this.occlusionIntensity = 1; + this.backgroundOcclusionIntensity = 1; + this.distanceToEdgeCurves = []; + this.distanceToCenterCurves = []; + this.radialAngleCurves = []; + this.xDistanceToCenter = []; + this.yDistanceToCenter = []; + this.bindings = []; + this.curveSets = []; + this.mesh = null; + this._direction = _global.vec3.create(); + this._transform = _global.mat4.create(); + this._backBuffer = null; + + EveLensflare.init(); + } /** - * SetCurves - * @param self - * @private + * Gets lensflares's res objects + * @param {Array} [out=[]] - Optional receiving array + * @returns {Array.} [out] */ - function SetCurves(self) { - if (!self.name || !self.group || !self.geometryRes) { - return; + + + _createClass(EveLensflare, [{ + key: 'GetResources', + value: function GetResources() { + var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + + if (this.mesh) this.mesh.GetResources(out); + + for (var i = 0; i < this.flares.length; i++) { + this.flares[i].GetResources(out); + } + + if (_EveOccluder.EveOccluder.global && _EveOccluder.EveOccluder.global.effect && !out.includes(_EveOccluder.EveOccluder.global.effect)) { + out.push(_EveOccluder.EveOccluder.global.effect); + } + + return out; } - for (var i = 0; i < self.geometryRes.animations.length; ++i) { - var animation = self.geometryRes.animations[i]; - for (var j = 0; j < animation.trackGroups.length; ++j) { - if (animation.trackGroups[j].name === self.group) { - self._ApplyTracks(animation.trackGroups[j], animation.duration); + /** + * Updates Occluders + */ + + }, { + key: 'UpdateOccluders', + value: function UpdateOccluders() { + if (!this.doOcclusionQueries) return; + + var d = _global.device, + g = EveLensflare.global; + + if (!g.occluderLevels[0].texture || g.occluderLevels[0].width < this.occluders.length * 2) { + for (var i = 0; i < g.occluderLevels.length; ++i) { + g.occluderLevels[i].Create(this.occluders.length * 2, 1, false); } } - } - } - /** - * Initialize - * @method - */ - this.Initialize = function () { - if (this.geometryResPath) { - this.geometryRes = _core.resMan.GetResource(this.geometryResPath); - var self = this; - var notification = { - OnResPrepared: function OnResPrepared() { - SetCurves(self); + // TODO: Is this deprecated? + for (var j = 0; j < this.flares.length; ++j) { + if ('_backBuffer' in this.flares[j]) { + this.flares[j]._backBuffer.textureRes = g.occluderLevels.texture; } - }; - this.geometryRes.RegisterNotification(notification); - } - }; + } - /** - * Updates a value at a specific time - * @param {number} time - * @prototype - */ - this.UpdateValue = function (time) { - if (!this._TracksReady()) return; - if (this.cycle) time = time % this.duration; - if (time <= this.duration && time >= 0) this._UpdateValue(time); - }; -} + this.occlusionIntensity = 1; + this.backgroundOcclusionIntensity = 1; -/** - * Tw2WbgTransformTrack - * - * @property {string|number} _id - * @property {vec3} translation - * @property {quat} rotation - * @property {vec3} scale - * @variable {*} positionCurve - * @variable {*} rotationCurve - * @variable {*} scaleCurve - * @variable {mat4} scaleShear - */ -function Tw2WbgTransformTrack() { - this._id = _math.util.generateID(); - this.translation = _math.vec3.create(); - this.rotation = _math.quat.create(); - this.rotation[3] = 1; - this.scale = _math.vec3.create(); - var positionCurve = null; - var rotationCurve = null; - var scaleCurve = null; - var scaleShear = _math.mat4.create(); + g.occluderLevels[g.occludedLevelIndex].Set(); + d.SetStandardStates(d.RM_OPAQUE); + d.gl.clearColor(0.0, 0.0, 0.0, 1.0); + d.gl.clear(d.gl.COLOR_BUFFER_BIT); + g.occluderLevels[g.occludedLevelIndex].Unset(); - /** - * _TracksReady - * @returns {*} - * @private - */ - this._TracksReady = function () { - return positionCurve || rotationCurve || scaleCurve; - }; + var samples = 1; + if (d.antialiasing) { + samples = d.msaaSamples; + d.gl.sampleCoverage(1.0 / samples, false); + } - /** - * _ApplyTracks - * @param trackGroup - * @param duration - * @private - */ - this._ApplyTracks = function (trackGroup, duration) { - for (var i = 0; i < trackGroup.transformTracks.length; ++i) { - var track = trackGroup.transformTracks[i]; - if (track.name === this.name) { - this.duration = duration; - positionCurve = track.position; - rotationCurve = track.orientation; - scaleCurve = track.scaleShear; + for (var _i = 0; _i < this.occluders.length; ++_i) { + d.SetRenderState(d.RS_COLORWRITEENABLE, 8); + d.gl.colorMask(false, false, false, true); + d.gl.clearColor(0.0, 0.0, 0.0, 0.0); + d.gl.clear(d.gl.COLOR_BUFFER_BIT); + + // Turn off antialiasing + if (d.antialiasing) { + d.gl.enable(d.gl.SAMPLE_COVERAGE); + d.gl.sampleCoverage(0.25, false); + } + this.occluders[_i].UpdateValue(this._transform, _i); + if (d.antialiasing) d.gl.disable(d.gl.SAMPLE_COVERAGE); + + // Copy back buffer into a texture + if (!g.backBuffer.texture) g.backBuffer.Attach(d.gl.createTexture()); + d.gl.bindTexture(d.gl.TEXTURE_2D, g.backBuffer.texture); + if (g.backBuffer.width !== d.viewportWidth || g.backBuffer.height !== d.viewportHeight) { + d.gl.texImage2D(d.gl.TEXTURE_2D, 0, d.gl.RGBA, d.viewportWidth, d.viewportHeight, 0, d.gl.RGBA, d.gl.UNSIGNED_BYTE, null); + d.gl.texParameteri(d.gl.TEXTURE_2D, d.gl.TEXTURE_MAG_FILTER, d.gl.LINEAR); + d.gl.texParameteri(d.gl.TEXTURE_2D, d.gl.TEXTURE_MIN_FILTER, d.gl.LINEAR); + g.backBuffer.width = d.viewportWidth; + g.backBuffer.height = d.viewportHeight; + } + d.gl.copyTexImage2D(d.gl.TEXTURE_2D, 0, d.alphaBlendBackBuffer ? d.gl.RGBA : d.gl.RGB, 0, 0, g.backBuffer.width, g.backBuffer.height, 0); + d.gl.bindTexture(d.gl.TEXTURE_2D, null); + + // Collect samples + g.occluderLevels[g.occludedLevelIndex].Set(); + _EveOccluder.EveOccluder.CollectSamples(g.backBuffer, _i, g.occluderLevels[0].width / 2, samples); + g.occluderLevels[g.occludedLevelIndex].Unset(); + } + + if (d.antialiasing) d.gl.sampleCoverage(1, false); + + g.occluderLevels[(g.occludedLevelIndex + 1) % g.occluderLevels.length].Set(); + var pixels = new Uint8Array(g.occluderLevels[0].width * 4); + d.gl.readPixels(0, 0, 2, 1, d.gl.RGBA, d.gl.UNSIGNED_BYTE, pixels); + g.occluderLevels[(g.occludedLevelIndex + 1) % g.occluderLevels.length].Unset(); + + this.occlusionIntensity = 1; + for (var _i2 = 0; _i2 < g.occluderLevels[0].width * 2; _i2 += 4) { + this.occlusionIntensity *= pixels[_i2 + 1] ? pixels[_i2] / pixels[_i2 + 1] : 1; } + + this.backgroundOcclusionIntensity = this.occlusionIntensity; + + _global.store.SetVariableValue('LensflareFxOccScale', [this.occlusionIntensity, this.occlusionIntensity, 0, 0]); + g.occludedLevelIndex = (g.occludedLevelIndex + 1) % g.occluderLevels.length; } - this.UpdateValue(0); - }; - /** - * Updates a value at a specific time - * @param {number} time - * @prototype - */ - this._UpdateValue = function (time) { - if (positionCurve) { - _math.curve.evaluate(positionCurve, time, this.translation, this.cycle, this.duration); + /** + * Gets render batches + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator + * @param {Tw2PerObjectData} perObjectData + */ + + }, { + key: 'GetBatches', + value: function GetBatches(mode, accumulator, perObjectData) { + if (this.display) { + var viewDir = _global.vec4.set(EveLensflare.global.vec4_0, 0, 0, 1, 0); + + _global.vec4.transformMat4(viewDir, viewDir, _global.device.viewInverse); + if (_global.vec3.dot(viewDir, this._direction) < 0) return; + + for (var i = 0; i < this.flares.length; ++i) { + this.flares[i].GetBatches(mode, accumulator, perObjectData); + } + + if (this.mesh) { + this.mesh.GetBatches(mode, accumulator, perObjectData); + } + } } - if (rotationCurve) { - _math.curve.evaluate(rotationCurve, time, this.rotation, this.cycle, this.duration); - _math.quat.normalize(this.rotation, this.rotation); + /** + * Prepares the lensflare for rendering + */ + + }, { + key: 'PrepareRender', + value: function PrepareRender() { + if (!this.display) return; + + var g = EveLensflare.global, + viewDir = g.vec4_0, + cameraPos = g.vec3_0, + scaleMat = _global.mat4.identity(g.mat4_0), + cameraSpacePos = g.vec3_2, + negDirVec = g.vec3_3, + negPos = g.vec3_1, + dist = g.vec4_1; + + _global.vec3.transformMat4(cameraPos, [0, 0, 0], _global.device.viewInverse); + + if (_global.vec3.length(this.position) === 0) { + _global.vec3.negate(negPos, cameraPos); + //let distScale = vec3.length(negPos); + //distScale = distScale > 1.5 ? 1 / Math.log(distScale) : 2.5; + } else { + _global.vec3.negate(negPos, this.position); + _global.vec3.normalize(this._direction, negPos); + } + + _global.vec4.transformMat4(viewDir, [0, 0, 1, 0], _global.device.viewInverse); + _global.vec3.scaleAndAdd(cameraSpacePos, cameraPos, viewDir, -this.cameraFactor); + _global.vec3.negate(negDirVec, this._direction); + _global.mat4.arcFromForward(this._transform, negDirVec); + _global.mat4.setTranslation(this._transform, cameraSpacePos); + _global.mat4.scale(scaleMat, scaleMat, [this.occlusionIntensity, this.occlusionIntensity, 1]); + //mat4.multiply(scaleMat, scaleMat, this._transform); + + var dir = this._direction; + + _global.store.SetVariableValue('LensflareFxDirectionScale', [dir[0], dir[1], dir[2], 1]); + + _global.vec4.set(dist, dir[0], dir[1], dir[2], 0); + _global.vec4.transformMat4(dist, dist, _global.device.view); + _global.vec4.transformMat4(dist, dist, _global.device.projection); + dist[0] /= dist[3]; + dist[1] /= dist[3]; + + var distToEdge = 1 - Math.min(1 - Math.abs(dist[0]), 1 - Math.abs(dist[1])), + distToCenter = Math.sqrt(dist[0] * dist[0] + dist[1] * dist[1]), + radialAngle = Math.atan2(dist[1], dist[0]) + Math.PI; + + for (var i = 0; i < this.distanceToEdgeCurves.length; ++i) { + this.distanceToEdgeCurves[i].UpdateValue(distToEdge); + } + + for (var _i3 = 0; _i3 < this.distanceToCenterCurves.length; ++_i3) { + this.distanceToCenterCurves[_i3].UpdateValue(distToCenter); + } + + for (var _i4 = 0; _i4 < this.radialAngleCurves.length; ++_i4) { + this.radialAngleCurves[_i4].UpdateValue(radialAngle); + } + + for (var _i5 = 0; _i5 < this.xDistanceToCenter.length; ++_i5) { + this.xDistanceToCenter[_i5].UpdateValue(dist[0] + 10); + } + + for (var _i6 = 0; _i6 < this.yDistanceToCenter.length; ++_i6) { + this.yDistanceToCenter[_i6].UpdateValue(dist[1] + 10); + } + + for (var _i7 = 0; _i7 < this.bindings.length; ++_i7) { + this.bindings[_i7].CopyValue(); + } + + for (var _i8 = 0; _i8 < this.flares.length; ++_i8) { + this.flares[_i8].UpdateViewDependentData(this._transform); + } } - if (scaleCurve) { - _math.curve.evaluate(scaleCurve, time, scaleShear, this.cycle, this.duration); + /** + * Initializes class global and scratch variables + */ + + }], [{ + key: 'init', + value: function init() { + if (!EveLensflare.global) { + var g = EveLensflare.global = {}; + g.vec3_0 = _global.vec3.create(); + g.vec3_1 = _global.vec3.create(); + g.vec3_2 = _global.vec3.create(); + g.vec3_3 = _global.vec3.create(); + g.vec4_0 = _global.vec4.create(); + g.vec4_1 = _global.vec4.create(); + g.mat4_0 = _global.mat4.create(); + + g.backBuffer = new _core.Tw2TextureRes(); + g.backBuffer.width = 0; + g.backBuffer.height = 0; + g.backBuffer.hasMipMaps = false; + g.occludedLevelIndex = 0; + g.occluderLevels = [new _core.Tw2RenderTarget(), new _core.Tw2RenderTarget(), new _core.Tw2RenderTarget(), new _core.Tw2RenderTarget()]; + } } + }]); - this.scale[0] = scaleShear[0]; - this.scale[1] = scaleShear[5]; - this.scale[2] = scaleShear[10]; - }; -} + return EveLensflare; +}(); /** - * @type {Tw2WbgTrack} - * @prototype + * Class global and scratch variables + * @type {{string:*}} */ -Tw2WbgTransformTrack.prototype = new Tw2WbgTrack(); + + +EveLensflare.global = null; /***/ }), -/* 166 */ +/* 167 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32648,195 +32911,152 @@ Tw2WbgTransformTrack.prototype = new Tw2WbgTrack(); Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2TransformTrack = undefined; +exports.EveMeshOverlayEffect = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); - var _core = __webpack_require__(1); +var _global = __webpack_require__(0); + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** - * Tw2TransformTrack + * Constructor for Overlay Effects * - * @property {string|number} _id + * @property {number|string} _id * @property {string} name - * @property {string} resPath - * @property {Object} res - * @property {string} group - * @property {boolean} cycle - * @property {number} duration - * @property {vec3} translation - * @property {quat} rotation - * @property {vec3} scale - * @property positionCurve - * @property orientationCurve - * @property scaleCurve - * @property {mat4} _scaleShear + * @property {boolean} display - Enables/ disables all batch accumulations + * @property {{}} visible - Batch accumulation options for the overlay effect + * @property {boolean} visible.opaqueEffects - Enables/ disables opaque effect batch accumulation + * @property {boolean} visible.decalEffects - Enables/ disables decal effect batch accumulation + * @property {boolean} visible.transparentEffects - Enables/ disables transparent effect batch accumulation + * @property {boolean} visible.additiveEffects - Enables/ disables additive effect batch accumulation + * @property {boolean} visible.distortionEffects - Currently not supported + * @property {boolean} update + * @property {Tw2CurveSet} curveSet + * @property {Array.} opaqueEffects + * @property {Array.} decalEffects + * @property {Array.} transparentEffects + * @property {Array.} additiveEffects + * @property {Array.} distortionEffects - Currently not supported * @class */ -var Tw2TransformTrack = exports.Tw2TransformTrack = function () { - function Tw2TransformTrack() { - _classCallCheck(this, Tw2TransformTrack); +var EveMeshOverlayEffect = exports.EveMeshOverlayEffect = function () { + function EveMeshOverlayEffect() { + _classCallCheck(this, EveMeshOverlayEffect); - this._id = _math.util.generateID(); + this._id = _global.util.generateID(); this.name = ''; - this.resPath = ''; - this.res = null; - this.group = ''; - this.cycle = false; - this.duration = 0; - this.translation = _math.vec3.create(); - this.rotation = _math.quat.create(); - this.scale = _math.vec3.fromValues(0, 0, 0); - this.scaleShear = _math.mat4.create(); - this.positionCurve = null; - this.orientationCurve = null; - this.scaleCurve = null; + this.display = true; + this.visible = {}; + this.visible.opaqueEffects = true; + this.visible.decalEffects = true; + this.visible.transparentEffects = true; + this.visible.additiveEffects = true; + this.visible.distortionEffects = false; + this.update = true; + this.curveSet = null; + this.opaqueEffects = []; + this.decalEffects = []; + this.transparentEffects = []; + this.additiveEffects = []; + this.distortionEffects = []; } /** - * Initializes the Curve + * Gets the mesh overlay's resources + * @param {Array} [out=[]] - Optional receiving array + * @returns {Array.} [out] */ - _createClass(Tw2TransformTrack, [{ - key: 'Initialize', - value: function Initialize() { - if (this.resPath !== '') { - this.res = _core.resMan.GetResource(this.resPath); - } + _createClass(EveMeshOverlayEffect, [{ + key: 'GetResources', + value: function GetResources() { + var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + + _global.util.perArrayChild(this.opaqueEffects, 'GetResources', out); + _global.util.perArrayChild(this.decalEffects, 'GetResources', out); + _global.util.perArrayChild(this.transparentEffects, 'GetResources', out); + _global.util.perArrayChild(this.additiveEffects, 'GetResources', out); + _global.util.perArrayChild(this.distortionEffects, 'GetResources', out); + return out; } /** - * Gets curve length - * - * @returns {number} + * Per frame update + * @param {number} dt - delta Time */ }, { - key: 'GetLength', - value: function GetLength() { - return this.duration; + key: 'Update', + value: function Update(dt) { + if (this.update && this.curveSet) this.curveSet.Update(dt); } /** - * Updates a value at a specific time - * - * @param {number} time + * Gets render batches + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator + * @param {Tw2PerObjectData} perObjectData + * @param {Tw2Mesh} mesh */ }, { - key: 'UpdateValue', - value: function UpdateValue(time) { - if (!this.res || !this.res.IsGood()) return; - if (!this.positionCurve) this.FindTracks(); - if (!this.positionCurve) return; - if (this.cycle) time = time % this.duration; - if (time > this.duration || time < 0) return; + key: 'GetBatches', + value: function GetBatches(mode, accumulator, perObjectData, mesh) { + if (!this.display || !mesh || !mesh.IsGood()) return; - _math.curve.evaluate(this.positionCurve, time, this.translation, this.cycle, this.duration); - _math.curve.evaluate(this.orientationCurve, time, this.rotation, this.cycle, this.duration); - _math.quat.normalize(this.rotation, this.rotation); - _math.curve.evaluate(this.scaleCurve, time, this.scaleShear, this.cycle, this.duration); - _math.mat4.getScaling(this.scale, this.scaleCurve); + var effects = this.GetEffects(mode); + for (var i = 0; i < effects.length; i++) { + var batch = new _core.Tw2GeometryBatch(); + batch.renderMode = mode; + batch.perObjectData = perObjectData; + batch.geometryRes = mesh.geometryResource; + batch.meshIx = mesh.meshIndex; + batch.start = 0; + batch.count = mesh.geometryResource.meshes[mesh.meshIndex].areas.length; + batch.effect = effects[i]; + accumulator.Commit(batch); + } } /** - * FindTracks + * Gets effects + * @param {number} mode + * @returns {Array.} */ }, { - key: 'FindTracks', - value: function FindTracks() { - var group = null; - for (var i = 0; i < this.res.animations.length; ++i) { - for (var j = 0; j < this.res.animations[i].trackGroups.length; ++j) { - if (this.res.animations[i].trackGroups[j].name === this.group) { - this.duration = this.res.animations[i].duration; - group = this.res.animations[i].trackGroups[j]; + key: 'GetEffects', + value: function GetEffects(mode) { + if (this.display) { + switch (mode) { + case _global.device.RM_OPAQUE: + if (this.visible.opaqueEffects) return this.opaqueEffects; break; - } - } - } - if (!group) return; + case _global.device.RM_TRANSPARENT: + if (this.visible.transparentEffects) return this.transparentEffects; + break; - for (var _i = 0; _i < group.transformTracks.length; ++_i) { - if (this.name === group.transformTracks[_i].name) { - this.positionCurve = group.transformTracks[_i].position; - this.orientationCurve = group.transformTracks[_i].orientation; - this.scaleCurve = group.transformTracks[_i].scaleShear; - break; + case _global.device.RM_ADDITIVE: + if (this.visible.additiveEffects) return this.additiveEffects; + break; + + case _global.device.RM_DECAL: + if (this.visible.decalEffects) return this.decalEffects; + break; } } + return []; } }]); - return Tw2TransformTrack; + return EveMeshOverlayEffect; }(); -/***/ }), -/* 167 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _Tw2MayaEulerRotationCurve = __webpack_require__(168); - -Object.keys(_Tw2MayaEulerRotationCurve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2MayaEulerRotationCurve[key]; - } - }); -}); - -var _Tw2MayaScalarCurve = __webpack_require__(169); - -Object.keys(_Tw2MayaScalarCurve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2MayaScalarCurve[key]; - } - }); -}); - -var _Tw2MayaVector3Curve = __webpack_require__(170); - -Object.keys(_Tw2MayaVector3Curve).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2MayaVector3Curve[key]; - } - }); -}); - -var _Tw2MayaAnimationEngine = __webpack_require__(171); - -Object.keys(_Tw2MayaAnimationEngine).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2MayaAnimationEngine[key]; - } - }); -}); - /***/ }), /* 168 */ /***/ (function(module, exports, __webpack_require__) { @@ -32847,285 +33067,317 @@ Object.keys(_Tw2MayaAnimationEngine).forEach(function (key) { Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2MayaEulerRotationCurve = undefined; +exports.EveStretch = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); -var _curves = __webpack_require__(19); +var _core = __webpack_require__(1); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - /** - * Tw2MayaEulerRotationCurve + * EveStretch * - * @property {number} xIndex - * @property {number} yIndex - * @property {number} zIndex - * @property {?Tw2MayaAnimationEngine} animationEngine - * @property {string} name - * @property {vec3} eulerValue - * @property {boolean} updateQuaternion - * @property {quat} quatValue - * @property {number} length + * @property {string|number} _id + * @property {String} name + * @property {boolean} display + * @property {boolean} update + * @property {Array.} curveSets + * @property {*} source + * @property {*} dest + * @property {*} sourceObject + * @property {*} destObject + * @property {*} stretchObject + * @property {Tw2Float} length + * @property {number} _time + * @property {boolean} _useTransformsForStretch + * @property {vec3} _sourcePosition + * @property {vec3} _destinationPosition + * @property {boolean} _displaySourceObject + * @property {mat4} _sourceTransform + * @property {boolean} _displayDestObject + * @property {boolean} _useTransformsForStretch + * @property {boolean} _isNegZForward * @class */ -var Tw2MayaEulerRotationCurve = exports.Tw2MayaEulerRotationCurve = function (_Tw2Curve) { - _inherits(Tw2MayaEulerRotationCurve, _Tw2Curve); - - function Tw2MayaEulerRotationCurve() { - _classCallCheck(this, Tw2MayaEulerRotationCurve); +var EveStretch = exports.EveStretch = function () { + function EveStretch() { + _classCallCheck(this, EveStretch); - var _this = _possibleConstructorReturn(this, (Tw2MayaEulerRotationCurve.__proto__ || Object.getPrototypeOf(Tw2MayaEulerRotationCurve)).call(this)); + this._id = _global.util.generateID(); + this.name = ''; + this.display = true; + this.update = true; + this.curveSets = []; + this.source = null; + this.dest = null; + this.sourceObject = null; + this.destObject = null; + this.stretchObject = null; + this.length = new _core.Tw2Float(); + this._time = 0; + this._useTransformsForStretch = false; + this._sourcePosition = _global.vec3.create(); + this._destinationPosition = _global.vec3.create(); + this._displaySourceObject = true; + this._sourceTransform = null; + this._displayDestObject = true; + this._useTransformsForStretch = false; + this._isNegZForward = false; - _this.xIndex = -1; - _this.yIndex = -1; - _this.zIndex = -1; - _this.animationEngine = null; - _this.eulerValue = _math.vec3.create(); - _this.updateQuaternion = false; - _this.quatValue = _math.quat.create(); - _this.length = 0; - return _this; + EveStretch.init(); } /** - * Sorts the curve + * Gets source position + * @param {vec3} position */ - _createClass(Tw2MayaEulerRotationCurve, [{ - key: 'Sort', - value: function Sort() { - this.ComputeLength(); + _createClass(EveStretch, [{ + key: 'SetSourcePosition', + value: function SetSourcePosition(position) { + this._useTransformsForStretch = false; + this._sourcePosition = position; } /** - * Gets the curve's length - * @returns {number} + * Sets the destination position + * @param {vec3} position */ }, { - key: 'GetLength', - value: function GetLength() { - return this.length; + key: 'SetDestinationPosition', + value: function SetDestinationPosition(position) { + this._destinationPosition = position; } /** - * Updates a value at a specific time - * @param {number} time + * Sets the source transform + * @param {mat4} transform */ }, { - key: 'UpdateValue', - value: function UpdateValue(time) { - if (this.animationEngine) { - if (this.xIndex) { - this.eulerValue[0] = this.animationEngine.Evaluate(this.xIndex, time); - } - - if (this.yIndex) { - if (this.yIndex === this.xIndex) { - this.eulerValue[1] = this.eulerValue[0]; - } else { - this.eulerValue[1] = this.animationEngine.Evaluate(this.yIndex, time); - } - } - - if (this.zIndex) { - if (this.zIndex === this.xIndex) { - this.eulerValue[2] = this.eulerValue[0]; - } else { - this.eulerValue[2] = this.animationEngine.Evaluate(this.zIndex, time); - } - } - - if (this.updateQuaternion) { - var sinYaw = Math.sin(this.eulerValue[0] / 2), - cosYaw = Math.cos(this.eulerValue[0] / 2), - sinPitch = Math.sin(this.eulerValue[1] / 2), - cosPitch = Math.cos(this.eulerValue[1] / 2), - sinRoll = Math.sin(this.eulerValue[2] / 2), - cosRoll = Math.cos(this.eulerValue[2] / 2); - - this.quatValue[0] = sinYaw * cosPitch * sinRoll + cosYaw * sinPitch * cosRoll; - this.quatValue[1] = sinYaw * cosPitch * cosRoll - cosYaw * sinPitch * sinRoll; - this.quatValue[2] = cosYaw * cosPitch * sinRoll - sinYaw * sinPitch * cosRoll; - this.quatValue[3] = cosYaw * cosPitch * cosRoll + sinYaw * sinPitch * sinRoll; - } - } + key: 'SetSourceTransform', + value: function SetSourceTransform(transform) { + this._useTransformsForStretch = true; + this._sourceTransform = transform; } /** - * Computes curve Length + * SetIsNegZForward + * @param {boolean} isNegZForward */ }, { - key: 'ComputeLength', - value: function ComputeLength() { - if (!this.animationEngine || this.animationEngine.GetNumberOfCurves() === 0) return; - - this.length = 0; - if (this.xIndex >= 0) { - this.length = this.animationEngine.GetLength(this.xIndex); - } - - if (this.yIndex >= 0) { - this.length = Math.max(this.length, this.animationEngine.GetLength(this.yIndex)); - } - - if (this.zIndex >= 0) { - this.length = Math.max(this.length, this.animationEngine.GetLength(this.zIndex)); - } + key: 'SetIsNegZForward', + value: function SetIsNegZForward(isNegZForward) { + this._isNegZForward = isNegZForward; } - }]); - - return Tw2MayaEulerRotationCurve; -}(_curves.Tw2Curve); - -/** - * The curve's dimension - * @type {number} - */ + /** + * Gets the stretches resources + * @param {Array} [out=[]] + * @return {Array} out + */ -Tw2MayaEulerRotationCurve.outputDimension = 3; + }, { + key: 'GetResources', + value: function GetResources() { + var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; -/** - * The curve's current value property - * @type {string} - */ -Tw2MayaEulerRotationCurve.valueProperty = 'eulerValue'; + if (this.source && this.source.GetResources) this.source.GetResources(out); + if (this.dest && this.dest.GetResources) this.dest.GetResources(out); + if (this.sourceObject && this.sourceObject.GetResources) this.sourceObject.GetResources(out); + if (this.destObject && this.destObject.GetResources) this.destObject.GetResources(out); + if (this.stretchObject && this.stretchObject.GetResources) this.stretchObject.GetResources(out); + return out; + } -/** - * The curve's type - * @type {number} - */ -Tw2MayaEulerRotationCurve.curveType = _curves.Tw2Curve.Type.CURVE_MAYA; + /** + * Updates view dependent data + */ -/***/ }), -/* 169 */ -/***/ (function(module, exports, __webpack_require__) { + }, { + key: 'UpdateViewDependentData', + value: function UpdateViewDependentData() { + if (!this.display) return; -"use strict"; + var g = EveStretch.global, + directionVec = _global.vec3.subtract(g.vec3_0, this._destinationPosition, this._sourcePosition), + m = _global.mat4.identity(g.mat4_0), + x = _global.vec3.set(g.vec3_1, 0, 0, 0), + up = _global.vec3.set(g.vec3_2, 0, 0, 0), + s = _global.mat4.identity(g.mat4_1); + var scalingLength = _global.vec3.length(directionVec); + _global.vec3.normalize(directionVec, directionVec); -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2MayaScalarCurve = undefined; + if (this._useTransformsForStretch) { + _global.mat4.rotateX(m, m, -Math.PI / 2); + _global.mat4.multiply(m, this._sourceTransform, m); + } else { + if (Math.abs(directionVec[1]) > 0.9) { + up[2] = 1; + } else { + up[1] = 1; + } -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + _global.vec3.cross(x, up, directionVec); + _global.vec3.normalize(x, x); + _global.vec3.cross(up, directionVec, x); + m[0] = x[0]; + m[1] = x[1]; + m[2] = x[2]; + m[4] = -directionVec[0]; + m[5] = -directionVec[1]; + m[6] = -directionVec[2]; + m[8] = up[0]; + m[9] = up[1]; + m[10] = up[2]; + } -var _curves = __webpack_require__(19); + if (this.destObject && this._displayDestObject) { + _global.mat4.setTranslation(m, this._destinationPosition); + this.destObject.UpdateViewDependentData(m); + } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + if (this.sourceObject && this._displaySourceObject) { + if (this._useTransformsForStretch) { + _global.mat4.identity(m); + _global.mat4.rotateX(m, m, -Math.PI / 2); + _global.mat4.multiply(m, this._sourceTransform, m); + } else { + _global.mat4.setTranslation(m, this._sourcePosition); + } + this.sourceObject.UpdateViewDependentData(m); + } -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + if (this.stretchObject) { + if (this._useTransformsForStretch) { + _global.mat4.identity(m); + _global.mat4.scale(m, m, [1, 1, scalingLength]); + _global.mat4.multiply(m, this._sourceTransform, m); + } else { + m[0] = x[0]; + m[1] = x[1]; + m[2] = x[2]; + m[4] = up[0]; + m[5] = up[1]; + m[6] = up[2]; + m[8] = -directionVec[0]; + m[9] = -directionVec[1]; + m[10] = -directionVec[2]; + if (this._isNegZForward) scalingLength = -scalingLength; + _global.mat4.scale(s, s, [1, 1, scalingLength]); + _global.mat4.multiply(m, m, s); + } + this.stretchObject.UpdateViewDependentData(m); + } + } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + /** + * Per frame update + * @param {number} dt - delta time + */ -/** - * Tw2MayaScalarCurve - * - * @property {number} index - * @property {null|Tw2MayaAnimationEngine} animationEngine - * @property {number} value - * @property {number} length - * @class - */ -var Tw2MayaScalarCurve = exports.Tw2MayaScalarCurve = function (_Tw2Curve) { - _inherits(Tw2MayaScalarCurve, _Tw2Curve); + }, { + key: 'Update', + value: function Update(dt) { + for (var i = 0; i < this.curveSets.length; ++i) { + this.curveSets[i].Update(dt); + } - function Tw2MayaScalarCurve() { - _classCallCheck(this, Tw2MayaScalarCurve); + this._time += dt; - var _this = _possibleConstructorReturn(this, (Tw2MayaScalarCurve.__proto__ || Object.getPrototypeOf(Tw2MayaScalarCurve)).call(this)); + if (this.source) { + this.source.GetValueAt(this._time, this._sourcePosition); + } else if (this._useTransformsForStretch) { + this._sourcePosition[0] = this._sourceTransform[12]; + this._sourcePosition[1] = this._sourceTransform[13]; + this._sourcePosition[2] = this._sourceTransform[14]; + } - _this.index = -1; - _this.animationEngine = null; - _this.value = 0; - _this.length = 0; - return _this; - } + if (this.dest) { + this.source.GetValueAt(this._time, this._destinationPosition); + } - /** - * Sorts the curve - */ + var directionVec = _global.vec3.subtract(EveStretch.global.vec3_0, this._destinationPosition, this._sourcePosition); + this.length.value = _global.vec3.length(directionVec); + _global.vec3.normalize(directionVec, directionVec); + if (this.sourceObject && this._displaySourceObject) { + this.sourceObject.Update(dt); + } - _createClass(Tw2MayaScalarCurve, [{ - key: 'Sort', - value: function Sort() { - this.ComputeLength(); + if (this.stretchObject) { + this.stretchObject.Update(dt); + } + + if (this.destObject && this._displayDestObject) { + this.destObject.Update(dt); + } } /** - * Gets the curve's length - * @returns {number} + * Gets render batches + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator + * @param {Tw2PerObjectData} perObjectData */ }, { - key: 'GetLength', - value: function GetLength() { - return this.length; - } + key: 'GetBatches', + value: function GetBatches(mode, accumulator, perObjectData) { + if (!this.display) return; - /** - * Updates a value at a specific time - * @param {number} time - */ + if (this.sourceObject && this._displaySourceObject) { + this.sourceObject.GetBatches(mode, accumulator, perObjectData); + } - }, { - key: 'UpdateValue', - value: function UpdateValue(time) { - if (this.animationEngine) { - this.value = this.animationEngine.Evaluate(this.index, time); + if (this.destObject && this._displayDestObject) { + this.destObject.GetBatches(mode, accumulator, perObjectData); + } + + if (this.stretchObject) { + this.stretchObject.GetBatches(mode, accumulator, perObjectData); } } /** - * Computes curve Length + * Initializes class global and scratch variables */ - }, { - key: 'ComputeLength', - value: function ComputeLength() { - if (!this.animationEngine || this.animationEngine.GetNumberOfCurves() === 0) return; - if (this.index >= 0) this.length = this.animationEngine.GetLength(this.index); + }], [{ + key: 'init', + value: function init() { + if (!EveStretch.global) { + EveStretch.global = { + vec3_0: _global.vec3.create(), + vec3_1: _global.vec3.create(), + vec3_2: _global.vec3.create(), + mat4_0: _global.mat4.create(), + mat4_1: _global.mat4.create() + }; + } } }]); - return Tw2MayaScalarCurve; -}(_curves.Tw2Curve); + return EveStretch; +}(); /** - * The curve's dimension - * @type {number} + * Class global and scratch variables + * @type {{string:*}} */ -Tw2MayaScalarCurve.outputDimension = 1; - -/** - * The curve's current value property - * @type {string} - */ -Tw2MayaScalarCurve.valueProperty = 'value'; - -/** - * The curve's type - * @type {number} - */ -Tw2MayaScalarCurve.curveType = _curves.Tw2Curve.Type.CURVE_MAYA; +EveStretch.global = null; /***/ }), -/* 170 */ +/* 169 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33134,610 +33386,387 @@ Tw2MayaScalarCurve.curveType = _curves.Tw2Curve.Type.CURVE_MAYA; Object.defineProperty(exports, "__esModule", { value: true }); -exports.Tw2MayaVector3Curve = undefined; +exports.EveTurretFiringFX = exports.EvePerMuzzleData = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); - -var _curves = __webpack_require__(19); +var _global = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } +/** + * EvePerMuzzleData + * Todo: Remove reference in this.muzzlePosition + * + * @property {boolean} started + * @property {boolean} readyToStart + * @property muzzlePositionBone + * @property {mat4} muzzleTransform + * @property {vec3} muzzlePosition + * @property {number} currentStartDelay + * @property {number} constantDelay + * @property {number} elapsedTime + * @class + */ +var EvePerMuzzleData = exports.EvePerMuzzleData = function EvePerMuzzleData() { + _classCallCheck(this, EvePerMuzzleData); -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + this._id = _global.util.generateID(); + this.started = false; + this.readyToStart = false; + this.muzzlePositionBone = null; + this.muzzleTransform = _global.mat4.create(); + this.muzzlePosition = this.muzzleTransform.subarray(12, 15); + this.currentStartDelay = 0; + this.constantDelay = 0; + this.elapsedTime = 0; +}; /** - * Tw2MayaVector3Curve + * EveTurretFiringFX * - * @property {number} xIndex - * @property {number} yIndex - * @property {number} zIndex - * @property {null|Tw2MayaAnimationEngine} animationEngine + * @property {string|number} _id * @property {string} name - * @property {vec3} value - * @property {number} length + * @property {boolean} display + * @property {Array.} stretch + * @property {boolean} useMuzzleTransform + * @property {boolean} isFiring + * @property {boolean} isLoopFiring + * @property {number} firingDelay1 + * @property {number} firingDelay2 + * @property {number} firingDelay3 + * @property {number} firingDelay4 + * @property {number} firingDelay5 + * @property {number} firingDelay6 + * @property {number} firingDelay7 + * @property {number} firingDelay8 + * @property {vec3} endPosition + * @property {number} _firingDuration + * @property {Array.} _perMuzzleData + * @class */ -var Tw2MayaVector3Curve = exports.Tw2MayaVector3Curve = function (_Tw2Curve) { - _inherits(Tw2MayaVector3Curve, _Tw2Curve); - function Tw2MayaVector3Curve() { - _classCallCheck(this, Tw2MayaVector3Curve); - var _this = _possibleConstructorReturn(this, (Tw2MayaVector3Curve.__proto__ || Object.getPrototypeOf(Tw2MayaVector3Curve)).call(this)); +var EveTurretFiringFX = exports.EveTurretFiringFX = function () { + function EveTurretFiringFX() { + _classCallCheck(this, EveTurretFiringFX); - _this.xIndex = -1; - _this.yIndex = -1; - _this.zIndex = -1; - _this.animationEngine = null; - _this.value = _math.vec3.create(); - _this.length = 0; - return _this; + this._id = _global.util.generateID(); + this.name = ''; + this.display = true; + this.stretch = []; + this.useMuzzleTransform = false; + this.isFiring = false; + this.isLoopFiring = false; + this.firingDelay1 = 0; + this.firingDelay2 = 0; + this.firingDelay3 = 0; + this.firingDelay4 = 0; + this.firingDelay5 = 0; + this.firingDelay6 = 0; + this.firingDelay7 = 0; + this.firingDelay8 = 0; + this.endPosition = _global.vec3.create(); + this._firingDuration = 0; + this._perMuzzleData = []; } /** - * Sorts the curve's keys + * Initializes the turret firing fx */ - _createClass(Tw2MayaVector3Curve, [{ - key: 'Sort', - value: function Sort() { - this.ComputeLength(); + _createClass(EveTurretFiringFX, [{ + key: 'Initialize', + value: function Initialize() { + this._firingDuration = this.GetCurveDuration(); + for (var i = 0; i < this.stretch.length; ++i) { + this._perMuzzleData[i] = new EvePerMuzzleData(); + }if (this._perMuzzleData.length > 0) this._perMuzzleData[0].constantDelay = this.firingDelay1; + if (this._perMuzzleData.length > 1) this._perMuzzleData[1].constantDelay = this.firingDelay2; + if (this._perMuzzleData.length > 2) this._perMuzzleData[2].constantDelay = this.firingDelay3; + if (this._perMuzzleData.length > 3) this._perMuzzleData[3].constantDelay = this.firingDelay4; + if (this._perMuzzleData.length > 4) this._perMuzzleData[4].constantDelay = this.firingDelay5; + if (this._perMuzzleData.length > 5) this._perMuzzleData[5].constantDelay = this.firingDelay6; + if (this._perMuzzleData.length > 6) this._perMuzzleData[6].constantDelay = this.firingDelay7; + if (this._perMuzzleData.length > 7) this._perMuzzleData[7].constantDelay = this.firingDelay8; } /** - * Gets the curve's length + * Gets the total curve duration * @returns {number} */ }, { - key: 'GetLength', - value: function GetLength() { - return this.length; + key: 'GetCurveDuration', + value: function GetCurveDuration() { + var maxDuration = 0; + for (var i = 0; i < this.stretch.length; ++i) { + var stretch = this.stretch[i]; + for (var j = 0; j < stretch.curveSets.length; ++j) { + maxDuration = Math.max(maxDuration, stretch.curveSets[j].GetMaxCurveDuration()); + } + } + return maxDuration; } /** - * Updates a value at a specific time - * @param {number} time + * Gets a count of stretch effects + * @returns {Number} */ }, { - key: 'UpdateValue', - value: function UpdateValue(time) { - if (this.animationEngine) { - if (this.xIndex) { - this.value[0] = this.animationEngine.Evaluate(this.xIndex, time); - } - - if (this.yIndex) { - if (this.yIndex === this.xIndex) { - this.value[1] = this.value[0]; - } else { - this.value[1] = this.animationEngine.Evaluate(this.yIndex, time); - } - } - - if (this.zIndex) { - if (this.zIndex === this.xIndex) { - this.value[2] = this.value[0]; - } else { - this.value[2] = this.animationEngine.Evaluate(this.zIndex, time); - } - } - } + key: 'GetPerMuzzleEffectCount', + value: function GetPerMuzzleEffectCount() { + return this.stretch.length; } /** - * Computes curve Length + * Sets muzzle bone id + * @param {number} index + * @param bone */ }, { - key: 'ComputeLength', - value: function ComputeLength() { - if (!this.animationEngine || this.animationEngine.GetNumberOfCurves() === 0) return; - - this.length = 0; - if (this.xIndex >= 0) { - this.length = this.animationEngine.GetLength(this.xIndex); - } - - if (this.yIndex >= 0) { - this.length = Math.max(this.length, this.animationEngine.GetLength(this.yIndex)); - } - - if (this.zIndex >= 0) { - this.length = Math.max(this.length, this.animationEngine.GetLength(this.zIndex)); - } + key: 'SetMuzzleBoneID', + value: function SetMuzzleBoneID(index, bone) { + this._perMuzzleData[index].muzzlePositionBone = bone; } - }]); - - return Tw2MayaVector3Curve; -}(_curves.Tw2Curve); - -/** - * The curve's dimension - * @type {number} - */ - - -Tw2MayaVector3Curve.outputDimension = 3; - -/** - * The curve's current value property - * @type {string} - */ -Tw2MayaVector3Curve.valueProperty = 'value'; - -/** - * The curve's type - * @type {number} - */ -Tw2MayaVector3Curve.curveType = _curves.Tw2Curve.Type.CURVE_MAYA; - -/***/ }), -/* 171 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2MayaAnimationEngine = undefined; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _math = __webpack_require__(0); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -/** - * Tw2MayaAnimationEngine - * TODO: Complete the prototype `_EvaluteBezier` - * - * @property {number|string} id - * @property {Array} curves - * @property {Array} hermiteSegments - * @property {Array} bezierSegments - * @property {number} _currentCurveIndex - * @property _evalCache - */ -var Tw2MayaAnimationEngine = exports.Tw2MayaAnimationEngine = function () { - function Tw2MayaAnimationEngine() { - _classCallCheck(this, Tw2MayaAnimationEngine); - - this._id = _math.util.generateID(); - this.curves = []; - this.hermiteSegments = []; - this.bezierSegments = []; - this._currentCurveIndex = 0; - this._evalCache = null; - } - - /** - * Evaluate - * @param curveIndex - * @param time - * @returns {*} - */ - - - _createClass(Tw2MayaAnimationEngine, [{ - key: 'Evaluate', - value: function Evaluate(curveIndex, time) { - if (this.curves.length <= curveIndex) return 0; - - this._currentCurveIndex = curveIndex; - if (!this._evalCache) { - this._evalCache = new Array(this.curves.length); - for (var i = 0; i < this._evalCache.length; ++i) { - this._evalCache[i] = -1; - } - } - - var animCurve = this.curves[curveIndex]; - var firstSegment = animCurve[Tw2MayaAnimationEngine.AnimCurveFields.SEGMENT_OFFSET]; - var segments = null; - - if (animCurve[Tw2MayaAnimationEngine.AnimCurveFields.IS_WEIGHTED]) { - segments = this.bezierSegments; - } else { - segments = this.hermiteSegments; - } - - if (time < segments[firstSegment][Tw2MayaAnimationEngine.AnimSegment.TIME]) { - if (animCurve[Tw2MayaAnimationEngine.AnimCurveFields.PRE_INFINITY] === Tw2MayaAnimationEngine.INFINITY) { - return segments[firstSegment][Tw2MayaAnimationEngine.AnimSegment.VALUE]; - } - return this._EvaluateInfinities(animCurve, segments, firstSegment, time, true); - } - - if (time > animCurve[Tw2MayaAnimationEngine.AnimCurveFields.END_TIME]) { - if (animCurve[Tw2MayaAnimationEngine.AnimCurveFields.POST_INFINITY] === Tw2MayaAnimationEngine.INFINITY) { - return animCurve[Tw2MayaAnimationEngine.AnimCurveFields.END_VALUE]; - } - return this._EvaluateInfinities(animCurve, segments, firstSegment, time, false); - } + /** + * Gets a muzzle's transform + * @param {number} index + * @returns {mat4} + */ - return this._EvaluateImpl(animCurve, segments, firstSegment, time); + }, { + key: 'GetMuzzleTransform', + value: function GetMuzzleTransform(index) { + return this._perMuzzleData[index].muzzleTransform; } /** - * _EvaluateImpl - * @param animCurve - * @param segments - * @param firstSegment - * @param time - * @returns {*} + * Prepares the firing effect + * @param {number} delay + * @param {number} [muzzleID=-1] */ }, { - key: '_EvaluateImpl', - value: function _EvaluateImpl(animCurve, segments, firstSegment, time) { - var withinInterval = false, - nextSegment = null, - lastSegment = null, - index = void 0; - - if (this._evalCache[this._currentCurveIndex] >= 0) { - lastSegment = firstSegment + this._evalCache[this._currentCurveIndex]; - if (this._evalCache[this._currentCurveIndex] < animCurve[Tw2MayaAnimationEngine.AnimCurveFields.NUM_SEGMENTS - 1] && time > segments[lastSegment][Tw2MayaAnimationEngine.AnimSegment.TIME]) { - nextSegment = firstSegment + this._evalCache[this._currentCurveIndex] + 1; - if (time === segments[nextSegment][Tw2MayaAnimationEngine.AnimSegment.TIME]) { - this._evalCache[this._currentCurveIndex]++; - return segments[nextSegment][Tw2MayaAnimationEngine.AnimSegment.VALUE]; - } else if (time < segments[nextSegment][Tw2MayaAnimationEngine.AnimSegment.TIME]) { - index = this._evalCache[this._currentCurveIndex] + 1; - withinInterval = true; - } else { - nextSegment = null; - } - } else if (this._evalCache[this._currentCurveIndex] > 0 && time < segments[lastSegment][Tw2MayaAnimationEngine.AnimSegment.TIME]) { - var prevSegment = firstSegment + this._evalCache[this._currentCurveIndex] - 1; - if (time > segments[prevSegment][Tw2MayaAnimationEngine.AnimSegment.TIME]) { - index = this._evalCache[this._currentCurveIndex]; - withinInterval = true; - } else if (time === segments[prevSegment][Tw2MayaAnimationEngine.AnimSegment.TIME]) { - this._evalCache[this._currentCurveIndex]--; - return segments[prevSegment][Tw2MayaAnimationEngine.AnimSegment.VALUE]; - } - } - } + key: 'PrepareFiring', + value: function PrepareFiring(delay) { + var muzzleID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1; - if (!withinInterval) { - var result = this._Find(animCurve, time, segments, firstSegment); - index = result[1]; - if (result[0] || index === 0) { - if (index === animCurve[Tw2MayaAnimationEngine.AnimCurveFields.NUM_SEGMENTS]) { - index--; - this._evalCache[this._currentCurveIndex] = index; - return animCurve[Tw2MayaAnimationEngine.AnimCurveFields.END_VALUE]; - } else { - this._evalCache[this._currentCurveIndex] = index; - return segments[firstSegment + index][Tw2MayaAnimationEngine.AnimSegment.VALUE]; - } - } else if (index === animCurve[Tw2MayaAnimationEngine.AnimCurveFields.NUM_SEGMENTS] + 1) { - this._evalCache[this._currentCurveIndex] = 0; - return animCurve[Tw2MayaAnimationEngine.AnimCurveFields.END_VALUE]; + for (var i = 0; i < this.stretch.length; ++i) { + if (muzzleID < 0 || muzzleID === i) { + this._perMuzzleData[i].currentStartDelay = delay + this._perMuzzleData[i].constantDelay; + this._perMuzzleData[i].started = false; + this._perMuzzleData[i].readyToStart = false; + this._perMuzzleData[i].elapsedTime = 0; + } else { + this._perMuzzleData[i].currentStartDelay = Number.MAX_VALUE; + this._perMuzzleData[i].started = false; + this._perMuzzleData[i].readyToStart = false; + this._perMuzzleData[i].elapsedTime = 0; } } + this.isFiring = true; + } - if (this._evalCache[this._currentCurveIndex] !== index - 1) { - this._evalCache[this._currentCurveIndex] = index - 1; - lastSegment = firstSegment + this._evalCache[this._currentCurveIndex]; - if (nextSegment === null) nextSegment = firstSegment + index; - } + /** + * Starts a muzzle effect + * @param {number} muzzleID + */ - if (animCurve[Tw2MayaAnimationEngine.AnimCurveFields.IS_WEIGHTED]) { - var bSegment = segments[lastSegment]; - if (bSegment[Tw2MayaAnimationEngine.BezierSegment.IS_STEP]) { - return bSegment[Tw2MayaAnimationEngine.BezierSegment.VALUE]; - } else if (bSegment[Tw2MayaAnimationEngine.BezierSegment.IS_STEP_NEXT]) { - if (nextSegment === null) { - return animCurve[Tw2MayaAnimationEngine.AnimCurveFields.END_VALUE]; - } - return segments[nextSegment][Tw2MayaAnimationEngine.BezierSegment.VALUE]; - } else { - var nextKeyTime = animCurve[Tw2MayaAnimationEngine.AnimCurveFields.END_TIME]; - if (this._evalCache[this._currentCurveIndex] + 1 < animCurve[Tw2MayaAnimationEngine.AnimCurveFields.NUM_SEGMENTS]) { - nextKeyTime = segments[nextSegment][Tw2MayaAnimationEngine.BezierSegment.TIME]; - } - return this._EvaluateBezier(bSegment, time, nextKeyTime); - } - } else { - var hSegment = segments[lastSegment]; - if (hSegment[Tw2MayaAnimationEngine.HermiteSegment.IS_STEP]) { - return hSegment[Tw2MayaAnimationEngine.HermiteSegment.VALUE]; - } else if (hSegment[Tw2MayaAnimationEngine.HermiteSegment.IS_STEP_NEXT]) { - if (nextSegment === null) { - return animCurve[Tw2MayaAnimationEngine.AnimCurveFields.END_VALUE]; - } - return segments[nextSegment][Tw2MayaAnimationEngine.HermiteSegment.VALUE]; - } else { - return this._EvaluateHermite(hSegment, time); + }, { + key: 'StartMuzzleEffect', + value: function StartMuzzleEffect(muzzleID) { + var stretch = this.stretch[muzzleID]; + for (var i = 0; i < stretch.curveSets.length; ++i) { + var curveSet = stretch.curveSets[i]; + switch (curveSet.name) { + case 'play_start': + case 'play_loop': + curveSet.PlayFrom(-this._perMuzzleData[muzzleID].currentStartDelay); + break; + + case 'play_stop': + curveSet.Stop(); + break; } } + this._perMuzzleData[muzzleID].started = true; + this._perMuzzleData[muzzleID].readyToStart = false; } - /* eslint-disable no-unused-vars */ - /** - * A static helper function to evaluate the infinity portion of an animation curve. - * The infinity portion is the parts of the animation curve outside the range of keys. - * @param curve - The animation curve to evaluate - * @param segments - * @param startSegment - * @param {time} time - * @param {boolean} bool - false: evaluate the post-infinity portion, true: evaluate the pre-infinity portion + * Stops the firing effect */ }, { - key: '_EvaluateInfinities', - value: function _EvaluateInfinities(curve, segments, startSegment, time, bool) { + key: 'StopFiring', + value: function StopFiring() { + for (var j = 0; j < this.stretch.length; ++j) { + var stretch = this.stretch[j]; + for (var i = 0; i < stretch.curveSets.length; ++i) { + var curveSet = stretch.curveSets[i]; + switch (curveSet.name) { + case 'play_start': + case 'play_loop': + curveSet.Stop(); + break; - throw new Error('_EvaluateInfinities not implemented'); + case 'play_stop': + curveSet.Play(); + break; + } + } + this._perMuzzleData[j].started = false; + this._perMuzzleData[j].readyToStart = false; + this._perMuzzleData[j].currentStartDelay = 0; + this._perMuzzleData[j].elapsedTime = 0; + } + this.isFiring = false; } - /* eslint-enable no-unused-vars */ - /** - * _EvaluateHermite - * @param segment - * @param time - * @returns {*} + * Gets resources + * @param {Array} [out=[]} + * @returns {Array} out */ }, { - key: '_EvaluateHermite', - value: function _EvaluateHermite(segment, time) { - var t = time - segment[Tw2MayaAnimationEngine.HermiteSegment.TIME]; - var coeff = segment[Tw2MayaAnimationEngine.HermiteSegment.COEFF]; - return t * (t * (t * coeff[0] + coeff[1]) + coeff[2]) + coeff[3]; + key: 'GetResources', + value: function GetResources() { + var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + + for (var i = 0; i < this.stretch.length; i++) { + this.stretch[i].GetResources(out); + } + return out; } /** - * _EvaluateBezier - * @param segment - * @param time - * @param nextSegmentTime - * @returns {*} + * Updates view dependant data */ }, { - key: '_EvaluateBezier', - value: function _EvaluateBezier(segment, time, nextSegmentTime) { - var t = void 0, - s = void 0; - - s = (time - segment[Tw2MayaAnimationEngine.BezierSegment.TIME]) / (nextSegmentTime - segment[Tw2MayaAnimationEngine.BezierSegment.TIME]); - - if (segment[Tw2MayaAnimationEngine.BezierSegment.IS_LINEAR]) { - t = s; - } else { - var _poly = _math.vec4.create(); - _poly[3] = segment[Tw2MayaAnimationEngine.BezierSegment.COEFF][3]; - _poly[2] = segment[Tw2MayaAnimationEngine.BezierSegment.COEFF][2]; - _poly[1] = segment[Tw2MayaAnimationEngine.BezierSegment.COEFF][1]; - _poly[0] = segment[Tw2MayaAnimationEngine.BezierSegment.COEFF][0] - s; - var roots = []; - if (_math.curve.polyZeroes(_poly, 3, 0.0, 1, 1.0, 1, roots) === 1) t = roots[0];else t = 0.0; + key: 'UpdateViewDependentData', + value: function UpdateViewDependentData() { + for (var i = 0; i < this.stretch.length; ++i) { + this.stretch[i].UpdateViewDependentData(); } - - var poly = segment[Tw2MayaAnimationEngine.BezierSegment.POLYY]; - return t * (t * (t * poly[3] + poly[2]) + poly[1]) + poly[0]; } /** - * _Find - * @param animCurve - * @param time - * @param segments - * @param firstSegment - * @returns {*} + * Per frame update + * @param {number} dt - Delta time */ }, { - key: '_Find', - value: function _Find(animCurve, time, segments, firstSegment) { - var len = void 0, - mid = void 0, - low = void 0, - high = void 0; - - /* use a binary search to find the key */ - var index = 0; - len = animCurve[Tw2MayaAnimationEngine.AnimCurveFields.NUM_SEGMENTS] + 1; - var segment = null; - var stime = 0.0; + key: 'Update', + value: function Update(dt) { + for (var i = 0; i < this.stretch.length; ++i) { + if (this._perMuzzleData[i].started) { + this._perMuzzleData[i].elapsedTime += dt; + } - if (len > 0) { - low = 0; - high = len - 1; - do { - mid = low + high >> 1; - if (mid < len - 1) { - segment = firstSegment + mid; - stime = segments[segment][Tw2MayaAnimationEngine.AnimSegment.TIME]; - } else { - stime = animCurve[Tw2MayaAnimationEngine.AnimCurveFields.END_TIME]; - } + if (this._perMuzzleData[i].elapsedTime < this._firingDuration || this.isLoopFiring) { + if (this.isFiring) { + if (!this._perMuzzleData[i].started) { + if (this._perMuzzleData[i].readyToStart) { + this.StartMuzzleEffect(i); + this._perMuzzleData[i].currentStartDelay = 0; + this._perMuzzleData[i].elapsedTime = 0; + } else { + this._perMuzzleData[i].currentStartDelay -= dt; + } - if (time < stime) { - high = mid - 1; - } else if (time > stime) { - low = mid + 1; - } else { - index = mid; - return [true, index]; + if (this._perMuzzleData[i].currentStartDelay <= 0) { + this._perMuzzleData[i].readyToStart = true; + } + } else { + if (this.useMuzzleTransform) { + this.stretch[i].SetSourceTransform(this._perMuzzleData[i].muzzleTransform); + } else { + this.stretch[i].SetSourcePosition(this._perMuzzleData[i].muzzlePosition); + } + this.stretch[i].SetDestinationPosition(this.endPosition); + this.stretch[i].SetIsNegZForward(true); + } } - } while (low <= high); - index = low; + } + this.stretch[i].Update(dt); } - return [false, index]; - } - - /** - * Returns the total number of curves - * @returns {number} - */ - - }, { - key: 'GetNumberOfCurves', - value: function GetNumberOfCurves() { - return this.curves.length; } /** - * Gets specific curve's length - * @property {number} index - * @returns {number} + * Gets render batches + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator + * @param {Tw2PerObjectData} perObjectData */ }, { - key: 'GetLength', - value: function GetLength(index) { - if (index < 0 || index >= this.curves.length) return 0; - var curve = this.curves[index]; - var firstSegment = void 0; + key: 'GetBatches', + value: function GetBatches(mode, accumulator, perObjectData) { + if (!this.display || !this.isFiring) return; - if (curve[Tw2MayaAnimationEngine.AnimCurveFields.IS_WEIGHTED]) { - firstSegment = this.bezierSegments[curve[Tw2MayaAnimationEngine.AnimCurveFields.SEGMENT_OFFSET]]; - } else { - firstSegment = this.hermiteSegments[curve[Tw2MayaAnimationEngine.AnimCurveFields.SEGMENT_OFFSET]]; + for (var i = 0; i < this.stretch.length; ++i) { + if (this._perMuzzleData[i].started && (this._firingDuration >= this._perMuzzleData[i].elapsedTime || this.isLoopFiring)) { + this.stretch[i].GetBatches(mode, accumulator, perObjectData); + } } - - return curve[Tw2MayaAnimationEngine.AnimCurveFields.END_TIME] - firstSegment[Tw2MayaAnimationEngine.AnimSegment.TIME]; } }]); - return Tw2MayaAnimationEngine; + return EveTurretFiringFX; }(); -Tw2MayaAnimationEngine.AnimCurveFields = { - NUM_SEGMENTS: 0, - SEGMENT_OFFSET: 1, - END_TIME: 2, - END_VALUE: 3, - IN_TANGENT: 4, - OUT_TANGENT: 5, - PRE_INFINITY: 6, - POST_INFINITY: 7, - IS_WEIGHTED: 8 -}; - -Tw2MayaAnimationEngine.AnimSegment = { - TIME: 0, - VALUE: 1 -}; - -Tw2MayaAnimationEngine.HermiteSegment = { - TIME: 0, - VALUE: 1, - COEFF: 2, - IS_STEP: 3, - IS_STEP_NEXT: 4 -}; - -Tw2MayaAnimationEngine.BezierSegment = { - TIME: 0, - VALUE: 1, - COEFF: 2, - POLYY: 3, - IS_STEP: 4, - IS_STEP_NEXT: 5, - IS_LINEAR: 6 -}; - -Tw2MayaAnimationEngine.INFINITY = 0; - /***/ }), -/* 172 */ +/* 170 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _child = __webpack_require__(58); - -Object.keys(_child).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _child[key]; - } - }); -}); - -var _effect = __webpack_require__(178); - -Object.keys(_effect).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _effect[key]; - } - }); -}); - -var _object = __webpack_require__(60); - -Object.keys(_object).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _object[key]; - } - }); -}); - -var _item = __webpack_require__(63); - -Object.keys(_item).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _item[key]; - } - }); + value: true }); +exports.EveStarField = undefined; -var _EveSpaceScene = __webpack_require__(195); +var _global = __webpack_require__(0); -Object.keys(_EveSpaceScene).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _EveSpaceScene[key]; - } - }); -}); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var _EveSOF = __webpack_require__(196); +/** + * EveStarField - not implemented yet + * + * @property {string|number} _id + * @property {string} name + * @property {boolean} display + * @property {Tw2Effect} effect + * @property {number} maxDist + * @property {number} maxFlashRate + * @property {number} minFlashIntensity + * @property {number} minFlashRate + * @property {number} seed + */ +var EveStarField = exports.EveStarField = function EveStarField() { + _classCallCheck(this, EveStarField); -Object.keys(_EveSOF).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _EveSOF[key]; - } - }); -}); + this._id = _global.util.generateID(); + this.name = ''; + this.display = true; + this.effect = null; + this.maxDist = 0; + this.maxFlashRate = 0; + this.minFlashIntensity = 0; + this.minFlashRate = 0; + this.seed = 20; +}; /***/ }), -/* 173 */ +/* 171 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33746,17 +33775,15 @@ Object.keys(_EveSOF).forEach(function (key) { Object.defineProperty(exports, "__esModule", { value: true }); -exports.EveChildBillboard = undefined; +exports.EveEffectRoot = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); var _core = __webpack_require__(1); -var _EveChild2 = __webpack_require__(14); +var _EveObject2 = __webpack_require__(11); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -33765,174 +33792,129 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Mesh attachment to space object and oriented towards the camera + * EveEffectRoot root objects for FX, can be put into scene's objects array * - * @property {Tw2Mesh|Tw2InstancedMesh} mesh - * @property {Tw2BasicPerObjectData} _perObjectData + * @property {string} name + * @property {boolean} display + * @property {[{}]} curveSets + * @property {[{}]} effectChildren + * @property {vec3} scaling + * @property {quat} rotation + * @property {vec3} translation + * @property {mat4} localTransform + * @property {mat4} rotationTransform + * @property {vec3} boundingSphereCenter + * @property {number} boundingSphereRadius + * @property {number} duration + * @property {Tw2PerObjectData} _perObjectData * @class */ -var EveChildBillboard = exports.EveChildBillboard = function (_EveChild) { - _inherits(EveChildBillboard, _EveChild); +var EveEffectRoot = exports.EveEffectRoot = function (_EveObject) { + _inherits(EveEffectRoot, _EveObject); - function EveChildBillboard() { - _classCallCheck(this, EveChildBillboard); + function EveEffectRoot() { + _classCallCheck(this, EveEffectRoot); - var _this = _possibleConstructorReturn(this, (EveChildBillboard.__proto__ || Object.getPrototypeOf(EveChildBillboard)).call(this)); + var _this = _possibleConstructorReturn(this, (EveEffectRoot.__proto__ || Object.getPrototypeOf(EveEffectRoot)).call(this)); - _this.mesh = null; - _this._perObjectData = new _core.Tw2BasicPerObjectData(); - _this._perObjectData.perObjectFFEData = new _core.Tw2RawData(); - _this._perObjectData.perObjectFFEData.Declare('world', 16); - _this._perObjectData.perObjectFFEData.Declare('worldInverseTranspose', 16); - _this._perObjectData.perObjectFFEData.Create(); + _this.curveSets = []; + _this.effectChildren = []; + _this.duration = 0; + _this.scaling = _global.vec3.fromValues(1, 1, 1); + _this.rotation = _global.quat.create(); + _this.translation = _global.vec3.create(); + _this.localTransform = _global.mat4.create(); + _this.rotationTransform = _global.mat4.create(); + _this.boundingSphereCenter = _global.vec3.create(); + _this.boundingSphereRadius = 0; + + _this._perObjectData = new _core.Tw2PerObjectData(); + _this._perObjectData.perObjectVSData = new _core.Tw2RawData(); + _this._perObjectData.perObjectVSData.Declare('WorldMat', 16); + _this._perObjectData.perObjectVSData.Declare('WorldMatLast', 16); + _this._perObjectData.perObjectVSData.Declare('Shipdata', 4); + _this._perObjectData.perObjectVSData.Declare('Clipdata1', 4); + _this._perObjectData.perObjectVSData.Declare('EllipsoidRadii', 4); + _this._perObjectData.perObjectVSData.Declare('EllipsoidCenter', 4); + _this._perObjectData.perObjectVSData.Declare('CustomMaskMatrix0', 16); + _this._perObjectData.perObjectVSData.Declare('CustomMaskMatrix1', 16); + _this._perObjectData.perObjectVSData.Declare('CustomMaskData0', 4); + _this._perObjectData.perObjectVSData.Declare('CustomMaskData1', 4); + _this._perObjectData.perObjectVSData.Declare('JointMat', 696); + _this._perObjectData.perObjectVSData.Create(); + + _this._perObjectData.perObjectPSData = new _core.Tw2RawData(); + _this._perObjectData.perObjectPSData.Declare('Shipdata', 4); + _this._perObjectData.perObjectPSData.Declare('Clipdata1', 4); + _this._perObjectData.perObjectPSData.Declare('Clipdata2', 4); + _this._perObjectData.perObjectPSData.Declare('ShLighting', 4 * 7); + _this._perObjectData.perObjectPSData.Declare('CustomMaskMaterialID0', 4); + _this._perObjectData.perObjectPSData.Declare('CustomMaskMaterialID1', 4); + _this._perObjectData.perObjectPSData.Declare('CustomMaskTarget0', 4); + _this._perObjectData.perObjectPSData.Declare('CustomMaskTarget1', 4); + _this._perObjectData.perObjectPSData.Create(); return _this; } /** - * Gets the child's resources - * @param {Array} [out=[]] - * @returns {Array.} out + * Starts playing the effectRoot's curveSets if they exist */ - _createClass(EveChildBillboard, [{ - key: 'GetResources', - value: function GetResources(out) { - if (this.mesh) this.mesh.GetResources(out); - return out; + _createClass(EveEffectRoot, [{ + key: 'Start', + value: function Start() { + for (var i = 0; i < this.curveSets.length; ++i) { + this.curveSets[i].Play(); + } } /** - * Per frame update - * @param {number} dt - * @param {mat4} parentTransform + * Stops the effectRoot's curveSets from playing */ }, { - key: 'Update', - value: function Update(dt, parentTransform) { - _get(EveChildBillboard.prototype.__proto__ || Object.getPrototypeOf(EveChildBillboard.prototype), 'Update', this).call(this, dt, parentTransform); - - var viewInverse = _EveChild2.EveChild.global.mat4_0, - finalScale = _EveChild2.EveChild.global.vec3_0; - - _math.mat4.lookAt(viewInverse, _core.device.eyePosition, this.worldTransform.subarray(12), [0, 1, 0]); - _math.mat4.transpose(viewInverse, viewInverse); - _math.mat4.getScaling(finalScale, parentTransform); - _math.vec3.multiply(finalScale, finalScale, this.scaling); - - this.worldTransform[0] = viewInverse[0] * finalScale[0]; - this.worldTransform[1] = viewInverse[1] * finalScale[0]; - this.worldTransform[2] = viewInverse[2] * finalScale[0]; - this.worldTransform[4] = viewInverse[4] * finalScale[1]; - this.worldTransform[5] = viewInverse[5] * finalScale[1]; - this.worldTransform[6] = viewInverse[6] * finalScale[1]; - this.worldTransform[8] = viewInverse[8] * finalScale[2]; - this.worldTransform[9] = viewInverse[9] * finalScale[2]; - this.worldTransform[10] = viewInverse[10] * finalScale[2]; + key: 'Stop', + value: function Stop() { + for (var i = 0; i < this.curveSets.length; ++i) { + this.curveSets[i].Stop(); + } } /** - * Gets render batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator + * Gets effect root res objects + * @param {Array} [out=[]] - Optional receiving array + * @returns {Array.} [out] */ }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator) { - if (this.display && this.mesh) { - _math.mat4.transpose(this._perObjectData.perObjectFFEData.Get('world'), this.worldTransform); - _math.mat4.invert(this._perObjectData.perObjectFFEData.Get('worldInverseTranspose'), this.worldTransform); - this.mesh.GetBatches(mode, accumulator, this._perObjectData); - } - } - }]); - - return EveChildBillboard; -}(_EveChild2.EveChild); - -/***/ }), -/* 174 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.EveChildContainer = undefined; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - -var _EveChild2 = __webpack_require__(14); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * Container for other child effects - * - * @parameter {Array.<{}>} objects - * @parameter {Array.} curveSets - * @class - */ -var EveChildContainer = exports.EveChildContainer = function (_EveChild) { - _inherits(EveChildContainer, _EveChild); - - function EveChildContainer() { - _classCallCheck(this, EveChildContainer); - - var _this = _possibleConstructorReturn(this, (EveChildContainer.__proto__ || Object.getPrototypeOf(EveChildContainer)).call(this)); - - _this.objects = []; - _this.curveSets = []; - return _this; - } - - /** - * Gets the child's resources - * @param {Array} [out=[]] - * @returns {Array} out - */ - - - _createClass(EveChildContainer, [{ key: 'GetResources', value: function GetResources() { var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - for (var i = 0; i < this.objects.length; i++) { - if ('GetResources' in this.objects[i]) { - this.objects[i].GetResources(out); - } + for (var i = 0; i < this.effectChildren.length; ++i) { + this.effectChildren[i].GetResources(out); } return out; } /** - * Per frame update - * @param {number} dt - * @param {mat4} parentTransform + * Internal per frame update + * @param {number} dt - Delta Time */ }, { key: 'Update', - value: function Update(dt, parentTransform) { - _get(EveChildContainer.prototype.__proto__ || Object.getPrototypeOf(EveChildContainer.prototype), 'Update', this).call(this, dt, parentTransform); + value: function Update(dt) { + _global.quat.normalize(this.rotation, this.rotation); // Don't really need to normalize... + _global.mat4.fromRotationTranslationScale(this.localTransform, this.rotation, this.translation, this.scaling); - for (var i = 0; i < this.curveSets.length; i++) { + for (var i = 0; i < this.curveSets.length; ++i) { this.curveSets[i].Update(dt); } - for (var _i = 0; _i < this.objects.length; _i++) { - this.objects[_i].Update(dt, this.worldTransform); + for (var _i = 0; _i < this.effectChildren.length; ++_i) { + this.effectChildren[_i].Update(dt, this.localTransform); } } @@ -33940,62 +33922,24 @@ var EveChildContainer = exports.EveChildContainer = function (_EveChild) { * Gets render batches * @param {number} mode * @param {Tw2BatchAccumulator} accumulator - * @param {Tw2PerObjectData} perObjectData */ }, { key: 'GetBatches', - value: function GetBatches(mode, accumulator, perObjectData) { - if (this.display) { - for (var i = 0; i < this.objects.length; i++) { - this.objects[i].GetBatches(mode, accumulator, perObjectData); - } + value: function GetBatches(mode, accumulator) { + if (!this.display) return; + + for (var i = 0; i < this.effectChildren.length; ++i) { + this.effectChildren[i].GetBatches(mode, accumulator, this._perObjectData); } } }]); - return EveChildContainer; -}(_EveChild2.EveChild); - -/***/ }), -/* 175 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.EveChildExplosion = undefined; - -var _EveChild2 = __webpack_require__(14); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/** - * 'Complex' explosion object. Not implemented. - * - * @class - */ -var EveChildExplosion = exports.EveChildExplosion = function (_EveChild) { - _inherits(EveChildExplosion, _EveChild); - - function EveChildExplosion() { - _classCallCheck(this, EveChildExplosion); - - return _possibleConstructorReturn(this, (EveChildExplosion.__proto__ || Object.getPrototypeOf(EveChildExplosion)).call(this)); - } - - return EveChildExplosion; -}(_EveChild2.EveChild); + return EveEffectRoot; +}(_EveObject2.EveObject); /***/ }), -/* 176 */ +/* 172 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -34004,15 +33948,15 @@ var EveChildExplosion = exports.EveChildExplosion = function (_EveChild) { Object.defineProperty(exports, "__esModule", { value: true }); -exports.EveChildMesh = undefined; +exports.EveMissile = exports.EveMissileWarhead = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); var _core = __webpack_require__(1); -var _EveChild2 = __webpack_require__(14); +var _EveObject2 = __webpack_require__(11); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -34021,273 +33965,392 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Mesh attachment to space object + * EveMissileWarhead * - * @property {Tw2Mesh|Tw2InstancedMesh} mesh - * @property {boolean} useSpaceObjectData + * @property {String} name + * @property {Boolean} display + * @property {Tw2Mesh} mesh + * @property {EveSpriteSet} spriteSet + * @property {Number} state + * @property {Number} time + * @property {Number} durationEjectPhase + * @property {Number} startEjectVelocity + * @property {Number} acceleration + * @property {Number} maxExplosionDistance + * @property {Number} impactSize + * @property {Number} impactDuration + * @property {vec3} pathOffset + * @property {mat4} transform + * @property {vec3} velocity + * @property {Tw2PerObjectData} _perObjectData * @class */ -var EveChildMesh = exports.EveChildMesh = function (_EveChild) { - _inherits(EveChildMesh, _EveChild); +var EveMissileWarhead = exports.EveMissileWarhead = function (_EveObject) { + _inherits(EveMissileWarhead, _EveObject); - function EveChildMesh() { - _classCallCheck(this, EveChildMesh); + function EveMissileWarhead() { + _classCallCheck(this, EveMissileWarhead); - var _this = _possibleConstructorReturn(this, (EveChildMesh.__proto__ || Object.getPrototypeOf(EveChildMesh)).call(this)); + var _this = _possibleConstructorReturn(this, (EveMissileWarhead.__proto__ || Object.getPrototypeOf(EveMissileWarhead)).call(this)); _this.mesh = null; - _this.useSpaceObjectData = true; + _this.spriteSet = null; + _this.state = EveMissileWarhead.State.READY; + _this.time = 0; + _this.durationEjectPhase = 0; + _this.startEjectVelocity = 0; + _this.acceleration = 1; + _this.maxExplosionDistance = 40; + _this.impactSize = 0; + _this.impactDuration = 0.6; + _this.pathOffset = _global.vec3.create(); + _this.transform = _global.mat4.create(); + _this.velocity = _global.vec3.create(); + + _this._perObjectData = new _core.Tw2PerObjectData(); + _this._perObjectData.perObjectVSData = new _core.Tw2RawData(); + _this._perObjectData.perObjectVSData.Declare('WorldMat', 16); + _this._perObjectData.perObjectVSData.Declare('WorldMatLast', 16); + _this._perObjectData.perObjectVSData.Declare('Shipdata', 4); + _this._perObjectData.perObjectVSData.Declare('Clipdata1', 4); + _this._perObjectData.perObjectVSData.Create(); + + _this._perObjectData.perObjectPSData = new _core.Tw2RawData(); + _this._perObjectData.perObjectPSData.Declare('Shipdata', 4); + _this._perObjectData.perObjectPSData.Declare('Clipdata1', 4); + _this._perObjectData.perObjectPSData.Declare('Clipdata2', 4); + _this._perObjectData.perObjectPSData.Create(); + + _this._perObjectData.perObjectVSData.Get('Shipdata')[1] = 1; + _this._perObjectData.perObjectPSData.Get('Shipdata')[1] = 1; + _this._perObjectData.perObjectVSData.Get('Shipdata')[3] = -10; + _this._perObjectData.perObjectPSData.Get('Shipdata')[3] = 1; return _this; } /** - * Gets the child's resources - * @param {Array} [out=[]] - * @returns {Array.} out + * Initializes the warhead */ - _createClass(EveChildMesh, [{ - key: 'GetResources', - value: function GetResources(out) { - if (this.mesh) this.mesh.GetResources(out); - return out; + _createClass(EveMissileWarhead, [{ + key: 'Initialize', + value: function Initialize() { + if (this.spriteSet) this.spriteSet.UseQuads(true); } /** - * Gets render batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator - * @param {Tw2PerObjectData} perObjectData + * Sets up the warhead for rendering + * @param {mat4} transform - Initial local to world transform */ }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator, perObjectData) { - if (!this.display || !this.mesh) return; + key: 'Launch', + value: function Launch(transform) { + _global.mat4.copy(this.transform, transform); + this.velocity[0] = transform[8] * this.startEjectVelocity; + this.velocity[1] = transform[9] * this.startEjectVelocity; + this.velocity[2] = transform[10] * this.startEjectVelocity; + this.time = 0; + this.state = EveMissileWarhead.State.IN_FLIGHT; + } - if (this.useSpaceObjectData) { - if (!this._perObjectData) { - this._perObjectData = new _core.Tw2PerObjectData(); - this._perObjectData.perObjectVSData = new _core.Tw2RawData(); - this._perObjectData.perObjectVSData.data = new Float32Array(perObjectData.perObjectVSData.data.length); + /** + * Creates a clone of the warhead + * @returns {EveMissileWarhead} + */ - this._perObjectData.perObjectVSData.data[33] = 1; - this._perObjectData.perObjectVSData.data[35] = 1; + }, { + key: 'Clone', + value: function Clone() { + var warhead = new EveMissileWarhead(); + warhead.mesh = this.mesh; + warhead.spriteSet = this.spriteSet; + return warhead; + } - this._perObjectData.perObjectPSData = new _core.Tw2RawData(); - this._perObjectData.perObjectPSData.data = new Float32Array(perObjectData.perObjectPSData.data.length); + /** + * Gets warhead resources + * @param {Array} [out=[]] - Receiving array + * @returns {Array} out + */ - this._perObjectData.perObjectPSData.data[1] = 1; - this._perObjectData.perObjectPSData.data[3] = 1; - } - this._perObjectData.perObjectVSData.data.set(perObjectData.perObjectVSData.data); - this._perObjectData.perObjectPSData.data.set(perObjectData.perObjectPSData.data); + }, { + key: 'GetResources', + value: function GetResources() { + var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - _math.mat4.transpose(this._perObjectData.perObjectVSData.data, this.worldTransform); - _math.mat4.transpose(this._perObjectData.perObjectVSData.data.subarray(16), this.worldTransformLast); - } else { - if (!this._perObjectData) { - this._perObjectData = new _core.Tw2BasicPerObjectData(); - this._perObjectData.perObjectFFEData = new _core.Tw2RawData(); - this._perObjectData.perObjectFFEData.Declare('world', 16); - this._perObjectData.perObjectFFEData.Declare('worldInverseTranspose', 16); - this._perObjectData.perObjectFFEData.Create(); - } - _math.mat4.transpose(this._perObjectData.perObjectFFEData.Get('world'), this.worldTransform); - _math.mat4.invert(this._perObjectData.perObjectFFEData.Get('worldInverseTranspose'), this.worldTransform); - } + if (this.mesh) this.mesh.GetResources(out); + if (this.spriteSet) this.spriteSet.GetResources(out); + } - this.mesh.GetBatches(mode, accumulator, this._perObjectData); + /** + * Per frame view dependent data update + */ + + }, { + key: 'UpdateViewDependentData', + value: function UpdateViewDependentData() { + if (!this.display || this.state === EveMissileWarhead.State.DEAD) return; + _global.mat4.transpose(this._perObjectData.perObjectVSData.Get('WorldMat'), this.transform); + _global.mat4.transpose(this._perObjectData.perObjectVSData.Get('WorldMatLast'), this.transform); } - }]); - return EveChildMesh; -}(_EveChild2.EveChild); + /** + * Per frame update + * @param {Number} dt - Time since previous frame + * @param {vec3} missilePosition - Missile position + * @param {vec3} missileTarget - Missile target position + */ -/***/ }), -/* 177 */ -/***/ (function(module, exports, __webpack_require__) { + }, { + key: 'Update', + value: function Update(dt, missilePosition, missileTarget) { + if (this.state === EveMissileWarhead.State.IN_FLIGHT) { + var g = EveMissileWarhead.global, + position = _global.mat4.getTranslation(g.vec3_0, this.transform), + tmp = g.vec3_1, + x = g.vec3_2, + y = g.vec3_3; -"use strict"; + this.time += dt; + if (this.time > this.durationEjectPhase) { + _global.vec3.subtract(position, this.velocity, missilePosition); + _global.vec3.lerp(position, position, missilePosition, 1 - Math.exp(-dt * 0.9999)); + _global.mat4.setTranslation(this.transform, position); + _global.vec3.subtract(tmp, missileTarget, position); + if (_global.vec3.length(tmp) < this.maxExplosionDistance) { + console.log(position, tmp); + this.state = EveMissileWarhead.State.DEAD; + } + } else { + _global.vec3.scale(tmp, this.velocity, dt); + this.transform[12] += tmp[0]; + this.transform[13] += tmp[1]; + this.transform[14] += tmp[2]; + } + var z = _global.vec3.normalize(tmp, this.velocity); -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.EveChildParticleSystem = undefined; + if (Math.abs(z[0]) < 0.99) { + _global.vec3.cross(x, z, [1, 0, 0]); + } else { + _global.vec3.cross(x, z, [0, 1, 0]); + } -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + _global.vec3.normalize(x, x); + _global.vec3.cross(y, x, z); + this.transform[0] = x[0]; + this.transform[1] = x[1]; + this.transform[2] = x[2]; + this.transform[4] = y[0]; + this.transform[5] = y[1]; + this.transform[6] = y[2]; + this.transform[8] = z[0]; + this.transform[9] = z[1]; + this.transform[10] = z[2]; + } -var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + if (this.spriteSet) { + this.spriteSet.Update(dt); + } + } + + /** + * Accumulates render batches + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator + */ -var _math = __webpack_require__(0); + }, { + key: 'GetBatches', + value: function GetBatches(mode, accumulator) { + if (this.display && this.mesh && this.state !== EveMissileWarhead.State.DEAD) { + if (this.mesh) { + this.mesh.GetBatches(mode, accumulator, this._perObjectData); + } -var _core = __webpack_require__(1); + if (this.spriteSet) { + this.spriteSet.GetBatches(mode, accumulator, this._perObjectData, this.transform); + } + } + } + }]); -var _EveChild2 = __webpack_require__(14); + return EveMissileWarhead; +}(_EveObject2.EveObject); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +/** + * Missile warhead states + * @type {{READY: number, IN_FLIGHT: number, DEAD: number}} + */ -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } +EveMissileWarhead.State = { + READY: 0, + IN_FLIGHT: 1, + DEAD: 2 +}; /** - * Particle system attachment to space object + * EveMissile * - * @property {Tw2Mesh} mesh - * @property {Array} particleEmitters - * @property {Array} particleSystems - * @property {Tw2BasicPerObjectData} _perObjectData + * @property {number|string} _id + * @property {String} name + * @property {Boolean} display + * @property {Array} warheads + * @property {Array} curveSets + * @property {vec3} boundingSphereCenter + * @property {Number} boundingSphereRadius + * @property {vec3} position + * @property {vec3} target + * @property {Number} speed + * @property {?function(EveMissileWarhead): void} warheadExplosionCallback + * @property {?function(EveMissile): void} missileFinishedCallback * @class */ -var EveChildParticleSystem = exports.EveChildParticleSystem = function (_EveChild) { - _inherits(EveChildParticleSystem, _EveChild); - function EveChildParticleSystem() { - _classCallCheck(this, EveChildParticleSystem); +var EveMissile = exports.EveMissile = function () { + function EveMissile() { + _classCallCheck(this, EveMissile); - var _this = _possibleConstructorReturn(this, (EveChildParticleSystem.__proto__ || Object.getPrototypeOf(EveChildParticleSystem)).call(this)); + this._id = _global.util.generateID(); + this.name = ''; + this.display = true; + this.warheads = []; + this.curveSets = []; + this.speed = 1; + this.position = _global.vec3.create(); + this.target = _global.vec3.create(); + this.boundingSphereCenter = _global.vec3.create(); + this.boundingSphereRadius = 0; + this.warheadExplosionCallback = null; + this.missileFinishedCallback = null; - _this.mesh = null; - _this.particleEmitters = []; - _this.particleSystems = []; - _this._perObjectData = new _core.Tw2BasicPerObjectData(); - _this._perObjectData.perObjectFFEData = new _core.Tw2RawData(); - _this._perObjectData.perObjectFFEData.Declare('world', 16); - _this._perObjectData.perObjectFFEData.Declare('worldInverseTranspose', 16); - _this._perObjectData.perObjectFFEData.Create(); - return _this; + EveMissile.init(); } /** - * Gets the child's resources - * @param {Array} [out=[]] - * @returns {Array.} out + * Prepares missile for rendering + * @param {vec3} position - Missile starting position + * @param {Array} turretTransforms - Turret muzzle local to world transforms + * @param {vec3} target - Target position */ - _createClass(EveChildParticleSystem, [{ - key: 'GetResources', - value: function GetResources(out) { - if (this.mesh) this.mesh.GetResources(out); - return out; + _createClass(EveMissile, [{ + key: 'Launch', + value: function Launch(position, turretTransforms, target) { + _global.vec3.copy(this.position, position); + _global.vec3.copy(this.target, target); + + if (this.warheads.length > turretTransforms.length) { + this.warheads.splice(turretTransforms.length); + } else { + while (this.warheads.length < turretTransforms.length) { + this.warheads.push(this.warheads[0].Clone()); + } + } + + for (var i = 0; i < this.warheads.length; ++i) { + this.warheads[0].Launch(turretTransforms[i]); + } } /** - * Per frame update - * @param {number} dt - * @param {mat4} parentTransform + * Gets missile res objects + * @param {Array} [out=[]] - Receiving array + * @returns {Array} out */ }, { - key: 'Update', - value: function Update(dt, parentTransform) { - _get(EveChildParticleSystem.prototype.__proto__ || Object.getPrototypeOf(EveChildParticleSystem.prototype), 'Update', this).call(this, dt, parentTransform); - - for (var i = 0; i < this.particleEmitters.length; ++i) { - this.particleEmitters[i].Update(dt); - } + key: 'GetResources', + value: function GetResources() { + var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - for (var _i = 0; _i < this.particleSystems.length; ++_i) { - this.particleSystems[_i].Update(dt); + for (var i = 0; i < this.warheads.length; ++i) { + this.warheads[i].GetResources(out); } } /** - * Gets render batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator + * Per frame view dependent data update */ }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator) { - if (this.display && this.mesh) { - _math.mat4.transpose(this._perObjectData.perObjectFFEData.Get('world'), this.worldTransform); - _math.mat4.invert(this._perObjectData.perObjectFFEData.Get('worldInverseTranspose'), this.worldTransform); - this.mesh.GetBatches(mode, accumulator, this._perObjectData); + key: 'UpdateViewDependentData', + value: function UpdateViewDependentData() { + for (var i = 0; i < this.warheads.length; ++i) { + this.warheads[i].UpdateViewDependentData(); } } - }]); - - return EveChildParticleSystem; -}(_EveChild2.EveChild); - -/***/ }), -/* 178 */ -/***/ (function(module, exports, __webpack_require__) { -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); + /** + * Per frame update + * @param {Number} dt - Time since previous frame + */ -var _EveLensflare = __webpack_require__(179); + }, { + key: 'Update', + value: function Update(dt) { + var tmp = _global.vec3.subtract(EveMissileWarhead.global.vec3_0, this.target, this.position), + distance = _global.vec3.length(tmp); -Object.keys(_EveLensflare).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _EveLensflare[key]; - } - }); -}); + if (distance > 0.1) { + _global.vec3.normalize(tmp, tmp); + _global.vec3.scale(tmp, tmp, Math.min(dt * this.speed, distance)); + _global.vec3.add(this.position, this.position, tmp); + } -var _EveMeshOverlayEffect = __webpack_require__(180); + for (var i = 0; i < this.curveSets.length; ++i) { + this.curveSets[i].Update(dt); + } -Object.keys(_EveMeshOverlayEffect).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _EveMeshOverlayEffect[key]; - } - }); -}); + var checkDead = false; + for (var _i = 0; _i < this.warheads.length; ++_i) { + var state = this.warheads[_i].state; + this.warheads[_i].Update(dt, this.position, this.target); -var _EveOccluder = __webpack_require__(59); + if (state !== EveMissileWarhead.State.DEAD && this.warheads[_i].state === EveMissileWarhead.State.DEAD) { + if (this.warheadExplosionCallback) { + this.warheadExplosionCallback(this.warheads[_i]); + } + checkDead = true; + } + } -Object.keys(_EveOccluder).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _EveOccluder[key]; - } - }); -}); + if (checkDead && this.missileFinishedCallback) { + for (var _i2 = 0; _i2 < this.warheads.length; ++_i2) { + if (this.warheads[_i2].state !== EveMissileWarhead.State.DEAD) { + return; + } + } + this.missileFinishedCallback(this); + } + } -var _EveStretch = __webpack_require__(181); + /** + * Accumulates render batches + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator + */ -Object.keys(_EveStretch).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _EveStretch[key]; - } - }); -}); + }, { + key: 'GetBatches', + value: function GetBatches(mode, accumulator) { + if (!this.display) return; -var _EveTurretFiringFX = __webpack_require__(182); + for (var i = 0; i < this.warheads.length; ++i) { + this.warheads[i].GetBatches(mode, accumulator); + } + } + }]); -Object.keys(_EveTurretFiringFX).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _EveTurretFiringFX[key]; - } - }); -}); + return EveMissile; +}(); /***/ }), -/* 179 */ +/* 173 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -34296,339 +34359,325 @@ Object.keys(_EveTurretFiringFX).forEach(function (key) { Object.defineProperty(exports, "__esModule", { value: true }); -exports.EveLensflare = undefined; +exports.EvePlanet = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); var _core = __webpack_require__(1); -var _EveOccluder = __webpack_require__(59); +var _EveTransform = __webpack_require__(62); + +var _EveObject2 = __webpack_require__(11); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + /** - * EveLensFlare + * EvePlanet * - * @property {number|string} _id - * @property {String} name= + * @property {string} name * @property {boolean} display - * @property {boolean} update - * @property {boolean} doOcclusionQueries - * @property {number} cameraFactor - * @property {vec3} position - * @property {Array} flares - * @property {Array.} occluders - * @property {Array.} backgroundOccluders - * @property {number} occlusionIntensity - * @property {number} backgroundOcclusionIntensity - * @property {Array} distanceToEdgeCurves - * @property {Array} distanceToCenterCurves - * @property {Array} radialAngleCurves - * @property {Array} xDistanceToCenter - * @property {Array} yDistanceToCenter - * @property {Array} bindings - * @property {Array.} curveSets - * @property {?Tw2Mesh} mesh - * @property {vec3} _direction - * @property {mat4} _transform - * @property {*} _backBuffer + * @property {EveTransform} highDetail + * @property {Tw2Effect} effectHeight + * @property {Tw2RenderTarget} heightMap + * @property {*} zOnlyModel + * @property {number} itemID + * @property {string} heightMapResPath1 + * @property {string} heightMapResPath2 + * @property {boolean} heightDirty + * @property {Array} lockedResources + * @property {Array.} watchedResources * @class */ -var EveLensflare = exports.EveLensflare = function () { - function EveLensflare() { - _classCallCheck(this, EveLensflare); +var EvePlanet = exports.EvePlanet = function (_EveObject) { + _inherits(EvePlanet, _EveObject); - this._id = _math.util.generateID(); - this.name = ''; - this.display = true; - this.update = true; - this.doOcclusionQueries = true; - this.cameraFactor = 20; - this.position = _math.vec3.create(); - this.flares = []; - this.occluders = []; - this.backgroundOccluders = []; - this.occlusionIntensity = 1; - this.backgroundOcclusionIntensity = 1; - this.distanceToEdgeCurves = []; - this.distanceToCenterCurves = []; - this.radialAngleCurves = []; - this.xDistanceToCenter = []; - this.yDistanceToCenter = []; - this.bindings = []; - this.curveSets = []; - this.mesh = null; - this._direction = _math.vec3.create(); - this._transform = _math.mat4.create(); - this._backBuffer = null; + function EvePlanet() { + _classCallCheck(this, EvePlanet); - EveLensflare.init(); + var _this = _possibleConstructorReturn(this, (EvePlanet.__proto__ || Object.getPrototypeOf(EvePlanet)).call(this)); + + _this.highDetail = new _EveTransform.EveTransform(); + _this.effectHeight = new _core.Tw2Effect(); + _this.heightMap = new _core.Tw2RenderTarget(); + _this.zOnlyModel = null; + _this.itemID = 0; + _this.heightMapResPath1 = ''; + _this.heightMapResPath2 = ''; + _this.heightDirty = false; + _this.lockedResources = []; + _this.watchedResources = []; + return _this; } /** - * Gets lensflares's res objects - * @param {Array} [out=[]] - Optional receiving array - * @returns {Array.} [out] + * Creates the planet + * @param {number} itemID - the item id is used for randomization + * @param {string} planetPath - .red file for a planet, or planet template + * @param {string} [atmospherePath] - optional .red file for a planet's atmosphere + * @param {string} heightMap1 + * @param {string} heightMap2 */ - _createClass(EveLensflare, [{ - key: 'GetResources', - value: function GetResources() { - var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + _createClass(EvePlanet, [{ + key: 'Create', + value: function Create(itemID, planetPath, atmospherePath, heightMap1, heightMap2) { + var _this2 = this; - if (this.mesh) this.mesh.GetResources(out); + this.itemID = itemID; + this.heightMapResPath1 = heightMap1; + this.heightMapResPath2 = heightMap2; + this.highDetail.children = []; + this.heightDirty = true; - for (var i = 0; i < this.flares.length; i++) { - this.flares[i].GetResources(out); - } + _global.resMan.GetObject(planetPath, function (obj) { + return EvePlanet.MeshLoaded(_this2, obj); + }); + _global.resMan.GetObject('res:/dx9/model/worldobject/planet/planetzonly.red', function (obj) { + return _this2.zOnlyModel = obj; + }); - if (_EveOccluder.EveOccluder.global && _EveOccluder.EveOccluder.global.effect && !out.includes(_EveOccluder.EveOccluder.global.effect)) { - out.push(_EveOccluder.EveOccluder.global.effect); + if (atmospherePath) { + _global.resMan.GetObject(atmospherePath, function (obj) { + return _this2.highDetail.children.push(obj); + }); } - - return out; } /** - * Updates Occluders + * GetPlanetResources + * Todo: Replace this, using this.GetResources(); + * @param obj + * @param visited + * @param result */ }, { - key: 'UpdateOccluders', - value: function UpdateOccluders() { - if (!this.doOcclusionQueries) return; - - var d = _core.device, - g = EveLensflare.global; + key: 'GetPlanetResources', + value: function GetPlanetResources(obj, visited, result) { + if (visited.includes(obj)) return; + visited.push(obj); - if (!g.occluderLevels[0].texture || g.occluderLevels[0].width < this.occluders.length * 2) { - for (var i = 0; i < g.occluderLevels.length; ++i) { - g.occluderLevels[i].Create(this.occluders.length * 2, 1, false); - } + if (obj && !_global.util.isUndefined(obj['doNotPurge'])) { + result.push(obj); + return; } - // TODO: Is this deprecated? - for (var j = 0; j < this.flares.length; ++j) { - if ('_backBuffer' in this.flares[j]) { - this.flares[j]._backBuffer.textureRes = g.occluderLevels.texture; + for (var prop in obj) { + if (obj.hasOwnProperty(prop)) { + if (_global.util.isObjectLike(obj[prop])) { + this.GetPlanetResources(obj[prop], visited, result); + } } } + } - this.occlusionIntensity = 1; - this.backgroundOcclusionIntensity = 1; - - g.occluderLevels[g.occludedLevelIndex].Set(); - d.SetStandardStates(d.RM_OPAQUE); - d.gl.clearColor(0.0, 0.0, 0.0, 1.0); - d.gl.clear(d.gl.COLOR_BUFFER_BIT); - g.occluderLevels[g.occludedLevelIndex].Unset(); - - var samples = 1; - if (d.antialiasing) { - samples = d.msaaSamples; - d.gl.sampleCoverage(1.0 / samples, false); - } - - for (var _i = 0; _i < this.occluders.length; ++_i) { - d.SetRenderState(d.RS_COLORWRITEENABLE, 8); - d.gl.colorMask(false, false, false, true); - d.gl.clearColor(0.0, 0.0, 0.0, 0.0); - d.gl.clear(d.gl.COLOR_BUFFER_BIT); - - // Turn off antialiasing - if (d.antialiasing) { - d.gl.enable(d.gl.SAMPLE_COVERAGE); - d.gl.sampleCoverage(0.25, false); - } - this.occluders[_i].UpdateValue(this._transform, _i); - if (d.antialiasing) d.gl.disable(d.gl.SAMPLE_COVERAGE); - - // Copy back buffer into a texture - if (!g.backBuffer.texture) g.backBuffer.Attach(d.gl.createTexture()); - d.gl.bindTexture(d.gl.TEXTURE_2D, g.backBuffer.texture); - if (g.backBuffer.width !== d.viewportWidth || g.backBuffer.height !== d.viewportHeight) { - d.gl.texImage2D(d.gl.TEXTURE_2D, 0, d.gl.RGBA, d.viewportWidth, d.viewportHeight, 0, d.gl.RGBA, d.gl.UNSIGNED_BYTE, null); - d.gl.texParameteri(d.gl.TEXTURE_2D, d.gl.TEXTURE_MAG_FILTER, d.gl.LINEAR); - d.gl.texParameteri(d.gl.TEXTURE_2D, d.gl.TEXTURE_MIN_FILTER, d.gl.LINEAR); - g.backBuffer.width = d.viewportWidth; - g.backBuffer.height = d.viewportHeight; - } - d.gl.copyTexImage2D(d.gl.TEXTURE_2D, 0, d.alphaBlendBackBuffer ? d.gl.RGBA : d.gl.RGB, 0, 0, g.backBuffer.width, g.backBuffer.height, 0); - d.gl.bindTexture(d.gl.TEXTURE_2D, null); + /** + * Gets planet res objects + * @param {Array} [out=[]] - Optional receiving array + * @returns {Array.} [out] + */ - // Collect samples - g.occluderLevels[g.occludedLevelIndex].Set(); - _EveOccluder.EveOccluder.CollectSamples(g.backBuffer, _i, g.occluderLevels[0].width / 2, samples); - g.occluderLevels[g.occludedLevelIndex].Unset(); - } + }, { + key: 'GetResources', + value: function GetResources() { + var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - if (d.antialiasing) d.gl.sampleCoverage(1, false); + if (this.highDetail) this.highDetail.GetResources(out); + if (this.effectHeight) this.effectHeight.GetResources(out); + return out; + } - g.occluderLevels[(g.occludedLevelIndex + 1) % g.occluderLevels.length].Set(); - var pixels = new Uint8Array(g.occluderLevels[0].width * 4); - d.gl.readPixels(0, 0, 2, 1, d.gl.RGBA, d.gl.UNSIGNED_BYTE, pixels); - g.occluderLevels[(g.occludedLevelIndex + 1) % g.occluderLevels.length].Unset(); + /** + * Updates view dependent data + * @param {mat4} parentTransform + */ - this.occlusionIntensity = 1; - for (var _i2 = 0; _i2 < g.occluderLevels[0].width * 2; _i2 += 4) { - this.occlusionIntensity *= pixels[_i2 + 1] ? pixels[_i2] / pixels[_i2 + 1] : 1; + }, { + key: 'UpdateViewDependentData', + value: function UpdateViewDependentData(parentTransform) { + this.highDetail.UpdateViewDependentData(parentTransform); + if (this.zOnlyModel) { + this.zOnlyModel.translation = this.highDetail.translation; + this.zOnlyModel.scaling = this.highDetail.scaling; + this.zOnlyModel.UpdateViewDependentData(parentTransform); } + } - this.backgroundOcclusionIntensity = this.occlusionIntensity; + /** + * Per frame update + * @param {number} dt - delta time + */ - _core.store.SetVariableValue('LensflareFxOccScale', [this.occlusionIntensity, this.occlusionIntensity, 0, 0]); - g.occludedLevelIndex = (g.occludedLevelIndex + 1) % g.occluderLevels.length; + }, { + key: 'Update', + value: function Update(dt) { + this.highDetail.Update(dt); } /** * Gets render batches * @param {number} mode * @param {Tw2BatchAccumulator} accumulator - * @param {Tw2PerObjectData} perObjectData */ }, { key: 'GetBatches', - value: function GetBatches(mode, accumulator, perObjectData) { - if (this.display) { - var viewDir = _math.vec4.set(EveLensflare.global.vec4_0, 0, 0, 1, 0); + value: function GetBatches(mode, accumulator) { + if (this.display && this.heightDirty && this.watchedResources.length && this.heightMapResPath1 !== '') { + for (var i = 0; i < this.watchedResources.length; ++i) { + if (this.watchedResources[i] && !this.watchedResources[i].IsGood()) return; + } - _math.vec4.transformMat4(viewDir, viewDir, _core.device.viewInverse); - if (_math.vec3.dot(viewDir, this._direction) < 0) return; + this.watchedResources = []; - for (var i = 0; i < this.flares.length; ++i) { - this.flares[i].GetBatches(mode, accumulator, perObjectData); + this.heightMap.Set(); + _global.device.SetStandardStates(_global.device.RM_FULLSCREEN); + _global.device.gl.clearColor(0.0, 0.0, 0.0, 0.0); + _global.device.gl.clear(_global.device.gl.COLOR_BUFFER_BIT); + _global.device.RenderFullScreenQuad(this.effectHeight); + this.heightMap.Unset(); + + this.heightDirty = false; + for (var _i = 0; _i < this.lockedResources.length; ++_i) { + this.lockedResources[_i].doNotPurge--; } - if (this.mesh) { - this.mesh.GetBatches(mode, accumulator, perObjectData); + var mainMesh = this.highDetail.children[0].mesh; + var originalEffect = null; + + if (mainMesh.transparentAreas.length) { + originalEffect = mainMesh.transparentAreas[0].effect; + } else if (mainMesh.opaqueAreas.length) { + originalEffect = mainMesh.opaqueAreas[0].effect; + } + + if (originalEffect) { + originalEffect.parameters['HeightMap'].textureRes = this.heightMap.texture; } } + + if (this.display) { + this.highDetail.GetBatches(mode, accumulator); + } } /** - * Prepares the lensflare for rendering + * Gets z buffer only batches + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator */ }, { - key: 'PrepareRender', - value: function PrepareRender() { - if (!this.display) return; - - var g = EveLensflare.global, - viewDir = g.vec4_0, - cameraPos = g.vec3_0, - scaleMat = _math.mat4.identity(g.mat4_0), - cameraSpacePos = g.vec3_2, - negDirVec = g.vec3_3, - negPos = g.vec3_1, - dist = g.vec4_1; - - _math.vec3.transformMat4(cameraPos, [0, 0, 0], _core.device.viewInverse); - - if (_math.vec3.length(this.position) === 0) { - _math.vec3.negate(negPos, cameraPos); - //let distScale = vec3.length(negPos); - //distScale = distScale > 1.5 ? 1 / Math.log(distScale) : 2.5; - } else { - _math.vec3.negate(negPos, this.position); - _math.vec3.normalize(this._direction, negPos); + key: 'GetZOnlyBatches', + value: function GetZOnlyBatches(mode, accumulator) { + if (this.display && this.zOnlyModel) { + this.zOnlyModel.GetBatches(mode, accumulator); } + } - _math.vec4.transformMat4(viewDir, [0, 0, 1, 0], _core.device.viewInverse); - _math.vec3.scaleAndAdd(cameraSpacePos, cameraPos, viewDir, -this.cameraFactor); - _math.vec3.negate(negDirVec, this._direction); - _math.mat4.arcFromForward(this._transform, negDirVec); - _math.mat4.setTranslation(this._transform, cameraSpacePos); - _math.mat4.scale(scaleMat, scaleMat, [this.occlusionIntensity, this.occlusionIntensity, 1]); - //mat4.multiply(scaleMat, scaleMat, this._transform); - - var dir = this._direction; - - _core.store.SetVariableValue('LensflareFxDirectionScale', [dir[0], dir[1], dir[2], 1]); + /** + * Internal helper function that fires when a planet's mesh has loaded + * @property {EvePlanet} planet + * @property {*} obj + */ - _math.vec4.set(dist, dir[0], dir[1], dir[2], 0); - _math.vec4.transformMat4(dist, dist, _core.device.view); - _math.vec4.transformMat4(dist, dist, _core.device.projection); - dist[0] /= dist[3]; - dist[1] /= dist[3]; + }], [{ + key: 'MeshLoaded', + value: function MeshLoaded(planet, obj) { + planet.highDetail.children.unshift(obj); + planet.lockedResources = []; + planet.GetPlanetResources(planet.highDetail, [], planet.lockedResources); - var distToEdge = 1 - Math.min(1 - Math.abs(dist[0]), 1 - Math.abs(dist[1])), - distToCenter = Math.sqrt(dist[0] * dist[0] + dist[1] * dist[1]), - radialAngle = Math.atan2(dist[1], dist[0]) + Math.PI; + var mainMesh = planet.highDetail.children[0].mesh, + originalEffect = null, + resPath = void 0; - for (var i = 0; i < this.distanceToEdgeCurves.length; ++i) { - this.distanceToEdgeCurves[i].UpdateValue(distToEdge); + if (mainMesh.transparentAreas.length) { + originalEffect = mainMesh.transparentAreas[0].effect; + resPath = originalEffect.effectFilePath; + } else if (mainMesh.opaqueAreas.length) { + originalEffect = mainMesh.opaqueAreas[0].effect; + resPath = originalEffect.effectFilePath; + } else { + resPath = 'res:/Graphics/Effect/Managed/Space/Planet/EarthlikePlanet.fx'; } + resPath = resPath.replace('.fx', 'BlitHeight.fx'); - for (var _i3 = 0; _i3 < this.distanceToCenterCurves.length; ++_i3) { - this.distanceToCenterCurves[_i3].UpdateValue(distToCenter); + planet.watchedResources = []; + for (var param in originalEffect.parameters) { + if (originalEffect.parameters.hasOwnProperty(param)) { + planet.effectHeight.parameters[param] = originalEffect.parameters[param]; + if ('textureRes' in originalEffect.parameters[param]) { + planet.watchedResources.push(originalEffect.parameters[param].textureRes); + } + } } - for (var _i4 = 0; _i4 < this.radialAngleCurves.length; ++_i4) { - this.radialAngleCurves[_i4].UpdateValue(radialAngle); - } + for (var i = 0; i < planet.highDetail.children[0].children.length; ++i) { + mainMesh = planet.highDetail.children[0].children[i].mesh; + if (!mainMesh) continue; - for (var _i5 = 0; _i5 < this.xDistanceToCenter.length; ++_i5) { - this.xDistanceToCenter[_i5].UpdateValue(dist[0] + 10); - } + originalEffect = null; + if (mainMesh.transparentAreas.length) { + originalEffect = mainMesh.transparentAreas[0].effect; + } else if (mainMesh.opaqueAreas.length) { + originalEffect = mainMesh.opaqueAreas[0].effect; + } else { + continue; + } - for (var _i6 = 0; _i6 < this.yDistanceToCenter.length; ++_i6) { - this.yDistanceToCenter[_i6].UpdateValue(dist[1] + 10); + for (var _param in originalEffect.parameters) { + if (originalEffect.parameters.hasOwnProperty(_param)) { + planet.effectHeight.parameters[_param] = originalEffect.parameters[_param]; + if ('textureRes' in originalEffect.parameters[_param]) { + planet.watchedResources.push(originalEffect.parameters[_param].textureRes); + } + } + } } - for (var _i7 = 0; _i7 < this.bindings.length; ++_i7) { - this.bindings[_i7].CopyValue(); - } + var NormalHeight1 = new _core.Tw2TextureParameter('NormalHeight1', planet.heightMapResPath1); + NormalHeight1.Initialize(); + planet.watchedResources.push(NormalHeight1.textureRes); + planet.lockedResources.push(NormalHeight1.textureRes); + planet.effectHeight.parameters.NormalHeight1 = NormalHeight1; - for (var _i8 = 0; _i8 < this.flares.length; ++_i8) { - this.flares[_i8].UpdateViewDependentData(this._transform); - } - } + var NormalHeight2 = new _core.Tw2TextureParameter('NormalHeight2', planet.heightMapResPath2); + NormalHeight2.Initialize(); + planet.watchedResources.push(NormalHeight2.textureRes); + planet.lockedResources.push(NormalHeight2.textureRes); + planet.effectHeight.parameters.NormalHeight2 = NormalHeight2; - /** - * Initializes class global and scratch variables - */ + planet.effectHeight.parameters.Random = new _core.Tw2FloatParameter('Random', planet.itemID % 100); + planet.effectHeight.parameters.TargetTextureHeight = new _core.Tw2FloatParameter('TargetTextureHeight', 1024); - }], [{ - key: 'init', - value: function init() { - if (!EveLensflare.global) { - var g = EveLensflare.global = {}; - g.vec3_0 = _math.vec3.create(); - g.vec3_1 = _math.vec3.create(); - g.vec3_2 = _math.vec3.create(); - g.vec3_3 = _math.vec3.create(); - g.vec4_0 = _math.vec4.create(); - g.vec4_1 = _math.vec4.create(); - g.mat4_0 = _math.mat4.create(); + planet.effectHeight.effectFilePath = resPath; + planet.effectHeight.Initialize(); + planet.heightDirty = true; + planet.heightMap.Create(2048, 1024, false); + planet.watchedResources.push(planet.effectHeight.effectRes); - g.backBuffer = new _core.Tw2TextureRes(); - g.backBuffer.width = 0; - g.backBuffer.height = 0; - g.backBuffer.hasMipMaps = false; - g.occludedLevelIndex = 0; - g.occluderLevels = [new _core.Tw2RenderTarget(), new _core.Tw2RenderTarget(), new _core.Tw2RenderTarget(), new _core.Tw2RenderTarget()]; + for (var _i2 = 0; _i2 < planet.lockedResources.length; ++_i2) { + planet.lockedResources[_i2].doNotPurge++; + if (planet.lockedResources[_i2].IsPurged()) { + planet.lockedResources[_i2].Reload(); + } } } }]); - return EveLensflare; -}(); - -/** - * Class global and scratch variables - * @type {{string:*}} - */ - - -EveLensflare.global = null; + return EvePlanet; +}(_EveObject2.EveObject); /***/ }), -/* 180 */ +/* 174 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -34637,154 +34686,220 @@ EveLensflare.global = null; Object.defineProperty(exports, "__esModule", { value: true }); -exports.EveMeshOverlayEffect = undefined; +exports.EveShip = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _core = __webpack_require__(1); +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; -var _math = __webpack_require__(0); +var _EveSpaceObject2 = __webpack_require__(63); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + /** - * Constructor for Overlay Effects + * EveShip * - * @property {number|string} _id - * @property {string} name - * @property {boolean} display - Enables/ disables all batch accumulations - * @property {{}} visible - Batch accumulation options for the overlay effect - * @property {boolean} visible.opaqueEffects - Enables/ disables opaque effect batch accumulation - * @property {boolean} visible.decalEffects - Enables/ disables decal effect batch accumulation - * @property {boolean} visible.transparentEffects - Enables/ disables transparent effect batch accumulation - * @property {boolean} visible.additiveEffects - Enables/ disables additive effect batch accumulation - * @property {boolean} visible.distortionEffects - Currently not supported - * @property {boolean} update - * @property {Tw2CurveSet} curveSet - * @property {Array.} opaqueEffects - * @property {Array.} decalEffects - * @property {Array.} transparentEffects - * @property {Array.} additiveEffects - * @property {Array.} distortionEffects - Currently not supported + * @property {boolean} visible.turretSets - Enables/ disables turret set batch accumulation + * @property {boolean} visible.boosters - Enables/ disables booster batch accumulation + * @property {Array.} boosters + * @property {Array.} turretSets + * @property {number} boosterGain * @class */ -var EveMeshOverlayEffect = exports.EveMeshOverlayEffect = function () { - function EveMeshOverlayEffect() { - _classCallCheck(this, EveMeshOverlayEffect); +var EveShip = exports.EveShip = function (_EveSpaceObject) { + _inherits(EveShip, _EveSpaceObject); + + function EveShip() { + _classCallCheck(this, EveShip); + + var _this = _possibleConstructorReturn(this, (EveShip.__proto__ || Object.getPrototypeOf(EveShip)).call(this)); + + _this.visible.turretSets = true; + _this.visible.boosters = true; + _this.boosters = null; + _this.turretSets = []; + _this.boosterGain = 1; + return _this; + } + + /** + * Initializes the Eve Ship + */ + + + _createClass(EveShip, [{ + key: 'Initialize', + value: function Initialize() { + _get(EveShip.prototype.__proto__ || Object.getPrototypeOf(EveShip.prototype), 'Initialize', this).call(this); + if (this.boosters) { + this.RebuildBoosterSet(); + } + } + + /** + * Rebuilds the ship's booster set + */ + + }, { + key: 'RebuildBoosterSet', + value: function RebuildBoosterSet() { + if (this.boosters) { + this.boosters.UpdateItemsFromLocators(this.FindLocatorsByPrefix('locator_booster')); + } + } + + /** + * Rebuilds turret sets + */ + + }, { + key: 'RebuildTurretPositions', + value: function RebuildTurretPositions() { + for (var i = 0; i < this.turretSets.length; i++) { + this.RebuildTurretSet(i); + } + } + + /** + * Rebuilds a turret set + * @param {number} index + */ + + }, { + key: 'RebuildTurretSet', + value: function RebuildTurretSet(index) { + if (this.turretSets[index] === undefined) return; - this._id = _math.util.generateID(); - this.name = ''; - this.display = true; - this.visible = {}; - this.visible.opaqueEffects = true; - this.visible.decalEffects = true; - this.visible.transparentEffects = true; - this.visible.additiveEffects = true; - this.visible.distortionEffects = false; - this.update = true; - this.curveSet = null; - this.opaqueEffects = []; - this.decalEffects = []; - this.transparentEffects = []; - this.additiveEffects = []; - this.distortionEffects = []; - } + var turretSet = this.turretSets[index], + prefix = turretSet.locatorName, + count = this.GetLocatorCount(prefix), + locators = []; - /** - * Gets the mesh overlay's resources - * @param {Array} [out=[]] - Optional receiving array - * @returns {Array.} [out] - */ + for (var j = 0; j < count; ++j) { + var name = prefix + String.fromCharCode('a'.charCodeAt(0) + j), + locator = this.FindLocatorByName(name); + + if (locator) { + locator.FindBone(this.animation); + locators.push(locator); + } + } + turretSet.UpdateItemsFromLocators(locators); + } - _createClass(EveMeshOverlayEffect, [{ + /** + * Gets ship's res objects + * @param {Array} [out=[]] - Optional receiving array + * @param {Boolean} excludeChildren - True to exclude children's res objects + * @returns {Array.} [out] + */ + + }, { key: 'GetResources', value: function GetResources() { var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + var excludeChildren = arguments[1]; + + _get(EveShip.prototype.__proto__ || Object.getPrototypeOf(EveShip.prototype), 'GetResources', this).call(this, out, excludeChildren); + + for (var i = 0; i < this.turretSets.length; i++) { + this.turretSets[i].GetResources(out); + } + + if (this.boosters) { + this.boosters.GetResources(out); + } - _math.util.perArrayChild(this.opaqueEffects, 'GetResources', out); - _math.util.perArrayChild(this.decalEffects, 'GetResources', out); - _math.util.perArrayChild(this.transparentEffects, 'GetResources', out); - _math.util.perArrayChild(this.additiveEffects, 'GetResources', out); - _math.util.perArrayChild(this.distortionEffects, 'GetResources', out); return out; } /** - * Per frame update - * @param {number} dt - delta Time + * Updates view dependant data */ }, { - key: 'Update', - value: function Update(dt) { - if (this.update && this.curveSet) this.curveSet.Update(dt); + key: 'UpdateViewDependentData', + value: function UpdateViewDependentData() { + _get(EveShip.prototype.__proto__ || Object.getPrototypeOf(EveShip.prototype), 'UpdateViewDependentData', this).call(this); + + for (var i = 0; i < this.turretSets.length; ++i) { + this.turretSets[i].UpdateViewDependentData(); + } } /** - * Gets render batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator - * @param {Tw2PerObjectData} perObjectData - * @param {Tw2Mesh} mesh + * Per frame update + * @param {number} dt - deltaTime */ }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator, perObjectData, mesh) { - if (!this.display || !mesh || !mesh.IsGood()) return; + key: 'Update', + value: function Update(dt) { + _get(EveShip.prototype.__proto__ || Object.getPrototypeOf(EveShip.prototype), 'Update', this).call(this, dt); - var effects = this.GetEffects(mode); - for (var i = 0; i < effects.length; i++) { - var batch = new _core.Tw2GeometryBatch(); - batch.renderMode = mode; - batch.perObjectData = perObjectData; - batch.geometryRes = mesh.geometryResource; - batch.meshIx = mesh.meshIndex; - batch.start = 0; - batch.count = mesh.geometryResource.meshes[mesh.meshIndex].areas.length; - batch.effect = effects[i]; - accumulator.Commit(batch); + if (this.boosters) { + if (this.boosters._locatorRebuildPending) { + this.RebuildBoosterSet(); + } + + this.boosters.Update(dt, this.transform); + } + + for (var i = 0; i < this.turretSets.length; ++i) { + if (this.turretSets[i]._locatorRebuildPending) { + this.RebuildTurretSet(i); + } + + this.turretSets[i].Update(dt, this.transform); } } /** - * Gets effects + * Gets render batches * @param {number} mode - * @returns {Array.} + * @param {Tw2BatchAccumulator} accumulator */ }, { - key: 'GetEffects', - value: function GetEffects(mode) { + key: 'GetBatches', + value: function GetBatches(mode, accumulator) { if (this.display) { - switch (mode) { - case _core.device.RM_OPAQUE: - if (this.visible.opaqueEffects) return this.opaqueEffects; - break; + _get(EveShip.prototype.__proto__ || Object.getPrototypeOf(EveShip.prototype), 'GetBatches', this).call(this, mode, accumulator); - case _core.device.RM_TRANSPARENT: - if (this.visible.transparentEffects) return this.transparentEffects; - break; + this._perObjectData.perObjectVSData.Get('Shipdata')[0] = this.boosterGain; + this._perObjectData.perObjectPSData.Get('Shipdata')[0] = this.boosterGain; - case _core.device.RM_ADDITIVE: - if (this.visible.additiveEffects) return this.additiveEffects; - break; + if (this.boosters && this.visible.boosters) { + this.boosters.GetBatches(mode, accumulator, this._perObjectData); + } - case _core.device.RM_DECAL: - if (this.visible.decalEffects) return this.decalEffects; - break; + if (this.visible.turretSets) { + if (this.lod > 1) { + for (var i = 0; i < this.turretSets.length; ++i) { + this.turretSets[i].GetBatches(mode, accumulator, this._perObjectData, this.visible.firingEffects); + } + } else if (this.visible.firingEffects) { + for (var _i = 0; _i < this.turretSets.length; ++_i) { + if (this.turretSets[_i].firingEffect) { + this.turretSets[_i].firingEffect.GetBatches(mode, accumulator, this._perObjectData); + } + } + } } } - return []; } }]); - return EveMeshOverlayEffect; -}(); + return EveShip; +}(_EveSpaceObject2.EveSpaceObject); /***/ }), -/* 181 */ +/* 175 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -34793,258 +34908,435 @@ var EveMeshOverlayEffect = exports.EveMeshOverlayEffect = function () { Object.defineProperty(exports, "__esModule", { value: true }); -exports.EveStretch = undefined; +exports.EveBoosterSet = exports.EveBoosterSetItem = exports.EveBoosterBatch = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _index = __webpack_require__(0); +var _global = __webpack_require__(0); + +var _core = __webpack_require__(1); -var _index2 = __webpack_require__(1); +var _EveObjectSet2 = __webpack_require__(6); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + /** - * EveStretch + * Booster render batch * - * @property {string|number} _id - * @property {String} name - * @property {boolean} display - * @property {boolean} update - * @property {Array.} curveSets - * @property {*} source - * @property {*} dest - * @property {*} sourceObject - * @property {*} destObject - * @property {*} stretchObject - * @property {Tw2Float} length - * @property {number} _time - * @property {boolean} _useTransformsForStretch - * @property {vec3} _sourcePosition - * @property {vec3} _destinationPosition - * @property {boolean} _displaySourceObject - * @property {mat4} _sourceTransform - * @property {boolean} _displayDestObject - * @property {boolean} _useTransformsForStretch - * @property {boolean} _isNegZForward + * @property {EveBoosterSet} boosters * @class */ -var EveStretch = exports.EveStretch = function () { - function EveStretch() { - _classCallCheck(this, EveStretch); +var EveBoosterBatch = exports.EveBoosterBatch = function (_Tw2RenderBatch) { + _inherits(EveBoosterBatch, _Tw2RenderBatch); - this._id = _index.util.generateID(); - this.name = ''; - this.display = true; - this.update = true; - this.curveSets = []; - this.source = null; - this.dest = null; - this.sourceObject = null; - this.destObject = null; - this.stretchObject = null; - this.length = new _index2.Tw2Float(); - this._time = 0; - this._useTransformsForStretch = false; - this._sourcePosition = _index.vec3.create(); - this._destinationPosition = _index.vec3.create(); - this._displaySourceObject = true; - this._sourceTransform = null; - this._displayDestObject = true; - this._useTransformsForStretch = false; - this._isNegZForward = false; + function EveBoosterBatch() { + _classCallCheck(this, EveBoosterBatch); - EveStretch.init(); + var _this = _possibleConstructorReturn(this, (EveBoosterBatch.__proto__ || Object.getPrototypeOf(EveBoosterBatch)).call(this)); + + _this.boosters = null; + return _this; } /** - * Gets source position - * @param {vec3} position + * Commits the batch + * @param {string} technique - technique name */ - _createClass(EveStretch, [{ - key: 'SetSourcePosition', - value: function SetSourcePosition(position) { - this._useTransformsForStretch = false; - this._sourcePosition = position; + _createClass(EveBoosterBatch, [{ + key: 'Commit', + value: function Commit(technique) { + this.boosters.Render(technique); } + }]); - /** - * Sets the destination position - * @param {vec3} position - */ + return EveBoosterBatch; +}(_core.Tw2RenderBatch); - }, { - key: 'SetDestinationPosition', - value: function SetDestinationPosition(position) { - this._destinationPosition = position; +/** + * EveBoosterSetItem + * + * @param {boolean} enableCustomValues - Enables custom values + * @property {{}} visible - Visibility options + * @property {boolean} visible.halo - Toggles halo visibility + * @property {boolean} visible.symHalo - Toggles symmetrical halo visibility + * @property {boolean} visible.glow - Toggles glow visibility + * @property {boolean} visible.trail - Toggles trail visibility (not implemented) + * @property {?string} locatorName - The item's locator name, if it was built from one + * @property {boolean} updateFromLocator - Sets whether the item should be updated when it's locator is + * @property {mat4} transform - The item's local transform + * @property {number} atlas0 - The item's atlas index 0 + * @property {number} atlas1 - The item's atlas index 1 + * @property {number} seed - A random seed which affects any glows built from this item + * @property {number} wavePhase - A random seed which affects the booster wave pattern + * @property {*} customValues - An optional object containing custom values + * @class + */ + + +var EveBoosterSetItem = exports.EveBoosterSetItem = function (_EveObjectSetItem) { + _inherits(EveBoosterSetItem, _EveObjectSetItem); + + function EveBoosterSetItem() { + _classCallCheck(this, EveBoosterSetItem); + + var _this2 = _possibleConstructorReturn(this, (EveBoosterSetItem.__proto__ || Object.getPrototypeOf(EveBoosterSetItem)).call(this)); + + _this2.visible = {}; + _this2.visible.glow = true; + _this2.visible.symHalo = true; + _this2.visible.halo = true; + _this2.visible.trail = true; + _this2.visible.customValues = false; + _this2.locatorName = null; + _this2.updateFromLocator = false; + _this2.seed = Math.random() * 7; + _this2.wavePhase = Math.random(); + _this2.atlas0 = 0; + _this2.atlas1 = 0; + _this2.transform = _global.mat4.create(); + _this2.customValues = null; + return _this2; + } + + /** + * Gets the item's position + * @param {vec3} out + * @returns {vec3} out + */ + + + _createClass(EveBoosterSetItem, [{ + key: 'GetPosition', + value: function GetPosition(out) { + return _global.mat4.getTranslation(out, this.transform); } /** - * Sets the source transform - * @param {mat4} transform + * Gets the item's direction + * @param {vec3} out + * @returns {vec3} out */ }, { - key: 'SetSourceTransform', - value: function SetSourceTransform(transform) { - this._useTransformsForStretch = true; - this._sourceTransform = transform; + key: 'GetDirection', + value: function GetDirection(out) { + _global.vec3.set(out, this.transform[8], this.transform[9], this.transform[10]); + _global.vec3.normalize(out, out); + var scale = this.GetScale(); + if (scale < 3) _global.vec3.scale(out, out, scale / 3); + return out; } /** - * SetIsNegZForward - * @param {boolean} isNegZForward + * Gets the item's scale + * @returns {number} */ }, { - key: 'SetIsNegZForward', - value: function SetIsNegZForward(isNegZForward) { - this._isNegZForward = isNegZForward; + key: 'GetScale', + value: function GetScale() { + var tr = this.transform; + return Math.max(_global.vec3.length([tr[0], tr[1], tr[2]]), _global.vec3.length([tr[4], tr[5], tr[6]])); } /** - * Gets the stretches resources - * @param {Array} [out=[]] - * @return {Array} out + * Creates an item from an object + * @param {*} [opt={}] + * @returns {EveBoosterSetItem} */ - }, { - key: 'GetResources', - value: function GetResources() { - var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + }], [{ + key: 'create', + value: function create() { + var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - if (this.source && this.source.GetResources) this.source.GetResources(out); - if (this.dest && this.dest.GetResources) this.dest.GetResources(out); - if (this.sourceObject && this.sourceObject.GetResources) this.sourceObject.GetResources(out); - if (this.destObject && this.destObject.GetResources) this.destObject.GetResources(out); - if (this.stretchObject && this.stretchObject.GetResources) this.stretchObject.GetResources(out); - return out; + var item = new this(); + _global.util.assignIfExists(item.visible, opt.visible, ['glow', 'symHalo', 'halo', 'trail']); + _global.util.assignIfExists(item, opt, ['name', 'display', 'seed', 'wavePhase', 'transform', 'locatorName', 'updateFromLocator', 'atlas0', 'atlas1']); + return item; + } + }]); + + return EveBoosterSetItem; +}(_EveObjectSet2.EveObjectSetItem); + +/** + * EveBoosterSet + * + * @property {{}} visible - Visibility controls + * @property {boolean} visible.glows - Toggles glow visibility + * @property {boolean} visible.symHalos - Toggles symmetrical halo visibility + * @property {boolean} visible.halos - Toggles halo visibility + * @property {boolean} visible.trails - Toggles trails visibility (Not implemented) + * @property {Tw2Effect} effect - The booster's booster effect + * @property {?Tw2Effect} glows - The booster's glows (sprites) + * @property {number} maxVel - (Not implemented) + * @property {boolean} alwaysOn - (Not implemented) + * @property {number} glowDistance - The distance between the booster's locators and glow sprites + * @property {number} glowScale - The base scale of the booster's glow sprites + * @property {vec4} glowColor - The color of the booster set's glow sprites + * @property {vec4} warpGlowColor - The color of the booster set's glow sprites when warping (Not implemented) + * @property {number} haloDistance - The distance between the booster set's locators and halo sprites + * @property {number} haloScaleX - The base vertical scale of the booster set's halos + * @property {number} haloScaleY - The base horizontal scale of the booster set's halos + * @property {vec4} haloColor - The color of the booster set's halo sprites + * @property {vec4} warpHaloColor - The color of the booster set's halo sprites when warping (Not implemented) + * @property {vec4} trailSize - The booster set's trail size (Not implemented) + * @property {vec4} trailColor - The booster set's trail color (Not implemented) + * @property {number} symHaloDistance - The distance between the booster set's locators and symmetrical halo sprites + * @property {number} symHaloScale - The base scale of the booster set's symmetrical halos + * @property {mat4} _parentTransform - The booster set's parent's transform + * @property {WebGLBuffer} _positions - The booster set's webgl buffer + * @property {Tw2VertexDeclaration} _decl - The booster set's vertex declarations + * @property {Tw2PerObjectData} _perObjectData - The booster set's shader data + * @property {boolean} _locatorRebuildPending - Identifies that the booster set needs to be rebuilt from locators + * @class + */ + + +var EveBoosterSet = exports.EveBoosterSet = function (_EveObjectSet) { + _inherits(EveBoosterSet, _EveObjectSet); + + function EveBoosterSet() { + _classCallCheck(this, EveBoosterSet); + + var _this3 = _possibleConstructorReturn(this, (EveBoosterSet.__proto__ || Object.getPrototypeOf(EveBoosterSet)).call(this)); + + _this3.visible = {}; + _this3.visible.glows = true; + _this3.visible.symHalos = true; + _this3.visible.halos = true; + _this3.visible.trails = true; + _this3.effect = null; + _this3.glows = null; + _this3.alwaysOn = true; + _this3.maxVel = 250; + _this3.glowDistance = 2.5; + _this3.glowScale = 1.0; + _this3.glowColor = _global.vec4.create(); + _this3.warpGlowColor = _global.vec4.create(); + _this3.haloDistance = 3.01; + _this3.haloScaleX = 1.0; + _this3.haloScaleY = 1.0; + _this3.haloColor = _global.vec4.create(); + _this3.warpHaloColor = _global.vec4.create(); + _this3.symHaloDistance = 3; + _this3.symHaloScale = 1.0; + _this3.trailColor = _global.vec4.create(); + _this3.trailSize = _global.vec4.create(); + _this3._parentTransform = _global.mat4.create(); + _this3._positions = null; + + _this3._decl = new _core.Tw2VertexDeclaration(); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.POSITION, 0, _global.device.gl.FLOAT, 3, 0)); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 0, _global.device.gl.FLOAT, 2, 12)); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 1, _global.device.gl.FLOAT, 4, 20)); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 2, _global.device.gl.FLOAT, 4, 36)); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 3, _global.device.gl.FLOAT, 4, 52)); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 4, _global.device.gl.FLOAT, 4, 68)); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 5, _global.device.gl.FLOAT, 4, 84)); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 6, _global.device.gl.FLOAT, 1, 100)); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 7, _global.device.gl.FLOAT, 2, 104)); + _this3._decl.RebuildHash(); + + _this3._perObjectData = new _core.Tw2PerObjectData(); + _this3._perObjectData.perObjectVSData = new _core.Tw2RawData(); + _this3._perObjectData.perObjectVSData.Declare('WorldMat', 16); + _this3._perObjectData.perObjectVSData.Declare('Shipdata', 4); + _this3._perObjectData.perObjectVSData.Create(); + + _this3._locatorRebuildPending = true; + return _this3; + } + + /** + * Finds a booster item that belongs to a locator by it's name + * @param {string} locatorName + * @returns {?EveBoosterSetItem} + */ + + + _createClass(EveBoosterSet, [{ + key: 'FindItemByLocatorName', + value: function FindItemByLocatorName(locatorName) { + for (var i = 0; i < this.items.length; i++) { + if (this.items[i].locatorName && this.items[i].locatorName === locatorName) { + return this.items[i]; + } + } + return null; } /** - * Updates view dependent data + * Updates booster items that were built from locators + * @param {Array.} locators */ }, { - key: 'UpdateViewDependentData', - value: function UpdateViewDependentData() { - if (!this.display) return; + key: 'UpdateItemsFromLocators', + value: function UpdateItemsFromLocators(locators) { + var items = Array.from(this.items); - var g = EveStretch.global, - directionVec = _index.vec3.subtract(g.vec3_0, this._destinationPosition, this._sourcePosition), - m = _index.mat4.identity(g.mat4_0), - x = _index.vec3.set(g.vec3_1, 0, 0, 0), - up = _index.vec3.set(g.vec3_2, 0, 0, 0), - s = _index.mat4.identity(g.mat4_1); + for (var i = 0; i < locators.length; i++) { + var _locators$i = locators[i], + name = _locators$i.name, + transform = _locators$i.transform, + atlasIndex0 = _locators$i.atlasIndex0, + atlasIndex1 = _locators$i.atlasIndex1; - var scalingLength = _index.vec3.length(directionVec); - _index.vec3.normalize(directionVec, directionVec); - if (this._useTransformsForStretch) { - _index.mat4.rotateX(m, m, -Math.PI / 2); - _index.mat4.multiply(m, this._sourceTransform, m); - } else { - if (Math.abs(directionVec[1]) > 0.9) { - up[2] = 1; + var item = this.FindItemByLocatorName(name); + if (!item) { + this.CreateItem({ + name: name, + locatorName: name, + updateFromLocator: true, + atlas0: atlasIndex0, + atlas1: atlasIndex1, + transform: transform + }); } else { - up[1] = 1; + items.splice(items.indexOf(item), 1); + + if (item.updateFromLocator) { + _global.mat4.copy(item.transform, transform); + item.atlas0 = atlasIndex0; + item.atlas1 = atlasIndex1; + item.OnValueChanged(); + } } + } - _index.vec3.cross(x, up, directionVec); - _index.vec3.normalize(x, x); - _index.vec3.cross(up, directionVec, x); - m[0] = x[0]; - m[1] = x[1]; - m[2] = x[2]; - m[4] = -directionVec[0]; - m[5] = -directionVec[1]; - m[6] = -directionVec[2]; - m[8] = up[0]; - m[9] = up[1]; - m[10] = up[2]; + for (var _i = 0; _i < items.length; _i++) { + if (items[_i].locatorName !== null) { + this.RemoveItem(items[_i]); + _i--; + } } - if (this.destObject && this._displayDestObject) { - _index.mat4.setTranslation(m, this._destinationPosition); - this.destObject.UpdateViewDependentData(m); + this._locatorRebuildPending = false; + + if (this._rebuildPending) { + this.Rebuild(); + } + } + + /** + * Rebuilds the booster set from it's parent's locators + */ + + }, { + key: 'RebuildItemsFromLocators', + value: function RebuildItemsFromLocators() { + this._locatorRebuildPending = true; + } + + /** + * Gets booster set resources + * @param {Array} [out=[]] - Optional receiving array + * @returns {Array.} [out] + */ + + }, { + key: 'GetResources', + value: function GetResources() { + var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + + if (this.effect) { + this.effect.GetResources(out); } - if (this.sourceObject && this._displaySourceObject) { - if (this._useTransformsForStretch) { - _index.mat4.identity(m); - _index.mat4.rotateX(m, m, -Math.PI / 2); - _index.mat4.multiply(m, this._sourceTransform, m); - } else { - _index.mat4.setTranslation(m, this._sourcePosition); - } - this.sourceObject.UpdateViewDependentData(m); + if (this.glows) { + this.glows.effect.GetResources(out); } - if (this.stretchObject) { - if (this._useTransformsForStretch) { - _index.mat4.identity(m); - _index.mat4.scale(m, m, [1, 1, scalingLength]); - _index.mat4.multiply(m, this._sourceTransform, m); - } else { - m[0] = x[0]; - m[1] = x[1]; - m[2] = x[2]; - m[4] = up[0]; - m[5] = up[1]; - m[6] = up[2]; - m[8] = -directionVec[0]; - m[9] = -directionVec[1]; - m[10] = -directionVec[2]; - if (this._isNegZForward) scalingLength = -scalingLength; - _index.mat4.scale(s, s, [1, 1, scalingLength]); - _index.mat4.multiply(m, m, s); - } - this.stretchObject.UpdateViewDependentData(m); - } + return out; } /** * Per frame update - * @param {number} dt - delta time + * @param {number} dt - DeltaTime + * @param {mat4} parentMatrix */ }, { key: 'Update', - value: function Update(dt) { - for (var i = 0; i < this.curveSets.length; ++i) { - this.curveSets[i].Update(dt); - } + value: function Update(dt, parentMatrix) { + _global.mat4.copy(this._parentTransform, parentMatrix); + if (this._rebuildPending) this.Rebuild(); + if (this.glows) this.glows.Update(dt); + } - this._time += dt; + /** + * Unloads the booster's buffers + */ - if (this.source) { - this.source.GetValueAt(this._time, this._sourcePosition); - } else if (this._useTransformsForStretch) { - this._sourcePosition[0] = this._sourceTransform[12]; - this._sourcePosition[1] = this._sourceTransform[13]; - this._sourcePosition[2] = this._sourceTransform[14]; + }, { + key: 'Unload', + value: function Unload() { + if (this._positions) { + _global.device.gl.deleteBuffer(this._positions); + this._positions = null; } - if (this.dest) { - this.source.GetValueAt(this._time, this._destinationPosition); + if (this.glows) { + this.glows.Unload(); } + } - var directionVec = _index.vec3.subtract(EveStretch.global.vec3_0, this._destinationPosition, this._sourcePosition); - this.length.value = _index.vec3.length(directionVec); - _index.vec3.normalize(directionVec, directionVec); + /** + * Rebuilds the boosters + */ - if (this.sourceObject && this._displaySourceObject) { - this.sourceObject.Update(dt); - } + }, { + key: 'Rebuild', + value: function Rebuild() { + this.constructor.RebuildItems(this); + var itemCount = this._visibleItems.length; + this._rebuildPending = false; + if (!itemCount) return; - if (this.stretchObject) { - this.stretchObject.Update(dt); - } + var d = _global.device, + box = EveBoosterSet._box, + data = new Float32Array(itemCount * box.length * 6 * 28), + order = [0, 3, 1, 3, 2, 1]; - if (this.destObject && this._displayDestObject) { - this.destObject.Update(dt); + var index = 0; + for (var i = 0; i < itemCount; ++i) { + var item = this._visibleItems[i]; + for (var b = 0; b < box.length; ++b) { + for (var j = 0; j < order.length; ++j) { + data[index++] = box[b][order[j]][0]; + data[index++] = box[b][order[j]][1]; + data[index++] = box[b][order[j]][2]; + data[index++] = 0; + data[index++] = 0; + data.set(item.transform, index); + index += 16; + data[index++] = 0; + data[index++] = 1; + data[index++] = 1; + data[index++] = 1; + data[index++] = item.wavePhase; + data[index++] = item.atlas0; + data[index++] = item.atlas1; + } + } } + + this._positions = d.gl.createBuffer(); + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._positions); + d.gl.bufferData(d.gl.ARRAY_BUFFER, data, d.gl.STATIC_DRAW); + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, null); + this._positions.count = itemCount * 12 * 3; + + if (this.glows) this.glows.Rebuild(); } /** @@ -35057,53 +35349,138 @@ var EveStretch = exports.EveStretch = function () { }, { key: 'GetBatches', value: function GetBatches(mode, accumulator, perObjectData) { - if (!this.display) return; + if (!this.display || mode !== _global.device.RM_ADDITIVE || !this._positions || !this._visibleItems.length) return; - if (this.sourceObject && this._displaySourceObject) { - this.sourceObject.GetBatches(mode, accumulator, perObjectData); + if (this.effect) { + var batch = new EveBoosterBatch(); + _global.mat4.transpose(this._perObjectData.perObjectVSData.Get('WorldMat'), this._parentTransform); + this._perObjectData.perObjectVSData.Set('Shipdata', perObjectData.perObjectVSData.Get('Shipdata')); + this._perObjectData.perObjectPSData = perObjectData.perObjectPSData; + batch.perObjectData = this._perObjectData; + batch.boosters = this; + batch.renderMode = _global.device.RM_ADDITIVE; + accumulator.Commit(batch); } - if (this.destObject && this._displayDestObject) { - this.destObject.GetBatches(mode, accumulator, perObjectData); + if (this.glows) { + this.glows.GetBoosterGlowBatches(mode, accumulator, perObjectData, this._parentTransform, perObjectData.perObjectVSData.Get('Shipdata')[0], 0); } + } - if (this.stretchObject) { - this.stretchObject.GetBatches(mode, accumulator, perObjectData); + /** + * Renders the accumulated batches + * @param {string} technique - technique name + * @returns {boolean} + */ + + }, { + key: 'Render', + value: function Render(technique) { + if (!this.effect || !this.effect.IsGood()) return false; + + _global.device.gl.bindBuffer(_global.device.gl.ARRAY_BUFFER, this._positions); + for (var pass = 0; pass < this.effect.GetPassCount(technique); ++pass) { + this.effect.ApplyPass(technique, pass); + if (!this._decl.SetDeclaration(this.effect.GetPassInput(technique, pass), 112)) return false; + _global.device.ApplyShadowState(); + _global.device.gl.drawArrays(_global.device.gl.TRIANGLES, 0, this._positions.count); } + return true; } /** - * Initializes class global and scratch variables + * Rebuilds a booster set's items + * @param {EveBoosterSet} boosters */ }], [{ - key: 'init', - value: function init() { - if (!EveStretch.global) { - EveStretch.global = { - vec3_0: _index.vec3.create(), - vec3_1: _index.vec3.create(), - vec3_2: _index.vec3.create(), - mat4_0: _index.mat4.create(), - mat4_1: _index.mat4.create() - }; + key: 'RebuildItems', + value: function RebuildItems(boosters) { + var glows = boosters.glows, + g = EveBoosterSet.global, + spritePos = g.vec3_0; + + if (glows) glows.ClearItems(); + boosters._visibleItems = []; + + for (var i = 0; i < boosters.items.length; i++) { + var item = boosters.items[i]; + item._onModified = boosters._onChildModified; + + if (item.display) { + boosters._visibleItems.push(item); + + if (glows) { + var src = item.customValues && item.customValues.display ? item.customValues : boosters, + pos = item.GetPosition(g.vec3_1), + dir = item.GetDirection(g.vec3_2), + scale = item.GetScale(); + + if (boosters.visible.glows && item.visible.glow) { + glows.CreateItem({ + name: item.name + '_glow', + position: _global.vec3.subtract(spritePos, pos, _global.vec3.scale(spritePos, dir, src.glowDistance)), + blinkRate: item.seed, + blinkPhase: item.seed, + minScale: src.glowScale * scale, + maxScale: src.glowScale * scale, + color: src.glowColor, + warpColor: src.warpGlowColor + }); + } + + if (boosters.visible.symHalos && item.visible.symHalo) { + glows.CreateItem({ + name: item.name + '_symHalo', + position: _global.vec3.subtract(spritePos, pos, _global.vec3.scale(spritePos, dir, src.symHaloDistance)), + blinkRate: item.seed, + blinkPhase: item.seed + 1, + minScale: src.symHaloScale * scale, + maxScale: src.symHaloScale * scale, + color: src.haloColor, + warpColor: src.warpHaloColor + }); + } + + if (boosters.visible.halos && item.visible.halo) { + glows.CreateItem({ + name: item.name + '_halo', + position: _global.vec3.subtract(spritePos, pos, _global.vec3.scale(spritePos, dir, src.haloDistance)), + blinkRate: item.seed, + blinkPhase: item.seed + 1, + minScale: src.haloScaleX * scale, + maxScale: src.haloScaleY * scale, + color: src.haloColor, + warpColor: src.warpHaloColor + }); + } + } + + item._rebuildPending = false; + } } } }]); - return EveStretch; -}(); + return EveBoosterSet; +}(_EveObjectSet2.EveObjectSet); /** - * Class global and scratch variables - * @type {{string:*}} + * The booster set's item constructor + * @type {EveBoosterSetItem} */ -EveStretch.global = null; +EveBoosterSet.Item = EveBoosterSetItem; + +/** + * Internal helper + * @type {Array} + */ +EveBoosterSet._box = [[[-1.0, -1.0, 0.0], [1.0, -1.0, 0.0], [1.0, 1.0, 0.0], [-1.0, 1.0, 0.0]], [[-1.0, -1.0, -1.0], [-1.0, 1.0, -1.0], [1.0, 1.0, -1.0], [1.0, -1.0, -1.0]], [[-1.0, -1.0, 0.0], [-1.0, 1.0, 0.0], [-1.0, 1.0, -1.0], [-1.0, -1.0, -1.0]], [[1.0, -1.0, 0.0], [1.0, -1.0, -1.0], [1.0, 1.0, -1.0], [1.0, 1.0, 0.0]], [[-1.0, -1.0, 0.0], [-1.0, -1.0, -1.0], [1.0, -1.0, -1.0], [1.0, -1.0, 0.0]], [[-1.0, 1.0, 0.0], [1.0, 1.0, 0.0], [1.0, 1.0, -1.0], [-1.0, 1.0, -1.0]]]; /***/ }), -/* 182 */ +/* 176 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -35112,928 +35489,1035 @@ EveStretch.global = null; Object.defineProperty(exports, "__esModule", { value: true }); -exports.EveTurretFiringFX = exports.EvePerMuzzleData = undefined; +exports.EveCurveLineSet = exports.EveCurveLineSetItem = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _index = __webpack_require__(0); +var _global = __webpack_require__(0); + +var _core = __webpack_require__(1); + +var _EveObjectSet2 = __webpack_require__(6); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -/** - * EvePerMuzzleData - * Todo: Remove reference in this.muzzlePosition - * - * @property {boolean} started - * @property {boolean} readyToStart - * @property muzzlePositionBone - * @property {mat4} muzzleTransform - * @property {vec3} muzzlePosition - * @property {number} currentStartDelay - * @property {number} constantDelay - * @property {number} elapsedTime - * @class - */ -var EvePerMuzzleData = exports.EvePerMuzzleData = function EvePerMuzzleData() { - _classCallCheck(this, EvePerMuzzleData); +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - this._id = _index.util.generateID(); - this.started = false; - this.readyToStart = false; - this.muzzlePositionBone = null; - this.muzzleTransform = _index.mat4.create(); - this.muzzlePosition = this.muzzleTransform.subarray(12, 15); - this.currentStartDelay = 0; - this.constantDelay = 0; - this.elapsedTime = 0; -}; +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * EveTurretFiringFX + * EveCurveLineSetItem * - * @property {string|number} _id - * @property {string} name - * @property {boolean} display - * @property {Array.} stretch - * @property {boolean} useMuzzleTransform - * @property {boolean} isFiring - * @property {boolean} isLoopFiring - * @property {number} firingDelay1 - * @property {number} firingDelay2 - * @property {number} firingDelay3 - * @property {number} firingDelay4 - * @property {number} firingDelay5 - * @property {number} firingDelay6 - * @property {number} firingDelay7 - * @property {number} firingDelay8 - * @property {vec3} endPosition - * @property {number} _firingDuration - * @property {Array.} _perMuzzleData + * @property {number} type + * @property {vec3} position1 + * @property {vec4} color1 + * @property {vec3} position2 + * @property {vec4} color2 + * @property {vec3} intermediatePosition + * @property {number} width + * @property {vec4} multiColor + * @property {number} multiColorBorder + * @property {vec4} overlayColor + * @property {number} animationSpeed + * @property {number} animationScale + * @property {number} numOfSegments * @class */ +var EveCurveLineSetItem = exports.EveCurveLineSetItem = function (_EveObjectSetItem) { + _inherits(EveCurveLineSetItem, _EveObjectSetItem); + function EveCurveLineSetItem() { + _classCallCheck(this, EveCurveLineSetItem); -var EveTurretFiringFX = exports.EveTurretFiringFX = function () { - function EveTurretFiringFX() { - _classCallCheck(this, EveTurretFiringFX); + var _this = _possibleConstructorReturn(this, (EveCurveLineSetItem.__proto__ || Object.getPrototypeOf(EveCurveLineSetItem)).call(this)); - this._id = _index.util.generateID(); - this.name = ''; - this.display = true; - this.stretch = []; - this.useMuzzleTransform = false; - this.isFiring = false; - this.isLoopFiring = false; - this.firingDelay1 = 0; - this.firingDelay2 = 0; - this.firingDelay3 = 0; - this.firingDelay4 = 0; - this.firingDelay5 = 0; - this.firingDelay6 = 0; - this.firingDelay7 = 0; - this.firingDelay8 = 0; - this.endPosition = _index.vec3.create(); - this._firingDuration = 0; - this._perMuzzleData = []; + _this.type = EveCurveLineSetItem.Type.INVALID; + _this.position1 = _global.vec3.create(); + _this.color1 = _global.vec4.fromValues(1, 1, 1, 1); + _this.position2 = _global.vec3.create(); + _this.color2 = _global.vec4.fromValues(1, 1, 1, 1); + _this.intermediatePosition = _global.vec3.create(); + _this.width = 1; + _this.multiColor = _global.vec4.fromValues(0, 0, 0, 1); + _this.multiColorBorder = -1; + _this.overlayColor = _global.vec4.fromValues(0, 0, 0, 1); + _this.animationSpeed = 0; + _this.animationScale = 1; + _this.numOfSegments = 1; + return _this; } /** - * Initializes the turret firing fx + * Changes the line's colors + * @param {vec3} startColor + * @param {vec3} endColor */ - _createClass(EveTurretFiringFX, [{ - key: 'Initialize', - value: function Initialize() { - this._firingDuration = this.GetCurveDuration(); - for (var i = 0; i < this.stretch.length; ++i) { - this._perMuzzleData[i] = new EvePerMuzzleData(); - }if (this._perMuzzleData.length > 0) this._perMuzzleData[0].constantDelay = this.firingDelay1; - if (this._perMuzzleData.length > 1) this._perMuzzleData[1].constantDelay = this.firingDelay2; - if (this._perMuzzleData.length > 2) this._perMuzzleData[2].constantDelay = this.firingDelay3; - if (this._perMuzzleData.length > 3) this._perMuzzleData[3].constantDelay = this.firingDelay4; - if (this._perMuzzleData.length > 4) this._perMuzzleData[4].constantDelay = this.firingDelay5; - if (this._perMuzzleData.length > 5) this._perMuzzleData[5].constantDelay = this.firingDelay6; - if (this._perMuzzleData.length > 6) this._perMuzzleData[6].constantDelay = this.firingDelay7; - if (this._perMuzzleData.length > 7) this._perMuzzleData[7].constantDelay = this.firingDelay8; + _createClass(EveCurveLineSetItem, [{ + key: 'ChangeColor', + value: function ChangeColor(startColor, endColor) { + _global.vec3.copy(this.color1, startColor); + _global.vec3.copy(this.color2, endColor); + this.OnValueChanged(); } /** - * Gets the total curve duration - * @returns {number} + * Changes the line's width + * @param {number} width */ }, { - key: 'GetCurveDuration', - value: function GetCurveDuration() { - var maxDuration = 0; - for (var i = 0; i < this.stretch.length; ++i) { - var stretch = this.stretch[i]; - for (var j = 0; j < stretch.curveSets.length; ++j) { - maxDuration = Math.max(maxDuration, stretch.curveSets[j].GetMaxCurveDuration()); - } - } - return maxDuration; + key: 'ChangeWidth', + value: function ChangeWidth(width) { + this.width = width; + this.OnValueChanged(); } /** - * Gets a count of stretch effects - * @returns {Number} + * Changes positions from cartesian coordinates + * @param {vec3} startPosition + * @param {vec3} endPosition + * @param {vec3} middle */ }, { - key: 'GetPerMuzzleEffectCount', - value: function GetPerMuzzleEffectCount() { - return this.stretch.length; + key: 'ChangeCartesian', + value: function ChangeCartesian(startPosition, endPosition, middle) { + _global.vec3.copy(this.position1, startPosition); + _global.vec3.copy(this.position2, endPosition); + _global.vec3.copy(this.intermediatePosition, middle); + this.OnValueChanged(); } /** - * Sets muzzle bone id - * @param {number} index - * @param bone + * Changes cartesian position + * @param {vec3} startPosition + * @param {vec3} endPosition */ }, { - key: 'SetMuzzleBoneID', - value: function SetMuzzleBoneID(index, bone) { - this._perMuzzleData[index].muzzlePositionBone = bone; + key: 'ChangePositionCartesian', + value: function ChangePositionCartesian(startPosition, endPosition) { + _global.vec3.copy(this.position1, startPosition); + _global.vec3.copy(this.position2, endPosition); + this.OnValueChanged(); } /** - * Gets a muzzle's transform - * @param {number} index - * @returns {mat4} + * Changes cartesian intermediate position + * @param {vec3} intermediatePosition */ }, { - key: 'GetMuzzleTransform', - value: function GetMuzzleTransform(index) { - return this._perMuzzleData[index].muzzleTransform; + key: 'ChangeIntermediateCartesian', + value: function ChangeIntermediateCartesian(intermediatePosition) { + _global.vec3.copy(this.intermediatePosition, intermediatePosition); + this.OnValueChanged(); } /** - * Prepares the firing effect - * @param {number} delay - * @param {number} [muzzleID=-1] + * Changes positions from spherical + * @param {vec3} startPosition + * @param {vec3} endPosition + * @param {vec3} middle + * @param {vec3} center */ }, { - key: 'PrepareFiring', - value: function PrepareFiring(delay) { - var muzzleID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1; - - for (var i = 0; i < this.stretch.length; ++i) { - if (muzzleID < 0 || muzzleID === i) { - this._perMuzzleData[i].currentStartDelay = delay + this._perMuzzleData[i].constantDelay; - this._perMuzzleData[i].started = false; - this._perMuzzleData[i].readyToStart = false; - this._perMuzzleData[i].elapsedTime = 0; - } else { - this._perMuzzleData[i].currentStartDelay = Number.MAX_VALUE; - this._perMuzzleData[i].started = false; - this._perMuzzleData[i].readyToStart = false; - this._perMuzzleData[i].elapsedTime = 0; - } - } - this.isFiring = true; + key: 'ChangeSpherical', + value: function ChangeSpherical(startPosition, endPosition, middle, center) { + _global.vec3.fromSpherical(this.position1, startPosition, center); + _global.vec3.fromSpherical(this.position2, endPosition, center); + _global.vec3.fromSpherical(this.intermediatePosition, middle, center); + this.OnValueChanged(); } /** - * Starts a muzzle effect - * @param {number} muzzleID + * Changes position from spherical coordinates + * @param {vec3} startPosition + * @param {vec3} endPosition + * @param {vec3} center */ }, { - key: 'StartMuzzleEffect', - value: function StartMuzzleEffect(muzzleID) { - var stretch = this.stretch[muzzleID]; - for (var i = 0; i < stretch.curveSets.length; ++i) { - var curveSet = stretch.curveSets[i]; - switch (curveSet.name) { - case 'play_start': - case 'play_loop': - curveSet.PlayFrom(-this._perMuzzleData[muzzleID].currentStartDelay); - break; - - case 'play_stop': - curveSet.Stop(); - break; - } - } - this._perMuzzleData[muzzleID].started = true; - this._perMuzzleData[muzzleID].readyToStart = false; + key: 'ChangePositionSpherical', + value: function ChangePositionSpherical(startPosition, endPosition, center) { + _global.vec3.fromSpherical(this.position1, startPosition, center); + _global.vec3.fromSpherical(this.position2, endPosition, center); + this.OnValueChanged(); } /** - * Stops the firing effect + * Changes spherical intermediate position + * @param {vec3} intermediatePosition + * @param {vec3} center */ }, { - key: 'StopFiring', - value: function StopFiring() { - for (var j = 0; j < this.stretch.length; ++j) { - var stretch = this.stretch[j]; - for (var i = 0; i < stretch.curveSets.length; ++i) { - var curveSet = stretch.curveSets[i]; - switch (curveSet.name) { - case 'play_start': - case 'play_loop': - curveSet.Stop(); - break; - - case 'play_stop': - curveSet.Play(); - break; - } - } - this._perMuzzleData[j].started = false; - this._perMuzzleData[j].readyToStart = false; - this._perMuzzleData[j].currentStartDelay = 0; - this._perMuzzleData[j].elapsedTime = 0; - } - this.isFiring = false; + key: 'ChangeIntermediateSpherical', + value: function ChangeIntermediateSpherical(intermediatePosition, center) { + _global.vec3.fromSpherical(this.intermediatePosition, intermediatePosition, center); + this.OnValueChanged(); } /** - * Gets resources - * @param {Array} [out=[]} - * @returns {Array} out + * Changes multi line color + * @param {vec4} color + * @param {number} border */ }, { - key: 'GetResources', - value: function GetResources() { - var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - - for (var i = 0; i < this.stretch.length; i++) { - this.stretch[i].GetResources(out); - } - return out; + key: 'ChangeMultiColor', + value: function ChangeMultiColor(color, border) { + _global.vec4.copy(this.multiColor, color); + this.multiColorBorder = border; + this.OnValueChanged(); } /** - * Updates view dependant data + * Changes animated color settings + * @param {vec4} color + * @param {number} speed + * @param {number} scale */ }, { - key: 'UpdateViewDependentData', - value: function UpdateViewDependentData() { - for (var i = 0; i < this.stretch.length; ++i) { - this.stretch[i].UpdateViewDependentData(); - } + key: 'ChangeAnimation', + value: function ChangeAnimation(color, speed, scale) { + _global.vec4.copy(this.overlayColor, color); + this.animationSpeed = speed; + this.animationScale = scale; + this.OnValueChanged(); } /** - * Per frame update - * @param {number} dt - Delta time + * Changes line segmentation + * @param {number} numOfSegments */ }, { - key: 'Update', - value: function Update(dt) { - for (var i = 0; i < this.stretch.length; ++i) { - if (this._perMuzzleData[i].started) { - this._perMuzzleData[i].elapsedTime += dt; - } - - if (this._perMuzzleData[i].elapsedTime < this._firingDuration || this.isLoopFiring) { - if (this.isFiring) { - if (!this._perMuzzleData[i].started) { - if (this._perMuzzleData[i].readyToStart) { - this.StartMuzzleEffect(i); - this._perMuzzleData[i].currentStartDelay = 0; - this._perMuzzleData[i].elapsedTime = 0; - } else { - this._perMuzzleData[i].currentStartDelay -= dt; - } - - if (this._perMuzzleData[i].currentStartDelay <= 0) { - this._perMuzzleData[i].readyToStart = true; - } - } else { - if (this.useMuzzleTransform) { - this.stretch[i].SetSourceTransform(this._perMuzzleData[i].muzzleTransform); - } else { - this.stretch[i].SetSourcePosition(this._perMuzzleData[i].muzzlePosition); - } - this.stretch[i].SetDestinationPosition(this.endPosition); - this.stretch[i].SetIsNegZForward(true); - } - } - } - this.stretch[i].Update(dt); + key: 'ChangeSegmentation', + value: function ChangeSegmentation(numOfSegments) { + if (this.type !== EveCurveLineSetItem.Type.STRAIGHT) { + this.numOfSegments = numOfSegments; + this.OnValueChanged(); } } /** - * Gets render batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator - * @param {Tw2PerObjectData} perObjectData + * Creates a line from an object + * @param {*} [opt={}] + * @returns {EveCurveLineSetItem} */ - }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator, perObjectData) { - if (!this.display || !this.isFiring) return; + }], [{ + key: 'create', + value: function create() { + var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - for (var i = 0; i < this.stretch.length; ++i) { - if (this._perMuzzleData[i].started && (this._firingDuration >= this._perMuzzleData[i].elapsedTime || this.isLoopFiring)) { - this.stretch[i].GetBatches(mode, accumulator, perObjectData); - } - } + var item = new this(); + _global.util.assignIfExists(item, opt, ['name', 'display', 'type', 'position1', 'color1', 'position2', 'color2', 'intermediatePosition', 'width', 'multiColor', 'multiColorBorder', 'overlayColor', 'animationSpeed', 'animationScale', 'numOfSegments']); + return item; } }]); - return EveTurretFiringFX; -}(); - -/***/ }), -/* 183 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.EveEffectRoot = undefined; - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _index = __webpack_require__(0); + return EveCurveLineSetItem; +}(_EveObjectSet2.EveObjectSetItem); -var _index2 = __webpack_require__(1); +/** + * Curve line types + * @type {{INVALID: number, STRAIGHT: number, SPHERED: number, CURVED: number}} + */ -var _EveObject2 = __webpack_require__(15); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +EveCurveLineSetItem.Type = { + INVALID: 0, + STRAIGHT: 1, + SPHERED: 2, + CURVED: 3 +}; -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } +/** + * Default curved line segmentation + * @type {number} + */ +EveCurveLineSetItem.DEFAULT_CURVED_SEGMENTS = 20; -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } +/** + * Default sphered line segmentation + * @type {number} + */ +EveCurveLineSetItem.DEFAULT_SPHERED_SEGEMENTS = 20; /** - * EveEffectRoot root objects for FX, can be put into scene's objects array + * EveCurveLineSet * - * @property {string} name - * @property {boolean} display - * @property {[{}]} curveSets - * @property {[{}]} effectChildren - * @property {vec3} scaling - * @property {quat} rotation + * @property {Tw2Effect} lineEffect + * @property {?Tw2Effect} pickEffect + * @property {number} lineWidthFactor + * @property {boolean} additive + * @property {number} depthOffset * @property {vec3} translation - * @property {mat4} localTransform - * @property {mat4} rotationTransform - * @property {vec3} boundingSphereCenter - * @property {number} boundingSphereRadius - * @property {number} duration + * @property {quat} rotation + * @property {vec3} scaling + * @property {mat4} transform + * @property {mat4} parentTransform + * @property {number} _vertexSize + * @property {number} _vbSize + * @property {?WebGLBuffer} _vb * @property {Tw2PerObjectData} _perObjectData + * @property {Tw2VertexDeclaration} _decl * @class */ -var EveEffectRoot = exports.EveEffectRoot = function (_EveObject) { - _inherits(EveEffectRoot, _EveObject); - function EveEffectRoot() { - _classCallCheck(this, EveEffectRoot); +var EveCurveLineSet = exports.EveCurveLineSet = function (_EveObjectSet) { + _inherits(EveCurveLineSet, _EveObjectSet); - var _this = _possibleConstructorReturn(this, (EveEffectRoot.__proto__ || Object.getPrototypeOf(EveEffectRoot)).call(this)); + function EveCurveLineSet() { + _classCallCheck(this, EveCurveLineSet); - _this.curveSets = []; - _this.effectChildren = []; - _this.duration = 0; - _this.scaling = _index.vec3.fromValues(1, 1, 1); - _this.rotation = _index.quat.create(); - _this.translation = _index.vec3.create(); - _this.localTransform = _index.mat4.create(); - _this.rotationTransform = _index.mat4.create(); - _this.boundingSphereCenter = _index.vec3.create(); - _this.boundingSphereRadius = 0; + var _this2 = _possibleConstructorReturn(this, (EveCurveLineSet.__proto__ || Object.getPrototypeOf(EveCurveLineSet)).call(this)); - _this._perObjectData = new _index2.Tw2PerObjectData(); - _this._perObjectData.perObjectVSData = new _index2.Tw2RawData(); - _this._perObjectData.perObjectVSData.Declare('WorldMat', 16); - _this._perObjectData.perObjectVSData.Declare('WorldMatLast', 16); - _this._perObjectData.perObjectVSData.Declare('Shipdata', 4); - _this._perObjectData.perObjectVSData.Declare('Clipdata1', 4); - _this._perObjectData.perObjectVSData.Declare('EllipsoidRadii', 4); - _this._perObjectData.perObjectVSData.Declare('EllipsoidCenter', 4); - _this._perObjectData.perObjectVSData.Declare('CustomMaskMatrix0', 16); - _this._perObjectData.perObjectVSData.Declare('CustomMaskMatrix1', 16); - _this._perObjectData.perObjectVSData.Declare('CustomMaskData0', 4); - _this._perObjectData.perObjectVSData.Declare('CustomMaskData1', 4); - _this._perObjectData.perObjectVSData.Declare('JointMat', 696); - _this._perObjectData.perObjectVSData.Create(); + _this2.lineEffect = _core.Tw2Effect.create({ + effectFilePath: 'res:/Graphics/Effect/Managed/Space/SpecialFX/Lines3D.fx', + textures: { + 'TexMap': 'res:/texture/global/white.dds.0.png', + 'OverlayTexMap': 'res:/texture/global/white.dds.0.png' + } + }); - _this._perObjectData.perObjectPSData = new _index2.Tw2RawData(); - _this._perObjectData.perObjectPSData.Declare('Shipdata', 4); - _this._perObjectData.perObjectPSData.Declare('Clipdata1', 4); - _this._perObjectData.perObjectPSData.Declare('Clipdata2', 4); - _this._perObjectData.perObjectPSData.Declare('ShLighting', 4 * 7); - _this._perObjectData.perObjectPSData.Declare('CustomMaskMaterialID0', 4); - _this._perObjectData.perObjectPSData.Declare('CustomMaskMaterialID1', 4); - _this._perObjectData.perObjectPSData.Declare('CustomMaskTarget0', 4); - _this._perObjectData.perObjectPSData.Declare('CustomMaskTarget1', 4); - _this._perObjectData.perObjectPSData.Create(); - return _this; + _this2.pickEffect = null; + _this2.lineWidthFactor = 1; + _this2.additive = false; + _this2.pickable = true; + _this2.depthOffset = 0; + _this2.translation = _global.vec3.create(); + _this2.rotation = _global.quat.create(); + _this2.scaling = _global.vec3.fromValues(1, 1, 1); + _this2.transform = _global.mat4.create(); + _this2.parentTransform = _global.mat4.create(); + _this2._vertexSize = 26; + _this2._vbSize = 0; + _this2._vb = null; + + _this2._perObjectData = new _core.Tw2PerObjectData(); + _this2._perObjectData.perObjectVSData = new _core.Tw2RawData(); + _this2._perObjectData.perObjectVSData.Declare('WorldMat', 16); + _this2._perObjectData.perObjectVSData.Create(); + _this2._perObjectData.perObjectPSData = new _core.Tw2RawData(); + _this2._perObjectData.perObjectPSData.Declare('WorldMat', 16); + _this2._perObjectData.perObjectPSData.Create(); + + _this2._decl = new _core.Tw2VertexDeclaration(); + _this2._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.POSITION, 0, _global.device.gl.FLOAT, 3, 0)); + _this2._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 0, _global.device.gl.FLOAT, 4, 12)); + _this2._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 1, _global.device.gl.FLOAT, 4, 28)); + _this2._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 2, _global.device.gl.FLOAT, 3, 44)); + _this2._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 0, _global.device.gl.FLOAT, 4, 56)); + _this2._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 1, _global.device.gl.FLOAT, 4, 72)); + _this2._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 2, _global.device.gl.FLOAT, 4, 88)); + _this2._decl.stride = 4 * _this2._vertexSize; + _this2._decl.RebuildHash(); + + EveCurveLineSet.init(); + return _this2; } /** - * Starts playing the effectRoot's curveSets if they exist + * Alias for this.items + * @returns {Array} */ - _createClass(EveEffectRoot, [{ - key: 'Start', - value: function Start() { - for (var i = 0; i < this.curveSets.length; ++i) { - this.curveSets[i].Play(); - } + _createClass(EveCurveLineSet, [{ + key: 'Initialize', + + + /** + * Initializes the curve line set + */ + value: function Initialize() { + this.OnValueChanged(); + this.Rebuild(); } /** - * Stops the effectRoot's curveSets from playing + * Creates a straight line + * @param {vec3} start + * @param {vec3} end + * @param {number} [width] + * @param {vec4} [startColor] + * @param {vec4} [endColor] + * @returns {EveCurveLineSetItem} */ }, { - key: 'Stop', - value: function Stop() { - for (var i = 0; i < this.curveSets.length; ++i) { - this.curveSets[i].Stop(); - } + key: 'AddStraightLine', + value: function AddStraightLine(start, end, width, startColor, endColor) { + return this.CreateItem({ + type: EveCurveLineSetItem.Type.STRAIGHT, + position1: start, + position2: end, + color1: startColor, + color2: endColor, + width: width + }); } /** - * Gets effect root res objects - * @param {Array} [out=[]] - Optional receiving array - * @returns {Array.} [out] + * Creates and adds a curved line from cartesian coordinates + * @param {vec3} start + * @param {vec3} end + * @param {vec3} center + * @param {number} [width] + * @param {vec4} [startColor] + * @param {vec4} [endColor] + * @returns {EveCurveLineSetItem} */ }, { - key: 'GetResources', - value: function GetResources() { - var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - - for (var i = 0; i < this.effectChildren.length; ++i) { - this.effectChildren[i].GetResources(out); - } - return out; + key: 'AddCurvedLineCrt', + value: function AddCurvedLineCrt(start, end, center, width, startColor, endColor) { + return this.CreateItem({ + type: EveCurveLineSetItem.Type.CURVED, + position1: start, + position2: end, + intermediatePosition: center, + color1: startColor, + color2: endColor, + width: width, + numOfSegments: EveCurveLineSetItem.DEFAULT_CURVED_SEGMENTS + }); } /** - * Internal per frame update - * @param {number} dt - Delta Time + * Creates and adds a curved line from spherical coordinates + * @param {vec3} start + * @param {vec3} end + * @param {vec3} center + * @param {vec3} middle + * @param {number} [width] + * @param {vec4} [startColor] + * @param {vec4} [endColor] + * @returns {EveCurveLineSetItem} */ }, { - key: 'Update', - value: function Update(dt) { - _index.quat.normalize(this.rotation, this.rotation); // Don't really need to normalize... - _index.mat4.fromRotationTranslationScale(this.localTransform, this.rotation, this.translation, this.scaling); + key: 'AddCurvedLineSph', + value: function AddCurvedLineSph(start, end, center, middle, width, startColor, endColor) { + var g = EveCurveLineSet.global; + return this.CreateItem({ + type: EveCurveLineSetItem.Type.CURVED, + position1: _global.vec3.fromSpherical(g.vec3_0, start, center), + position2: _global.vec3.fromSpherical(g.vec3_1, end, center), + intermediatePosition: _global.vec3.fromSpherical(g.vec3_2, middle, center), + color1: startColor, + color2: endColor, + width: width, + numOfSegments: EveCurveLineSetItem.DEFAULT_CURVED_SEGMENTS + }); + } - for (var i = 0; i < this.curveSets.length; ++i) { - this.curveSets[i].Update(dt); - } + /** + * Creates and adds a sphered line from cartesian coordinates + * @param {vec3} start + * @param {vec3} end + * @param {vec3} center + * @param {number} [width] + * @param {vec4} [startColor] + * @param {vec4} [endColor] + * @returns {EveCurveLineSetItem} + */ - for (var _i = 0; _i < this.effectChildren.length; ++_i) { - this.effectChildren[_i].Update(dt, this.localTransform); - } + }, { + key: 'AddSpheredLineCrt', + value: function AddSpheredLineCrt(start, end, center, width, startColor, endColor) { + return this.CreateItem({ + type: EveCurveLineSetItem.Type.SPHERED, + position1: start, + position2: end, + intermediatePosition: center, + color1: startColor, + color2: endColor, + width: width, + numOfSegments: EveCurveLineSetItem.DEFAULT_SPHERED_SEGEMENTS + }); } /** - * Gets render batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator + * Creates and adds a sphered line from spherical coordinates + * @param {vec3} start + * @param {vec3} end + * @param {vec3} center + * @param {vec3} middle + * @param {number} [width] + * @param {vec4} [startColor] + * @param {vec4} [endColor] + * @returns {EveCurveLineSetItem} */ }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator) { - if (!this.display) return; - - for (var i = 0; i < this.effectChildren.length; ++i) { - this.effectChildren[i].GetBatches(mode, accumulator, this._perObjectData); - } + key: 'AddSpheredLineSph', + value: function AddSpheredLineSph(start, end, center, middle, width, startColor, endColor) { + var g = EveCurveLineSet.global; + return this.CreateItem({ + type: EveCurveLineSetItem.Type.SPHERED, + position1: _global.vec3.fromSpherical(g.vec3_0, start, center), + position2: _global.vec3.fromSpherical(g.vec3_1, end, center), + intermediatePosition: _global.vec3.fromSpherical(g.vec3_2, middle, center), + color1: startColor, + color2: endColor, + width: width, + numOfSegments: EveCurveLineSetItem.DEFAULT_SPHERED_SEGEMENTS + }); } - }]); - return EveEffectRoot; -}(_EveObject2.EveObject); + /** + * Fire on value changes + */ -/***/ }), -/* 184 */ -/***/ (function(module, exports, __webpack_require__) { + }, { + key: 'OnValueChanged', + value: function OnValueChanged() { + _global.mat4.fromRotationTranslationScale(this.transform, this.rotation, this.translation, this.scaling); + this._rebuildPending = true; + } -"use strict"; + /** + * Per frame update + * @param {mat4} parentTransform + */ + }, { + key: 'UpdateViewDependentData', + value: function UpdateViewDependentData(parentTransform) { + _global.mat4.copy(this.parentTransform, parentTransform); + } -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.EveMissile = exports.EveMissileWarhead = undefined; + /** + * Per frame update + */ -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + }, { + key: 'Update', + value: function Update() { + if (this._rebuildPending) { + this.Rebuild(); + } + } -var _math = __webpack_require__(0); + /** + * Unloads the line set's buffers + */ -var _core = __webpack_require__(1); + }, { + key: 'Unload', + value: function Unload() { + if (this._vb) { + _global.device.gl.deleteBuffer(this._vb); + this._vb = null; + } + } -var _EveObject2 = __webpack_require__(15); + /** + * Rebuilds the line set + */ -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + }, { + key: 'Rebuild', + value: function Rebuild() { + EveCurveLineSet.RebuildItems(this); + this._vb = null; + this._vbSize = this.lineCount; + this._rebuildPending = false; + var visibleItems = this._visibleItems.length; + if (!visibleItems) return; -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + var g = EveCurveLineSet.global, + data = new Float32Array(this._vbSize * 6 * this._vertexSize), + startDir = g.vec3_0, + endDir = g.vec3_1, + startDirNrm = g.vec3_2, + endDirNrm = g.vec3_3, + rotationAxis = g.vec3_4, + tangent1 = g.vec3_5, + tangent2 = g.vec3_6, + rotationMatrix = g.mat4_0; -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + var dir1 = g.vec3_7, + dir2 = g.vec3_8, + pos1 = g.vec3_9, + pos2 = g.vec3_10, + col1 = g.vec4_0, + col2 = g.vec4_1, + offset = 0, + tmp = void 0; -/** - * EveMissileWarhead - * - * @property {String} name - * @property {Boolean} display - * @property {Tw2Mesh} mesh - * @property {EveSpriteSet} spriteSet - * @property {Number} state - * @property {Number} time - * @property {Number} durationEjectPhase - * @property {Number} startEjectVelocity - * @property {Number} acceleration - * @property {Number} maxExplosionDistance - * @property {Number} impactSize - * @property {Number} impactDuration - * @property {vec3} pathOffset - * @property {mat4} transform - * @property {vec3} velocity - * @property {Tw2PerObjectData} _perObjectData - * @class - */ -var EveMissileWarhead = exports.EveMissileWarhead = function (_EveObject) { - _inherits(EveMissileWarhead, _EveObject); + for (var i = 0; i < visibleItems; ++i) { + var item = this._visibleItems[i]; + switch (item.type) { + case EveCurveLineSetItem.Type.INVALID: + break; - function EveMissileWarhead() { - _classCallCheck(this, EveMissileWarhead); + case EveCurveLineSetItem.Type.STRAIGHT: + EveCurveLineSet.WriteLineVerticesToBuffer(this, item.position1, item.color1, 0, item.position2, item.color2, 1, i, data, offset); + offset += 6 * this._vertexSize; + break; - var _this = _possibleConstructorReturn(this, (EveMissileWarhead.__proto__ || Object.getPrototypeOf(EveMissileWarhead)).call(this)); + case EveCurveLineSetItem.Type.SPHERED: + _global.vec3.subtract(startDir, item.position1, item.intermediatePosition); + _global.vec3.subtract(endDir, item.position2, item.intermediatePosition); + _global.vec3.normalize(startDirNrm, startDir); + _global.vec3.normalize(endDirNrm, endDir); + _global.vec3.cross(rotationAxis, startDir, endDir); - _this.mesh = null; - _this.spriteSet = null; - _this.state = EveMissileWarhead.State.READY; - _this.time = 0; - _this.durationEjectPhase = 0; - _this.startEjectVelocity = 0; - _this.acceleration = 1; - _this.maxExplosionDistance = 40; - _this.impactSize = 0; - _this.impactDuration = 0.6; - _this.pathOffset = _math.vec3.create(); - _this.transform = _math.mat4.create(); - _this.velocity = _math.vec3.create(); + var fullAngle = Math.acos(_global.vec3.dot(startDirNrm, endDirNrm)), + segmentAngle = fullAngle / item.numOfSegments; - _this._perObjectData = new _core.Tw2PerObjectData(); - _this._perObjectData.perObjectVSData = new _core.Tw2RawData(); - _this._perObjectData.perObjectVSData.Declare('WorldMat', 16); - _this._perObjectData.perObjectVSData.Declare('WorldMatLast', 16); - _this._perObjectData.perObjectVSData.Declare('Shipdata', 4); - _this._perObjectData.perObjectVSData.Declare('Clipdata1', 4); - _this._perObjectData.perObjectVSData.Create(); + _global.mat4.identity(rotationMatrix); + _global.mat4.rotate(rotationMatrix, rotationMatrix, segmentAngle, rotationAxis); + _global.vec3.copy(dir1, startDir); + _global.vec4.copy(col1, item.color1); - _this._perObjectData.perObjectPSData = new _core.Tw2RawData(); - _this._perObjectData.perObjectPSData.Declare('Shipdata', 4); - _this._perObjectData.perObjectPSData.Declare('Clipdata1', 4); - _this._perObjectData.perObjectPSData.Declare('Clipdata2', 4); - _this._perObjectData.perObjectPSData.Create(); + for (var j = 0; j < this.lines[i].numOfSegments; ++j) { + var segmentFactor = (j + 1) / item.numOfSegments; + _global.vec3.transformMat4(dir2, dir1, rotationMatrix); + col2[0] = item.color1[0] * (1 - segmentFactor) + item.color2[0] * segmentFactor; + col2[1] = item.color1[1] * (1 - segmentFactor) + item.color2[1] * segmentFactor; + col2[2] = item.color1[2] * (1 - segmentFactor) + item.color2[2] * segmentFactor; + col2[3] = item.color1[3] * (1 - segmentFactor) + item.color2[3] * segmentFactor; + _global.vec3.add(pos1, dir1, item.intermediatePosition); + _global.vec3.add(pos2, dir2, item.intermediatePosition); + EveCurveLineSet.WriteLineVerticesToBuffer(this, pos1, col1, j / item.numOfSegments, pos2, col2, segmentFactor, i, data, offset); + offset += 6 * this._vertexSize; + + tmp = dir1; + dir1 = dir2; + dir2 = tmp; + tmp = col1; + col1 = col2; + col2 = tmp; + } + break; - _this._perObjectData.perObjectVSData.Get('Shipdata')[1] = 1; - _this._perObjectData.perObjectPSData.Get('Shipdata')[1] = 1; - _this._perObjectData.perObjectVSData.Get('Shipdata')[3] = -10; - _this._perObjectData.perObjectPSData.Get('Shipdata')[3] = 1; - return _this; - } + case EveCurveLineSetItem.Type.CURVED: + _global.vec3.subtract(tangent1, item.intermediatePosition, item.position1); + _global.vec3.subtract(tangent2, item.position2, item.intermediatePosition); + _global.vec3.copy(pos1, item.position1); + _global.vec3.copy(col1, item.color1); - /** - * Initializes the warhead - */ + for (var _j = 0; _j < item.numOfSegments; ++_j) { + var _segmentFactor = (_j + 1) / item.numOfSegments; + _global.vec3.hermite(pos2, item.position1, tangent1, item.position2, tangent2, _segmentFactor); + col2[0] = item.color1[0] * (1 - _segmentFactor) + item.color2[0] * _segmentFactor; + col2[1] = item.color1[1] * (1 - _segmentFactor) + item.color2[1] * _segmentFactor; + col2[2] = item.color1[2] * (1 - _segmentFactor) + item.color2[2] * _segmentFactor; + col2[3] = item.color1[3] * (1 - _segmentFactor) + item.color2[3] * _segmentFactor; + EveCurveLineSet.WriteLineVerticesToBuffer(this, pos1, col1, _j / item.numOfSegments, pos2, col2, _segmentFactor, i, data, offset); + offset += 6 * this._vertexSize; + tmp = pos1; + pos1 = pos2; + pos2 = tmp; + tmp = col1; + col1 = col2; + col2 = tmp; + } + } + } - _createClass(EveMissileWarhead, [{ - key: 'Initialize', - value: function Initialize() { - if (this.spriteSet) this.spriteSet.UseQuads(true); + //if (this._vb) device.gl.deleteBuffer(this._vb); + this._vb = _global.device.gl.createBuffer(); + _global.device.gl.bindBuffer(_global.device.gl.ARRAY_BUFFER, this._vb); + _global.device.gl.bufferData(_global.device.gl.ARRAY_BUFFER, data, _global.device.gl.STATIC_DRAW); + _global.device.gl.bindBuffer(_global.device.gl.ARRAY_BUFFER, null); } /** - * Sets up the warhead for rendering - * @param {mat4} transform - Initial local to world transform + * Gets render batches + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator */ }, { - key: 'Launch', - value: function Launch(transform) { - _math.mat4.copy(this.transform, transform); - this.velocity[0] = transform[8] * this.startEjectVelocity; - this.velocity[1] = transform[9] * this.startEjectVelocity; - this.velocity[2] = transform[10] * this.startEjectVelocity; - this.time = 0; - this.state = EveMissileWarhead.State.IN_FLIGHT; + key: 'GetBatches', + value: function GetBatches(mode, accumulator) { + if (!this.display || !this._vb) return; + + var effect = void 0; + switch (mode) { + case _global.device.RM_TRANSPARENT: + if (this.additive || !this.lineEffect) return; + effect = this.lineEffect; + break; + + case _global.device.RM_ADDITIVE: + if (!this.additive || !this.lineEffect) return; + effect = this.lineEffect; + break; + + case _global.device.RM_PICKABLE: + if (!this.pickable || !this.pickEffect) return; + effect = this.pickEffect; + } + + var batch = new _core.Tw2ForwardingRenderBatch(), + worldTransform = EveCurveLineSet.global.mat4_0; + + _global.mat4.multiply(worldTransform, this.transform, this.parentTransform); + _global.mat4.transpose(this._perObjectData.perObjectVSData.Get('WorldMat'), worldTransform); + _global.mat4.transpose(this._perObjectData.perObjectPSData.Get('WorldMat'), worldTransform); + batch.perObjectData = this._perObjectData; + batch.geometryProvider = this; + batch.renderMode = mode; + batch.effect = effect; + accumulator.Commit(batch); } /** - * Creates a clone of the warhead - * @returns {EveMissileWarhead} + * Per frame update + * @param {Tw2ForwardingRenderBatch} batch + * @param {string} technique - technique name + * @returns {boolean} */ }, { - key: 'Clone', - value: function Clone() { - var warhead = new EveMissileWarhead(); - warhead.mesh = this.mesh; - warhead.spriteSet = this.spriteSet; - return warhead; + key: 'Render', + value: function Render(batch, technique) { + if (!batch.effect || !batch.effect.IsGood()) return false; + + _global.device.gl.bindBuffer(_global.device.gl.ARRAY_BUFFER, this._vb); + + var passCount = batch.effect.GetPassCount(technique); + for (var pass = 0; pass < passCount; ++pass) { + batch.effect.ApplyPass(technique, pass); + var passInput = batch.effect.GetPassInput(technique, pass); + if (!this._decl.SetDeclaration(passInput, this._decl.stride)) return false; + _global.device.ApplyShadowState(); + _global.device.gl.drawArrays(_global.device.gl.TRIANGLES, 0, this._vbSize * 6); + } + return true; } /** - * Gets warhead resources - * @param {Array} [out=[]] - Receiving array - * @returns {Array} out + * Fills color vertices + * @param {EveCurveLineSetItem} item + * @param buffer + * @param {number} offset + * @returns {number} */ }, { - key: 'GetResources', - value: function GetResources() { - var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + key: 'lines', + get: function get() { + return this.items; + } - if (this.mesh) this.mesh.GetResources(out); - if (this.spriteSet) this.spriteSet.GetResources(out); + /** + * Alias for this.items + * @param {Array} arr + */ + , + set: function set(arr) { + this.items = arr; } /** - * Per frame view dependent data update + * Gets the current line count + * @returns {number} */ }, { - key: 'UpdateViewDependentData', - value: function UpdateViewDependentData() { - if (!this.display || this.state === EveMissileWarhead.State.DEAD) return; - _math.mat4.transpose(this._perObjectData.perObjectVSData.Get('WorldMat'), this.transform); - _math.mat4.transpose(this._perObjectData.perObjectVSData.Get('WorldMatLast'), this.transform); + key: 'lineCount', + get: function get() { + var count = 0; + for (var i = 0; i < this.items.length; i++) { + if (this.items[i].type !== EveCurveLineSetItem.Type.INVALID) { + count += this.items[i].numOfSegments; + } + } + return count; + } + }], [{ + key: 'FillColorVertices', + value: function FillColorVertices(item, buffer, offset) { + buffer[offset++] = item.multiColor[0]; + buffer[offset++] = item.multiColor[1]; + buffer[offset++] = item.multiColor[2]; + buffer[offset++] = item.multiColor[3]; + buffer[offset++] = item.overlayColor[0]; + buffer[offset++] = item.overlayColor[1]; + buffer[offset++] = item.overlayColor[2]; + buffer[offset++] = item.overlayColor[3]; + return offset; } /** - * Per frame update - * @param {Number} dt - Time since previous frame - * @param {vec3} missilePosition - Missile position - * @param {vec3} missileTarget - Missile target position + * Writes line vertices to the vertex buffer + * @param {EveCurveLineSet} lineSet + * @param {vec3} start + * @param {quat} startColor + * @param length1 + * @param {vec3} end + * @param {quat} endColor + * @param length2 + * @param {Number} lineID + * @param buffer + * @param {Number} offset */ }, { - key: 'Update', - value: function Update(dt, missilePosition, missileTarget) { - if (this.state === EveMissileWarhead.State.IN_FLIGHT) { - var g = EveMissileWarhead.global, - position = _math.mat4.getTranslation(g.vec3_0, this.transform), - tmp = g.vec3_1, - x = g.vec3_2, - y = g.vec3_3; + key: 'WriteLineVerticesToBuffer', + value: function WriteLineVerticesToBuffer(lineSet, start, startColor, length1, end, endColor, length2, lineID, buffer, offset) { + var item = lineSet.items[lineID]; - this.time += dt; - if (this.time > this.durationEjectPhase) { - _math.vec3.subtract(position, this.velocity, missilePosition); - _math.vec3.lerp(position, position, missilePosition, 1 - Math.exp(-dt * 0.9999)); - _math.mat4.setTranslation(this.transform, position); - _math.vec3.subtract(tmp, missileTarget, position); - if (_math.vec3.length(tmp) < this.maxExplosionDistance) { - console.log(position, tmp); - this.state = EveMissileWarhead.State.DEAD; - } - } else { - _math.vec3.scale(tmp, this.velocity, dt); - this.transform[12] += tmp[0]; - this.transform[13] += tmp[1]; - this.transform[14] += tmp[2]; - } + buffer[offset++] = start[0]; + buffer[offset++] = start[1]; + buffer[offset++] = start[2]; + buffer[offset++] = end[0] - start[0]; + buffer[offset++] = end[1] - start[1]; + buffer[offset++] = end[2] - start[2]; + buffer[offset++] = -lineSet.lineWidthFactor * item.width; + buffer[offset++] = 0; + buffer[offset++] = length1; + buffer[offset++] = item.multiColorBorder; + buffer[offset++] = length2 - length1; + buffer[offset++] = item.animationSpeed; + buffer[offset++] = item.animationScale; + buffer[offset++] = lineID; + buffer[offset++] = startColor[0]; + buffer[offset++] = startColor[1]; + buffer[offset++] = startColor[2]; + buffer[offset++] = startColor[3]; + offset = EveCurveLineSet.FillColorVertices(item, buffer, offset); - var z = _math.vec3.normalize(tmp, this.velocity); + buffer[offset++] = start[0]; + buffer[offset++] = start[1]; + buffer[offset++] = start[2]; + buffer[offset++] = end[0] - start[0]; + buffer[offset++] = end[1] - start[1]; + buffer[offset++] = end[2] - start[2]; + buffer[offset++] = lineSet.lineWidthFactor * item.width; + buffer[offset++] = 0; + buffer[offset++] = length1; + buffer[offset++] = item.multiColorBorder; + buffer[offset++] = length2 - length1; + buffer[offset++] = item.animationSpeed; + buffer[offset++] = item.animationScale; + buffer[offset++] = lineID; + buffer[offset++] = startColor[0]; + buffer[offset++] = startColor[1]; + buffer[offset++] = startColor[2]; + buffer[offset++] = startColor[3]; + offset = EveCurveLineSet.FillColorVertices(item, buffer, offset); - if (Math.abs(z[0]) < 0.99) { - _math.vec3.cross(x, z, [1, 0, 0]); - } else { - _math.vec3.cross(x, z, [0, 1, 0]); - } + buffer[offset++] = end[0]; + buffer[offset++] = end[1]; + buffer[offset++] = end[2]; + buffer[offset++] = start[0] - end[0]; + buffer[offset++] = start[1] - end[1]; + buffer[offset++] = start[2] - end[2]; + buffer[offset++] = -lineSet.lineWidthFactor * item.width; + buffer[offset++] = 1; + buffer[offset++] = length2; + buffer[offset++] = item.multiColorBorder; + buffer[offset++] = length2 - length1; + buffer[offset++] = item.animationSpeed; + buffer[offset++] = item.animationScale; + buffer[offset++] = lineID; + buffer[offset++] = endColor[0]; + buffer[offset++] = endColor[1]; + buffer[offset++] = endColor[2]; + buffer[offset++] = endColor[3]; + offset = EveCurveLineSet.FillColorVertices(item, buffer, offset); - _math.vec3.normalize(x, x); - _math.vec3.cross(y, x, z); - this.transform[0] = x[0]; - this.transform[1] = x[1]; - this.transform[2] = x[2]; - this.transform[4] = y[0]; - this.transform[5] = y[1]; - this.transform[6] = y[2]; - this.transform[8] = z[0]; - this.transform[9] = z[1]; - this.transform[10] = z[2]; - } + buffer[offset++] = start[0]; + buffer[offset++] = start[1]; + buffer[offset++] = start[2]; + buffer[offset++] = end[0] - start[0]; + buffer[offset++] = end[1] - start[1]; + buffer[offset++] = end[2] - start[2]; + buffer[offset++] = lineSet.lineWidthFactor * item.width; + buffer[offset++] = 0; + buffer[offset++] = length1; + buffer[offset++] = item.multiColorBorder; + buffer[offset++] = length2 - length1; + buffer[offset++] = item.animationSpeed; + buffer[offset++] = item.animationScale; + buffer[offset++] = lineID; + buffer[offset++] = startColor[0]; + buffer[offset++] = startColor[1]; + buffer[offset++] = startColor[2]; + buffer[offset++] = startColor[3]; + offset = EveCurveLineSet.FillColorVertices(item, buffer, offset); - if (this.spriteSet) { - this.spriteSet.Update(dt); - } + buffer[offset++] = end[0]; + buffer[offset++] = end[1]; + buffer[offset++] = end[2]; + buffer[offset++] = start[0] - end[0]; + buffer[offset++] = start[1] - end[1]; + buffer[offset++] = start[2] - end[2]; + buffer[offset++] = lineSet.lineWidthFactor * item.width; + buffer[offset++] = 1; + buffer[offset++] = length2; + buffer[offset++] = item.multiColorBorder; + buffer[offset++] = length2 - length1; + buffer[offset++] = item.animationSpeed; + buffer[offset++] = item.animationScale; + buffer[offset++] = lineID; + buffer[offset++] = endColor[0]; + buffer[offset++] = endColor[1]; + buffer[offset++] = endColor[2]; + buffer[offset++] = endColor[3]; + offset = EveCurveLineSet.FillColorVertices(item, buffer, offset); + + buffer[offset++] = end[0]; + buffer[offset++] = end[1]; + buffer[offset++] = end[2]; + buffer[offset++] = start[0] - end[0]; + buffer[offset++] = start[1] - end[1]; + buffer[offset++] = start[2] - end[2]; + buffer[offset++] = -lineSet.lineWidthFactor * item.width; + buffer[offset++] = 1; + buffer[offset++] = length2; + buffer[offset++] = item.multiColorBorder; + buffer[offset++] = length2 - length1; + buffer[offset++] = item.animationSpeed; + buffer[offset++] = item.animationScale; + buffer[offset++] = lineID; + buffer[offset++] = endColor[0]; + buffer[offset++] = endColor[1]; + buffer[offset++] = endColor[2]; + buffer[offset++] = endColor[3]; + EveCurveLineSet.FillColorVertices(item, buffer, offset); } /** - * Accumulates render batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator + * Initializes class global variables and scratch */ }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator) { - if (this.display && this.mesh && this.state !== EveMissileWarhead.State.DEAD) { - if (this.mesh) { - this.mesh.GetBatches(mode, accumulator, this._perObjectData); - } - - if (this.spriteSet) { - this.spriteSet.GetBatches(mode, accumulator, this._perObjectData, this.transform); - } + key: 'init', + value: function init() { + if (!EveCurveLineSet.global) { + EveCurveLineSet.global = { + vec3_0: _global.vec3.create(), // start direction + vec3_1: _global.vec3.create(), // end direction + vec3_2: _global.vec3.create(), // start direction normalized + vec3_3: _global.vec3.create(), // end direction normalized + vec3_4: _global.vec3.create(), // rotationAxis + vec3_5: _global.vec3.create(), // direction1 + vec3_6: _global.vec3.create(), // direction2 + vec3_7: _global.vec3.create(), // position 1 + vec3_8: _global.vec3.create(), // position 2 + vec3_9: _global.vec3.create(), // tangent1 + vec3_10: _global.vec3.create(), // tangent2 + vec4_0: _global.vec4.create(), // color 1 + vec4_1: _global.vec4.create(), // color 2 + mat4_0: _global.mat4.create() // rotationMatrix + }; } } }]); - return EveMissileWarhead; -}(_EveObject2.EveObject); + return EveCurveLineSet; +}(_EveObjectSet2.EveObjectSet); /** - * Missile warhead states - * @type {{READY: number, IN_FLIGHT: number, DEAD: number}} + * Class global variables and scratch */ -EveMissileWarhead.State = { - READY: 0, - IN_FLIGHT: 1, - DEAD: 2 -}; +EveCurveLineSet.global = null; /** - * EveMissile - * - * @property {number|string} _id - * @property {String} name - * @property {Boolean} display - * @property {Array} warheads - * @property {Array} curveSets - * @property {vec3} boundingSphereCenter - * @property {Number} boundingSphereRadius - * @property {vec3} position - * @property {vec3} target - * @property {Number} speed - * @property {?function(EveMissileWarhead): void} warheadExplosionCallback - * @property {?function(EveMissile): void} missileFinishedCallback - * @class + * Line set item constructor + * @type {EveCurveLineSetItem} */ +EveCurveLineSet.Item = EveCurveLineSetItem; -var EveMissile = exports.EveMissile = function () { - function EveMissile() { - _classCallCheck(this, EveMissile); - - this._id = _math.util.generateID(); - this.name = ''; - this.display = true; - this.warheads = []; - this.curveSets = []; - this.speed = 1; - this.position = _math.vec3.create(); - this.target = _math.vec3.create(); - this.boundingSphereCenter = _math.vec3.create(); - this.boundingSphereRadius = 0; - this.warheadExplosionCallback = null; - this.missileFinishedCallback = null; - - EveMissile.init(); - } - - /** - * Prepares missile for rendering - * @param {vec3} position - Missile starting position - * @param {Array} turretTransforms - Turret muzzle local to world transforms - * @param {vec3} target - Target position - */ - - - _createClass(EveMissile, [{ - key: 'Launch', - value: function Launch(position, turretTransforms, target) { - _math.vec3.copy(this.position, position); - _math.vec3.copy(this.target, target); - - if (this.warheads.length > turretTransforms.length) { - this.warheads.splice(turretTransforms.length); - } else { - while (this.warheads.length < turretTransforms.length) { - this.warheads.push(this.warheads[0].Clone()); - } - } - - for (var i = 0; i < this.warheads.length; ++i) { - this.warheads[0].Launch(turretTransforms[i]); - } - } - - /** - * Gets missile res objects - * @param {Array} [out=[]] - Receiving array - * @returns {Array} out - */ - - }, { - key: 'GetResources', - value: function GetResources() { - var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - - for (var i = 0; i < this.warheads.length; ++i) { - this.warheads[i].GetResources(out); - } - } - - /** - * Per frame view dependent data update - */ +/***/ }), +/* 177 */ +/***/ (function(module, exports, __webpack_require__) { - }, { - key: 'UpdateViewDependentData', - value: function UpdateViewDependentData() { - for (var i = 0; i < this.warheads.length; ++i) { - this.warheads[i].UpdateViewDependentData(); - } - } +"use strict"; - /** - * Per frame update - * @param {Number} dt - Time since previous frame - */ - }, { - key: 'Update', - value: function Update(dt) { - var tmp = _math.vec3.subtract(EveMissileWarhead.global.vec3_0, this.target, this.position), - distance = _math.vec3.length(tmp); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.EveLocator = undefined; - if (distance > 0.1) { - _math.vec3.normalize(tmp, tmp); - _math.vec3.scale(tmp, tmp, Math.min(dt * this.speed, distance)); - _math.vec3.add(this.position, this.position, tmp); - } +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - for (var i = 0; i < this.curveSets.length; ++i) { - this.curveSets[i].Update(dt); - } +var _global = __webpack_require__(0); - var checkDead = false; - for (var _i = 0; _i < this.warheads.length; ++_i) { - var state = this.warheads[_i].state; - this.warheads[_i].Update(dt, this.position, this.target); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - if (state !== EveMissileWarhead.State.DEAD && this.warheads[_i].state === EveMissileWarhead.State.DEAD) { - if (this.warheadExplosionCallback) { - this.warheadExplosionCallback(this.warheads[_i]); - } - checkDead = true; - } - } +/** + * Contains transform information for T3 Attachments, Boosters, Turrets and XLTurrets + * + * @property {string} name - The locator's name + * @property {mat4} transform - The locator's transform + * @property {?number} atlasIndex0 - A booster locator's atlasIndex0 + * @property {?number} atlasIndex1 - A booster locator's atlasIndex1 + * @property {?Tw2Bone} bone - A turret locator's bone + */ +var EveLocator = exports.EveLocator = function () { + function EveLocator() { + _classCallCheck(this, EveLocator); - if (checkDead && this.missileFinishedCallback) { - for (var _i2 = 0; _i2 < this.warheads.length; ++_i2) { - if (this.warheads[_i2].state !== EveMissileWarhead.State.DEAD) { - return; - } - } - this.missileFinishedCallback(this); - } - } + this.name = ''; + this.transform = _global.mat4.create(); + this.atlasIndex0 = null; + this.atlasIndex1 = null; + this.bone = null; + } - /** - * Accumulates render batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator - */ + /** + * Gets the locator's bone from an animation controller + * @param {Tw2AnimationController} animationController + * @returns {?Tw2Bone} + */ - }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator) { - if (!this.display) return; - for (var i = 0; i < this.warheads.length; ++i) { - this.warheads[i].GetBatches(mode, accumulator); + _createClass(EveLocator, [{ + key: 'FindBone', + value: function FindBone(animationController) { + this.bone = null; + var model = animationController.FindModelForMesh(0); + if (model) { + for (var i = 0; i < model.bones.length; ++i) { + if (model.bones[i].boneRes.name === this.name) { + this.bone = model.bones[i]; + break; + } + } } + return this.bone; } }]); - return EveMissile; + return EveLocator; }(); +/** + * Locator name prefixes + * @type {{AUDIO: string, ATTACH: string, BOOSTER: string, TURRET: string, XL_TURRET: string}} + */ + + +EveLocator.Prefix = { + AUDIO: 'locator_audio', + ATTACH: 'locator_attach', + BOOSTER: 'locator_booster', + TURRET: 'locator_turret', + XL_TURRET: 'locator_xl' +}; + /***/ }), -/* 185 */ +/* 178 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -36042,17 +36526,15 @@ var EveMissile = exports.EveMissile = function () { Object.defineProperty(exports, "__esModule", { value: true }); -exports.EvePlanet = undefined; - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; +exports.EvePlaneSet = exports.EvePlaneSetItem = exports.EvePlaneSetBatch = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _core = __webpack_require__(1); +var _global = __webpack_require__(0); -var _EveTransform = __webpack_require__(61); +var _core = __webpack_require__(1); -var _EveObject2 = __webpack_require__(15); +var _EveObjectSet2 = __webpack_require__(6); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -36061,306 +36543,370 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * EvePlanet + * Plane set render batch * - * @property {string} name - * @property {boolean} display - * @property {EveTransform} highDetail - * @property {Tw2Effect} effectHeight - * @property {Tw2RenderTarget} heightMap - * @property {*} zOnlyModel - * @property {number} itemID - * @property {string} heightMapResPath1 - * @property {string} heightMapResPath2 - * @property {boolean} heightDirty - * @property {Array} lockedResources - * @property {Array.} watchedResources + * @property {EvePlaneSet} planeSet * @class */ -var EvePlanet = exports.EvePlanet = function (_EveObject) { - _inherits(EvePlanet, _EveObject); +var EvePlaneSetBatch = exports.EvePlaneSetBatch = function (_Tw2RenderBatch) { + _inherits(EvePlaneSetBatch, _Tw2RenderBatch); - function EvePlanet() { - _classCallCheck(this, EvePlanet); + function EvePlaneSetBatch() { + _classCallCheck(this, EvePlaneSetBatch); - var _this = _possibleConstructorReturn(this, (EvePlanet.__proto__ || Object.getPrototypeOf(EvePlanet)).call(this)); + var _this = _possibleConstructorReturn(this, (EvePlaneSetBatch.__proto__ || Object.getPrototypeOf(EvePlaneSetBatch)).call(this)); - _this.highDetail = new _EveTransform.EveTransform(); - _this.effectHeight = new _core.Tw2Effect(); - _this.heightMap = new _core.Tw2RenderTarget(); - _this.zOnlyModel = null; - _this.itemID = 0; - _this.heightMapResPath1 = ''; - _this.heightMapResPath2 = ''; - _this.heightDirty = false; - _this.lockedResources = []; - _this.watchedResources = []; + _this.planeSet = null; return _this; } /** - * Creates the planet - * @param {number} itemID - the item id is used for randomization - * @param {string} planetPath - .red file for a planet, or planet template - * @param {string} [atmospherePath] - optional .red file for a planet's atmosphere - * @param {string} heightMap1 - * @param {string} heightMap2 + * Commits the plan set + * @param {string} technique - technique name */ - _createClass(EvePlanet, [{ - key: 'Create', - value: function Create(itemID, planetPath, atmospherePath, heightMap1, heightMap2) { - var _this2 = this; + _createClass(EvePlaneSetBatch, [{ + key: 'Commit', + value: function Commit(technique) { + this.planeSet.Render(technique); + } + }]); - this.itemID = itemID; - this.heightMapResPath1 = heightMap1; - this.heightMapResPath2 = heightMap2; - this.highDetail.children = []; - this.heightDirty = true; + return EvePlaneSetBatch; +}(_core.Tw2RenderBatch); - _core.resMan.GetObject(planetPath, function (obj) { - return EvePlanet.MeshLoaded(_this2, obj); - }); - _core.resMan.GetObject('res:/dx9/model/worldobject/planet/planetzonly.red', function (obj) { - return _this2.zOnlyModel = obj; - }); +/** + * EvePlaneSetItem + * + * @property {number} boneIndex + * @property {number} groupIndex + * @property {number} maskAtlasID + * @property {vec3} position + * @property {vec3} scaling + * @property {quat} rotation + * @property {vec4} color + * @property {vec4} layer1Transform + * @property {vec4} layer2Transform + * @property {vec4} layer1Scroll + * @property {vec4} layer2Scroll + * @class + */ - if (atmospherePath) { - _core.resMan.GetObject(atmospherePath, function (obj) { - return _this2.highDetail.children.push(obj); - }); - } - } - /** - * GetPlanetResources - * Todo: Replace this, using this.GetResources(); - * @param obj - * @param visited - * @param result - */ +var EvePlaneSetItem = exports.EvePlaneSetItem = function (_EveObjectSetItem) { + _inherits(EvePlaneSetItem, _EveObjectSetItem); - }, { - key: 'GetPlanetResources', - value: function GetPlanetResources(obj, visited, result) { - if (visited.includes(obj)) return; - visited.push(obj); + function EvePlaneSetItem() { + _classCallCheck(this, EvePlaneSetItem); - if (obj && _typeof(obj['doNotPurge']) !== ( true ? 'undefined' : _typeof(undefined))) { - result.push(obj); - return; - } + var _this2 = _possibleConstructorReturn(this, (EvePlaneSetItem.__proto__ || Object.getPrototypeOf(EvePlaneSetItem)).call(this)); - for (var prop in obj) { - if (obj.hasOwnProperty(prop)) { - if (_typeof(obj[prop]) === 'object') { - this.GetPlanetResources(obj[prop], visited, result); - } - } - } + _this2.boneIndex = 0; + _this2.groupIndex = -1; + _this2.maskAtlasID = 0; + _this2.position = _global.vec3.create(); + _this2.scaling = _global.vec3.fromValues(1, 1, 1); + _this2.rotation = _global.quat.create(); + _this2.transform = _global.mat4.create(); + _this2.color = _global.vec4.fromValues(1, 1, 1, 1); + _this2.layer1Transform = _global.vec4.fromValues(1, 1, 0, 0); + _this2.layer2Transform = _global.vec4.fromValues(1, 1, 0, 0); + _this2.layer1Scroll = _global.vec4.create(); + _this2.layer2Scroll = _global.vec4.create(); + return _this2; + } + + /** + * Creates a plane set item from an object + * @param {*} opt + * @returns {EvePlaneSetItem} + */ + + + _createClass(EvePlaneSetItem, null, [{ + key: 'create', + value: function create() { + var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var item = new this(); + _global.util.assignIfExists(item, opt, ['name', 'display', 'boneIndex', 'groupIndex', 'maskAtlasID', 'position', 'scaling', 'rotation', 'transform', 'color', 'layer1Transform', 'layer2Transform', 'layer1Scroll', 'layer2Scroll']); + return item; } + }]); + + return EvePlaneSetItem; +}(_EveObjectSet2.EveObjectSetItem); + +/** + * EvePlaneSet + * + * @property {String} name + * @property {Array.} planes + * @property {Tw2Effect} effect + * @property {boolean} display + * @property {boolean} hideOnLowQuality + * @property {number} _time + * @property {WebGLBuffer} _vertexBuffer + * @property {WebGLBuffer} _indexBuffer + * @property {Tw2VertexDeclaration} _decl + * @class + */ + + +var EvePlaneSet = exports.EvePlaneSet = function (_EveObjectSet) { + _inherits(EvePlaneSet, _EveObjectSet); + + function EvePlaneSet() { + _classCallCheck(this, EvePlaneSet); + + var _this3 = _possibleConstructorReturn(this, (EvePlaneSet.__proto__ || Object.getPrototypeOf(EvePlaneSet)).call(this)); + + _this3.effect = null; + _this3.hideOnLowQuality = false; + _this3._time = 0; + _this3._vertexBuffer = null; + _this3._indexBuffer = null; + + _this3._decl = new _core.Tw2VertexDeclaration(); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 0, _global.device.gl.FLOAT, 4, 0)); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 1, _global.device.gl.FLOAT, 4, 16)); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 2, _global.device.gl.FLOAT, 4, 32)); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 0, _global.device.gl.FLOAT, 4, 48)); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 3, _global.device.gl.FLOAT, 4, 64)); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 4, _global.device.gl.FLOAT, 4, 80)); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 5, _global.device.gl.FLOAT, 4, 96)); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 6, _global.device.gl.FLOAT, 4, 112)); + _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 7, _global.device.gl.FLOAT, 3, 128)); + _this3._decl.RebuildHash(); + return _this3; + } + + /** + * Alias for this.items + * @returns {Array} + */ + + + _createClass(EvePlaneSet, [{ + key: 'GetResources', + /** - * Gets planet res objects + * Gets plane set res objects * @param {Array} [out=[]] - Optional receiving array - * @returns {Array.} [out] + * @returns {Array} {Array.} [out] */ - - }, { - key: 'GetResources', value: function GetResources() { var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - if (this.highDetail) this.highDetail.GetResources(out); - if (this.effectHeight) this.effectHeight.GetResources(out); + if (this.effect) { + this.effect.GetResources(out); + } return out; } /** - * Updates view dependent data - * @param {mat4} parentTransform + * Per frame update + * @param {number} dt - Delta Time */ }, { - key: 'UpdateViewDependentData', - value: function UpdateViewDependentData(parentTransform) { - this.highDetail.UpdateViewDependentData(parentTransform); - if (this.zOnlyModel) { - this.zOnlyModel.translation = this.highDetail.translation; - this.zOnlyModel.scaling = this.highDetail.scaling; - this.zOnlyModel.UpdateViewDependentData(parentTransform); + key: 'Update', + value: function Update(dt) { + this._time += dt; + + if (this._rebuildPending) { + this.Rebuild(); } } /** - * Per frame update - * @param {number} dt - delta time + * Unloads the set's buffers */ }, { - key: 'Update', - value: function Update(dt) { - this.highDetail.Update(dt); + key: 'Unload', + value: function Unload() { + if (this._vertexBuffer) { + _global.device.gl.deleteBuffer(this._vertexBuffer); + this._vertexBuffer = null; + } + + if (this._indexBuffer) { + _global.device.gl.deleteBuffer(this._indexBuffer); + this._indexBuffer = null; + } } /** - * Gets render batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator + * Rebuilds the plane set's buffers */ }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator) { - if (this.display && this.heightDirty && this.watchedResources.length && this.heightMapResPath1 !== '') { - for (var i = 0; i < this.watchedResources.length; ++i) { - if (this.watchedResources[i] && !this.watchedResources[i].IsGood()) return; - } + key: 'Rebuild', + value: function Rebuild() { + this.Unload(); + EvePlaneSet.RebuildItems(this); + this._rebuildPending = false; + var itemCount = this._visibleItems.length; + if (!itemCount) return; - this.watchedResources = []; + var vertexSize = 35, + mat4_0 = EvePlaneSet.global.mat4_0; - this.heightMap.Set(); - _core.device.SetStandardStates(_core.device.RM_FULLSCREEN); - _core.device.gl.clearColor(0.0, 0.0, 0.0, 0.0); - _core.device.gl.clear(_core.device.gl.COLOR_BUFFER_BIT); - _core.device.RenderFullScreenQuad(this.effectHeight); - this.heightMap.Unset(); + var array = new Float32Array(itemCount * 4 * vertexSize); + for (var i = 0; i < itemCount; ++i) { + var item = this._visibleItems[i], + offset = i * 4 * vertexSize; - this.heightDirty = false; - for (var _i = 0; _i < this.lockedResources.length; ++_i) { - this.lockedResources[_i].doNotPurge--; - } + array[offset + vertexSize - 3] = 0; + array[offset + vertexSize + vertexSize - 3] = 1; + array[offset + 2 * vertexSize + vertexSize - 3] = 2; + array[offset + 3 * vertexSize + vertexSize - 3] = 3; - var mainMesh = this.highDetail.children[0].mesh; - var originalEffect = null; + var itemTransform = _global.mat4.fromRotationTranslationScale(mat4_0, item.rotation, item.position, item.scaling); - if (mainMesh.transparentAreas.length) { - originalEffect = mainMesh.transparentAreas[0].effect; - } else if (mainMesh.opaqueAreas.length) { - originalEffect = mainMesh.opaqueAreas[0].effect; - } + for (var j = 0; j < 4; ++j) { + var vtxOffset = offset + j * vertexSize; + array[vtxOffset] = itemTransform[0]; + array[vtxOffset + 1] = itemTransform[4]; + array[vtxOffset + 2] = itemTransform[8]; + array[vtxOffset + 3] = itemTransform[12]; + array[vtxOffset + 4] = itemTransform[1]; + array[vtxOffset + 5] = itemTransform[5]; + array[vtxOffset + 6] = itemTransform[9]; + array[vtxOffset + 7] = itemTransform[13]; + array[vtxOffset + 8] = itemTransform[2]; + array[vtxOffset + 9] = itemTransform[6]; + array[vtxOffset + 10] = itemTransform[10]; + array[vtxOffset + 11] = itemTransform[14]; - if (originalEffect) { - originalEffect.parameters['HeightMap'].textureRes = this.heightMap.texture; + array[vtxOffset + 12] = item.color[0]; + array[vtxOffset + 13] = item.color[1]; + array[vtxOffset + 14] = item.color[2]; + array[vtxOffset + 15] = item.color[3]; + + array[vtxOffset + 16] = item.layer1Transform[0]; + array[vtxOffset + 17] = item.layer1Transform[1]; + array[vtxOffset + 18] = item.layer1Transform[2]; + array[vtxOffset + 19] = item.layer1Transform[3]; + + array[vtxOffset + 20] = item.layer2Transform[0]; + array[vtxOffset + 21] = item.layer2Transform[1]; + array[vtxOffset + 22] = item.layer2Transform[2]; + array[vtxOffset + 23] = item.layer2Transform[3]; + + array[vtxOffset + 24] = item.layer1Scroll[0]; + array[vtxOffset + 25] = item.layer1Scroll[1]; + array[vtxOffset + 26] = item.layer1Scroll[2]; + array[vtxOffset + 27] = item.layer1Scroll[3]; + + array[vtxOffset + 28] = item.layer2Scroll[0]; + array[vtxOffset + 29] = item.layer2Scroll[1]; + array[vtxOffset + 30] = item.layer2Scroll[2]; + array[vtxOffset + 31] = item.layer2Scroll[3]; + + array[vtxOffset + 33] = item.boneIndex; + array[vtxOffset + 34] = item.maskAtlasID; } } - if (this.display) { - this.highDetail.GetBatches(mode, accumulator); + this._vertexBuffer = _global.device.gl.createBuffer(); + _global.device.gl.bindBuffer(_global.device.gl.ARRAY_BUFFER, this._vertexBuffer); + _global.device.gl.bufferData(_global.device.gl.ARRAY_BUFFER, array, _global.device.gl.STATIC_DRAW); + _global.device.gl.bindBuffer(_global.device.gl.ARRAY_BUFFER, null); + + var indexes = new Uint16Array(itemCount * 6); + for (var _i = 0; _i < itemCount; ++_i) { + var _offset = _i * 6, + _vtxOffset = _i * 4; + + indexes[_offset] = _vtxOffset; + indexes[_offset + 1] = _vtxOffset + 2; + indexes[_offset + 2] = _vtxOffset + 1; + indexes[_offset + 3] = _vtxOffset; + indexes[_offset + 4] = _vtxOffset + 3; + indexes[_offset + 5] = _vtxOffset + 2; } + + this._indexBuffer = _global.device.gl.createBuffer(); + _global.device.gl.bindBuffer(_global.device.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + _global.device.gl.bufferData(_global.device.gl.ELEMENT_ARRAY_BUFFER, indexes, _global.device.gl.STATIC_DRAW); + _global.device.gl.bindBuffer(_global.device.gl.ELEMENT_ARRAY_BUFFER, null); + this._indexBuffer.count = itemCount * 6; } /** - * Gets z buffer only batches + * Gets the plane set's render batches * @param {number} mode * @param {Tw2BatchAccumulator} accumulator + * @param {Tw2PerObjectData} perObjectData */ }, { - key: 'GetZOnlyBatches', - value: function GetZOnlyBatches(mode, accumulator) { - if (this.display && this.zOnlyModel) { - this.zOnlyModel.GetBatches(mode, accumulator); + key: 'GetBatches', + value: function GetBatches(mode, accumulator, perObjectData) { + if (this.display && mode === _global.device.RM_ADDITIVE && this._indexBuffer && this._visibleItems.length) { + var batch = new EvePlaneSetBatch(); + batch.renderMode = _global.device.RM_ADDITIVE; + batch.planeSet = this; + batch.perObjectData = perObjectData; + accumulator.Commit(batch); } } /** - * Internal helper function that fires when a planet's mesh has loaded - * @property {EvePlanet} planet - * @property {*} obj + * Renders the plane set + * @param {string} technique - technique name */ - }], [{ - key: 'MeshLoaded', - value: function MeshLoaded(planet, obj) { - planet.highDetail.children.unshift(obj); - planet.lockedResources = []; - planet.GetPlanetResources(planet.highDetail, [], planet.lockedResources); - - var mainMesh = planet.highDetail.children[0].mesh, - originalEffect = null, - resPath = void 0; - - if (mainMesh.transparentAreas.length) { - originalEffect = mainMesh.transparentAreas[0].effect; - resPath = originalEffect.effectFilePath; - } else if (mainMesh.opaqueAreas.length) { - originalEffect = mainMesh.opaqueAreas[0].effect; - resPath = originalEffect.effectFilePath; - } else { - resPath = 'res:/Graphics/Effect/Managed/Space/Planet/EarthlikePlanet.fx'; - } - resPath = resPath.replace('.fx', 'BlitHeight.fx'); - - planet.watchedResources = []; - for (var param in originalEffect.parameters) { - if (originalEffect.parameters.hasOwnProperty(param)) { - planet.effectHeight.parameters[param] = originalEffect.parameters[param]; - if ('textureRes' in originalEffect.parameters[param]) { - planet.watchedResources.push(originalEffect.parameters[param].textureRes); - } - } - } - - for (var i = 0; i < planet.highDetail.children[0].children.length; ++i) { - mainMesh = planet.highDetail.children[0].children[i].mesh; - if (!mainMesh) continue; + }, { + key: 'Render', + value: function Render(technique) { + if (!this.effect || !this.effect.IsGood()) return false; - originalEffect = null; - if (mainMesh.transparentAreas.length) { - originalEffect = mainMesh.transparentAreas[0].effect; - } else if (mainMesh.opaqueAreas.length) { - originalEffect = mainMesh.opaqueAreas[0].effect; - } else { - continue; - } + _global.device.SetStandardStates(_global.device.RM_ADDITIVE); + _global.device.gl.bindBuffer(_global.device.gl.ARRAY_BUFFER, this._vertexBuffer); + _global.device.gl.bindBuffer(_global.device.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - for (var _param in originalEffect.parameters) { - if (originalEffect.parameters.hasOwnProperty(_param)) { - planet.effectHeight.parameters[_param] = originalEffect.parameters[_param]; - if ('textureRes' in originalEffect.parameters[_param]) { - planet.watchedResources.push(originalEffect.parameters[_param].textureRes); - } - } - } + for (var pass = 0; pass < this.effect.GetPassCount(technique); ++pass) { + this.effect.ApplyPass(technique, pass); + if (!this._decl.SetDeclaration(this.effect.GetPassInput(technique, pass), 140)) return false; + _global.device.ApplyShadowState(); + _global.device.gl.drawElements(_global.device.gl.TRIANGLES, this._indexBuffer.count, _global.device.gl.UNSIGNED_SHORT, 0); } + return true; + } + }, { + key: 'planes', + get: function get() { + return this.items; + } - var NormalHeight1 = new _core.Tw2TextureParameter('NormalHeight1', planet.heightMapResPath1); - NormalHeight1.Initialize(); - planet.watchedResources.push(NormalHeight1.textureRes); - planet.lockedResources.push(NormalHeight1.textureRes); - planet.effectHeight.parameters.NormalHeight1 = NormalHeight1; - - var NormalHeight2 = new _core.Tw2TextureParameter('NormalHeight2', planet.heightMapResPath2); - NormalHeight2.Initialize(); - planet.watchedResources.push(NormalHeight2.textureRes); - planet.lockedResources.push(NormalHeight2.textureRes); - planet.effectHeight.parameters.NormalHeight2 = NormalHeight2; + /** + * Alias for this.items + * @param {Array} arr + */ + , + set: function set(arr) { + this.items = arr; + } + }]); - planet.effectHeight.parameters.Random = new _core.Tw2FloatParameter('Random', planet.itemID % 100); - planet.effectHeight.parameters.TargetTextureHeight = new _core.Tw2FloatParameter('TargetTextureHeight', 1024); + return EvePlaneSet; +}(_EveObjectSet2.EveObjectSet); - planet.effectHeight.effectFilePath = resPath; - planet.effectHeight.Initialize(); - planet.heightDirty = true; - planet.heightMap.Create(2048, 1024, false); - planet.watchedResources.push(planet.effectHeight.effectRes); +/** + * The plane set's item constructor + * @type {EvePlaneSetItem} + */ - for (var _i2 = 0; _i2 < planet.lockedResources.length; ++_i2) { - planet.lockedResources[_i2].doNotPurge++; - if (planet.lockedResources[_i2].IsPurged()) { - planet.lockedResources[_i2].Reload(); - } - } - } - }]); - return EvePlanet; -}(_EveObject2.EveObject); +EvePlaneSet.Item = EvePlaneSetItem; /***/ }), -/* 186 */ +/* 179 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -36369,220 +36915,263 @@ var EvePlanet = exports.EvePlanet = function (_EveObject) { Object.defineProperty(exports, "__esModule", { value: true }); -exports.EveShip = undefined; +exports.EveSpaceObjectDecal = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; +var _global = __webpack_require__(0); -var _EveSpaceObject2 = __webpack_require__(62); +var _core = __webpack_require__(1); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - /** - * EveShip + * EveSpaceObjectDecal * - * @property {boolean} visible.turretSets - Enables/ disables turret set batch accumulation - * @property {boolean} visible.boosters - Enables/ disables booster batch accumulation - * @property {Array.} boosters - * @property {Array.} turretSets - * @property {number} boosterGain + * @property {String|number} _id + * @property {String} name + * @property {boolean} display + * @property {Tw2Effect} decalEffect + * @property {Tw2Effect} pickEffect + * @property {Tw2GeometryRes} parentGeometry + * @property {number} parentBoneIndex + * @property {number} groupIndex + * @property {boolean} pickable + * @property {vec3} position + * @property {quat} rotation + * @property {vec3} scaling + * @property {mat4} decalMatrix + * @property {mat4} invDecalMatrix + * @property {Array} indexBuffer + * @property {*} _indexBuffer + * @property {Tw2PerObjectData} _perObjectData * @class */ -var EveShip = exports.EveShip = function (_EveSpaceObject) { - _inherits(EveShip, _EveSpaceObject); +var EveSpaceObjectDecal = exports.EveSpaceObjectDecal = function () { + function EveSpaceObjectDecal() { + _classCallCheck(this, EveSpaceObjectDecal); - function EveShip() { - _classCallCheck(this, EveShip); + this._id = _global.util.generateID(); + this.name = ''; + this.display = true; + this.decalEffect = null; + this.pickEffect = null; + this.parentGeometry = null; + this.parentBoneIndex = -1; + this.groupIndex = -1; + this.pickable = true; + this.position = _global.vec3.create(); + this.rotation = _global.quat.create(); + this.scaling = _global.vec3.create(); + this.decalMatrix = _global.mat4.create(); + this.invDecalMatrix = _global.mat4.create(); + this.indexBuffer = []; + this._indexBuffer = null; - var _this = _possibleConstructorReturn(this, (EveShip.__proto__ || Object.getPrototypeOf(EveShip)).call(this)); + this._perObjectData = new _core.Tw2PerObjectData(); + this._perObjectData.perObjectVSData = new _core.Tw2RawData(); + this._perObjectData.perObjectVSData.Declare('worldMatrix', 16); + this._perObjectData.perObjectVSData.Declare('invWorldMatrix', 16); + this._perObjectData.perObjectVSData.Declare('decalMatrix', 16); + this._perObjectData.perObjectVSData.Declare('invDecalMatrix', 16); + this._perObjectData.perObjectVSData.Declare('parentBoneMatrix', 16); + this._perObjectData.perObjectVSData.Create(); - _this.visible.turretSets = true; - _this.visible.boosters = true; - _this.boosters = null; - _this.turretSets = []; - _this.boosterGain = 1; - return _this; + this._perObjectData.perObjectPSData = new _core.Tw2RawData(); + this._perObjectData.perObjectPSData.Declare('displayData', 4); + this._perObjectData.perObjectPSData.Declare('shipData', 4 * 3); + this._perObjectData.perObjectPSData.Create(); + + _global.mat4.identity(this._perObjectData.perObjectVSData.Get('parentBoneMatrix')); } /** - * Initializes the Eve Ship + * Initializes the decal */ - _createClass(EveShip, [{ + _createClass(EveSpaceObjectDecal, [{ key: 'Initialize', value: function Initialize() { - _get(EveShip.prototype.__proto__ || Object.getPrototypeOf(EveShip.prototype), 'Initialize', this).call(this); - if (this.boosters) { - this.RebuildBoosterSet(); - } + this.SetIndexBuffer(this.indexBuffer); } /** - * Rebuilds the ship's booster set + * Fire on value changes */ }, { - key: 'RebuildBoosterSet', - value: function RebuildBoosterSet() { - if (this.boosters) { - this.boosters.UpdateItemsFromLocators(this.FindLocatorsByPrefix('locator_booster')); + key: 'OnValueChanged', + value: function OnValueChanged() { + if (!this._indexBuffer && this.indexBuffer) { + var indexes = new Uint16Array(this.indexBuffer); + this._indexBuffer = _global.device.gl.createBuffer(); + _global.device.gl.bindBuffer(_global.device.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + _global.device.gl.bufferData(_global.device.gl.ELEMENT_ARRAY_BUFFER, indexes, _global.device.gl.STATIC_DRAW); } + + _global.mat4.fromRotationTranslationScale(this.decalMatrix, this.rotation, this.position, this.scaling); + _global.mat4.invert(this.invDecalMatrix, this.decalMatrix); } /** - * Rebuilds turret sets + * Sets the parent geometry + * @param {Tw2GeometryRes} geometryRes */ }, { - key: 'RebuildTurretPositions', - value: function RebuildTurretPositions() { - for (var i = 0; i < this.turretSets.length; i++) { - this.RebuildTurretSet(i); - } + key: 'SetParentGeometry', + value: function SetParentGeometry(geometryRes) { + this.parentGeometry = geometryRes; } /** - * Rebuilds a turret set - * @param {number} index + * Sets the decal's index buffer + * @param {number[]} indices */ }, { - key: 'RebuildTurretSet', - value: function RebuildTurretSet(index) { - if (this.turretSets[index] === undefined) return; - - var turretSet = this.turretSets[index], - prefix = turretSet.locatorName, - count = this.GetLocatorCount(prefix), - locators = []; - - for (var j = 0; j < count; ++j) { - var name = prefix + String.fromCharCode('a'.charCodeAt(0) + j), - locator = this.FindLocatorByName(name); - - if (locator) { - locator.FindBone(this.animation); - locators.push(locator); - } - } - - turretSet.UpdateItemsFromLocators(locators); + key: 'SetIndexBuffer', + value: function SetIndexBuffer(indices) { + this.indexBuffer = indices; + this.Unload(); + this.OnValueChanged(); } /** - * Gets ship's res objects + * Gets decal resources * @param {Array} [out=[]] - Optional receiving array - * @param {Boolean} excludeChildren - True to exclude children's res objects - * @returns {Array.} [out] + * @returns {Array.} [out] */ }, { key: 'GetResources', value: function GetResources() { var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - var excludeChildren = arguments[1]; - - _get(EveShip.prototype.__proto__ || Object.getPrototypeOf(EveShip.prototype), 'GetResources', this).call(this, out, excludeChildren); - - for (var i = 0; i < this.turretSets.length; i++) { - this.turretSets[i].GetResources(out); - } - if (this.boosters) { - this.boosters.GetResources(out); + if (this.parentGeometry && !out.includes(this.parentGeometry)) { + out.push(this.parentGeometry); } + if (this.decalEffect) this.decalEffect.GetResources(out); + if (this.pickEffect) this.pickEffect.GetResources(out); return out; } /** - * Updates view dependant data + * Unloads the decal's buffers */ }, { - key: 'UpdateViewDependentData', - value: function UpdateViewDependentData() { - _get(EveShip.prototype.__proto__ || Object.getPrototypeOf(EveShip.prototype), 'UpdateViewDependentData', this).call(this); - - for (var i = 0; i < this.turretSets.length; ++i) { - this.turretSets[i].UpdateViewDependentData(); + key: 'Unload', + value: function Unload() { + if (this._indexBuffer) { + _global.device.gl.deleteBuffer(this._indexBuffer); + this._indexBuffer = null; } } /** - * Per frame update - * @param {number} dt - deltaTime + * Gets batches for rendering + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator + * @param {Tw2PerObjectData} perObjectData + * @param {number} [counter=0] */ }, { - key: 'Update', - value: function Update(dt) { - _get(EveShip.prototype.__proto__ || Object.getPrototypeOf(EveShip.prototype), 'Update', this).call(this, dt); - - if (this.boosters) { - if (this.boosters._locatorRebuildPending) { - this.RebuildBoosterSet(); - } + key: 'GetBatches', + value: function GetBatches(mode, accumulator, perObjectData, counter) { + var effect = void 0; + switch (mode) { + case _global.device.RM_DECAL: + effect = this.decalEffect; + break; - this.boosters.Update(dt, this.transform); + case _global.device.RM_PICKABLE: + effect = this.pickable ? this.pickEffect : null; + break; } - for (var i = 0; i < this.turretSets.length; ++i) { - if (this.turretSets[i]._locatorRebuildPending) { - this.RebuildTurretSet(i); + if (this.display && effect && effect.IsGood() && this.indexBuffer.length && this.parentGeometry && this.parentGeometry.IsGood()) { + var batch = new _core.Tw2ForwardingRenderBatch(); + this._perObjectData.perObjectVSData.Set('worldMatrix', perObjectData.perObjectVSData.Get('WorldMat')); + if (this.parentBoneIndex >= 0) { + var bones = perObjectData.perObjectVSData.Get('JointMat'), + offset = this.parentBoneIndex * 12; + + if (bones[offset] || bones[offset + 4] || bones[offset + 8]) { + var bone = this._perObjectData.perObjectVSData.Get('parentBoneMatrix'); + bone[0] = bones[offset]; + bone[1] = bones[offset + 4]; + bone[2] = bones[offset + 8]; + bone[3] = 0; + bone[4] = bones[offset + 1]; + bone[5] = bones[offset + 5]; + bone[6] = bones[offset + 9]; + bone[7] = 0; + bone[8] = bones[offset + 2]; + bone[9] = bones[offset + 6]; + bone[10] = bones[offset + 10]; + bone[11] = 0; + bone[12] = bones[offset + 3]; + bone[13] = bones[offset + 7]; + bone[14] = bones[offset + 11]; + bone[15] = 1; + _global.mat4.transpose(bone, bone); + } } - this.turretSets[i].Update(dt, this.transform); + _global.mat4.invert(this._perObjectData.perObjectVSData.Get('invWorldMatrix'), this._perObjectData.perObjectVSData.Get('worldMatrix')); + _global.mat4.transpose(this._perObjectData.perObjectVSData.Get('decalMatrix'), this.decalMatrix); + _global.mat4.transpose(this._perObjectData.perObjectVSData.Get('invDecalMatrix'), this.invDecalMatrix); + + this._perObjectData.perObjectPSData.Get('displayData')[0] = counter || 0; + this._perObjectData.perObjectPSData.Set('shipData', perObjectData.perObjectPSData.data); + + batch.perObjectData = this._perObjectData; + batch.geometryProvider = this; + batch.renderMode = mode; + batch.effect = effect; + accumulator.Commit(batch); } } /** - * Gets render batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator + * Renders the decal + * @param {Tw2ForwardingRenderBatch} batch + * @param {string} technique - technique name */ }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator) { - if (this.display) { - _get(EveShip.prototype.__proto__ || Object.getPrototypeOf(EveShip.prototype), 'GetBatches', this).call(this, mode, accumulator); + key: 'Render', + value: function Render(batch, technique) { + var bkIB = this.parentGeometry.meshes[0].indexes, + bkStart = this.parentGeometry.meshes[0].areas[0].start, + bkCount = this.parentGeometry.meshes[0].areas[0].count, + bkIndexType = this.parentGeometry.meshes[0].indexType; - this._perObjectData.perObjectVSData.Get('Shipdata')[0] = this.boosterGain; - this._perObjectData.perObjectPSData.Get('Shipdata')[0] = this.boosterGain; + _global.store.SetVariableValue('u_DecalMatrix', this.decalMatrix); + _global.store.SetVariableValue('u_InvDecalMatrix', this.invDecalMatrix); - if (this.boosters && this.visible.boosters) { - this.boosters.GetBatches(mode, accumulator, this._perObjectData); - } + this.parentGeometry.meshes[0].indexes = this._indexBuffer; + this.parentGeometry.meshes[0].areas[0].start = 0; + this.parentGeometry.meshes[0].areas[0].count = this.indexBuffer.length; + this.parentGeometry.meshes[0].indexType = _global.device.gl.UNSIGNED_SHORT; - if (this.visible.turretSets) { - if (this.lod > 1) { - for (var i = 0; i < this.turretSets.length; ++i) { - this.turretSets[i].GetBatches(mode, accumulator, this._perObjectData, this.visible.firingEffects); - } - } else if (this.visible.firingEffects) { - for (var _i = 0; _i < this.turretSets.length; ++_i) { - if (this.turretSets[_i].firingEffect) { - this.turretSets[_i].firingEffect.GetBatches(mode, accumulator, this._perObjectData); - } - } - } - } - } + this.parentGeometry.RenderAreas(0, 0, 1, batch.effect, technique); + this.parentGeometry.meshes[0].indexes = bkIB; + this.parentGeometry.meshes[0].areas[0].start = bkStart; + this.parentGeometry.meshes[0].areas[0].count = bkCount; + this.parentGeometry.meshes[0].indexType = bkIndexType; } }]); - return EveShip; -}(_EveSpaceObject2.EveSpaceObject); + return EveSpaceObjectDecal; +}(); /***/ }), -/* 187 */ +/* 180 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -36591,15 +37180,15 @@ var EveShip = exports.EveShip = function (_EveSpaceObject) { Object.defineProperty(exports, "__esModule", { value: true }); -exports.EveBoosterSet = exports.EveBoosterSetItem = exports.EveBoosterBatch = undefined; +exports.EveSpotlightSet = exports.EveSpotlightSetItem = exports.EveSpotlightSetBatch = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); var _core = __webpack_require__(1); -var _EveObjectSet2 = __webpack_require__(10); +var _EveObjectSet2 = __webpack_require__(6); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -36608,422 +37197,336 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Booster render batch + * EveSpotlightSetBatch * - * @property {EveBoosterSet} boosters + * @property {EveSpotlightSet} spotlightSet * @class */ -var EveBoosterBatch = exports.EveBoosterBatch = function (_Tw2RenderBatch) { - _inherits(EveBoosterBatch, _Tw2RenderBatch); +var EveSpotlightSetBatch = exports.EveSpotlightSetBatch = function (_Tw2RenderBatch) { + _inherits(EveSpotlightSetBatch, _Tw2RenderBatch); - function EveBoosterBatch() { - _classCallCheck(this, EveBoosterBatch); + function EveSpotlightSetBatch() { + _classCallCheck(this, EveSpotlightSetBatch); - var _this = _possibleConstructorReturn(this, (EveBoosterBatch.__proto__ || Object.getPrototypeOf(EveBoosterBatch)).call(this)); + var _this = _possibleConstructorReturn(this, (EveSpotlightSetBatch.__proto__ || Object.getPrototypeOf(EveSpotlightSetBatch)).call(this)); - _this.boosters = null; + _this.spotlightSet = null; return _this; } /** - * Commits the batch + * Commits the spotlight set for rendering * @param {string} technique - technique name */ - _createClass(EveBoosterBatch, [{ + _createClass(EveSpotlightSetBatch, [{ key: 'Commit', value: function Commit(technique) { - this.boosters.Render(technique); + this.spotlightSet.RenderCones(technique); + this.spotlightSet.RenderGlow(technique); } }]); - return EveBoosterBatch; + return EveSpotlightSetBatch; }(_core.Tw2RenderBatch); /** - * EveBoosterSetItem + * Spotlight Item * - * @param {boolean} enableCustomValues - Enables custom values - * @property {{}} visible - Visibility options - * @property {boolean} visible.halo - Toggles halo visibility - * @property {boolean} visible.symHalo - Toggles symmetrical halo visibility - * @property {boolean} visible.glow - Toggles glow visibility - * @property {boolean} visible.trail - Toggles trail visibility (not implemented) - * @property {?string} locatorName - The item's locator name, if it was built from one - * @property {boolean} updateFromLocator - Sets whether the item should be updated when it's locator is - * @property {mat4} transform - The item's local transform - * @property {number} atlas0 - The item's atlas index 0 - * @property {number} atlas1 - The item's atlas index 1 - * @property {number} seed - A random seed which affects any glows built from this item - * @property {number} wavePhase - A random seed which affects the booster wave pattern - * @property {*} customValues - An optional object containing custom values + * @property {mat4} transform - The spotlight's transform + * @property {vec4} coneColor - Colour of the spotlight's cone + * @property {vec4} spriteColor - Colour of the spotlight's sprite texture + * @property {vec4} flareColor - Colour of the spotlight's flare + * @property {vec4} spriteScale - The size of the spotlight + * @property {number} boosterGainInfluence - If true, the spotlight can change size on booster gain + * @property {number} boneIndex - The spotlight's bone index + * @property {number} groupIndex - The sof faction group that the spotlight belongs to + * @property {number} coneIntensity - Scales the spotlight's cone colour, set by an object's sof Faction + * @property {number} spriteIntensity - Scales the spotlight's sprite colour, set by an object's sof Faction + * @property {number} flareIntensity - Scales the spotlight's flare colour, set by an object's sof Faction * @class */ -var EveBoosterSetItem = exports.EveBoosterSetItem = function (_EveObjectSetItem) { - _inherits(EveBoosterSetItem, _EveObjectSetItem); +var EveSpotlightSetItem = exports.EveSpotlightSetItem = function (_EveObjectSetItem) { + _inherits(EveSpotlightSetItem, _EveObjectSetItem); - function EveBoosterSetItem() { - _classCallCheck(this, EveBoosterSetItem); + function EveSpotlightSetItem() { + _classCallCheck(this, EveSpotlightSetItem); - var _this2 = _possibleConstructorReturn(this, (EveBoosterSetItem.__proto__ || Object.getPrototypeOf(EveBoosterSetItem)).call(this)); + var _this2 = _possibleConstructorReturn(this, (EveSpotlightSetItem.__proto__ || Object.getPrototypeOf(EveSpotlightSetItem)).call(this)); - _this2.visible = {}; - _this2.visible.glow = true; - _this2.visible.symHalo = true; - _this2.visible.halo = true; - _this2.visible.trail = true; - _this2.visible.customValues = false; - _this2.locatorName = null; - _this2.updateFromLocator = false; - _this2.seed = Math.random() * 7; - _this2.wavePhase = Math.random(); - _this2.atlas0 = 0; - _this2.atlas1 = 0; - _this2.transform = _math.mat4.create(); - _this2.customValues = null; + _this2.transform = _global.mat4.create(); + _this2.coneColor = _global.vec4.create(); + _this2.spriteColor = _global.vec4.create(); + _this2.flareColor = _global.vec4.create(); + _this2.spriteScale = _global.vec3.fromValues(1, 1, 1); + _this2.boosterGainInfluence = 0; + _this2.boneIndex = 0; + _this2.groupIndex = -1; + _this2.coneIntensity = 0; + _this2.spriteIntensity = 0; + _this2.flareIntensity = 0; return _this2; } /** - * Gets the item's position - * @param {vec3} out - * @returns {vec3} out + * Creates a spotlight set item from an object + * @param {*} [opt={} + * @returns {EveSpotlightSetItem} */ - _createClass(EveBoosterSetItem, [{ - key: 'GetPosition', - value: function GetPosition(out) { - return _math.mat4.getTranslation(out, this.transform); - } - - /** - * Gets the item's direction - * @param {vec3} out - * @returns {vec3} out - */ - - }, { - key: 'GetDirection', - value: function GetDirection(out) { - _math.vec3.set(out, this.transform[8], this.transform[9], this.transform[10]); - _math.vec3.normalize(out, out); - var scale = this.GetScale(); - if (scale < 3) _math.vec3.scale(out, out, scale / 3); - return out; - } - - /** - * Gets the item's scale - * @returns {number} - */ - - }, { - key: 'GetScale', - value: function GetScale() { - var tr = this.transform; - return Math.max(_math.vec3.length([tr[0], tr[1], tr[2]]), _math.vec3.length([tr[4], tr[5], tr[6]])); - } - - /** - * Creates an item from an object - * @param {*} [opt={}] - * @returns {EveBoosterSetItem} - */ - - }], [{ + _createClass(EveSpotlightSetItem, null, [{ key: 'create', value: function create() { var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var item = new this(); - _math.util.assignIfExists(item.visible, opt.visible, ['glow', 'symHalo', 'halo', 'trail']); - _math.util.assignIfExists(item, opt, ['name', 'display', 'seed', 'wavePhase', 'transform', 'locatorName', 'updateFromLocator', 'atlas0', 'atlas1']); + _global.util.assignIfExists(item, opt, ['name', 'display', 'boosterGainInfluence', 'boneIndex', 'groupIndex', 'coneIntensity', 'spriteIntensity', 'flareIntensity', 'transform', 'coneColor', 'spriteColor', 'flareColor', 'spriteScale']); return item; } }]); - return EveBoosterSetItem; + return EveSpotlightSetItem; }(_EveObjectSet2.EveObjectSetItem); /** - * EveBoosterSet + * EveSpotlightSet * - * @property {{}} visible - Visibility controls - * @property {boolean} visible.glows - Toggles glow visibility - * @property {boolean} visible.symHalos - Toggles symmetrical halo visibility - * @property {boolean} visible.halos - Toggles halo visibility - * @property {boolean} visible.trails - Toggles trails visibility (Not implemented) - * @property {Tw2Effect} effect - The booster's booster effect - * @property {?Tw2Effect} glows - The booster's glows (sprites) - * @property {number} maxVel - (Not implemented) - * @property {boolean} alwaysOn - (Not implemented) - * @property {number} glowDistance - The distance between the booster's locators and glow sprites - * @property {number} glowScale - The base scale of the booster's glow sprites - * @property {vec4} glowColor - The color of the booster set's glow sprites - * @property {vec4} warpGlowColor - The color of the booster set's glow sprites when warping (Not implemented) - * @property {number} haloDistance - The distance between the booster set's locators and halo sprites - * @property {number} haloScaleX - The base vertical scale of the booster set's halos - * @property {number} haloScaleY - The base horizontal scale of the booster set's halos - * @property {vec4} haloColor - The color of the booster set's halo sprites - * @property {vec4} warpHaloColor - The color of the booster set's halo sprites when warping (Not implemented) - * @property {vec4} trailSize - The booster set's trail size (Not implemented) - * @property {vec4} trailColor - The booster set's trail color (Not implemented) - * @property {number} symHaloDistance - The distance between the booster set's locators and symmetrical halo sprites - * @property {number} symHaloScale - The base scale of the booster set's symmetrical halos - * @property {mat4} _parentTransform - The booster set's parent's transform - * @property {WebGLBuffer} _positions - The booster set's webgl buffer - * @property {Tw2VertexDeclaration} _decl - The booster set's vertex declarations - * @property {Tw2PerObjectData} _perObjectData - The booster set's shader data - * @property {boolean} _locatorRebuildPending - Identifies that the booster set needs to be rebuilt from locators + * @property {string} name - The spotlight set's name + * @property {boolean} display - controls the visibility of the spotlight set, and all it's children + * @property {Tw2Effect} coneEffect - The spotlight set's cone effect + * @property {Tw2Effect} glowEffect - The spotlight set's glow effect + * @property {Array.} locators - */ - - }, { - key: 'UpdateItemsFromLocators', - value: function UpdateItemsFromLocators(locators) { - var items = Array.from(this.items); - - for (var i = 0; i < locators.length; i++) { - var _locators$i = locators[i], - name = _locators$i.name, - transform = _locators$i.transform, - atlasIndex0 = _locators$i.atlasIndex0, - atlasIndex1 = _locators$i.atlasIndex1; - - - var item = this.FindItemByLocatorName(name); - if (!item) { - this.CreateItem({ - name: name, - locatorName: name, - updateFromLocator: true, - atlas0: atlasIndex0, - atlas1: atlasIndex1, - transform: transform - }); - } else { - items.splice(items.indexOf(item), 1); - - if (item.updateFromLocator) { - _math.mat4.copy(item.transform, transform); - item.atlas0 = atlasIndex0; - item.atlas1 = atlasIndex1; - item.OnValueChanged(); - } - } - } - - for (var _i = 0; _i < items.length; _i++) { - if (items[_i].locatorName !== null) { - this.RemoveItem(items[_i]); - _i--; - } - } - - this._locatorRebuildPending = false; - - if (this._rebuildPending) { - this.Rebuild(); - } - } - - /** - * Rebuilds the booster set from it's parent's locators - */ + _createClass(EveSpotlightSet, [{ + key: 'GetResources', - }, { - key: 'RebuildItemsFromLocators', - value: function RebuildItemsFromLocators() { - this._locatorRebuildPending = true; - } /** - * Gets booster set resources + * Gets the spotlight set's resources * @param {Array} [out=[]] - Optional receiving array * @returns {Array.} [out] */ - - }, { - key: 'GetResources', value: function GetResources() { var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - if (this.effect) { - this.effect.GetResources(out); + if (this.coneEffect) { + this.coneEffect.GetResources(out); } - if (this.glows) { - this.glows.effect.GetResources(out); + if (this.glowEffect) { + this.glowEffect.GetResources(out); } return out; } /** - * Per frame update - * @param {number} dt - DeltaTime - * @param {mat4} parentMatrix - */ - - }, { - key: 'Update', - value: function Update(dt, parentMatrix) { - _math.mat4.copy(this._parentTransform, parentMatrix); - if (this._rebuildPending) this.Rebuild(); - if (this.glows) this.glows.Update(dt); - } - - /** - * Unloads the booster's buffers + * Unloads the spotlight set's buffers */ }, { key: 'Unload', value: function Unload() { - if (this._positions) { - _core.device.gl.deleteBuffer(this._positions); - this._positions = null; + if (this._coneVertexBuffer) { + _global.device.gl.deleteBuffer(this._coneVertexBuffer); + this._coneVertexBuffer = null; } - if (this.glows) { - this.glows.Unload(); + if (this._spriteVertexBuffer) { + _global.device.gl.deleteBuffer(this._spriteVertexBuffer); + this._spriteVertexBuffer = null; + } + + if (this._indexBuffer) { + _global.device.gl.deleteBuffer(this._indexBuffer); + this._indexBuffer = null; } } /** - * Rebuilds the boosters + * Rebuilds the spotlight set's buffers */ }, { key: 'Rebuild', value: function Rebuild() { - this.constructor.RebuildItems(this); - var itemCount = this._visibleItems.length; + this.Unload(); + EveSpotlightSet.RebuildItems(this); this._rebuildPending = false; + var itemCount = this._visibleItems.length; if (!itemCount) return; - var d = _core.device, - box = EveBoosterSet._box, - data = new Float32Array(itemCount * box.length * 6 * 28), - order = [0, 3, 1, 3, 2, 1]; + var d = _global.device, + vertCount = 4, + coneQuadCount = 4, + coneVertexCount = itemCount * coneQuadCount * vertCount, + vertexSize = 22, + coneIndices = [1, 0, 2, 3], + coneArray = new Float32Array(coneVertexCount * vertexSize); - var index = 0; for (var i = 0; i < itemCount; ++i) { var item = this._visibleItems[i]; - for (var b = 0; b < box.length; ++b) { - for (var j = 0; j < order.length; ++j) { - data[index++] = box[b][order[j]][0]; - data[index++] = box[b][order[j]][1]; - data[index++] = box[b][order[j]][2]; - data[index++] = 0; - data[index++] = 0; - data.set(item.transform, index); - index += 16; - data[index++] = 0; - data[index++] = 1; - data[index++] = 1; - data[index++] = 1; - data[index++] = item.wavePhase; - data[index++] = item.atlas0; - data[index++] = item.atlas1; + for (var q = 0; q < coneQuadCount; ++q) { + for (var v = 0; v < vertCount; ++v) { + var offset = (i * coneQuadCount * vertCount + vertCount * q + v) * vertexSize; + coneArray[offset] = item.coneColor[0] * item.coneIntensity; + coneArray[offset + 1] = item.coneColor[1] * item.coneIntensity; + coneArray[offset + 2] = item.coneColor[2] * item.coneIntensity; + coneArray[offset + 3] = item.coneColor[3]; + + coneArray[offset + 4] = item.transform[0]; + coneArray[offset + 5] = item.transform[4]; + coneArray[offset + 6] = item.transform[8]; + coneArray[offset + 7] = item.transform[12]; + + coneArray[offset + 8] = item.transform[1]; + coneArray[offset + 9] = item.transform[5]; + coneArray[offset + 10] = item.transform[9]; + coneArray[offset + 11] = item.transform[13]; + + coneArray[offset + 12] = item.transform[2]; + coneArray[offset + 13] = item.transform[6]; + coneArray[offset + 14] = item.transform[10]; + coneArray[offset + 15] = item.transform[14]; + + coneArray[offset + 16] = 1; + coneArray[offset + 17] = 1; + coneArray[offset + 18] = 1; + + coneArray[offset + 19] = q * vertCount + coneIndices[v]; + coneArray[offset + 20] = item.boneIndex; + coneArray[offset + 21] = item.boosterGainInfluence ? 255 : 0; } } } - this._positions = d.gl.createBuffer(); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._positions); - d.gl.bufferData(d.gl.ARRAY_BUFFER, data, d.gl.STATIC_DRAW); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, null); - this._positions.count = itemCount * 12 * 3; + this._coneVertexBuffer = d.gl.createBuffer(); + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._coneVertexBuffer); + d.gl.bufferData(d.gl.ARRAY_BUFFER, coneArray, d.gl.STATIC_DRAW); + this._coneVertexBuffer.count = itemCount * coneQuadCount * 6; - if (this.glows) this.glows.Rebuild(); + var spriteQuadCount = 2, + spriteVertexCount = itemCount * spriteQuadCount * vertCount, + spriteArray = new Float32Array(spriteVertexCount * vertexSize), + spriteIndexes = [1, 0, 2, 3]; + + for (var _i = 0; _i < itemCount; ++_i) { + var _item = this._visibleItems[_i]; + for (var _q = 0; _q < spriteQuadCount; ++_q) { + for (var _v = 0; _v < vertCount; ++_v) { + var _offset = (_i * spriteQuadCount * vertCount + vertCount * _q + _v) * vertexSize; + if (_q % 2 === 0) { + spriteArray[_offset] = _item.spriteColor[0] * _item.spriteIntensity; + spriteArray[_offset + 1] = _item.spriteColor[1] * _item.spriteIntensity; + spriteArray[_offset + 2] = _item.spriteColor[2] * _item.spriteIntensity; + spriteArray[_offset + 3] = _item.spriteColor[3]; + + spriteArray[_offset + 16] = _item.spriteScale[0]; + spriteArray[_offset + 17] = 1; + spriteArray[_offset + 18] = 1; + } else { + spriteArray[_offset] = _item.flareColor[0] * _item.flareIntensity; + spriteArray[_offset + 1] = _item.flareColor[1] * _item.flareIntensity; + spriteArray[_offset + 2] = _item.flareColor[2] * _item.flareIntensity; + spriteArray[_offset + 3] = _item.flareColor[3]; + + spriteArray[_offset + 16] = 1; + spriteArray[_offset + 17] = _item.spriteScale[1]; + spriteArray[_offset + 18] = _item.spriteScale[2]; + } + + spriteArray[_offset + 4] = _item.transform[0]; + spriteArray[_offset + 5] = _item.transform[4]; + spriteArray[_offset + 6] = _item.transform[8]; + spriteArray[_offset + 7] = _item.transform[12]; + + spriteArray[_offset + 8] = _item.transform[1]; + spriteArray[_offset + 9] = _item.transform[5]; + spriteArray[_offset + 10] = _item.transform[9]; + spriteArray[_offset + 11] = _item.transform[13]; + + spriteArray[_offset + 12] = _item.transform[2]; + spriteArray[_offset + 13] = _item.transform[6]; + spriteArray[_offset + 14] = _item.transform[10]; + spriteArray[_offset + 15] = _item.transform[14]; + + spriteArray[_offset + 19] = _q * vertCount + spriteIndexes[_v]; + spriteArray[_offset + 20] = _item.boneIndex; + spriteArray[_offset + 21] = _item.boosterGainInfluence ? 255 : 0; + } + } + } + + this._spriteVertexBuffer = d.gl.createBuffer(); + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._spriteVertexBuffer); + d.gl.bufferData(d.gl.ARRAY_BUFFER, spriteArray, d.gl.STATIC_DRAW); + this._spriteVertexBuffer.count = itemCount * spriteQuadCount * 6; + + var indexes = new Uint16Array(itemCount * coneQuadCount * 6); + for (var _i2 = 0; _i2 < itemCount * coneQuadCount; ++_i2) { + var _offset2 = _i2 * 6, + vtxOffset = _i2 * 4; + + indexes[_offset2] = vtxOffset; + indexes[_offset2 + 1] = vtxOffset + 1; + indexes[_offset2 + 2] = vtxOffset + 2; + indexes[_offset2 + 3] = vtxOffset + 2; + indexes[_offset2 + 4] = vtxOffset + 3; + indexes[_offset2 + 5] = vtxOffset; + } + + this._indexBuffer = d.gl.createBuffer(); + d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + d.gl.bufferData(d.gl.ELEMENT_ARRAY_BUFFER, indexes, d.gl.STATIC_DRAW); + d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, null); + this._indexBuffer.count = itemCount; } /** - * Gets render batches + * Gets the spotlight set's render batches * @param {number} mode * @param {Tw2BatchAccumulator} accumulator * @param {Tw2PerObjectData} perObjectData @@ -37032,138 +37535,96 @@ var EveBoosterSet = exports.EveBoosterSet = function (_EveObjectSet) { }, { key: 'GetBatches', value: function GetBatches(mode, accumulator, perObjectData) { - if (!this.display || mode !== _core.device.RM_ADDITIVE || !this._positions || !this._visibleItems.length) return; - - if (this.effect) { - var batch = new EveBoosterBatch(); - _math.mat4.transpose(this._perObjectData.perObjectVSData.Get('WorldMat'), this._parentTransform); - this._perObjectData.perObjectVSData.Set('Shipdata', perObjectData.perObjectVSData.Get('Shipdata')); - this._perObjectData.perObjectPSData = perObjectData.perObjectPSData; - batch.perObjectData = this._perObjectData; - batch.boosters = this; - batch.renderMode = _core.device.RM_ADDITIVE; + if (this.display && mode === _global.device.RM_ADDITIVE && this._indexBuffer && this._indexBuffer.count) { + var batch = new EveSpotlightSetBatch(); + batch.renderMode = _global.device.RM_ADDITIVE; + batch.spotlightSet = this; + batch.perObjectData = perObjectData; accumulator.Commit(batch); } - - if (this.glows) { - this.glows.GetBoosterGlowBatches(mode, accumulator, perObjectData, this._parentTransform, perObjectData.perObjectVSData.Get('Shipdata')[0], 0); - } } /** - * Renders the accumulated batches + * Renders the spotlight set's cone effect * @param {string} technique - technique name * @returns {boolean} */ }, { - key: 'Render', - value: function Render(technique) { - if (!this.effect || !this.effect.IsGood()) return false; - - _core.device.gl.bindBuffer(_core.device.gl.ARRAY_BUFFER, this._positions); - for (var pass = 0; pass < this.effect.GetPassCount(technique); ++pass) { - this.effect.ApplyPass(technique, pass); - if (!this._decl.SetDeclaration(this.effect.GetPassInput(technique, pass), 112)) return false; - _core.device.ApplyShadowState(); - _core.device.gl.drawArrays(_core.device.gl.TRIANGLES, 0, this._positions.count); - } - return true; + key: 'RenderCones', + value: function RenderCones(technique) { + return EveSpotlightSet.Render(this, this.coneEffect, technique, this._coneVertexBuffer); } /** - * Rebuilds a booster set's items - * @param {EveBoosterSet} boosters + * Renders the spotlight set's glow effect + * @param {string} technique - technique name + * @returns {boolean} */ - }], [{ - key: 'RebuildItems', - value: function RebuildItems(boosters) { - var glows = boosters.glows, - g = EveBoosterSet.global, - spritePos = g.vec3_0; - - if (glows) glows.ClearItems(); - boosters._visibleItems = []; - - for (var i = 0; i < boosters.items.length; i++) { - var item = boosters.items[i]; - item._onModified = boosters._onChildModified; - - if (item.display) { - boosters._visibleItems.push(item); + }, { + key: 'RenderGlow', + value: function RenderGlow(technique) { + return EveSpotlightSet.Render(this, this.glowEffect, technique, this._spriteVertexBuffer); + } - if (glows) { - var src = item.customValues && item.customValues.display ? item.customValues : boosters, - pos = item.GetPosition(g.vec3_1), - dir = item.GetDirection(g.vec3_2), - scale = item.GetScale(); + /** + * Internal render function + * @param {EveSpotlightSet} spotlightSet + * @param {Tw2Effect} effect - The Tw2Effect to render + * @param {string} technique - technique name + * @param {WebGLBuffer} buffer - A webgl buffer (ie. cone or glow buffer) + * @returns {boolean} + * @private + */ - if (boosters.visible.glows && item.visible.glow) { - glows.CreateItem({ - name: item.name + '_glow', - position: _math.vec3.subtract(spritePos, pos, _math.vec3.scale(spritePos, dir, src.glowDistance)), - blinkRate: item.seed, - blinkPhase: item.seed, - minScale: src.glowScale * scale, - maxScale: src.glowScale * scale, - color: src.glowColor, - warpColor: src.warpGlowColor - }); - } + }, { + key: 'spotlightItems', + get: function get() { + return this.items; + } - if (boosters.visible.symHalos && item.visible.symHalo) { - glows.CreateItem({ - name: item.name + '_symHalo', - position: _math.vec3.subtract(spritePos, pos, _math.vec3.scale(spritePos, dir, src.symHaloDistance)), - blinkRate: item.seed, - blinkPhase: item.seed + 1, - minScale: src.symHaloScale * scale, - maxScale: src.symHaloScale * scale, - color: src.haloColor, - warpColor: src.warpHaloColor - }); - } + /** + * Alias for this.items + * @param {Array} arr + */ + , + set: function set(arr) { + this.items = arr; + } + }], [{ + key: 'Render', + value: function Render(spotlightSet, effect, technique, buffer) { + if (!effect || !effect.IsGood() || !buffer) return false; - if (boosters.visible.halos && item.visible.halo) { - glows.CreateItem({ - name: item.name + '_halo', - position: _math.vec3.subtract(spritePos, pos, _math.vec3.scale(spritePos, dir, src.haloDistance)), - blinkRate: item.seed, - blinkPhase: item.seed + 1, - minScale: src.haloScaleX * scale, - maxScale: src.haloScaleY * scale, - color: src.haloColor, - warpColor: src.warpHaloColor - }); - } - } + var stride = 22 * 4; + _global.device.SetStandardStates(_global.device.RM_ADDITIVE); + _global.device.gl.bindBuffer(_global.device.gl.ARRAY_BUFFER, buffer); + _global.device.gl.bindBuffer(_global.device.gl.ELEMENT_ARRAY_BUFFER, spotlightSet._indexBuffer); - item._rebuildPending = false; - } + for (var pass = 0; pass < effect.GetPassCount(technique); ++pass) { + effect.ApplyPass(technique, pass); + if (!spotlightSet._decl.SetDeclaration(effect.GetPassInput(technique, pass), stride)) return false; + _global.device.ApplyShadowState(); + _global.device.gl.drawElements(_global.device.gl.TRIANGLES, buffer['count'], _global.device.gl.UNSIGNED_SHORT, 0); } + return true; } }]); - return EveBoosterSet; + return EveSpotlightSet; }(_EveObjectSet2.EveObjectSet); /** - * The booster set's item constructor - * @type {EveBoosterSetItem} + * Spotlight set item constructor + * @type {EveSpotlightSetItem} */ -EveBoosterSet.Item = EveBoosterSetItem; - -/** - * Internal helper - * @type {Array} - */ -EveBoosterSet._box = [[[-1.0, -1.0, 0.0], [1.0, -1.0, 0.0], [1.0, 1.0, 0.0], [-1.0, 1.0, 0.0]], [[-1.0, -1.0, -1.0], [-1.0, 1.0, -1.0], [1.0, 1.0, -1.0], [1.0, -1.0, -1.0]], [[-1.0, -1.0, 0.0], [-1.0, 1.0, 0.0], [-1.0, 1.0, -1.0], [-1.0, -1.0, -1.0]], [[1.0, -1.0, 0.0], [1.0, -1.0, -1.0], [1.0, 1.0, -1.0], [1.0, 1.0, 0.0]], [[-1.0, -1.0, 0.0], [-1.0, -1.0, -1.0], [1.0, -1.0, -1.0], [1.0, -1.0, 0.0]], [[-1.0, 1.0, 0.0], [1.0, 1.0, 0.0], [1.0, 1.0, -1.0], [-1.0, 1.0, -1.0]]]; +EveSpotlightSet.Item = EveSpotlightSetItem; /***/ }), -/* 188 */ +/* 181 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -37172,15 +37633,15 @@ EveBoosterSet._box = [[[-1.0, -1.0, 0.0], [1.0, -1.0, 0.0], [1.0, 1.0, 0.0], [-1 Object.defineProperty(exports, "__esModule", { value: true }); -exports.EveCurveLineSet = exports.EveCurveLineSetItem = undefined; +exports.EveSpriteSet = exports.EveSpriteSetItem = exports.EveSpriteSetBatch = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); var _core = __webpack_require__(1); -var _EveObjectSet2 = __webpack_require__(10); +var _EveObjectSet2 = __webpack_require__(6); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -37189,322 +37650,150 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * EveCurveLineSetItem + * Sprite set render batch * - * @property {number} type - * @property {vec3} position1 - * @property {vec4} color1 - * @property {vec3} position2 - * @property {vec4} color2 - * @property {vec3} intermediatePosition - * @property {number} width - * @property {vec4} multiColor - * @property {number} multiColorBorder - * @property {vec4} overlayColor - * @property {number} animationSpeed - * @property {number} animationScale - * @property {number} numOfSegments + * @property {boolean} boosterGlow + * @property {EveSpriteSet} spriteSet + * @property {mat4} world + * @property {number} + * @property {number} * @class */ -var EveCurveLineSetItem = exports.EveCurveLineSetItem = function (_EveObjectSetItem) { - _inherits(EveCurveLineSetItem, _EveObjectSetItem); +var EveSpriteSetBatch = exports.EveSpriteSetBatch = function (_Tw2RenderBatch) { + _inherits(EveSpriteSetBatch, _Tw2RenderBatch); - function EveCurveLineSetItem() { - _classCallCheck(this, EveCurveLineSetItem); + function EveSpriteSetBatch() { + _classCallCheck(this, EveSpriteSetBatch); - var _this = _possibleConstructorReturn(this, (EveCurveLineSetItem.__proto__ || Object.getPrototypeOf(EveCurveLineSetItem)).call(this)); + var _this = _possibleConstructorReturn(this, (EveSpriteSetBatch.__proto__ || Object.getPrototypeOf(EveSpriteSetBatch)).call(this)); - _this.type = EveCurveLineSetItem.Type.INVALID; - _this.position1 = _math.vec3.create(); - _this.color1 = _math.vec4.fromValues(1, 1, 1, 1); - _this.position2 = _math.vec3.create(); - _this.color2 = _math.vec4.fromValues(1, 1, 1, 1); - _this.intermediatePosition = _math.vec3.create(); - _this.width = 1; - _this.multiColor = _math.vec4.fromValues(0, 0, 0, 1); - _this.multiColorBorder = -1; - _this.overlayColor = _math.vec4.fromValues(0, 0, 0, 1); - _this.animationSpeed = 0; - _this.animationScale = 1; - _this.numOfSegments = 1; + _this.boosterGlow = false; + _this.spriteSet = null; + _this.world = null; + _this.boosterGain = 0; + _this.warpIntensity = 0; return _this; } /** - * Changes the line's colors - * @param {vec3} startColor - * @param {vec3} endColor + * Commits the sprite set + * @param {string} technique - technique name */ - _createClass(EveCurveLineSetItem, [{ - key: 'ChangeColor', - value: function ChangeColor(startColor, endColor) { - _math.vec3.copy(this.color1, startColor); - _math.vec3.copy(this.color2, endColor); - this.OnValueChanged(); - } - - /** - * Changes the line's width - * @param {number} width - */ - - }, { - key: 'ChangeWidth', - value: function ChangeWidth(width) { - this.width = width; - this.OnValueChanged(); - } - - /** - * Changes positions from cartesian coordinates - * @param {vec3} startPosition - * @param {vec3} endPosition - * @param {vec3} middle - */ - - }, { - key: 'ChangeCartesian', - value: function ChangeCartesian(startPosition, endPosition, middle) { - _math.vec3.copy(this.position1, startPosition); - _math.vec3.copy(this.position2, endPosition); - _math.vec3.copy(this.intermediatePosition, middle); - this.OnValueChanged(); - } - - /** - * Changes cartesian position - * @param {vec3} startPosition - * @param {vec3} endPosition - */ - - }, { - key: 'ChangePositionCartesian', - value: function ChangePositionCartesian(startPosition, endPosition) { - _math.vec3.copy(this.position1, startPosition); - _math.vec3.copy(this.position2, endPosition); - this.OnValueChanged(); - } - - /** - * Changes cartesian intermediate position - * @param {vec3} intermediatePosition - */ - - }, { - key: 'ChangeIntermediateCartesian', - value: function ChangeIntermediateCartesian(intermediatePosition) { - _math.vec3.copy(this.intermediatePosition, intermediatePosition); - this.OnValueChanged(); - } - - /** - * Changes positions from spherical - * @param {vec3} startPosition - * @param {vec3} endPosition - * @param {vec3} middle - * @param {vec3} center - */ - - }, { - key: 'ChangeSpherical', - value: function ChangeSpherical(startPosition, endPosition, middle, center) { - _math.vec3.fromSpherical(this.position1, startPosition, center); - _math.vec3.fromSpherical(this.position2, endPosition, center); - _math.vec3.fromSpherical(this.intermediatePosition, middle, center); - this.OnValueChanged(); - } - - /** - * Changes position from spherical coordinates - * @param {vec3} startPosition - * @param {vec3} endPosition - * @param {vec3} center - */ - - }, { - key: 'ChangePositionSpherical', - value: function ChangePositionSpherical(startPosition, endPosition, center) { - _math.vec3.fromSpherical(this.position1, startPosition, center); - _math.vec3.fromSpherical(this.position2, endPosition, center); - this.OnValueChanged(); + _createClass(EveSpriteSetBatch, [{ + key: 'Commit', + value: function Commit(technique) { + if (this.boosterGlow) { + this.spriteSet.RenderBoosterGlow(technique, this.world, this.boosterGain, this.warpIntensity); + } else { + this.spriteSet.Render(technique, this.world, this.perObjectData); + } } + }]); - /** - * Changes spherical intermediate position - * @param {vec3} intermediatePosition - * @param {vec3} center - */ - - }, { - key: 'ChangeIntermediateSpherical', - value: function ChangeIntermediateSpherical(intermediatePosition, center) { - _math.vec3.fromSpherical(this.intermediatePosition, intermediatePosition, center); - this.OnValueChanged(); - } + return EveSpriteSetBatch; +}(_core.Tw2RenderBatch); - /** - * Changes multi line color - * @param {vec4} color - * @param {number} border - */ +/** + * EveSpriteSetItem + * + * @property {vec3} position + * @property {number} blinkRate + * @property {number} blinkPhase + * @property {number} minScale + * @property {number} maxScale + * @property {number} falloff + * @property {vec4} color + * @property {vec4} warpColor + * @property {number} boneIndex + * @property {number} groupIndex + * @class + */ - }, { - key: 'ChangeMultiColor', - value: function ChangeMultiColor(color, border) { - _math.vec4.copy(this.multiColor, color); - this.multiColorBorder = border; - this.OnValueChanged(); - } - /** - * Changes animated color settings - * @param {vec4} color - * @param {number} speed - * @param {number} scale - */ +var EveSpriteSetItem = exports.EveSpriteSetItem = function (_EveObjectSetItem) { + _inherits(EveSpriteSetItem, _EveObjectSetItem); - }, { - key: 'ChangeAnimation', - value: function ChangeAnimation(color, speed, scale) { - _math.vec4.copy(this.overlayColor, color); - this.animationSpeed = speed; - this.animationScale = scale; - this.OnValueChanged(); - } + function EveSpriteSetItem() { + _classCallCheck(this, EveSpriteSetItem); - /** - * Changes line segmentation - * @param {number} numOfSegments - */ + var _this2 = _possibleConstructorReturn(this, (EveSpriteSetItem.__proto__ || Object.getPrototypeOf(EveSpriteSetItem)).call(this)); - }, { - key: 'ChangeSegmentation', - value: function ChangeSegmentation(numOfSegments) { - if (this.type !== EveCurveLineSetItem.Type.STRAIGHT) { - this.numOfSegments = numOfSegments; - this.OnValueChanged(); - } - } + _this2.position = _global.vec3.create(); + _this2.blinkRate = 0; + _this2.blinkPhase = 0; + _this2.minScale = 1; + _this2.maxScale = 1; + _this2.falloff = 0; + _this2.color = _global.vec4.create(); + _this2.warpColor = _global.vec4.create(); + _this2.boneIndex = 0; + _this2.groupIndex = -1; + return _this2; + } - /** - * Creates a line from an object - * @param {*} [opt={}] - * @returns {EveCurveLineSetItem} - */ + /** + * Creates a sprite set item from an object + * @param {*} [opt={}] + * @returns {EveSpriteSetItem} + */ - }], [{ + + _createClass(EveSpriteSetItem, null, [{ key: 'create', value: function create() { var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var item = new this(); - _math.util.assignIfExists(item, opt, ['name', 'display', 'type', 'position1', 'color1', 'position2', 'color2', 'intermediatePosition', 'width', 'multiColor', 'multiColorBorder', 'overlayColor', 'animationSpeed', 'animationScale', 'numOfSegments']); + _global.util.assignIfExists(item, opt, ['name', 'display', 'blinkRate', 'blinkPhase', 'minScale', 'maxScale', 'falloff', 'boneIndex', 'groupIndex', 'position', 'color', 'warpColor']); return item; } }]); - return EveCurveLineSetItem; + return EveSpriteSetItem; }(_EveObjectSet2.EveObjectSetItem); /** - * Curve line types - * @type {{INVALID: number, STRAIGHT: number, SPHERED: number, CURVED: number}} - */ - - -EveCurveLineSetItem.Type = { - INVALID: 0, - STRAIGHT: 1, - SPHERED: 2, - CURVED: 3 -}; - -/** - * Default curved line segmentation - * @type {number} - */ -EveCurveLineSetItem.DEFAULT_CURVED_SEGMENTS = 20; - -/** - * Default sphered line segmentation - * @type {number} - */ -EveCurveLineSetItem.DEFAULT_SPHERED_SEGEMENTS = 20; - -/** - * EveCurveLineSet + * EveSpriteSet * - * @property {Tw2Effect} lineEffect - * @property {?Tw2Effect} pickEffect - * @property {number} lineWidthFactor - * @property {boolean} additive - * @property {number} depthOffset - * @property {vec3} translation - * @property {quat} rotation - * @property {vec3} scaling - * @property {mat4} transform - * @property {mat4} parentTransform - * @property {number} _vertexSize - * @property {number} _vbSize - * @property {?WebGLBuffer} _vb - * @property {Tw2PerObjectData} _perObjectData + * @param {boolean} [useQuads] - Use quad rendering (CPU transform) + * @param {boolean} [isSkinned] - Use bone transforms (when useQuads is true) + * @property {Tw2Effect} effect + * @property {?boolean} useQuads - Use quad rendering (CPU transform) + * @property {?boolean} isSkinned - Use bone transforms (when useQuads is true) + * @property {number} _time + * @property {WebGLBuffer} _vertexBuffer + * @property {WebGLBuffer} _indexBuffer * @property {Tw2VertexDeclaration} _decl - * @class */ -var EveCurveLineSet = exports.EveCurveLineSet = function (_EveObjectSet) { - _inherits(EveCurveLineSet, _EveObjectSet); - - function EveCurveLineSet() { - _classCallCheck(this, EveCurveLineSet); - var _this2 = _possibleConstructorReturn(this, (EveCurveLineSet.__proto__ || Object.getPrototypeOf(EveCurveLineSet)).call(this)); +var EveSpriteSet = exports.EveSpriteSet = function (_EveObjectSet) { + _inherits(EveSpriteSet, _EveObjectSet); - _this2.lineEffect = _core.Tw2Effect.create({ - effectFilePath: 'res:/Graphics/Effect/Managed/Space/SpecialFX/Lines3D.fx', - textures: { - 'TexMap': 'res:/texture/global/white.dds.0.png', - 'OverlayTexMap': 'res:/texture/global/white.dds.0.png' - } - }); + function EveSpriteSet() { + var useQuads = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + var isSkinned = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - _this2.pickEffect = null; - _this2.lineWidthFactor = 1; - _this2.additive = false; - _this2.pickable = true; - _this2.depthOffset = 0; - _this2.translation = _math.vec3.create(); - _this2.rotation = _math.quat.create(); - _this2.scaling = _math.vec3.fromValues(1, 1, 1); - _this2.transform = _math.mat4.create(); - _this2.parentTransform = _math.mat4.create(); - _this2._vertexSize = 26; - _this2._vbSize = 0; - _this2._vb = null; + _classCallCheck(this, EveSpriteSet); - _this2._perObjectData = new _core.Tw2PerObjectData(); - _this2._perObjectData.perObjectVSData = new _core.Tw2RawData(); - _this2._perObjectData.perObjectVSData.Declare('WorldMat', 16); - _this2._perObjectData.perObjectVSData.Create(); - _this2._perObjectData.perObjectPSData = new _core.Tw2RawData(); - _this2._perObjectData.perObjectPSData.Declare('WorldMat', 16); - _this2._perObjectData.perObjectPSData.Create(); + var _this3 = _possibleConstructorReturn(this, (EveSpriteSet.__proto__ || Object.getPrototypeOf(EveSpriteSet)).call(this)); - _this2._decl = new _core.Tw2VertexDeclaration(); - _this2._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.POSITION, 0, _core.device.gl.FLOAT, 3, 0)); - _this2._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 0, _core.device.gl.FLOAT, 4, 12)); - _this2._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 1, _core.device.gl.FLOAT, 4, 28)); - _this2._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 2, _core.device.gl.FLOAT, 3, 44)); - _this2._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 0, _core.device.gl.FLOAT, 4, 56)); - _this2._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 1, _core.device.gl.FLOAT, 4, 72)); - _this2._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 2, _core.device.gl.FLOAT, 4, 88)); - _this2._decl.stride = 4 * _this2._vertexSize; - _this2._decl.RebuildHash(); + _this3.effect = null; + _this3.useQuads = null; + _this3.isSkinned = null; + _this3._time = 0; + _this3._vertexBuffer = null; + _this3._indexBuffer = null; + _this3._instanceBuffer = null; + _this3._decl = _this3._decl = new _core.Tw2VertexDeclaration(); + _this3._vdecl = new _core.Tw2VertexDeclaration(); + _this3._vdecl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 5, _global.device.gl.FLOAT, 1, 0)); + _this3._vdecl.RebuildHash(); - EveCurveLineSet.init(); - return _this2; + _this3.UseQuads(useQuads, isSkinned); + return _this3; } /** @@ -37513,386 +37802,388 @@ var EveCurveLineSet = exports.EveCurveLineSet = function (_EveObjectSet) { */ - _createClass(EveCurveLineSet, [{ - key: 'Initialize', + _createClass(EveSpriteSet, [{ + key: 'UseQuads', /** - * Initializes the curve line set + * Use instanced rendering or 'quad' rendering + * @param {boolean} useQuads - Use quad rendering (CPU transform) + * @param {boolean} isSkinned - Use bone transforms (when useQuads is true) */ - value: function Initialize() { - this.OnValueChanged(); - this.Rebuild(); - } + value: function UseQuads(useQuads, isSkinned) { + if (this.useQuads === useQuads) return; - /** - * Creates a straight line - * @param {vec3} start - * @param {vec3} end - * @param {number} [width] - * @param {vec4} [startColor] - * @param {vec4} [endColor] - * @returns {EveCurveLineSetItem} - */ + this.useQuads = useQuads; + this.isSkinned = isSkinned; - }, { - key: 'AddStraightLine', - value: function AddStraightLine(start, end, width, startColor, endColor) { - return this.CreateItem({ - type: EveCurveLineSetItem.Type.STRAIGHT, - position1: start, - position2: end, - color1: startColor, - color2: endColor, - width: width - }); + this._decl.elements.splice(0, this._decl.elements.length); + if (!useQuads) { + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 5, _global.device.gl.FLOAT, 2, 0)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.POSITION, 0, _global.device.gl.FLOAT, 3, 8)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 0, _global.device.gl.FLOAT, 3, 20)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 0, _global.device.gl.FLOAT, 1, 32)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 1, _global.device.gl.FLOAT, 1, 36)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 2, _global.device.gl.FLOAT, 1, 40)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 3, _global.device.gl.FLOAT, 1, 44)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 4, _global.device.gl.FLOAT, 1, 48)); + } else { + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.POSITION, 0, _global.device.gl.FLOAT, 3, 0)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 0, _global.device.gl.FLOAT, 4, 12)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 1, _global.device.gl.FLOAT, 2, 28)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 0, _global.device.gl.FLOAT, 4, 36)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 1, _global.device.gl.FLOAT, 4, 52)); + } + + this._decl.RebuildHash(); + this._rebuildPending = true; } /** - * Creates and adds a curved line from cartesian coordinates - * @param {vec3} start - * @param {vec3} end - * @param {vec3} center - * @param {number} [width] - * @param {vec4} [startColor] - * @param {vec4} [endColor] - * @returns {EveCurveLineSetItem} + * Gets Sprite Set Resource Objects + * @param {Array} [out=[]] - Optional receiving array + * @returns {Array.} [out] */ }, { - key: 'AddCurvedLineCrt', - value: function AddCurvedLineCrt(start, end, center, width, startColor, endColor) { - return this.CreateItem({ - type: EveCurveLineSetItem.Type.CURVED, - position1: start, - position2: end, - intermediatePosition: center, - color1: startColor, - color2: endColor, - width: width, - numOfSegments: EveCurveLineSetItem.DEFAULT_CURVED_SEGMENTS - }); + key: 'GetResources', + value: function GetResources() { + var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + + if (this.effect) { + this.effect.GetResources(out); + } + return out; } /** - * Creates and adds a curved line from spherical coordinates - * @param {vec3} start - * @param {vec3} end - * @param {vec3} center - * @param {vec3} middle - * @param {number} [width] - * @param {vec4} [startColor] - * @param {vec4} [endColor] - * @returns {EveCurveLineSetItem} + * Per frame update + * @param {number} dt - Delta time */ }, { - key: 'AddCurvedLineSph', - value: function AddCurvedLineSph(start, end, center, middle, width, startColor, endColor) { - var g = EveCurveLineSet.global; - return this.CreateItem({ - type: EveCurveLineSetItem.Type.CURVED, - position1: _math.vec3.fromSpherical(g.vec3_0, start, center), - position2: _math.vec3.fromSpherical(g.vec3_1, end, center), - intermediatePosition: _math.vec3.fromSpherical(g.vec3_2, middle, center), - color1: startColor, - color2: endColor, - width: width, - numOfSegments: EveCurveLineSetItem.DEFAULT_CURVED_SEGMENTS - }); + key: 'Update', + value: function Update(dt) { + this._time += dt; + + if (this._rebuildPending) { + this.Rebuild(); + } } /** - * Creates and adds a sphered line from cartesian coordinates - * @param {vec3} start - * @param {vec3} end - * @param {vec3} center - * @param {number} [width] - * @param {vec4} [startColor] - * @param {vec4} [endColor] - * @returns {EveCurveLineSetItem} + * Unloads the sprite set's buffers */ }, { - key: 'AddSpheredLineCrt', - value: function AddSpheredLineCrt(start, end, center, width, startColor, endColor) { - return this.CreateItem({ - type: EveCurveLineSetItem.Type.SPHERED, - position1: start, - position2: end, - intermediatePosition: center, - color1: startColor, - color2: endColor, - width: width, - numOfSegments: EveCurveLineSetItem.DEFAULT_SPHERED_SEGEMENTS - }); - } + key: 'Unload', + value: function Unload() { + if (this._vertexBuffer) { + _global.device.gl.deleteBuffer(this._vertexBuffer); + this._vertexBuffer = null; + } - /** - * Creates and adds a sphered line from spherical coordinates - * @param {vec3} start - * @param {vec3} end - * @param {vec3} center - * @param {vec3} middle - * @param {number} [width] - * @param {vec4} [startColor] - * @param {vec4} [endColor] - * @returns {EveCurveLineSetItem} - */ + // Standard + if (this._indexBuffer) { + _global.device.gl.deleteBuffer(this._indexBuffer); + this._indexBuffer = null; + } - }, { - key: 'AddSpheredLineSph', - value: function AddSpheredLineSph(start, end, center, middle, width, startColor, endColor) { - var g = EveCurveLineSet.global; - return this.CreateItem({ - type: EveCurveLineSetItem.Type.SPHERED, - position1: _math.vec3.fromSpherical(g.vec3_0, start, center), - position2: _math.vec3.fromSpherical(g.vec3_1, end, center), - intermediatePosition: _math.vec3.fromSpherical(g.vec3_2, middle, center), - color1: startColor, - color2: endColor, - width: width, - numOfSegments: EveCurveLineSetItem.DEFAULT_SPHERED_SEGEMENTS - }); + // Quad + if (this._instanceBuffer) { + _global.device.gl.deleteBuffer(this._instanceBuffer); + this._instanceBuffer = null; + } } /** - * Fire on value changes + * Rebuilds the sprite set's buffers */ }, { - key: 'OnValueChanged', - value: function OnValueChanged() { - _math.mat4.fromRotationTranslationScale(this.transform, this.rotation, this.translation, this.scaling); - this._rebuildPending = true; - } + key: 'Rebuild', + value: function Rebuild() { + this.constructor.RebuildItems(this); + this._rebuildPending = false; + var itemCount = this._visibleItems.length; + if (!itemCount) return; - /** - * Per frame update - * @param {mat4} parentTransform - */ + var d = _global.device; - }, { - key: 'UpdateViewDependentData', - value: function UpdateViewDependentData(parentTransform) { - _math.mat4.copy(this.parentTransform, parentTransform); + if (this.useQuads) { + this._vertexBuffer = d.gl.createBuffer(); + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vertexBuffer); + d.gl.bufferData(d.gl.ARRAY_BUFFER, new Float32Array([0, 1, 2, 2, 3, 0]), d.gl.STATIC_DRAW); + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, null); + this._instanceBuffer = d.gl.createBuffer(); + return; + } + + var vertexSize = 13, + array = new Float32Array(itemCount * 4 * vertexSize); + + for (var i = 0; i < itemCount; ++i) { + var item = this._visibleItems[i], + offset = i * 4 * vertexSize; + + array[offset] = 0; + array[offset + vertexSize] = 1; + array[offset + 2 * vertexSize] = 2; + array[offset + 3 * vertexSize] = 3; + + for (var j = 0; j < 4; ++j) { + var vtxOffset = offset + j * vertexSize; + array[vtxOffset + 1] = item.boneIndex; + array[vtxOffset + 2] = item.position[0]; + array[vtxOffset + 3] = item.position[1]; + array[vtxOffset + 4] = item.position[2]; + array[vtxOffset + 5] = item.color[0]; + array[vtxOffset + 6] = item.color[1]; + array[vtxOffset + 7] = item.color[2]; + array[vtxOffset + 8] = item.blinkPhase; + array[vtxOffset + 9] = item.blinkRate; + array[vtxOffset + 10] = item.minScale; + array[vtxOffset + 11] = item.maxScale; + array[vtxOffset + 12] = item.falloff; + } + } + + this._vertexBuffer = d.gl.createBuffer(); + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vertexBuffer); + d.gl.bufferData(d.gl.ARRAY_BUFFER, array, d.gl.STATIC_DRAW); + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, null); + + var indexes = new Uint16Array(itemCount * 6); + for (var _i = 0; _i < itemCount; ++_i) { + var _offset = _i * 6, + _vtxOffset = _i * 4; + + indexes[_offset] = _vtxOffset; + indexes[_offset + 1] = _vtxOffset + 2; + indexes[_offset + 2] = _vtxOffset + 1; + indexes[_offset + 3] = _vtxOffset; + indexes[_offset + 4] = _vtxOffset + 3; + indexes[_offset + 5] = _vtxOffset + 2; + } + + this._indexBuffer = d.gl.createBuffer(); + d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + d.gl.bufferData(d.gl.ELEMENT_ARRAY_BUFFER, indexes, d.gl.STATIC_DRAW); + d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, null); + this._indexBuffer.count = itemCount * 6; } /** - * Per frame update + * Gets render batches + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator + * @param {Tw2PerObjectData} perObjectData + * @param {mat4} world */ }, { - key: 'Update', - value: function Update() { - if (this._rebuildPending) { - this.Rebuild(); + key: 'GetBatches', + value: function GetBatches(mode, accumulator, perObjectData, world) { + if (this.display && mode === _global.device.RM_ADDITIVE && this._vertexBuffer && this._visibleItems.length) { + var batch = new EveSpriteSetBatch(); + batch.world = world; + batch.renderMode = _global.device.RM_ADDITIVE; + batch.spriteSet = this; + batch.perObjectData = perObjectData; + accumulator.Commit(batch); } } /** - * Unloads the line set's buffers + * Gets render batches for booster glows + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator + * @param {Tw2PerObjectData} perObjectData + * @param {mat4} world + * @param {Number} boosterGain + * @param {Number} warpIntensity */ }, { - key: 'Unload', - value: function Unload() { - if (this._vb) { - _core.device.gl.deleteBuffer(this._vb); - this._vb = null; + key: 'GetBoosterGlowBatches', + value: function GetBoosterGlowBatches(mode, accumulator, perObjectData, world, boosterGain, warpIntensity) { + if (this.display && mode === _global.device.RM_ADDITIVE && this._vertexBuffer && this._visibleItems.length) { + var batch = new EveSpriteSetBatch(); + batch.boosterGlow = true; + batch.world = world; + batch.boosterGain = boosterGain; + batch.warpIntensity = warpIntensity; + batch.renderMode = _global.device.RM_ADDITIVE; + batch.spriteSet = this; + batch.perObjectData = perObjectData; + accumulator.Commit(batch); } } /** - * Rebuilds the line set + * Renders the sprite set + * @param {string} technique - technique name + * @param {mat4} world + * @param {Tw2PerObjectData} perObjectData + * @returns {boolean} */ }, { - key: 'Rebuild', - value: function Rebuild() { - EveCurveLineSet.RebuildItems(this); - this._vb = null; - this._vbSize = this.lineCount; - this._rebuildPending = false; - var visibleItems = this._visibleItems.length; - if (!visibleItems) return; - - var g = EveCurveLineSet.global, - data = new Float32Array(this._vbSize * 6 * this._vertexSize), - startDir = g.vec3_0, - endDir = g.vec3_1, - startDirNrm = g.vec3_2, - endDirNrm = g.vec3_3, - rotationAxis = g.vec3_4, - tangent1 = g.vec3_5, - tangent2 = g.vec3_6, - rotationMatrix = g.mat4_0; - - var dir1 = g.vec3_7, - dir2 = g.vec3_8, - pos1 = g.vec3_9, - pos2 = g.vec3_10, - col1 = g.vec4_0, - col2 = g.vec4_1, - offset = 0, - tmp = void 0; - - for (var i = 0; i < visibleItems; ++i) { - var item = this._visibleItems[i]; - switch (item.type) { - case EveCurveLineSetItem.Type.INVALID: - break; - - case EveCurveLineSetItem.Type.STRAIGHT: - EveCurveLineSet.WriteLineVerticesToBuffer(this, item.position1, item.color1, 0, item.position2, item.color2, 1, i, data, offset); - offset += 6 * this._vertexSize; - break; - - case EveCurveLineSetItem.Type.SPHERED: - _math.vec3.subtract(startDir, item.position1, item.intermediatePosition); - _math.vec3.subtract(endDir, item.position2, item.intermediatePosition); - _math.vec3.normalize(startDirNrm, startDir); - _math.vec3.normalize(endDirNrm, endDir); - _math.vec3.cross(rotationAxis, startDir, endDir); - - var fullAngle = Math.acos(_math.vec3.dot(startDirNrm, endDirNrm)), - segmentAngle = fullAngle / item.numOfSegments; - - _math.mat4.identity(rotationMatrix); - _math.mat4.rotate(rotationMatrix, rotationMatrix, segmentAngle, rotationAxis); - _math.vec3.copy(dir1, startDir); - _math.vec4.copy(col1, item.color1); - - for (var j = 0; j < this.lines[i].numOfSegments; ++j) { - var segmentFactor = (j + 1) / item.numOfSegments; - _math.vec3.transformMat4(dir2, dir1, rotationMatrix); - col2[0] = item.color1[0] * (1 - segmentFactor) + item.color2[0] * segmentFactor; - col2[1] = item.color1[1] * (1 - segmentFactor) + item.color2[1] * segmentFactor; - col2[2] = item.color1[2] * (1 - segmentFactor) + item.color2[2] * segmentFactor; - col2[3] = item.color1[3] * (1 - segmentFactor) + item.color2[3] * segmentFactor; - _math.vec3.add(pos1, dir1, item.intermediatePosition); - _math.vec3.add(pos2, dir2, item.intermediatePosition); - EveCurveLineSet.WriteLineVerticesToBuffer(this, pos1, col1, j / item.numOfSegments, pos2, col2, segmentFactor, i, data, offset); - offset += 6 * this._vertexSize; - - tmp = dir1; - dir1 = dir2; - dir2 = tmp; - tmp = col1; - col1 = col2; - col2 = tmp; - } - break; + key: 'Render', + value: function Render(technique, world, perObjectData) { + if (this.useQuads) { + return this.RenderQuads(technique, world, perObjectData); + } - case EveCurveLineSetItem.Type.CURVED: - _math.vec3.subtract(tangent1, item.intermediatePosition, item.position1); - _math.vec3.subtract(tangent2, item.position2, item.intermediatePosition); - _math.vec3.copy(pos1, item.position1); - _math.vec3.copy(col1, item.color1); + if (!this.effect || !this.effect.IsGood() || !this._indexBuffer) return false; - for (var _j = 0; _j < item.numOfSegments; ++_j) { - var _segmentFactor = (_j + 1) / item.numOfSegments; - _math.vec3.hermite(pos2, item.position1, tangent1, item.position2, tangent2, _segmentFactor); - col2[0] = item.color1[0] * (1 - _segmentFactor) + item.color2[0] * _segmentFactor; - col2[1] = item.color1[1] * (1 - _segmentFactor) + item.color2[1] * _segmentFactor; - col2[2] = item.color1[2] * (1 - _segmentFactor) + item.color2[2] * _segmentFactor; - col2[3] = item.color1[3] * (1 - _segmentFactor) + item.color2[3] * _segmentFactor; - EveCurveLineSet.WriteLineVerticesToBuffer(this, pos1, col1, _j / item.numOfSegments, pos2, col2, _segmentFactor, i, data, offset); - offset += 6 * this._vertexSize; + _global.device.SetStandardStates(_global.device.RM_ADDITIVE); + _global.device.gl.bindBuffer(_global.device.gl.ARRAY_BUFFER, this._vertexBuffer); + _global.device.gl.bindBuffer(_global.device.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - tmp = pos1; - pos1 = pos2; - pos2 = tmp; - tmp = col1; - col1 = col2; - col2 = tmp; - } - } + for (var pass = 0; pass < this.effect.GetPassCount(technique); ++pass) { + this.effect.ApplyPass(technique, pass); + if (!this._decl.SetDeclaration(this.effect.GetPassInput(technique, pass), 52)) return false; + _global.device.ApplyShadowState(); + _global.device.gl.drawElements(_global.device.gl.TRIANGLES, this._indexBuffer.count, _global.device.gl.UNSIGNED_SHORT, 0); } - - //if (this._vb) device.gl.deleteBuffer(this._vb); - this._vb = _core.device.gl.createBuffer(); - _core.device.gl.bindBuffer(_core.device.gl.ARRAY_BUFFER, this._vb); - _core.device.gl.bufferData(_core.device.gl.ARRAY_BUFFER, data, _core.device.gl.STATIC_DRAW); - _core.device.gl.bindBuffer(_core.device.gl.ARRAY_BUFFER, null); + return true; } /** - * Gets render batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator + * Renders the sprite set as booster glow + * @param {string} technique - technique name + * @param {mat4} world + * @param {Number} boosterGain + * @param {Number} warpIntensity + * @returns {boolean} */ }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator) { - if (!this.display || !this._vb) return; + key: 'RenderBoosterGlow', + value: function RenderBoosterGlow(technique, world, boosterGain, warpIntensity) { + if (!this.effect || !this.effect.IsGood() || !this._instanceBuffer) return false; - var effect = void 0; - switch (mode) { - case _core.device.RM_TRANSPARENT: - if (this.additive || !this.lineEffect) return; - effect = this.lineEffect; - break; + var d = _global.device, + pos = _EveObjectSet2.EveObjectSet.global.vec3_0, + itemCount = this._visibleItems.length, + array = new Float32Array(17 * itemCount); - case _core.device.RM_ADDITIVE: - if (!this.additive || !this.lineEffect) return; - effect = this.lineEffect; - break; + d.SetStandardStates(d.RM_ADDITIVE); - case _core.device.RM_PICKABLE: - if (!this.pickable || !this.pickEffect) return; - effect = this.pickEffect; + var index = 0; + for (var i = 0; i < itemCount; ++i) { + var item = this._visibleItems[i]; + _global.vec3.transformMat4(pos, item.position, world); + array[index++] = pos[0]; + array[index++] = pos[1]; + array[index++] = pos[2]; + array[index++] = world[8]; + array[index++] = item.blinkPhase; + array[index++] = world[9]; + array[index++] = item.minScale; + array[index++] = item.maxScale; + array[index++] = world[10]; + array[index++] = item.color[0]; + array[index++] = item.color[1]; + array[index++] = item.color[2]; + array[index++] = boosterGain; + array[index++] = item.warpColor[0]; + array[index++] = item.warpColor[1]; + array[index++] = item.warpColor[2]; + array[index++] = warpIntensity; } - var batch = new _core.Tw2ForwardingRenderBatch(), - worldTransform = EveCurveLineSet.global.mat4_0; + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._instanceBuffer); + d.gl.bufferData(d.gl.ARRAY_BUFFER, array, d.gl.DYNAMIC_DRAW); - _math.mat4.multiply(worldTransform, this.transform, this.parentTransform); - _math.mat4.transpose(this._perObjectData.perObjectVSData.Get('WorldMat'), worldTransform); - _math.mat4.transpose(this._perObjectData.perObjectPSData.Get('WorldMat'), worldTransform); - batch.perObjectData = this._perObjectData; - batch.geometryProvider = this; - batch.renderMode = mode; - batch.effect = effect; - accumulator.Commit(batch); + for (var pass = 0; pass < this.effect.GetPassCount(technique); ++pass) { + this.effect.ApplyPass(technique, pass); + var passInput = this.effect.GetPassInput(technique, pass); + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vertexBuffer); + this._vdecl.SetPartialDeclaration(passInput, 4); + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._instanceBuffer); + var resetData = this._decl.SetPartialDeclaration(passInput, 17 * 4, 0, 1); + d.ApplyShadowState(); + d.ext.drawArraysInstanced(d.gl.TRIANGLES, 0, 6, itemCount); + this._decl.ResetInstanceDivisors(resetData); + } + + return true; } /** - * Per frame update - * @param {Tw2ForwardingRenderBatch} batch + * Renders the sprite set with pre-transformed quads * @param {string} technique - technique name + * @param {mat4} world + * @param {Tw2PerObjectData} perObjectData * @returns {boolean} */ }, { - key: 'Render', - value: function Render(batch, technique) { - if (!batch.effect || !batch.effect.IsGood()) return false; + key: 'RenderQuads', + value: function RenderQuads(technique, world, perObjectData) { + if (!this.effect || !this.effect.IsGood() || !this._instanceBuffer) return false; + + var d = _global.device, + itemCount = this._visibleItems.length, + array = new Float32Array(17 * itemCount), + pos = _EveObjectSet2.EveObjectSet.global.vec3_0, + bones = perObjectData.perObjectVSData.Get('JointMat'); - _core.device.gl.bindBuffer(_core.device.gl.ARRAY_BUFFER, this._vb); + d.SetStandardStates(d.RM_ADDITIVE); - var passCount = batch.effect.GetPassCount(technique); - for (var pass = 0; pass < passCount; ++pass) { - batch.effect.ApplyPass(technique, pass); - var passInput = batch.effect.GetPassInput(technique, pass); - if (!this._decl.SetDeclaration(passInput, this._decl.stride)) return false; - _core.device.ApplyShadowState(); - _core.device.gl.drawArrays(_core.device.gl.TRIANGLES, 0, this._vbSize * 6); + var index = 0; + for (var i = 0; i < itemCount; ++i) { + var item = this._visibleItems[i]; + if (this.isSkinned) { + var offset = item.boneIndex * 12; + pos[0] = bones[offset] * item.position[0] + bones[offset + 1] * item.position[1] + bones[offset + 2] * item.position[2] + bones[offset + 3]; + pos[1] = bones[offset + 4] * item.position[0] + bones[offset + 5] * item.position[1] + bones[offset + 6] * item.position[2] + bones[offset + 7]; + pos[2] = bones[offset + 8] * item.position[0] + bones[offset + 9] * item.position[1] + bones[offset + 10] * item.position[2] + bones[offset + 11]; + _global.vec3.transformMat4(pos, pos, world); + } else { + _global.vec3.transformMat4(pos, item.position, world); + } + + array[index++] = pos[0]; + array[index++] = pos[1]; + array[index++] = pos[2]; + array[index++] = 1; + array[index++] = item.blinkPhase; + array[index++] = item.blinkRate; + array[index++] = item.minScale; + array[index++] = item.maxScale; + array[index++] = item.falloff; + array[index++] = item.color[0]; + array[index++] = item.color[1]; + array[index++] = item.color[2]; + array[index++] = 1; + array[index++] = item.warpColor[0]; + array[index++] = item.warpColor[1]; + array[index++] = item.warpColor[2]; + array[index++] = 1; } - return true; - } - /** - * Fills color vertices - * @param {EveCurveLineSetItem} item - * @param buffer - * @param {number} offset - * @returns {number} - */ + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._instanceBuffer); + d.gl.bufferData(d.gl.ARRAY_BUFFER, array, d.gl.DYNAMIC_DRAW); + for (var pass = 0; pass < this.effect.GetPassCount(technique); ++pass) { + this.effect.ApplyPass(technique, pass); + var passInput = this.effect.GetPassInput(technique, pass); + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vertexBuffer); + this._vdecl.SetPartialDeclaration(passInput, 4); + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._instanceBuffer); + var resetData = this._decl.SetPartialDeclaration(passInput, 17 * 4, 0, 1); + d.ApplyShadowState(); + d.ext.drawArraysInstanced(d.gl.TRIANGLES, 0, 6, itemCount); + this._decl.ResetInstanceDivisors(resetData); + } + + return true; + } }, { - key: 'lines', + key: 'sprites', get: function get() { return this.items; } @@ -37905,664 +38196,748 @@ var EveCurveLineSet = exports.EveCurveLineSet = function (_EveObjectSet) { set: function set(arr) { this.items = arr; } + }]); - /** - * Gets the current line count - * @returns {number} - */ + return EveSpriteSet; +}(_EveObjectSet2.EveObjectSet); - }, { - key: 'lineCount', - get: function get() { - var count = 0; - for (var i = 0; i < this.items.length; i++) { - if (this.items[i].type !== EveCurveLineSetItem.Type.INVALID) { - count += this.items[i].numOfSegments; - } - } - return count; - } - }], [{ - key: 'FillColorVertices', - value: function FillColorVertices(item, buffer, offset) { - buffer[offset++] = item.multiColor[0]; - buffer[offset++] = item.multiColor[1]; - buffer[offset++] = item.multiColor[2]; - buffer[offset++] = item.multiColor[3]; - buffer[offset++] = item.overlayColor[0]; - buffer[offset++] = item.overlayColor[1]; - buffer[offset++] = item.overlayColor[2]; - buffer[offset++] = item.overlayColor[3]; - return offset; - } +/** + * The sprite set's item constructor + * @type {EveSpriteSetItem} + */ - /** - * Writes line vertices to the vertex buffer - * @param {EveCurveLineSet} lineSet - * @param {vec3} start - * @param {quat} startColor - * @param length1 - * @param {vec3} end - * @param {quat} endColor - * @param length2 - * @param {Number} lineID - * @param buffer - * @param {Number} offset - */ - }, { - key: 'WriteLineVerticesToBuffer', - value: function WriteLineVerticesToBuffer(lineSet, start, startColor, length1, end, endColor, length2, lineID, buffer, offset) { - var item = lineSet.items[lineID]; +EveSpriteSet.Item = EveSpriteSetItem; - buffer[offset++] = start[0]; - buffer[offset++] = start[1]; - buffer[offset++] = start[2]; - buffer[offset++] = end[0] - start[0]; - buffer[offset++] = end[1] - start[1]; - buffer[offset++] = end[2] - start[2]; - buffer[offset++] = -lineSet.lineWidthFactor * item.width; - buffer[offset++] = 0; - buffer[offset++] = length1; - buffer[offset++] = item.multiColorBorder; - buffer[offset++] = length2 - length1; - buffer[offset++] = item.animationSpeed; - buffer[offset++] = item.animationScale; - buffer[offset++] = lineID; - buffer[offset++] = startColor[0]; - buffer[offset++] = startColor[1]; - buffer[offset++] = startColor[2]; - buffer[offset++] = startColor[3]; - offset = EveCurveLineSet.FillColorVertices(item, buffer, offset); +/***/ }), +/* 182 */ +/***/ (function(module, exports, __webpack_require__) { - buffer[offset++] = start[0]; - buffer[offset++] = start[1]; - buffer[offset++] = start[2]; - buffer[offset++] = end[0] - start[0]; - buffer[offset++] = end[1] - start[1]; - buffer[offset++] = end[2] - start[2]; - buffer[offset++] = lineSet.lineWidthFactor * item.width; - buffer[offset++] = 0; - buffer[offset++] = length1; - buffer[offset++] = item.multiColorBorder; - buffer[offset++] = length2 - length1; - buffer[offset++] = item.animationSpeed; - buffer[offset++] = item.animationScale; - buffer[offset++] = lineID; - buffer[offset++] = startColor[0]; - buffer[offset++] = startColor[1]; - buffer[offset++] = startColor[2]; - buffer[offset++] = startColor[3]; - offset = EveCurveLineSet.FillColorVertices(item, buffer, offset); +"use strict"; - buffer[offset++] = end[0]; - buffer[offset++] = end[1]; - buffer[offset++] = end[2]; - buffer[offset++] = start[0] - end[0]; - buffer[offset++] = start[1] - end[1]; - buffer[offset++] = start[2] - end[2]; - buffer[offset++] = -lineSet.lineWidthFactor * item.width; - buffer[offset++] = 1; - buffer[offset++] = length2; - buffer[offset++] = item.multiColorBorder; - buffer[offset++] = length2 - length1; - buffer[offset++] = item.animationSpeed; - buffer[offset++] = item.animationScale; - buffer[offset++] = lineID; - buffer[offset++] = endColor[0]; - buffer[offset++] = endColor[1]; - buffer[offset++] = endColor[2]; - buffer[offset++] = endColor[3]; - offset = EveCurveLineSet.FillColorVertices(item, buffer, offset); - buffer[offset++] = start[0]; - buffer[offset++] = start[1]; - buffer[offset++] = start[2]; - buffer[offset++] = end[0] - start[0]; - buffer[offset++] = end[1] - start[1]; - buffer[offset++] = end[2] - start[2]; - buffer[offset++] = lineSet.lineWidthFactor * item.width; - buffer[offset++] = 0; - buffer[offset++] = length1; - buffer[offset++] = item.multiColorBorder; - buffer[offset++] = length2 - length1; - buffer[offset++] = item.animationSpeed; - buffer[offset++] = item.animationScale; - buffer[offset++] = lineID; - buffer[offset++] = startColor[0]; - buffer[offset++] = startColor[1]; - buffer[offset++] = startColor[2]; - buffer[offset++] = startColor[3]; - offset = EveCurveLineSet.FillColorVertices(item, buffer, offset); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.EveTurretSet = exports.EveTurretSetItem = undefined; - buffer[offset++] = end[0]; - buffer[offset++] = end[1]; - buffer[offset++] = end[2]; - buffer[offset++] = start[0] - end[0]; - buffer[offset++] = start[1] - end[1]; - buffer[offset++] = start[2] - end[2]; - buffer[offset++] = lineSet.lineWidthFactor * item.width; - buffer[offset++] = 1; - buffer[offset++] = length2; - buffer[offset++] = item.multiColorBorder; - buffer[offset++] = length2 - length1; - buffer[offset++] = item.animationSpeed; - buffer[offset++] = item.animationScale; - buffer[offset++] = lineID; - buffer[offset++] = endColor[0]; - buffer[offset++] = endColor[1]; - buffer[offset++] = endColor[2]; - buffer[offset++] = endColor[3]; - offset = EveCurveLineSet.FillColorVertices(item, buffer, offset); +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - buffer[offset++] = end[0]; - buffer[offset++] = end[1]; - buffer[offset++] = end[2]; - buffer[offset++] = start[0] - end[0]; - buffer[offset++] = start[1] - end[1]; - buffer[offset++] = start[2] - end[2]; - buffer[offset++] = -lineSet.lineWidthFactor * item.width; - buffer[offset++] = 1; - buffer[offset++] = length2; - buffer[offset++] = item.multiColorBorder; - buffer[offset++] = length2 - length1; - buffer[offset++] = item.animationSpeed; - buffer[offset++] = item.animationScale; - buffer[offset++] = lineID; - buffer[offset++] = endColor[0]; - buffer[offset++] = endColor[1]; - buffer[offset++] = endColor[2]; - buffer[offset++] = endColor[3]; - EveCurveLineSet.FillColorVertices(item, buffer, offset); - } +var _global = __webpack_require__(0); - /** - * Initializes class global variables and scratch - */ +var _core = __webpack_require__(1); - }, { - key: 'init', - value: function init() { - if (!EveCurveLineSet.global) { - EveCurveLineSet.global = { - vec3_0: _math.vec3.create(), // start direction - vec3_1: _math.vec3.create(), // end direction - vec3_2: _math.vec3.create(), // start direction normalized - vec3_3: _math.vec3.create(), // end direction normalized - vec3_4: _math.vec3.create(), // rotationAxis - vec3_5: _math.vec3.create(), // direction1 - vec3_6: _math.vec3.create(), // direction2 - vec3_7: _math.vec3.create(), // position 1 - vec3_8: _math.vec3.create(), // position 2 - vec3_9: _math.vec3.create(), // tangent1 - vec3_10: _math.vec3.create(), // tangent2 - vec4_0: _math.vec4.create(), // color 1 - vec4_1: _math.vec4.create(), // color 2 - mat4_0: _math.mat4.create() // rotationMatrix - }; - } - } - }]); +var _EveObjectSet2 = __webpack_require__(6); - return EveCurveLineSet; -}(_EveObjectSet2.EveObjectSet); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Class global variables and scratch + * EveTurretSetItem + * + * @property {?Tw2Bone} bone - The bone the turret is on + * @property {boolean} isJoint - Identifies if the turret is on a joint + * @property {?string} locatorName - The item's locator name + * @property {boolean} updateFromLocator - Allows the turret to be updated from a locator's transforms + * @property {boolean} canFireWhenHidden - Enables firing effects when hidden + * @property {vec3} position - The turret's position + * @property {quat} rotation - The turret's rotation + * @property {mat4} _localTransform - The turret's local transform + * @property {quat} _localRotation - the turret's local rotation */ +var EveTurretSetItem = exports.EveTurretSetItem = function (_EveObjectSetItem) { + _inherits(EveTurretSetItem, _EveObjectSetItem); + function EveTurretSetItem() { + _classCallCheck(this, EveTurretSetItem); -EveCurveLineSet.global = null; + var _this = _possibleConstructorReturn(this, (EveTurretSetItem.__proto__ || Object.getPrototypeOf(EveTurretSetItem)).call(this)); -/** - * Line set item constructor - * @type {EveCurveLineSetItem} - */ -EveCurveLineSet.Item = EveCurveLineSetItem; + _this.bone = null; + _this.locatorName = null; + _this.updateFromLocator = false; + _this.canFireWhenHidden = false; + _this.position = _global.vec3.create(); + _this.rotation = _global.quat.create(); + _this._localTransform = _global.mat4.create(); + _this._localRotation = _global.quat.create(); + return _this; + } -/***/ }), -/* 189 */ -/***/ (function(module, exports, __webpack_require__) { + /** + * Updates the turret's transforms + */ -"use strict"; + _createClass(EveTurretSetItem, [{ + key: 'UpdateTransforms', + value: function UpdateTransforms() { + _global.mat4.fromRotationTranslation(this._localTransform, this.rotation, this.position); -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.EveLocator = undefined; + if (this.bone) { + _global.mat4.multiply(this._localTransform, this.bone.offsetTransform, this._localTransform); + _global.mat4.getRotation(this._localRotation, this._localTransform); + } else { + _global.quat.copy(this._localRotation, this.rotation); + } + } -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + /** + * Creates a turret item from an object + * @param {*} [opt={}] + * @returns {EveTurretSetItem} + */ -var _index = __webpack_require__(0); + }], [{ + key: 'create', + value: function create() { + var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + var item = new this(); + _global.util.assignIfExists(item, opt, ['name', 'display', 'locatorName', 'updateFromLocator', 'position', 'rotation', 'bone', 'canFireWhenHidden']); + item.UpdateTransforms(); + return item; + } + }]); + + return EveTurretSetItem; +}(_EveObjectSet2.EveObjectSetItem); /** - * Contains transform information for T3 Attachments, Boosters, Turrets and XLTurrets + * EveTurretSet * - * @property {string} name - The locator's name - * @property {mat4} transform - The locator's transform - * @property {?number} atlasIndex0 - A booster locator's atlasIndex0 - * @property {?number} atlasIndex1 - A booster locator's atlasIndex1 - * @property {?Tw2Bone} bone - A turret locator's bone + * @property {Array.} turrets + * @property {Tw2AnimationController} activeAnimation + * @property {Tw2AnimationController} inactiveAnimation + * @property {string} geometryResPath + * @property {Tw2GeometryRes} geometryResource + * @property {number} bottomClipHeight + * @property {string} locatorName + * @property {Tw2Effect} turretEffect + * @property {vec3} targetPosition + * @property {number} sysBoneHeight + * @property {string} firingEffectResPath + * @property {EveTurretFiringFX} firingEffect + * @property {number} state + * @property {boolean} hasCyclingFiringPos + * @property {mat4} parentMatrix + * @property {quat} boundingSphere + * @property {number} _activeTurret + * @property {number} _recheckTimeLeft + * @property {number} _currentCyclingFiresPos + * @property {Tw2PerObjectData} _perObjectDataActive + * @property {Tw2PerObjectData} _perObjectDataInactive + * @property {boolean} _locatorRebuildPending + * @class */ -var EveLocator = exports.EveLocator = function () { - function EveLocator() { - _classCallCheck(this, EveLocator); - this.name = ''; - this.transform = _index.mat4.create(); - this.atlasIndex0 = null; - this.atlasIndex1 = null; - this.bone = null; + +var EveTurretSet = exports.EveTurretSet = function (_EveObjectSet) { + _inherits(EveTurretSet, _EveObjectSet); + + function EveTurretSet() { + _classCallCheck(this, EveTurretSet); + + var _this2 = _possibleConstructorReturn(this, (EveTurretSet.__proto__ || Object.getPrototypeOf(EveTurretSet)).call(this)); + + _this2.visible = {}; + _this2.visible.turrets = true; + _this2.visible.firingEffects = true; + _this2.activeAnimation = new _core.Tw2AnimationController(); + _this2.inactiveAnimation = new _core.Tw2AnimationController(); + _this2.geometryResPath = ''; + _this2.geometryResource = null; + _this2.turretEffect = null; + _this2.firingEffectResPath = ''; + _this2.firingEffect = null; + _this2.fireCallback = null; + _this2.fireCallbackPending = false; + _this2.state = EveTurretSet.State.IDLE; + _this2.bottomClipHeight = 0; + _this2.locatorName = ''; + _this2.sysBoneHeight = 0; + _this2.hasCyclingFiringPos = false; + _this2.targetPosition = _global.vec3.create(); + _this2.parentMatrix = _global.mat4.create(); + _this2.boundingSphere = _global.quat.create(); + _this2._activeTurret = -1; + _this2._recheckTimeLeft = 0; + _this2._currentCyclingFiresPos = 0; + + _this2._perObjectDataActive = new _core.Tw2PerObjectData(); + _this2._perObjectDataActive.perObjectVSData = new _core.Tw2RawData(); + _this2._perObjectDataActive.perObjectVSData.Declare('baseCutoffData', 4); + _this2._perObjectDataActive.perObjectVSData.Declare('turretSetData', 4); + _this2._perObjectDataActive.perObjectVSData.Declare('shipMatrix', 16); + _this2._perObjectDataActive.perObjectVSData.Declare('turretTranslation', 4 * 24); + _this2._perObjectDataActive.perObjectVSData.Declare('turretRotation', 4 * 24); + _this2._perObjectDataActive.perObjectVSData.Declare('turretPoseTransAndRot', 2 * 4 * 72); + _this2._perObjectDataActive.perObjectVSData.Create(); + + _this2._perObjectDataInactive = new _core.Tw2PerObjectData(); + _this2._perObjectDataInactive.perObjectVSData = new _core.Tw2RawData(); + _this2._perObjectDataInactive.perObjectVSData.Declare('baseCutoffData', 4); + _this2._perObjectDataInactive.perObjectVSData.Declare('turretSetData', 4); + _this2._perObjectDataInactive.perObjectVSData.Declare('shipMatrix', 16); + _this2._perObjectDataInactive.perObjectVSData.Declare('turretTranslation', 4 * 24); + _this2._perObjectDataInactive.perObjectVSData.Declare('turretRotation', 4 * 24); + _this2._perObjectDataInactive.perObjectVSData.Declare('turretPoseTransAndRot', 2 * 4 * 72); + _this2._perObjectDataInactive.perObjectVSData.Create(); + + _this2._locatorRebuildPending = true; + return _this2; } /** - * Gets the locator's bone from an animation controller - * @param {Tw2AnimationController} animationController - * @returns {?Tw2Bone} + * Alias for this.items + * @returns {Array} */ - _createClass(EveLocator, [{ - key: 'FindBone', - value: function FindBone(animationController) { - this.bone = null; - var model = animationController.FindModelForMesh(0); - if (model) { - for (var i = 0; i < model.bones.length; ++i) { - if (model.bones[i].boneRes.name === this.name) { - this.bone = model.bones[i]; - break; - } - } - } - return this.bone; - } - }]); + _createClass(EveTurretSet, [{ + key: 'Initialize', - return EveLocator; -}(); -/** - * Locator name prefixes - * @type {{AUDIO: string, ATTACH: string, BOOSTER: string, TURRET: string, XL_TURRET: string}} - */ + /** + * Initializes the Turret Set + */ + value: function Initialize() { + var _this3 = this; + if (this.turretEffect && this.geometryResPath !== '') { + this.geometryResource = _global.resMan.GetResource(this.geometryResPath); + this.activeAnimation.SetGeometryResource(this.geometryResource); + this.inactiveAnimation.SetGeometryResource(this.geometryResource); + if (this.geometryResource) this.geometryResource.RegisterNotification(this); + } -EveLocator.Prefix = { - AUDIO: 'locator_audio', - ATTACH: 'locator_attach', - BOOSTER: 'locator_booster', - TURRET: 'locator_turret', - XL_TURRET: 'locator_xl' -}; + if (this.firingEffectResPath !== '') { + _global.resMan.GetObject(this.firingEffectResPath, function (object) { + return _this3.firingEffect = object; + }); + } -/***/ }), -/* 190 */ -/***/ (function(module, exports, __webpack_require__) { + this.Rebuild(); + } -"use strict"; + /** + * Initializes turret set's firing effect + */ + }, { + key: 'InitializeFiringEffect', + value: function InitializeFiringEffect() { + if (!this.firingEffect) return; -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.EvePlaneSet = exports.EvePlaneSetItem = exports.EvePlaneSetBatch = undefined; + if (this.geometryResource && this.geometryResource.models.length) { + var model = this.geometryResource.models[0]; + for (var i = 0; i < this.firingEffect.GetPerMuzzleEffectCount(); ++i) { + this.firingEffect.SetMuzzleBoneID(i, model.FindBoneByName(EveTurretSet.positionBoneSkeletonNames[i])); + } + } + } -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + /** + * Helper function for finding out what turret should be firing + * @returns {number} + */ -var _math = __webpack_require__(0); + }, { + key: 'GetClosestTurret', + value: function GetClosestTurret() { + var closestTurret = -1, + closestAngle = -2; -var _core = __webpack_require__(1); + var g = EveTurretSet.global, + nrmToTarget = g.vec3_0, + nrmUp = g.vec4_0, + turretPosition = g.vec4_1; -var _EveObjectSet2 = __webpack_require__(10); + for (var i = 0; i < this.items.length; ++i) { + var item = this.items[i]; + if (!item.display && !item.canFireWhenHidden) continue; -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + turretPosition[0] = item._localTransform[12]; + turretPosition[1] = item._localTransform[13]; + turretPosition[2] = item._localTransform[14]; + turretPosition[3] = 1; + _global.vec4.transformMat4(turretPosition, turretPosition, this.parentMatrix); + _global.vec3.subtract(nrmToTarget, this.targetPosition, turretPosition); + _global.vec3.normalize(nrmToTarget, nrmToTarget); + _global.vec4.set(nrmUp, 0, 1, 0, 0); + _global.vec4.transformMat4(nrmUp, nrmUp, item._localTransform); + _global.vec4.transformMat4(nrmUp, nrmUp, this.parentMatrix); + var angle = _global.vec3.dot(nrmUp, nrmToTarget); + if (angle > closestAngle) { + closestTurret = this.items.indexOf(item); + closestAngle = angle; + } + } -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + return closestTurret; + } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + /** + * Animation helper function for deactivating a turret set + */ -/** - * Plane set render batch - * - * @property {EvePlaneSet} planeSet - * @class - */ -var EvePlaneSetBatch = exports.EvePlaneSetBatch = function (_Tw2RenderBatch) { - _inherits(EvePlaneSetBatch, _Tw2RenderBatch); + }, { + key: 'EnterStateDeactive', + value: function EnterStateDeactive() { + var _this4 = this; - function EvePlaneSetBatch() { - _classCallCheck(this, EvePlaneSetBatch); + if (this.state === EveTurretSet.State.INACTIVE || this.state === EveTurretSet.State.PACKING) return; - var _this = _possibleConstructorReturn(this, (EvePlaneSetBatch.__proto__ || Object.getPrototypeOf(EvePlaneSetBatch)).call(this)); + if (this.turretEffect) { + this.activeAnimation.StopAllAnimations(); + this.inactiveAnimation.StopAllAnimations(); - _this.planeSet = null; - return _this; - } + this.activeAnimation.PlayAnimation('Pack', false, function () { + _this4.state = EveTurretSet.State.INACTIVE; + _this4.activeAnimation.PlayAnimation('Inactive', true); + }); - /** - * Commits the plan set - * @param {string} technique - technique name - */ + this.inactiveAnimation.PlayAnimation('Pack', false, function () { + _this4.state = EveTurretSet.State.INACTIVE; + _this4.inactiveAnimation.PlayAnimation('Inactive', true); + }); + + this.state = EveTurretSet.State.PACKING; + } else { + this.state = EveTurretSet.State.INACTIVE; + } + this._activeTurret = -1; - _createClass(EvePlaneSetBatch, [{ - key: 'Commit', - value: function Commit(technique) { - this.planeSet.Render(technique); + if (this.firingEffect) { + this.firingEffect.StopFiring(); + } } - }]); - return EvePlaneSetBatch; -}(_core.Tw2RenderBatch); + /** + * Animation helper function for putting a turret set into idle state + */ -/** - * EvePlaneSetItem - * - * @property {number} boneIndex - * @property {number} groupIndex - * @property {number} maskAtlasID - * @property {vec3} position - * @property {vec3} scaling - * @property {quat} rotation - * @property {vec4} color - * @property {vec4} layer1Transform - * @property {vec4} layer2Transform - * @property {vec4} layer1Scroll - * @property {vec4} layer2Scroll - * @class - */ + }, { + key: 'EnterStateIdle', + value: function EnterStateIdle() { + var _this5 = this; + if (this.state === EveTurretSet.State.IDLE || this.state === EveTurretSet.State.UNPACKING) return; -var EvePlaneSetItem = exports.EvePlaneSetItem = function (_EveObjectSetItem) { - _inherits(EvePlaneSetItem, _EveObjectSetItem); + if (this.turretEffect) { + this.activeAnimation.StopAllAnimations(); + this.inactiveAnimation.StopAllAnimations(); - function EvePlaneSetItem() { - _classCallCheck(this, EvePlaneSetItem); + if (this.state === EveTurretSet.State.FIRING) { + this.activeAnimation.PlayAnimation('Active', true); + this.inactiveAnimation.PlayAnimation('Active', true); + } else { + this.activeAnimation.PlayAnimation('Deploy', false, function () { + _this5.state = EveTurretSet.State.IDLE; + _this5.activeAnimation.PlayAnimation('Active', true); + }); - var _this2 = _possibleConstructorReturn(this, (EvePlaneSetItem.__proto__ || Object.getPrototypeOf(EvePlaneSetItem)).call(this)); + this.inactiveAnimation.PlayAnimation('Deploy', false, function () { + _this5.state = EveTurretSet.State.IDLE; + _this5.inactiveAnimation.PlayAnimation('Active', true); + }); + } - _this2.boneIndex = 0; - _this2.groupIndex = -1; - _this2.maskAtlasID = 0; - _this2.position = _math.vec3.create(); - _this2.scaling = _math.vec3.fromValues(1, 1, 1); - _this2.rotation = _math.quat.create(); - _this2.transform = _math.mat4.create(); - _this2.color = _math.vec4.fromValues(1, 1, 1, 1); - _this2.layer1Transform = _math.vec4.fromValues(1, 1, 0, 0); - _this2.layer2Transform = _math.vec4.fromValues(1, 1, 0, 0); - _this2.layer1Scroll = _math.vec4.create(); - _this2.layer2Scroll = _math.vec4.create(); - return _this2; - } + this.state = EveTurretSet.State.UNPACKING; + } else { + this.state = EveTurretSet.State.IDLE; + } - /** - * Creates a plane set item from an object - * @param {*} opt - * @returns {EvePlaneSetItem} - */ + this._activeTurret = -1; + if (this.firingEffect) { + this.firingEffect.StopFiring(); + } + } - _createClass(EvePlaneSetItem, null, [{ - key: 'create', - value: function create() { - var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + /** + * Animation helper function for putting a turret set into a firing state + */ - var item = new this(); - _math.util.assignIfExists(item, opt, ['name', 'display', 'boneIndex', 'groupIndex', 'maskAtlasID', 'position', 'scaling', 'rotation', 'transform', 'color', 'layer1Transform', 'layer2Transform', 'layer1Scroll', 'layer2Scroll']); - return item; - } - }]); + }, { + key: 'EnterStateFiring', + value: function EnterStateFiring() { + var _this6 = this; - return EvePlaneSetItem; -}(_EveObjectSet2.EveObjectSetItem); + if (!this.turretEffect || this.state === EveTurretSet.State.FIRING) { + EveTurretSet.DoStartFiring(this); + if (this.turretEffect) { + this.activeAnimation.PlayAnimation('Fire', false, function () { + _this6.activeAnimation.PlayAnimation('Active', true); + }); + } + return; + } -/** - * EvePlaneSet - * - * @property {String} name - * @property {Array.} planes - * @property {Tw2Effect} effect - * @property {boolean} display - * @property {boolean} hideOnLowQuality - * @property {number} _time - * @property {WebGLBuffer} _vertexBuffer - * @property {WebGLBuffer} _indexBuffer - * @property {Tw2VertexDeclaration} _decl - * @class - */ + this.activeAnimation.StopAllAnimations(); + this.inactiveAnimation.StopAllAnimations(); + if (this.state === EveTurretSet.State.INACTIVE) { + this.activeAnimation.PlayAnimation('Deploy', false, function () { + EveTurretSet.DoStartFiring(_this6); + _this6.activeAnimation.PlayAnimation('Fire', false, function () { + _this6.activeAnimation.PlayAnimation('Active', true); + }); + }); + this.inactiveAnimation.PlayAnimation('Deploy', false, function () { + _this6.inactiveAnimation.PlayAnimation('Active', true); + }); + this.state = EveTurretSet.State.UNPACKING; + } else { + EveTurretSet.DoStartFiring(this); + this.activeAnimation.PlayAnimation('Fire', false, function () { + _this6.activeAnimation.PlayAnimation('Active', true); + }); -var EvePlaneSet = exports.EvePlaneSet = function (_EveObjectSet) { - _inherits(EvePlaneSet, _EveObjectSet); + this.inactiveAnimation.PlayAnimation('Active', true); + } + } - function EvePlaneSet() { - _classCallCheck(this, EvePlaneSet); + /** + * Rebuilds the turret sets cached data + */ - var _this3 = _possibleConstructorReturn(this, (EvePlaneSet.__proto__ || Object.getPrototypeOf(EvePlaneSet)).call(this)); + }, { + key: 'RebuildCachedData', + value: function RebuildCachedData() { + var instancedElement = new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 1, _global.device.gl.FLOAT, 2), + meshes = this.geometryResource.meshes, + active = this.activeAnimation, + inactive = this.inactiveAnimation; - _this3.effect = null; - _this3.hideOnLowQuality = false; - _this3._time = 0; - _this3._vertexBuffer = null; - _this3._indexBuffer = null; + for (var i = 0; i < meshes.length; ++i) { + meshes[i].declaration.elements.push(instancedElement); + meshes[i].declaration.RebuildHash(); + } - _this3._decl = new _core.Tw2VertexDeclaration(); - _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 0, _core.device.gl.FLOAT, 4, 0)); - _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 1, _core.device.gl.FLOAT, 4, 16)); - _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 2, _core.device.gl.FLOAT, 4, 32)); - _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 0, _core.device.gl.FLOAT, 4, 48)); - _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 3, _core.device.gl.FLOAT, 4, 64)); - _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 4, _core.device.gl.FLOAT, 4, 80)); - _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 5, _core.device.gl.FLOAT, 4, 96)); - _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 6, _core.device.gl.FLOAT, 4, 112)); - _this3._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 7, _core.device.gl.FLOAT, 3, 128)); - _this3._decl.RebuildHash(); - return _this3; - } + switch (this.state) { + case EveTurretSet.State.INACTIVE: + active.PlayAnimation('Inactive', true); + inactive.PlayAnimation('Inactive', true); + break; - /** - * Alias for this.items - * @returns {Array} - */ + case EveTurretSet.State.IDLE: + active.PlayAnimation('Active', true); + inactive.PlayAnimation('Active', true); + break; + case EveTurretSet.State.FIRING: + active.PlayAnimation('Fire', false, function () { + return active.PlayAnimation('Active', true); + }); + inactive.PlayAnimation('Active', true); + break; - _createClass(EvePlaneSet, [{ - key: 'GetResources', + case EveTurretSet.State.PACKING: + this.EnterStateIdle(); + break; + case EveTurretSet.State.UNPACKING: + this.EnterStateDeactive(); + break; + } + } /** - * Gets plane set res objects - * @param {Array} [out=[]] - Optional receiving array - * @returns {Array} {Array.} [out] + * Finds a turret item by name + * @param {string} name + * @returns {?EveTurretSetItem} */ - value: function GetResources() { - var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - if (this.effect) { - this.effect.GetResources(out); + }, { + key: 'FindItemByLocatorName', + value: function FindItemByLocatorName(name) { + for (var i = 0; i < this.items.length; i++) { + if (this.items[i].locatorName === name) { + return this.items[i]; + } } - return out; + return null; } /** - * Per frame update - * @param {number} dt - Delta Time + * Updates the turret set's items that were created from locators + * - Turrets without locator names are ignored + * @param {Array} locators */ }, { - key: 'Update', - value: function Update(dt) { - this._time += dt; + key: 'UpdateItemsFromLocators', + value: function UpdateItemsFromLocators(locators) { + var g = EveTurretSet.global, + toRemove = Array.from(this.items), + norm = g.mat4_0; - if (this._rebuildPending) { - this.Rebuild(); + for (var i = 0; i < locators.length; i++) { + var _locators$i = locators[i], + name = _locators$i.name, + transform = _locators$i.transform, + _locators$i$bone = _locators$i.bone, + bone = _locators$i$bone === undefined ? null : _locators$i$bone; + + + var item = this.FindItemByLocatorName(name); + if (!item) { + item = this.CreateItem({ + name: name, + locatorName: name, + updateFromLocator: true + }); + } else { + toRemove.splice(toRemove.indexOf(item), 1); + } + + if (item.updateFromLocator) { + item.bone = bone; + _global.mat4.copy(norm, transform); + _global.vec3.normalize(norm.subarray(0, 3), norm.subarray(0, 3)); + _global.vec3.normalize(norm.subarray(4, 7), norm.subarray(4, 7)); + _global.vec3.normalize(norm.subarray(8, 11), norm.subarray(8, 11)); + _global.mat4.getRotation(item.rotation, norm); + _global.mat4.getTranslation(item.position, norm); + item.OnValueChanged(); + } + } + + for (var _i = 0; _i < toRemove.length; _i++) { + if (toRemove[_i].locatorName) { + this.RemoveItem(toRemove[_i]); + _i--; + } } + + this._locatorRebuildPending = false; + if (this._rebuildPending) this.Rebuild(); } /** - * Unloads the set's buffers + * Rebuilds the turret set's items from it's parent's locators */ }, { - key: 'Unload', - value: function Unload() { - if (this._vertexBuffer) { - _core.device.gl.deleteBuffer(this._vertexBuffer); - this._vertexBuffer = null; + key: 'RebuildItemsFromLocators', + value: function RebuildItemsFromLocators() { + this._locatorRebuildPending = true; + } + + /** + * Gets turret set res objects + * @param {Array} [out=[]] - Optional receiving array + * @returns {Array.} [out] + */ + + }, { + key: 'GetResources', + value: function GetResources() { + var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + + if (this.geometryResource && !out.includes(this.geometryResource)) { + out.push(this.geometryResource); } - if (this._indexBuffer) { - _core.device.gl.deleteBuffer(this._indexBuffer); - this._indexBuffer = null; + if (this.turretEffect) { + this.turretEffect.GetResources(out); + } + + if (this.firingEffect) { + this.firingEffect.GetResources(out); } + + return out; } /** - * Rebuilds the plane set's buffers + * Updates view dependent data */ }, { - key: 'Rebuild', - value: function Rebuild() { - this.Unload(); - EvePlaneSet.RebuildItems(this); - this._rebuildPending = false; - var itemCount = this._visibleItems.length; - if (!itemCount) return; - - var vertexSize = 35, - mat4_0 = EvePlaneSet.global.mat4_0; - - var array = new Float32Array(itemCount * 4 * vertexSize); - for (var i = 0; i < itemCount; ++i) { - var item = this._visibleItems[i], - offset = i * 4 * vertexSize; + key: 'UpdateViewDependentData', + value: function UpdateViewDependentData() { + if (this.firingEffect) { + this.firingEffect.UpdateViewDependentData(); + } + } - array[offset + vertexSize - 3] = 0; - array[offset + vertexSize + vertexSize - 3] = 1; - array[offset + 2 * vertexSize + vertexSize - 3] = 2; - array[offset + 3 * vertexSize + vertexSize - 3] = 3; + /** + * Per frame update + * @param {number} dt - Delta Time + * @param {mat4} parentMatrix + */ - var itemTransform = _math.mat4.fromRotationTranslationScale(mat4_0, item.rotation, item.position, item.scaling); + }, { + key: 'Update', + value: function Update(dt, parentMatrix) { + if (this._rebuildPending) { + this.Rebuild(); + } - for (var j = 0; j < 4; ++j) { - var vtxOffset = offset + j * vertexSize; - array[vtxOffset] = itemTransform[0]; - array[vtxOffset + 1] = itemTransform[4]; - array[vtxOffset + 2] = itemTransform[8]; - array[vtxOffset + 3] = itemTransform[12]; - array[vtxOffset + 4] = itemTransform[1]; - array[vtxOffset + 5] = itemTransform[5]; - array[vtxOffset + 6] = itemTransform[9]; - array[vtxOffset + 7] = itemTransform[13]; - array[vtxOffset + 8] = itemTransform[2]; - array[vtxOffset + 9] = itemTransform[6]; - array[vtxOffset + 10] = itemTransform[10]; - array[vtxOffset + 11] = itemTransform[14]; + if (this.turretEffect) { + this.activeAnimation.Update(dt); + this.inactiveAnimation.Update(dt); + } - array[vtxOffset + 12] = item.color[0]; - array[vtxOffset + 13] = item.color[1]; - array[vtxOffset + 14] = item.color[2]; - array[vtxOffset + 15] = item.color[3]; + _global.mat4.copy(this.parentMatrix, parentMatrix); - array[vtxOffset + 16] = item.layer1Transform[0]; - array[vtxOffset + 17] = item.layer1Transform[1]; - array[vtxOffset + 18] = item.layer1Transform[2]; - array[vtxOffset + 19] = item.layer1Transform[3]; + if (this.firingEffect && this._visibleItems.length) { + if (this._activeTurret !== -1) { + if (this.firingEffect.isLoopFiring) { + if (this.state === EveTurretSet.State.FIRING) { + this._recheckTimeLeft -= dt; + if (this._recheckTimeLeft <= 0) { + EveTurretSet.DoStartFiring(this); + } + } + } - array[vtxOffset + 20] = item.layer2Transform[0]; - array[vtxOffset + 21] = item.layer2Transform[1]; - array[vtxOffset + 22] = item.layer2Transform[2]; - array[vtxOffset + 23] = item.layer2Transform[3]; + var activeItem = this.items[this._activeTurret]; - array[vtxOffset + 24] = item.layer1Scroll[0]; - array[vtxOffset + 25] = item.layer1Scroll[1]; - array[vtxOffset + 26] = item.layer1Scroll[2]; - array[vtxOffset + 27] = item.layer1Scroll[3]; + if (this.activeAnimation.models.length) { + var bones = this.activeAnimation.models[0].bonesByName; + for (var i = 0; i < this.firingEffect.GetPerMuzzleEffectCount(); ++i) { + var transform = bones[EveTurretSet.positionBoneSkeletonNames[i]].worldTransform, + out = this.firingEffect.GetMuzzleTransform(i); - array[vtxOffset + 28] = item.layer2Scroll[0]; - array[vtxOffset + 29] = item.layer2Scroll[1]; - array[vtxOffset + 30] = item.layer2Scroll[2]; - array[vtxOffset + 31] = item.layer2Scroll[3]; + _global.mat4.multiply(out, activeItem._localTransform, transform); + _global.mat4.multiply(out, out, parentMatrix); + } + } else { + for (var _i2 = 0; _i2 < this.firingEffect.GetPerMuzzleEffectCount(); ++_i2) { + _global.mat4.multiply(this.firingEffect.GetMuzzleTransform(_i2), parentMatrix, activeItem._localTransform); + } + } - array[vtxOffset + 33] = item.boneIndex; - array[vtxOffset + 34] = item.maskAtlasID; + if (this.fireCallbackPending) { + if (this.fireCallback) { + var cbTransforms = []; + for (var _i3 = 0; _i3 < this.firingEffect.GetPerMuzzleEffectCount(); ++_i3) { + cbTransforms.push(this.firingEffect.GetMuzzleTransform(_i3)); + } + this.fireCallback(this, cbTransforms); + } + this.fireCallbackPending = false; + } } + + _global.vec3.copy(this.firingEffect.endPosition, this.targetPosition); + this.firingEffect.Update(dt); } + } + + /** + * Gets turret set render batches + * @param {number} mode + * @param {Tw2BatchAccumulator} accumulator + * @param {Tw2PerObjectData} perObjectData + * @param {boolean} [hideFiringEffect] + */ - this._vertexBuffer = _core.device.gl.createBuffer(); - _core.device.gl.bindBuffer(_core.device.gl.ARRAY_BUFFER, this._vertexBuffer); - _core.device.gl.bufferData(_core.device.gl.ARRAY_BUFFER, array, _core.device.gl.STATIC_DRAW); - _core.device.gl.bindBuffer(_core.device.gl.ARRAY_BUFFER, null); + }, { + key: 'GetBatches', + value: function GetBatches(mode, accumulator, perObjectData, hideFiringEffect) { + if (!this.turretEffect || !this.geometryResource || !this.display || !this._visibleItems.length) return; - var indexes = new Uint16Array(itemCount * 6); - for (var _i = 0; _i < itemCount; ++_i) { - var _offset = _i * 6, - _vtxOffset = _i * 4; + if (mode === _global.device.RM_OPAQUE && this.visible.turrets) { + var transforms = this.inactiveAnimation.GetBoneMatrices(0); + if (transforms.length !== 0) { + EveTurretSet.UpdatePerObjectData(this, this._perObjectDataInactive.perObjectVSData, transforms); + this._perObjectDataInactive.perObjectPSData = perObjectData.perObjectPSData; - indexes[_offset] = _vtxOffset; - indexes[_offset + 1] = _vtxOffset + 2; - indexes[_offset + 2] = _vtxOffset + 1; - indexes[_offset + 3] = _vtxOffset; - indexes[_offset + 4] = _vtxOffset + 3; - indexes[_offset + 5] = _vtxOffset + 2; + var batch = new _core.Tw2ForwardingRenderBatch(); + batch.renderMode = mode; + batch.renderActive = false; + batch.perObjectData = this._perObjectDataInactive; + batch.geometryProvider = this; + accumulator.Commit(batch); + + if (this.state === EveTurretSet.State.FIRING) { + var _transforms = this.activeAnimation.GetBoneMatrices(0); + if (_transforms.length !== 0) { + EveTurretSet.UpdatePerObjectData(this, this._perObjectDataActive.perObjectVSData, _transforms, true); + this._perObjectDataActive.perObjectPSData = perObjectData.perObjectPSData; + + var _batch = new _core.Tw2ForwardingRenderBatch(); + _batch.renderActive = true; + _batch.perObjectData = this._perObjectDataActive; + _batch.geometryProvider = this; + accumulator.Commit(_batch); + } + } + } } - this._indexBuffer = _core.device.gl.createBuffer(); - _core.device.gl.bindBuffer(_core.device.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - _core.device.gl.bufferData(_core.device.gl.ELEMENT_ARRAY_BUFFER, indexes, _core.device.gl.STATIC_DRAW); - _core.device.gl.bindBuffer(_core.device.gl.ELEMENT_ARRAY_BUFFER, null); - this._indexBuffer.count = itemCount * 6; + this.GetFiringEffectBatches(mode, accumulator, perObjectData, hideFiringEffect); } /** - * Gets the plane set's render batches + * Gets turret firing effect batches * @param {number} mode * @param {Tw2BatchAccumulator} accumulator * @param {Tw2PerObjectData} perObjectData + * @param {boolean} [hideFiringEffect] */ }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator, perObjectData) { - if (this.display && mode === _core.device.RM_ADDITIVE && this._indexBuffer && this._visibleItems.length) { - var batch = new EvePlaneSetBatch(); - batch.renderMode = _core.device.RM_ADDITIVE; - batch.planeSet = this; - batch.perObjectData = perObjectData; - accumulator.Commit(batch); + key: 'GetFiringEffectBatches', + value: function GetFiringEffectBatches(mode, accumulator, perObjectData, hideFiringEffect) { + if (this.firingEffect && this.display && this._visibleItems.length && this.visible.firingEffects && !hideFiringEffect) { + this.firingEffect.GetBatches(mode, accumulator, perObjectData); } } /** - * Renders the plane set + * Renders the turret set + * @param batch * @param {string} technique - technique name + * @returns {boolean} */ }, { key: 'Render', - value: function Render(technique) { - if (!this.effect || !this.effect.IsGood()) return false; + value: function Render(batch, technique) { + if (!this.turretEffect || !this.turretEffect.IsGood() || !this._visibleItems.length) return false; + + var index = 0; + var customSetter = function customSetter(el) { + _global.device.gl.disableVertexAttribArray(el.location); + _global.device.gl.vertexAttrib2f(el.location, index, index); + }; - _core.device.SetStandardStates(_core.device.RM_ADDITIVE); - _core.device.gl.bindBuffer(_core.device.gl.ARRAY_BUFFER, this._vertexBuffer); - _core.device.gl.bindBuffer(_core.device.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + for (var i = 0; i < this.geometryResource.meshes.length; ++i) { + var decl = this.geometryResource.meshes[i].declaration; + decl.FindUsage(_core.Tw2VertexDeclaration.Type.TEXCOORD, 1).customSetter = customSetter; + } - for (var pass = 0; pass < this.effect.GetPassCount(technique); ++pass) { - this.effect.ApplyPass(technique, pass); - if (!this._decl.SetDeclaration(this.effect.GetPassInput(technique, pass), 140)) return false; - _core.device.ApplyShadowState(); - _core.device.gl.drawElements(_core.device.gl.TRIANGLES, this._indexBuffer.count, _core.device.gl.UNSIGNED_SHORT, 0); + var rendered = 0; + for (; index < this.items.length; ++index) { + if (this.items[index].display) { + var isActive = this.state === EveTurretSet.State.FIRING && index === this._activeTurret; + if (batch.renderActive === isActive) { + this.geometryResource.RenderAreas(0, 0, 1, this.turretEffect, technique); + rendered++; + } + } } - return true; + + return !!rendered; } + + /** + * Rebuilds the set's items + * + * @param {EveTurretSet} turretSet + */ + }, { - key: 'planes', + key: 'turrets', get: function get() { return this.items; } @@ -38575,21 +38950,177 @@ var EvePlaneSet = exports.EvePlaneSet = function (_EveObjectSet) { set: function set(arr) { this.items = arr; } + }], [{ + key: 'RebuildItems', + value: function RebuildItems(turretSet) { + turretSet._visibleItems = []; + + for (var i = 0; i < turretSet.items.length; i++) { + var item = turretSet.items[i]; + item._onModified = turretSet._onChildModified; + + if (item.display) { + turretSet._visibleItems.push(item); + if (item._rebuildPending) { + item.UpdateTransforms(); + item._rebuildPending = false; + } + } + } + } + + /** + * Updates per object data + * @param {EveTurretSet} turretSet + * @param {Tw2RawData} perObjectData + * @param transforms + * @param {boolean} [skipBoneCalculations] + */ + + }, { + key: 'UpdatePerObjectData', + value: function UpdatePerObjectData(turretSet, perObjectData, transforms, skipBoneCalculations) { + _global.mat4.transpose(perObjectData.Get('shipMatrix'), turretSet.parentMatrix); + var transformCount = transforms.length / 12; + perObjectData.Get('turretSetData')[0] = transformCount; + perObjectData.Get('baseCutoffData')[0] = turretSet.bottomClipHeight; + + var translation = perObjectData.Get('turretTranslation'), + rotation = perObjectData.Get('turretRotation'), + pose = perObjectData.Get('turretPoseTransAndRot'); + + for (var i = 0; i < turretSet._visibleItems.length; ++i) { + var item = turretSet._visibleItems[i]; + + for (var j = 0; j < transformCount; ++j) { + pose[(i * transformCount + j) * 2 * 4] = transforms[j * 12 + 3]; + pose[(i * transformCount + j) * 2 * 4 + 1] = transforms[j * 12 + 7]; + pose[(i * transformCount + j) * 2 * 4 + 2] = transforms[j * 12 + 11]; + pose[(i * transformCount + j) * 2 * 4 + 3] = 1; + EveTurretSet.mat3x4toquat(transforms, j, pose, (i * transformCount + j) * 2 + 1); + } + + if (item.bone && !skipBoneCalculations) { + item.UpdateTransforms(); + } + + translation[i * 4] = item._localTransform[12]; + translation[i * 4 + 1] = item._localTransform[13]; + translation[i * 4 + 2] = item._localTransform[14]; + translation[i * 4 + 3] = 1; + + rotation[i * 4] = item.rotation[0]; + rotation[i * 4 + 1] = item.rotation[1]; + rotation[i * 4 + 2] = item.rotation[2]; + rotation[i * 4 + 3] = item.rotation[3]; + } + } + + /** + * Animation helper function for turret firing + * @param {EveTurretSet} turretSet + * @returns {EveTurretSetItem} the closest turret + */ + + }, { + key: 'DoStartFiring', + value: function DoStartFiring(turretSet) { + if (turretSet.hasCyclingFiringPos) { + turretSet._currentCyclingFiresPos = 1 - turretSet._currentCyclingFiresPos; + } + + if (turretSet.firingEffect) { + turretSet.firingEffect.PrepareFiring(0, turretSet.hasCyclingFiringPos ? turretSet._currentCyclingFiresPos : -1); + } + + turretSet._activeTurret = turretSet.GetClosestTurret(); + turretSet.state = EveTurretSet.State.FIRING; + turretSet._recheckTimeLeft = 2; + + if (turretSet.fireCallback) { + turretSet.fireCallbackPending = true; + } + } }]); - return EvePlaneSet; + return EveTurretSet; }(_EveObjectSet2.EveObjectSet); /** - * The plane set's item constructor - * @type {EvePlaneSetItem} + * mat3x4 to quat */ -EvePlaneSet.Item = EvePlaneSetItem; +EveTurretSet.mat3x4toquat = function () { + var m = void 0, + q = void 0; + + return function mat3x4toquat(mm, index, out, outIndex) { + if (!m) { + m = _global.mat4.create(); + q = _global.quat.create(); + } + + index *= 12; + outIndex *= 4; + + m[0] = mm[index]; + m[1] = mm[index + 4]; + m[2] = mm[index + 8]; + m[3] = 0; + m[4] = mm[index + 1]; + m[5] = mm[index + 5]; + m[6] = mm[index + 9]; + m[7] = 0; + m[8] = mm[index + 2]; + m[9] = mm[index + 6]; + m[10] = mm[index + 10]; + m[11] = 0; + m[12] = mm[index + 3]; + m[13] = mm[index + 7]; + m[14] = mm[index + 11]; + m[15] = 1; + + _global.mat4.getRotation(q, m); + out[outIndex] = q[0]; + out[outIndex + 1] = q[1]; + out[outIndex + 2] = q[2]; + out[outIndex + 3] = q[3]; + }; +}(); + +/** + * The eve turret set's item constructor + * @type {EveTurretSetItem} + */ +EveTurretSet.Item = EveTurretSetItem; + +/** + * Turret states + * @type {{INACTIVE: number, IDLE: number, FIRING: number, PACKING: number, UNPACKING: number}} + */ +EveTurretSet.State = { + INACTIVE: 0, + IDLE: 1, + FIRING: 2, + PACKING: 2, + UNPACKING: 4 +}; + +/** + * World turret bone names + * @type {string[]} + */ +EveTurretSet.worldNames = ['turretWorld0', 'turretWorld1', 'turretWorld2']; + +/** + * Bone Skeleton Names + * @type {string[]} + */ +EveTurretSet.positionBoneSkeletonNames = ['Pos_Fire01', 'Pos_Fire02', 'Pos_Fire03', 'Pos_Fire04', 'Pos_Fire05', 'Pos_Fire06', 'Pos_Fire07', 'Pos_Fire08']; /***/ }), -/* 191 */ +/* 183 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -38598,132 +39129,281 @@ EvePlaneSet.Item = EvePlaneSetItem; Object.defineProperty(exports, "__esModule", { value: true }); -exports.EveSpaceObjectDecal = undefined; +exports.EveSpaceScene = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); var _core = __webpack_require__(1); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** - * EveSpaceObjectDecal + * EveSpaceScene * - * @property {String|number} _id - * @property {String} name + * @property {number|string} _id + * @property {string} name * @property {boolean} display - * @property {Tw2Effect} decalEffect - * @property {Tw2Effect} pickEffect - * @property {Tw2GeometryRes} parentGeometry - * @property {number} parentBoneIndex - * @property {number} groupIndex - * @property {boolean} pickable - * @property {vec3} position - * @property {quat} rotation - * @property {vec3} scaling - * @property {mat4} decalMatrix - * @property {mat4} invDecalMatrix - * @property {Array} indexBuffer - * @property {*} _indexBuffer - * @property {Tw2PerObjectData} _perObjectData + * @property {{}} visible + * @property {boolean} visible.lensflare + * @property {boolean} visible.objects + * @property {boolean} visible.planets + * @property {boolean} visible.fog + * @property {boolean} visible.clearColor + * @property {boolean} visible.nebula + * @property {Array.} lensflares - Scene lensflares + * @property {Array.<*>} objects - Scene objects + * @property {Array.} planets - Scene planets + * @property {number} nebulaIntensity - controls nebula intensity on scene objects + * @property {vec4} ambientColor - unused + * @property {null|Tw2Effect} backgroundEffect + * @property {number} backgroundRenderingEnabled - Toggles background effect visibility + * @property {vec3} endMapScaling - controls the scale of the environment maps + * @property {quat} envMapRotation - controls the rotation of the environment maps + * @property {boolean} logEnabled - toggles LOD + * @property {number} fogStart - fog start distance + * @property {number} fogEnd - fog end distance + * @property {number} fogMax - fog maximum opacity + * @property {number} fogType - fog blend type + * @property {number} fogBlur - fog blur mode + * @property {vec4} fogColor - fog color + * @property {vec3} sunDirection - the direction of the scene sun + * @property {vec4} sunDiffuseColor - the colour of the light from the sun + * @property {String} envMapResPath - nebula reflection map path + * @property {String} envMap1ResPath - nebula diffuse map path + * @property {String} envMap2ResPath - nebular blur map path + * @property {String} envMap3ResPath - unused + * @property {null|Tw2TextureRes} envMapRes + * @property {null|Tw2TextureRes} envMap1Res + * @property {null|Tw2TextureRes} envMap2Res + * @property {null} envMap3Res - unused + * @property {Tw2BatchAccumulator} _batches - Scene batch accumulator + * @property {Tw2RawData} _perFrameVS + * @property {Tw2RawData} _perFramePS + * @property {boolean} renderDebugInfo + * @property {*} _debugHelper * @class */ -var EveSpaceObjectDecal = exports.EveSpaceObjectDecal = function () { - function EveSpaceObjectDecal() { - _classCallCheck(this, EveSpaceObjectDecal); +var EveSpaceScene = exports.EveSpaceScene = function () { + function EveSpaceScene() { + var _this = this; + + _classCallCheck(this, EveSpaceScene); - this._id = _math.util.generateID(); + this._id = _global.util.generateID(); this.name = ''; this.display = true; - this.decalEffect = null; - this.pickEffect = null; - this.parentGeometry = null; - this.parentBoneIndex = -1; - this.groupIndex = -1; - this.pickable = true; - this.position = _math.vec3.create(); - this.rotation = _math.quat.create(); - this.scaling = _math.vec3.create(); - this.decalMatrix = _math.mat4.create(); - this.invDecalMatrix = _math.mat4.create(); - this.indexBuffer = []; - this._indexBuffer = null; + this.visible = {}; + this.visible.lensflares = true; + this.visible.objects = true; + this.visible.planets = true; + this.visible.fog = true; + this.visible.clearColor = true; + this.visible.environmentReflection = true; + this.visible.environmentDiffuse = true; + this.visible.environmentBlur = true; - this._perObjectData = new _core.Tw2PerObjectData(); - this._perObjectData.perObjectVSData = new _core.Tw2RawData(); - this._perObjectData.perObjectVSData.Declare('worldMatrix', 16); - this._perObjectData.perObjectVSData.Declare('invWorldMatrix', 16); - this._perObjectData.perObjectVSData.Declare('decalMatrix', 16); - this._perObjectData.perObjectVSData.Declare('invDecalMatrix', 16); - this._perObjectData.perObjectVSData.Declare('parentBoneMatrix', 16); - this._perObjectData.perObjectVSData.Create(); + Object.defineProperty(this.visible, 'environment', { + get: function get() { + return _this.backgroundRenderingEnabled; + }, + set: function set(bool) { + _this.backgroundRenderingEnabled = bool ? 1 : 0; + } + }); - this._perObjectData.perObjectPSData = new _core.Tw2RawData(); - this._perObjectData.perObjectPSData.Declare('displayData', 4); - this._perObjectData.perObjectPSData.Declare('shipData', 4 * 3); - this._perObjectData.perObjectPSData.Create(); + this.lensflares = []; + this.objects = []; + this.planets = []; + this.nebulaIntensity = 1; + this.ambientColor = _global.quat.fromValues(0.25, 0.25, 0.25, 1); + this.backgroundEffect = null; + this.backgroundRenderingEnabled = 1; + this.clearColor = _global.vec4.fromValues(0, 0, 0, 0); + this.lodEnabled = false; + this.fogStart = 0; + this.fogEnd = 0; + this.fogMax = 0; + this.fogType = 0; + this.fogBlur = 0; + this.fogColor = _global.vec4.fromValues(0.25, 0.25, 0.25, 1); + this.sunDirection = _global.vec3.fromValues(1, -1, 1); + this.sunDiffuseColor = _global.vec4.fromValues(1, 1, 1, 1); + this.envMapScaling = _global.vec3.fromValues(1, 1, 1); + this.envMapRotation = _global.quat.create(); + this.envMapResPath = ''; + this.envMap1ResPath = ''; + this.envMap2ResPath = ''; + this.envMap3ResPath = ''; + this.envMapRes = null; + this.envMap1Res = null; + this.envMap2Res = null; + this.envMap3Res = null; + this.renderDebugInfo = false; + this._debugHelper = null; - _math.mat4.identity(this._perObjectData.perObjectVSData.Get('parentBoneMatrix')); + this._batches = new _core.Tw2BatchAccumulator(); + this._perFrameVS = new _core.Tw2RawData(); + this._perFrameVS.Declare('ViewInverseTransposeMat', 16); + this._perFrameVS.Declare('ViewProjectionMat', 16); + this._perFrameVS.Declare('ViewMat', 16); + this._perFrameVS.Declare('ProjectionMat', 16); + this._perFrameVS.Declare('ShadowViewMat', 16); + this._perFrameVS.Declare('ShadowViewProjectionMat', 16); + this._perFrameVS.Declare('EnvMapRotationMat', 16); + this._perFrameVS.Declare('SunData.DirWorld', 4); + this._perFrameVS.Declare('SunData.DiffuseColor', 4); + this._perFrameVS.Declare('FogFactors', 4); + this._perFrameVS.Declare('TargetResolution', 4); + this._perFrameVS.Declare('ViewportAdjustment', 4); + this._perFrameVS.Declare('MiscSettings', 4); + this._perFrameVS.Create(); + + this._perFramePS = new _core.Tw2RawData(); + this._perFramePS.Declare('ViewInverseTransposeMat', 16); + this._perFramePS.Declare('ViewMat', 16); + this._perFramePS.Declare('EnvMapRotationMat', 16); + this._perFramePS.Declare('SunData.DirWorld', 4); + this._perFramePS.Declare('SunData.DiffuseColor', 4); + this._perFramePS.Declare('SceneData.AmbientColor', 3); + this._perFramePS.Declare('SceneData.NebulaIntensity', 1); + this._perFramePS.Declare('SceneData.FogColor', 4); + this._perFramePS.Declare('ViewportOffset', 2); + this._perFramePS.Declare('ViewportSize', 2); + this._perFramePS.Declare('TargetResolution', 4); + this._perFramePS.Declare('ShadowMapSettings', 4); + this._perFramePS.Declare('ShadowCameraRange', 4); + this._perFramePS.Declare('ProjectionToView', 2); + this._perFramePS.Declare('FovXY', 2); + this._perFramePS.Declare('MiscSettings', 4); + this._perFramePS.Create(); + + EveSpaceScene.init(); } - /** - * Initializes the decal - */ + /** + * Initializes the space scene + */ + + + _createClass(EveSpaceScene, [{ + key: 'Initialize', + value: function Initialize() { + this.SetEnvMapPath(0, this.envMapResPath); + this.SetEnvMapPath(1, this.envMap1ResPath); + this.SetEnvMapPath(2, this.envMap2ResPath); + this.SetEnvMapPath(3, this.envMap3ResPath); + } + + /** + * Sets the environment's reflection map + * @param {String} path + */ + + }, { + key: 'SetEnvMapReflection', + value: function SetEnvMapReflection(path) { + this.SetEnvMapPath(0, path); + } + + /** + * Sets the environment's diffuse map + * @param {string} path + */ + + }, { + key: 'SetEnvMapDiffuse', + value: function SetEnvMapDiffuse(path) { + this.SetEnvMapPath(1, path); + } + /** + * Sets the environment's blur map (used for fog) + * @param {string} path + */ - _createClass(EveSpaceObjectDecal, [{ - key: 'Initialize', - value: function Initialize() { - this.SetIndexBuffer(this.indexBuffer); + }, { + key: 'SetEnvMapBlur', + value: function SetEnvMapBlur(path) { + this.SetEnvMapPath(2, path); } /** - * Fire on value changes + * Sets an environment map + * @param {number} index + * @param {String} path */ }, { - key: 'OnValueChanged', - value: function OnValueChanged() { - if (!this._indexBuffer && this.indexBuffer) { - var indexes = new Uint16Array(this.indexBuffer); - this._indexBuffer = _core.device.gl.createBuffer(); - _core.device.gl.bindBuffer(_core.device.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - _core.device.gl.bufferData(_core.device.gl.ELEMENT_ARRAY_BUFFER, indexes, _core.device.gl.STATIC_DRAW); + key: 'SetEnvMapPath', + value: function SetEnvMapPath(index, path) { + var _this2 = this; + + var _setEnvPath = function _setEnvPath(path, pathTarget, resTarget) { + path = path.toLowerCase(); + _this2[pathTarget] = path; + _this2[resTarget] = path === '' ? null : _global.resMan.GetResource(path); + return true; + }; + + switch (index) { + case 0: + // Reflection + return _setEnvPath(path, 'envMapResPath', 'envMapRes'); + + case 1: + // Diffuse + return _setEnvPath(path, 'envMap1ResPath', 'envMap1Res'); + + case 2: + // Blur + return _setEnvPath(path, 'envMap2ResPath', 'envMap2Res'); + + case 3: + // Unused + return _setEnvPath(path, 'envMap3ResPath', 'envMap3Res'); } - _math.mat4.fromRotationTranslationScale(this.decalMatrix, this.rotation, this.position, this.scaling); - _math.mat4.invert(this.invDecalMatrix, this.decalMatrix); + return false; } /** - * Sets the parent geometry - * @param {Tw2GeometryRes} geometryRes + * Enables LOD + * @param {boolean} enable */ }, { - key: 'SetParentGeometry', - value: function SetParentGeometry(geometryRes) { - this.parentGeometry = geometryRes; + key: 'EnableLod', + value: function EnableLod(enable) { + this.lodEnabled = enable; + + if (!enable) { + for (var i = 0; i < this.objects.length; ++i) { + if (this.objects[i].ResetLod) { + this.objects[i].ResetLod(); + } + } + } } /** - * Sets the decal's index buffer - * @param {number[]} indices + * Keeps the scene and it's object's resources alive */ }, { - key: 'SetIndexBuffer', - value: function SetIndexBuffer(indices) { - this.indexBuffer = indices; - this.Unload(); - this.OnValueChanged(); + key: 'KeepAlive', + value: function KeepAlive() { + var res = this.GetResources(); + for (var i = 0; i < res.length; i++) { + res[i].KeepAlive(); + } } /** - * Gets decal resources + * Gets scene's resources * @param {Array} [out=[]] - Optional receiving array + * @param {boolean} [excludeChildren] * @returns {Array.} [out] */ @@ -38731,1169 +39411,1467 @@ var EveSpaceObjectDecal = exports.EveSpaceObjectDecal = function () { key: 'GetResources', value: function GetResources() { var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + var excludeChildren = arguments[1]; - if (this.parentGeometry && !out.includes(this.parentGeometry)) { - out.push(this.parentGeometry); + for (var i = 0; i < this.lensflares.length; i++) { + this.lensflares[i].GetResources(out); + } + + if (this.backgroundEffect) { + this.backgroundEffect.GetResources(out); + } + + if (this.envMapRes && !out.includes(this.envMapRes)) out.push(this.envMapRes); + if (this.envMap1Res && !out.includes(this.envMap1Res)) out.push(this.envMapRes); + if (this.envMap2Res && !out.includes(this.envMap2Res)) out.push(this.envMapRes); + if (this.envMap3Res && !out.includes(this.envMap3Res)) out.push(this.envMapRes); + + if (!excludeChildren) { + for (var _i = 0; _i < this.planets.length; _i++) { + this.planets[_i].GetResources(out); + } + + for (var _i2 = 0; _i2 < this.objects.length; _i2++) { + if ('GetResources' in this.objects[_i2]) { + this.objects[_i2].GetResources(out); + } + } } - if (this.decalEffect) this.decalEffect.GetResources(out); - if (this.pickEffect) this.pickEffect.GetResources(out); return out; } /** - * Unloads the decal's buffers + * Per frame update that is called per frame + * @param {number} dt - delta time */ }, { - key: 'Unload', - value: function Unload() { - if (this._indexBuffer) { - _core.device.gl.deleteBuffer(this._indexBuffer); - this._indexBuffer = null; + key: 'Update', + value: function Update(dt) { + for (var i = 0; i < this.planets.length; ++i) { + if ('Update' in this.planets[i]) { + this.planets[i].Update(dt); + } + } + + for (var _i3 = 0; _i3 < this.objects.length; ++_i3) { + if ('Update' in this.objects[_i3]) { + this.objects[_i3].Update(dt); + } } } /** * Gets batches for rendering * @param {number} mode + * @param {Array.} objectArray * @param {Tw2BatchAccumulator} accumulator - * @param {Tw2PerObjectData} perObjectData - * @param {number} [counter=0] */ }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator, perObjectData, counter) { - var effect = void 0; - switch (mode) { - case _core.device.RM_DECAL: - effect = this.decalEffect; - break; - - case _core.device.RM_PICKABLE: - effect = this.pickable ? this.pickEffect : null; - break; - } - - if (this.display && effect && effect.IsGood() && this.indexBuffer.length && this.parentGeometry && this.parentGeometry.IsGood()) { - var batch = new _core.Tw2ForwardingRenderBatch(); - this._perObjectData.perObjectVSData.Set('worldMatrix', perObjectData.perObjectVSData.Get('WorldMat')); - if (this.parentBoneIndex >= 0) { - var bones = perObjectData.perObjectVSData.Get('JointMat'), - offset = this.parentBoneIndex * 12; + key: 'RenderBatches', + value: function RenderBatches(mode, objectArray) { + var accumulator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this._batches; - if (bones[offset] || bones[offset + 4] || bones[offset + 8]) { - var bone = this._perObjectData.perObjectVSData.Get('parentBoneMatrix'); - bone[0] = bones[offset]; - bone[1] = bones[offset + 4]; - bone[2] = bones[offset + 8]; - bone[3] = 0; - bone[4] = bones[offset + 1]; - bone[5] = bones[offset + 5]; - bone[6] = bones[offset + 9]; - bone[7] = 0; - bone[8] = bones[offset + 2]; - bone[9] = bones[offset + 6]; - bone[10] = bones[offset + 10]; - bone[11] = 0; - bone[12] = bones[offset + 3]; - bone[13] = bones[offset + 7]; - bone[14] = bones[offset + 11]; - bone[15] = 1; - _math.mat4.transpose(bone, bone); - } + for (var i = 0; i < objectArray.length; ++i) { + if ('GetBatches' in objectArray[i]) { + objectArray[i].GetBatches(mode, accumulator); } - - _math.mat4.invert(this._perObjectData.perObjectVSData.Get('invWorldMatrix'), this._perObjectData.perObjectVSData.Get('worldMatrix')); - _math.mat4.transpose(this._perObjectData.perObjectVSData.Get('decalMatrix'), this.decalMatrix); - _math.mat4.transpose(this._perObjectData.perObjectVSData.Get('invDecalMatrix'), this.invDecalMatrix); - - this._perObjectData.perObjectPSData.Get('displayData')[0] = counter || 0; - this._perObjectData.perObjectPSData.Set('shipData', perObjectData.perObjectPSData.data); - - batch.perObjectData = this._perObjectData; - batch.geometryProvider = this; - batch.renderMode = mode; - batch.effect = effect; - accumulator.Commit(batch); } } /** - * Renders the decal - * @param {Tw2ForwardingRenderBatch} batch - * @param {string} technique - technique name + * Updates children's view dependent data and renders them */ }, { key: 'Render', - value: function Render(batch, technique) { - var bkIB = this.parentGeometry.meshes[0].indexes, - bkStart = this.parentGeometry.meshes[0].areas[0].start, - bkCount = this.parentGeometry.meshes[0].areas[0].count, - bkIndexType = this.parentGeometry.meshes[0].indexType; - - _core.store.SetVariableValue('u_DecalMatrix', this.decalMatrix); - _core.store.SetVariableValue('u_InvDecalMatrix', this.invDecalMatrix); - - this.parentGeometry.meshes[0].indexes = this._indexBuffer; - this.parentGeometry.meshes[0].areas[0].start = 0; - this.parentGeometry.meshes[0].areas[0].count = this.indexBuffer.length; - this.parentGeometry.meshes[0].indexType = _core.device.gl.UNSIGNED_SHORT; - - this.parentGeometry.RenderAreas(0, 0, 1, batch.effect, technique); - this.parentGeometry.meshes[0].indexes = bkIB; - this.parentGeometry.meshes[0].areas[0].start = bkStart; - this.parentGeometry.meshes[0].areas[0].count = bkCount; - this.parentGeometry.meshes[0].indexType = bkIndexType; - } - }]); - - return EveSpaceObjectDecal; -}(); + value: function Render() { + this.ApplyPerFrameData(); -/***/ }), -/* 192 */ -/***/ (function(module, exports, __webpack_require__) { + var d = _global.device, + g = EveSpaceScene.global, + id = _global.mat4.identity(g.mat4_ID), + show = this.visible; -"use strict"; + if (show['environment'] && this.backgroundEffect) { + d.SetStandardStates(d.RM_FULLSCREEN); + d.RenderCameraSpaceQuad(this.backgroundEffect); + } + if (show.planets && this.planets.length) { + var tempProj = _global.mat4.copy(g.mat4_0, d.projection), + newProj = _global.mat4.copy(g.mat4_1, d.projection), + zn = 10000, + zf = 1e11; -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.EveSpotlightSet = exports.EveSpotlightSetItem = exports.EveSpotlightSetBatch = undefined; + newProj[10] = zf / (zn - zf); + newProj[14] = zf * zn / (zn - zf); + d.SetProjection(newProj, true); + this.ApplyPerFrameData(); -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + for (var i = 0; i < this.planets.length; ++i) { + if (this.planets[i].UpdateViewDependentData) { + this.planets[i].UpdateViewDependentData(id); + } + } -var _math = __webpack_require__(0); + this._batches.Clear(); + d.gl.depthRange(0.9, 1); + this.RenderBatches(d.RM_OPAQUE, this.planets); + this.RenderBatches(d.RM_DECAL, this.planets); + this.RenderBatches(d.RM_TRANSPARENT, this.planets); + this.RenderBatches(d.RM_ADDITIVE, this.planets); + this._batches.Render(); + d.SetProjection(tempProj, true); + this.ApplyPerFrameData(); + d.gl.depthRange(0, 0.9); + } -var _core = __webpack_require__(1); + if (this.lodEnabled) { + g.frustum.Initialize(d.view, d.projection, d.viewportWidth, d.viewInverse, d.viewProjection); + for (var _i4 = 0; _i4 < this.objects.length; ++_i4) { + if (this.objects[_i4].UpdateLod) { + this.objects[_i4].UpdateLod(g.frustum); + } + } + } -var _EveObjectSet2 = __webpack_require__(10); + if (show.objects) { + for (var _i5 = 0; _i5 < this.objects.length; ++_i5) { + if (this.objects[_i5].UpdateViewDependentData) { + this.objects[_i5].UpdateViewDependentData(id); + } + } + } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + if (show.lensflares) { + for (var _i6 = 0; _i6 < this.lensflares.length; ++_i6) { + this.lensflares[_i6].PrepareRender(); + } + } -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + this._batches.Clear(); -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + if (show.planets) { + for (var _i7 = 0; _i7 < this.planets.length; ++_i7) { + this.planets[_i7].GetZOnlyBatches(d.RM_OPAQUE, this._batches); + } + } -/** - * EveSpotlightSetBatch - * - * @property {EveSpotlightSet} spotlightSet - * @class - */ -var EveSpotlightSetBatch = exports.EveSpotlightSetBatch = function (_Tw2RenderBatch) { - _inherits(EveSpotlightSetBatch, _Tw2RenderBatch); + if (show.objects) { + this.RenderBatches(d.RM_OPAQUE, this.objects); + this.RenderBatches(d.RM_DECAL, this.objects); + this.RenderBatches(d.RM_TRANSPARENT, this.objects); + this.RenderBatches(d.RM_ADDITIVE, this.objects); + } - function EveSpotlightSetBatch() { - _classCallCheck(this, EveSpotlightSetBatch); + if (show.lensflares) { + for (var _i8 = 0; _i8 < this.lensflares.length; ++_i8) { + this.lensflares[_i8].GetBatches(d.RM_ADDITIVE, this._batches); + } + } - var _this = _possibleConstructorReturn(this, (EveSpotlightSetBatch.__proto__ || Object.getPrototypeOf(EveSpotlightSetBatch)).call(this)); + this._batches.Render(); - _this.spotlightSet = null; - return _this; - } + if (show.lensflares) { + for (var _i9 = 0; _i9 < this.lensflares.length; ++_i9) { + this.lensflares[_i9].UpdateOccluders(); + } + } - /** - * Commits the spotlight set for rendering - * @param {string} technique - technique name - */ + if (this.renderDebugInfo) { + if (EveSpaceScene.DebugRenderer) { + if (!this._debugHelper) { + this._debugHelper = new EveSpaceScene.DebugRenderer(); + } + for (var _i10 = 0; _i10 < this.objects.length; ++_i10) { + if (this.objects[_i10].RenderDebugInfo) { + this.objects[_i10].RenderDebugInfo(this._debugHelper); + } + } - _createClass(EveSpotlightSetBatch, [{ - key: 'Commit', - value: function Commit(technique) { - this.spotlightSet.RenderCones(technique); - this.spotlightSet.RenderGlow(technique); + this._debugHelper.Render(); + } + } } - }]); - return EveSpotlightSetBatch; -}(_core.Tw2RenderBatch); - -/** - * Spotlight Item - * - * @property {mat4} transform - The spotlight's transform - * @property {vec4} coneColor - Colour of the spotlight's cone - * @property {vec4} spriteColor - Colour of the spotlight's sprite texture - * @property {vec4} flareColor - Colour of the spotlight's flare - * @property {vec4} spriteScale - The size of the spotlight - * @property {number} boosterGainInfluence - If true, the spotlight can change size on booster gain - * @property {number} boneIndex - The spotlight's bone index - * @property {number} groupIndex - The sof faction group that the spotlight belongs to - * @property {number} coneIntensity - Scales the spotlight's cone colour, set by an object's sof Faction - * @property {number} spriteIntensity - Scales the spotlight's sprite colour, set by an object's sof Faction - * @property {number} flareIntensity - Scales the spotlight's flare colour, set by an object's sof Faction - * @class - */ + /** + * Applies per frame data + */ + }, { + key: 'ApplyPerFrameData', + value: function ApplyPerFrameData() { + var d = _global.device, + g = EveSpaceScene.global, + envMapTransform = g.mat4_2, + sunDir = g.vec3_0, + show = this.visible; -var EveSpotlightSetItem = exports.EveSpotlightSetItem = function (_EveObjectSetItem) { - _inherits(EveSpotlightSetItem, _EveObjectSetItem); + _global.mat4.fromQuat(envMapTransform, this.envMapRotation); + _global.mat4.scale(envMapTransform, envMapTransform, this.envMapScaling); + _global.mat4.transpose(envMapTransform, envMapTransform); + _global.vec3.negate(sunDir, this.sunDirection); + _global.vec3.normalize(sunDir, sunDir); - function EveSpotlightSetItem() { - _classCallCheck(this, EveSpotlightSetItem); + var distance = this.fogEnd - this.fogStart; + if (Math.abs(distance) < 1e-5) distance = 1e-5; + var f = 1.0 / distance; - var _this2 = _possibleConstructorReturn(this, (EveSpotlightSetItem.__proto__ || Object.getPrototypeOf(EveSpotlightSetItem)).call(this)); + var VSData = this._perFrameVS; + VSData.Set('FogFactors', [this.fogEnd * f, f, this.visible.fog ? this.fogMax : 0, 1]); + VSData.Set('ViewportAdjustment', [1, 1, 1, 1]); + VSData.Set('MiscSettings', [d.currentTime, 0, d.viewportWidth, d.viewportHeight]); + VSData.Set('SunData.DirWorld', sunDir); + VSData.Set('SunData.DiffuseColor', this.sunDiffuseColor); + VSData.Set('TargetResolution', d.targetResolution); + VSData.Set('ViewInverseTransposeMat', d.viewInverse); + VSData.Set('ViewProjectionMat', d.viewProjectionTranspose); + VSData.Set('ViewMat', d.viewTranspose); + VSData.Set('ProjectionMat', d.projectionTranspose); + VSData.Set('EnvMapRotationMat', envMapTransform); + d.perFrameVSData = VSData; - _this2.transform = _math.mat4.create(); - _this2.coneColor = _math.vec4.create(); - _this2.spriteColor = _math.vec4.create(); - _this2.flareColor = _math.vec4.create(); - _this2.spriteScale = _math.vec3.fromValues(1, 1, 1); - _this2.boosterGainInfluence = 0; - _this2.boneIndex = 0; - _this2.groupIndex = -1; - _this2.coneIntensity = 0; - _this2.spriteIntensity = 0; - _this2.flareIntensity = 0; - return _this2; - } + var PSData = this._perFramePS; + PSData.Set('ViewInverseTransposeMat', d.viewInverse); + PSData.Set('ViewMat', d.viewTranspose); + PSData.Set('EnvMapRotationMat', envMapTransform); + PSData.Set('SunData.DirWorld', sunDir); + PSData.Set('SunData.DiffuseColor', this.sunDiffuseColor); + PSData.Set('SceneData.AmbientColor', this.ambientColor); + PSData.Set('MiscSettings', [d.currentTime, this.fogType, this.fogBlur, 1]); + PSData.Set('SceneData.FogColor', this.fogColor); + PSData.Set('FovXY', [d.targetResolution[3], d.targetResolution[2]]); + PSData.Set('ShadowMapSettings', [1, 1, 0, 0]); + PSData.Set('TargetResolution', d.targetResolution); + PSData.Get('SceneData.NebulaIntensity')[0] = this.nebulaIntensity; + PSData.Get('ViewportSize')[0] = d.viewportWidth; + PSData.Get('ViewportSize')[1] = d.viewportHeight; + PSData.Get('ShadowCameraRange')[0] = 1; + PSData.Get('ProjectionToView')[0] = -d.projection[14]; + PSData.Get('ProjectionToView')[1] = -d.projection[10] - 1; + d.perFramePSData = PSData; - /** - * Creates a spotlight set item from an object - * @param {*} [opt={} - * @returns {EveSpotlightSetItem} - */ + var envMap = this.envMapRes && show.environmentReflection ? this.envMapRes : g.emptyTexture, + envMap1 = this.envMap1Res && show.environmentDiffuse ? this.envMap1Res : g.emptyTexture, + envMap2 = this.envMap2Res && show.environmentBlur ? this.envMap2Res : g.emptyTexture, + envMap3 = this.envMap3Res ? this.envMap3Res : g.emptyTexture; + _global.store.GetVariable('EveSpaceSceneEnvMap').SetTextureRes(envMap); + _global.store.GetVariable('EnvMap1').SetTextureRes(envMap1); + _global.store.GetVariable('EnvMap2').SetTextureRes(envMap2); + _global.store.GetVariable('EnvMap3').SetTextureRes(envMap3); + } - _createClass(EveSpotlightSetItem, null, [{ - key: 'create', - value: function create() { - var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + /** + * Initializes class global and scratch variables + */ - var item = new this(); - _math.util.assignIfExists(item, opt, ['name', 'display', 'boosterGainInfluence', 'boneIndex', 'groupIndex', 'coneIntensity', 'spriteIntensity', 'flareIntensity', 'transform', 'coneColor', 'spriteColor', 'flareColor', 'spriteScale']); - return item; + }], [{ + key: 'init', + value: function init() { + if (!EveSpaceScene.global) { + EveSpaceScene.global = { + vec3_0: _global.vec3.create(), + vec4_0: _global.vec4.create(), + mat4_0: _global.mat4.create(), + mat4_1: _global.mat4.create(), + mat4_2: _global.mat4.create(), + mat4_ID: _global.mat4.create(), + frustum: new _core.Tw2Frustum(), + emptyTexture: _global.resMan.GetResource('res:/texture/global/black.dds.0.png') + }; + } } }]); - return EveSpotlightSetItem; -}(_EveObjectSet2.EveObjectSetItem); + return EveSpaceScene; +}(); /** - * EveSpotlightSet - * - * @property {string} name - The spotlight set's name - * @property {boolean} display - controls the visibility of the spotlight set, and all it's children - * @property {Tw2Effect} coneEffect - The spotlight set's cone effect - * @property {Tw2Effect} glowEffect - The spotlight set's glow effect - * @property {Array.} [out] - */ - value: function GetResources() { - var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; +var _item = __webpack_require__(64); - if (this.coneEffect) { - this.coneEffect.GetResources(out); - } +var _child = __webpack_require__(59); - if (this.glowEffect) { - this.glowEffect.GetResources(out); - } +var _object = __webpack_require__(61); - return out; +function EveSOF() { + var data = null; + var spriteEffect = null; + + function _get(obj, property, defaultValue) { + if (property in obj) { + return obj[property]; } + return defaultValue; + } - /** - * Unloads the spotlight set's buffers - */ + /** + * @return {string} + */ + function GetShaderPrefix(isAnimated) { + return isAnimated ? _get(data['generic'], 'shaderPrefixAnimated', '') : _get(data['generic'], 'shaderPrefix', ''); + } - }, { - key: 'Unload', - value: function Unload() { - if (this._coneVertexBuffer) { - _core.device.gl.deleteBuffer(this._coneVertexBuffer); - this._coneVertexBuffer = null; + function ModifyTextureResPath(path, name, area, faction, commands) { + var pathInsert = null; + if (_get(faction, 'resPathInsert', '').length) { + pathInsert = faction.resPathInsert; + } + if ('respathinsert' in commands && commands.respathinsert.length === 1) { + if (commands.respathinsert[0] === 'none') { + return path; + } else { + pathInsert = commands.respathinsert[0]; } - - if (this._spriteVertexBuffer) { - _core.device.gl.deleteBuffer(this._spriteVertexBuffer); - this._spriteVertexBuffer = null; + } + if (name === 'MaterialMap' || name === 'PaintMaskMap' || name === 'PmdgMap') { + var index = path.lastIndexOf('/'); + var pathCopy = path; + if (index >= 0) { + pathCopy = path.substr(0, index + 1) + pathInsert + '/' + path.substr(index + 1); } - - if (this._indexBuffer) { - _core.device.gl.deleteBuffer(this._indexBuffer); - this._indexBuffer = null; + index = pathCopy.lastIndexOf('_'); + if (index >= 0) { + pathCopy = pathCopy.substr(0, index) + '_' + pathInsert + pathCopy.substr(index); + var textureOverrides = _get(area, 'textureOverrides', {}); + if (name in textureOverrides && faction.name in textureOverrides[name]) { + return pathCopy; + } } } + return path; + } - /** - * Rebuilds the spotlight set's buffers - */ + /** + * @return {string} + */ + function ModifyShaderPath(shader, isSkinned) { + var prefix = GetShaderPrefix(isSkinned); + shader = '/' + shader; + var index = shader.lastIndexOf('/'); + return shader.substr(0, index + 1) + prefix + shader.substr(index + 1); + } - }, { - key: 'Rebuild', - value: function Rebuild() { - this.Unload(); - EveSpotlightSet.RebuildItems(this); - this._rebuildPending = false; - var itemCount = this._visibleItems.length; - if (!itemCount) return; + function FindPrefix(prefixes, name) { + for (var m = 0; m < prefixes.length; ++m) { + if (name.substr(0, prefixes[m].length) === prefixes[m]) { + return m; + } + } + return null; + } - var d = _core.device, - vertCount = 4, - coneQuadCount = 4, - coneVertexCount = itemCount * coneQuadCount * vertCount, - vertexSize = 22, - coneIndices = [1, 0, 2, 3], - coneArray = new Float32Array(coneVertexCount * vertexSize); + function GetOverridenParameter(name, area, commands, race) { + var prefixes, materialIndex, materialData, shortName; + if ('mesh' in commands) { + prefixes = data.generic.materialPrefixes; + materialIndex = FindPrefix(prefixes, name); + if (materialIndex !== null && materialIndex < commands.mesh.length && (_get(area, 'blockedMaterials', 0) & 1 << materialIndex) === 0) { + materialData = _get(data.material, commands.mesh[materialIndex], null); + if (materialData) { + shortName = name.substr(prefixes[materialIndex].length); + return _get(materialData.parameters, shortName, undefined); + } + } + } + prefixes = data.generic.patternMaterialPrefixes; + materialIndex = FindPrefix(prefixes, name); + if ('pattern' in commands) { + if (materialIndex !== null && 1 + materialIndex < commands.pattern.length) { + materialData = _get(data.material, commands.pattern[1 + materialIndex], null); + if (materialData) { + shortName = name.substr(prefixes[materialIndex].length); + return _get(materialData.parameters, shortName, undefined); + } + } + } - for (var i = 0; i < itemCount; ++i) { - var item = this._visibleItems[i]; - for (var q = 0; q < coneQuadCount; ++q) { - for (var v = 0; v < vertCount; ++v) { - var offset = (i * coneQuadCount * vertCount + vertCount * q + v) * vertexSize; - coneArray[offset] = item.coneColor[0] * item.coneIntensity; - coneArray[offset + 1] = item.coneColor[1] * item.coneIntensity; - coneArray[offset + 2] = item.coneColor[2] * item.coneIntensity; - coneArray[offset + 3] = item.coneColor[3]; + if (materialIndex !== null) { + materialData = _get(data.material, race.defaultPatternLayer1MaterialName, null); + if (materialData) { + shortName = name.substr(prefixes[materialIndex].length); + return _get(materialData.parameters, shortName, undefined); + } + } + } - coneArray[offset + 4] = item.transform[0]; - coneArray[offset + 5] = item.transform[4]; - coneArray[offset + 6] = item.transform[8]; - coneArray[offset + 7] = item.transform[12]; + function GetAddressMode(projectionType) { + switch (projectionType) { + case 2: + return 4; + case 1: + return 3; + default: + return 1; + } + } - coneArray[offset + 8] = item.transform[1]; - coneArray[offset + 9] = item.transform[5]; - coneArray[offset + 10] = item.transform[9]; - coneArray[offset + 11] = item.transform[13]; + function FillMeshAreas(areas, areasName, hull, faction, race, pattern, commands, shaderOverride) { + var hullAreas = _get(hull, areasName, []); + for (var i = 0; i < hullAreas.length; ++i) { + var area = hullAreas[i]; + var effect = new _core.Tw2Effect(); + effect.effectFilePath = data['generic']['areaShaderLocation'] + ModifyShaderPath(shaderOverride ? shaderOverride : area.shader, hull['isSkinned']); + var names = _get(_get(data['generic']['areaShaders'], area.shader, {}), 'parameters', []); + for (var j = 0; j < names.length; ++j) { + var name = names[j]; + var param = GetOverridenParameter(name, area, commands, race); + param = param || _get(_get(_get(data.generic.hullAreas, area.name, {}), 'parameters', {}), name); + param = param || _get(_get(_get(race.hullAreas, area.name, {}), 'parameters', {}), name); + param = param || _get(_get(_get(faction.areas, area.name, {}), 'parameters', {}), name); + param = param || _get(_get(area, 'parameters', {}), name); + if (param) { + effect.parameters[name] = new _core.Tw2Vector4Parameter(name, param); + } + } - coneArray[offset + 12] = item.transform[2]; - coneArray[offset + 13] = item.transform[6]; - coneArray[offset + 14] = item.transform[10]; - coneArray[offset + 15] = item.transform[14]; + var hullTextures = _get(area, 'textures', []); + for (j in hullTextures) { + if (hullTextures.hasOwnProperty(j)) { + var path = hullTextures[j]; + path = ModifyTextureResPath(path, j, area, faction, commands); + effect.parameters[j] = new _core.Tw2TextureParameter(j, path); + } + } - coneArray[offset + 16] = 1; - coneArray[offset + 17] = 1; - coneArray[offset + 18] = 1; + for (j = 0; j < pattern.layers.length; ++j) { + if (pattern.layers[j] && !(pattern.layers[j].textureName in effect.parameters)) { + var patternTex = new _core.Tw2TextureParameter(pattern.layers[j].textureName); + patternTex.resourcePath = pattern.layers[j].textureResFilePath; + patternTex.useAllOverrides = true; + patternTex.addressUMode = GetAddressMode(_get(pattern.layers[j], 'projectionTypeU', 0)); + patternTex.addressVMode = GetAddressMode(_get(pattern.layers[j], 'projectionTypeV', 0)); + patternTex.Initialize(); + effect.parameters[pattern.layers[j].textureName] = patternTex; + } + } - coneArray[offset + 19] = q * vertCount + coneIndices[v]; - coneArray[offset + 20] = item.boneIndex; - coneArray[offset + 21] = item.boosterGainInfluence ? 255 : 0; + var defaultTextures = _get(_get(data['generic']['areaShaders'], area.shader, {}), 'defaultTextures', {}); + for (var texName in defaultTextures) { + if (defaultTextures.hasOwnProperty(texName)) { + if (!(texName in effect.parameters)) { + effect.parameters[texName] = new _core.Tw2TextureParameter(texName, defaultTextures[texName]); } } } - this._coneVertexBuffer = d.gl.createBuffer(); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._coneVertexBuffer); - d.gl.bufferData(d.gl.ARRAY_BUFFER, coneArray, d.gl.STATIC_DRAW); - this._coneVertexBuffer.count = itemCount * coneQuadCount * 6; - - var spriteQuadCount = 2, - spriteVertexCount = itemCount * spriteQuadCount * vertCount, - spriteArray = new Float32Array(spriteVertexCount * vertexSize), - spriteIndexes = [1, 0, 2, 3]; - - for (var _i = 0; _i < itemCount; ++_i) { - var _item = this._visibleItems[_i]; - for (var _q = 0; _q < spriteQuadCount; ++_q) { - for (var _v = 0; _v < vertCount; ++_v) { - var _offset = (_i * spriteQuadCount * vertCount + vertCount * _q + _v) * vertexSize; - if (_q % 2 === 0) { - spriteArray[_offset] = _item.spriteColor[0] * _item.spriteIntensity; - spriteArray[_offset + 1] = _item.spriteColor[1] * _item.spriteIntensity; - spriteArray[_offset + 2] = _item.spriteColor[2] * _item.spriteIntensity; - spriteArray[_offset + 3] = _item.spriteColor[3]; - - spriteArray[_offset + 16] = _item.spriteScale[0]; - spriteArray[_offset + 17] = 1; - spriteArray[_offset + 18] = 1; - } else { - spriteArray[_offset] = _item.flareColor[0] * _item.flareIntensity; - spriteArray[_offset + 1] = _item.flareColor[1] * _item.flareIntensity; - spriteArray[_offset + 2] = _item.flareColor[2] * _item.flareIntensity; - spriteArray[_offset + 3] = _item.flareColor[3]; + effect.Initialize(); - spriteArray[_offset + 16] = 1; - spriteArray[_offset + 17] = _item.spriteScale[1]; - spriteArray[_offset + 18] = _item.spriteScale[2]; - } + var newArea = new _core.Tw2MeshArea(); + newArea.name = area.name; + newArea.effect = effect; + newArea.index = _get(area, 'index', 0); + newArea.count = _get(area, 'count', 1); + areas.push(newArea); + } + } - spriteArray[_offset + 4] = _item.transform[0]; - spriteArray[_offset + 5] = _item.transform[4]; - spriteArray[_offset + 6] = _item.transform[8]; - spriteArray[_offset + 7] = _item.transform[12]; + function SetupMesh(ship, hull, faction, race, commands, pattern) { + var mesh = new _core.Tw2Mesh(); + mesh.geometryResPath = hull['geometryResFilePath']; + ship.boundingSphereCenter[0] = hull.boundingSphere[0]; + ship.boundingSphereCenter[1] = hull.boundingSphere[1]; + ship.boundingSphereCenter[2] = hull.boundingSphere[2]; + ship.boundingSphereRadius = hull.boundingSphere[3]; + FillMeshAreas(_get(mesh, 'opaqueAreas', []), 'opaqueAreas', hull, faction, race, pattern, commands); + FillMeshAreas(_get(mesh, 'transparentAreas', []), 'transparentAreas', hull, faction, race, pattern, commands); + FillMeshAreas(_get(mesh, 'additiveAreas', []), 'additiveAreas', hull, faction, race, pattern, commands); + FillMeshAreas(_get(mesh, 'decalAreas', []), 'decalAreas', hull, faction, race, pattern, commands); + FillMeshAreas(_get(mesh, 'depthAreas', []), 'depthAreas', hull, faction, race, pattern, commands); + mesh.Initialize(); + ship.mesh = mesh; + if ('shapeEllipsoidCenter' in hull) { + ship.shapeEllipsoidCenter = hull.shapeEllipsoidCenter; + } + if ('shapeEllipsoidRadius' in hull) { + ship.shapeEllipsoidRadius = hull.shapeEllipsoidRadius; + } + } - spriteArray[_offset + 8] = _item.transform[1]; - spriteArray[_offset + 9] = _item.transform[5]; - spriteArray[_offset + 10] = _item.transform[9]; - spriteArray[_offset + 11] = _item.transform[13]; + function SetupPattern(hull, race, commands) { + var pattern = { + patterns: [], + layers: [] + }; + if ('pattern' in commands) { + var p = {}; + for (var k = 0; k < data.pattern.length; ++k) { + if (data.pattern[k].name === commands.pattern[0]) { + p = data.pattern[k]; + break; + } + } + var layer = _get(p, 'layer1', null); + if (layer) { + pattern.layers.push(layer); + } + layer = _get(p, 'layer2', null); + if (layer) { + pattern.layers.push(layer); + } + var projections = _get(p, 'projections', []); + for (var i = 0; i < projections.length; ++i) { + if (projections[i].name === hull.name) { + p = projections[i]; + layer = _get(p, 'transformLayer1', null); + if (layer) { + pattern.patterns.push(layer); + } + layer = _get(p, 'transformLayer2', null); + if (layer) { + pattern.patterns.push(layer); + } + } + } + } else if (_get(hull, 'defaultPattern')) { + p = _get(hull, 'defaultPattern', {}); + layer = _get(p, 'transformLayer1', null); + if (layer) { + pattern.patterns.push(layer); + } + layer = _get(p, 'transformLayer2', null); + if (layer) { + pattern.patterns.push(layer); + } + p = _get(race, 'defaultPattern', {}); + layer = _get(p, 'layer1', null); + if (layer) { + pattern.layers.push(layer); + } + layer = _get(p, 'layer2', null); + if (layer) { + pattern.layers.push(layer); + } + } + return pattern; + } - spriteArray[_offset + 12] = _item.transform[2]; - spriteArray[_offset + 13] = _item.transform[6]; - spriteArray[_offset + 14] = _item.transform[10]; - spriteArray[_offset + 15] = _item.transform[14]; + function SetupCustomMasks(ship, pattern) { + for (var i = 0; i < pattern.patterns.length; ++i) { + if (pattern.patterns[i] && pattern.layers[i]) { + var p = pattern.patterns[i]; + var l = pattern.layers[i]; + ship.AddCustomMask(_get(p, 'position', _global.vec3.create()), _get(p, 'scaling', _global.vec3.fromValues(1, 1, 1)), _get(p, 'rotation', _global.quat.create()), _get(p, 'isMirrored', false), _get(l, 'materialSource', 0), _global.vec4.fromValues(_get(l, 'isTargetMtl1', true) ? 1 : 0, _get(l, 'isTargetMtl2', true) ? 1 : 0, _get(l, 'isTargetMtl3', true) ? 1 : 0, _get(l, 'isTargetMtl4', true) ? 1 : 0)); + } + } + } - spriteArray[_offset + 19] = _q * vertCount + spriteIndexes[_v]; - spriteArray[_offset + 20] = _item.boneIndex; - spriteArray[_offset + 21] = _item.boosterGainInfluence ? 255 : 0; + function SetupDecals(ship, hull, faction) { + var hullDecals = _get(hull, 'hullDecals', []); + for (var i = 0; i < hullDecals.length; ++i) { + var hullDecal = hullDecals[i]; + var factionDecal = null; + var factionIndex = 'group' + _get(hullDecal, 'groupIndex', -1); + if (faction.decals && factionIndex in faction.decals) { + factionDecal = faction.decals[factionIndex]; + } + if (factionDecal && !factionDecal['isVisible']) { + continue; + } + var effect = new _core.Tw2Effect(); + if (factionDecal && factionDecal.shader && factionDecal.shader.length) { + effect.effectFilePath = data['generic']['decalShaderLocation'] + '/' + GetShaderPrefix(false) + factionDecal.shader; + } else if (hullDecal.shader && hullDecal.shader.length) { + effect.effectFilePath = data['generic']['decalShaderLocation'] + '/' + GetShaderPrefix(false) + hullDecal.shader; + } else { + continue; + } + var hullParameters = _get(hullDecal, 'parameters', {}); + for (var j in hullParameters) { + if (hullParameters.hasOwnProperty(j)) { + effect.parameters[j] = new _core.Tw2Vector4Parameter(j, hullParameters[j]); + } + } + var hullTextures = _get(hullDecal, 'textures', {}); + for (j in hullTextures) { + if (hullTextures.hasOwnProperty(j)) { + effect.parameters[j] = new _core.Tw2TextureParameter(j, hullTextures[j]); + } + } + if (factionDecal) { + var factionParameters = _get(factionDecal, 'parameters', {}); + for (j in factionParameters) { + if (factionParameters.hasOwnProperty(j)) { + effect.parameters[j] = new _core.Tw2Vector4Parameter(j, factionParameters[j]); + } + } + var factionTextures = _get(factionDecal, 'textures', {}); + for (j in factionTextures) { + if (factionTextures.hasOwnProperty(j) && !(j in effect.parameters)) { + effect.parameters[j] = new _core.Tw2TextureParameter(j, factionTextures[j]); } } } - this._spriteVertexBuffer = d.gl.createBuffer(); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._spriteVertexBuffer); - d.gl.bufferData(d.gl.ARRAY_BUFFER, spriteArray, d.gl.STATIC_DRAW); - this._spriteVertexBuffer.count = itemCount * spriteQuadCount * 6; + var defaultTextures = _get(_get(data['generic']['decalShaders'], hullDecal.shader, {}), 'defaultTextures', {}); + for (var texName in defaultTextures) { + if (defaultTextures.hasOwnProperty(texName)) { + if (!(texName in effect.parameters)) { + effect.parameters[texName] = new _core.Tw2TextureParameter(texName, defaultTextures[texName]); + } + } + } - var indexes = new Uint16Array(itemCount * coneQuadCount * 6); - for (var _i2 = 0; _i2 < itemCount * coneQuadCount; ++_i2) { - var _offset2 = _i2 * 6, - vtxOffset = _i2 * 4; + effect.Initialize(); - indexes[_offset2] = vtxOffset; - indexes[_offset2 + 1] = vtxOffset + 1; - indexes[_offset2 + 2] = vtxOffset + 2; - indexes[_offset2 + 3] = vtxOffset + 2; - indexes[_offset2 + 4] = vtxOffset + 3; - indexes[_offset2 + 5] = vtxOffset; + var decal = new _item.EveSpaceObjectDecal(); + _global.vec3.copy(decal.position, _get(hullDecal, 'position', [0, 0, 0])); + _global.quat.copy(decal.rotation, _get(hullDecal, 'rotation', [0, 0, 0, 1])); + _global.vec3.copy(decal.scaling, _get(hullDecal, 'scaling', [1, 1, 1])); + decal.parentBoneIndex = _get(hullDecal, 'boneIndex', -1); + decal.indexBuffer = new Uint16Array(hullDecal.indexBuffer); + decal.decalEffect = effect; + decal.name = _get(hullDecals[i], 'name', ''); + if ('groupIndex' in hullDecals[i]) { + decal.groupIndex = hullDecals[i].groupIndex; } + decal.Initialize(); + ship.decals.push(decal); + } + } - this._indexBuffer = d.gl.createBuffer(); - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - d.gl.bufferData(d.gl.ELEMENT_ARRAY_BUFFER, indexes, d.gl.STATIC_DRAW); - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, null); - this._indexBuffer.count = itemCount; + function SetupInstancedMeshes(ship, hull, faction, race, commands, pattern) { + var instancedMeshes = _get(hull, 'instancedMeshes', []); + for (var i = 0; i < instancedMeshes.length; ++i) { + var him = instancedMeshes[i]; + var mesh = new _core.Tw2InstancedMesh(); + mesh.instanceGeometryResPath = him.instanceGeometryResPath; + mesh.geometryResPath = him.geometryResPath; + mesh.Initialize(); + + FillMeshAreas(_get(mesh, 'opaqueAreas', []), 'opaqueAreas', hull, faction, race, pattern, commands, him.shader); + + var child = new _child.EveChildMesh(); + child.mesh = mesh; + ship.effectChildren.push(child); } + } - /** - * Gets the spotlight set's render batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator - * @param {Tw2PerObjectData} perObjectData - */ + function SetupSpriteSets(ship, hull, faction) { + var hullSets = _get(hull, 'spriteSets', []); + var factionSets = _get(faction, 'spriteSets', {}); + for (var i = 0; i < hullSets.length; ++i) { + var spriteSet = new _item.EveSpriteSet(true, !!(hull['isSkinned'] && hullSets[i]['skinned'])); + spriteSet.name = _get(hullSets[i], 'name', ''); + spriteSet.effect = spriteEffect; + var hullData = _get(hullSets[i], 'items', []); + for (var j = 0; j < hullData.length; ++j) { + if (!('group' + _get(hullData[j], 'groupIndex', -1) in factionSets)) continue; + var item = new _item.EveSpriteSetItem(); + item.blinkPhase = _get(hullData[j], 'blinkPhase', 0); + item.blinkRate = _get(hullData[j], 'blinkRate', 0.1); + item.boneIndex = _get(hullData[j], 'boneIndex', 0); + item.falloff = _get(hullData[j], 'falloff', 0); + item.maxScale = _get(hullData[j], 'maxScale', 10); + item.minScale = _get(hullData[j], 'minScale', 1); + item.name = _get(hullData[j], 'name', ''); + item.groupIndex = _get(hullData[j], 'groupIndex', -1); + _global.vec3.copy(item.position, _get(hullData[j], 'position', [0, 0, 0])); - }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator, perObjectData) { - if (this.display && mode === _core.device.RM_ADDITIVE && this._indexBuffer && this._indexBuffer.count) { - var batch = new EveSpotlightSetBatch(); - batch.renderMode = _core.device.RM_ADDITIVE; - batch.spotlightSet = this; - batch.perObjectData = perObjectData; - accumulator.Commit(batch); + var factionSet = factionSets['group' + item.groupIndex]; + if (factionSet) { + item.groupName = factionSet.name; + if ('color' in factionSet) _global.vec4.copy(item.color, factionSet.color); + } + spriteSet.sprites.push(item); } + spriteSet.Initialize(); + ship.spriteSets.push(spriteSet); } + } + + function SetupSpotlightSets(ship, hull, faction) { + var hullSets = _get(hull, 'spotlightSets', []); + var factionSets = _get(faction, 'spotlightSets', {}); + for (var i = 0; i < hullSets.length; ++i) { + var spotlightSet = new _item.EveSpotlightSet(); + spotlightSet.name = _get(hullSets[i], 'name', ''); + spotlightSet.coneEffect = new _core.Tw2Effect(); + spotlightSet.glowEffect = new _core.Tw2Effect(); + if (hullSets[i]['skinned']) { + spotlightSet.coneEffect.effectFilePath = 'res:/graphics/effect/managed/space/spaceobject/fx/skinned_spotlightcone.fx'; + spotlightSet.glowEffect.effectFilePath = 'res:/graphics/effect/managed/space/spaceobject/fx/skinned_spotlightglow.fx'; + } else { + spotlightSet.coneEffect.effectFilePath = 'res:/graphics/effect/managed/space/spaceobject/fx/spotlightcone.fx'; + spotlightSet.glowEffect.effectFilePath = 'res:/graphics/effect/managed/space/spaceobject/fx/spotlightglow.fx'; + } + spotlightSet.coneEffect.parameters['TextureMap'] = new _core.Tw2TextureParameter('TextureMap', hullSets[i]['coneTextureResPath']); + spotlightSet.glowEffect.parameters['TextureMap'] = new _core.Tw2TextureParameter('TextureMap', hullSets[i]['glowTextureResPath']); + spotlightSet.coneEffect.parameters['zOffset'] = new _core.Tw2FloatParameter('zOffset', _get(hullSets[i], 'zOffset', 0)); + spotlightSet.coneEffect.Initialize(); + spotlightSet.glowEffect.Initialize(); + + var hullData = _get(hullSets[i], 'items', []); + for (var j = 0; j < hullData.length; ++j) { + var item = new _item.EveSpotlightSetItem(); + item.name = _get(hullData[j], 'name', ''); + item.groupIndex = _get(hullData[j], 'groupIndex', -1); + item.boneIndex = _get(hullData[j], 'boneIndex', 0); + item.boosterGainInfluence = _get(hullData[j], 'boosterGainInfluence', 0); - /** - * Renders the spotlight set's cone effect - * @param {string} technique - technique name - * @returns {boolean} - */ + item.coneIntensity = _get(hullData[j], 'coneIntensity', 0); + item.spriteIntensity = _get(hullData[j], 'spriteIntensity', 0); + item.flareIntensity = _get(hullData[j], 'flareIntensity', 0); - }, { - key: 'RenderCones', - value: function RenderCones(technique) { - return EveSpotlightSet.Render(this, this.coneEffect, technique, this._coneVertexBuffer); - } + var factionSet = factionSets['group' + item.groupIndex]; + if (factionSet) { + _global.vec4.copy(item.coneColor, _get(factionSet, 'coneColor', [0, 0, 0, 0])); + _global.vec4.copy(item.spriteColor, _get(factionSet, 'spriteColor', [0, 0, 0, 0])); + _global.vec4.copy(item.flareColor, _get(factionSet, 'flareColor', [0, 0, 0, 0])); + } + _global.vec3.copy(item.spriteScale, _get(hullData[j], 'spriteScale', [1, 1, 1])); - /** - * Renders the spotlight set's glow effect - * @param {string} technique - technique name - * @returns {boolean} - */ + if ('transform' in hullData[j]) { + _global.mat4.copy(item.transform, hullData[j].transform); + } else { + _global.mat4.identity(item.transform); + } - }, { - key: 'RenderGlow', - value: function RenderGlow(technique) { - return EveSpotlightSet.Render(this, this.glowEffect, technique, this._spriteVertexBuffer); + spotlightSet.spotlightItems.push(item); + } + spotlightSet.Initialize(); + ship.spotlightSets.push(spotlightSet); } + } - /** - * Internal render function - * @param {EveSpotlightSet} spotlightSet - * @param {Tw2Effect} effect - The Tw2Effect to render - * @param {string} technique - technique name - * @param {WebGLBuffer} buffer - A webgl buffer (ie. cone or glow buffer) - * @returns {boolean} - * @private - */ - - }, { - key: 'spotlightItems', - get: function get() { - return this.items; + function _assignIfExists(dest, src, attr) { + if (attr in src) { + dest[attr] = src[attr]; } + } - /** - * Alias for this.items - * @param {Array} arr - */ - , - set: function set(arr) { - this.items = arr; - } - }], [{ - key: 'Render', - value: function Render(spotlightSet, effect, technique, buffer) { - if (!effect || !effect.IsGood() || !buffer) return false; + function SetupPlaneSets(ship, hull, faction) { + var hullSets = _get(hull, 'planeSets', []); + var factionSets = _get(faction, 'planeSets', {}); + for (var i = 0; i < hullSets.length; ++i) { + var planeSet = new _item.EvePlaneSet(); + planeSet.name = _get(hullSets[i], 'name', ''); + planeSet.effect = new _core.Tw2Effect(); + if (hullSets[i]['skinned']) { + planeSet.effect.effectFilePath = 'res:/graphics/effect/managed/space/spaceobject/fx/skinned_planeglow.fx'; + } else { + planeSet.effect.effectFilePath = 'res:/graphics/effect/managed/space/spaceobject/fx/planeglow.fx'; + } + planeSet.effect.parameters['Layer1Map'] = new _core.Tw2TextureParameter('Layer1Map', hullSets[i]['layer1MapResPath']); + planeSet.effect.parameters['Layer2Map'] = new _core.Tw2TextureParameter('Layer2Map', hullSets[i]['layer2MapResPath']); + planeSet.effect.parameters['MaskMap'] = new _core.Tw2TextureParameter('MaskMap', hullSets[i]['maskMapResPath']); + planeSet.effect.parameters['PlaneData'] = new _core.Tw2Vector4Parameter('PlaneData', _get(hullSets[i], 'planeData', [1, 0, 0, 0])); + planeSet.effect.Initialize(); - var stride = 22 * 4; - _core.device.SetStandardStates(_core.device.RM_ADDITIVE); - _core.device.gl.bindBuffer(_core.device.gl.ARRAY_BUFFER, buffer); - _core.device.gl.bindBuffer(_core.device.gl.ELEMENT_ARRAY_BUFFER, spotlightSet._indexBuffer); + var hullData = _get(hullSets[i], 'items', []); + for (var j = 0; j < hullData.length; ++j) { + var item = new _item.EvePlaneSetItem(); + _assignIfExists(item, hullData[j], 'groupIndex'); + _assignIfExists(item, hullData[j], 'name'); + item.boneIndex = _get(hullData[j], 'boneIndex', -1); + item.maskAtlasID = _get(hullData[j], 'maskMapAtlasIndex', 0); + // Do not copy reference! + _global.vec3.copy(item.position, _get(hullData[j], 'position', [0, 0, 0])); + _global.quat.copy(item.rotation, _get(hullData[j], 'rotation', [0, 0, 0, 1])); + _global.vec3.copy(item.scaling, _get(hullData[j], 'scaling', [1, 1, 1])); + _global.vec4.copy(item.color, _get(hullData[j], 'color', [0, 0, 0, 0])); + _global.vec4.copy(item.layer1Transform, _get(hullData[j], 'layer1Transform', [0, 0, 0, 0])); + _global.vec4.copy(item.layer1Scroll, _get(hullData[j], 'layer1Scroll', [0, 0, 0, 0])); + _global.vec4.copy(item.layer2Transform, _get(hullData[j], 'layer2Transform', [0, 0, 0, 0])); + _global.vec4.copy(item.layer2Scroll, _get(hullData[j], 'layer2Scroll', [0, 0, 0, 0])); - for (var pass = 0; pass < effect.GetPassCount(technique); ++pass) { - effect.ApplyPass(technique, pass); - if (!spotlightSet._decl.SetDeclaration(effect.GetPassInput(technique, pass), stride)) return false; - _core.device.ApplyShadowState(); - _core.device.gl.drawElements(_core.device.gl.TRIANGLES, buffer['count'], _core.device.gl.UNSIGNED_SHORT, 0); + var factionSet = factionSets['group' + _get(hullData[j], 'groupIndex', -1)]; + if (factionSet) _global.vec4.copy(item.color, _get(factionSet, 'color', [0, 0, 0, 0])); + planeSet.planes.push(item); } - return true; + planeSet.Initialize(); + ship.planeSets.push(planeSet); } - }]); - - return EveSpotlightSet; -}(_EveObjectSet2.EveObjectSet); - -/** - * Spotlight set item constructor - * @type {EveSpotlightSetItem} - */ - - -EveSpotlightSet.Item = EveSpotlightSetItem; - -/***/ }), -/* 193 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - + } -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.EveSpriteSet = exports.EveSpriteSetItem = exports.EveSpriteSetBatch = undefined; + function SetupBoosters(ship, hull, race) { + if (!('booster' in hull)) { + return; + } + var booster = new _item.EveBoosterSet(); + var hullBooster = hull['booster']; + var raceBooster = _get(race, 'booster', {}); + _assignIfExists(booster, raceBooster, 'glowScale'); + _assignIfExists(booster, raceBooster, 'symHaloScale'); + _assignIfExists(booster, raceBooster, 'haloScaleX'); + _assignIfExists(booster, raceBooster, 'haloScaleY'); + _assignIfExists(booster, raceBooster, 'haloColor'); + _global.vec4.copy(booster.glowColor, _get(raceBooster, 'glowColor', [0, 0, 0, 0])); + _global.vec4.copy(booster.warpGlowColor, _get(raceBooster, 'warpGlowColor', [0, 0, 0, 0])); + _global.vec4.copy(booster.warpHaloColor, _get(raceBooster, 'warpHalpColor', [0, 0, 0, 0])); + _global.vec4.copy(booster.trailColor, _get(raceBooster, 'trailColor', [0, 0, 0, 0])); + _global.vec4.copy(booster.trailSize, _get(raceBooster, 'trailSize', [0, 0, 0, 0])); -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + booster.effect = new _core.Tw2Effect(); + booster.effect.effectFilePath = 'res:/Graphics/Effect/Managed/Space/Booster/BoosterVolumetric.fx'; + booster.effect.parameters['NoiseFunction0'] = new _core.Tw2FloatParameter('NoiseFunction0', _get(raceBooster.shape0, 'noiseFunction', 0)); + booster.effect.parameters['NoiseSpeed0'] = new _core.Tw2FloatParameter('NoiseSpeed0', _get(raceBooster.shape0, 'noiseSpeed', 0)); + booster.effect.parameters['NoiseAmplitudeStart0'] = new _core.Tw2Vector4Parameter('NoiseAmplitudeStart0', _get(raceBooster.shape0, 'noiseAmplitureStart', [0, 0, 0, 0])); + booster.effect.parameters['NoiseAmplitudeEnd0'] = new _core.Tw2Vector4Parameter('NoiseAmplitudeEnd0', _get(raceBooster.shape0, 'noiseAmplitureEnd', [0, 0, 0, 0])); + booster.effect.parameters['NoiseFrequency0'] = new _core.Tw2Vector4Parameter('NoiseFrequency0', _get(raceBooster.shape0, 'noiseFrequency', [0, 0, 0, 0])); + booster.effect.parameters['Color0'] = new _core.Tw2Vector4Parameter('Color0', _get(raceBooster.shape0, 'color', [0, 0, 0, 0])); -var _math = __webpack_require__(0); + booster.effect.parameters['NoiseFunction1'] = new _core.Tw2FloatParameter('NoiseFunction1', _get(raceBooster.shape1, 'noiseFunction', 0)); + booster.effect.parameters['NoiseSpeed1'] = new _core.Tw2FloatParameter('NoiseSpeed1', _get(raceBooster.shape1, 'noiseSpeed', 0)); + booster.effect.parameters['NoiseAmplitudeStart1'] = new _core.Tw2Vector4Parameter('NoiseAmplitudeStart1', _get(raceBooster.shape1, 'noiseAmplitureStart', [0, 0, 0, 0])); + booster.effect.parameters['NoiseAmplitudeEnd1'] = new _core.Tw2Vector4Parameter('NoiseAmplitudeEnd1', _get(raceBooster.shape1, 'noiseAmplitureEnd', [0, 0, 0, 0])); + booster.effect.parameters['NoiseFrequency1'] = new _core.Tw2Vector4Parameter('NoiseFrequency1', _get(raceBooster.shape1, 'noiseFrequency', [0, 0, 0, 0])); + booster.effect.parameters['Color1'] = new _core.Tw2Vector4Parameter('Color1', _get(raceBooster.shape1, 'color', [0, 0, 0, 0])); -var _core = __webpack_require__(1); + booster.effect.parameters['WarpNoiseFunction0'] = new _core.Tw2FloatParameter('WarpNoiseFunction0', _get(raceBooster.warpShape0, 'noiseFunction', 0)); + booster.effect.parameters['WarpNoiseSpeed0'] = new _core.Tw2FloatParameter('WarpNoiseSpeed0', _get(raceBooster.warpShape0, 'noiseSpeed', 0)); + booster.effect.parameters['WarpNoiseAmplitudeStart0'] = new _core.Tw2Vector4Parameter('WarpNoiseAmplitudeStart0', _get(raceBooster.warpShape0, 'noiseAmplitureStart', [0, 0, 0, 0])); + booster.effect.parameters['WarpNoiseAmplitudeEnd0'] = new _core.Tw2Vector4Parameter('WarpNoiseAmplitudeEnd0', _get(raceBooster.warpShape0, 'noiseAmplitureEnd', [0, 0, 0, 0])); + booster.effect.parameters['WarpNoiseFrequency0'] = new _core.Tw2Vector4Parameter('WarpNoiseFrequency0', _get(raceBooster.warpShape0, 'noiseFrequency', [0, 0, 0, 0])); + booster.effect.parameters['WarpColor0'] = new _core.Tw2Vector4Parameter('WarpColor0', _get(raceBooster.warpShape0, 'color', [0, 0, 0, 0])); -var _EveObjectSet2 = __webpack_require__(10); + booster.effect.parameters['WarpNoiseFunction1'] = new _core.Tw2FloatParameter('WarpNoiseFunction1', _get(raceBooster.warpShape1, 'noiseFunction', 0)); + booster.effect.parameters['WarpNoiseSpeed1'] = new _core.Tw2FloatParameter('WarpNoiseSpeed1', _get(raceBooster.warpShape1, 'noiseSpeed', 0)); + booster.effect.parameters['WarpNoiseAmplitudeStart1'] = new _core.Tw2Vector4Parameter('WarpNoiseAmplitudeStart1', _get(raceBooster.warpShape1, 'noiseAmplitureStart', [0, 0, 0, 0])); + booster.effect.parameters['WarpNoiseAmplitudeEnd1'] = new _core.Tw2Vector4Parameter('WarpNoiseAmplitudeEnd1', _get(raceBooster.warpShape1, 'noiseAmplitureEnd', [0, 0, 0, 0])); + booster.effect.parameters['WarpNoiseFrequency1'] = new _core.Tw2Vector4Parameter('WarpNoiseFrequency1', _get(raceBooster.warpShape1, 'noiseFrequency', [0, 0, 0, 0])); + booster.effect.parameters['WarpColor1'] = new _core.Tw2Vector4Parameter('WarpColor1', _get(raceBooster.warpShape1, 'color', [0, 0, 0, 0])); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + booster.effect.parameters['ShapeAtlasSize'] = new _core.Tw2Vector4Parameter('ShapeAtlasSize', [_get(raceBooster, 'shapeAtlasHeight', 0), _get(raceBooster, 'shapeAtlasCount', 0), 0, 0]); + booster.effect.parameters['BoosterScale'] = new _core.Tw2Vector4Parameter('BoosterScale', _get(raceBooster, 'scale', [1, 1, 1, 1])); -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + booster.effect.parameters['ShapeMap'] = new _core.Tw2TextureParameter('ShapeMap', raceBooster.shapeAtlasResPath); + booster.effect.parameters['GradientMap0'] = new _core.Tw2TextureParameter('GradientMap0', raceBooster.gradient0ResPath); + booster.effect.parameters['GradientMap1'] = new _core.Tw2TextureParameter('GradientMap1', raceBooster.gradient1ResPath); + booster.effect.parameters['NoiseMap'] = new _core.Tw2TextureParameter('ShapeMap', 'res:/Texture/Global/noise32cube_volume.dds.0.png'); -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + booster.effect.Initialize(); -/** - * Sprite set render batch - * - * @property {boolean} boosterGlow - * @property {EveSpriteSet} spriteSet - * @property {mat4} world - * @property {number} - * @property {number} - * @class - */ -var EveSpriteSetBatch = exports.EveSpriteSetBatch = function (_Tw2RenderBatch) { - _inherits(EveSpriteSetBatch, _Tw2RenderBatch); + booster.glows = new _item.EveSpriteSet(true); + booster.glows.effect = new _core.Tw2Effect(); + booster.glows.effect.effectFilePath = 'res:/Graphics/Effect/Managed/Space/Booster/BoosterGlowAnimated.fx'; + booster.glows.effect.parameters['DiffuseMap'] = new _core.Tw2TextureParameter('DiffuseMap', 'res:/Texture/Particle/whitesharp.dds.0.png'); + booster.glows.effect.parameters['NoiseMap'] = new _core.Tw2TextureParameter('NoiseMap', 'res:/Texture/global/noise.dds.0.png'); + booster.glows.effect.Initialize(); - function EveSpriteSetBatch() { - _classCallCheck(this, EveSpriteSetBatch); + var items = _get(hullBooster, 'items', []); + for (var i = 0; i < items.length; ++i) { + var locator = new _item.EveLocator(); + locator.name = 'locator_booster_' + (i + 1); + if ('transform' in items[i]) { + _global.mat4.copy(locator.transform, items[i].transform); + } else { + _global.mat4.identity(locator.transform); + } + locator.atlasIndex0 = _get(items[i], 'atlasIndex0', 0); + locator.atlasIndex1 = _get(items[i], 'atlasIndex1', 0); + ship.locators.push(locator); + } + booster.Initialize(); + ship.boosters = booster; + } - var _this = _possibleConstructorReturn(this, (EveSpriteSetBatch.__proto__ || Object.getPrototypeOf(EveSpriteSetBatch)).call(this)); + function SetupLocators(ship, hull) { + var hullLocators = _get(hull, 'locatorTurrets', []); + for (var i = 0; i < hullLocators.length; ++i) { + var locator = new _item.EveLocator(); + locator.name = hullLocators[i].name; + if ('transform' in hullLocators[i]) { + _global.mat4.copy(locator.transform, hullLocators[i].transform); + } else { + _global.mat4.identity(locator.transform); + } + ship.locators.push(locator); + } + } - _this.boosterGlow = false; - _this.spriteSet = null; - _this.world = null; - _this.boosterGain = 0; - _this.warpIntensity = 0; - return _this; + function BindParticleEmitters(obj, curveSet, curve) { + for (var i = 0; i < obj.particleEmitters.length; ++i) { + if ('rate' in obj.particleEmitters[i]) { + var binding = new _core.Tw2ValueBinding(); + binding.sourceObject = curve; + binding.sourceAttribute = 'currentValue'; + binding.destinationObject = obj.particleEmitters[i]; + binding.destinationAttribute = 'rate'; + binding.Initialize(); + curveSet.bindings.push(binding); + } + } + for (i = 0; i < obj.children.length; ++i) { + BindParticleEmitters(obj.children[i], curveSet, curve); + } } - /** - * Commits the sprite set - * @param {string} technique - technique name - */ + function SetupChildren(ship, hull, curveSet, curves) { + function onChildLoaded(child) { + return function (obj) { + if (obj.isEffectChild) { + ship.effectChildren.push(obj); + } else { + ship.children.push(obj); + } + _global.vec3.copy(obj.translation, _get(child, 'translation', [0, 0, 0])); + _global.quat.copy(obj.rotation, _get(child, 'rotation', [0, 0, 0, 1])); + _global.vec3.copy(obj.scaling, _get(child, 'scaling', [1, 1, 1])); + var id = _get(child, 'id', -1); + if (id !== -1 && curves[id]) { + BindParticleEmitters(obj, curveSet, curves[id]); + } + }; + } + var children = _get(hull, 'children', []); + for (var i = 0; i < children.length; ++i) { + _global.resMan.GetObject(children[i]['redFilePath'], onChildLoaded(children[i])); + } + } - _createClass(EveSpriteSetBatch, [{ - key: 'Commit', - value: function Commit(technique) { - if (this.boosterGlow) { - this.spriteSet.RenderBoosterGlow(technique, this.world, this.boosterGain, this.warpIntensity); - } else { - this.spriteSet.Render(technique, this.world, this.perObjectData); + function SetupAnimations(ship, hull) { + var id_curves = []; + var curveSet = null; + var animations = _get(hull, 'animations', []); + for (var i = 0; i < animations.length; ++i) { + if (_get(animations[i], 'id', -1) !== -1 && _get(animations[i], 'startRate', -1) !== -1) { + if (!curveSet) { + curveSet = new _core.Tw2CurveSet(); + } + var curve = new _curve.Tw2ScalarCurve2(); + curve.keys.push(new _curve.Tw2ScalarKey2()); + curve.keys.push(new _curve.Tw2ScalarKey2()); + curve.keys[0].value = _get(animations[i], 'startRate', -1); + curve.keys[1].time = 1; + curve.keys[1].value = _get(animations[i], 'endRate', -1); + curve.Initialize(); + curveSet.curves.push(curve); + ship.curveSets.push(curveSet); + id_curves[_get(animations[i], 'id', -1)] = curve; } } - }]); + if (curveSet) { + curveSet.Initialize(); + } + return [curveSet, id_curves]; + } - return EveSpriteSetBatch; -}(_core.Tw2RenderBatch); + var dataLoading = false; + var pendingLoads = []; -/** - * EveSpriteSetItem - * - * @property {vec3} position - * @property {number} blinkRate - * @property {number} blinkPhase - * @property {number} minScale - * @property {number} maxScale - * @property {number} falloff - * @property {vec4} color - * @property {vec4} warpColor - * @property {number} boneIndex - * @property {number} groupIndex - * @class - */ + function Build(dna) { + var parts = dna.split(':'); + var commands = {}; + for (var i = 3; i < parts.length; ++i) { + var subparts = parts[i].split('?'); + commands[subparts[0]] = subparts[1].split(';'); + } + var hull = data['hull'][parts[0]]; + var faction = data['faction'][parts[1]]; + var race = data['race'][parts[2]]; + var ship = new (_get(hull, 'buildClass', 0) === 2 ? _object.EveSpaceObject : _object.EveShip)(); + var pattern = SetupPattern(hull, race, commands); + SetupMesh(ship, hull, faction, race, commands, pattern); + SetupCustomMasks(ship, pattern); + SetupDecals(ship, hull, faction); + SetupSpriteSets(ship, hull, faction); + SetupSpotlightSets(ship, hull, faction); + SetupPlaneSets(ship, hull, faction); + SetupBoosters(ship, hull, race); + SetupLocators(ship, hull); + var curves = SetupAnimations(ship, hull); + SetupChildren(ship, hull, curves[0], curves[1]); + SetupInstancedMeshes(ship, hull, faction, race, commands, pattern); + ship.Initialize(); + return ship; + } -var EveSpriteSetItem = exports.EveSpriteSetItem = function (_EveObjectSetItem) { - _inherits(EveSpriteSetItem, _EveObjectSetItem); + this.LoadData = function (callback) { + if (data === null) { + if (callback) { + pendingLoads.push(callback); + } + if (!dataLoading) { + spriteEffect = new _core.Tw2Effect(); + spriteEffect.effectFilePath = 'res:/graphics/effect/managed/space/spaceobject/fx/blinkinglightspool.fx'; + spriteEffect.parameters['MainIntensity'] = new _core.Tw2FloatParameter('MainIntensity', 1); + spriteEffect.parameters['GradientMap'] = new _core.Tw2TextureParameter('GradientMap', 'res:/texture/particle/whitesharp_gradient.dds.0.png'); + spriteEffect.Initialize(); - function EveSpriteSetItem() { - _classCallCheck(this, EveSpriteSetItem); + _global.resMan.GetObject('res:/dx9/model/spaceobjectfactory/data.red', function (obj) { + data = obj; + for (var i = 0; i < pendingLoads.length; ++i) { + pendingLoads[i](); + } + pendingLoads = []; + }); + dataLoading = true; + } + } else { + if (callback) { + callback(); + } + } + }; - var _this2 = _possibleConstructorReturn(this, (EveSpriteSetItem.__proto__ || Object.getPrototypeOf(EveSpriteSetItem)).call(this)); + this.BuildFromDNA = function (dna, callback) { + if (data === null) { + this.LoadData(function () { + var result = Build(dna); + if (callback) { + callback(result); + } + }); + } else { + var result = Build(dna); + if (callback) { + callback(result); + } + } + }; - _this2.position = _math.vec3.create(); - _this2.blinkRate = 0; - _this2.blinkPhase = 0; - _this2.minScale = 1; - _this2.maxScale = 1; - _this2.falloff = 0; - _this2.color = _math.vec4.create(); - _this2.warpColor = _math.vec4.create(); - _this2.boneIndex = 0; - _this2.groupIndex = -1; - return _this2; + function GetTurretMaterialParameter(name, parentFaction, areaData) { + var materialIdx = -1; + for (var i = 0; i < data['generic']['materialPrefixes'].length; ++i) { + if (name.substr(0, data['generic']['materialPrefixes'][i].length) === data['generic']['materialPrefixes'][i]) { + materialIdx = i; + name = name.substr(data['generic']['materialPrefixes'][i].length); + } + } + if (materialIdx !== -1) { + var turretMaterialIndex = _get(parentFaction, 'materialUsageMtl' + (materialIdx + 1), materialIdx); + if (turretMaterialIndex >= 0 && turretMaterialIndex < data['generic']['materialPrefixes'].length) { + name = data['generic']['materialPrefixes'][turretMaterialIndex] + name; + if (name in areaData.parameters) { + return areaData.parameters[name]; + } + } + } } - /** - * Creates a sprite set item from an object - * @param {*} [opt={}] - * @returns {EveSpriteSetItem} - */ + var zeroColor = [0, 0, 0, 0]; + function CombineTurretMaterial(name, parentValue, turretValue, overrideMethod) { + switch (overrideMethod) { + case 'overridable': + return parentValue ? parentValue : turretValue ? turretValue : zeroColor; + case 'half_overridable': + if (name.indexOf('GlowColor') >= 0) { + return turretValue ? turretValue : zeroColor; + } + return parentValue ? parentValue : turretValue ? turretValue : zeroColor; + case 'not_overridable': + case 'half_overridable_2': + return turretValue ? turretValue : zeroColor; + } + return zeroColor; + } - _createClass(EveSpriteSetItem, null, [{ - key: 'create', - value: function create() { - var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + function SetupTurretMaterial(turretSet, parentFactionName, turretFactionName) { + var parentFaction = data['faction'][parentFactionName]; + var turretFaction = data['faction'][turretFactionName]; + var parentArea = null; + if (parentFaction && parentFaction.areas && 'hull' in parentFaction.areas) { + parentArea = parentFaction.areas.hull; + } + var turretArea = null; + if (turretFaction && turretFaction.areas && 'hull' in turretFaction.areas) { + turretArea = turretFaction.areas.hull; + } + if (!parentArea && !turretArea) { + return; + } + if (turretSet.turretEffect) { + var params = turretSet.turretEffect.parameters; + for (var i in params) { + if (params.hasOwnProperty(i)) { + if (params[i].constructor.prototype !== _core.Tw2Vector4Parameter.prototype) { + continue; + } + var parentValue = null; + var turretValue = null; + if (parentArea) { + parentValue = GetTurretMaterialParameter(i, parentFaction, parentArea); + } + if (turretArea) { + turretValue = GetTurretMaterialParameter(i, parentFaction, parentArea); + } + _global.vec4.copy(params[i].value, CombineTurretMaterial(i, parentValue, turretValue, turretSet.turretEffect.name)); + } + } + turretSet.turretEffect.BindParameters(); + } + } - var item = new this(); - _math.util.assignIfExists(item, opt, ['name', 'display', 'blinkRate', 'blinkPhase', 'minScale', 'maxScale', 'falloff', 'boneIndex', 'groupIndex', 'position', 'color', 'warpColor']); - return item; + this.SetupTurretMaterial = function (turretSet, parentFactionName, turretFactionName, callback) { + if (data === null) { + this.LoadData(function () { + SetupTurretMaterial(turretSet, parentFactionName, turretFactionName); + if (callback) { + callback(); + } + }); + } else { + SetupTurretMaterial(turretSet, parentFactionName, turretFactionName); + if (callback) { + callback(); + } } - }]); + }; - return EveSpriteSetItem; -}(_EveObjectSet2.EveObjectSetItem); + function getDataKeys(name) { + if (name !== 'all') { + var names = {}; + for (var i in data[name]) { + if (data[name].hasOwnProperty(i)) { + names[i] = data[name][i].description || ''; + } + } + return names; + } else { + return data; + } + } -/** - * EveSpriteSet - * - * @param {boolean} [useQuads] - Use quad rendering (CPU transform) - * @param {boolean} [isSkinned] - Use bone transforms (when useQuads is true) - * @property {Tw2Effect} effect - * @property {?boolean} useQuads - Use quad rendering (CPU transform) - * @property {?boolean} isSkinned - Use bone transforms (when useQuads is true) - * @property {number} _time - * @property {WebGLBuffer} _vertexBuffer - * @property {WebGLBuffer} _indexBuffer - * @property {Tw2VertexDeclaration} _decl - */ + this.GetHullNames = function (callback) { + this.LoadData(function () { + callback(getDataKeys('hull')); + }); + }; + this.GetFactionNames = function (callback) { + this.LoadData(function () { + callback(getDataKeys('faction')); + }); + }; -var EveSpriteSet = exports.EveSpriteSet = function (_EveObjectSet) { - _inherits(EveSpriteSet, _EveObjectSet); + this.GetRaceNames = function (callback) { + this.LoadData(function () { + callback(getDataKeys('race')); + }); + }; - function EveSpriteSet() { - var useQuads = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - var isSkinned = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + this.GetSofData = function (callback) { + this.LoadData(function () { + callback(getDataKeys('all')); + }); + }; +} - _classCallCheck(this, EveSpriteSet); +/***/ }), +/* 185 */ +/***/ (function(module, exports, __webpack_require__) { - var _this3 = _possibleConstructorReturn(this, (EveSpriteSet.__proto__ || Object.getPrototypeOf(EveSpriteSet)).call(this)); +"use strict"; - _this3.effect = null; - _this3.useQuads = null; - _this3.isSkinned = null; - _this3._time = 0; - _this3._vertexBuffer = null; - _this3._indexBuffer = null; - _this3._instanceBuffer = null; - _this3._decl = _this3._decl = new _core.Tw2VertexDeclaration(); - _this3._vdecl = new _core.Tw2VertexDeclaration(); - _this3._vdecl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 5, _core.device.gl.FLOAT, 1, 0)); - _this3._vdecl.RebuildHash(); - _this3.UseQuads(useQuads, isSkinned); - return _this3; - } +Object.defineProperty(exports, "__esModule", { + value: true +}); - /** - * Alias for this.items - * @returns {Array} - */ +var _emitters = __webpack_require__(186); +Object.keys(_emitters).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _emitters[key]; + } + }); +}); - _createClass(EveSpriteSet, [{ - key: 'UseQuads', +var _forces = __webpack_require__(190); +Object.keys(_forces).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _forces[key]; + } + }); +}); - /** - * Use instanced rendering or 'quad' rendering - * @param {boolean} useQuads - Use quad rendering (CPU transform) - * @param {boolean} isSkinned - Use bone transforms (when useQuads is true) - */ - value: function UseQuads(useQuads, isSkinned) { - if (this.useQuads === useQuads) return; +var _generators = __webpack_require__(197); - this.useQuads = useQuads; - this.isSkinned = isSkinned; +Object.keys(_generators).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _generators[key]; + } + }); +}); - this._decl.elements.splice(0, this._decl.elements.length); - if (!useQuads) { - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 5, _core.device.gl.FLOAT, 2, 0)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.POSITION, 0, _core.device.gl.FLOAT, 3, 8)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 0, _core.device.gl.FLOAT, 3, 20)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 0, _core.device.gl.FLOAT, 1, 32)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 1, _core.device.gl.FLOAT, 1, 36)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 2, _core.device.gl.FLOAT, 1, 40)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 3, _core.device.gl.FLOAT, 1, 44)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 4, _core.device.gl.FLOAT, 1, 48)); - } else { - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.POSITION, 0, _core.device.gl.FLOAT, 3, 0)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 0, _core.device.gl.FLOAT, 4, 12)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 1, _core.device.gl.FLOAT, 2, 28)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 0, _core.device.gl.FLOAT, 4, 36)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 1, _core.device.gl.FLOAT, 4, 52)); - } +var _constraints = __webpack_require__(201); - this._decl.RebuildHash(); - this._rebuildPending = true; - } +Object.keys(_constraints).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _constraints[key]; + } + }); +}); - /** - * Gets Sprite Set Resource Objects - * @param {Array} [out=[]] - Optional receiving array - * @returns {Array.} [out] - */ +var _Tw2ParticleSystem = __webpack_require__(202); - }, { - key: 'GetResources', - value: function GetResources() { - var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; +Object.keys(_Tw2ParticleSystem).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2ParticleSystem[key]; + } + }); +}); - if (this.effect) { - this.effect.GetResources(out); - } - return out; - } +var _Tw2ParticleElement = __webpack_require__(14); - /** - * Per frame update - * @param {number} dt - Delta time - */ +Object.keys(_Tw2ParticleElement).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2ParticleElement[key]; + } + }); +}); - }, { - key: 'Update', - value: function Update(dt) { - this._time += dt; +/***/ }), +/* 186 */ +/***/ (function(module, exports, __webpack_require__) { - if (this._rebuildPending) { - this.Rebuild(); - } - } +"use strict"; - /** - * Unloads the sprite set's buffers - */ - }, { - key: 'Unload', - value: function Unload() { - if (this._vertexBuffer) { - _core.device.gl.deleteBuffer(this._vertexBuffer); - this._vertexBuffer = null; - } +Object.defineProperty(exports, "__esModule", { + value: true +}); - // Standard - if (this._indexBuffer) { - _core.device.gl.deleteBuffer(this._indexBuffer); - this._indexBuffer = null; - } +var _Tw2StaticEmitter = __webpack_require__(187); - // Quad - if (this._instanceBuffer) { - _core.device.gl.deleteBuffer(this._instanceBuffer); - this._instanceBuffer = null; - } - } +Object.keys(_Tw2StaticEmitter).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2StaticEmitter[key]; + } + }); +}); - /** - * Rebuilds the sprite set's buffers - */ +var _Tw2DynamicEmitter = __webpack_require__(188); - }, { - key: 'Rebuild', - value: function Rebuild() { - this.constructor.RebuildItems(this); - this._rebuildPending = false; - var itemCount = this._visibleItems.length; - if (!itemCount) return; +Object.keys(_Tw2DynamicEmitter).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2DynamicEmitter[key]; + } + }); +}); - var d = _core.device; +var _Tw2GpuUniqueEmitter = __webpack_require__(189); - if (this.useQuads) { - this._vertexBuffer = d.gl.createBuffer(); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vertexBuffer); - d.gl.bufferData(d.gl.ARRAY_BUFFER, new Float32Array([0, 1, 2, 2, 3, 0]), d.gl.STATIC_DRAW); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, null); - this._instanceBuffer = d.gl.createBuffer(); - return; - } +Object.keys(_Tw2GpuUniqueEmitter).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2GpuUniqueEmitter[key]; + } + }); +}); - var vertexSize = 13, - array = new Float32Array(itemCount * 4 * vertexSize); +/***/ }), +/* 187 */ +/***/ (function(module, exports, __webpack_require__) { - for (var i = 0; i < itemCount; ++i) { - var item = this._visibleItems[i], - offset = i * 4 * vertexSize; +"use strict"; - array[offset] = 0; - array[offset + vertexSize] = 1; - array[offset + 2 * vertexSize] = 2; - array[offset + 3 * vertexSize] = 3; - for (var j = 0; j < 4; ++j) { - var vtxOffset = offset + j * vertexSize; - array[vtxOffset + 1] = item.boneIndex; - array[vtxOffset + 2] = item.position[0]; - array[vtxOffset + 3] = item.position[1]; - array[vtxOffset + 4] = item.position[2]; - array[vtxOffset + 5] = item.color[0]; - array[vtxOffset + 6] = item.color[1]; - array[vtxOffset + 7] = item.color[2]; - array[vtxOffset + 8] = item.blinkPhase; - array[vtxOffset + 9] = item.blinkRate; - array[vtxOffset + 10] = item.minScale; - array[vtxOffset + 11] = item.maxScale; - array[vtxOffset + 12] = item.falloff; - } - } +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2StaticEmitter = undefined; - this._vertexBuffer = d.gl.createBuffer(); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vertexBuffer); - d.gl.bufferData(d.gl.ARRAY_BUFFER, array, d.gl.STATIC_DRAW); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, null); +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var indexes = new Uint16Array(itemCount * 6); - for (var _i = 0; _i < itemCount; ++_i) { - var _offset = _i * 6, - _vtxOffset = _i * 4; +var _core = __webpack_require__(1); - indexes[_offset] = _vtxOffset; - indexes[_offset + 1] = _vtxOffset + 2; - indexes[_offset + 2] = _vtxOffset + 1; - indexes[_offset + 3] = _vtxOffset; - indexes[_offset + 4] = _vtxOffset + 3; - indexes[_offset + 5] = _vtxOffset + 2; - } +var _Tw2ParticleEmitter2 = __webpack_require__(27); - this._indexBuffer = d.gl.createBuffer(); - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - d.gl.bufferData(d.gl.ELEMENT_ARRAY_BUFFER, indexes, d.gl.STATIC_DRAW); - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, null); - this._indexBuffer.count = itemCount * 6; - } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - /** - * Gets render batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator - * @param {Tw2PerObjectData} perObjectData - * @param {mat4} world - */ +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator, perObjectData, world) { - if (this.display && mode === _core.device.RM_ADDITIVE && this._vertexBuffer && this._visibleItems.length) { - var batch = new EveSpriteSetBatch(); - batch.world = world; - batch.renderMode = _core.device.RM_ADDITIVE; - batch.spriteSet = this; - batch.perObjectData = perObjectData; - accumulator.Commit(batch); - } - } +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - /** - * Gets render batches for booster glows - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator - * @param {Tw2PerObjectData} perObjectData - * @param {mat4} world - * @param {Number} boosterGain - * @param {Number} warpIntensity - */ +/** + * Tw2StaticEmitter + * + * @property {string} name + * @property {string} geometryResourcePath + * @property {Tw2GeometryRes} geometryResource + * @property {Number} geometryIndex + * @property {Boolean} _spawned + * @inherits Tw2ParticleEmitter + * @class + */ +var Tw2StaticEmitter = exports.Tw2StaticEmitter = function (_Tw2ParticleEmitter) { + _inherits(Tw2StaticEmitter, _Tw2ParticleEmitter); - }, { - key: 'GetBoosterGlowBatches', - value: function GetBoosterGlowBatches(mode, accumulator, perObjectData, world, boosterGain, warpIntensity) { - if (this.display && mode === _core.device.RM_ADDITIVE && this._vertexBuffer && this._visibleItems.length) { - var batch = new EveSpriteSetBatch(); - batch.boosterGlow = true; - batch.world = world; - batch.boosterGain = boosterGain; - batch.warpIntensity = warpIntensity; - batch.renderMode = _core.device.RM_ADDITIVE; - batch.spriteSet = this; - batch.perObjectData = perObjectData; - accumulator.Commit(batch); - } - } + function Tw2StaticEmitter() { + _classCallCheck(this, Tw2StaticEmitter); - /** - * Renders the sprite set - * @param {string} technique - technique name - * @param {mat4} world - * @param {Tw2PerObjectData} perObjectData - * @returns {boolean} - */ + var _this = _possibleConstructorReturn(this, (Tw2StaticEmitter.__proto__ || Object.getPrototypeOf(Tw2StaticEmitter)).call(this)); - }, { - key: 'Render', - value: function Render(technique, world, perObjectData) { - if (this.useQuads) { - return this.RenderQuads(technique, world, perObjectData); - } + _this.geometryResourcePath = ''; + _this.geometryResource = null; + _this.geometryIndex = 0; + _this._spawned = false; + return _this; + } - if (!this.effect || !this.effect.IsGood() || !this._indexBuffer) return false; + /** + * Initializes the particle emitter + */ - _core.device.SetStandardStates(_core.device.RM_ADDITIVE); - _core.device.gl.bindBuffer(_core.device.gl.ARRAY_BUFFER, this._vertexBuffer); - _core.device.gl.bindBuffer(_core.device.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - for (var pass = 0; pass < this.effect.GetPassCount(technique); ++pass) { - this.effect.ApplyPass(technique, pass); - if (!this._decl.SetDeclaration(this.effect.GetPassInput(technique, pass), 52)) return false; - _core.device.ApplyShadowState(); - _core.device.gl.drawElements(_core.device.gl.TRIANGLES, this._indexBuffer.count, _core.device.gl.UNSIGNED_SHORT, 0); + _createClass(Tw2StaticEmitter, [{ + key: 'Initialize', + value: function Initialize() { + if (this.geometryResourcePath !== '') { + this.geometryResource = _core.resMan.GetResource(this.geometryResourcePath); + this.geometryResource.systemMirror = true; + this.geometryResource.RegisterNotification(this); } - return true; + this._spawned = false; } /** - * Renders the sprite set as booster glow - * @param {string} technique - technique name - * @param {mat4} world - * @param {Number} boosterGain - * @param {Number} warpIntensity - * @returns {boolean} + * Rebuilds cached data */ }, { - key: 'RenderBoosterGlow', - value: function RenderBoosterGlow(technique, world, boosterGain, warpIntensity) { - if (!this.effect || !this.effect.IsGood() || !this._instanceBuffer) return false; - - var d = _core.device, - pos = _EveObjectSet2.EveObjectSet.global.vec3_0, - itemCount = this._visibleItems.length, - array = new Float32Array(17 * itemCount); - - d.SetStandardStates(d.RM_ADDITIVE); - - var index = 0; - for (var i = 0; i < itemCount; ++i) { - var item = this._visibleItems[i]; - _math.vec3.transformMat4(pos, item.position, world); - array[index++] = pos[0]; - array[index++] = pos[1]; - array[index++] = pos[2]; - array[index++] = world[8]; - array[index++] = item.blinkPhase; - array[index++] = world[9]; - array[index++] = item.minScale; - array[index++] = item.maxScale; - array[index++] = world[10]; - array[index++] = item.color[0]; - array[index++] = item.color[1]; - array[index++] = item.color[2]; - array[index++] = boosterGain; - array[index++] = item.warpColor[0]; - array[index++] = item.warpColor[1]; - array[index++] = item.warpColor[2]; - array[index++] = warpIntensity; - } - - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._instanceBuffer); - d.gl.bufferData(d.gl.ARRAY_BUFFER, array, d.gl.DYNAMIC_DRAW); - - for (var pass = 0; pass < this.effect.GetPassCount(technique); ++pass) { - this.effect.ApplyPass(technique, pass); - var passInput = this.effect.GetPassInput(technique, pass); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vertexBuffer); - this._vdecl.SetPartialDeclaration(passInput, 4); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._instanceBuffer); - var resetData = this._decl.SetPartialDeclaration(passInput, 17 * 4, 0, 1); - d.ApplyShadowState(); - d.ext.drawArraysInstanced(d.gl.TRIANGLES, 0, 6, itemCount); - this._decl.ResetInstanceDivisors(resetData); + key: 'RebuildCachedData', + value: function RebuildCachedData() { + if (this.geometryResource && this.geometryResource.meshes.length) { + if (!this.geometryResource.meshes[0].bufferData) { + this.geometryResource.systemMirror = true; + this.geometryResource.Reload(); + } } - - return true; } /** - * Renders the sprite set with pre-transformed quads - * @param {string} technique - technique name - * @param {mat4} world - * @param {Tw2PerObjectData} perObjectData - * @returns {boolean} + * Per frame update */ }, { - key: 'RenderQuads', - value: function RenderQuads(technique, world, perObjectData) { - if (!this.effect || !this.effect.IsGood() || !this._instanceBuffer) return false; - - var d = _core.device, - itemCount = this._visibleItems.length, - array = new Float32Array(17 * itemCount), - pos = _EveObjectSet2.EveObjectSet.global.vec3_0, - bones = perObjectData.perObjectVSData.Get('JointMat'); + key: 'Update', + value: function Update() { + if (!this._spawned && this.particleSystem && this.geometryResource && this.geometryResource.IsGood() && this.geometryResource.meshes.length > this.geometryIndex && this.geometryResource.meshes[this.geometryIndex].bufferData) { + this._spawned = true; - d.SetStandardStates(d.RM_ADDITIVE); + var mesh = this.geometryResource.meshes[this.geometryIndex], + elts = this.particleSystem.elements, + inputs = new Array(elts.length); - var index = 0; - for (var i = 0; i < itemCount; ++i) { - var item = this._visibleItems[i]; - if (this.isSkinned) { - var offset = item.boneIndex * 12; - pos[0] = bones[offset] * item.position[0] + bones[offset + 1] * item.position[1] + bones[offset + 2] * item.position[2] + bones[offset + 3]; - pos[1] = bones[offset + 4] * item.position[0] + bones[offset + 5] * item.position[1] + bones[offset + 6] * item.position[2] + bones[offset + 7]; - pos[2] = bones[offset + 8] * item.position[0] + bones[offset + 9] * item.position[1] + bones[offset + 10] * item.position[2] + bones[offset + 11]; - _math.vec3.transformMat4(pos, pos, world); - } else { - _math.vec3.transformMat4(pos, item.position, world); - } + for (var i = 0; i < elts.length; ++i) { + var d = elts[i].GetDeclaration(), + input = mesh.declaration.FindUsage(d.usage, d.usageIndex - 8); - array[index++] = pos[0]; - array[index++] = pos[1]; - array[index++] = pos[2]; - array[index++] = 1; - array[index++] = item.blinkPhase; - array[index++] = item.blinkRate; - array[index++] = item.minScale; - array[index++] = item.maxScale; - array[index++] = item.falloff; - array[index++] = item.color[0]; - array[index++] = item.color[1]; - array[index++] = item.color[2]; - array[index++] = 1; - array[index++] = item.warpColor[0]; - array[index++] = item.warpColor[1]; - array[index++] = item.warpColor[2]; - array[index++] = 1; - } + if (input === null) { + _core.logger.log('res.error', { + log: 'error', + src: ['Tw2StaticEmitter', 'Update'], + msg: 'Input geometry mesh lacks element required by particle system', + path: this.geometryResource.path, + type: 'geometry.elements', + data: { + elementUsage: d.usage, + elementUsageIndex: d.usageIndex + } + }); + return; + } - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._instanceBuffer); - d.gl.bufferData(d.gl.ARRAY_BUFFER, array, d.gl.DYNAMIC_DRAW); + if (input.elements < d.elements) { + _core.logger.log('res.error', { + log: 'error', + src: ['Tw2StaticEmitter', 'Update'], + msg: 'Input geometry mesh elements do not have the required number of components', + path: this.geometryResource.path, + type: 'geometry.elementcomponents', + data: { + inputCount: input.elements, + elementCount: d.elements, + elementUsage: d.usage, + elementUsageIndex: d.usageIndex + } + }); + return; + } - for (var pass = 0; pass < this.effect.GetPassCount(technique); ++pass) { - this.effect.ApplyPass(technique, pass); - var passInput = this.effect.GetPassInput(technique, pass); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vertexBuffer); - this._vdecl.SetPartialDeclaration(passInput, 4); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._instanceBuffer); - var resetData = this._decl.SetPartialDeclaration(passInput, 17 * 4, 0, 1); - d.ApplyShadowState(); - d.ext.drawArraysInstanced(d.gl.TRIANGLES, 0, 6, itemCount); - this._decl.ResetInstanceDivisors(resetData); - } + inputs[i] = input.offset / 4; + } - return true; - } - }, { - key: 'sprites', - get: function get() { - return this.items; - } + var vertexCount = mesh.bufferData.length / mesh.declaration.stride * 4; + for (var _i = 0; _i < vertexCount; ++_i) { + var index = this.particleSystem.BeginSpawnParticle(); + if (index === null) break; - /** - * Alias for this.items - * @param {Array} arr - */ - , - set: function set(arr) { - this.items = arr; + for (var j = 0; j < this.particleSystem._elements.length; ++j) { + var e = this.particleSystem._elements[j]; + for (var k = 0; k < e.dimension; ++k) { + e.buffer[e.instanceStride * index + e.startOffset + k] = mesh.bufferData[inputs[j] + k + _i * mesh.declaration.stride / 4]; + } + } + this.particleSystem.EndSpawnParticle(); + } + } } }]); - return EveSpriteSet; -}(_EveObjectSet2.EveObjectSet); - -/** - * The sprite set's item constructor - * @type {EveSpriteSetItem} - */ - - -EveSpriteSet.Item = EveSpriteSetItem; + return Tw2StaticEmitter; +}(_Tw2ParticleEmitter2.Tw2ParticleEmitter); /***/ }), -/* 194 */ +/* 188 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -39902,15 +40880,11 @@ EveSpriteSet.Item = EveSpriteSetItem; Object.defineProperty(exports, "__esModule", { value: true }); -exports.EveTurretSet = exports.EveTurretSetItem = undefined; +exports.Tw2DynamicEmitter = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); - -var _core = __webpack_require__(1); - -var _EveObjectSet2 = __webpack_require__(10); +var _Tw2ParticleEmitter2 = __webpack_require__(27); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -39919,891 +40893,626 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * EveTurretSetItem + * Tw2DynamicEmitter * - * @property {?Tw2Bone} bone - The bone the turret is on - * @property {boolean} isJoint - Identifies if the turret is on a joint - * @property {?string} locatorName - The item's locator name - * @property {boolean} updateFromLocator - Allows the turret to be updated from a locator's transforms - * @property {boolean} canFireWhenHidden - Enables firing effects when hidden - * @property {vec3} position - The turret's position - * @property {quat} rotation - The turret's rotation - * @property {mat4} _localTransform - The turret's local transform - * @property {quat} _localRotation - the turret's local rotation + * @property {string} name + * @property {number} rate + * @property {boolean} isValid + * @property {number} _accumulatedRate + * @property {Array}} generators + * @inherits Tw2ParticleEmitter + * @class */ -var EveTurretSetItem = exports.EveTurretSetItem = function (_EveObjectSetItem) { - _inherits(EveTurretSetItem, _EveObjectSetItem); +var Tw2DynamicEmitter = exports.Tw2DynamicEmitter = function (_Tw2ParticleEmitter) { + _inherits(Tw2DynamicEmitter, _Tw2ParticleEmitter); - function EveTurretSetItem() { - _classCallCheck(this, EveTurretSetItem); + function Tw2DynamicEmitter() { + _classCallCheck(this, Tw2DynamicEmitter); - var _this = _possibleConstructorReturn(this, (EveTurretSetItem.__proto__ || Object.getPrototypeOf(EveTurretSetItem)).call(this)); + var _this = _possibleConstructorReturn(this, (Tw2DynamicEmitter.__proto__ || Object.getPrototypeOf(Tw2DynamicEmitter)).call(this)); - _this.bone = null; - _this.locatorName = null; - _this.updateFromLocator = false; - _this.canFireWhenHidden = false; - _this.position = _math.vec3.create(); - _this.rotation = _math.quat.create(); - _this._localTransform = _math.mat4.create(); - _this._localRotation = _math.quat.create(); + _this.rate = 0; + _this.isValid = false; + _this._accumulatedRate = 0; + _this.generators = []; return _this; } /** - * Updates the turret's transforms + * Initializes the particle emitter */ - _createClass(EveTurretSetItem, [{ - key: 'UpdateTransforms', - value: function UpdateTransforms() { - _math.mat4.fromRotationTranslation(this._localTransform, this.rotation, this.position); - - if (this.bone) { - _math.mat4.multiply(this._localTransform, this.bone.offsetTransform, this._localTransform); - _math.mat4.getRotation(this._localRotation, this._localTransform); - } else { - _math.quat.copy(this._localRotation, this.rotation); - } + _createClass(Tw2DynamicEmitter, [{ + key: 'Initialize', + value: function Initialize() { + this.Rebind(); } /** - * Creates a turret item from an object - * @param {*} [opt={}] - * @returns {EveTurretSetItem} + * Per frame update + * @param {number} dt - delta time */ - }], [{ - key: 'create', - value: function create() { - var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - var item = new this(); - _math.util.assignIfExists(item, opt, ['name', 'display', 'locatorName', 'updateFromLocator', 'position', 'rotation', 'bone', 'canFireWhenHidden']); - item.UpdateTransforms(); - return item; + }, { + key: 'Update', + value: function Update(dt) { + this.SpawnParticles(null, null, Math.min(dt, 0.1)); } - }]); - - return EveTurretSetItem; -}(_EveObjectSet2.EveObjectSetItem); - -/** - * EveTurretSet - * - * @property {Array.} turrets - * @property {Tw2AnimationController} activeAnimation - * @property {Tw2AnimationController} inactiveAnimation - * @property {string} geometryResPath - * @property {Tw2GeometryRes} geometryResource - * @property {number} bottomClipHeight - * @property {string} locatorName - * @property {Tw2Effect} turretEffect - * @property {vec3} targetPosition - * @property {number} sysBoneHeight - * @property {string} firingEffectResPath - * @property {EveTurretFiringFX} firingEffect - * @property {number} state - * @property {boolean} hasCyclingFiringPos - * @property {mat4} parentMatrix - * @property {quat} boundingSphere - * @property {number} _activeTurret - * @property {number} _recheckTimeLeft - * @property {number} _currentCyclingFiresPos - * @property {Tw2PerObjectData} _perObjectDataActive - * @property {Tw2PerObjectData} _perObjectDataInactive - * @property {boolean} _locatorRebuildPending - * @class - */ - - -var EveTurretSet = exports.EveTurretSet = function (_EveObjectSet) { - _inherits(EveTurretSet, _EveObjectSet); - - function EveTurretSet() { - _classCallCheck(this, EveTurretSet); - - var _this2 = _possibleConstructorReturn(this, (EveTurretSet.__proto__ || Object.getPrototypeOf(EveTurretSet)).call(this)); - - _this2.visible = {}; - _this2.visible.turrets = true; - _this2.visible.firingEffects = true; - _this2.activeAnimation = new _core.Tw2AnimationController(); - _this2.inactiveAnimation = new _core.Tw2AnimationController(); - _this2.geometryResPath = ''; - _this2.geometryResource = null; - _this2.turretEffect = null; - _this2.firingEffectResPath = ''; - _this2.firingEffect = null; - _this2.fireCallback = null; - _this2.fireCallbackPending = false; - _this2.state = EveTurretSet.State.IDLE; - _this2.bottomClipHeight = 0; - _this2.locatorName = ''; - _this2.sysBoneHeight = 0; - _this2.hasCyclingFiringPos = false; - _this2.targetPosition = _math.vec3.create(); - _this2.parentMatrix = _math.mat4.create(); - _this2.boundingSphere = _math.quat.create(); - _this2._activeTurret = -1; - _this2._recheckTimeLeft = 0; - _this2._currentCyclingFiresPos = 0; - - _this2._perObjectDataActive = new _core.Tw2PerObjectData(); - _this2._perObjectDataActive.perObjectVSData = new _core.Tw2RawData(); - _this2._perObjectDataActive.perObjectVSData.Declare('baseCutoffData', 4); - _this2._perObjectDataActive.perObjectVSData.Declare('turretSetData', 4); - _this2._perObjectDataActive.perObjectVSData.Declare('shipMatrix', 16); - _this2._perObjectDataActive.perObjectVSData.Declare('turretTranslation', 4 * 24); - _this2._perObjectDataActive.perObjectVSData.Declare('turretRotation', 4 * 24); - _this2._perObjectDataActive.perObjectVSData.Declare('turretPoseTransAndRot', 2 * 4 * 72); - _this2._perObjectDataActive.perObjectVSData.Create(); - - _this2._perObjectDataInactive = new _core.Tw2PerObjectData(); - _this2._perObjectDataInactive.perObjectVSData = new _core.Tw2RawData(); - _this2._perObjectDataInactive.perObjectVSData.Declare('baseCutoffData', 4); - _this2._perObjectDataInactive.perObjectVSData.Declare('turretSetData', 4); - _this2._perObjectDataInactive.perObjectVSData.Declare('shipMatrix', 16); - _this2._perObjectDataInactive.perObjectVSData.Declare('turretTranslation', 4 * 24); - _this2._perObjectDataInactive.perObjectVSData.Declare('turretRotation', 4 * 24); - _this2._perObjectDataInactive.perObjectVSData.Declare('turretPoseTransAndRot', 2 * 4 * 72); - _this2._perObjectDataInactive.perObjectVSData.Create(); - - _this2._locatorRebuildPending = true; - return _this2; - } - - /** - * Alias for this.items - * @returns {Array} - */ - - - _createClass(EveTurretSet, [{ - key: 'Initialize', - /** - * Initializes the Turret Set + * Rebinds the emitter's generators to it's particle system */ - value: function Initialize() { - var _this3 = this; - if (this.turretEffect && this.geometryResPath !== '') { - this.geometryResource = _core.resMan.GetResource(this.geometryResPath); - this.activeAnimation.SetGeometryResource(this.geometryResource); - this.inactiveAnimation.SetGeometryResource(this.geometryResource); - if (this.geometryResource) this.geometryResource.RegisterNotification(this); - } + }, { + key: 'Rebind', + value: function Rebind() { + this.isValid = false; + if (!this.particleSystem) return; - if (this.firingEffectResPath !== '') { - _core.resMan.GetObject(this.firingEffectResPath, function (object) { - return _this3.firingEffect = object; - }); + for (var i = 0; i < this.generators.length; ++i) { + if (!this.generators[i].Bind(this.particleSystem)) return; } - this.Rebuild(); + this.isValid = true; } /** - * Initializes turret set's firing effect + * Spawn particles + * @param position + * @param velocity + * @param rateModifier */ }, { - key: 'InitializeFiringEffect', - value: function InitializeFiringEffect() { - if (!this.firingEffect) return; + key: 'SpawnParticles', + value: function SpawnParticles(position, velocity, rateModifier) { + if (!this.isValid) return; - if (this.geometryResource && this.geometryResource.models.length) { - var model = this.geometryResource.models[0]; - for (var i = 0; i < this.firingEffect.GetPerMuzzleEffectCount(); ++i) { - this.firingEffect.SetMuzzleBoneID(i, model.FindBoneByName(EveTurretSet.positionBoneSkeletonNames[i])); + this._accumulatedRate += this.rate * rateModifier; + var count = Math.floor(this._accumulatedRate); + this._accumulatedRate -= count; + + for (var i = 0; i < count; ++i) { + var index = this.particleSystem.BeginSpawnParticle(); + if (index === null) break; + + for (var j = 0; j < this.generators.length; ++j) { + this.generators[j].Generate(position, velocity, index); } + + this.particleSystem.EndSpawnParticle(); } } + }]); - /** - * Helper function for finding out what turret should be firing - * @returns {number} - */ + return Tw2DynamicEmitter; +}(_Tw2ParticleEmitter2.Tw2ParticleEmitter); - }, { - key: 'GetClosestTurret', - value: function GetClosestTurret() { - var closestTurret = -1, - closestAngle = -2; +/***/ }), +/* 189 */ +/***/ (function(module, exports, __webpack_require__) { - var g = EveTurretSet.global, - nrmToTarget = g.vec3_0, - nrmUp = g.vec4_0, - turretPosition = g.vec4_1; +"use strict"; - for (var i = 0; i < this.items.length; ++i) { - var item = this.items[i]; - if (!item.display && !item.canFireWhenHidden) continue; - turretPosition[0] = item._localTransform[12]; - turretPosition[1] = item._localTransform[13]; - turretPosition[2] = item._localTransform[14]; - turretPosition[3] = 1; - _math.vec4.transformMat4(turretPosition, turretPosition, this.parentMatrix); - _math.vec3.subtract(nrmToTarget, this.targetPosition, turretPosition); - _math.vec3.normalize(nrmToTarget, nrmToTarget); - _math.vec4.set(nrmUp, 0, 1, 0, 0); - _math.vec4.transformMat4(nrmUp, nrmUp, item._localTransform); - _math.vec4.transformMat4(nrmUp, nrmUp, this.parentMatrix); - var angle = _math.vec3.dot(nrmUp, nrmToTarget); - if (angle > closestAngle) { - closestTurret = this.items.indexOf(item); - closestAngle = angle; - } - } +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tr2GpuUniqueEmitter = exports.Tw2GpuUniqueEmitter = undefined; - return closestTurret; - } +var _global = __webpack_require__(0); - /** - * Animation helper function for deactivating a turret set - */ +var _Tw2ParticleEmitter2 = __webpack_require__(27); - }, { - key: 'EnterStateDeactive', - value: function EnterStateDeactive() { - var _this4 = this; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - if (this.state === EveTurretSet.State.INACTIVE || this.state === EveTurretSet.State.PACKING) return; +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - if (this.turretEffect) { - this.activeAnimation.StopAllAnimations(); - this.inactiveAnimation.StopAllAnimations(); +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - this.activeAnimation.PlayAnimation('Pack', false, function () { - _this4.state = EveTurretSet.State.INACTIVE; - _this4.activeAnimation.PlayAnimation('Inactive', true); - }); +/** + * Tr2GpuUniqueEmitter - not implemented yet + * + * @property {number} angle + * @property {number} innerAngle + * @property {number} drag + * @property {number} rate + * @property {number} radius + * @property {number} gravity + * @property {number} maxSpeed + * @property {number} minSpeed + * @property {number} minLifeTime + * @property {number} maxLifeTime + * @property {number} sizeVariance + * @property {vec3} attractorPosition + * @property {number} attractorStrength + * @property {number} textureIndex + * @property {number} turbulenceAmplitude + * @property {number} turbulenceFrequency + * @property {vec3} sizes + * @property {vec4} color0 + * @property {vec4} color1 + * @property {vec4} color2 + * @property {vec4} color3 + * @class + */ +var Tw2GpuUniqueEmitter = exports.Tw2GpuUniqueEmitter = function (_Tw2ParticleEmitter) { + _inherits(Tw2GpuUniqueEmitter, _Tw2ParticleEmitter); - this.inactiveAnimation.PlayAnimation('Pack', false, function () { - _this4.state = EveTurretSet.State.INACTIVE; - _this4.inactiveAnimation.PlayAnimation('Inactive', true); - }); + function Tw2GpuUniqueEmitter() { + _classCallCheck(this, Tw2GpuUniqueEmitter); - this.state = EveTurretSet.State.PACKING; - } else { - this.state = EveTurretSet.State.INACTIVE; - } + var _this = _possibleConstructorReturn(this, (Tw2GpuUniqueEmitter.__proto__ || Object.getPrototypeOf(Tw2GpuUniqueEmitter)).call(this)); - this._activeTurret = -1; + _this.angle = 0; + _this.innerAngle = 0; + _this.drag = 0; + _this.rate = 0; + _this.radius = 0; + _this.gravity = 0; + _this.maxSpeed = 0; + _this.minSpeed = 0; + _this.minLifeTime = 0; + _this.maxLifeTime = 0; + _this.sizeVariance = 0; + _this.attractorPosition = _global.vec3.create(); + _this.attractorStrength = 0; + _this.turbulenceAmplitude = 0; + _this.turbulenceFrequency = 0; + _this.textureIndex = 0; + _this.sizes = _global.vec3.create(); + _this.position = _global.vec3.create(); + _this.color0 = _global.vec4.create(); + _this.color1 = _global.vec4.create(); + _this.color2 = _global.vec4.create(); + _this.color3 = _global.vec4.create(); - if (this.firingEffect) { - this.firingEffect.StopFiring(); - } - } + //this.maxDisplacement=null; + //this.emissionDensity=null; + //this.velocityStretchRotation=null; + //this.inheritVelocity=null; + return _this; + } - /** - * Animation helper function for putting a turret set into idle state - */ + return Tw2GpuUniqueEmitter; +}(_Tw2ParticleEmitter2.Tw2ParticleEmitter); - }, { - key: 'EnterStateIdle', - value: function EnterStateIdle() { - var _this5 = this; +// Temporary alias - if (this.state === EveTurretSet.State.IDLE || this.state === EveTurretSet.State.UNPACKING) return; - if (this.turretEffect) { - this.activeAnimation.StopAllAnimations(); - this.inactiveAnimation.StopAllAnimations(); +exports.Tr2GpuUniqueEmitter = Tw2GpuUniqueEmitter; - if (this.state === EveTurretSet.State.FIRING) { - this.activeAnimation.PlayAnimation('Active', true); - this.inactiveAnimation.PlayAnimation('Active', true); - } else { - this.activeAnimation.PlayAnimation('Deploy', false, function () { - _this5.state = EveTurretSet.State.IDLE; - _this5.activeAnimation.PlayAnimation('Active', true); - }); +/***/ }), +/* 190 */ +/***/ (function(module, exports, __webpack_require__) { - this.inactiveAnimation.PlayAnimation('Deploy', false, function () { - _this5.state = EveTurretSet.State.IDLE; - _this5.inactiveAnimation.PlayAnimation('Active', true); - }); - } +"use strict"; - this.state = EveTurretSet.State.UNPACKING; - } else { - this.state = EveTurretSet.State.IDLE; - } - this._activeTurret = -1; +Object.defineProperty(exports, "__esModule", { + value: true +}); - if (this.firingEffect) { - this.firingEffect.StopFiring(); - } - } +var _Tw2ParticleAttractorForce = __webpack_require__(191); - /** - * Animation helper function for putting a turret set into a firing state - */ +Object.keys(_Tw2ParticleAttractorForce).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2ParticleAttractorForce[key]; + } + }); +}); - }, { - key: 'EnterStateFiring', - value: function EnterStateFiring() { - var _this6 = this; +var _Tw2ParticleDirectForce = __webpack_require__(192); - if (!this.turretEffect || this.state === EveTurretSet.State.FIRING) { - EveTurretSet.DoStartFiring(this); - if (this.turretEffect) { - this.activeAnimation.PlayAnimation('Fire', false, function () { - _this6.activeAnimation.PlayAnimation('Active', true); - }); - } - return; - } +Object.keys(_Tw2ParticleDirectForce).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2ParticleDirectForce[key]; + } + }); +}); - this.activeAnimation.StopAllAnimations(); - this.inactiveAnimation.StopAllAnimations(); - if (this.state === EveTurretSet.State.INACTIVE) { - this.activeAnimation.PlayAnimation('Deploy', false, function () { - EveTurretSet.DoStartFiring(_this6); - _this6.activeAnimation.PlayAnimation('Fire', false, function () { - _this6.activeAnimation.PlayAnimation('Active', true); - }); - }); +var _Tw2ParticleDragForce = __webpack_require__(193); - this.inactiveAnimation.PlayAnimation('Deploy', false, function () { - _this6.inactiveAnimation.PlayAnimation('Active', true); - }); - this.state = EveTurretSet.State.UNPACKING; - } else { - EveTurretSet.DoStartFiring(this); - this.activeAnimation.PlayAnimation('Fire', false, function () { - _this6.activeAnimation.PlayAnimation('Active', true); - }); +Object.keys(_Tw2ParticleDragForce).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2ParticleDragForce[key]; + } + }); +}); + +var _Tw2ParticleFluidDragForce = __webpack_require__(194); + +Object.keys(_Tw2ParticleFluidDragForce).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2ParticleFluidDragForce[key]; + } + }); +}); + +var _Tw2ParticleSpring = __webpack_require__(195); + +Object.keys(_Tw2ParticleSpring).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2ParticleSpring[key]; + } + }); +}); - this.inactiveAnimation.PlayAnimation('Active', true); - } - } +var _Tw2ParticleTurbulenceForce = __webpack_require__(196); - /** - * Rebuilds the turret sets cached data - */ +Object.keys(_Tw2ParticleTurbulenceForce).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2ParticleTurbulenceForce[key]; + } + }); +}); - }, { - key: 'RebuildCachedData', - value: function RebuildCachedData() { - var instancedElement = new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 1, _core.device.gl.FLOAT, 2), - meshes = this.geometryResource.meshes, - active = this.activeAnimation, - inactive = this.inactiveAnimation; +/***/ }), +/* 191 */ +/***/ (function(module, exports, __webpack_require__) { - for (var i = 0; i < meshes.length; ++i) { - meshes[i].declaration.elements.push(instancedElement); - meshes[i].declaration.RebuildHash(); - } +"use strict"; - switch (this.state) { - case EveTurretSet.State.INACTIVE: - active.PlayAnimation('Inactive', true); - inactive.PlayAnimation('Inactive', true); - break; - case EveTurretSet.State.IDLE: - active.PlayAnimation('Active', true); - inactive.PlayAnimation('Active', true); - break; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2ParticleAttractorForce = undefined; - case EveTurretSet.State.FIRING: - active.PlayAnimation('Fire', false, function () { - return active.PlayAnimation('Active', true); - }); - inactive.PlayAnimation('Active', true); - break; +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - case EveTurretSet.State.PACKING: - this.EnterStateIdle(); - break; +var _global = __webpack_require__(0); - case EveTurretSet.State.UNPACKING: - this.EnterStateDeactive(); - break; - } - } +var _Tw2ParticleForce2 = __webpack_require__(12); - /** - * Finds a turret item by name - * @param {string} name - * @returns {?EveTurretSetItem} - */ +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - }, { - key: 'FindItemByLocatorName', - value: function FindItemByLocatorName(name) { - for (var i = 0; i < this.items.length; i++) { - if (this.items[i].locatorName === name) { - return this.items[i]; - } - } - return null; - } +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - /** - * Updates the turret set's items that were created from locators - * - Turrets without locator names are ignored - * @param {Array} locators - */ +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - }, { - key: 'UpdateItemsFromLocators', - value: function UpdateItemsFromLocators(locators) { - var g = EveTurretSet.global, - toRemove = Array.from(this.items), - norm = g.mat4_0; +/** + * Tw2ParticleAttractorForce + * + * @property {number} magnitude + * @property {vec3} position + * @property {vec3} _tempVec + * @inherits Tw2ParticleForce + * @class + */ +var Tw2ParticleAttractorForce = exports.Tw2ParticleAttractorForce = function (_Tw2ParticleForce) { + _inherits(Tw2ParticleAttractorForce, _Tw2ParticleForce); - for (var i = 0; i < locators.length; i++) { - var _locators$i = locators[i], - name = _locators$i.name, - transform = _locators$i.transform, - _locators$i$bone = _locators$i.bone, - bone = _locators$i$bone === undefined ? null : _locators$i$bone; + function Tw2ParticleAttractorForce() { + _classCallCheck(this, Tw2ParticleAttractorForce); + var _this = _possibleConstructorReturn(this, (Tw2ParticleAttractorForce.__proto__ || Object.getPrototypeOf(Tw2ParticleAttractorForce)).call(this)); - var item = this.FindItemByLocatorName(name); - if (!item) { - item = this.CreateItem({ - name: name, - locatorName: name, - updateFromLocator: true - }); - } else { - toRemove.splice(toRemove.indexOf(item), 1); - } + _this.magnitude = 0; + _this.position = _global.vec3.create(); + return _this; + } - if (item.updateFromLocator) { - item.bone = bone; - _math.mat4.copy(norm, transform); - _math.vec3.normalize(norm.subarray(0, 3), norm.subarray(0, 3)); - _math.vec3.normalize(norm.subarray(4, 7), norm.subarray(4, 7)); - _math.vec3.normalize(norm.subarray(8, 11), norm.subarray(8, 11)); - _math.mat4.getRotation(item.rotation, norm); - _math.mat4.getTranslation(item.position, norm); - item.OnValueChanged(); - } - } + /** + * ApplyForce + * @param {Tw2ParticleElement} position + * @param {Tw2ParticleElement} velocity + * @param {Tw2ParticleElement} force + */ - for (var _i = 0; _i < toRemove.length; _i++) { - if (toRemove[_i].locatorName) { - this.RemoveItem(toRemove[_i]); - _i--; - } - } - this._locatorRebuildPending = false; - if (this._rebuildPending) this.Rebuild(); - } + _createClass(Tw2ParticleAttractorForce, [{ + key: 'ApplyForce', + value: function ApplyForce(position, velocity, force) { + var vec3_0 = _Tw2ParticleForce2.Tw2ParticleForce.global.vec3_0; - /** - * Rebuilds the turret set's items from it's parent's locators - */ + vec3_0[0] = this.position[0] - position.buffer[position.offset]; + vec3_0[1] = this.position[1] - position.buffer[position.offset + 1]; + vec3_0[2] = this.position[2] - position.buffer[position.offset + 2]; - }, { - key: 'RebuildItemsFromLocators', - value: function RebuildItemsFromLocators() { - this._locatorRebuildPending = true; + _global.vec3.normalize(vec3_0, vec3_0); + _global.vec3.scale(vec3_0, vec3_0, this.magnitude); + _global.vec3.add(force, force, vec3_0); } + }]); - /** - * Gets turret set res objects - * @param {Array} [out=[]] - Optional receiving array - * @returns {Array.} [out] - */ + return Tw2ParticleAttractorForce; +}(_Tw2ParticleForce2.Tw2ParticleForce); - }, { - key: 'GetResources', - value: function GetResources() { - var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; +/***/ }), +/* 192 */ +/***/ (function(module, exports, __webpack_require__) { - if (this.geometryResource && !out.includes(this.geometryResource)) { - out.push(this.geometryResource); - } +"use strict"; - if (this.turretEffect) { - this.turretEffect.GetResources(out); - } - if (this.firingEffect) { - this.firingEffect.GetResources(out); - } +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2ParticleDirectForce = undefined; - return out; - } +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - /** - * Updates view dependent data - */ +var _global = __webpack_require__(0); - }, { - key: 'UpdateViewDependentData', - value: function UpdateViewDependentData() { - if (this.firingEffect) { - this.firingEffect.UpdateViewDependentData(); - } - } +var _Tw2ParticleForce2 = __webpack_require__(12); - /** - * Per frame update - * @param {number} dt - Delta Time - * @param {mat4} parentMatrix - */ +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - }, { - key: 'Update', - value: function Update(dt, parentMatrix) { - if (this._rebuildPending) { - this.Rebuild(); - } +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - if (this.turretEffect) { - this.activeAnimation.Update(dt); - this.inactiveAnimation.Update(dt); - } +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - _math.mat4.copy(this.parentMatrix, parentMatrix); +/** + * Tw2ParticleDirectForce + * + * @property {vec3} force + * @inherits Tw2ParticleForce + * @class + */ +var Tw2ParticleDirectForce = exports.Tw2ParticleDirectForce = function (_Tw2ParticleForce) { + _inherits(Tw2ParticleDirectForce, _Tw2ParticleForce); - if (this.firingEffect && this._visibleItems.length) { - if (this._activeTurret !== -1) { - if (this.firingEffect.isLoopFiring) { - if (this.state === EveTurretSet.State.FIRING) { - this._recheckTimeLeft -= dt; - if (this._recheckTimeLeft <= 0) { - EveTurretSet.DoStartFiring(this); - } - } - } + function Tw2ParticleDirectForce() { + _classCallCheck(this, Tw2ParticleDirectForce); - var activeItem = this.items[this._activeTurret]; + var _this = _possibleConstructorReturn(this, (Tw2ParticleDirectForce.__proto__ || Object.getPrototypeOf(Tw2ParticleDirectForce)).call(this)); - if (this.activeAnimation.models.length) { - var bones = this.activeAnimation.models[0].bonesByName; - for (var i = 0; i < this.firingEffect.GetPerMuzzleEffectCount(); ++i) { - var transform = bones[EveTurretSet.positionBoneSkeletonNames[i]].worldTransform, - out = this.firingEffect.GetMuzzleTransform(i); + _this.force = _global.vec3.create(); + return _this; + } - _math.mat4.multiply(out, activeItem._localTransform, transform); - _math.mat4.multiply(out, out, parentMatrix); - } - } else { - for (var _i2 = 0; _i2 < this.firingEffect.GetPerMuzzleEffectCount(); ++_i2) { - _math.mat4.multiply(this.firingEffect.GetMuzzleTransform(_i2), parentMatrix, activeItem._localTransform); - } - } + /** + * ApplyForce + * @param {Tw2ParticleElement} position + * @param {Tw2ParticleElement} velocity + * @param {Tw2ParticleElement} force + */ - if (this.fireCallbackPending) { - if (this.fireCallback) { - var cbTransforms = []; - for (var _i3 = 0; _i3 < this.firingEffect.GetPerMuzzleEffectCount(); ++_i3) { - cbTransforms.push(this.firingEffect.GetMuzzleTransform(_i3)); - } - this.fireCallback(this, cbTransforms); - } - this.fireCallbackPending = false; - } - } - _math.vec3.copy(this.firingEffect.endPosition, this.targetPosition); - this.firingEffect.Update(dt); - } + _createClass(Tw2ParticleDirectForce, [{ + key: 'ApplyForce', + value: function ApplyForce(position, velocity, force) { + _global.vec3.add(force, force, this.force); } + }]); - /** - * Gets turret set render batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator - * @param {Tw2PerObjectData} perObjectData - * @param {boolean} [hideFiringEffect] - */ + return Tw2ParticleDirectForce; +}(_Tw2ParticleForce2.Tw2ParticleForce); - }, { - key: 'GetBatches', - value: function GetBatches(mode, accumulator, perObjectData, hideFiringEffect) { - if (!this.turretEffect || !this.geometryResource || !this.display || !this._visibleItems.length) return; +/***/ }), +/* 193 */ +/***/ (function(module, exports, __webpack_require__) { - if (mode === _core.device.RM_OPAQUE && this.visible.turrets) { - var transforms = this.inactiveAnimation.GetBoneMatrices(0); - if (transforms.length !== 0) { - EveTurretSet.UpdatePerObjectData(this, this._perObjectDataInactive.perObjectVSData, transforms); - this._perObjectDataInactive.perObjectPSData = perObjectData.perObjectPSData; +"use strict"; - var batch = new _core.Tw2ForwardingRenderBatch(); - batch.renderMode = mode; - batch.renderActive = false; - batch.perObjectData = this._perObjectDataInactive; - batch.geometryProvider = this; - accumulator.Commit(batch); - if (this.state === EveTurretSet.State.FIRING) { - var _transforms = this.activeAnimation.GetBoneMatrices(0); - if (_transforms.length !== 0) { - EveTurretSet.UpdatePerObjectData(this, this._perObjectDataActive.perObjectVSData, _transforms, true); - this._perObjectDataActive.perObjectPSData = perObjectData.perObjectPSData; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2ParticleDragForce = undefined; - var _batch = new _core.Tw2ForwardingRenderBatch(); - _batch.renderActive = true; - _batch.perObjectData = this._perObjectDataActive; - _batch.geometryProvider = this; - accumulator.Commit(_batch); - } - } - } - } +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - this.GetFiringEffectBatches(mode, accumulator, perObjectData, hideFiringEffect); - } +var _Tw2ParticleForce2 = __webpack_require__(12); - /** - * Gets turret firing effect batches - * @param {number} mode - * @param {Tw2BatchAccumulator} accumulator - * @param {Tw2PerObjectData} perObjectData - * @param {boolean} [hideFiringEffect] - */ +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - }, { - key: 'GetFiringEffectBatches', - value: function GetFiringEffectBatches(mode, accumulator, perObjectData, hideFiringEffect) { - if (this.firingEffect && this.display && this._visibleItems.length && this.visible.firingEffects && !hideFiringEffect) { - this.firingEffect.GetBatches(mode, accumulator, perObjectData); - } - } +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - /** - * Renders the turret set - * @param batch - * @param {string} technique - technique name - * @returns {boolean} - */ +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - }, { - key: 'Render', - value: function Render(batch, technique) { - if (!this.turretEffect || !this.turretEffect.IsGood() || !this._visibleItems.length) return false; +/** + * Tw2ParticleDragForce + * + * @property {number} drag + * @inherits Tw2ParticleForce + * @class + */ +var Tw2ParticleDragForce = exports.Tw2ParticleDragForce = function (_Tw2ParticleForce) { + _inherits(Tw2ParticleDragForce, _Tw2ParticleForce); - var index = 0; - var customSetter = function customSetter(el) { - _core.device.gl.disableVertexAttribArray(el.location); - _core.device.gl.vertexAttrib2f(el.location, index, index); - }; + function Tw2ParticleDragForce() { + _classCallCheck(this, Tw2ParticleDragForce); - for (var i = 0; i < this.geometryResource.meshes.length; ++i) { - var decl = this.geometryResource.meshes[i].declaration; - decl.FindUsage(_core.Tw2VertexDeclaration.Type.TEXCOORD, 1).customSetter = customSetter; - } + var _this = _possibleConstructorReturn(this, (Tw2ParticleDragForce.__proto__ || Object.getPrototypeOf(Tw2ParticleDragForce)).call(this)); - var rendered = 0; - for (; index < this.items.length; ++index) { - if (this.items[index].display) { - var isActive = this.state === EveTurretSet.State.FIRING && index === this._activeTurret; - if (batch.renderActive === isActive) { - this.geometryResource.RenderAreas(0, 0, 1, this.turretEffect, technique); - rendered++; - } - } - } + _this.drag = 0.1; + return _this; + } - return !!rendered; - } + /** + * Applies forces + * @param {Tw2ParticleElement} position + * @param {Tw2ParticleElement} velocity + * @param {Tw2ParticleElement} force + */ - /** - * Rebuilds the set's items - * - * @param {EveTurretSet} turretSet - */ - }, { - key: 'turrets', - get: function get() { - return this.items; + _createClass(Tw2ParticleDragForce, [{ + key: 'ApplyForce', + value: function ApplyForce(position, velocity, force) { + force[0] += velocity.buffer[velocity.offset] * -this.drag; + force[1] += velocity.buffer[velocity.offset + 1] * -this.drag; + force[2] += velocity.buffer[velocity.offset + 2] * -this.drag; } + }]); - /** - * Alias for this.items - * @param {Array} arr - */ - , - set: function set(arr) { - this.items = arr; - } - }], [{ - key: 'RebuildItems', - value: function RebuildItems(turretSet) { - turretSet._visibleItems = []; + return Tw2ParticleDragForce; +}(_Tw2ParticleForce2.Tw2ParticleForce); - for (var i = 0; i < turretSet.items.length; i++) { - var item = turretSet.items[i]; - item._onModified = turretSet._onChildModified; +/***/ }), +/* 194 */ +/***/ (function(module, exports, __webpack_require__) { - if (item.display) { - turretSet._visibleItems.push(item); - if (item._rebuildPending) { - item.UpdateTransforms(); - item._rebuildPending = false; - } - } - } - } +"use strict"; - /** - * Updates per object data - * @param {EveTurretSet} turretSet - * @param {Tw2RawData} perObjectData - * @param transforms - * @param {boolean} [skipBoneCalculations] - */ - }, { - key: 'UpdatePerObjectData', - value: function UpdatePerObjectData(turretSet, perObjectData, transforms, skipBoneCalculations) { - _math.mat4.transpose(perObjectData.Get('shipMatrix'), turretSet.parentMatrix); - var transformCount = transforms.length / 12; - perObjectData.Get('turretSetData')[0] = transformCount; - perObjectData.Get('baseCutoffData')[0] = turretSet.bottomClipHeight; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2ParticleFluidDragForce = undefined; - var translation = perObjectData.Get('turretTranslation'), - rotation = perObjectData.Get('turretRotation'), - pose = perObjectData.Get('turretPoseTransAndRot'); +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - for (var i = 0; i < turretSet._visibleItems.length; ++i) { - var item = turretSet._visibleItems[i]; +var _global = __webpack_require__(0); - for (var j = 0; j < transformCount; ++j) { - pose[(i * transformCount + j) * 2 * 4] = transforms[j * 12 + 3]; - pose[(i * transformCount + j) * 2 * 4 + 1] = transforms[j * 12 + 7]; - pose[(i * transformCount + j) * 2 * 4 + 2] = transforms[j * 12 + 11]; - pose[(i * transformCount + j) * 2 * 4 + 3] = 1; - EveTurretSet.mat3x4toquat(transforms, j, pose, (i * transformCount + j) * 2 + 1); - } +var _Tw2ParticleForce2 = __webpack_require__(12); - if (item.bone && !skipBoneCalculations) { - item.UpdateTransforms(); - } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - translation[i * 4] = item._localTransform[12]; - translation[i * 4 + 1] = item._localTransform[13]; - translation[i * 4 + 2] = item._localTransform[14]; - translation[i * 4 + 3] = 1; +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - rotation[i * 4] = item.rotation[0]; - rotation[i * 4 + 1] = item.rotation[1]; - rotation[i * 4 + 2] = item.rotation[2]; - rotation[i * 4 + 3] = item.rotation[3]; - } - } +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +/** + * Tw2ParticleFluidDragForce + * + * @property {number} drag + * @property {vec3} _tempVec + * @property {vec3} _tempVec2 + * @inherits Tw2ParticleForce + * @class + */ +var Tw2ParticleFluidDragForce = exports.Tw2ParticleFluidDragForce = function (_Tw2ParticleForce) { + _inherits(Tw2ParticleFluidDragForce, _Tw2ParticleForce); + + function Tw2ParticleFluidDragForce() { + _classCallCheck(this, Tw2ParticleFluidDragForce); + + var _this = _possibleConstructorReturn(this, (Tw2ParticleFluidDragForce.__proto__ || Object.getPrototypeOf(Tw2ParticleFluidDragForce)).call(this)); + + _this.drag = 0.1; + return _this; + } + + /** + * Applies forces + * @param {Tw2ParticleElement} position + * @param {Tw2ParticleElement} velocity + * @param {Tw2ParticleElement} force + * @param {number} dt - delta time + * @param { number} mass + */ - /** - * Animation helper function for turret firing - * @param {EveTurretSet} turretSet - * @returns {EveTurretSetItem} the closest turret - */ - }, { - key: 'DoStartFiring', - value: function DoStartFiring(turretSet) { - if (turretSet.hasCyclingFiringPos) { - turretSet._currentCyclingFiresPos = 1 - turretSet._currentCyclingFiresPos; - } + _createClass(Tw2ParticleFluidDragForce, [{ + key: 'ApplyForce', + value: function ApplyForce(position, velocity, force, dt, mass) { + var vec3_0 = _Tw2ParticleForce2.Tw2ParticleForce.global.vec3_0, + vec3_1 = _Tw2ParticleForce2.Tw2ParticleForce.global.vec3_1, + speed = Math.sqrt(velocity.buffer[velocity.offset] * velocity.buffer[velocity.offset] + velocity.buffer[velocity.offset + 1] * velocity.buffer[velocity.offset + 1] + velocity.buffer[velocity.offset + 2] * velocity.buffer[velocity.offset + 2]); - if (turretSet.firingEffect) { - turretSet.firingEffect.PrepareFiring(0, turretSet.hasCyclingFiringPos ? turretSet._currentCyclingFiresPos : -1); - } + vec3_0[0] = velocity.buffer[velocity.offset] * -speed * this.drag; + vec3_0[1] = velocity.buffer[velocity.offset + 1] * -speed * this.drag; + vec3_0[2] = velocity.buffer[velocity.offset + 2] * -speed * this.drag; - turretSet._activeTurret = turretSet.GetClosestTurret(); - turretSet.state = EveTurretSet.State.FIRING; - turretSet._recheckTimeLeft = 2; + _global.vec3.scale(vec3_1, vec3_0, dt * mass); + vec3_1[0] += velocity.buffer[velocity.offset]; + vec3_1[1] += velocity.buffer[velocity.offset + 1]; + vec3_1[2] += velocity.buffer[velocity.offset + 2]; - if (turretSet.fireCallback) { - turretSet.fireCallbackPending = true; + var dot = velocity.buffer[velocity.offset] * vec3_1[0] + velocity.buffer[velocity.offset + 1] * vec3_1[1] + velocity.buffer[velocity.offset + 2] * vec3_1[2]; + + if (dot < 0) { + force[0] = -velocity.buffer[velocity.offset] / dt / mass; + force[1] = -velocity.buffer[velocity.offset + 1] / dt / mass; + force[2] = -velocity.buffer[velocity.offset + 2] / dt / mass; + } else { + _global.vec3.copy(force, vec3_0); } } }]); - return EveTurretSet; -}(_EveObjectSet2.EveObjectSet); + return Tw2ParticleFluidDragForce; +}(_Tw2ParticleForce2.Tw2ParticleForce); -/** - * mat3x4 to quat - */ +/***/ }), +/* 195 */ +/***/ (function(module, exports, __webpack_require__) { +"use strict"; -EveTurretSet.mat3x4toquat = function () { - var m = void 0, - q = void 0; - return function mat3x4toquat(mm, index, out, outIndex) { - if (!m) { - m = _math.mat4.create(); - q = _math.quat.create(); - } +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2ParticleSpring = undefined; - index *= 12; - outIndex *= 4; +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - m[0] = mm[index]; - m[1] = mm[index + 4]; - m[2] = mm[index + 8]; - m[3] = 0; - m[4] = mm[index + 1]; - m[5] = mm[index + 5]; - m[6] = mm[index + 9]; - m[7] = 0; - m[8] = mm[index + 2]; - m[9] = mm[index + 6]; - m[10] = mm[index + 10]; - m[11] = 0; - m[12] = mm[index + 3]; - m[13] = mm[index + 7]; - m[14] = mm[index + 11]; - m[15] = 1; +var _global = __webpack_require__(0); - _math.mat4.getRotation(q, m); - out[outIndex] = q[0]; - out[outIndex + 1] = q[1]; - out[outIndex + 2] = q[2]; - out[outIndex + 3] = q[3]; - }; -}(); +var _Tw2ParticleForce2 = __webpack_require__(12); -/** - * The eve turret set's item constructor - * @type {EveTurretSetItem} - */ -EveTurretSet.Item = EveTurretSetItem; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -/** - * Turret states - * @type {{INACTIVE: number, IDLE: number, FIRING: number, PACKING: number, UNPACKING: number}} - */ -EveTurretSet.State = { - INACTIVE: 0, - IDLE: 1, - FIRING: 2, - PACKING: 2, - UNPACKING: 4 -}; +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } -/** - * World turret bone names - * @type {string[]} - */ -EveTurretSet.worldNames = ['turretWorld0', 'turretWorld1', 'turretWorld2']; +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** - * Bone Skeleton Names - * @type {string[]} + * Tw2ParticleSpring + * + * @property {number} springConstant + * @property {vec3} position + * @inherits Tw2ParticleForce + * @class */ -EveTurretSet.positionBoneSkeletonNames = ['Pos_Fire01', 'Pos_Fire02', 'Pos_Fire03', 'Pos_Fire04', 'Pos_Fire05', 'Pos_Fire06', 'Pos_Fire07', 'Pos_Fire08']; +var Tw2ParticleSpring = exports.Tw2ParticleSpring = function (_Tw2ParticleForce) { + _inherits(Tw2ParticleSpring, _Tw2ParticleForce); + + function Tw2ParticleSpring() { + _classCallCheck(this, Tw2ParticleSpring); + + var _this = _possibleConstructorReturn(this, (Tw2ParticleSpring.__proto__ || Object.getPrototypeOf(Tw2ParticleSpring)).call(this)); + + _this.springConstant = 0; + _this.position = _global.vec3.create(); + return _this; + } + + /** + * Applies forces + * @param {Tw2ParticleElement} position + * @param {Tw2ParticleElement} velocity + * @param {Tw2ParticleElement} force + */ + + + _createClass(Tw2ParticleSpring, [{ + key: 'ApplyForce', + value: function ApplyForce(position, velocity, force) { + force[0] += (this.position[0] - position.buffer[position.offset]) * this.springConstant; + force[1] += (this.position[1] - position.buffer[position.offset + 1]) * this.springConstant; + force[2] += (this.position[2] - position.buffer[position.offset + 2]) * this.springConstant; + } + }]); + + return Tw2ParticleSpring; +}(_Tw2ParticleForce2.Tw2ParticleForce); /***/ }), -/* 195 */ +/* 196 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -40812,584 +41521,489 @@ EveTurretSet.positionBoneSkeletonNames = ['Pos_Fire01', 'Pos_Fire02', 'Pos_Fire0 Object.defineProperty(exports, "__esModule", { value: true }); -exports.EveSpaceScene = undefined; +exports.Tw2ParticleTurbulenceForce = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _math = __webpack_require__(0); +var _global = __webpack_require__(0); -var _core = __webpack_require__(1); +var _Tw2ParticleForce2 = __webpack_require__(12); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + /** - * EveSpaceScene + * Tw2ParticleTurbulenceForce * - * @property {number|string} _id - * @property {string} name - * @property {boolean} display - * @property {{}} visible - * @property {boolean} visible.lensflare - * @property {boolean} visible.objects - * @property {boolean} visible.planets - * @property {boolean} visible.fog - * @property {boolean} visible.clearColor - * @property {boolean} visible.nebula - * @property {Array.} lensflares - Scene lensflares - * @property {Array.<*>} objects - Scene objects - * @property {Array.} planets - Scene planets - * @property {number} nebulaIntensity - controls nebula intensity on scene objects - * @property {vec4} ambientColor - unused - * @property {null|Tw2Effect} backgroundEffect - * @property {number} backgroundRenderingEnabled - Toggles background effect visibility - * @property {vec3} endMapScaling - controls the scale of the environment maps - * @property {quat} envMapRotation - controls the rotation of the environment maps - * @property {boolean} logEnabled - toggles LOD - * @property {number} fogStart - fog start distance - * @property {number} fogEnd - fog end distance - * @property {number} fogMax - fog maximum opacity - * @property {number} fogType - fog blend type - * @property {number} fogBlur - fog blur mode - * @property {vec4} fogColor - fog color - * @property {vec3} sunDirection - the direction of the scene sun - * @property {vec4} sunDiffuseColor - the colour of the light from the sun - * @property {String} envMapResPath - nebula reflection map path - * @property {String} envMap1ResPath - nebula diffuse map path - * @property {String} envMap2ResPath - nebular blur map path - * @property {String} envMap3ResPath - unused - * @property {null|Tw2TextureRes} envMapRes - * @property {null|Tw2TextureRes} envMap1Res - * @property {null|Tw2TextureRes} envMap2Res - * @property {null} envMap3Res - unused - * @property {Tw2BatchAccumulator} _batches - Scene batch accumulator - * @property {Tw2RawData} _perFrameVS - * @property {Tw2RawData} _perFramePS - * @property {boolean} renderDebugInfo - * @property {*} _debugHelper + * @property {number} noiseLevel + * @property {number} noiseRatio + * @property {vec3} amplitude + * @property {quat} frequency + * @property {number} _time + * @inherits Tw2ParticleForce * @class */ -var EveSpaceScene = exports.EveSpaceScene = function () { - function EveSpaceScene() { - var _this = this; +var Tw2ParticleTurbulenceForce = exports.Tw2ParticleTurbulenceForce = function (_Tw2ParticleForce) { + _inherits(Tw2ParticleTurbulenceForce, _Tw2ParticleForce); - _classCallCheck(this, EveSpaceScene); + function Tw2ParticleTurbulenceForce() { + _classCallCheck(this, Tw2ParticleTurbulenceForce); - this._id = _math.util.generateID(); - this.name = ''; - this.display = true; - this.visible = {}; - this.visible.lensflares = true; - this.visible.objects = true; - this.visible.planets = true; - this.visible.fog = true; - this.visible.clearColor = true; - this.visible.environmentReflection = true; - this.visible.environmentDiffuse = true; - this.visible.environmentBlur = true; + var _this = _possibleConstructorReturn(this, (Tw2ParticleTurbulenceForce.__proto__ || Object.getPrototypeOf(Tw2ParticleTurbulenceForce)).call(this)); - Object.defineProperty(this.visible, 'environment', { - get: function get() { - return _this.backgroundRenderingEnabled; - }, - set: function set(bool) { - _this.backgroundRenderingEnabled = bool ? 1 : 0; - } - }); + _this.noiseLevel = 3; + _this.noiseRatio = 0.5; + _this.amplitude = _global.vec3.fromValues(1, 1, 1); + _this.frequency = _global.vec4.fromValues(1, 1, 1, 1); + _this._time = 0; + return _this; + } - this.lensflares = []; - this.objects = []; - this.planets = []; - this.nebulaIntensity = 1; - this.ambientColor = _math.quat.fromValues(0.25, 0.25, 0.25, 1); - this.backgroundEffect = null; - this.backgroundRenderingEnabled = 1; - this.clearColor = _math.vec4.fromValues(0, 0, 0, 0); - this.lodEnabled = false; - this.fogStart = 0; - this.fogEnd = 0; - this.fogMax = 0; - this.fogType = 0; - this.fogBlur = 0; - this.fogColor = _math.vec4.fromValues(0.25, 0.25, 0.25, 1); - this.sunDirection = _math.vec3.fromValues(1, -1, 1); - this.sunDiffuseColor = _math.vec4.fromValues(1, 1, 1, 1); - this.envMapScaling = _math.vec3.fromValues(1, 1, 1); - this.envMapRotation = _math.quat.create(); - this.envMapResPath = ''; - this.envMap1ResPath = ''; - this.envMap2ResPath = ''; - this.envMap3ResPath = ''; - this.envMapRes = null; - this.envMap1Res = null; - this.envMap2Res = null; - this.envMap3Res = null; - this.renderDebugInfo = false; - this._debugHelper = null; + /** + * ApplyForce + * @param {Tw2ParticleElement} position + * @param {Tw2ParticleElement} velocity + * @param {Tw2ParticleElement} force + */ - this._batches = new _core.Tw2BatchAccumulator(); - this._perFrameVS = new _core.Tw2RawData(); - this._perFrameVS.Declare('ViewInverseTransposeMat', 16); - this._perFrameVS.Declare('ViewProjectionMat', 16); - this._perFrameVS.Declare('ViewMat', 16); - this._perFrameVS.Declare('ProjectionMat', 16); - this._perFrameVS.Declare('ShadowViewMat', 16); - this._perFrameVS.Declare('ShadowViewProjectionMat', 16); - this._perFrameVS.Declare('EnvMapRotationMat', 16); - this._perFrameVS.Declare('SunData.DirWorld', 4); - this._perFrameVS.Declare('SunData.DiffuseColor', 4); - this._perFrameVS.Declare('FogFactors', 4); - this._perFrameVS.Declare('TargetResolution', 4); - this._perFrameVS.Declare('ViewportAdjustment', 4); - this._perFrameVS.Declare('MiscSettings', 4); - this._perFrameVS.Create(); - this._perFramePS = new _core.Tw2RawData(); - this._perFramePS.Declare('ViewInverseTransposeMat', 16); - this._perFramePS.Declare('ViewMat', 16); - this._perFramePS.Declare('EnvMapRotationMat', 16); - this._perFramePS.Declare('SunData.DirWorld', 4); - this._perFramePS.Declare('SunData.DiffuseColor', 4); - this._perFramePS.Declare('SceneData.AmbientColor', 3); - this._perFramePS.Declare('SceneData.NebulaIntensity', 1); - this._perFramePS.Declare('SceneData.FogColor', 4); - this._perFramePS.Declare('ViewportOffset', 2); - this._perFramePS.Declare('ViewportSize', 2); - this._perFramePS.Declare('TargetResolution', 4); - this._perFramePS.Declare('ShadowMapSettings', 4); - this._perFramePS.Declare('ShadowCameraRange', 4); - this._perFramePS.Declare('ProjectionToView', 2); - this._perFramePS.Declare('FovXY', 2); - this._perFramePS.Declare('MiscSettings', 4); - this._perFramePS.Create(); + _createClass(Tw2ParticleTurbulenceForce, [{ + key: 'ApplyForce', + value: function ApplyForce(position, velocity, force) { + if (this.noiseLevel === 0) return; - EveSpaceScene.init(); - } + var pos_0 = position.buffer[position.offset] * this.frequency[0], + pos_1 = position.buffer[position.offset + 1] * this.frequency[1], + pos_2 = position.buffer[position.offset + 2] * this.frequency[2], + pos_3 = this._time * this.frequency[3]; - /** - * Initializes the space scene - */ + var sum = 0, + power = 0.5, + frequency = 1 / this.noiseRatio; + var out = _global.vec4.set(_Tw2ParticleForce2.Tw2ParticleForce.global.vec4_0, 0, 0, 0, 0); - _createClass(EveSpaceScene, [{ - key: 'Initialize', - value: function Initialize() { - this.SetEnvMapPath(0, this.envMapResPath); - this.SetEnvMapPath(1, this.envMap1ResPath); - this.SetEnvMapPath(2, this.envMap2ResPath); - this.SetEnvMapPath(3, this.envMap3ResPath); + for (var i = 0; i < this.noiseLevel; ++i) { + _global.noise.turbulence(out, pos_0, pos_1, pos_2, pos_3, power); + sum += power; + pos_0 *= frequency; + pos_1 *= frequency; + pos_2 *= frequency; + pos_3 *= frequency; + power *= this.noiseRatio; + } + + force[0] += out[0] * this.amplitude[0] * sum; + force[1] += out[1] * this.amplitude[1] * sum; + force[2] += out[2] * this.amplitude[2] * sum; } /** - * Sets the environment's reflection map - * @param {String} path + * Per frame update (Called before ApplyForce) + * @param {number} dt - delta Time */ }, { - key: 'SetEnvMapReflection', - value: function SetEnvMapReflection(path) { - this.SetEnvMapPath(0, path); + key: 'Update', + value: function Update(dt) { + this._time += dt; } + }]); - /** - * Sets the environment's diffuse map - * @param {string} path - */ + return Tw2ParticleTurbulenceForce; +}(_Tw2ParticleForce2.Tw2ParticleForce); - }, { - key: 'SetEnvMapDiffuse', - value: function SetEnvMapDiffuse(path) { - this.SetEnvMapPath(1, path); - } +/***/ }), +/* 197 */ +/***/ (function(module, exports, __webpack_require__) { - /** - * Sets the environment's blur map (used for fog) - * @param {string} path - */ +"use strict"; - }, { - key: 'SetEnvMapBlur', - value: function SetEnvMapBlur(path) { - this.SetEnvMapPath(2, path); - } - /** - * Sets an environment map - * @param {number} index - * @param {String} path - */ +Object.defineProperty(exports, "__esModule", { + value: true +}); - }, { - key: 'SetEnvMapPath', - value: function SetEnvMapPath(index, path) { - var _this2 = this; +var _Tw2RandomIntegerAttributeGenerator = __webpack_require__(198); - var _setEnvPath = function _setEnvPath(path, pathTarget, resTarget) { - path = path.toLowerCase(); - _this2[pathTarget] = path; - _this2[resTarget] = path === '' ? null : _core.resMan.GetResource(path); - return true; - }; +Object.keys(_Tw2RandomIntegerAttributeGenerator).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2RandomIntegerAttributeGenerator[key]; + } + }); +}); - switch (index) { - case 0: - // Reflection - return _setEnvPath(path, 'envMapResPath', 'envMapRes'); +var _Tw2RandomUniformAttributeGenerator = __webpack_require__(199); - case 1: - // Diffuse - return _setEnvPath(path, 'envMap1ResPath', 'envMap1Res'); +Object.keys(_Tw2RandomUniformAttributeGenerator).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2RandomUniformAttributeGenerator[key]; + } + }); +}); - case 2: - // Blur - return _setEnvPath(path, 'envMap2ResPath', 'envMap2Res'); +var _Tw2SphereShapeAttributeGenerator = __webpack_require__(200); - case 3: - // Unused - return _setEnvPath(path, 'envMap3ResPath', 'envMap3Res'); - } +Object.keys(_Tw2SphereShapeAttributeGenerator).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2SphereShapeAttributeGenerator[key]; + } + }); +}); - return false; - } +/***/ }), +/* 198 */ +/***/ (function(module, exports, __webpack_require__) { - /** - * Enables LOD - * @param {boolean} enable - */ +"use strict"; - }, { - key: 'EnableLod', - value: function EnableLod(enable) { - this.lodEnabled = enable; - if (!enable) { - for (var i = 0; i < this.objects.length; ++i) { - if (this.objects[i].ResetLod) { - this.objects[i].ResetLod(); - } - } - } - } +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2RandomIntegerAttributeGenerator = undefined; - /** - * Keeps the scene and it's object's resources alive - */ +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - }, { - key: 'KeepAlive', - value: function KeepAlive() { - var res = this.GetResources(); - for (var i = 0; i < res.length; i++) { - res[i].KeepAlive(); +var _global = __webpack_require__(0); + +var _Tw2ParticleElement = __webpack_require__(14); + +var _Tw2ParticleAttributeGenerator = __webpack_require__(28); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +/** + * Tw2RandomIntegerAttributeGenerator + * + * @property {number} elementType + * @property {string} customName + * @property {vec4} minRange + * @property {vec4} maxRange + * @property {Tw2ParticleElement} _element + * @inherits Tw2ParticleAttributeGenerator + * @class + */ +var Tw2RandomIntegerAttributeGenerator = exports.Tw2RandomIntegerAttributeGenerator = function (_Tw2ParticleAttribute) { + _inherits(Tw2RandomIntegerAttributeGenerator, _Tw2ParticleAttribute); + + function Tw2RandomIntegerAttributeGenerator() { + _classCallCheck(this, Tw2RandomIntegerAttributeGenerator); + + var _this = _possibleConstructorReturn(this, (Tw2RandomIntegerAttributeGenerator.__proto__ || Object.getPrototypeOf(Tw2RandomIntegerAttributeGenerator)).call(this)); + + _this.elementType = _Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.CUSTOM; + _this.customName = ''; + _this.minRange = _global.vec4.create(); + _this.maxRange = _global.vec4.create(); + _this._element = null; + return _this; + } + + /** + * Binds a particle system element to the generator + * @param {Tw2ParticleSystem} ps + * @returns {boolean} True if successfully bound + */ + + + _createClass(Tw2RandomIntegerAttributeGenerator, [{ + key: 'Bind', + value: function Bind(ps) { + for (var i = 0; i < ps._elements.length; ++i) { + if (ps._elements[i].elementType === this.elementType && (this.elementType !== _Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.CUSTOM || ps._elements[i].customName === this.customName)) { + this._element = ps._elements[i]; + return true; + } } + return false; } /** - * Gets scene's resources - * @param {Array} [out=[]] - Optional receiving array - * @param {boolean} [excludeChildren] - * @returns {Array.} [out] + * Generates the attributes + * @param {Tw2ParticleElement} position + * @param {Tw2ParticleElement} velocity + * @param {number} index */ }, { - key: 'GetResources', - value: function GetResources() { - var out = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - var excludeChildren = arguments[1]; - - for (var i = 0; i < this.lensflares.length; i++) { - this.lensflares[i].GetResources(out); + key: 'Generate', + value: function Generate(position, velocity, index) { + for (var i = 0; i < this._element.dimension; ++i) { + this._element.buffer[this._element.instanceStride * index + this._element.startOffset + i] = Math.floor(this.minRange[i] + Math.random() * (this.maxRange[i] - this.minRange[i]) + 0.5); } + } + }]); - if (this.backgroundEffect) { - this.backgroundEffect.GetResources(out); - } + return Tw2RandomIntegerAttributeGenerator; +}(_Tw2ParticleAttributeGenerator.Tw2ParticleAttributeGenerator); - if (this.envMapRes && !out.includes(this.envMapRes)) out.push(this.envMapRes); - if (this.envMap1Res && !out.includes(this.envMap1Res)) out.push(this.envMapRes); - if (this.envMap2Res && !out.includes(this.envMap2Res)) out.push(this.envMapRes); - if (this.envMap3Res && !out.includes(this.envMap3Res)) out.push(this.envMapRes); +/***/ }), +/* 199 */ +/***/ (function(module, exports, __webpack_require__) { - if (!excludeChildren) { - for (var _i = 0; _i < this.planets.length; _i++) { - this.planets[_i].GetResources(out); - } +"use strict"; - for (var _i2 = 0; _i2 < this.objects.length; _i2++) { - if ('GetResources' in this.objects[_i2]) { - this.objects[_i2].GetResources(out); - } - } - } - return out; - } +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2RandomUniformAttributeGenerator = undefined; - /** - * Per frame update that is called per frame - * @param {number} dt - delta time - */ +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - }, { - key: 'Update', - value: function Update(dt) { - for (var i = 0; i < this.planets.length; ++i) { - if ('Update' in this.planets[i]) { - this.planets[i].Update(dt); - } - } +var _global = __webpack_require__(0); - for (var _i3 = 0; _i3 < this.objects.length; ++_i3) { - if ('Update' in this.objects[_i3]) { - this.objects[_i3].Update(dt); +var _Tw2ParticleElement = __webpack_require__(14); + +var _Tw2ParticleAttributeGenerator = __webpack_require__(28); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +/** + * Tw2RandomUniformAttributeGenerator + * + * @property {number} elementType + * @property {string} customName + * @property {vec4} minRange + * @property {vec4} maxRange + * @property {Tw2ParticleElement} _element + * @inherits Tw2ParticleAttributeGenerator + * @class + */ +var Tw2RandomUniformAttributeGenerator = exports.Tw2RandomUniformAttributeGenerator = function (_Tw2ParticleAttribute) { + _inherits(Tw2RandomUniformAttributeGenerator, _Tw2ParticleAttribute); + + function Tw2RandomUniformAttributeGenerator() { + _classCallCheck(this, Tw2RandomUniformAttributeGenerator); + + var _this = _possibleConstructorReturn(this, (Tw2RandomUniformAttributeGenerator.__proto__ || Object.getPrototypeOf(Tw2RandomUniformAttributeGenerator)).call(this)); + + _this.elementType = _Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.CUSTOM; + _this.customName = ''; + _this.minRange = _global.vec4.create(); + _this.maxRange = _global.vec4.create(); + _this._element = null; + return _this; + } + + /** + * Binds a particle system element to the generator + * @param {Tw2ParticleSystem} ps + * @returns {boolean} True if successfully bound + */ + + + _createClass(Tw2RandomUniformAttributeGenerator, [{ + key: 'Bind', + value: function Bind(ps) { + for (var i = 0; i < ps._elements.length; ++i) { + if (ps._elements[i].elementType === this.elementType && (this.elementType !== _Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.CUSTOM || ps._elements[i].customName === this.customName)) { + this._element = ps._elements[i]; + return true; } } + return false; } /** - * Gets batches for rendering - * @param {number} mode - * @param {Array.} objectArray - * @param {Tw2BatchAccumulator} accumulator + * Generates the attributes + * @param {Tw2ParticleElement} position + * @param {Tw2ParticleElement} velocity + * @param {number} index */ }, { - key: 'RenderBatches', - value: function RenderBatches(mode, objectArray) { - var accumulator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this._batches; - - for (var i = 0; i < objectArray.length; ++i) { - if ('GetBatches' in objectArray[i]) { - objectArray[i].GetBatches(mode, accumulator); - } + key: 'Generate', + value: function Generate(position, velocity, index) { + for (var i = 0; i < this._element.dimension; ++i) { + this._element.buffer[this._element.instanceStride * index + this._element.startOffset + i] = this.minRange[i] + Math.random() * (this.maxRange[i] - this.minRange[i]); } } + }]); - /** - * Updates children's view dependent data and renders them - */ + return Tw2RandomUniformAttributeGenerator; +}(_Tw2ParticleAttributeGenerator.Tw2ParticleAttributeGenerator); - }, { - key: 'Render', - value: function Render() { - this.ApplyPerFrameData(); +/***/ }), +/* 200 */ +/***/ (function(module, exports, __webpack_require__) { - var d = _core.device, - g = EveSpaceScene.global, - id = _math.mat4.identity(g.mat4_ID), - show = this.visible; +"use strict"; - if (show['environment'] && this.backgroundEffect) { - d.SetStandardStates(d.RM_FULLSCREEN); - d.RenderCameraSpaceQuad(this.backgroundEffect); - } - if (show.planets && this.planets.length) { - var tempProj = _math.mat4.copy(g.mat4_0, d.projection), - newProj = _math.mat4.copy(g.mat4_1, d.projection), - zn = 10000, - zf = 1e11; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2SphereShapeAttributeGenerator = undefined; - newProj[10] = zf / (zn - zf); - newProj[14] = zf * zn / (zn - zf); - d.SetProjection(newProj, true); - this.ApplyPerFrameData(); +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - for (var i = 0; i < this.planets.length; ++i) { - if (this.planets[i].UpdateViewDependentData) { - this.planets[i].UpdateViewDependentData(id); - } - } +var _global = __webpack_require__(0); - this._batches.Clear(); - d.gl.depthRange(0.9, 1); - this.RenderBatches(d.RM_OPAQUE, this.planets); - this.RenderBatches(d.RM_DECAL, this.planets); - this.RenderBatches(d.RM_TRANSPARENT, this.planets); - this.RenderBatches(d.RM_ADDITIVE, this.planets); - this._batches.Render(); - d.SetProjection(tempProj, true); - this.ApplyPerFrameData(); - d.gl.depthRange(0, 0.9); - } +var _Tw2ParticleElement = __webpack_require__(14); - if (this.lodEnabled) { - g.frustum.Initialize(d.view, d.projection, d.viewportWidth, d.viewInverse, d.viewProjection); - for (var _i4 = 0; _i4 < this.objects.length; ++_i4) { - if (this.objects[_i4].UpdateLod) { - this.objects[_i4].UpdateLod(g.frustum); - } - } - } +var _Tw2ParticleAttributeGenerator = __webpack_require__(28); - if (show.objects) { - for (var _i5 = 0; _i5 < this.objects.length; ++_i5) { - if (this.objects[_i5].UpdateViewDependentData) { - this.objects[_i5].UpdateViewDependentData(id); - } - } - } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - if (show.lensflares) { - for (var _i6 = 0; _i6 < this.lensflares.length; ++_i6) { - this.lensflares[_i6].PrepareRender(); - } - } +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - this._batches.Clear(); +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - if (show.planets) { - for (var _i7 = 0; _i7 < this.planets.length; ++_i7) { - this.planets[_i7].GetZOnlyBatches(d.RM_OPAQUE, this._batches); - } - } +/** + * Tw2SphereShapeAttributeGenerator + * + * @property {number} minRadius + * @property {number} maxRadius + * @property {number} minPhi + * @property {number} maxPhi + * @property {number} minTheta + * @property {number} maxTheta + * @property {boolean} controlPosition + * @property {boolean} controlVelocity + * @property {number} minSpeed + * @property {number} maxSpeed + * @property {number} parentVelocityFactor + * @property {vec3} position + * @property {quat} rotation + * @property {?Tw2ParticleElement} _position + * @property {?Tw2ParticleElement}_velocity + * @inherits Tw2ParticleAttributeGenerator + */ +var Tw2SphereShapeAttributeGenerator = exports.Tw2SphereShapeAttributeGenerator = function (_Tw2ParticleAttribute) { + _inherits(Tw2SphereShapeAttributeGenerator, _Tw2ParticleAttribute); - if (show.objects) { - this.RenderBatches(d.RM_OPAQUE, this.objects); - this.RenderBatches(d.RM_DECAL, this.objects); - this.RenderBatches(d.RM_TRANSPARENT, this.objects); - this.RenderBatches(d.RM_ADDITIVE, this.objects); - } + function Tw2SphereShapeAttributeGenerator() { + _classCallCheck(this, Tw2SphereShapeAttributeGenerator); - if (show.lensflares) { - for (var _i8 = 0; _i8 < this.lensflares.length; ++_i8) { - this.lensflares[_i8].GetBatches(d.RM_ADDITIVE, this._batches); - } - } + var _this = _possibleConstructorReturn(this, (Tw2SphereShapeAttributeGenerator.__proto__ || Object.getPrototypeOf(Tw2SphereShapeAttributeGenerator)).call(this)); - this._batches.Render(); + _this.minRadius = 0; + _this.maxRadius = 0; + _this.minPhi = 0; + _this.maxPhi = 360; + _this.minTheta = 0; + _this.maxTheta = 360; + _this.controlPosition = true; + _this.controlVelocity = true; + _this.minSpeed = 0; + _this.maxSpeed = 0; + _this.parentVelocityFactor = 1; + _this.position = _global.vec3.create(); + _this.rotation = _global.quat.create(); + _this._position = null; + _this._velocity = null; + return _this; + } - if (show.lensflares) { - for (var _i9 = 0; _i9 < this.lensflares.length; ++_i9) { - this.lensflares[_i9].UpdateOccluders(); - } - } + /** + * Binds a particle system element to the generator + * @param {Tw2ParticleSystem} ps + * @returns {boolean} True if successfully bound + */ - if (this.renderDebugInfo) { - if (EveSpaceScene.DebugRenderer) { - if (!this._debugHelper) { - this._debugHelper = new EveSpaceScene.DebugRenderer(); - } - for (var _i10 = 0; _i10 < this.objects.length; ++_i10) { - if (this.objects[_i10].RenderDebugInfo) { - this.objects[_i10].RenderDebugInfo(this._debugHelper); - } - } + _createClass(Tw2SphereShapeAttributeGenerator, [{ + key: 'Bind', + value: function Bind(ps) { + this._position = null; + this._velocity = null; - this._debugHelper.Render(); + for (var i = 0; i < ps._elements.length; ++i) { + if (ps._elements[i].elementType === _Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION && this.controlPosition) { + this._position = ps._elements[i]; + } else if (ps._elements[i].elementType === _Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.VELOCITY && this.controlVelocity) { + this._velocity = ps._elements[i]; } } + return (!this.controlPosition || this._position !== null) && (!this.controlVelocity || this._velocity !== null); } /** - * Applies per frame data + * Generates the attributes + * @param {Tw2ParticleElement} position + * @param {Tw2ParticleElement} velocity + * @param {number} index */ }, { - key: 'ApplyPerFrameData', - value: function ApplyPerFrameData() { - var d = _core.device, - g = EveSpaceScene.global, - envMapTransform = g.mat4_2, - sunDir = g.vec3_0, - show = this.visible; - - _math.mat4.fromQuat(envMapTransform, this.envMapRotation); - _math.mat4.scale(envMapTransform, envMapTransform, this.envMapScaling); - _math.mat4.transpose(envMapTransform, envMapTransform); - _math.vec3.negate(sunDir, this.sunDirection); - _math.vec3.normalize(sunDir, sunDir); + key: 'Generate', + value: function Generate(position, velocity, index) { + var phi = (this.minPhi + Math.random() * (this.maxPhi - this.minPhi)) / 180 * Math.PI, + theta = (this.minTheta + Math.random() * (this.maxTheta - this.minTheta)) / 180 * Math.PI, + rv = _Tw2ParticleAttributeGenerator.Tw2ParticleAttributeGenerator.global.vec3_0; - var distance = this.fogEnd - this.fogStart; - if (Math.abs(distance) < 1e-5) distance = 1e-5; - var f = 1.0 / distance; + rv[0] = Math.sin(phi) * Math.cos(theta); + rv[1] = -Math.cos(phi); + rv[2] = Math.sin(phi) * Math.sin(theta); + _global.vec3.transformQuat(rv, rv, this.rotation); - var VSData = this._perFrameVS; - VSData.Set('FogFactors', [this.fogEnd * f, f, this.visible.fog ? this.fogMax : 0, 1]); - VSData.Set('ViewportAdjustment', [1, 1, 1, 1]); - VSData.Set('MiscSettings', [d.currentTime, 0, d.viewportWidth, d.viewportHeight]); - VSData.Set('SunData.DirWorld', sunDir); - VSData.Set('SunData.DiffuseColor', this.sunDiffuseColor); - VSData.Set('TargetResolution', d.targetResolution); - VSData.Set('ViewInverseTransposeMat', d.viewInverse); - VSData.Set('ViewProjectionMat', d.viewProjectionTranspose); - VSData.Set('ViewMat', d.viewTranspose); - VSData.Set('ProjectionMat', d.projectionTranspose); - VSData.Set('EnvMapRotationMat', envMapTransform); - d.perFrameVSData = VSData; + if (this._velocity) { + var speed = this.minSpeed + Math.random() * (this.maxSpeed - this.minSpeed), + offset = this._velocity.instanceStride * index + this._velocity.startOffset; - var PSData = this._perFramePS; - PSData.Set('ViewInverseTransposeMat', d.viewInverse); - PSData.Set('ViewMat', d.viewTranspose); - PSData.Set('EnvMapRotationMat', envMapTransform); - PSData.Set('SunData.DirWorld', sunDir); - PSData.Set('SunData.DiffuseColor', this.sunDiffuseColor); - PSData.Set('SceneData.AmbientColor', this.ambientColor); - PSData.Set('MiscSettings', [d.currentTime, this.fogType, this.fogBlur, 1]); - PSData.Set('SceneData.FogColor', this.fogColor); - PSData.Set('FovXY', [d.targetResolution[3], d.targetResolution[2]]); - PSData.Set('ShadowMapSettings', [1, 1, 0, 0]); - PSData.Set('TargetResolution', d.targetResolution); - PSData.Get('SceneData.NebulaIntensity')[0] = this.nebulaIntensity; - PSData.Get('ViewportSize')[0] = d.viewportWidth; - PSData.Get('ViewportSize')[1] = d.viewportHeight; - PSData.Get('ShadowCameraRange')[0] = 1; - PSData.Get('ProjectionToView')[0] = -d.projection[14]; - PSData.Get('ProjectionToView')[1] = -d.projection[10] - 1; - d.perFramePSData = PSData; + this._velocity.buffer[offset] = rv[0] * speed; + this._velocity.buffer[offset + 1] = rv[1] * speed; + this._velocity.buffer[offset + 2] = rv[2] * speed; - var envMap = this.envMapRes && show.environmentReflection ? this.envMapRes : g.emptyTexture, - envMap1 = this.envMap1Res && show.environmentDiffuse ? this.envMap1Res : g.emptyTexture, - envMap2 = this.envMap2Res && show.environmentBlur ? this.envMap2Res : g.emptyTexture, - envMap3 = this.envMap3Res ? this.envMap3Res : g.emptyTexture; + if (velocity) { + this._velocity.buffer[offset] += velocity.buffer[velocity.offset] * this.parentVelocityFactor; + this._velocity.buffer[offset + 1] += velocity.buffer[velocity.offset + 1] * this.parentVelocityFactor; + this._velocity.buffer[offset + 2] += velocity.buffer[velocity.offset + 2] * this.parentVelocityFactor; + } + } - _core.store.GetVariable('EveSpaceSceneEnvMap').SetTextureRes(envMap); - _core.store.GetVariable('EnvMap1').SetTextureRes(envMap1); - _core.store.GetVariable('EnvMap2').SetTextureRes(envMap2); - _core.store.GetVariable('EnvMap3').SetTextureRes(envMap3); - } + if (this._position) { + _global.vec3.scale(rv, rv, this.minRadius + Math.random() * (this.maxRadius - this.minRadius)); + _global.vec3.add(rv, rv, this.position); - /** - * Initializes class global and scratch variables - */ + if (position) { + rv[0] += position.buffer[position.offset]; + rv[1] += position.buffer[position.offset + 1]; + rv[2] += position.buffer[position.offset + 2]; + } - }], [{ - key: 'init', - value: function init() { - if (!EveSpaceScene.global) { - EveSpaceScene.global = { - vec3_0: _math.vec3.create(), - vec4_0: _math.vec4.create(), - mat4_0: _math.mat4.create(), - mat4_1: _math.mat4.create(), - mat4_2: _math.mat4.create(), - mat4_ID: _math.mat4.create(), - frustum: new _core.Tw2Frustum(), - emptyTexture: _core.resMan.GetResource('res:/texture/global/black.dds.0.png') - }; + var _offset = this._position.instanceStride * index + this._position.startOffset; + this._position.buffer[_offset] = rv[0]; + this._position.buffer[_offset + 1] = rv[1]; + this._position.buffer[_offset + 2] = rv[2]; } } }]); - return EveSpaceScene; -}(); - -/** - * Class global and scratch variables - * @type {{string:*}} - */ + return Tw2SphereShapeAttributeGenerator; +}(_Tw2ParticleAttributeGenerator.Tw2ParticleAttributeGenerator); +/***/ }), +/* 201 */ +/***/ (function(module, exports, __webpack_require__) { -EveSpaceScene.global = null; +"use strict"; -/** - * Debug renderer - * @type {?Function} - */ -EveSpaceScene.DebugRenderer = 'Tw2DebugRenderer' in window ? window['Tw2DebugRenderer'] : null; /***/ }), -/* 196 */ +/* 202 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41398,876 +42012,539 @@ EveSpaceScene.DebugRenderer = 'Tw2DebugRenderer' in window ? window['Tw2DebugRen Object.defineProperty(exports, "__esModule", { value: true }); -exports.EveSOF = EveSOF; +exports.Tw2ParticleSystem = undefined; -var _math = __webpack_require__(0); +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _core = __webpack_require__(1); +var _global = __webpack_require__(0); -var _curve = __webpack_require__(57); +var _core = __webpack_require__(1); -var _item = __webpack_require__(63); +var _Tw2ParticleElement = __webpack_require__(14); -var _child = __webpack_require__(58); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var _object = __webpack_require__(60); +/** + * Tw2ParticleSystem + * + * @property {number|string} id + * @property {string} name + * @property {number} aliveCount + * @property {number} maxParticleCount + * @property {*} emitParticleOnDeathEmitter + * @property {*} emitParticleDuringLifeEmitter + * @property {Array.} elements + * @property {boolean} isValid + * @property {boolean} requiresSorting + * @property {boolean} updateSimulation + * @property {boolean} applyForce + * @property {boolean} applyAging + * @property {boolean} isGlobal + * @property {Array} forces + * @property {Array} constraints + * @property {boolean} updateBoundingBox + * @property {vec3} aabbMin + * @property {vec3} aabbMax + * @property {number} peakAliveCount + * @property {boolean} bufferDirty + * @property {WebGLBuffer} _vb + * @property {Tw2VertexDeclaration} _declaration + * @property {Array} _stdElements + * @property {Array} _elements + * @property {Array} instanceStride + * @property {Array} vertexStride + * @property {Array} buffers + * @class + */ +var Tw2ParticleSystem = exports.Tw2ParticleSystem = function () { + function Tw2ParticleSystem() { + _classCallCheck(this, Tw2ParticleSystem); -function EveSOF() { - var data = null; - var spriteEffect = null; + this._id = _global.util.generateID(); + this.name = ''; + this.aliveCount = 0; + this.maxParticleCount = 0; + this.emitParticleOnDeathEmitter = null; + this.emitParticleDuringLifeEmitter = null; + this.elements = []; + this.isValid = false; + this.requiresSorting = false; + this.updateSimulation = true; + this.applyForce = true; + this.applyAging = true; + this.isGlobal = false; + this.forces = []; + this.constraints = []; + this.updateBoundingBox = false; + this.aabbMin = _global.vec3.create(); + this.aabbMax = _global.vec3.create(); + this.peakAliveCount = 0; - function _get(obj, property, defaultValue) { - if (property in obj) { - return obj[property]; - } - return defaultValue; - } + this.bufferDirty = false; - /** - * @return {string} - */ - function GetShaderPrefix(isAnimated) { - return isAnimated ? _get(data['generic'], 'shaderPrefixAnimated', '') : _get(data['generic'], 'shaderPrefix', ''); - } + this._vb = null; + this._declaration = null; - function ModifyTextureResPath(path, name, area, faction, commands) { - var pathInsert = null; - if (_get(faction, 'resPathInsert', '').length) { - pathInsert = faction.resPathInsert; - } - if ('respathinsert' in commands && commands.respathinsert.length === 1) { - if (commands.respathinsert[0] === 'none') { - return path; - } else { - pathInsert = commands.respathinsert[0]; - } - } - if (name === 'MaterialMap' || name === 'PaintMaskMap' || name === 'PmdgMap') { - var index = path.lastIndexOf('/'); - var pathCopy = path; - if (index >= 0) { - pathCopy = path.substr(0, index + 1) + pathInsert + '/' + path.substr(index + 1); - } - index = pathCopy.lastIndexOf('_'); - if (index >= 0) { - pathCopy = pathCopy.substr(0, index) + '_' + pathInsert + pathCopy.substr(index); - var textureOverrides = _get(area, 'textureOverrides', {}); - if (name in textureOverrides && faction.name in textureOverrides[name]) { - return pathCopy; - } - } - } - return path; + this._stdElements = [null, null, null, null]; + this._elements = []; + this.instanceStride = [null, null]; + this.vertexStride = [null, null]; + this.buffers = [null, null]; + + Tw2ParticleSystem.init(); } /** - * @return {string} + * Initializes the Particle System */ - function ModifyShaderPath(shader, isSkinned) { - var prefix = GetShaderPrefix(isSkinned); - shader = '/' + shader; - var index = shader.lastIndexOf('/'); - return shader.substr(0, index + 1) + prefix + shader.substr(index + 1); - } - - function FindPrefix(prefixes, name) { - for (var m = 0; m < prefixes.length; ++m) { - if (name.substr(0, prefixes[m].length) === prefixes[m]) { - return m; - } - } - return null; - } - - function GetOverridenParameter(name, area, commands, race) { - var prefixes, materialIndex, materialData, shortName; - if ('mesh' in commands) { - prefixes = data.generic.materialPrefixes; - materialIndex = FindPrefix(prefixes, name); - if (materialIndex !== null && materialIndex < commands.mesh.length && (_get(area, 'blockedMaterials', 0) & 1 << materialIndex) === 0) { - materialData = _get(data.material, commands.mesh[materialIndex], null); - if (materialData) { - shortName = name.substr(prefixes[materialIndex].length); - return _get(materialData.parameters, shortName, undefined); - } - } - } - prefixes = data.generic.patternMaterialPrefixes; - materialIndex = FindPrefix(prefixes, name); - if ('pattern' in commands) { - if (materialIndex !== null && 1 + materialIndex < commands.pattern.length) { - materialData = _get(data.material, commands.pattern[1 + materialIndex], null); - if (materialData) { - shortName = name.substr(prefixes[materialIndex].length); - return _get(materialData.parameters, shortName, undefined); - } - } - } - if (materialIndex !== null) { - materialData = _get(data.material, race.defaultPatternLayer1MaterialName, null); - if (materialData) { - shortName = name.substr(prefixes[materialIndex].length); - return _get(materialData.parameters, shortName, undefined); - } - } - } - function GetAddressMode(projectionType) { - switch (projectionType) { - case 2: - return 4; - case 1: - return 3; - default: - return 1; + _createClass(Tw2ParticleSystem, [{ + key: 'Initialize', + value: function Initialize() { + this.UpdateElementDeclaration(); } - } - function FillMeshAreas(areas, areasName, hull, faction, race, pattern, commands, shaderOverride) { - var hullAreas = _get(hull, areasName, []); - for (var i = 0; i < hullAreas.length; ++i) { - var area = hullAreas[i]; - var effect = new _core.Tw2Effect(); - effect.effectFilePath = data['generic']['areaShaderLocation'] + ModifyShaderPath(shaderOverride ? shaderOverride : area.shader, hull['isSkinned']); - var names = _get(_get(data['generic']['areaShaders'], area.shader, {}), 'parameters', []); - for (var j = 0; j < names.length; ++j) { - var name = names[j]; - var param = GetOverridenParameter(name, area, commands, race); - param = param || _get(_get(_get(data.generic.hullAreas, area.name, {}), 'parameters', {}), name); - param = param || _get(_get(_get(race.hullAreas, area.name, {}), 'parameters', {}), name); - param = param || _get(_get(_get(faction.areas, area.name, {}), 'parameters', {}), name); - param = param || _get(_get(area, 'parameters', {}), name); - if (param) { - effect.parameters[name] = new _core.Tw2Vector4Parameter(name, param); - } - } + /** + * Updates Element Declarations + */ - var hullTextures = _get(area, 'textures', []); - for (j in hullTextures) { - if (hullTextures.hasOwnProperty(j)) { - var path = hullTextures[j]; - path = ModifyTextureResPath(path, j, area, faction, commands); - effect.parameters[j] = new _core.Tw2TextureParameter(j, path); - } - } + }, { + key: 'UpdateElementDeclaration', + value: function UpdateElementDeclaration() { + this.isValid = false; - for (j = 0; j < pattern.layers.length; ++j) { - if (pattern.layers[j] && !(pattern.layers[j].textureName in effect.parameters)) { - var patternTex = new _core.Tw2TextureParameter(pattern.layers[j].textureName); - patternTex.resourcePath = pattern.layers[j].textureResFilePath; - patternTex.useAllOverrides = true; - patternTex.addressUMode = GetAddressMode(_get(pattern.layers[j], 'projectionTypeU', 0)); - patternTex.addressVMode = GetAddressMode(_get(pattern.layers[j], 'projectionTypeV', 0)); - patternTex.Initialize(); - effect.parameters[pattern.layers[j].textureName] = patternTex; - } + if (this._vb) { + _global.device.gl.deleteBuffer(this._vb); + this._vb = null; } - var defaultTextures = _get(_get(data['generic']['areaShaders'], area.shader, {}), 'defaultTextures', {}); - for (var texName in defaultTextures) { - if (defaultTextures.hasOwnProperty(texName)) { - if (!(texName in effect.parameters)) { - effect.parameters[texName] = new _core.Tw2TextureParameter(texName, defaultTextures[texName]); - } - } - } + this._declaration = null; + this.aliveCount = 0; - effect.Initialize(); + if (this.elements.length === 0) return; - var newArea = new _core.Tw2MeshArea(); - newArea.name = area.name; - newArea.effect = effect; - newArea.index = _get(area, 'index', 0); - newArea.count = _get(area, 'count', 1); - areas.push(newArea); - } - } + this._stdElements = [null, null, null, null]; + this._elements = []; + this.instanceStride = [0, 0]; + this.vertexStride = [0, 0]; + this._declaration = new _core.Tw2VertexDeclaration(); + this.buffers = [null, null]; - function SetupMesh(ship, hull, faction, race, commands, pattern) { - var mesh = new _core.Tw2Mesh(); - mesh.geometryResPath = hull['geometryResFilePath']; - ship.boundingSphereCenter[0] = hull.boundingSphere[0]; - ship.boundingSphereCenter[1] = hull.boundingSphere[1]; - ship.boundingSphereCenter[2] = hull.boundingSphere[2]; - ship.boundingSphereRadius = hull.boundingSphere[3]; - FillMeshAreas(_get(mesh, 'opaqueAreas', []), 'opaqueAreas', hull, faction, race, pattern, commands); - FillMeshAreas(_get(mesh, 'transparentAreas', []), 'transparentAreas', hull, faction, race, pattern, commands); - FillMeshAreas(_get(mesh, 'additiveAreas', []), 'additiveAreas', hull, faction, race, pattern, commands); - FillMeshAreas(_get(mesh, 'decalAreas', []), 'decalAreas', hull, faction, race, pattern, commands); - FillMeshAreas(_get(mesh, 'depthAreas', []), 'depthAreas', hull, faction, race, pattern, commands); - mesh.Initialize(); - ship.mesh = mesh; - if ('shapeEllipsoidCenter' in hull) { - ship.shapeEllipsoidCenter = hull.shapeEllipsoidCenter; - } - if ('shapeEllipsoidRadius' in hull) { - ship.shapeEllipsoidRadius = hull.shapeEllipsoidRadius; - } - } + for (var i = 0; i < this.elements.length; ++i) { + var bufferIndex = this.elements[i].usedByGPU ? 0 : 1, + el = new _Tw2ParticleElement.Tw2ParticleElement(this.elements[i]); + //el.buffer = this.buffers[bufferIndex]; - function SetupPattern(hull, race, commands) { - var pattern = { - patterns: [], - layers: [] - }; - if ('pattern' in commands) { - var p = {}; - for (var k = 0; k < data.pattern.length; ++k) { - if (data.pattern[k].name === commands.pattern[0]) { - p = data.pattern[k]; - break; + el.startOffset = this.vertexStride[bufferIndex]; + el.offset = el.startOffset; + if (this.elements[i].elementType !== _Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.CUSTOM) { + this._stdElements[this.elements[i].elementType] = el; } - } - var layer = _get(p, 'layer1', null); - if (layer) { - pattern.layers.push(layer); - } - layer = _get(p, 'layer2', null); - if (layer) { - pattern.layers.push(layer); - } - var projections = _get(p, 'projections', []); - for (var i = 0; i < projections.length; ++i) { - if (projections[i].name === hull.name) { - p = projections[i]; - layer = _get(p, 'transformLayer1', null); - if (layer) { - pattern.patterns.push(layer); - } - layer = _get(p, 'transformLayer2', null); - if (layer) { - pattern.patterns.push(layer); - } + this.vertexStride[bufferIndex] += el.dimension; + this._elements.push(el); + if (bufferIndex === 0) { + var d = this.elements[i].GetDeclaration(); + d.offset = el.startOffset * 4; + this._declaration.elements.push(d); } } - } else if (_get(hull, 'defaultPattern')) { - p = _get(hull, 'defaultPattern', {}); - layer = _get(p, 'transformLayer1', null); - if (layer) { - pattern.patterns.push(layer); - } - layer = _get(p, 'transformLayer2', null); - if (layer) { - pattern.patterns.push(layer); - } - p = _get(race, 'defaultPattern', {}); - layer = _get(p, 'layer1', null); - if (layer) { - pattern.layers.push(layer); - } - layer = _get(p, 'layer2', null); - if (layer) { - pattern.layers.push(layer); - } - } - return pattern; - } - function SetupCustomMasks(ship, pattern) { - for (var i = 0; i < pattern.patterns.length; ++i) { - if (pattern.patterns[i] && pattern.layers[i]) { - var p = pattern.patterns[i]; - var l = pattern.layers[i]; - ship.AddCustomMask(_get(p, 'position', _math.vec3.create()), _get(p, 'scaling', _math.vec3.fromValues(1, 1, 1)), _get(p, 'rotation', _math.quat.create()), _get(p, 'isMirrored', false), _get(l, 'materialSource', 0), _math.vec4.fromValues(_get(l, 'isTargetMtl1', true) ? 1 : 0, _get(l, 'isTargetMtl2', true) ? 1 : 0, _get(l, 'isTargetMtl3', true) ? 1 : 0, _get(l, 'isTargetMtl4', true) ? 1 : 0)); - } - } - } + this._declaration.RebuildHash(); - function SetupDecals(ship, hull, faction) { - var hullDecals = _get(hull, 'hullDecals', []); - for (var i = 0; i < hullDecals.length; ++i) { - var hullDecal = hullDecals[i]; - var factionDecal = null; - var factionIndex = 'group' + _get(hullDecal, 'groupIndex', -1); - if (faction.decals && factionIndex in faction.decals) { - factionDecal = faction.decals[factionIndex]; - } - if (factionDecal && !factionDecal['isVisible']) { - continue; - } - var effect = new _core.Tw2Effect(); - if (factionDecal && factionDecal.shader && factionDecal.shader.length) { - effect.effectFilePath = data['generic']['decalShaderLocation'] + '/' + GetShaderPrefix(false) + factionDecal.shader; - } else if (hullDecal.shader && hullDecal.shader.length) { - effect.effectFilePath = data['generic']['decalShaderLocation'] + '/' + GetShaderPrefix(false) + hullDecal.shader; - } else { - continue; - } - var hullParameters = _get(hullDecal, 'parameters', {}); - for (var j in hullParameters) { - if (hullParameters.hasOwnProperty(j)) { - effect.parameters[j] = new _core.Tw2Vector4Parameter(j, hullParameters[j]); - } + for (var _i = 0; _i < this._elements.length; ++_i) { + var _bufferIndex = this._elements[_i].usedByGPU ? 0 : 1; + this._elements[_i].vertexStride = this.vertexStride[_bufferIndex]; } - var hullTextures = _get(hullDecal, 'textures', {}); - for (j in hullTextures) { - if (hullTextures.hasOwnProperty(j)) { - effect.parameters[j] = new _core.Tw2TextureParameter(j, hullTextures[j]); - } + + this.instanceStride[0] = this.vertexStride[0] * 4; + this.instanceStride[1] = this.vertexStride[1] * 4; + + for (var _i2 = 0; _i2 < this._elements.length; ++_i2) { + var _bufferIndex2 = this._elements[_i2].usedByGPU ? 0 : 1; + this._elements[_i2].instanceStride = this.instanceStride[_bufferIndex2]; } - if (factionDecal) { - var factionParameters = _get(factionDecal, 'parameters', {}); - for (j in factionParameters) { - if (factionParameters.hasOwnProperty(j)) { - effect.parameters[j] = new _core.Tw2Vector4Parameter(j, factionParameters[j]); - } - } - var factionTextures = _get(factionDecal, 'textures', {}); - for (j in factionTextures) { - if (factionTextures.hasOwnProperty(j) && !(j in effect.parameters)) { - effect.parameters[j] = new _core.Tw2TextureParameter(j, factionTextures[j]); - } - } + + this.buffers = [null, null]; + if (this.instanceStride[0] && this.maxParticleCount) { + this.buffers[0] = new Float32Array(this.instanceStride[0] * this.maxParticleCount); + this._vb = _global.device.gl.createBuffer(); + _global.device.gl.bindBuffer(_global.device.gl.ARRAY_BUFFER, this._vb); + _global.device.gl.bufferData(_global.device.gl.ARRAY_BUFFER, this.buffers[0].length, _global.device.gl.DYNAMIC_DRAW); + _global.device.gl.bindBuffer(_global.device.gl.ARRAY_BUFFER, null); } - var defaultTextures = _get(_get(data['generic']['decalShaders'], hullDecal.shader, {}), 'defaultTextures', {}); - for (var texName in defaultTextures) { - if (defaultTextures.hasOwnProperty(texName)) { - if (!(texName in effect.parameters)) { - effect.parameters[texName] = new _core.Tw2TextureParameter(texName, defaultTextures[texName]); - } - } + if (this.instanceStride[1]) { + this.buffers[1] = new Float32Array(this.instanceStride[1] * this.maxParticleCount); } - effect.Initialize(); + for (var _i3 = 0; _i3 < this._elements.length; ++_i3) { + var _bufferIndex3 = this._elements[_i3].usedByGPU ? 0 : 1; + this._elements[_i3].buffer = this.buffers[_bufferIndex3]; + } - var decal = new _item.EveSpaceObjectDecal(); - _math.vec3.copy(decal.position, _get(hullDecal, 'position', [0, 0, 0])); - _math.quat.copy(decal.rotation, _get(hullDecal, 'rotation', [0, 0, 0, 1])); - _math.vec3.copy(decal.scaling, _get(hullDecal, 'scaling', [1, 1, 1])); - decal.parentBoneIndex = _get(hullDecal, 'boneIndex', -1); - decal.indexBuffer = new Uint16Array(hullDecal.indexBuffer); - decal.decalEffect = effect; - decal.name = _get(hullDecals[i], 'name', ''); - if ('groupIndex' in hullDecals[i]) { - decal.groupIndex = hullDecals[i].groupIndex; + if (this.requiresSorting) { + this._sortedIndexes = new Array(this.maxParticleCount); + this._sortedBuffer = new Float32Array(this.instanceStride[0] * this.maxParticleCount); + this._distancesBuffer = new Float32Array(this.maxParticleCount); } - decal.Initialize(); - ship.decals.push(decal); - } - } - function SetupInstancedMeshes(ship, hull, faction, race, commands, pattern) { - var instancedMeshes = _get(hull, 'instancedMeshes', []); - for (var i = 0; i < instancedMeshes.length; ++i) { - var him = instancedMeshes[i]; - var mesh = new _core.Tw2InstancedMesh(); - mesh.instanceGeometryResPath = him.instanceGeometryResPath; - mesh.geometryResPath = him.geometryResPath; - mesh.Initialize(); + this.isValid = true; + this.bufferDirty = true; + } - FillMeshAreas(_get(mesh, 'opaqueAreas', []), 'opaqueAreas', hull, faction, race, pattern, commands, him.shader); + /** + * Checks if an element type exists + * @param {number} type + * @returns {boolean} + */ - var child = new _child.EveChildMesh(); - child.mesh = mesh; - ship.effectChildren.push(child); + }, { + key: 'HasElement', + value: function HasElement(type) { + return this._stdElements[type] !== null; } - } - function SetupSpriteSets(ship, hull, faction) { - var hullSets = _get(hull, 'spriteSets', []); - var factionSets = _get(faction, 'spriteSets', {}); - for (var i = 0; i < hullSets.length; ++i) { - var spriteSet = new _item.EveSpriteSet(true, !!(hull['isSkinned'] && hullSets[i]['skinned'])); - spriteSet.name = _get(hullSets[i], 'name', ''); - spriteSet.effect = spriteEffect; - var hullData = _get(hullSets[i], 'items', []); - for (var j = 0; j < hullData.length; ++j) { - if (!('group' + _get(hullData[j], 'groupIndex', -1) in factionSets)) continue; - var item = new _item.EveSpriteSetItem(); - item.blinkPhase = _get(hullData[j], 'blinkPhase', 0); - item.blinkRate = _get(hullData[j], 'blinkRate', 0.1); - item.boneIndex = _get(hullData[j], 'boneIndex', 0); - item.falloff = _get(hullData[j], 'falloff', 0); - item.maxScale = _get(hullData[j], 'maxScale', 10); - item.minScale = _get(hullData[j], 'minScale', 1); - item.name = _get(hullData[j], 'name', ''); - item.groupIndex = _get(hullData[j], 'groupIndex', -1); - _math.vec3.copy(item.position, _get(hullData[j], 'position', [0, 0, 0])); + /** + * Gets an element by it's type + * @param {number} type + * @returns {Tw2ParticleElement} + */ - var factionSet = factionSets['group' + item.groupIndex]; - if (factionSet) { - item.groupName = factionSet.name; - if ('color' in factionSet) _math.vec4.copy(item.color, factionSet.color); - } - spriteSet.sprites.push(item); + }, { + key: 'GetElement', + value: function GetElement(type) { + if (this._stdElements[type]) { + this._stdElements[type].offset = this._stdElements[type].startOffset; } - spriteSet.Initialize(); - ship.spriteSets.push(spriteSet); + return this._stdElements[type]; } - } - - function SetupSpotlightSets(ship, hull, faction) { - var hullSets = _get(hull, 'spotlightSets', []); - var factionSets = _get(faction, 'spotlightSets', {}); - for (var i = 0; i < hullSets.length; ++i) { - var spotlightSet = new _item.EveSpotlightSet(); - spotlightSet.name = _get(hullSets[i], 'name', ''); - spotlightSet.coneEffect = new _core.Tw2Effect(); - spotlightSet.glowEffect = new _core.Tw2Effect(); - if (hullSets[i]['skinned']) { - spotlightSet.coneEffect.effectFilePath = 'res:/graphics/effect/managed/space/spaceobject/fx/skinned_spotlightcone.fx'; - spotlightSet.glowEffect.effectFilePath = 'res:/graphics/effect/managed/space/spaceobject/fx/skinned_spotlightglow.fx'; - } else { - spotlightSet.coneEffect.effectFilePath = 'res:/graphics/effect/managed/space/spaceobject/fx/spotlightcone.fx'; - spotlightSet.glowEffect.effectFilePath = 'res:/graphics/effect/managed/space/spaceobject/fx/spotlightglow.fx'; - } - spotlightSet.coneEffect.parameters['TextureMap'] = new _core.Tw2TextureParameter('TextureMap', hullSets[i]['coneTextureResPath']); - spotlightSet.glowEffect.parameters['TextureMap'] = new _core.Tw2TextureParameter('TextureMap', hullSets[i]['glowTextureResPath']); - spotlightSet.coneEffect.parameters['zOffset'] = new _core.Tw2FloatParameter('zOffset', _get(hullSets[i], 'zOffset', 0)); - spotlightSet.coneEffect.Initialize(); - spotlightSet.glowEffect.Initialize(); - - var hullData = _get(hullSets[i], 'items', []); - for (var j = 0; j < hullData.length; ++j) { - var item = new _item.EveSpotlightSetItem(); - item.name = _get(hullData[j], 'name', ''); - item.groupIndex = _get(hullData[j], 'groupIndex', -1); - item.boneIndex = _get(hullData[j], 'boneIndex', 0); - item.boosterGainInfluence = _get(hullData[j], 'boosterGainInfluence', 0); - item.coneIntensity = _get(hullData[j], 'coneIntensity', 0); - item.spriteIntensity = _get(hullData[j], 'spriteIntensity', 0); - item.flareIntensity = _get(hullData[j], 'flareIntensity', 0); + /** + * Begins particle spawning + * @returns {?number} + */ - var factionSet = factionSets['group' + item.groupIndex]; - if (factionSet) { - _math.vec4.copy(item.coneColor, _get(factionSet, 'coneColor', [0, 0, 0, 0])); - _math.vec4.copy(item.spriteColor, _get(factionSet, 'spriteColor', [0, 0, 0, 0])); - _math.vec4.copy(item.flareColor, _get(factionSet, 'flareColor', [0, 0, 0, 0])); - } - _math.vec3.copy(item.spriteScale, _get(hullData[j], 'spriteScale', [1, 1, 1])); + }, { + key: 'BeginSpawnParticle', + value: function BeginSpawnParticle() { + if (!this.isValid || this.aliveCount >= this.maxParticleCount) return null; + return this.aliveCount++; + } - if ('transform' in hullData[j]) { - _math.mat4.copy(item.transform, hullData[j].transform); - } else { - _math.mat4.identity(item.transform); - } + /** + * Ends particle spawning + */ - spotlightSet.spotlightItems.push(item); - } - spotlightSet.Initialize(); - ship.spotlightSets.push(spotlightSet); + }, { + key: 'EndSpawnParticle', + value: function EndSpawnParticle() { + this.bufferDirty = true; } - } - function _assignIfExists(dest, src, attr) { - if (attr in src) { - dest[attr] = src[attr]; - } - } + /** + * Per frame update + * @param {number} dt - delta time + */ - function SetupPlaneSets(ship, hull, faction) { - var hullSets = _get(hull, 'planeSets', []); - var factionSets = _get(faction, 'planeSets', {}); - for (var i = 0; i < hullSets.length; ++i) { - var planeSet = new _item.EvePlaneSet(); - planeSet.name = _get(hullSets[i], 'name', ''); - planeSet.effect = new _core.Tw2Effect(); - if (hullSets[i]['skinned']) { - planeSet.effect.effectFilePath = 'res:/graphics/effect/managed/space/spaceobject/fx/skinned_planeglow.fx'; - } else { - planeSet.effect.effectFilePath = 'res:/graphics/effect/managed/space/spaceobject/fx/planeglow.fx'; - } - planeSet.effect.parameters['Layer1Map'] = new _core.Tw2TextureParameter('Layer1Map', hullSets[i]['layer1MapResPath']); - planeSet.effect.parameters['Layer2Map'] = new _core.Tw2TextureParameter('Layer2Map', hullSets[i]['layer2MapResPath']); - planeSet.effect.parameters['MaskMap'] = new _core.Tw2TextureParameter('MaskMap', hullSets[i]['maskMapResPath']); - planeSet.effect.parameters['PlaneData'] = new _core.Tw2Vector4Parameter('PlaneData', _get(hullSets[i], 'planeData', [1, 0, 0, 0])); - planeSet.effect.Initialize(); + }, { + key: 'Update', + value: function Update(dt) { + dt = Math.min(dt, 0.1); - var hullData = _get(hullSets[i], 'items', []); - for (var j = 0; j < hullData.length; ++j) { - var item = new _item.EvePlaneSetItem(); - _assignIfExists(item, hullData[j], 'groupIndex'); - _assignIfExists(item, hullData[j], 'name'); - item.boneIndex = _get(hullData[j], 'boneIndex', -1); - item.maskAtlasID = _get(hullData[j], 'maskMapAtlasIndex', 0); - // Do not copy reference! - _math.vec3.copy(item.position, _get(hullData[j], 'position', [0, 0, 0])); - _math.quat.copy(item.rotation, _get(hullData[j], 'rotation', [0, 0, 0, 1])); - _math.vec3.copy(item.scaling, _get(hullData[j], 'scaling', [1, 1, 1])); - _math.vec4.copy(item.color, _get(hullData[j], 'color', [0, 0, 0, 0])); - _math.vec4.copy(item.layer1Transform, _get(hullData[j], 'layer1Transform', [0, 0, 0, 0])); - _math.vec4.copy(item.layer1Scroll, _get(hullData[j], 'layer1Scroll', [0, 0, 0, 0])); - _math.vec4.copy(item.layer2Transform, _get(hullData[j], 'layer2Transform', [0, 0, 0, 0])); - _math.vec4.copy(item.layer2Scroll, _get(hullData[j], 'layer2Scroll', [0, 0, 0, 0])); + if (this.applyAging && this.HasElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.LIFETIME)) { + var lifetime = this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.LIFETIME), + position = this.emitParticleOnDeathEmitter ? this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION) : null, + velocity = this.emitParticleOnDeathEmitter ? this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.VELOCITY) : null; - var factionSet = factionSets['group' + _get(hullData[j], 'groupIndex', -1)]; - if (factionSet) _math.vec4.copy(item.color, _get(factionSet, 'color', [0, 0, 0, 0])); - planeSet.planes.push(item); + for (var i = 0; i < this.aliveCount; ++i) { + lifetime.buffer[lifetime.offset] += dt / lifetime.buffer[lifetime.offset + 1]; + if (lifetime.buffer[lifetime.offset] > 1) { + if (this.emitParticleOnDeathEmitter) { + this.emitParticleOnDeathEmitter.SpawnParticles(position, velocity, 1); + } + + this.aliveCount--; + if (i < this.aliveCount) { + for (var j = 0; j < 2; ++j) { + if (this.buffers[j]) { + this.buffers[j].set(this.buffers[j].subarray(this.instanceStride[j] * this.aliveCount, this.instanceStride[j] * this.aliveCount + this.instanceStride[j]), i * this.instanceStride[j]); + } + } + --i; + this.bufferDirty = true; + } + } else { + lifetime.offset += lifetime.instanceStride; + if (position) position.offset += position.instanceStride; + if (velocity) velocity.offset += velocity.instanceStride; + } + } + lifetime.dirty = true; } - planeSet.Initialize(); - ship.planeSets.push(planeSet); - } - } - function SetupBoosters(ship, hull, race) { - if (!('booster' in hull)) { - return; - } - var booster = new _item.EveBoosterSet(); - var hullBooster = hull['booster']; - var raceBooster = _get(race, 'booster', {}); - _assignIfExists(booster, raceBooster, 'glowScale'); - _assignIfExists(booster, raceBooster, 'symHaloScale'); - _assignIfExists(booster, raceBooster, 'haloScaleX'); - _assignIfExists(booster, raceBooster, 'haloScaleY'); - _assignIfExists(booster, raceBooster, 'haloColor'); - _math.vec4.copy(booster.glowColor, _get(raceBooster, 'glowColor', [0, 0, 0, 0])); - _math.vec4.copy(booster.warpGlowColor, _get(raceBooster, 'warpGlowColor', [0, 0, 0, 0])); - _math.vec4.copy(booster.warpHaloColor, _get(raceBooster, 'warpHalpColor', [0, 0, 0, 0])); - _math.vec4.copy(booster.trailColor, _get(raceBooster, 'trailColor', [0, 0, 0, 0])); - _math.vec4.copy(booster.trailSize, _get(raceBooster, 'trailSize', [0, 0, 0, 0])); + var vec3_0 = Tw2ParticleSystem.global.vec3_0; - booster.effect = new _core.Tw2Effect(); - booster.effect.effectFilePath = 'res:/Graphics/Effect/Managed/Space/Booster/BoosterVolumetric.fx'; - booster.effect.parameters['NoiseFunction0'] = new _core.Tw2FloatParameter('NoiseFunction0', _get(raceBooster.shape0, 'noiseFunction', 0)); - booster.effect.parameters['NoiseSpeed0'] = new _core.Tw2FloatParameter('NoiseSpeed0', _get(raceBooster.shape0, 'noiseSpeed', 0)); - booster.effect.parameters['NoiseAmplitudeStart0'] = new _core.Tw2Vector4Parameter('NoiseAmplitudeStart0', _get(raceBooster.shape0, 'noiseAmplitureStart', [0, 0, 0, 0])); - booster.effect.parameters['NoiseAmplitudeEnd0'] = new _core.Tw2Vector4Parameter('NoiseAmplitudeEnd0', _get(raceBooster.shape0, 'noiseAmplitureEnd', [0, 0, 0, 0])); - booster.effect.parameters['NoiseFrequency0'] = new _core.Tw2Vector4Parameter('NoiseFrequency0', _get(raceBooster.shape0, 'noiseFrequency', [0, 0, 0, 0])); - booster.effect.parameters['Color0'] = new _core.Tw2Vector4Parameter('Color0', _get(raceBooster.shape0, 'color', [0, 0, 0, 0])); + if (this.updateSimulation && this.HasElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION) && this.HasElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.VELOCITY)) { + var hasForces = this.applyForce && this.forces.length; + for (var _i4 = 0; _i4 < this.forces.length; ++_i4) { + this.forces[_i4].Update(dt); + } - booster.effect.parameters['NoiseFunction1'] = new _core.Tw2FloatParameter('NoiseFunction1', _get(raceBooster.shape1, 'noiseFunction', 0)); - booster.effect.parameters['NoiseSpeed1'] = new _core.Tw2FloatParameter('NoiseSpeed1', _get(raceBooster.shape1, 'noiseSpeed', 0)); - booster.effect.parameters['NoiseAmplitudeStart1'] = new _core.Tw2Vector4Parameter('NoiseAmplitudeStart1', _get(raceBooster.shape1, 'noiseAmplitureStart', [0, 0, 0, 0])); - booster.effect.parameters['NoiseAmplitudeEnd1'] = new _core.Tw2Vector4Parameter('NoiseAmplitudeEnd1', _get(raceBooster.shape1, 'noiseAmplitureEnd', [0, 0, 0, 0])); - booster.effect.parameters['NoiseFrequency1'] = new _core.Tw2Vector4Parameter('NoiseFrequency1', _get(raceBooster.shape1, 'noiseFrequency', [0, 0, 0, 0])); - booster.effect.parameters['Color1'] = new _core.Tw2Vector4Parameter('Color1', _get(raceBooster.shape1, 'color', [0, 0, 0, 0])); + var _position = this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION), + _velocity = this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.VELOCITY), + mass = hasForces ? this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.MASS) : null; - booster.effect.parameters['WarpNoiseFunction0'] = new _core.Tw2FloatParameter('WarpNoiseFunction0', _get(raceBooster.warpShape0, 'noiseFunction', 0)); - booster.effect.parameters['WarpNoiseSpeed0'] = new _core.Tw2FloatParameter('WarpNoiseSpeed0', _get(raceBooster.warpShape0, 'noiseSpeed', 0)); - booster.effect.parameters['WarpNoiseAmplitudeStart0'] = new _core.Tw2Vector4Parameter('WarpNoiseAmplitudeStart0', _get(raceBooster.warpShape0, 'noiseAmplitureStart', [0, 0, 0, 0])); - booster.effect.parameters['WarpNoiseAmplitudeEnd0'] = new _core.Tw2Vector4Parameter('WarpNoiseAmplitudeEnd0', _get(raceBooster.warpShape0, 'noiseAmplitureEnd', [0, 0, 0, 0])); - booster.effect.parameters['WarpNoiseFrequency0'] = new _core.Tw2Vector4Parameter('WarpNoiseFrequency0', _get(raceBooster.warpShape0, 'noiseFrequency', [0, 0, 0, 0])); - booster.effect.parameters['WarpColor0'] = new _core.Tw2Vector4Parameter('WarpColor0', _get(raceBooster.warpShape0, 'color', [0, 0, 0, 0])); + for (var _i5 = 0; _i5 < this.aliveCount; ++_i5) { + if (hasForces) { + var amass = mass ? mass.buffer[mass.offset] : 1, + force = _global.vec3.set(vec3_0, 0, 0, 0); - booster.effect.parameters['WarpNoiseFunction1'] = new _core.Tw2FloatParameter('WarpNoiseFunction1', _get(raceBooster.warpShape1, 'noiseFunction', 0)); - booster.effect.parameters['WarpNoiseSpeed1'] = new _core.Tw2FloatParameter('WarpNoiseSpeed1', _get(raceBooster.warpShape1, 'noiseSpeed', 0)); - booster.effect.parameters['WarpNoiseAmplitudeStart1'] = new _core.Tw2Vector4Parameter('WarpNoiseAmplitudeStart1', _get(raceBooster.warpShape1, 'noiseAmplitureStart', [0, 0, 0, 0])); - booster.effect.parameters['WarpNoiseAmplitudeEnd1'] = new _core.Tw2Vector4Parameter('WarpNoiseAmplitudeEnd1', _get(raceBooster.warpShape1, 'noiseAmplitureEnd', [0, 0, 0, 0])); - booster.effect.parameters['WarpNoiseFrequency1'] = new _core.Tw2Vector4Parameter('WarpNoiseFrequency1', _get(raceBooster.warpShape1, 'noiseFrequency', [0, 0, 0, 0])); - booster.effect.parameters['WarpColor1'] = new _core.Tw2Vector4Parameter('WarpColor1', _get(raceBooster.warpShape1, 'color', [0, 0, 0, 0])); + for (var _j = 0; _j < this.forces.length; ++_j) { + this.forces[_j].ApplyForce(_position, _velocity, force, dt, amass); + } - booster.effect.parameters['ShapeAtlasSize'] = new _core.Tw2Vector4Parameter('ShapeAtlasSize', [_get(raceBooster, 'shapeAtlasHeight', 0), _get(raceBooster, 'shapeAtlasCount', 0), 0, 0]); - booster.effect.parameters['BoosterScale'] = new _core.Tw2Vector4Parameter('BoosterScale', _get(raceBooster, 'scale', [1, 1, 1, 1])); + if (mass) _global.vec3.scale(force, force, 1 / mass.buffer[mass.offset]); - booster.effect.parameters['ShapeMap'] = new _core.Tw2TextureParameter('ShapeMap', raceBooster.shapeAtlasResPath); - booster.effect.parameters['GradientMap0'] = new _core.Tw2TextureParameter('GradientMap0', raceBooster.gradient0ResPath); - booster.effect.parameters['GradientMap1'] = new _core.Tw2TextureParameter('GradientMap1', raceBooster.gradient1ResPath); - booster.effect.parameters['NoiseMap'] = new _core.Tw2TextureParameter('ShapeMap', 'res:/Texture/Global/noise32cube_volume.dds.0.png'); + _velocity.buffer[_velocity.offset] += force[0] * dt; + _velocity.buffer[_velocity.offset + 1] += force[1] * dt; + _velocity.buffer[_velocity.offset + 2] += force[2] * dt; + } - booster.effect.Initialize(); + _position.buffer[_position.offset] += _velocity.buffer[_velocity.offset] * dt; + _position.buffer[_position.offset + 1] += _velocity.buffer[_velocity.offset + 1] * dt; + _position.buffer[_position.offset + 2] += _velocity.buffer[_velocity.offset + 2] * dt; - booster.glows = new _item.EveSpriteSet(true); - booster.glows.effect = new _core.Tw2Effect(); - booster.glows.effect.effectFilePath = 'res:/Graphics/Effect/Managed/Space/Booster/BoosterGlowAnimated.fx'; - booster.glows.effect.parameters['DiffuseMap'] = new _core.Tw2TextureParameter('DiffuseMap', 'res:/Texture/Particle/whitesharp.dds.0.png'); - booster.glows.effect.parameters['NoiseMap'] = new _core.Tw2TextureParameter('NoiseMap', 'res:/Texture/global/noise.dds.0.png'); - booster.glows.effect.Initialize(); + if (this.emitParticleDuringLifeEmitter) { + this.emitParticleDuringLifeEmitter.SpawnParticles(_position, _velocity, dt); + } - var items = _get(hullBooster, 'items', []); - for (var i = 0; i < items.length; ++i) { - var locator = new _item.EveLocator(); - locator.name = 'locator_booster_' + (i + 1); - if ('transform' in items[i]) { - _math.mat4.copy(locator.transform, items[i].transform); - } else { - _math.mat4.identity(locator.transform); + _position.offset += _position.instanceStride; + _velocity.offset += _velocity.instanceStride; + + if (mass) mass.offset += mass.instanceStride; + } + _position.dirty = true; + _velocity.dirty = true; } - locator.atlasIndex0 = _get(items[i], 'atlasIndex0', 0); - locator.atlasIndex1 = _get(items[i], 'atlasIndex1', 0); - ship.locators.push(locator); - } - booster.Initialize(); - ship.boosters = booster; - } - function SetupLocators(ship, hull) { - var hullLocators = _get(hull, 'locatorTurrets', []); - for (var i = 0; i < hullLocators.length; ++i) { - var locator = new _item.EveLocator(); - locator.name = hullLocators[i].name; - if ('transform' in hullLocators[i]) { - _math.mat4.copy(locator.transform, hullLocators[i].transform); - } else { - _math.mat4.identity(locator.transform); + if (this.updateSimulation && this.constraints.length) { + for (var _i6 = 0; _i6 < this.constraints.length; ++_i6) { + this.constraints[_i6].ApplyConstraint(this.buffers, this.instanceStride, this.aliveCount, dt); + } } - ship.locators.push(locator); - } - } - function BindParticleEmitters(obj, curveSet, curve) { - for (var i = 0; i < obj.particleEmitters.length; ++i) { - if ('rate' in obj.particleEmitters[i]) { - var binding = new _core.Tw2ValueBinding(); - binding.sourceObject = curve; - binding.sourceAttribute = 'currentValue'; - binding.destinationObject = obj.particleEmitters[i]; - binding.destinationAttribute = 'rate'; - binding.Initialize(); - curveSet.bindings.push(binding); + if (this.updateBoundingBox) { + this.GetBoundingBox(this.aabbMin, this.aabbMax); } - } - for (i = 0; i < obj.children.length; ++i) { - BindParticleEmitters(obj.children[i], curveSet, curve); - } - } - function SetupChildren(ship, hull, curveSet, curves) { - function onChildLoaded(child) { - return function (obj) { - if (obj.isEffectChild) { - ship.effectChildren.push(obj); - } else { - ship.children.push(obj); + if (this.emitParticleDuringLifeEmitter && !(this.HasElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION) && this.HasElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.VELOCITY)) && this.updateSimulation) { + var _position2 = this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION), + _velocity2 = this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.VELOCITY); + + for (var _i7 = 0; _i7 < this.aliveCount; ++_i7) { + this.emitParticleDuringLifeEmitter.SpawnParticles(_position2, _velocity2, 1); + if (_position2) _position2.offset += _position2.instanceStride; + if (_velocity2) _velocity2.offset += _velocity2.instanceStride; } - _math.vec3.copy(obj.translation, _get(child, 'translation', [0, 0, 0])); - _math.quat.copy(obj.rotation, _get(child, 'rotation', [0, 0, 0, 1])); - _math.vec3.copy(obj.scaling, _get(child, 'scaling', [1, 1, 1])); - var id = _get(child, 'id', -1); - if (id !== -1 && curves[id]) { - BindParticleEmitters(obj, curveSet, curves[id]); + } + + for (var _i8 = 0; _i8 < this._elements.length; ++_i8) { + var el = this._elements[_i8]; + el.offset = el.startOffset; + if (el.dirty) { + this.bufferDirty = true; + el.dirty = false; } - }; + } } - var children = _get(hull, 'children', []); - for (var i = 0; i < children.length; ++i) { - _core.resMan.GetObject(children[i]['redFilePath'], onChildLoaded(children[i])); - } - } + /** + * Gets bounding box + * @param {vec3} aabbMin + * @param {vec3} aabbMax + * @returns {boolean} + */ - function SetupAnimations(ship, hull) { - var id_curves = []; - var curveSet = null; - var animations = _get(hull, 'animations', []); - for (var i = 0; i < animations.length; ++i) { - if (_get(animations[i], 'id', -1) !== -1 && _get(animations[i], 'startRate', -1) !== -1) { - if (!curveSet) { - curveSet = new _core.Tw2CurveSet(); + }, { + key: 'GetBoundingBox', + value: function GetBoundingBox(aabbMin, aabbMax) { + if (this.aliveCount && this.HasElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION)) { + var position = this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION); + aabbMin[0] = position.buffer[position.offset]; + aabbMin[1] = position.buffer[position.offset + 1]; + aabbMin[2] = position.buffer[position.offset + 2]; + aabbMax[0] = position.buffer[position.offset]; + aabbMax[1] = position.buffer[position.offset + 1]; + aabbMax[2] = position.buffer[position.offset + 2]; + for (var i = 0; i < this.aliveCount; ++i) { + aabbMin[0] = Math.min(aabbMin[0], position.buffer[position.offset]); + aabbMin[1] = Math.min(aabbMin[1], position.buffer[position.offset + 1]); + aabbMin[2] = Math.min(aabbMin[2], position.buffer[position.offset + 2]); + aabbMax[0] = Math.max(aabbMax[0], position.buffer[position.offset]); + aabbMax[1] = Math.max(aabbMax[1], position.buffer[position.offset + 1]); + aabbMax[2] = Math.max(aabbMax[2], position.buffer[position.offset + 2]); + position.offset += position.instanceStride; } - var curve = new _curve.Tw2ScalarCurve2(); - curve.keys.push(new _curve.Tw2ScalarKey2()); - curve.keys.push(new _curve.Tw2ScalarKey2()); - curve.keys[0].value = _get(animations[i], 'startRate', -1); - curve.keys[1].time = 1; - curve.keys[1].value = _get(animations[i], 'endRate', -1); - curve.Initialize(); - curveSet.curves.push(curve); - ship.curveSets.push(curveSet); - id_curves[_get(animations[i], 'id', -1)] = curve; + return true; } + return false; } - if (curveSet) { - curveSet.Initialize(); - } - return [curveSet, id_curves]; - } - var dataLoading = false; - var pendingLoads = []; - - function Build(dna) { - var parts = dna.split(':'); - var commands = {}; - for (var i = 3; i < parts.length; ++i) { - var subparts = parts[i].split('?'); - commands[subparts[0]] = subparts[1].split(';'); - } - var hull = data['hull'][parts[0]]; - var faction = data['faction'][parts[1]]; - var race = data['race'][parts[2]]; - var ship = new (_get(hull, 'buildClass', 0) === 2 ? _object.EveSpaceObject : _object.EveShip)(); - var pattern = SetupPattern(hull, race, commands); - SetupMesh(ship, hull, faction, race, commands, pattern); - SetupCustomMasks(ship, pattern); - SetupDecals(ship, hull, faction); - SetupSpriteSets(ship, hull, faction); - SetupSpotlightSets(ship, hull, faction); - SetupPlaneSets(ship, hull, faction); - SetupBoosters(ship, hull, race); - SetupLocators(ship, hull); - var curves = SetupAnimations(ship, hull); - SetupChildren(ship, hull, curves[0], curves[1]); - SetupInstancedMeshes(ship, hull, faction, race, commands, pattern); + /** + * _Sort + * @private + */ - ship.Initialize(); - return ship; - } + }, { + key: '_Sort', + value: function _Sort() { + var eye = _global.mat4.multiply(Tw2ParticleSystem.global.mat4_0, _global.device.projection, _global.device.view), + //device.viewInverse; + position = this.GetElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION), + count = this.aliveCount, + distances = this._distancesBuffer; - this.LoadData = function (callback) { - if (data === null) { - if (callback) { - pendingLoads.push(callback); - } - if (!dataLoading) { - spriteEffect = new _core.Tw2Effect(); - spriteEffect.effectFilePath = 'res:/graphics/effect/managed/space/spaceobject/fx/blinkinglightspool.fx'; - spriteEffect.parameters['MainIntensity'] = new _core.Tw2FloatParameter('MainIntensity', 1); - spriteEffect.parameters['GradientMap'] = new _core.Tw2TextureParameter('GradientMap', 'res:/texture/particle/whitesharp_gradient.dds.0.png'); - spriteEffect.Initialize(); + for (var i = 0; i < count; ++i) { + var o0 = position.offset + position.instanceStride * i; + var dd = position.buffer[o0] - eye[12], + l0 = dd * dd; - _core.resMan.GetObject('res:/dx9/model/spaceobjectfactory/data.red', function (obj) { - data = obj; - for (var i = 0; i < pendingLoads.length; ++i) { - pendingLoads[i](); - } - pendingLoads = []; - }); - dataLoading = true; - } - } else { - if (callback) { - callback(); + dd = position.buffer[o0 + 1] - eye[13]; + l0 += dd * dd; + dd = position.buffer[o0 + 2] - eye[14]; + l0 += dd * dd; + distances[i] = l0; } - } - }; - this.BuildFromDNA = function (dna, callback) { - if (data === null) { - this.LoadData(function () { - var result = Build(dna); - if (callback) { - callback(result); + /** + * sortItems + * @param a + * @param b + * @returns {number} + * @private + */ + function sortItems(a, b) { + if (a >= count && b >= count) { + if (a < b) return -1; + if (a > b) return 1; + return 0; } - }); - } else { - var result = Build(dna); - if (callback) { - callback(result); + + if (a >= count) return 1; + if (b >= count) return -1; + + var l0 = distances[a], + l1 = distances[b]; + + if (l0 < l1) return 1; + if (l0 > l1) return -1; + return 0; } - } - }; - function GetTurretMaterialParameter(name, parentFaction, areaData) { - var materialIdx = -1; - for (var i = 0; i < data['generic']['materialPrefixes'].length; ++i) { - if (name.substr(0, data['generic']['materialPrefixes'][i].length) === data['generic']['materialPrefixes'][i]) { - materialIdx = i; - name = name.substr(data['generic']['materialPrefixes'][i].length); + for (var _i9 = 0; _i9 < this.maxParticleCount; ++_i9) { + this._sortedIndexes[_i9] = _i9; } + + this._sortedIndexes.sort(sortItems); } - if (materialIdx !== -1) { - var turretMaterialIndex = _get(parentFaction, 'materialUsageMtl' + (materialIdx + 1), materialIdx); - if (turretMaterialIndex >= 0 && turretMaterialIndex < data['generic']['materialPrefixes'].length) { - name = data['generic']['materialPrefixes'][turretMaterialIndex] + name; - if (name in areaData.parameters) { - return areaData.parameters[name]; + + /** + * Updates and gets the particle system's InstanceBuffer + * @returns {?WebGLBuffer} + */ + + }, { + key: 'GetInstanceBuffer', + value: function GetInstanceBuffer() { + if (this.aliveCount === 0) return undefined; + + var d = _global.device; + if (this.requiresSorting && this.HasElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION) && this.buffers) { + this._Sort(); + + var stride = this.instanceStride[0], + gpuBuffer = this.buffers[0]; + + for (var i = 0; i < this.aliveCount; ++i) { + var toOffset = i * stride, + fromOffset = this._sortedIndexes[i] * stride; + + for (var j = 0; j < stride; ++j) { + this._sortedBuffer[toOffset + j] = gpuBuffer[j + fromOffset]; + } } + + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vb); + d.gl.bufferSubData(d.gl.ARRAY_BUFFER, 0, this._sortedBuffer.subarray(0, this.vertexStride[0] * this.aliveCount)); + this.bufferDirty = false; + } else if (this.bufferDirty) { + d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vb); + d.gl.bufferSubData(d.gl.ARRAY_BUFFER, 0, this.buffers[0].subarray(0, this.vertexStride[0] * this.aliveCount)); + this.bufferDirty = false; } + + return this._vb; } - } - var zeroColor = [0, 0, 0, 0]; + /** + * Gets the particle system's InstanceDeclaration + * @returns {Tw2VertexDeclaration} + */ - function CombineTurretMaterial(name, parentValue, turretValue, overrideMethod) { - switch (overrideMethod) { - case 'overridable': - return parentValue ? parentValue : turretValue ? turretValue : zeroColor; - case 'half_overridable': - if (name.indexOf('GlowColor') >= 0) { - return turretValue ? turretValue : zeroColor; - } - return parentValue ? parentValue : turretValue ? turretValue : zeroColor; - case 'not_overridable': - case 'half_overridable_2': - return turretValue ? turretValue : zeroColor; + }, { + key: 'GetInstanceDeclaration', + value: function GetInstanceDeclaration() { + return this._declaration; } - return zeroColor; - } - function SetupTurretMaterial(turretSet, parentFactionName, turretFactionName) { - var parentFaction = data['faction'][parentFactionName]; - var turretFaction = data['faction'][turretFactionName]; - var parentArea = null; - if (parentFaction && parentFaction.areas && 'hull' in parentFaction.areas) { - parentArea = parentFaction.areas.hull; - } - var turretArea = null; - if (turretFaction && turretFaction.areas && 'hull' in turretFaction.areas) { - turretArea = turretFaction.areas.hull; - } - if (!parentArea && !turretArea) { - return; - } - if (turretSet.turretEffect) { - var params = turretSet.turretEffect.parameters; - for (var i in params) { - if (params.hasOwnProperty(i)) { - if (params[i].constructor.prototype !== _core.Tw2Vector4Parameter.prototype) { - continue; - } - var parentValue = null; - var turretValue = null; - if (parentArea) { - parentValue = GetTurretMaterialParameter(i, parentFaction, parentArea); - } - if (turretArea) { - turretValue = GetTurretMaterialParameter(i, parentFaction, parentArea); - } - _math.vec4.copy(params[i].value, CombineTurretMaterial(i, parentValue, turretValue, turretSet.turretEffect.name)); - } - } - turretSet.turretEffect.BindParameters(); + /** + * Gets the particle system's InstanceStride + * @returns {number} + */ + + }, { + key: 'GetInstanceStride', + value: function GetInstanceStride() { + return this.instanceStride[0]; } - } - this.SetupTurretMaterial = function (turretSet, parentFactionName, turretFactionName, callback) { - if (data === null) { - this.LoadData(function () { - SetupTurretMaterial(turretSet, parentFactionName, turretFactionName); - if (callback) { - callback(); - } - }); - } else { - SetupTurretMaterial(turretSet, parentFactionName, turretFactionName); - if (callback) { - callback(); - } + /** + * Gets the particle system's InstanceCount + * @returns {number} + */ + + }, { + key: 'GetInstanceCount', + value: function GetInstanceCount() { + return this.aliveCount; } - }; - function getDataKeys(name) { - if (name !== 'all') { - var names = {}; - for (var i in data[name]) { - if (data[name].hasOwnProperty(i)) { - names[i] = data[name][i].description || ''; - } + /** + * Initializes class globals + */ + + }], [{ + key: 'init', + value: function init() { + if (!Tw2ParticleSystem.global) { + Tw2ParticleSystem.global = { + vec3_0: _global.vec3.create(), + mat4_0: _global.mat4.create() + }; } - return names; - } else { - return data; } - } + }]); - this.GetHullNames = function (callback) { - this.LoadData(function () { - callback(getDataKeys('hull')); - }); - }; + return Tw2ParticleSystem; +}(); - this.GetFactionNames = function (callback) { - this.LoadData(function () { - callback(getDataKeys('faction')); - }); - }; +/** + * Class globals + */ - this.GetRaceNames = function (callback) { - this.LoadData(function () { - callback(getDataKeys('race')); - }); - }; - this.GetSofData = function (callback) { - this.LoadData(function () { - callback(getDataKeys('all')); - }); - }; -} +Tw2ParticleSystem.global = null; /***/ }) /******/ ]); diff --git a/dist/ccpwgl_int.min.js b/dist/ccpwgl_int.min.js index 372935e..e1dfadd 100644 --- a/dist/ccpwgl_int.min.js +++ b/dist/ccpwgl_int.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ccpwgl_int=t():e.ccpwgl_int=t()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=64)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(30);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(66);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(34);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(35);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(72);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(73);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(74);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(75);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(76);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})});var h=r(77);Object.keys(h).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return h[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(20);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(86);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(96);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(98);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(17);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(46);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(47);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(131);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(24);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})});var h=r(137);Object.keys(h).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return h[e]}})});var p=r(29);Object.keys(p).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return p[e]}})});var d=r(28);Object.keys(d).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return d[e]}})});var v=r(21);Object.keys(v).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return v[e]}})});var m=r(9);Object.keys(m).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return m[e]}})});var y=r(139);Object.keys(y).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return y[e]}})});var b=r(140);Object.keys(b).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return b[e]}})});var g=r(56);Object.keys(g).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return g[e]}})});var _=r(36);Object.keys(_).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return _[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.device=t.Tw2Device=void 0;var n=function(){function e(e,t){for(var r=0;r1,this.canvas=t,this.Resize();return this._quadBuffer=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,this._quadBuffer),n.bufferData(n.ARRAY_BUFFER,new Float32Array([1,1,0,1,1,1,-1,1,0,1,0,1,1,-1,0,1,1,0,-1,-1,0,1,0,0]),n.STATIC_DRAW),this._cameraQuadBuffer=n.createBuffer(),this._quadDecl=new l.Tw2VertexDeclaration,this._quadDecl.elements.push(new l.Tw2VertexElement(l.Tw2VertexDeclaration.Type.POSITION,0,n.FLOAT,4,0)),this._quadDecl.elements.push(new l.Tw2VertexElement(l.Tw2VertexDeclaration.Type.TEXCOORD,0,n.FLOAT,2,16)),this._quadDecl.RebuildHash(),this._alphaTestState={},this._alphaTestState.states={},this._alphaTestState.states[this.RS_ALPHATESTENABLE]=0,this._alphaTestState.states[this.RS_ALPHAREF]=-1,this._alphaTestState.states[this.RS_ALPHAFUNC]=this.CMP_GREATER,this._alphaTestState.states[this.RS_CLIPPING]=0,this._alphaTestState.states[this.RS_CLIPPLANEENABLE]=0,this._alphaTestState.dirty=!1,this._alphaBlendState={},this._alphaBlendState.states={},this._alphaBlendState.states[this.RS_SRCBLEND]=this.BLEND_SRCALPHA,this._alphaBlendState.states[this.RS_DESTBLEND]=this.BLEND_INVSRCALPHA,this._alphaBlendState.states[this.RS_BLENDOP]=this.BLENDOP_ADD,this._alphaBlendState.states[this.RS_SEPARATEALPHABLENDENABLE]=0,this._alphaBlendState.states[this.RS_BLENDOPALPHA]=this.BLENDOP_ADD,this._alphaBlendState.states[this.RS_SRCBLENDALPHA]=this.BLEND_SRCALPHA,this._alphaBlendState.states[this.RS_DESTBLENDALPHA]=this.BLEND_INVSRCALPHA,this._alphaBlendState.dirty=!1,this._depthOffsetState={},this._depthOffsetState.states={},this._depthOffsetState.states[this.RS_SLOPESCALEDEPTHBIAS]=0,this._depthOffsetState.states[this.RS_DEPTHBIAS]=0,this._depthOffsetState.dirty=!1,this.wrapModes=[],this.wrapModes[0]=0,this.wrapModes[1]=n.REPEAT,this.wrapModes[2]=n.MIRRORED_REPEAT,this.wrapModes[3]=n.CLAMP_TO_EDGE,this.wrapModes[4]=n.CLAMP_TO_EDGE,this.wrapModes[5]=n.CLAMP_TO_EDGE,this._shadowStateBuffer=new Float32Array(24),this._blendTable=[-1,n.ZERO,n.ONE,n.SRC_COLOR,n.ONE_MINUS_SRC_COLOR,n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.DST_ALPHA,n.ONE_MINUS_DST_ALPHA,n.DST_COLOR,n.ONE_MINUS_DST_COLOR,n.SRC_ALPHA_SATURATE,-1,-1,n.CONSTANT_COLOR,n.ONE_MINUS_CONSTANT_COLOR],this.glVersion}},{key:"Schedule",value:function(e){this._scheduled.includes(e)||this._scheduled.push(e)}},{key:"OnResize",value:function(e){this._onResize=e}},{key:"Resize",value:function(){if(this.vrDisplay&&this.vrDisplay.isPresenting){var e=this.vrDisplay.getEyeParameters("left"),t=this.vrDisplay.getEyeParameters("right");this.canvas.width=2*Math.max(e.renderWidth,t.renderWidth),this.canvas.height=Math.max(t.renderHeight,t.renderHeight)}else this.canvas.width=this.canvas.offsetWidth*this.viewportPixelRatio,this.canvas.height=this.canvas.offsetHeight*this.viewportPixelRatio;this.viewportWidth=this.canvas.clientWidth,this.viewportHeight=this.canvas.clientHeight,this.viewportAspect=this.viewportWidth/this.viewportHeight,this._onResize&&this._onResize(this.viewportWidth,this.viewportHeight),a.store.SetVariableValue("ViewportSize",[this.viewportWidth,this.viewportHeight,this.viewportWidth,this.viewportHeight])}},{key:"Tick",value:function(){this.canvas.clientWidth===this.viewportWidth&&this.canvas.clientHeight===this.viewportHeight||this.Resize();var e=null===this.previousTime?0:this.previousTime,t=this.Now();this.currentTime=.001*(t-this.startTime),this.dt=null===this.previousTime?0:.001*(t-this.previousTime),this.previousTime=t,a.store.SetVariableValue("Time",[this.currentTime,this.currentTime-Math.floor(this.currentTime),this.frameCounter,e]),s.resMan.PrepareLoop(this.dt);for(var r=0;r1.6&&(r=t/1.6);var n=2*Math.atan(r/this.projection[5]);return e[0]=this.viewportWidth,e[1]=this.viewportHeight,e[2]=n,e[3]=n*t,e}},{key:"GetEyePosition",value:function(e){return i.vec3.copy(e,this.eyePosition)}},{key:"IsAlphaTestEnabled",value:function(){return this._alphaTestState.states[this.RS_ALPHATESTENABLE]}},{key:"IsFrameBufferComplete",value:function(e){return this.gl.checkFramebufferStatus(e)===this.gl.FRAMEBUFFER_COMPLETE}},{key:"GetExtension",value:function(t){for(var r in e.WebglVendorPrefixes)if(e.WebglVendorPrefixes.hasOwnProperty(r)){var n=this.gl.getExtension(e.WebglVendorPrefixes[r]+t);if(n)return n}return null}},{key:"GetFallbackTexture",value:function(){return this._fallbackTexture||(this._fallbackTexture=this.CreateSolidTexture()),this._fallbackTexture}},{key:"GetFallbackCubeMap",value:function(){return this._fallbackCube||(this._fallbackCube=this.CreateSolidCube()),this._fallbackCube}},{key:"CreateSolidTexture",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],t=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,1,1,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(e)),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.bindTexture(this.gl.TEXTURE_2D,null),t}},{key:"CreateSolidCube",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],t=this.gl.createTexture();this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP,t);for(var r=0;r<6;++r)this.gl.texImage2D(this.gl.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,this.gl.RGBA,1,1,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(e));return this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP,null),t}},{key:"RenderFullScreenQuad",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Main";if(!e||!e.IsGood())return!1;this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._quadBuffer);for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:"Main";if(!e||!e.IsGood())return!1;for(var r=new Float32Array([1,1,0,1,1,1,-1,1,0,1,0,1,1,-1,0,1,1,0,-1,-1,0,1,0,0]),n=this.projectionInverse,a=0;a<4;++a){var o=r.subarray(6*a,6*a+4);i.vec4.transformMat4(o,o,n),i.vec3.scale(o,o,1/o[3]),o[3]=1}this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._cameraQuadBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,r,this.gl.STATIC_DRAW);for(var s=0;s>16,r=(4278190080&e)>>24,n=(r<<1&255|t>>7)-127,i=(127&t)<<16|(65280&e)>>8<<8|255&e;return 0===i&&-127===n?0:(1-2*(r>>7))*(1+i*Math.pow(2,-23))*Math.pow(2,n)}},{key:"CreateContext",value:function(e,t,r){r=Array.isArray(r)?r:[r];for(var n=0;nt.time?1:0}},{key:"Sort",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.keys;r&&r.length&&(r.sort(e.Compare),t.length=r[r.length-1].time)}},{key:"Sort2",value:function(t){if(t.keys&&t.keys.length){t.keys.sort(e.Compare);var r=t.keys[t.keys.length-1];if(r.time>t.length){var n=t.length,i=t.endValue,a=t.endTangent;t.length=r.time,t.endValue=r.value,t.endTangent=r.leftTangent,n>0&&(r.time=n,r.value=i,r.leftTangent=a)}}}}]),e}();o.inputDimension=null,o.outputDimension=null,o.valueProperty=null,o.curveType=null,o.Key=null,o.Interpolation=null,o.Extrapolation=null,o.Type={CURVE:1,CURVE2:2,CURVE_MAYA:3,CURVE_NO_KEYS:4,SEQUENCER:100,SEQUENCER2:101},o.global={vec3_0:i.vec3.create(),vec4_0:i.vec4.create(),quat_0:i.quat.create(),quat_1:i.quat.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logger=t.Tw2Logger=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r.name=e,r.display=!0,r.visible={},r.visible.log=!0,r.visible.info=!0,r.visible.debug=!0,r.visible.warn=!0,r.visible.error=!0,r.maxLogs=100,r._logs=[],r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.Tw2EventEmitter),n(t,[{key:"log",value:function(e,r){if(r.log=t.Type[r.log?r.log.toUpperCase():"LOG"]||"log",!r.hide&&this.display&&this.visible[r.log]){var n=this.name+": {"+e+"}",i=r.msg||"";r.path&&(i+=" '"+r.path+"'","time"in r&&(i+=" in "+r.time.toFixed(3)+" secs")),(void 0!==r.value||r.type)&&(i+=" (",r.type&&(i+=r.type),r.type&&void 0!==r.value&&(i+=":"),void 0!==r.value&&(i+=r.value),i+=")"),"data"in r||"err"in r?(console.group(n),console[r.log](i),r.data&&console.debug(r.data),r.err&&console.debug(r.err.stack||r.err.toString()),console.groupEnd()):console[r.log](n,i)}return this.maxLogs?(this._logs.length>=this.maxLogs&&this._logs.splice(this.maxLogs,this._logs.length-1),this._logs.unshift(r)):this._logs=[],this.emit("log",r),r}},{key:"GetLogs",value:function(e){return Object.assign([],void 0===e?this._logs:this._logs.splice(0,e))}},{key:"Set",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a.util.assignIfExists(this,e,["name","maxLogs","display"]),a.util.assignIfExists(this.visible,e.visible,["log","info","debug","warn","error"])}}]),t}();t.Tw2Logger=o,o.Type={THROW:"error",ERROR:"error",WARNING:"warn",WARN:"warn",INFO:"info",LOG:"log",DEBUG:"debug"};var s=t.logger=new o("CCPWGL");i.Tw2EventEmitter.logger=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r.d(t,"ARRAY_TYPE",function(){return i}),t.setMatrixArrayType=function(e){i=e},t.toRadian=function(e){return e*o},t.equals=function(e,t){return Math.abs(e-t)<=n*Math.max(1,Math.abs(e),Math.abs(t))};const n=1e-6;t.EPSILON=n;let i="undefined"!=typeof Float32Array?Float32Array:Array;const a=Math.random;t.RANDOM=a;const o=Math.PI/180},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resMan=t.Tw2ResMan=void 0;var n=function(){function e(e,t){for(var r=0;r1&&(this.activeFrame+=1,this._purgeTime-=Math.floor(this._purgeTime),this._purgeFrame+=1,this._purgeFrame>=5&&this.autoPurgeResources&&this.motherLode.PurgeInactive(this._purgeFrame,this._purgeFrameLimit,this.purgeTime)),!0}},{key:"GetResource",value:function(t){var r=void 0;if(t=e.NormalizePath(t),r=this.motherLode.Find(t))return r.IsPurged()&&r.Reload(),r;var n=e.GetPathExt(t);if(null===n)return i.logger.log("res.error",{log:"error",src:["Tw2ResMan","ReloadResource"],msg:"Undefined extension",type:"extension.undefined",path:t}),null;var o=a.store.GetExtension(n);return o?((r=new o).path=t,e.LoadResource(this,r)):(i.logger.log("res.error",{log:"error",src:["Tw2ResMan","ReloadResource"],msg:"Unregistered extension",type:"extension.unregistered",path:t,value:n}),null)}},{key:"GetObject",value:function(t,r){var n={};t=e.NormalizePath(t);var i=this.motherLode.Find(t);i?i.AddObject(n,r):((i=new s.Tw2LoadingObject).path=t,i.AddObject(n,r),e.LoadResource(this,i))}},{key:"ReloadResource",value:function(t){var r=t.path,n=this.motherLode.Find(r);return n&&!n.IsPurged()?n:(i.logger.log("res.event",{msg:"Reloading ",path:r,type:"reload"}),e.LoadResource(this,t))}}],[{key:"BuildUrl",value:function(e){var t=e.indexOf(":/");if(-1===t)return i.logger.log("res.error",{log:"warn",src:["Tw2ResMan","BuildUrl"],msg:"Invalid path",type:"prefix.undefined",path:e}),e;var r=e.substr(0,t),n=a.store.GetPath(r);return n?n+e.substr(t+2):(i.logger.log("res.error",{log:"warn",src:["Tw2ResMan","BuildUrl"],msg:"Unregistered path",path:e,type:"prefix.unregistered",value:r}),e)}},{key:"NormalizePath",value:function(e){return"str:/"===e.substr(0,5)?e:((e=e.toLowerCase()).replace("\\","/"),e)}},{key:"GetPathExt",value:function(e){if("str:/"===e.substr(0,5)){var t=e.indexOf("/",5);return-1===t?null:e.substr(5,t-5)}var r=e.lastIndexOf(".");return-1===r?null:e.substr(r+1)}},{key:"LogPathString",value:function(e){return"str:/"===e.substr(0,5)&&e.length>64?e.substr(0,64)+"...":e}},{key:"LoadResource",value:function(t,r){var n=r.path,a=e.BuildUrl(n);if(r._isPurged=!1,t.motherLode.Add(n,r),r.DoCustomLoad&&r.DoCustomLoad(a))return r;var o=e.CreateHttpRequest(r.requestResponseType);if(o){i.logger.log("res.event",{msg:"Requesting",path:n,type:"request"}),o.onreadystatechange=e.DoLoadResource(t,r),o.open("GET",a),r.LoadStarted();try{o.send(),t._pendingLoads++}catch(e){i.logger.log("res.error",{log:"error",src:["Tw2ResMan","LoadResource"],msg:"Error sending object HTTP request",path:n,type:"http.request",err:e})}}return r}},{key:"DoLoadResource",value:function(e,t){return function(){var r=0;try{r=this.readyState}catch(n){return i.logger.log("res.error",{log:"error",src:["Tw2ResMan","_DoLoadResource"],msg:"Communication error loading",path:t.path,type:"http.readystate",value:r}),t.LoadFinished(!1),void e._pendingLoads--}if(4===r){if(200===this.status){var n=null,a=null;try{n=this.responseText,a=this.responseXML}catch(e){n=this.response}t.LoadFinished(!0),e._prepareQueue.push([t,n,a])}else i.logger.log("res.error",{log:"error",src:["Tw2ResMan","_DoLoadResource"],msg:"Communication error loading",path:t.path,type:"http.status",value:this.status}),t.LoadFinished(!1),t.PrepareFinished(!1);e._pendingLoads--}}}},{key:"CreateHttpRequest",value:function(e){var t=null;if(window.XMLHttpRequest)t=new XMLHttpRequest;else if(window.ActiveXObject)try{t=new window.ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{t=new window.ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}return t?e&&(t.responseType=e):i.logger.log("res.error",{log:"error",src:["Tw2LoadingObject","Prepare"],msg:"Could not create an XMLHTTP instance",type:"http.instance"}),t}}]),e}();t.resMan=new u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VectorParameter=t.Tw2Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";a(this,e),this._id=i.util.generateID(),this.name=t,this._onModified=[]}return n(e,[{key:"OnValueChanged",value:function(e,t){for(var r=0;r=this.size&&(this.constantBuffer=e,this.offset=t,this.Apply(e,t,r),!0)}},{key:"Unbind",value:function(){this.constantBuffer=null}},{key:"Apply",value:function(e,t,r){e.set(this.value,t)}},{key:"EqualsValue",value:function(e){for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:{},t=this.constructor.Item;if(t&&"create"in t){var r=t.create(e);return this.AddItem(r),r}return null}},{key:"AddItem",value:function(e){this.items.includes(e)||(e._onModified=this._onChildModified,this.items.push(e),this.OnValueChanged())}},{key:"RemoveItem",value:function(e){var t=this.items.indexOf(e);-1!==t&&(e._onModified=null,this.items.splice(t,1),this.OnValueChanged())}},{key:"ClearItems",value:function(){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:null;if(null!==e)for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e){this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this),this._rebuildPending=!1}},{key:"GetBatches",value:function(e,t,r){}},{key:"Render",value:function(){}}],[{key:"RebuildItems",value:function(e){e._visibleItems=[];for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e,t){this.useSRT&&(i.quat.normalize(this.rotation,this.rotation),i.mat4.fromRotationTranslationScale(this.localTransform,this.rotation,this.translation,this.scaling)),i.mat4.copy(this.worldTransformLast,this.worldTransform),i.mat4.multiply(this.worldTransform,t,this.localTransform)}},{key:"GetBatches",value:function(e,t){}}]),e}()).global={mat4_0:i.mat4.create(),vec3_0:i.vec3.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveObject=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e){}},{key:"GetBatches",value:function(e,t){}}]),e}()).global={vec3_0:i.vec3.create(),vec3_1:i.vec3.create(),vec3_2:i.vec3.create(),vec3_3:i.vec3.create(),vec3_4:i.vec3.create(),vec3_5:i.vec3.create(),vec3_6:i.vec3.create(),vec3_7:i.vec3.create(),mat4_0:i.mat4.create(),mat4_1:i.mat4.create(),mat4_2:i.mat4.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.store=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};"uuid"in e&&i.util.enableUUID(e.uuid),this.RegisterPaths(e.paths),this.RegisterDynamicPaths(e.dynamicPaths),this.RegisterTypes(e.types),this.RegisterConstructors(e.constructors),this.RegisterExtensions(e.extensions),this.RegisterVariables(e.variables)}}],[{key:"GetStoreItem",value:function(e,t,r){if("string"==typeof r){var n=e["_"+t],i=t.substring(0,t.length-1);if(n){if(r in n)return n[r];e._missing[t]||(e._missing[t]=[]),e._missing[t].includes(r)||(e._missing[t].push(r),a.logger.log("store.warning",{log:"warning",msg:"Missing "+i+": '"+r+"'"}))}}return null}},{key:"SetStoreItem",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=arguments[3];if("string"==typeof r&&void 0!==n){var i=e["_"+t];if(i){var o=i[r],s=t.substring(0,t.length-1);return i[r]=n,o?a.logger.log("store.registered",{log:"debug",msg:"Re-registered "+s+": '"+r+"'",data:{old_value:o,new_value:n}}):a.logger.log("store.registered",{log:"debug",msg:"Registered "+s+": '"+r+"'",hide:!0}),n}}return!1}},{key:"RegisterFromObject",value:function(e,t,r){if(r&&t in e){r=Array.isArray(r)?r:[r];for(var n=0;nr.size?t.subarray(0,r.size):t,r.offset)}},{key:"Get",value:function(e){return this.elements[e].array}},{key:"GetData",value:function(e){return this.data.subarray(this.elements[e].offset,this.elements[e].offset+this.elements[e].array.length)}},{key:"Create",value:function(){for(var e in this.data=new Float32Array(this.nextOffset),this.elements)if(this.elements.hasOwnProperty(e)){var t=this.elements[e];if(t.array=this.data.subarray(t.offset,t.offset+t.size),null!==t.value){if(1===t.size)t.array[0]=t.value;else for(var r=0;r2&&void 0!==arguments[2]?arguments[2]:null;this.elements[e]={offset:this.nextOffset,size:t,array:null,value:r},this.nextOffset+=t}},{key:"DeclareFromObject",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in e)if(e.hasOwnProperty(t)){var r=e[t];if("number"==typeof r)this.Declare(t,1,r);else{if(!a.util.isArrayLike(r))throw new Error("Invalid declaration type: "+(void 0===r?"undefined":n(r)));1===r.length&&this.Declare(t,r.length,r)}}this.Create()}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2ParticleEmitter=void 0;var n=function(){function e(e,t){for(var r=0;r1?0:i<-1?Math.PI:Math.acos(i)},t.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},t.equals=function(e,t){let r=e[0],i=e[1],a=e[2],o=t[0],s=t[1],u=t[2];return Math.abs(r-o)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-s)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(a-u)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(u))};var n=r(5);function i(){let e=new n.ARRAY_TYPE(3);return e[0]=0,e[1]=0,e[2]=0,e}function a(e){let t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function o(e,t,r){let i=new n.ARRAY_TYPE(3);return i[0]=e,i[1]=t,i[2]=r,i}function s(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function u(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function l(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function c(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(r*r+n*n+i*i)}function f(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return r*r+n*n+i*i}function h(e){let t=e[0],r=e[1],n=e[2];return t*t+r*r+n*n}function p(e,t){let r=t[0],n=t[1],i=t[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a),e}function d(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}const v=s;t.sub=v;const m=u;t.mul=m;const y=l;t.div=y;const b=c;t.dist=b;const g=f;t.sqrDist=g;const _=a;t.len=_;const E=h;t.sqrLen=E;const T=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=3),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s0&&(o=1/Math.sqrt(o),e[0]=r*o,e[1]=n*o,e[2]=i*o,e[3]=a*o),e}const d=a;t.sub=d;const v=o;t.mul=v;const m=s;t.div=m;const y=l;t.dist=y;const b=c;t.sqrDist=b;const g=f;t.len=g;const _=h;t.sqrLen=_;const E=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=4),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s2&&void 0!==arguments[2]?arguments[2]:void 0,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=i.get(this).events;return o[e=e.toLowerCase()]||(o[e]=new Set,o[e].add(function(){return r.emit("event_added",{eventName:e})},{once:!0})),o[e].add(t,{context:n,once:a}),this}},{key:"once",value:function(e,t,r){return this.on(e,t,r,!0)}},{key:"off",value:function(e,t){var r=i.get(this).events;return(e=e.toLowerCase())in r&&r[e].delete(t),this}},{key:"del",value:function(e){var t=i.get(this).events;return(e=e.toLowerCase())in t&&(this.emit("event_removed",{eventName:e}),delete t[e]),this}},{key:"clr",value:function(e){var t=i.get(this).events;for(var r in t)t.hasOwnProperty(r)&&t[r].has(e)&&t[r].delete(e);return this}},{key:"kill",value:function(){return this.emit("event_kill"),i.get(this).events={},this}},{key:"log",value:function(e,t){return this.constructor.logger&&this.constructor.logger.log(e,t),t}}]),e}()).logger=null},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2LoadingObject=void 0;var n=function(){function e(e,t){for(var r=0;r127&&(e=e-255-1),e}},{key:"ReadUInt16",value:function(){return this.data[this.cursor++]+(this.data[this.cursor++]<<8)}},{key:"ReadInt16",value:function(){var e=this.data[this.cursor++]+(this.data[this.cursor++]<<8);return e>32767&&(e=e-65535-1),e}},{key:"ReadUInt32",value:function(){return this.data[this.cursor++]+(this.data[this.cursor++]<<8)+(this.data[this.cursor++]<<16)+(this.data[this.cursor++]<<24>>>0)}},{key:"ReadInt32",value:function(){var e=this.data[this.cursor++]+(this.data[this.cursor++]<<8)+(this.data[this.cursor++]<<16)+(this.data[this.cursor++]<<24>>>0);return e>2147483647&&(e=e-4294967295-1),e}},{key:"ReadFloat16",value:function(){var e=this.data[this.cursor++],t=this.data[this.cursor++],r=(t>>2&31)-15,n=(3&t)<<8|e;return 0===n&&-15===r?0:(1-2*(t>>7))*(1+n*Math.pow(2,-10))*Math.pow(2,r)}},{key:"ReadFloat32",value:function(){var e=this.data[this.cursor++],t=this.data[this.cursor++],r=this.data[this.cursor++],n=this.data[this.cursor++],i=(n<<1&255|r>>7)-127,a=(127&r)<<16|t<<8|e;return 0===a&&-127===i?0:(1-2*(n>>7))*(1+a*Math.pow(2,-23))*Math.pow(2,i)}},{key:"ReadString",value:function(){for(var e=this.data[this.cursor++],t="",r=0;r0&&void 0!==arguments[0]?arguments[0]:[];for(var t in this.effectRes&&!e.includes(this.effectRes)&&e.push(this.effectRes),this.parameters)this.parameters.hasOwnProperty(t)&&"GetResources"in this.parameters[t]&&this.parameters[t].GetResources(e);return e}},{key:"RebuildCachedData",value:function(e){this.shader=e.GetShader(this.options),this.BindParameters()}},{key:"UnBindParameters",value:function(){for(var e in this.techniques)if(this.techniques.hasOwnProperty(e))for(var t=this.techniques[e],r=0;r=this.techniques[e].length)){this.shader.ApplyPass(e,t);for(var r=this.techniques[e][t],n=this.shader.techniques[e].passes[t],i=a.device,o=i.IsAlphaTestEnabled()&&n.shadowShaderProgram?n.shadowShaderProgram:n.shaderProgram,s=0;s<2;++s){for(var u=r.stages[s],l=0;l=this.techniques[e].length?null:a.device.IsAlphaTestEnabled()&&this.shader.techniques[e].passes[t].shadowShaderProgram?this.shader.techniques[e].passes[t].shadowShaderProgram.input:this.shader.techniques[e].passes[t].shaderProgram.input}},{key:"Render",value:function(e){for(var t=this.GetPassCount("Main"),r=0;r0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)if(this.parameters.hasOwnProperty(t)&&this.parameters[t]instanceof o.Tw2TextureParameter){var r=this.parameters[t].GetValue();r&&(e[t]=r)}return e}},{key:"SetTextures",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=e[r],i=this.parameters[r];o.Tw2TextureParameter.is(n)&&(i?i.EqualsValue(n)||(i.SetTexturePath(n),t=!0):(this.parameters[r]=new o.Tw2TextureParameter(r,n),t=!0))}return t}},{key:"GetParameters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)!this.parameters.hasOwnProperty(t)||this.parameters[t]instanceof o.Tw2TextureParameter||(e[t]=this.parameters[t].GetValue(!0));return e}},{key:"SetParameters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=e[r],i=this.parameters[r];if(i)i.constructor.is(n)&&!i.EqualsValue(n)&&(this.parameters[r].SetValue(n),t=!0);else{var o=a.store.CreateType(r,n);o&&(this.parameters[r]=o,t=!0)}}return t}},{key:"SetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=this.parameters[r];if(n&&n instanceof o.Tw2TextureParameter){var i=!1,a=e[r];for(var s in a)if(a.hasOwnProperty(s)&&o.Tw2TextureParameter.overrideProperties.includes(s)&&a[s]!==n[s]){i=!0;break}i&&(n.SetOverrides(e[r]),t=!0)}}return t}},{key:"GetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)if(this.parameters.hasOwnProperty(t)){var r=this.parameters[t];r&&r instanceof o.Tw2TextureParameter&&r.useAllOverrides&&(e[t]=this.parameters[t].GetOverrides())}return e}}],[{key:"ToEffectResPath",value:function(e){return(e=e?e.substr(0,e.lastIndexOf(".")).replace("/effect/",a.device.effectDir)+".sm_"+a.device.shaderModel:"").toLowerCase()}},{key:"FromEffectResPath",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"fx";return(e=e.substr(0,e.lastIndexOf(".")).replace(a.device.effectDir,"/effect/")+"."+t).toLowerCase()}},{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new this;if(i.util.assignIfExists(t,e,["name","effectFilePath","display","autoParameter"]),"parameters"in e&&t.SetParameters(e.parameters),"textures"in e&&t.SetTextures(e.textures),"overrides"in e&&t.SetOverrides(e.overrides),""===t.name&&""!==e.effectFilePath){var r=e.effectFilePath;t.name=r.substring(r.lastIndexOf("/")+1,r.length)}return t.Initialize(),t}}]),e}()).ConstantIgnore=["PerFrameVS","PerObjectVS","PerFramePS","PerObjectPS","PerObjectPSInt"]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TextureParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.resourcePath=r,n.useAllOverrides=!1,n.addressUMode=1,n.addressVMode=1,n.addressWMode=1,n.filterMode=2,n.mipFilterMode=2,n.maxAnisotropy=4,n.textureRes=null,n._sampler=null,r&&n.Initialize(),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,s.Tw2Parameter),n(t,[{key:"Initialize",value:function(){this.OnValueChanged()}},{key:"SetTexturePath",value:function(e){this.resourcePath=e,this.OnValueChanged()}},{key:"GetValue",value:function(){return this.isTextureAttached?null:this.resourcePath}},{key:"SetTextureRes",value:function(e){this.textureRes!==e&&(this.resourcePath="",this.textureRes=e),this.textureRes._isAttached=!0}},{key:"OnValueChanged",value:function(e,r){""!==this.resourcePath&&(this.resourcePath=this.resourcePath.toLowerCase(),this.textureRes=""!==this.resourcePath?i.resMan.GetResource(this.resourcePath):null),this.UpdateOverrides(),function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,r,n)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(n):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"OnValueChanged",this).call(this,e,r)}},{key:"Apply",value:function(e,t,r){this.textureRes&&(this.useAllOverrides&&(this._sampler.samplerType=t.samplerType,this._sampler.isVolume=t.isVolume,this._sampler.registerIndex=t.registerIndex,t=this._sampler),a.device.gl.activeTexture(a.device.gl.TEXTURE0+e),this.textureRes.Bind(t,r))}},{key:"SetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};u.util.assignIfExists(this,e,t.overrideProperties),this.OnValueChanged()}},{key:"GetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return u.util.assignIfExists(e,this,t.overrideProperties),e}},{key:"UpdateOverrides",value:function(){if(this.useAllOverrides){this._sampler=this._sampler||new o.Tw2SamplerState;var e=this._sampler;if(1===this.filterMode){switch(this.mipFilterMode){case 0:e.minFilter=a.device.gl.NEAREST;break;case 1:e.minFilter=a.device.gl.NEAREST_MIPMAP_NEAREST;break;default:e.minFilter=a.device.gl.NEAREST_MIPMAP_LINEAR}e.minFilterNoMips=a.device.gl.NEAREST,e.magFilter=a.device.gl.NEAREST}else{switch(this.mipFilterMode){case 0:e.minFilter=a.device.gl.LINEAR;break;case 1:e.minFilter=a.device.gl.LINEAR_MIPMAP_NEAREST;break;default:e.minFilter=a.device.gl.LINEAR_MIPMAP_LINEAR}e.minFilterNoMips=a.device.gl.LINEAR,e.magFilter=a.device.gl.LINEAR}e.addressU=a.device.wrapModes[this.addressUMode],e.addressV=a.device.wrapModes[this.addressVMode],e.addressW=a.device.wrapModes[this.addressWMode],e.anisotropy=this.maxAnisotropy,e.ComputeHash()}else this._sampler&&(this._sampler=null)}},{key:"EqualsValue",value:function(e){return e.toLowerCase()===this.GetValue()}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.resourcePath=e.resourcePath,this.SetOverrides(e.GetOverrides)}},{key:"Clone",value:function(){var e=new t;return e.Copy(this,!0),e}},{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.textureRes&&!e.includes(this.textureRes)&&e.push(this.textureRes),e}},{key:"isTextureAttached",get:function(){return this.textureRes&&this.textureRes._isAttached}}],[{key:"is",value:function(e){return"string"==typeof e}}]),t}();l.prototype.SetValue=l.prototype.SetTexturePath,l.overrideProperties=["useAllOverrides","addressUMode","addressVMode","addressWMode","filterMode","mipFilterMode","maxAnisotropy"]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SamplerState=void 0;var n=function(){function e(e,t){for(var r=0;r4&&void 0!==arguments[4]?arguments[4]:0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.usage=t,this.usageIndex=r,this.type=n,this.elements=i,this.offset=a,this.location=null,this.customSetter=null}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PerObjectData=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};e.VSData&&(this.perObjectVSData=new a.Tw2RawData(e.VSData)),e.PSData&&(this.perObjectPSData=new a.Tw2RawData(e.PSData))}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(100);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(104);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(111);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(115);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(116);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(18);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(118);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(119);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(120);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(121);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(122);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(123);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(124);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(125);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(126);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})});var h=r(127);Object.keys(h).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return h[e]}})});var p=r(128);Object.keys(p).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return p[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(40);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(129);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(48);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(49);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(130);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Mesh=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[];return e.includes(this.geometryResource)||e.push(this.geometryResource),i.util.perArrayChild(this.opaqueAreas,"GetResources",e),i.util.perArrayChild(this.transparentAreas,"GetResources",e),i.util.perArrayChild(this.additiveAreas,"GetResources",e),i.util.perArrayChild(this.pickableAreas,"GetResources",e),i.util.perArrayChild(this.decalAreas,"GetResources",e),i.util.perArrayChild(this.depthAreas,"GetResources",e),e}},{key:"GetBatches",value:function(e,t,r){if(!this.IsGood()||!this.display)return!1;var n=this.constructor.GetAreaBatches;switch(e){case o.device.RM_OPAQUE:return void(this.visible.opaqueAreas&&n(this,this.opaqueAreas,e,t,r));case o.device.RM_DECAL:return void(this.visible.decalAreas&&n(this,this.opaqueAreas,e,t,r));case o.device.RM_TRANSPARENT:return void(this.visible.transparentAreas&&n(this,this.transparentAreas,e,t,r));case o.device.RM_ADDITIVE:return void(this.visible.transparentAreas&&n(this,this.additiveAreas,e,t,r));case o.device.RM_PICKABLE:return void(this.visible.pickableAreas&&n(this,this.pickableAreas,e,t,r))}}}],[{key:"GetAreaBatches",value:function(e,t,r,n,i){for(var a=0;a=this.animationRes.duration}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TextureRes=void 0;var n=function(){function e(e,t){for(var r=0;r0?"."+t.mipLevelSkipCount.toString():"";if(t.mipLevelSkipCount>0){var n=e.lastIndexOf(".");n>=0&&(e=e.substr(0,n-2)+r+e.substr(n))}return e}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Bone=void 0;var n=r(0);t.Tw2Bone=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.boneRes=null,this.localTransform=n.mat4.create(),this.worldTransform=n.mat4.create(),this.offsetTransform=n.mat4.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2Model=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.modelRes=null,this.bones=[],this.bonesByName={}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2Track=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.trackRes=null,this.bone=null}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2TrackGroup=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.trackGroupRes=null,this.model=null,this.transformTracks=[]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2RenderTarget=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];if(this.mesh&&this.mesh.GetResources(e),!t)for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];return this.mesh&&this.mesh.GetResources(e),this.animation&&this.animation.GetResources(e),i.util.perArrayChild(this.spriteSets,"GetResources",e),i.util.perArrayChild(this.turretSets,"GetResources",e),i.util.perArrayChild(this.decals,"GetResources",e),i.util.perArrayChild(this.spotlightSets,"GetResources",e),i.util.perArrayChild(this.planeSets,"GetResources",e),i.util.perArrayChild(this.lineSets,"GetResources",e),i.util.perArrayChild(this.overlayEffects,"GetResources",e),i.util.perArrayChild(this.effectChildren,"GetResources",e),t||i.util.perArrayChild(this.children,"GetResources",e),e}},{key:"UpdateViewDependentData",value:function(){for(var e=0;e0?(t[0]=this.shapeEllipsoidCenter[0],t[1]=this.shapeEllipsoidCenter[1],t[2]=this.shapeEllipsoidCenter[2],r[0]=this.shapeEllipsoidRadius[0],r[1]=this.shapeEllipsoidRadius[1],r[2]=this.shapeEllipsoidRadius[2]):this.mesh&&this.mesh.IsGood()&&(i.vec3.subtract(t,this.mesh.geometryResource.maxBounds,this.mesh.geometryResource.minBounds),i.vec3.scale(t,t,.8660254035),i.vec3.add(r,this.mesh.geometryResource.maxBounds,this.mesh.geometryResource.minBounds),i.vec3.scale(r,r,.5));for(var n=0;n0){for(var t=0;t0&&this.mesh.GetBatches(e,t,this._perObjectData),this.lod>1){if(r.spriteSets)for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:null;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.batches=[],this._sortMethod=t}return n(e,[{key:"Commit",value:function(e){this.batches.push(e)}},{key:"Clear",value:function(){this.batches=[]}},{key:"Render",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Main";this._sortMethod&&this.batches.sort(this._sortMethod);for(var r=0;r0?(n=2*Math.sqrt(r+1),e[3]=.25*n,e[0]=(t[6]-t[9])/n,e[1]=(t[8]-t[2])/n,e[2]=(t[1]-t[4])/n):t[0]>t[5]&t[0]>t[10]?(n=2*Math.sqrt(1+t[0]-t[5]-t[10]),e[3]=(t[6]-t[9])/n,e[0]=.25*n,e[1]=(t[1]+t[4])/n,e[2]=(t[8]+t[2])/n):t[5]>t[10]?(n=2*Math.sqrt(1+t[5]-t[0]-t[10]),e[3]=(t[8]-t[2])/n,e[0]=(t[1]+t[4])/n,e[1]=.25*n,e[2]=(t[6]+t[9])/n):(n=2*Math.sqrt(1+t[10]-t[0]-t[5]),e[3]=(t[1]-t[4])/n,e[0]=(t[8]+t[2])/n,e[1]=(t[6]+t[9])/n,e[2]=.25*n);return e},t.fromRotationTranslationScale=function(e,t,r,n){let i=t[0],a=t[1],o=t[2],s=t[3],u=i+i,l=a+a,c=o+o,f=i*u,h=i*l,p=i*c,d=a*l,v=a*c,m=o*c,y=s*u,b=s*l,g=s*c,_=n[0],E=n[1],T=n[2];return e[0]=(1-(d+m))*_,e[1]=(h+g)*_,e[2]=(p-b)*_,e[3]=0,e[4]=(h-g)*E,e[5]=(1-(f+m))*E,e[6]=(v+y)*E,e[7]=0,e[8]=(p+b)*T,e[9]=(v-y)*T,e[10]=(1-(f+d))*T,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e},t.fromRotationTranslationScaleOrigin=function(e,t,r,n,i){let a=t[0],o=t[1],s=t[2],u=t[3],l=a+a,c=o+o,f=s+s,h=a*l,p=a*c,d=a*f,v=o*c,m=o*f,y=s*f,b=u*l,g=u*c,_=u*f,E=n[0],T=n[1],O=n[2],w=i[0],S=i[1],R=i[2];return e[0]=(1-(v+y))*E,e[1]=(p+_)*E,e[2]=(d-g)*E,e[3]=0,e[4]=(p-_)*T,e[5]=(1-(h+y))*T,e[6]=(m+b)*T,e[7]=0,e[8]=(d+g)*O,e[9]=(m-b)*O,e[10]=(1-(h+v))*O,e[11]=0,e[12]=r[0]+w-(e[0]*w+e[4]*S+e[8]*R),e[13]=r[1]+S-(e[1]*w+e[5]*S+e[9]*R),e[14]=r[2]+R-(e[2]*w+e[6]*S+e[10]*R),e[15]=1,e},t.fromQuat=function(e,t){let r=t[0],n=t[1],i=t[2],a=t[3],o=r+r,s=n+n,u=i+i,l=r*o,c=n*o,f=n*s,h=i*o,p=i*s,d=i*u,v=a*o,m=a*s,y=a*u;return e[0]=1-f-d,e[1]=c+y,e[2]=h-m,e[3]=0,e[4]=c-y,e[5]=1-l-d,e[6]=p+v,e[7]=0,e[8]=h+m,e[9]=p-v,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},t.frustum=function(e,t,r,n,i,a,o){let s=1/(r-t),u=1/(i-n),l=1/(a-o);return e[0]=2*a*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*u,e[6]=0,e[7]=0,e[8]=(r+t)*s,e[9]=(i+n)*u,e[10]=(o+a)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*l,e[15]=0,e},t.perspective=function(e,t,r,n,i){let a=1/Math.tan(t/2),o=1/(n-i);return e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(i+n)*o,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*i*n*o,e[15]=0,e},t.perspectiveFromFieldOfView=function(e,t,r,n){let i=Math.tan(t.upDegrees*Math.PI/180),a=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),s=Math.tan(t.rightDegrees*Math.PI/180),u=2/(o+s),l=2/(i+a);return e[0]=u,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-(o-s)*u*.5,e[9]=(i-a)*l*.5,e[10]=n/(r-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*r/(r-n),e[15]=0,e},t.ortho=function(e,t,r,n,i,a,o){let s=1/(t-r),u=1/(n-i),l=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*s,e[13]=(i+n)*u,e[14]=(o+a)*l,e[15]=1,e},t.lookAt=function(e,t,r,i){let a,o,s,u,l,c,f,h,p,d,v=t[0],m=t[1],y=t[2],b=i[0],g=i[1],_=i[2],E=r[0],T=r[1],O=r[2];if(Math.abs(v-E)0&&(p=1/Math.sqrt(p),c*=p,f*=p,h*=p);let d=u*h-l*f,v=l*c-s*h,m=s*f-u*c;return e[0]=d,e[1]=v,e[2]=m,e[3]=0,e[4]=f*m-h*v,e[5]=h*d-c*m,e[6]=c*v-f*d,e[7]=0,e[8]=c,e[9]=f,e[10]=h,e[11]=0,e[12]=i,e[13]=a,e[14]=o,e[15]=1,e},t.str=function(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},t.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2)+Math.pow(e[9],2)+Math.pow(e[10],2)+Math.pow(e[11],2)+Math.pow(e[12],2)+Math.pow(e[13],2)+Math.pow(e[14],2)+Math.pow(e[15],2))},t.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e},t.subtract=a,t.multiplyScalar=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e},t.multiplyScalarAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e[9]=t[9]+r[9]*n,e[10]=t[10]+r[10]*n,e[11]=t[11]+r[11]*n,e[12]=t[12]+r[12]*n,e[13]=t[13]+r[13]*n,e[14]=t[14]+r[14]*n,e[15]=t[15]+r[15]*n,e},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},t.equals=function(e,t){let r=e[0],i=e[1],a=e[2],o=e[3],s=e[4],u=e[5],l=e[6],c=e[7],f=e[8],h=e[9],p=e[10],d=e[11],v=e[12],m=e[13],y=e[14],b=e[15],g=t[0],_=t[1],E=t[2],T=t[3],O=t[4],w=t[5],S=t[6],R=t[7],P=t[8],A=t[9],M=t[10],D=t[11],j=t[12],C=t[13],I=t[14],k=t[15];return Math.abs(r-g)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(g))&&Math.abs(i-_)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(_))&&Math.abs(a-E)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(E))&&Math.abs(o-T)<=n.EPSILON*Math.max(1,Math.abs(o),Math.abs(T))&&Math.abs(s-O)<=n.EPSILON*Math.max(1,Math.abs(s),Math.abs(O))&&Math.abs(u-w)<=n.EPSILON*Math.max(1,Math.abs(u),Math.abs(w))&&Math.abs(l-S)<=n.EPSILON*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(c-R)<=n.EPSILON*Math.max(1,Math.abs(c),Math.abs(R))&&Math.abs(f-P)<=n.EPSILON*Math.max(1,Math.abs(f),Math.abs(P))&&Math.abs(h-A)<=n.EPSILON*Math.max(1,Math.abs(h),Math.abs(A))&&Math.abs(p-M)<=n.EPSILON*Math.max(1,Math.abs(p),Math.abs(M))&&Math.abs(d-D)<=n.EPSILON*Math.max(1,Math.abs(d),Math.abs(D))&&Math.abs(v-j)<=n.EPSILON*Math.max(1,Math.abs(v),Math.abs(j))&&Math.abs(m-C)<=n.EPSILON*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(y-I)<=n.EPSILON*Math.max(1,Math.abs(y),Math.abs(I))&&Math.abs(b-k)<=n.EPSILON*Math.max(1,Math.abs(b),Math.abs(k))};var n=r(5);function i(e,t,r){let n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],l=t[6],c=t[7],f=t[8],h=t[9],p=t[10],d=t[11],v=t[12],m=t[13],y=t[14],b=t[15],g=r[0],_=r[1],E=r[2],T=r[3];return e[0]=g*n+_*s+E*f+T*v,e[1]=g*i+_*u+E*h+T*m,e[2]=g*a+_*l+E*p+T*y,e[3]=g*o+_*c+E*d+T*b,g=r[4],_=r[5],E=r[6],T=r[7],e[4]=g*n+_*s+E*f+T*v,e[5]=g*i+_*u+E*h+T*m,e[6]=g*a+_*l+E*p+T*y,e[7]=g*o+_*c+E*d+T*b,g=r[8],_=r[9],E=r[10],T=r[11],e[8]=g*n+_*s+E*f+T*v,e[9]=g*i+_*u+E*h+T*m,e[10]=g*a+_*l+E*p+T*y,e[11]=g*o+_*c+E*d+T*b,g=r[12],_=r[13],E=r[14],T=r[15],e[12]=g*n+_*s+E*f+T*v,e[13]=g*i+_*u+E*h+T*m,e[14]=g*a+_*l+E*p+T*y,e[15]=g*o+_*c+E*d+T*b,e}function a(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}const o=i;t.mul=o;const s=a;t.sub=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=s,t.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},t.setAxisAngle=u,t.getAxisAngle=function(e,t){let r=2*Math.acos(t[3]),n=Math.sin(r/2);0!=n?(e[0]=t[0]/n,e[1]=t[1]/n,e[2]=t[2]/n):(e[0]=1,e[1]=0,e[2]=0);return r},t.multiply=l,t.rotateX=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u+o*s,e[1]=i*u+a*s,e[2]=a*u-i*s,e[3]=o*u-n*s,e},t.rotateY=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u-a*s,e[1]=i*u+o*s,e[2]=a*u+n*s,e[3]=o*u-i*s,e},t.rotateZ=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u+i*s,e[1]=i*u-n*s,e[2]=a*u+o*s,e[3]=o*u-a*s,e},t.calculateW=function(e,t){let r=t[0],n=t[1],i=t[2];return e[0]=r,e[1]=n,e[2]=i,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),e},t.slerp=c,t.invert=function(e,t){let r=t[0],n=t[1],i=t[2],a=t[3],o=r*r+n*n+i*i+a*a,s=o?1/o:0;return e[0]=-r*s,e[1]=-n*s,e[2]=-i*s,e[3]=a*s,e},t.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},t.fromMat3=f,t.fromEuler=function(e,t,r,n){let i=.5*Math.PI/180;t*=i,r*=i,n*=i;let a=Math.sin(t),o=Math.cos(t),s=Math.sin(r),u=Math.cos(r),l=Math.sin(n),c=Math.cos(n);return e[0]=a*u*c-o*s*l,e[1]=o*s*c+a*u*l,e[2]=o*u*l-a*s*c,e[3]=o*u*c+a*s*l,e},t.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"};var n=r(5),i=r(31),a=r(32),o=r(33);function s(){let e=new n.ARRAY_TYPE(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function u(e,t,r){r*=.5;let n=Math.sin(r);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r),e}function l(e,t,r){let n=t[0],i=t[1],a=t[2],o=t[3],s=r[0],u=r[1],l=r[2],c=r[3];return e[0]=n*c+o*s+i*l-a*u,e[1]=i*c+o*u+a*s-n*l,e[2]=a*c+o*l+n*u-i*s,e[3]=o*c-n*s-i*u-a*l,e}function c(e,t,r,n){let i,a,o,s,u,l=t[0],c=t[1],f=t[2],h=t[3],p=r[0],d=r[1],v=r[2],m=r[3];return(a=l*p+c*d+f*v+h*m)<0&&(a=-a,p=-p,d=-d,v=-v,m=-m),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,u=Math.sin(n*i)/o):(s=1-n,u=n),e[0]=s*l+u*p,e[1]=s*c+u*d,e[2]=s*f+u*v,e[3]=s*h+u*m,e}function f(e,t){let r,n=t[0]+t[4]+t[8];if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{let n=0;t[4]>t[0]&&(n=1),t[8]>t[3*n+n]&&(n=2);let i=(n+1)%3,a=(n+2)%3;r=Math.sqrt(t[3*n+n]-t[3*i+i]-t[3*a+a]+1),e[n]=.5*r,r=.5/r,e[3]=(t[3*i+a]-t[3*a+i])*r,e[i]=(t[3*i+n]+t[3*n+i])*r,e[a]=(t[3*a+n]+t[3*n+a])*r}return e}const h=o.clone;t.clone=h;const p=o.fromValues;t.fromValues=p;const d=o.copy;t.copy=d;const v=o.set;t.set=v;const m=o.add;t.add=m;const y=l;t.mul=y;const b=o.scale;t.scale=b;const g=o.dot;t.dot=g;const _=o.lerp;t.lerp=_;const E=o.length;t.length=E;const T=E;t.len=T;const O=o.squaredLength;t.squaredLength=O;const w=O;t.sqrLen=w;const S=o.normalize;t.normalize=S;const R=o.exactEquals;t.exactEquals=R;const P=o.equals;t.equals=P;const A=function(){let e=a.create(),t=a.fromValues(1,0,0),r=a.fromValues(0,1,0);return function(n,i,o){let s=a.dot(i,o);return s<-.999999?(a.cross(e,t,i),a.len(e)<1e-6&&a.cross(e,r,i),a.normalize(e,e),u(n,e,Math.PI),n):s>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(a.cross(e,i,o),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+s,S(n,n))}}();t.rotationTo=A;const M=function(){let e=s(),t=s();return function(r,n,i,a,o,s){return c(e,n,o,s),c(t,i,a,s),c(r,e,t,2*s*(1-s)),r}}();t.sqlerp=M;const D=function(){let e=i.create();return function(t,r,n,i){return e[0]=n[0],e[3]=n[1],e[6]=n[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-r[0],e[5]=-r[1],e[8]=-r[2],S(t,f(t,e))}}();t.setAxes=D},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=i,t.clone=function(e){let t=new n.ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t},t.fromValues=function(e,t){let r=new n.ARRAY_TYPE(2);return r[0]=e,r[1]=t,r},t.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},t.set=function(e,t,r){return e[0]=t,e[1]=r,e},t.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e},t.subtract=a,t.multiply=o,t.divide=s,t.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},t.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},t.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e},t.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e},t.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},t.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e},t.scaleAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e},t.distance=u,t.squaredDistance=l,t.length=c,t.squaredLength=f,t.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},t.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},t.normalize=function(e,t){var r=t[0],n=t[1],i=r*r+n*n;i>0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i);return e},t.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},t.cross=function(e,t,r){var n=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=n,e},t.lerp=function(e,t,r,n){var i=t[0],a=t[1];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e},t.random=function(e,t){t=t||1;var r=2*n.RANDOM()*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e},t.transformMat2=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e},t.transformMat2d=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i+r[4],e[1]=r[1]*n+r[3]*i+r[5],e},t.transformMat3=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[3]*i+r[6],e[1]=r[1]*n+r[4]*i+r[7],e},t.transformMat4=function(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[4]*i+r[12],e[1]=r[1]*n+r[5]*i+r[13],e},t.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]},t.equals=function(e,t){let r=e[0],i=e[1],a=t[0],o=t[1];return Math.abs(r-a)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-o)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))};var n=r(5);function i(){let e=new n.ARRAY_TYPE(2);return e[0]=0,e[1]=0,e}function a(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function o(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function s(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function u(e,t){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function l(e,t){var r=t[0]-e[0],n=t[1]-e[1];return r*r+n*n}function c(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function f(e){var t=e[0],r=e[1];return t*t+r*r}const h=c;t.len=h;const p=a;t.sub=p;const d=o;t.mul=d;const v=s;t.div=v;const m=u;t.dist=m;const y=l;t.sqrDist=y;const b=f;t.sqrLen=b;const g=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=2),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s1.0001||r<.99999)e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=0;else if(r=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])){var i=Math.atan2(r,t[3])/r;e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=0}else e[0]=0,e[1]=0,e[2]=0,e[3]=0;return e},n.quat.pow=function(e,t,r){return 1===r?n.quat.copy(e,t):(n.quat.ln(e,t),e[0]*=r,e[1]*=r,e[2]*=r,e[3]*=r,n.quat.exp(e,e),e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mat3=void 0;var n=r(11);t.mat3=n.mat3},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mat4=void 0;var n,i=r(11);t.mat4=i.mat4,i.mat4.arcFromForward=(n=void 0,function(e,t){n||(n=i.vec3.create());var r=i.vec3.normalize(n,t);if(i.mat4.identity(e),r[2]<-.99999)return e;if(r[2]>.99999)return e[5]=-1,e[10]=-1,e;var a=(1+r[2])/(r[0]*r[0]+r[1]*r[1]);return e[0]=a*r[1]*r[1]-r[2],e[1]=-a*r[0]*r[1],e[2]=r[0],e[4]=e[1],e[5]=a*r[0]*r[0]-r[2],e[6]=r[1],e[8]=-r[0],e[9]=-r[1],e[10]=-r[2],e}),i.mat4.copyTranslation=function(e,t){return e[12]=t[12],e[13]=t[13],e[14]=t[14],e},i.mat4.fromMat3=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[4]=t[3],e[5]=t[4],e[6]=t[5],e[8]=t[6],e[9]=t[7],e[10]=t[8],e[3]=e[7]=e[11]=e[12]=e[13]=e[14]=0,e[15]=1,e},i.mat4.lookAtGL=function(){var e=void 0,t=void 0,r=void 0;return function(n,a,o,s){return e||(e=i.vec3.create(),t=i.vec3.create(),r=i.vec3.create()),i.vec3.subtract(r,a,o),0===i.vec3.squaredLength(r)&&(r[2]=1),i.vec3.normalize(r,r),i.vec3.cross(e,s,r),0===i.vec3.squaredLength(e)&&(r[2]+=1e-4,i.vec3.cross(e,s,r)),i.vec3.normalize(e,e),i.vec3.cross(t,r,e),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[4]=t[0],n[5]=t[1],n[6]=t[2],n[8]=r[0],n[9]=r[1],n[10]=r[2],n}}(),i.mat4.perspectiveGL=function(e,t,r,n,a){var o=Math.tan(t/360*Math.PI)*n,s=o*r;return i.mat4.frustum(e,-s,s,-o,o,n,a),e},i.mat4.setTranslation=function(e,t){return e[12]=t[0],e[13]=t[1],e[14]=t[2],e},i.mat4.setTranslationFromValues=function(e,t,r,n){return e[12]=t,e[13]=r,e[14]=n,e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.noise=void 0;var n=r(34),i=r(35),a=t.noise={};a.turbulence=function(){var e=[],t=[],r=[],a=!1;return function(o,s,u,l,c,f){a||function(){for(var o=0;o<256;o++)e[o]=i.vec4.fromValues(Math.random()-.5,Math.random()-.5,Math.random()-.5,Math.random()-.5),t[o]=o;for(var s=256;--s;){var u=t[s],l=Math.floor(256*Math.random());t[s]=t[l],t[l]=u}for(var c=0;c<256;c++)t[256+c]=t[c],e[256+c]=e[c],e[512+c]=e[c];for(var f=0;f<15;++f)r[f]=n.vec3.create();a=!0}(),s+=4096,u+=4096,l+=4096,c+=4096;var h=Math.floor(s),p=Math.floor(u),d=Math.floor(l),v=Math.floor(c),m=s-h,y=u-p,b=l-d,g=c-v,_=(h&=255)+1,E=(p&=255)+1,T=(d&=255)+1,O=(v&=255)+1,w=t[h],S=t[_],R=t[w+p],P=t[S+p],A=t[w+E],M=t[S+E],D=n.vec3.lerp(r[0],e[R+d+v],e[P+d+v],m),j=n.vec3.lerp(r[1],e[A+d+v],e[M+d+v],m),C=n.vec3.lerp(r[2],e[R+T+v],e[P+T+v],m),I=n.vec3.lerp(r[3],e[R+T+v],e[P+T+v],m),k=n.vec3.lerp(r[4],D,j,y),x=n.vec3.lerp(r[5],C,I,y),L=n.vec3.lerp(r[6],k,x,b);D=n.vec3.lerp(r[7],e[R+d+O],e[P+d+O],m),j=n.vec3.lerp(r[8],e[A+d+O],e[M+d+O],m),C=n.vec3.lerp(r[9],e[R+T+O],e[P+T+O],m),I=n.vec3.lerp(r[10],e[R+T+O],e[P+T+O],m),k=n.vec3.lerp(r[11],D,j,y),x=n.vec3.lerp(r[12],C,I,y);var B=n.vec3.lerp(r[13],k,x,b),F=n.vec3.lerp(r[14],L,B,g);return o[0]+=F[0]*f,o[1]+=F[1]*f,o[2]+=F[2]*f,o}}(),a.perlin1=function(){var e=!1,t=256,r=null,n=null;return function(i){e||function(){r=new Array(t+t+2),n=new Array(t+t+2);var i=0,a=0,o=0;for(i=0;it){o=u;break}if(0===e.degree)for(var l=0;l0&&(s=(t-e.knots[e.knots.length-1])/f);for(var h=0;h_&&(_+=i,E+=i,t+=i),g>_&&(_+=i,E+=i,t+=i),E<_&&(E+=i);var T=t-g,O=T/(_-g),w=(t-b)/(_-b),S=w+O-O*w,R=O*(T/(E-g)),P=S-R;S=1-S;for(var A=0;A=0;)n=r*n+e[t];return n},n.ag_zeroin2=function(e,t,r,i,a,o){var s=void 0,u=void 0,l=void 0,c=void 0,f=void 0,h=void 0,p=void 0,d=void 0,v=void 0,m=void 0;for(var y=!0;y&&(s=e,c=r,l=u=t-e),Math.abs(c)f&&0!==i;)Math.abs(l)0?d=-d:p=-p,m=l,l=u,2*p<3*h*d-Math.abs(f*d)&&pf?t+=u:h>0?t+=f:t-=f,(i=n.ag_horner1(o.p,o.deg,t))*(c/Math.abs(c))>0&&(y=!0);return t},n.ag_zeroin=function(e,t,r,i){var a,o;return a=n.ag_horner1(i.p,i.deg,e),Math.abs(a)<1.192092896e-7?e:(o=n.ag_horner1(i.p,i.deg,t),Math.abs(o)<1.192092896e-7?t:n.ag_zeroin2(e,t,a,o,r,i))},n.polyZeroes=function(e,t,r,i,a,o,s){var u,l,c=void 0,f=void 0,h=void 0,p=void 0,d=void 0,v=void 0,m=void 0,y=void 0,b=void 0,g=void 0,_=void 0,E=void 0,T=new Array(22),O=void 0,w=new Array(22),S=new Array(22),R={p:[],deg:0};for(m=g=0,y=0,c=0;cs[0]-u:a>s[0]+u,(p=f&&h?1:0)&&(i&&s[0]a&&(s[0]=a)),p;for(R.p=E,R.deg=t,c=1;c<=t;c++)O[c-1]=c*E[c];if(0===(d=n.polyZeroes(O,t-1,r,0,a,0,l)).length)return 0;for(c=v=0;c<=d;c++){if(p>t)return p;0===c?(b=r,_=n.ag_horner1(E,t,b),Math.abs(_)<=u&&i&&(s[p++]=r)):(b=m,_=g),c===d?(m=a,v=0):m=l[c],g=n.ag_horner1(E,t,m),v?v=0:Math.abs(g)0||_>0&&g<0)&&(s[p++]=n.ag_zeroin(b,m,0,R),p>1&&s[p-2]>=s[p-1]-u&&(s[p-2]=.5*(s[p-2]+s[p-1]),p--))}return p}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=t.util={};n.addToArray=function(e){for(var t=!1,r=arguments.length,n=Array(r>1?r-1:0),i=1;i>8&255]+e[t>>16&255]+e[t>>24&255]+"-"+e[255&r]+e[r>>8&255]+"-"+e[r>>16&15|64]+e[r>>24&255]+"-"+e[63&n|128]+e[n>>8&255]+"-"+e[n>>16&255]+e[n>>24&255]+e[255&i]+e[i>>8&255]+e[i>>16&255]+e[i>>24&255]}}();n.enableUUID=function(e){if(null!==a&&e!==a)throw new Error("Cannot change id generation type once used");a=e},n.generateID=function(){return null===a&&(a=!1),a?s():o()},n.get=function(e,t,r){return e&&t in e?e[t]:r},n.isArray=Array.isArray,n.isArrayLike=function(e){return!!e&&(n.isArray(e)||n.isTyped(e))},n.isVector=function(e){if(e){if(n.isTyped(e))return!0;if(n.isArray(e)){for(var t=0;t2?n-2:0),a=2;a1?r-1:0),i=1;i=r&&a.Unload()&&(i.logger.log("res.event",{msg:"Unloaded ",path:a.path,type:"unused"}),delete this._loadedObjects[n]))}}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SamplerOverride=void 0;var n=r(2),i=r(42);t.Tw2SamplerOverride=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="",this.addressU=0,this.addressV=0,this.addressW=0,this.filter=0,this.mipFilter=0,this.lodBias=0,this.maxMipLevel=0,this.maxAnisotropy=0;var t=null;this.GetSampler=function(e){if(!t){if((t=new i.Tw2SamplerState).registerIndex=e.registerIndex,t.name=e.name,1===this.filter){switch(this.mipFilter){case 0:t.minFilter=n.device.gl.NEAREST;break;case 1:t.minFilter=n.device.gl.NEAREST_MIPMAP_NEAREST;break;default:t.minFilter=n.device.gl.NEAREST_MIPMAP_LINEAR}t.minFilterNoMips=n.device.gl.NEAREST}else{switch(this.mipFilter){case 0:t.minFilter=n.device.gl.LINEAR;break;case 1:t.minFilter=n.device.gl.LINEAR_MIPMAP_NEAREST;break;default:t.minFilter=n.device.gl.LINEAR_MIPMAP_LINEAR}t.minFilterNoMips=n.device.gl.LINEAR}3!==this.filter&&3!==this.mipFilter||(t.anisotropy=Math.max(this.maxAnisotropy,1)),t.magFilter=1===this.filter?n.device.gl.NEAREST:n.device.gl.LINEAR,t.addressU=n.device.wrapModes[this.addressU],t.addressV=n.device.wrapModes[this.addressV],t.addressW=n.device.wrapModes[this.addressW],t.samplerType=e.samplerType,t.isVolume=e.isVolume,t.ComputeHash()}return t}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VertexDeclaration=void 0;var n=function(){function e(e,t){for(var r=0;rt)return null}if(n.usage>e)return null}return null}},{key:"SetDeclaration",value:function(t,r){for(var n=0,a=0;a=this._elementsSorted.length){i.device.gl.disableVertexAttribArray(o.location),i.device.gl.vertexAttrib4f(o.location,0,0,0,0);break}var s=this._elementsSorted[n],u=e.CompareDeclarationElements(s,o);if(u>0){i.device.gl.disableVertexAttribArray(o.location),i.device.gl.vertexAttrib4f(o.location,0,0,0,0);break}if(0===u){s.customSetter?s.customSetter(o):(i.device.gl.enableVertexAttribArray(o.location),i.device.gl.vertexAttribPointer(o.location,s.elements,s.type,!1,r,s.offset));break}n++}}return!0}},{key:"SetPartialDeclaration",value:function(t,r){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=[],s=0,u=0;u0){a||(i.device.gl.disableVertexAttribArray(l.location),i.device.gl.vertexAttrib4f(l.location,0,0,0,0));break}if(++s>=this._elementsSorted.length)return a||(i.device.gl.disableVertexAttribArray(l.location),i.device.gl.vertexAttrib4f(l.location,0,0,0,0)),o}}return o}},{key:"ResetInstanceDivisors",value:function(e){if(e)for(var t=0;t2&&void 0!==arguments[2]?arguments[2]:0;return e.usaget.usage?1:e.usageIndex+rt.usageIndex?1:0}}]),e}()).Type={POSITION:0,COLOR:1,NORMAL:2,TANGENT:3,BINORMAL:4,TEXCOORD:5,BLENDWEIGHT:6,BLENDINDICES:7}},function(e,t,r){(function(t){WebGLDebugUtils=function(){var e;void 0===e&&(e=t);var r=function(t){e.console&&e.console.error?e.console.error(t):function(t){e.console&&e.console.log&&e.console.log(t)}(t)},n={enable:{1:{0:!0}},disable:{1:{0:!0}},getParameter:{1:{0:!0}},drawArrays:{3:{0:!0}},drawElements:{4:{0:!0,2:!0}},createShader:{1:{0:!0}},getShaderParameter:{2:{1:!0}},getProgramParameter:{2:{1:!0}},getShaderPrecisionFormat:{2:{0:!0,1:!0}},getVertexAttrib:{2:{1:!0}},vertexAttribPointer:{6:{2:!0}},bindTexture:{2:{0:!0}},activeTexture:{1:{0:!0}},getTexParameter:{2:{0:!0,1:!0}},texParameterf:{3:{0:!0,1:!0}},texParameteri:{3:{0:!0,1:!0,2:!0}},copyTexImage2D:{8:{0:!0,2:!0}},copyTexSubImage2D:{8:{0:!0}},generateMipmap:{1:{0:!0}},bindBuffer:{2:{0:!0}},getBufferParameter:{2:{0:!0,1:!0}},pixelStorei:{2:{0:!0,1:!0}},bindRenderbuffer:{2:{0:!0}},bindFramebuffer:{2:{0:!0}},checkFramebufferStatus:{1:{0:!0}},framebufferRenderbuffer:{4:{0:!0,1:!0,2:!0}},framebufferTexture2D:{5:{0:!0,1:!0,2:!0}},getFramebufferAttachmentParameter:{3:{0:!0,1:!0,2:!0}},getRenderbufferParameter:{2:{0:!0,1:!0}},renderbufferStorage:{4:{0:!0,1:!0}},clear:{1:{0:{enumBitwiseOr:["COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT"]}}},depthFunc:{1:{0:!0}},blendFunc:{2:{0:!0,1:!0}},blendFuncSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},blendEquation:{1:{0:!0}},blendEquationSeparate:{2:{0:!0,1:!0}},stencilFunc:{3:{0:!0}},stencilFuncSeparate:{4:{0:!0,1:!0}},stencilMaskSeparate:{2:{0:!0}},stencilOp:{3:{0:!0,1:!0,2:!0}},stencilOpSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},cullFace:{1:{0:!0}},frontFace:{1:{0:!0}},drawArraysInstancedANGLE:{4:{0:!0}},drawElementsInstancedANGLE:{5:{0:!0,2:!0}},blendEquationEXT:{1:{0:!0}},bufferData:{3:{0:!0,2:!0},4:{0:!0,2:!0},5:{0:!0,2:!0}},bufferSubData:{3:{0:!0},4:{0:!0},5:{0:!0}},copyBufferSubData:{5:{0:!0,1:!0}},getBufferSubData:{3:{0:!0},4:{0:!0},5:{0:!0}},blitFramebuffer:{10:{8:{enumBitwiseOr:["COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT"]},9:!0}},framebufferTextureLayer:{5:{0:!0,1:!0}},invalidateFramebuffer:{2:{0:!0}},invalidateSubFramebuffer:{6:{0:!0}},readBuffer:{1:{0:!0}},getInternalformatParameter:{3:{0:!0,1:!0,2:!0}},renderbufferStorageMultisample:{5:{0:!0,2:!0}},texStorage2D:{5:{0:!0,2:!0}},texStorage3D:{6:{0:!0,2:!0}},texImage2D:{9:{0:!0,2:!0,6:!0,7:!0},6:{0:!0,2:!0,3:!0,4:!0},10:{0:!0,2:!0,6:!0,7:!0}},texImage3D:{10:{0:!0,2:!0,7:!0,8:!0},11:{0:!0,2:!0,7:!0,8:!0}},texSubImage2D:{9:{0:!0,6:!0,7:!0},7:{0:!0,4:!0,5:!0},10:{0:!0,6:!0,7:!0}},texSubImage3D:{11:{0:!0,8:!0,9:!0},12:{0:!0,8:!0,9:!0}},copyTexSubImage3D:{9:{0:!0}},compressedTexImage2D:{7:{0:!0,2:!0},8:{0:!0,2:!0},9:{0:!0,2:!0}},compressedTexImage3D:{8:{0:!0,2:!0},9:{0:!0,2:!0},10:{0:!0,2:!0}},compressedTexSubImage2D:{8:{0:!0,6:!0},9:{0:!0,6:!0},10:{0:!0,6:!0}},compressedTexSubImage3D:{10:{0:!0,8:!0},11:{0:!0,8:!0},12:{0:!0,8:!0}},vertexAttribIPointer:{5:{2:!0}},drawArraysInstanced:{4:{0:!0}},drawElementsInstanced:{5:{0:!0,2:!0}},drawRangeElements:{6:{0:!0,4:!0}},readPixels:{7:{4:!0,5:!0},8:{4:!0,5:!0}},clearBufferfv:{3:{0:!0},4:{0:!0}},clearBufferiv:{3:{0:!0},4:{0:!0}},clearBufferuiv:{3:{0:!0},4:{0:!0}},clearBufferfi:{4:{0:!0}},beginQuery:{2:{0:!0}},endQuery:{1:{0:!0}},getQuery:{2:{0:!0,1:!0}},getQueryParameter:{2:{1:!0}},samplerParameteri:{3:{1:!0,2:!0}},samplerParameterf:{3:{1:!0}},getSamplerParameter:{2:{1:!0}},fenceSync:{2:{0:!0,1:{enumBitwiseOr:[]}}},clientWaitSync:{3:{1:{enumBitwiseOr:["SYNC_FLUSH_COMMANDS_BIT"]}}},waitSync:{3:{1:{enumBitwiseOr:[]}}},getSyncParameter:{2:{1:!0}},bindTransformFeedback:{2:{0:!0}},beginTransformFeedback:{1:{0:!0}},transformFeedbackVaryings:{3:{2:!0}},bindBufferBase:{3:{0:!0}},bindBufferRange:{5:{0:!0}},getIndexedParameter:{2:{0:!0}},getActiveUniforms:{3:{2:!0}},getActiveUniformBlockParameter:{3:{2:!0}}},i=null,a=null;function o(e){if(null==i)for(var t in i={},a={},e)"number"==typeof e[t]&&(i[e[t]]=t,a[t]=e[t])}function s(){if(null==i)throw"WebGLDebugUtils.init(ctx) not called"}function u(e){s();var t=i[e];return void 0!==t?"gl."+t:"/*UNKNOWN WebGL ENUM*/ 0x"+e.toString(16)}function l(e,t,r,i){var o;if(void 0!==(o=n[e])&&(void 0!==(o=o[t])&&o[r])){if("object"==typeof o[r]&&void 0!==o[r].enumBitwiseOr){for(var s=o[r].enumBitwiseOr,l=0,c=[],f=0;f=0&&setTimeout(function(){t.restoreContext()},m)},0)}},t.restoreContext=function(){l&&o.length&&setTimeout(function(){if(!v)throw"can not restore. webglcontestlost listener did not call event.preventDefault";!function(){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:0;this.isPlaying=!0,this.scaledTime=e}},{key:"Stop",value:function(){this.isPlaying=!1}},{key:"Update",value:function(e){if(this.isPlaying){this.scaledTime+=e*this.scale;for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:this;this._copyFunc&&(this._copyFunc.call(this),"OnValueChanged"in this.destinationObject&&this.destinationObject.OnValueChanged(e,[this.destinationAttribute]))}}],[{key:"CopyValueToValue",value:function(){this.destinationObject[this.destinationAttribute]=this.sourceObject[this.sourceAttribute]*this.scale+this.offset[0]}},{key:"CopyArray",value:function(){for(var e=Math.min(this.destinationObject[this.destinationAttribute].length,this.sourceObject[this.sourceAttribute].length),t=0;t0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.value=a.util.isArrayLike(r)?r[0]:r,n.constantBuffer=null,n.offset=null,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.Tw2Parameter),n(t,[{key:"SetValue",value:function(e){this.value=e,this.OnValueChanged()}},{key:"GetValue",value:function(){return this.value}},{key:"Apply",value:function(e,t){e[t]=this.value}},{key:"EqualsValue",value:function(e){return this.value===e}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.SetValue(e.GetValue())}}],[{key:"is",value:function(e){return"number"==typeof e}}]),t}()).size=1},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MatrixParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.mat4.create();return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"Compose",value:function(e,t,r){"value"in e&&(e=e.value),"value"in t&&(t=t.value),"value"in r&&(r=r.value),i.mat4.fromRotationTranslationScale(this.value,e,t,r),this.OnValueChanged()}},{key:"Decompose",value:function(e,t,r){i.mat4.getRotation("value"in e?e.value:e,this.value),i.mat4.getTranslation("value"in t?t.value:t,this.value),i.mat4.getScaling("value"in r?r.value:r,this.value),"OnValueChanged"in e&&e.OnValueChanged(),"OnValueChanged"in t&&t.OnValueChanged(),"OnValueChanged"in r&&r.OnValueChanged()}},{key:"x",get:function(){return this.GetIndexValue(12)},set:function(e){this.SetIndexValue(12,e)}},{key:"y",get:function(){return this.GetIndexValue(13)},set:function(e){this.SetIndexValue(13,e)}},{key:"z",get:function(){return this.GetIndexValue(14)},set:function(e){this.SetIndexValue(14,e)}}]),t}()).constantBufferSize=16},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TransformParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.scaling=i.vec3.fromValues(1,1,1),r.rotationCenter=i.vec3.create(),r.rotation=i.quat.create(),r.translation=i.vec3.create(),r.transform=i.mat4.create(),r.worldTransform=i.mat4.create(),r.constantBuffer=null,r.offset=null,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2Parameter),n(t,[{key:"Initialize",value:function(){this.OnValueChanged()}},{key:"GetValue",value:function(e){return e?Array.from(this.transform):new Float32Array(this.transform)}},{key:"OnValueChanged",value:function(e,r){i.mat4.fromRotationTranslationScaleOrigin(this.transform,this.rotation,this.translation,this.scaling,this.rotationCenter),i.mat4.transpose(this.worldTransform,this.transform),function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,r,n)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(n):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"OnValueChanged",this).call(this,e,r)}},{key:"Bind",value:function(e,t,r){return!this.constantBuffer&&r>=this.size&&(this.constantBuffer=e,this.offset=t,this.Apply(e,t,r),!0)}},{key:"Apply",value:function(e,t,r){r>=this.constructor.constantBufferSize?e.set(this.worldTransform,t):e.set(this.worldTransform.subarray(0,r),t)}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),i.quat.copy(this.rotation,e.rotation),i.vec3.copy(this.translation,e.translation),i.vec3.copy(this.scaling,e.scaling),i.vec3.copy(this.rotationCenter,e.rotationCenter),this.OnValueChanged()}}]),t}()).constantBufferSize=16},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VariableParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.variableName=r,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2Parameter),n(t,[{key:"GetValue",value:function(e){return i.store.GetVariableValue(this.variableName,e)}},{key:"Apply",value:function(e,t,r){this.variable&&this.variable.Apply(e,t,r)}},{key:"AddCallback",value:function(){return!1}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.variableName=e.variableName}},{key:"variable",get:function(){return i.store.GetVariable(this.variableName)}},{key:"size",get:function(){return this.variable?this.variable.size:0}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector2Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec2.fromValues(1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}}]),t}()).constantBufferSize=2},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector3Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec3.fromValues(1,1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}},{key:"z",get:function(){return this.GetIndexValue(2)},set:function(e){this.SetIndexValue(2,e)}}]),t}()).constantBufferSize=3},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector4Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec4.fromValues(1,1,1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}},{key:"z",get:function(){return this.GetIndexValue(2)},set:function(e){this.SetIndexValue(2,e)}},{key:"w",get:function(){return this.GetIndexValue(3)},set:function(e){this.SetIndexValue(3,e)}}]),t}()).constantBufferSize=4},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(97);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(44);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(25);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveBasicPerObjectData=t.Tw2BasicPerObjectData=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"DeclareFromObject",this).call(this,e),e.FFEData&&(this.perObjectFFEData=new s.Tw2RawData(e.FFEData))}}]),t}();t.EveBasicPerObjectData=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(99);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(117);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2RuntimeInstanceData=function(){this.name="",this.count=0;var e=null,t=null,r=0,o=0,s=null,u=!0;this.GetMaxInstanceCount=function(){return s?s.length:1},this.SetElementLayout=function(o){t&&(n.device.gl.deleteBuffer(t),t=null),r=0,e=new i.Tw2VertexDeclaration;for(var s=0;s1)for(var i=0;ithis.geometryIndex&&this.geometryResource.meshes[this.geometryIndex].bufferData){this._spawned=!0;for(var e=this.geometryResource.meshes[this.geometryIndex],t=this.particleSystem.elements,r=new Array(t.length),n=0;n=this.maxParticleCount?null:this.aliveCount++}},{key:"EndSpawnParticle",value:function(){this.bufferDirty=!0}},{key:"Update",value:function(t){if(t=Math.min(t,.1),this.applyAging&&this.HasElement(o.Tw2ParticleElementDeclaration.Type.LIFETIME)){for(var r=this.GetElement(o.Tw2ParticleElementDeclaration.Type.LIFETIME),n=this.emitParticleOnDeathEmitter?this.GetElement(o.Tw2ParticleElementDeclaration.Type.POSITION):null,a=this.emitParticleOnDeathEmitter?this.GetElement(o.Tw2ParticleElementDeclaration.Type.VELOCITY):null,s=0;s1){if(this.emitParticleOnDeathEmitter&&this.emitParticleOnDeathEmitter.SpawnParticles(n,a,1),this.aliveCount--,s=n&&t>=n)return et?1:0;if(e>=n)return 1;if(t>=n)return-1;var r=s[e],i=s[t];return ri?-1:0})}},{key:"GetInstanceBuffer",value:function(){if(0!==this.aliveCount){var e=a.device;if(this.requiresSorting&&this.HasElement(o.Tw2ParticleElementDeclaration.Type.POSITION)&&this.buffers){this._Sort();for(var t=this.instanceStride[0],r=this.buffers[0],n=0;n0&&void 0!==arguments[0]?arguments[0]:[];return i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"GetResources",this).call(this,e),this.instanceGeometryResource&&"GetResources"in this.instanceGeometryResource&&this.instanceGeometryResource.GetResources(e),e}},{key:"RenderAreas",value:function(e,t,r,n,i){if(this.IsGood()){var a=this.instanceGeometryResource.GetInstanceBuffer(this.instanceMeshIndex);a&&this.geometryResource.RenderAreasInstanced(e,t,r,n,i,a,this.instanceGeometryResource.GetInstanceDeclaration(this.instanceMeshIndex),this.instanceGeometryResource.GetInstanceStride(this.instanceMeshIndex),this.instanceGeometryResource.GetInstanceCount(this.instanceMeshIndex))}}}],[{key:"GetAreaBatches",value:function(e,t,r,n,i){for(var a=0;a0&&void 0!==arguments[0]?arguments[0]:[],t=0;tf.duration&&(c.callback&&c.callback(this,c),c.cycle?c.time=c.time%f.duration:(c.isPlaying=!1,c.time=f.duration));for(var h=0;h=0){var i=this.models[t].bones[n.boneRes.parentIndex];e.AddLine([n.worldTransform[12],n.worldTransform[13],n.worldTransform[14]],[i.worldTransform[12],i.worldTransform[13],i.worldTransform[14]])}}}}],[{key:"AddModel",value:function(e,t){for(var r=0;r7)return i.logger.log("res.error",{log:"error",src:["Tw2EffectRes","CreateProgram"],msg:"Invalid version of effect file",type:"shader.effectversion",path:this.path,value:o}),void this.PrepareFinished(!1);var s=void 0,u=void 0;if(o<5){if(0===(s=t.ReadUInt32()))return i.logger.log("res.error",{log:"error",src:["Tw2EffectRes","CreateProgram"],msg:"File contains no compiled effects",path:this.path,type:"shader.effectheadersize",value:0}),void this.PrepareFinished(!1);t.ReadUInt32();var l=t.ReadUInt32();t.cursor=8+3*s*4,u=t.ReadUInt32(),this.stringTableOffset=t.cursor,r=String.fromCharCode.apply(null,t.data.subarray(t.cursor,t.cursor+u)),t.cursor=l}else{u=t.ReadUInt32(),this.stringTableOffset=t.cursor,r=String.fromCharCode.apply(null,t.data.subarray(t.cursor,t.cursor+u)),t.cursor+=u;for(var c=t.ReadUInt8(),f=0;f6&&(h=t.ReadUInt8());for(var p=0;p6&&(d.name=c()),this.techniques[d.name]=d;for(var v=t.ReadUInt8(),m=0;m=3&&(t.ReadUInt32(),t.ReadUInt32(),t.ReadUInt32()),E.constantSize=0;for(var C=t.ReadUInt32(),I=0;IE.constantSize&&(E.constantSize=x)}}var L=t.ReadUInt32()/4;if(E.constantValues=new Float32Array(L),r<5)for(var B=0;B=4?c():"";t.ReadUInt8();var X=t.ReadUInt8(),K=t.ReadUInt8(),Q=t.ReadUInt8(),Z=t.ReadUInt8(),J=t.ReadUInt8(),$=t.ReadUInt8();t.ReadFloat32();var ee=t.ReadUInt8();t.ReadUInt8();var te=s.quat.create();te[0]=t.ReadFloat32(),te[1]=t.ReadFloat32(),te[2]=t.ReadFloat32(),te[3]=t.ReadFloat32(),t.ReadFloat32(),t.ReadFloat32(),r<4&&t.ReadUInt8();var re=new u.Tw2SamplerState;if(re.registerIndex=Y,re.name=W,1===X){switch(Q){case 0:re.minFilter=f.gl.NEAREST;break;case 1:re.minFilter=f.gl.NEAREST_MIPMAP_NEAREST;break;default:re.minFilter=f.gl.NEAREST_MIPMAP_LINEAR}re.minFilterNoMips=f.gl.NEAREST}else{switch(Q){case 0:re.minFilter=f.gl.LINEAR;break;case 1:re.minFilter=f.gl.LINEAR_MIPMAP_NEAREST;break;default:re.minFilter=f.gl.LINEAR_MIPMAP_LINEAR}re.minFilterNoMips=f.gl.LINEAR}re.magFilter=1===K?f.gl.NEAREST:f.gl.LINEAR,re.addressU=f.wrapModes[Z],re.addressV=f.wrapModes[J],re.addressW=f.wrapModes[$],3!==X&&3!==K&&3!==Q||(re.anisotropy=Math.max(ee,1));for(var ne=0;ne=3&&t.ReadUInt8(),y.stages[T]=E}y.states=[];for(var ie=t.ReadUInt8(),ae=0;ae=0){var d=new o.Tw2VertexElement(r.stages[0].inputDefinition.elements[h].usage,r.stages[0].inputDefinition.elements[h].usageIndex);d.location=p,u.input.elements.push(d)}}u.input.RebuildHash(),u.shadowStateInt=s.gl.getUniformLocation(u.program,"ssi"),u.shadowStateFloat=s.gl.getUniformLocation(u.program,"ssf"),u.shadowStateYFlip=s.gl.getUniformLocation(u.program,"ssyf"),s.gl.uniform3f(u.shadowStateYFlip,0,0,1),u.volumeSlices=[];for(var v=0;v=this.meshes.length)return!1;var c=a.device,f=this.meshes[e],h=n.GetPassCount(i);c.gl.bindBuffer(c.gl.ELEMENT_ARRAY_BUFFER,f.indexes);for(var p=0;p=this.meshes.length)return!1;var s=a.device,u=this.meshes[e]||this.meshes[0],l=n.GetPassCount(i);s.gl.bindBuffer(s.gl.ARRAY_BUFFER,u.buffer),s.gl.bindBuffer(s.gl.ELEMENT_ARRAY_BUFFER,u.indexes);for(var c=0;c=this.meshes.length)return!1;var s=a.device,u=this.meshes[e],l=n.GetPassCount(i);s.gl.bindBuffer(s.gl.ARRAY_BUFFER,u.buffer),s.gl.bindBuffer(s.gl.ELEMENT_ARRAY_BUFFER,u.indexes);for(var c=0;c=0){var i=this.models[t].skeleton.bones[n.parentIndex];e.AddLine([n.worldTransform[12],n.worldTransform[13],n.worldTransform[14]],[i.worldTransform[12],i.worldTransform[13],i.worldTransform[14]],[0,.7,0,1],[0,.7,0,1])}}}},{key:"Unload",value:function(){for(var e=0;e>5),s.offset=4*n,t.elements[i]=s,n+=s.elements}t.RebuildHash(),t.stride=4*n;var l=e.ReadUInt32();if(0===l)return null;for(var c=new Float32Array(n*l),f=0,h=0;h0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.cycle=e,this._onEnded=t,this.video&&this._playable?(this.video.loop=this.cycle,this.video.play()):this.playOnLoad=!0}},{key:"Pause",value:function(){this.video?this.video.pause():this.playOnLoad=!1}},{key:"Prepare",value:function(e){var t=i.device.gl;switch(e){case"mp4":case"webm":case"ogg":this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this.video),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.bindTexture(t.TEXTURE_2D,null),this.width=this.video.width,this.height=this.video.height,this.video.loop=this.cycle,this.playOnLoad&&this.video.play(),this.PrepareFinished(!0)}}},{key:"DoCustomLoad",value:function(e){var t=this,r=a.resMan.constructor.GetPathExt(e);return this.LoadStarted(),a.resMan._pendingLoads++,this.video=document.createElement("video"),this.video.crossOrigin="anonymous",this.video.muted=!0,this.video.onerror=function(){a.resMan._pendingLoads--,o.logger.log("res.error",{log:"error",src:["Tw2TextureRes","DoCustomLoad"],msg:"Error loading resource",type:"http.error",path:e}),t.LoadFinished(!1),t.PrepareFinished(!1),t.video=null},this.video.oncanplay=function(){t._playable=!0,t.video.oncanplay=null,a.resMan._pendingLoads--,a.resMan._prepareQueue.push([t,r,null]),t.LoadFinished(!0)},this.video.onended=function(){t._isPlaying=!1,t._onEnded&&t._onEnded(t)},this.video.onpause=function(){t._isPlaying=!1,t._onPause&&t._onPause(t)},this.video.onplaying=function(){t._isPlaying=!0,t._onPlaying&&t._onPlaying(t)},this.video.src=e,!0}},{key:"Unload",value:function(){return this.texture&&(i.device.gl.deleteTexture(this.texture),this.texture=null),this._isPlaying=!1,this._playable=!1,this.playOnLoad=!0,this.video=null,!0}},{key:"Bind",value:function(e){var t=i.device;this.KeepAlive();var r=e.samplerType;r===t.gl.TEXTURE_2D&&(this.texture?(this._currentTime=this.video.currentTime,t.gl.bindTexture(t.gl.TEXTURE_2D,this.texture),t.gl.texImage2D(t.gl.TEXTURE_2D,0,t.gl.RGBA,t.gl.RGBA,t.gl.UNSIGNED_BYTE,this.video),t.gl.bindTexture(t.gl.TEXTURE_2D,null),t.gl.bindTexture(r,this.texture),e.hash!==this._currentSampler&&(e.Apply(!1),this._currentSampler=e.hash)):t.gl.bindTexture(t.gl.TEXTURE_2D,t.GetFallbackTexture()))}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(138);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PostProcess=void 0;var n=function(){function e(e,t){for(var r=0;r=a.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.vec4.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.vec4.copy(r,a.value);case t.Extrapolation.GRADIENT:return i.vec4.scaleAndAdd(r,a.value,a.right,e-a.time);default:e%=a.time}else if(e<0||e=o.time||ethis.length){if(!this.cycle)return this.reversed?i.vec4.copy(t,this.startValue):i.vec4.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec4.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a[2]=o[2]+(s[2]-o[2])*(e/l),a[3]=o[3]+(s[3]-o[3])*(e/l),a;default:return a}}}]),t}();c.inputDimension=4,c.outputDimension=4,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2EventCurve=t.Tw2EventKey=void 0;var n=function(){function e(e,t){for(var r=0;r=this.keys[this._currentKey].time;)this.value=this.keys[this._currentKey].value,++this._currentKey}}]),t}();l.dimension=1,l.outputDimension=1,l.valueProperty="value",l.curveType=i.Tw2Curve.Type.CURVE,l.Key=u,l.Extrapolation={NONE:0,CYCLE:3}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PerlinCurve=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?(t[0]=this.startValue[0],t[1]=this.startValue[1],t[2]=this.startValue[2],t):(t[0]=this.endValue[0],t[1]=this.endValue[1],t[2]=this.endValue[2],t);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var i=0;i+1e));++i);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){a[0]=this.startValue[0],a[1]=this.startValue[1],a[2]=this.startValue[2];var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.SPHERICAL_LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),i.quat.slerp(a,o,s,e/l),a;default:return a}}}]),t}();c.inputDimension=4,c.outputDimension=4,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,SPHERICAL_LINEAR:4}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2RandomConstantCurve=void 0;var n=function(){function e(e,t){for(var r=0;r=this.states[this.states.length-1].time)r=this.states.length-1;else for(;r+1=this.states[r].time&&e=s.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.quat.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.quat.copy(r,s.value);default:e%=s.time}else if(e<0||e=u.time||e0;p--){var d=i.num.biCumulative(c,p);d>1&&i.quat.multiply(r,f,h[p]),r[0]=-h[p-1][0],r[1]=-h[p-1][1],r[2]=-h[p-1][2],r[3]=h[p-1][3],i.quat.multiply(r,r,h[p]),i.quat.pow(r,r,d),i.quat.multiply(f,f,r)}return i.quat.multiply(r,f,l.value);case t.Interpolation.SLERP:return i.quat.slerp(r,l.value,u.value,c);default:return i.quat.sqlerp(r,l.value,l.right,u.left,u.value,c)}}}]),t}();c.outputDimention=4,c.inputDimension=4,c.valueProperty="value",c.curveType=a.Tw2Curve.Type.CURVE,c.Child=l,c.Extrapolation={NONE:0,CONSTANT:1,GRADIENT:2,CYCLE:3},c.Interpolation={NONE:0,CONSTANT:1,LINEAR:2,HERMITE:3,SLERP:5,SQUAD:6}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2ScalarCurve=t.Tw2ScalarKey=void 0;var n=function(){function e(e,t){for(var r=0;r=n.time)switch(this.extrapolation){case t.Extrapolation.NONE:return this.value;case t.Extrapolation.CONSTANT:return n.value;case t.Extrapolation.GRADIENT:return n.value+(e-n.time)*n.right;default:e%=n.time}else if(e<0||e=i.time||ethis.length){if(!this.cycle)return this.reversed?this.startValue:this.endValue;e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null);var t=this.keys[0],r=this.keys[this.keys.length-1];if(e<=t.time)return this.Interpolate(e,null,t);if(e>=r.time)return this.Interpolate(e,r,null);for(var n=0;n+1e));++n);return this.Interpolate(e,t,r)}},{key:"Interpolate",value:function(e,r,n){var i=this.startValue,a=this.endValue,o=this.interpolation,s=this.length;switch(null!==r&&(o=r.interpolation,e-=r.time),o){case t.Interpolation.LINEAR:return r&&n?(i=r.value,a=n.value,s=n.time-r.time):n?(a=n.value,s=n.time):r&&(i=r.value,s=this.length-r.time),i+e/s*(a-i);case t.Interpolation.HERMITE:var u=this.startTangent,l=this.endTangent;r&&n?(i=r.value,u=r.rightTangent,a=n.value,l=n.leftTangent,s=n.time-r.time):n?(a=n.value,l=n.leftTangent,s=n.time):r&&(i=r.value,u=r.rightTangent,s=this.length-r.time);var c=e/s,f=c*c,h=f*c,p=-2*h+3*f,d=h-f;return i*(1-p)+a*p+u*(c+d-f)+l*d;default:return this.startValue}}}]),t}();l.inputDimension=1,l.outputDimension=1,l.valueProperty="currentValue",l.curveType=i.Tw2Curve.Type.CURVE2,l.Key=u,l.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SineCurve=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?i.vec2.copy(t,this.startValue):i.vec2.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec2.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a;case t.Interpolation.HERMITE:var c=this.startTangent,f=this.endTangent;r&&n?(o=r.value,c=r.rightTangent,s=n.value,f=n.leftTangent,l=n.time-r.time):n?(s=n.value,f=n.leftTangent,l=n.time):r&&(o=r.value,c=r.rightTangent,l=this.length-r.time);var h=e/l,p=h*h,d=p*h,v=-2*d+3*p,m=1-v,y=d-p,b=h+y-p;return a[0]=o[0]*m+s[0]*v+c[0]*b+f[0]*y,a[1]=o[1]*m+s[1]*v+c[1]*b+f[1]*y,a;default:return a}}}]),t}();c.inputDimension=2,c.outputDimension=2,c.valueProperty="value",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector3Curve=t.Tw2Vector3Key=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?i.vec3.copy(t,this.startValue):i.vec3.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec3.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a[2]=o[2]+(s[2]-o[2])*(e/l),a;case t.Interpolation.HERMITE:var c=this.startTangent,f=this.endTangent;r&&n?(o=r.value,c=r.rightTangent,s=n.value,f=n.leftTangent,l=n.time-r.time):n?(s=n.value,f=n.leftTangent,l=n.time):r&&(o=r.value,c=r.rightTangent,l=this.length-r.time);var h=e/l,p=h*h,d=p*h,v=-2*d+3*p,m=1-v,y=d-p,b=h+y-p;return a[0]=o[0]*m+s[0]*v+c[0]*b+f[0]*y,a[1]=o[1]*m+s[1]*v+c[1]*b+f[1]*y,a[2]=o[2]*m+s[2]*v+c[2]*b+f[2]*y,a;default:return a}}}]),t}();c.inputDimension=3,c.outputDimension=3,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VectorCurve=t.Tw2VectorKey=void 0;var n=function(){function e(e,t){for(var r=0;r=a.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.vec3.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.vec3.copy(r,a.value);case t.Extrapolation.GRADIENT:return i.vec3.scaleAndAdd(r,a.value,a.right,e-a.time);default:e%=a.time}else if(e<0||e=o.time||e=0&&this._UpdateValue(e))}}function o(){this._id=n.util.generateID(),this.translation=n.vec3.create(),this.rotation=n.quat.create(),this.rotation[3]=1,this.scale=n.vec3.create();var e=null,t=null,r=null,i=n.mat4.create();this._TracksReady=function(){return e||t||r},this._ApplyTracks=function(n,i){for(var a=0;athis.duration||e<0||(i.curve.evaluate(this.positionCurve,e,this.translation,this.cycle,this.duration),i.curve.evaluate(this.orientationCurve,e,this.rotation,this.cycle,this.duration),i.quat.normalize(this.rotation,this.rotation),i.curve.evaluate(this.scaleCurve,e,this.scaleShear,this.cycle,this.duration),i.mat4.getScaling(this.scale,this.scaleCurve))))}},{key:"FindTracks",value:function(){for(var e=null,t=0;t=0&&(this.length=this.animationEngine.GetLength(this.xIndex)),this.yIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.yIndex))),this.zIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.zIndex))))}}]),t}();o.outputDimension=3,o.valueProperty="eulerValue",o.curveType=a.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaScalarCurve=void 0;var n=function(){function e(e,t){for(var r=0;r=0&&(this.length=this.animationEngine.GetLength(this.index))}}]),t}();a.outputDimension=1,a.valueProperty="value",a.curveType=i.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaVector3Curve=void 0;var n=function(){function e(e,t){for(var r=0;r=0&&(this.length=this.animationEngine.GetLength(this.xIndex)),this.yIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.yIndex))),this.zIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.zIndex))))}}]),t}();o.outputDimension=3,o.valueProperty="value",o.curveType=a.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaAnimationEngine=void 0;var n=function(){function e(e,t){for(var r=0;ri[e.AnimCurveFields.END_TIME]?i[e.AnimCurveFields.POST_INFINITY]===e.INFINITY?i[e.AnimCurveFields.END_VALUE]:this._EvaluateInfinities(i,o,a,r,!1):this._EvaluateImpl(i,o,a,r)}},{key:"_EvaluateImpl",value:function(t,r,n,i){var a=!1,o=null,s=null,u=void 0;if(this._evalCache[this._currentCurveIndex]>=0)if(s=n+this._evalCache[this._currentCurveIndex],this._evalCache[this._currentCurveIndex]r[s][e.AnimSegment.TIME]){if(i===r[o=n+this._evalCache[this._currentCurveIndex]+1][e.AnimSegment.TIME])return this._evalCache[this._currentCurveIndex]++,r[o][e.AnimSegment.VALUE];i0&&ir[l][e.AnimSegment.TIME])u=this._evalCache[this._currentCurveIndex],a=!0;else if(i===r[l][e.AnimSegment.TIME])return this._evalCache[this._currentCurveIndex]--,r[l][e.AnimSegment.VALUE]}if(!a){var c=this._Find(t,i,r,n);if(u=c[1],c[0]||0===u)return u===t[e.AnimCurveFields.NUM_SEGMENTS]?(u--,this._evalCache[this._currentCurveIndex]=u,t[e.AnimCurveFields.END_VALUE]):(this._evalCache[this._currentCurveIndex]=u,r[n+u][e.AnimSegment.VALUE]);if(u===t[e.AnimCurveFields.NUM_SEGMENTS]+1)return this._evalCache[this._currentCurveIndex]=0,t[e.AnimCurveFields.END_VALUE]}if(this._evalCache[this._currentCurveIndex]!==u-1&&(this._evalCache[this._currentCurveIndex]=u-1,s=n+this._evalCache[this._currentCurveIndex],null===o&&(o=n+u)),t[e.AnimCurveFields.IS_WEIGHTED]){var f=r[s];if(f[e.BezierSegment.IS_STEP])return f[e.BezierSegment.VALUE];if(f[e.BezierSegment.IS_STEP_NEXT])return null===o?t[e.AnimCurveFields.END_VALUE]:r[o][e.BezierSegment.VALUE];var h=t[e.AnimCurveFields.END_TIME];return this._evalCache[this._currentCurveIndex]+10){s=0,u=a-1;do{if(r<(c=(o=s+u>>1)c))return[!0,l=o];s=o+1}}while(s<=u);l=s}return[!1,l]}},{key:"GetNumberOfCurves",value:function(){return this.curves.length}},{key:"GetLength",value:function(t){if(t<0||t>=this.curves.length)return 0;var r=this.curves[t],n=void 0;return n=r[e.AnimCurveFields.IS_WEIGHTED]?this.bezierSegments[r[e.AnimCurveFields.SEGMENT_OFFSET]]:this.hermiteSegments[r[e.AnimCurveFields.SEGMENT_OFFSET]],r[e.AnimCurveFields.END_TIME]-n[e.AnimSegment.TIME]}}]),e}();a.AnimCurveFields={NUM_SEGMENTS:0,SEGMENT_OFFSET:1,END_TIME:2,END_VALUE:3,IN_TANGENT:4,OUT_TANGENT:5,PRE_INFINITY:6,POST_INFINITY:7,IS_WEIGHTED:8},a.AnimSegment={TIME:0,VALUE:1},a.HermiteSegment={TIME:0,VALUE:1,COEFF:2,IS_STEP:3,IS_STEP_NEXT:4},a.BezierSegment={TIME:0,VALUE:1,COEFF:2,POLYY:3,IS_STEP:4,IS_STEP_NEXT:5,IS_LINEAR:6},a.INFINITY=0},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(58);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(178);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(60);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(63);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(195);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(196);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveChildBillboard=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t0&&void 0!==arguments[0]?arguments[0]:[];this.mesh&&this.mesh.GetResources(e);for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return a.util.perArrayChild(this.opaqueEffects,"GetResources",e),a.util.perArrayChild(this.decalEffects,"GetResources",e),a.util.perArrayChild(this.transparentEffects,"GetResources",e),a.util.perArrayChild(this.additiveEffects,"GetResources",e),a.util.perArrayChild(this.distortionEffects,"GetResources",e),e}},{key:"Update",value:function(e){this.update&&this.curveSet&&this.curveSet.Update(e)}},{key:"GetBatches",value:function(e,t,r,n){if(this.display&&n&&n.IsGood())for(var a=this.GetEffects(e),o=0;o0&&void 0!==arguments[0]?arguments[0]:[];return this.source&&this.source.GetResources&&this.source.GetResources(e),this.dest&&this.dest.GetResources&&this.dest.GetResources(e),this.sourceObject&&this.sourceObject.GetResources&&this.sourceObject.GetResources(e),this.destObject&&this.destObject.GetResources&&this.destObject.GetResources(e),this.stretchObject&&this.stretchObject.GetResources&&this.stretchObject.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(){if(this.display){var t=e.global,r=i.vec3.subtract(t.vec3_0,this._destinationPosition,this._sourcePosition),n=i.mat4.identity(t.mat4_0),a=i.vec3.set(t.vec3_1,0,0,0),o=i.vec3.set(t.vec3_2,0,0,0),s=i.mat4.identity(t.mat4_1),u=i.vec3.length(r);i.vec3.normalize(r,r),this._useTransformsForStretch?(i.mat4.rotateX(n,n,-Math.PI/2),i.mat4.multiply(n,this._sourceTransform,n)):(Math.abs(r[1])>.9?o[2]=1:o[1]=1,i.vec3.cross(a,o,r),i.vec3.normalize(a,a),i.vec3.cross(o,r,a),n[0]=a[0],n[1]=a[1],n[2]=a[2],n[4]=-r[0],n[5]=-r[1],n[6]=-r[2],n[8]=o[0],n[9]=o[1],n[10]=o[2]),this.destObject&&this._displayDestObject&&(i.mat4.setTranslation(n,this._destinationPosition),this.destObject.UpdateViewDependentData(n)),this.sourceObject&&this._displaySourceObject&&(this._useTransformsForStretch?(i.mat4.identity(n),i.mat4.rotateX(n,n,-Math.PI/2),i.mat4.multiply(n,this._sourceTransform,n)):i.mat4.setTranslation(n,this._sourcePosition),this.sourceObject.UpdateViewDependentData(n)),this.stretchObject&&(this._useTransformsForStretch?(i.mat4.identity(n),i.mat4.scale(n,n,[1,1,u]),i.mat4.multiply(n,this._sourceTransform,n)):(n[0]=a[0],n[1]=a[1],n[2]=a[2],n[4]=o[0],n[5]=o[1],n[6]=o[2],n[8]=-r[0],n[9]=-r[1],n[10]=-r[2],this._isNegZForward&&(u=-u),i.mat4.scale(s,s,[1,1,u]),i.mat4.multiply(n,n,s)),this.stretchObject.UpdateViewDependentData(n))}}},{key:"Update",value:function(t){for(var r=0;r0&&(this._perMuzzleData[0].constantDelay=this.firingDelay1),this._perMuzzleData.length>1&&(this._perMuzzleData[1].constantDelay=this.firingDelay2),this._perMuzzleData.length>2&&(this._perMuzzleData[2].constantDelay=this.firingDelay3),this._perMuzzleData.length>3&&(this._perMuzzleData[3].constantDelay=this.firingDelay4),this._perMuzzleData.length>4&&(this._perMuzzleData[4].constantDelay=this.firingDelay5),this._perMuzzleData.length>5&&(this._perMuzzleData[5].constantDelay=this.firingDelay6),this._perMuzzleData.length>6&&(this._perMuzzleData[6].constantDelay=this.firingDelay7),this._perMuzzleData.length>7&&(this._perMuzzleData[7].constantDelay=this.firingDelay8)}},{key:"GetCurveDuration",value:function(){for(var e=0,t=0;t1&&void 0!==arguments[1]?arguments[1]:-1,r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t=this._perMuzzleData[n].elapsedTime||this.isLoopFiring)&&this.stretch[n].GetBatches(e,t,r)}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveEffectRoot=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t0&&void 0!==arguments[0]?arguments[0]:[];this.mesh&&this.mesh.GetResources(e),this.spriteSet&&this.spriteSet.GetResources(e)}},{key:"UpdateViewDependentData",value:function(){this.display&&this.state!==t.State.DEAD&&(i.mat4.transpose(this._perObjectData.perObjectVSData.Get("WorldMat"),this.transform),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("WorldMatLast"),this.transform))}},{key:"Update",value:function(e,r,n){if(this.state===t.State.IN_FLIGHT){var a=t.global,o=i.mat4.getTranslation(a.vec3_0,this.transform),s=a.vec3_1,u=a.vec3_2,l=a.vec3_3;this.time+=e,this.time>this.durationEjectPhase?(i.vec3.subtract(o,this.velocity,r),i.vec3.lerp(o,o,r,1-Math.exp(.9999*-e)),i.mat4.setTranslation(this.transform,o),i.vec3.subtract(s,n,o),i.vec3.length(s)t.length)this.warheads.splice(t.length);else for(;this.warheads.length0&&void 0!==arguments[0]?arguments[0]:[],t=0;t.1&&(i.vec3.normalize(t,t),i.vec3.scale(t,t,Math.min(e*this.speed,r)),i.vec3.add(this.position,this.position,t));for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:[];return this.highDetail&&this.highDetail.GetResources(e),this.effectHeight&&this.effectHeight.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(e){this.highDetail.UpdateViewDependentData(e),this.zOnlyModel&&(this.zOnlyModel.translation=this.highDetail.translation,this.zOnlyModel.scaling=this.highDetail.scaling,this.zOnlyModel.UpdateViewDependentData(e))}},{key:"Update",value:function(e){this.highDetail.Update(e)}},{key:"GetBatches",value:function(e,t){if(this.display&&this.heightDirty&&this.watchedResources.length&&""!==this.heightMapResPath1){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],r=arguments[1];i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"GetResources",this).call(this,e,r);for(var n=0;n1)for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t.visible,e.visible,["glow","symHalo","halo","trail"]),i.util.assignIfExists(t,e,["name","display","seed","wavePhase","transform","locatorName","updateFromLocator","atlas0","atlas1"]),t}}]),t}(),h=t.EveBoosterSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.visible={},e.visible.glows=!0,e.visible.symHalos=!0,e.visible.halos=!0,e.visible.trails=!0,e.effect=null,e.glows=null,e.alwaysOn=!0,e.maxVel=250,e.glowDistance=2.5,e.glowScale=1,e.glowColor=i.vec4.create(),e.warpGlowColor=i.vec4.create(),e.haloDistance=3.01,e.haloScaleX=1,e.haloScaleY=1,e.haloColor=i.vec4.create(),e.warpHaloColor=i.vec4.create(),e.symHaloDistance=3,e.symHaloScale=1,e.trailColor=i.vec4.create(),e.trailSize=i.vec4.create(),e._parentTransform=i.mat4.create(),e._positions=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,a.device.gl.FLOAT,3,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,a.device.gl.FLOAT,2,12)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,a.device.gl.FLOAT,4,20)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,a.device.gl.FLOAT,4,36)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,a.device.gl.FLOAT,4,52)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,a.device.gl.FLOAT,4,68)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,a.device.gl.FLOAT,4,84)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,6,a.device.gl.FLOAT,1,100)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,7,a.device.gl.FLOAT,2,104)),e._decl.RebuildHash(),e._perObjectData=new a.Tw2PerObjectData,e._perObjectData.perObjectVSData=new a.Tw2RawData,e._perObjectData.perObjectVSData.Declare("WorldMat",16),e._perObjectData.perObjectVSData.Declare("Shipdata",4),e._perObjectData.perObjectVSData.Create(),e._locatorRebuildPending=!0,e}return l(t,o.EveObjectSet),n(t,[{key:"FindItemByLocatorName",value:function(e){for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),this.glows&&this.glows.effect.GetResources(e),e}},{key:"Update",value:function(e,t){i.mat4.copy(this._parentTransform,t),this._rebuildPending&&this.Rebuild(),this.glows&&this.glows.Update(e)}},{key:"Unload",value:function(){this._positions&&(a.device.gl.deleteBuffer(this._positions),this._positions=null),this.glows&&this.glows.Unload()}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this);var e=this._visibleItems.length;if(this._rebuildPending=!1,e){for(var r=a.device,n=t._box,i=new Float32Array(e*n.length*6*28),o=[0,3,1,3,2,1],s=0,u=0;u0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","type","position1","color1","position2","color2","intermediatePosition","width","multiColor","multiColorBorder","overlayColor","animationSpeed","animationScale","numOfSegments"]),t}}]),t}();c.Type={INVALID:0,STRAIGHT:1,SPHERED:2,CURVED:3},c.DEFAULT_CURVED_SEGMENTS=20,c.DEFAULT_SPHERED_SEGEMENTS=20;var f=t.EveCurveLineSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.lineEffect=a.Tw2Effect.create({effectFilePath:"res:/Graphics/Effect/Managed/Space/SpecialFX/Lines3D.fx",textures:{TexMap:"res:/texture/global/white.dds.0.png",OverlayTexMap:"res:/texture/global/white.dds.0.png"}}),e.pickEffect=null,e.lineWidthFactor=1,e.additive=!1,e.pickable=!0,e.depthOffset=0,e.translation=i.vec3.create(),e.rotation=i.quat.create(),e.scaling=i.vec3.fromValues(1,1,1),e.transform=i.mat4.create(),e.parentTransform=i.mat4.create(),e._vertexSize=26,e._vbSize=0,e._vb=null,e._perObjectData=new a.Tw2PerObjectData,e._perObjectData.perObjectVSData=new a.Tw2RawData,e._perObjectData.perObjectVSData.Declare("WorldMat",16),e._perObjectData.perObjectVSData.Create(),e._perObjectData.perObjectPSData=new a.Tw2RawData,e._perObjectData.perObjectPSData.Declare("WorldMat",16),e._perObjectData.perObjectPSData.Create(),e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,a.device.gl.FLOAT,3,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,a.device.gl.FLOAT,4,12)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,a.device.gl.FLOAT,4,28)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,a.device.gl.FLOAT,3,44)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,a.device.gl.FLOAT,4,56)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,1,a.device.gl.FLOAT,4,72)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,2,a.device.gl.FLOAT,4,88)),e._decl.stride=4*e._vertexSize,e._decl.RebuildHash(),t.init(),e}return l(t,o.EveObjectSet),n(t,[{key:"Initialize",value:function(){this.OnValueChanged(),this.Rebuild()}},{key:"AddStraightLine",value:function(e,t,r,n,i){return this.CreateItem({type:c.Type.STRAIGHT,position1:e,position2:t,color1:n,color2:i,width:r})}},{key:"AddCurvedLineCrt",value:function(e,t,r,n,i,a){return this.CreateItem({type:c.Type.CURVED,position1:e,position2:t,intermediatePosition:r,color1:i,color2:a,width:n,numOfSegments:c.DEFAULT_CURVED_SEGMENTS})}},{key:"AddCurvedLineSph",value:function(e,r,n,a,o,s,u){var l=t.global;return this.CreateItem({type:c.Type.CURVED,position1:i.vec3.fromSpherical(l.vec3_0,e,n),position2:i.vec3.fromSpherical(l.vec3_1,r,n),intermediatePosition:i.vec3.fromSpherical(l.vec3_2,a,n),color1:s,color2:u,width:o,numOfSegments:c.DEFAULT_CURVED_SEGMENTS})}},{key:"AddSpheredLineCrt",value:function(e,t,r,n,i,a){return this.CreateItem({type:c.Type.SPHERED,position1:e,position2:t,intermediatePosition:r,color1:i,color2:a,width:n,numOfSegments:c.DEFAULT_SPHERED_SEGEMENTS})}},{key:"AddSpheredLineSph",value:function(e,r,n,a,o,s,u){var l=t.global;return this.CreateItem({type:c.Type.SPHERED,position1:i.vec3.fromSpherical(l.vec3_0,e,n),position2:i.vec3.fromSpherical(l.vec3_1,r,n),intermediatePosition:i.vec3.fromSpherical(l.vec3_2,a,n),color1:s,color2:u,width:o,numOfSegments:c.DEFAULT_SPHERED_SEGEMENTS})}},{key:"OnValueChanged",value:function(){i.mat4.fromRotationTranslationScale(this.transform,this.rotation,this.translation,this.scaling),this._rebuildPending=!0}},{key:"UpdateViewDependentData",value:function(e){i.mat4.copy(this.parentTransform,e)}},{key:"Update",value:function(){this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){this._vb&&(a.device.gl.deleteBuffer(this._vb),this._vb=null)}},{key:"Rebuild",value:function(){t.RebuildItems(this),this._vb=null,this._vbSize=this.lineCount,this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=t.global,n=new Float32Array(6*this._vbSize*this._vertexSize),o=r.vec3_0,s=r.vec3_1,u=r.vec3_2,l=r.vec3_3,f=r.vec3_4,h=r.vec3_5,p=r.vec3_6,d=r.mat4_0,v=r.vec3_7,m=r.vec3_8,y=r.vec3_9,b=r.vec3_10,g=r.vec4_0,_=r.vec4_1,E=0,T=void 0,O=0;O0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","boneIndex","groupIndex","maskAtlasID","position","scaling","rotation","transform","color","layer1Transform","layer2Transform","layer1Scroll","layer2Scroll"]),t}}]),t}();(t.EvePlaneSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.effect=null,e.hideOnLowQuality=!1,e._time=0,e._vertexBuffer=null,e._indexBuffer=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,a.device.gl.FLOAT,4,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,a.device.gl.FLOAT,4,16)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,a.device.gl.FLOAT,4,32)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,a.device.gl.FLOAT,4,48)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,a.device.gl.FLOAT,4,64)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,a.device.gl.FLOAT,4,80)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,a.device.gl.FLOAT,4,96)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,6,a.device.gl.FLOAT,4,112)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,7,a.device.gl.FLOAT,3,128)),e._decl.RebuildHash(),e}return l(t,o.EveObjectSet),n(t,[{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),e}},{key:"Update",value:function(e){this._time+=e,this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){this._vertexBuffer&&(a.device.gl.deleteBuffer(this._vertexBuffer),this._vertexBuffer=null),this._indexBuffer&&(a.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"Rebuild",value:function(){this.Unload(),t.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=t.global.mat4_0,n=new Float32Array(4*e*35),o=0;o0&&void 0!==arguments[0]?arguments[0]:[];return this.parentGeometry&&!e.includes(this.parentGeometry)&&e.push(this.parentGeometry),this.decalEffect&&this.decalEffect.GetResources(e),this.pickEffect&&this.pickEffect.GetResources(e),e}},{key:"Unload",value:function(){this._indexBuffer&&(a.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"GetBatches",value:function(e,t,r,n){var o=void 0;switch(e){case a.device.RM_DECAL:o=this.decalEffect;break;case a.device.RM_PICKABLE:o=this.pickable?this.pickEffect:null}if(this.display&&o&&o.IsGood()&&this.indexBuffer.length&&this.parentGeometry&&this.parentGeometry.IsGood()){var s=new a.Tw2ForwardingRenderBatch;if(this._perObjectData.perObjectVSData.Set("worldMatrix",r.perObjectVSData.Get("WorldMat")),this.parentBoneIndex>=0){var u=r.perObjectVSData.Get("JointMat"),l=12*this.parentBoneIndex;if(u[l]||u[l+4]||u[l+8]){var c=this._perObjectData.perObjectVSData.Get("parentBoneMatrix");c[0]=u[l],c[1]=u[l+4],c[2]=u[l+8],c[3]=0,c[4]=u[l+1],c[5]=u[l+5],c[6]=u[l+9],c[7]=0,c[8]=u[l+2],c[9]=u[l+6],c[10]=u[l+10],c[11]=0,c[12]=u[l+3],c[13]=u[l+7],c[14]=u[l+11],c[15]=1,i.mat4.transpose(c,c)}}i.mat4.invert(this._perObjectData.perObjectVSData.Get("invWorldMatrix"),this._perObjectData.perObjectVSData.Get("worldMatrix")),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("decalMatrix"),this.decalMatrix),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("invDecalMatrix"),this.invDecalMatrix),this._perObjectData.perObjectPSData.Get("displayData")[0]=n||0,this._perObjectData.perObjectPSData.Set("shipData",r.perObjectPSData.data),s.perObjectData=this._perObjectData,s.geometryProvider=this,s.renderMode=e,s.effect=o,t.Commit(s)}}},{key:"Render",value:function(e,t){var r=this.parentGeometry.meshes[0].indexes,n=this.parentGeometry.meshes[0].areas[0].start,i=this.parentGeometry.meshes[0].areas[0].count,o=this.parentGeometry.meshes[0].indexType;a.store.SetVariableValue("u_DecalMatrix",this.decalMatrix),a.store.SetVariableValue("u_InvDecalMatrix",this.invDecalMatrix),this.parentGeometry.meshes[0].indexes=this._indexBuffer,this.parentGeometry.meshes[0].areas[0].start=0,this.parentGeometry.meshes[0].areas[0].count=this.indexBuffer.length,this.parentGeometry.meshes[0].indexType=a.device.gl.UNSIGNED_SHORT,this.parentGeometry.RenderAreas(0,0,1,e.effect,t),this.parentGeometry.meshes[0].indexes=r,this.parentGeometry.meshes[0].areas[0].start=n,this.parentGeometry.meshes[0].areas[0].count=i,this.parentGeometry.meshes[0].indexType=o}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveSpotlightSet=t.EveSpotlightSetItem=t.EveSpotlightSetBatch=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","boosterGainInfluence","boneIndex","groupIndex","coneIntensity","spriteIntensity","flareIntensity","transform","coneColor","spriteColor","flareColor","spriteScale"]),t}}]),t}();(t.EveSpotlightSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.coneEffect=null,e.glowEffect=null,e._coneVertexBuffer=null,e._spriteVertexBuffer=null,e._indexBuffer=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,a.device.gl.FLOAT,4,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,a.device.gl.FLOAT,4,16)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,a.device.gl.FLOAT,4,32)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,a.device.gl.FLOAT,4,48)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,a.device.gl.FLOAT,3,64)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,a.device.gl.FLOAT,3,76)),e._decl.RebuildHash(),e}return l(t,o.EveObjectSet),n(t,[{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.coneEffect&&this.coneEffect.GetResources(e),this.glowEffect&&this.glowEffect.GetResources(e),e}},{key:"Unload",value:function(){this._coneVertexBuffer&&(a.device.gl.deleteBuffer(this._coneVertexBuffer),this._coneVertexBuffer=null),this._spriteVertexBuffer&&(a.device.gl.deleteBuffer(this._spriteVertexBuffer),this._spriteVertexBuffer=null),this._indexBuffer&&(a.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"Rebuild",value:function(){this.Unload(),t.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=a.device,n=[1,0,2,3],i=new Float32Array(22*(4*e*4)),o=0;o0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","blinkRate","blinkPhase","minScale","maxScale","falloff","boneIndex","groupIndex","position","color","warpColor"]),t}}]),t}();(t.EveSpriteSet=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];s(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.effect=null,n.useQuads=null,n.isSkinned=null,n._time=0,n._vertexBuffer=null,n._indexBuffer=null,n._instanceBuffer=null,n._decl=n._decl=new a.Tw2VertexDeclaration,n._vdecl=new a.Tw2VertexDeclaration,n._vdecl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,a.device.gl.FLOAT,1,0)),n._vdecl.RebuildHash(),n.UseQuads(e,r),n}return l(t,o.EveObjectSet),n(t,[{key:"UseQuads",value:function(e,t){this.useQuads!==e&&(this.useQuads=e,this.isSkinned=t,this._decl.elements.splice(0,this._decl.elements.length),e?(this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,a.device.gl.FLOAT,3,0)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,a.device.gl.FLOAT,4,12)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,a.device.gl.FLOAT,2,28)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,a.device.gl.FLOAT,4,36)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,1,a.device.gl.FLOAT,4,52))):(this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,a.device.gl.FLOAT,2,0)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,a.device.gl.FLOAT,3,8)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,a.device.gl.FLOAT,3,20)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,a.device.gl.FLOAT,1,32)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,a.device.gl.FLOAT,1,36)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,a.device.gl.FLOAT,1,40)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,a.device.gl.FLOAT,1,44)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,a.device.gl.FLOAT,1,48))),this._decl.RebuildHash(),this._rebuildPending=!0)}},{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),e}},{key:"Update",value:function(e){this._time+=e,this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){this._vertexBuffer&&(a.device.gl.deleteBuffer(this._vertexBuffer),this._vertexBuffer=null),this._indexBuffer&&(a.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null),this._instanceBuffer&&(a.device.gl.deleteBuffer(this._instanceBuffer),this._instanceBuffer=null)}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){var t=a.device;if(this.useQuads)return this._vertexBuffer=t.gl.createBuffer(),t.gl.bindBuffer(t.gl.ARRAY_BUFFER,this._vertexBuffer),t.gl.bufferData(t.gl.ARRAY_BUFFER,new Float32Array([0,1,2,2,3,0]),t.gl.STATIC_DRAW),t.gl.bindBuffer(t.gl.ARRAY_BUFFER,null),void(this._instanceBuffer=t.gl.createBuffer());for(var r=new Float32Array(4*e*13),n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","locatorName","updateFromLocator","position","rotation","bone","canFireWhenHidden"]),t.UpdateTransforms(),t}}]),t}(),p=t.EveTurretSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.visible={},e.visible.turrets=!0,e.visible.firingEffects=!0,e.activeAnimation=new a.Tw2AnimationController,e.inactiveAnimation=new a.Tw2AnimationController,e.geometryResPath="",e.geometryResource=null,e.turretEffect=null,e.firingEffectResPath="",e.firingEffect=null,e.fireCallback=null,e.fireCallbackPending=!1,e.state=t.State.IDLE,e.bottomClipHeight=0,e.locatorName="",e.sysBoneHeight=0,e.hasCyclingFiringPos=!1,e.targetPosition=i.vec3.create(),e.parentMatrix=i.mat4.create(),e.boundingSphere=i.quat.create(),e._activeTurret=-1,e._recheckTimeLeft=0,e._currentCyclingFiresPos=0,e._perObjectDataActive=new a.Tw2PerObjectData,e._perObjectDataActive.perObjectVSData=new a.Tw2RawData,e._perObjectDataActive.perObjectVSData.Declare("baseCutoffData",4),e._perObjectDataActive.perObjectVSData.Declare("turretSetData",4),e._perObjectDataActive.perObjectVSData.Declare("shipMatrix",16),e._perObjectDataActive.perObjectVSData.Declare("turretTranslation",96),e._perObjectDataActive.perObjectVSData.Declare("turretRotation",96),e._perObjectDataActive.perObjectVSData.Declare("turretPoseTransAndRot",576),e._perObjectDataActive.perObjectVSData.Create(),e._perObjectDataInactive=new a.Tw2PerObjectData,e._perObjectDataInactive.perObjectVSData=new a.Tw2RawData,e._perObjectDataInactive.perObjectVSData.Declare("baseCutoffData",4),e._perObjectDataInactive.perObjectVSData.Declare("turretSetData",4),e._perObjectDataInactive.perObjectVSData.Declare("shipMatrix",16),e._perObjectDataInactive.perObjectVSData.Declare("turretTranslation",96),e._perObjectDataInactive.perObjectVSData.Declare("turretRotation",96),e._perObjectDataInactive.perObjectVSData.Declare("turretPoseTransAndRot",576),e._perObjectDataInactive.perObjectVSData.Create(),e._locatorRebuildPending=!0,e}return l(t,o.EveObjectSet),n(t,[{key:"Initialize",value:function(){var e=this;this.turretEffect&&""!==this.geometryResPath&&(this.geometryResource=a.resMan.GetResource(this.geometryResPath),this.activeAnimation.SetGeometryResource(this.geometryResource),this.inactiveAnimation.SetGeometryResource(this.geometryResource),this.geometryResource&&this.geometryResource.RegisterNotification(this)),""!==this.firingEffectResPath&&a.resMan.GetObject(this.firingEffectResPath,function(t){return e.firingEffect=t}),this.Rebuild()}},{key:"InitializeFiringEffect",value:function(){if(this.firingEffect&&this.geometryResource&&this.geometryResource.models.length)for(var e=this.geometryResource.models[0],r=0;rr&&(e=this.items.indexOf(l),r=c)}}return e}},{key:"EnterStateDeactive",value:function(){var e=this;this.state!==t.State.INACTIVE&&this.state!==t.State.PACKING&&(this.turretEffect?(this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.activeAnimation.PlayAnimation("Pack",!1,function(){e.state=t.State.INACTIVE,e.activeAnimation.PlayAnimation("Inactive",!0)}),this.inactiveAnimation.PlayAnimation("Pack",!1,function(){e.state=t.State.INACTIVE,e.inactiveAnimation.PlayAnimation("Inactive",!0)}),this.state=t.State.PACKING):this.state=t.State.INACTIVE,this._activeTurret=-1,this.firingEffect&&this.firingEffect.StopFiring())}},{key:"EnterStateIdle",value:function(){var e=this;this.state!==t.State.IDLE&&this.state!==t.State.UNPACKING&&(this.turretEffect?(this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.state===t.State.FIRING?(this.activeAnimation.PlayAnimation("Active",!0),this.inactiveAnimation.PlayAnimation("Active",!0)):(this.activeAnimation.PlayAnimation("Deploy",!1,function(){e.state=t.State.IDLE,e.activeAnimation.PlayAnimation("Active",!0)}),this.inactiveAnimation.PlayAnimation("Deploy",!1,function(){e.state=t.State.IDLE,e.inactiveAnimation.PlayAnimation("Active",!0)})),this.state=t.State.UNPACKING):this.state=t.State.IDLE,this._activeTurret=-1,this.firingEffect&&this.firingEffect.StopFiring())}},{key:"EnterStateFiring",value:function(){var e=this;if(!this.turretEffect||this.state===t.State.FIRING)return t.DoStartFiring(this),void(this.turretEffect&&this.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)}));this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.state===t.State.INACTIVE?(this.activeAnimation.PlayAnimation("Deploy",!1,function(){t.DoStartFiring(e),e.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)})}),this.inactiveAnimation.PlayAnimation("Deploy",!1,function(){e.inactiveAnimation.PlayAnimation("Active",!0)}),this.state=t.State.UNPACKING):(t.DoStartFiring(this),this.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)}),this.inactiveAnimation.PlayAnimation("Active",!0))}},{key:"RebuildCachedData",value:function(){for(var e=new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,a.device.gl.FLOAT,2),r=this.geometryResource.meshes,n=this.activeAnimation,i=this.inactiveAnimation,o=0;o0&&void 0!==arguments[0]?arguments[0]:[];return this.geometryResource&&!e.includes(this.geometryResource)&&e.push(this.geometryResource),this.turretEffect&&this.turretEffect.GetResources(e),this.firingEffect&&this.firingEffect.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(){this.firingEffect&&this.firingEffect.UpdateViewDependentData()}},{key:"Update",value:function(e,r){if(this._rebuildPending&&this.Rebuild(),this.turretEffect&&(this.activeAnimation.Update(e),this.inactiveAnimation.Update(e)),i.mat4.copy(this.parentMatrix,r),this.firingEffect&&this._visibleItems.length){if(-1!==this._activeTurret){this.firingEffect.isLoopFiring&&this.state===t.State.FIRING&&(this._recheckTimeLeft-=e,this._recheckTimeLeft<=0&&t.DoStartFiring(this));var n=this.items[this._activeTurret];if(this.activeAnimation.models.length)for(var a=this.activeAnimation.models[0].bonesByName,o=0;o0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1],r=0;r2&&void 0!==arguments[2]?arguments[2]:this._batches,n=0;n=0&&(u=e.substr(0,s+1)+o+"/"+e.substr(s+1)),(s=u.lastIndexOf("_"))>=0){u=u.substr(0,s)+"_"+o+u.substr(s);var l=r(n,"textureOverrides",{});if(t in l&&i.name in l[t])return u}}return e}function f(e,t){var r=l(t),n=(e="/"+e).lastIndexOf("/");return e.substr(0,n+1)+r+e.substr(n+1)}function h(e,t){for(var r=0;r=0&&s=0?r||T:t||(r||T);case"not_overridable":case"half_overridable_2":return r||T}return T}function w(t,r,a){var o=e.faction[r],s=e.faction[a],u=null;o&&o.areas&&"hull"in o.areas&&(u=o.areas.hull);var l=null;if(s&&s.areas&&"hull"in s.areas&&(l=s.areas.hull),(u||l)&&t.turretEffect){var c=t.turretEffect.parameters;for(var f in c)if(c.hasOwnProperty(f)){if(c[f].constructor.prototype!==i.Tw2Vector4Parameter.prototype)continue;var h=null,p=null;u&&(h=E(f,o,u)),l&&(p=E(f,o,u)),n.vec4.copy(c[f].value,O(f,h,p,t.turretEffect.name))}t.turretEffect.BindParameters()}}function S(t){if("all"!==t){var r={};for(var n in e[t])e[t].hasOwnProperty(n)&&(r[n]=e[t][n].description||"");return r}return e}this.SetupTurretMaterial=function(t,r,n,i){null===e?this.LoadData(function(){w(t,r,n),i&&i()}):(w(t,r,n),i&&i())},this.GetHullNames=function(e){this.LoadData(function(){e(S("hull"))})},this.GetFactionNames=function(e){this.LoadData(function(){e(S("faction"))})},this.GetRaceNames=function(e){this.LoadData(function(){e(S("race"))})},this.GetSofData=function(e){this.LoadData(function(){e(S("all"))})}};var n=r(0),i=r(1),a=r(57),o=r(63),s=r(58),u=r(60)}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ccpwgl_int=t():e.ccpwgl_int=t()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=65)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.util=void 0;var n=r(18);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(78);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(16));t.util=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(15);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(36);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(93);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(103);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(47);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(48);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(118);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(45);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(124);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})});var h=r(26);Object.keys(h).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return h[e]}})});var p=r(25);Object.keys(p).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return p[e]}})});var d=r(21);Object.keys(d).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return d[e]}})});var v=r(9);Object.keys(v).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return v[e]}})});var m=r(126);Object.keys(m).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return m[e]}})});var y=r(127);Object.keys(y).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return y[e]}})});var b=r(57);Object.keys(b).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return b[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Curve=t.Tw2CurveKey=void 0;var n=function(){function e(e,t){for(var r=0;rt.time?1:0}},{key:"Sort",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.keys;r&&r.length&&(r.sort(e.Compare),t.length=r[r.length-1].time)}},{key:"Sort2",value:function(t){if(t.keys&&t.keys.length){t.keys.sort(e.Compare);var r=t.keys[t.keys.length-1];if(r.time>t.length){var n=t.length,i=t.endValue,a=t.endTangent;t.length=r.time,t.endValue=r.value,t.endTangent=r.leftTangent,n>0&&(r.time=n,r.value=i,r.leftTangent=a)}}}}]),e}();o.inputDimension=null,o.outputDimension=null,o.valueProperty=null,o.curveType=null,o.Key=null,o.Interpolation=null,o.Extrapolation=null,o.Type={CURVE:1,CURVE2:2,CURVE_MAYA:3,CURVE_NO_KEYS:4,SEQUENCER:100,SEQUENCER2:101},o.global={vec3_0:i.vec3.create(),vec4_0:i.vec4.create(),quat_0:i.quat.create(),quat_1:i.quat.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r.d(t,"ARRAY_TYPE",function(){return i}),t.setMatrixArrayType=function(e){i=e},t.toRadian=function(e){return e*o},t.equals=function(e,t){return Math.abs(e-t)<=n*Math.max(1,Math.abs(e),Math.abs(t))};const n=1e-6;t.EPSILON=n;let i="undefined"!=typeof Float32Array?Float32Array:Array;const a=Math.random;t.RANDOM=a;const o=Math.PI/180},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VectorParameter=t.Tw2Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";a(this,e),this._id=i.util.generateID(),this.name=t,this._onModified=[]}return n(e,[{key:"OnValueChanged",value:function(e,t){for(var r=0;r=this.size&&(this.constantBuffer=e,this.offset=t,this.Apply(e,t,r),!0)}},{key:"Unbind",value:function(){this.constantBuffer=null}},{key:"Apply",value:function(e,t,r){e.set(this.value,t)}},{key:"EqualsValue",value:function(e){for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:{},t=this.constructor.Item;if(t&&"create"in t){var r=t.create(e);return this.AddItem(r),r}return null}},{key:"AddItem",value:function(e){this.items.includes(e)||(e._onModified=this._onChildModified,this.items.push(e),this.OnValueChanged())}},{key:"RemoveItem",value:function(e){var t=this.items.indexOf(e);-1!==t&&(e._onModified=null,this.items.splice(t,1),this.OnValueChanged())}},{key:"ClearItems",value:function(){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:null;if(null!==e)for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e){this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this),this._rebuildPending=!1}},{key:"GetBatches",value:function(e,t,r){}},{key:"Render",value:function(){}}],[{key:"RebuildItems",value:function(e){e._visibleItems=[];for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e,t){this.useSRT&&(i.quat.normalize(this.rotation,this.rotation),i.mat4.fromRotationTranslationScale(this.localTransform,this.rotation,this.translation,this.scaling)),i.mat4.copy(this.worldTransformLast,this.worldTransform),i.mat4.multiply(this.worldTransform,t,this.localTransform)}},{key:"GetBatches",value:function(e,t){}}]),e}()).global={mat4_0:i.mat4.create(),vec3_0:i.vec3.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveObject=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e){}},{key:"GetBatches",value:function(e,t){}}]),e}()).global={vec3_0:i.vec3.create(),vec3_1:i.vec3.create(),vec3_2:i.vec3.create(),vec3_3:i.vec3.create(),vec3_4:i.vec3.create(),vec3_5:i.vec3.create(),vec3_6:i.vec3.create(),vec3_7:i.vec3.create(),mat4_0:i.mat4.create(),mat4_1:i.mat4.create(),mat4_2:i.mat4.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2ParticleForce=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r.name=e,r.display=!0,r.visible={},r.visible.log=!0,r.visible.info=!0,r.visible.debug=!0,r.visible.warn=!0,r.visible.error=!0,r.maxLogs=100,r._logs=[],r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.Tw2EventEmitter),n(t,[{key:"log",value:function(e,r){if(r.logged)return r;if(r.log=t.Type[r.log?r.log.toUpperCase():"LOG"]||"log",!r.hide&&this.display&&this.visible[r.log]){var n=this.name+": {"+e+"}",i=r.msg||"";r.path&&(i+=" '"+r.path+"'","time"in r&&(i+=" in "+r.time.toFixed(3)+" secs")),(void 0!==r.value||r.type)&&(i+=" (",r.type&&(i+=r.type),r.type&&void 0!==r.value&&(i+=":"),void 0!==r.value&&(i+=r.value),i+=")"),"data"in r||"err"in r?(console.group(n),console[r.log](i),r.data&&console.debug(r.data),r.err&&console.debug(r.err.stack||r.err.toString()),console.groupEnd()):console[r.log](n,i)}return this.maxLogs?(this._logs.length>=this.maxLogs&&this._logs.splice(this.maxLogs,this._logs.length-1),this._logs.unshift(r)):this._logs=[],this.emit("log",r),r.logged=!0,r}},{key:"GetLogs",value:function(e){return Object.assign([],void 0===e?this._logs:this._logs.splice(0,e))}},{key:"Set",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,a.assignIfExists)(this,e,["name","maxLogs","display"]),(0,a.assignIfExists)(this.visible,e.visible,["log","info","debug","warn","error"])}}]),t}();o.Type={THROW:"error",ERROR:"error",WARNING:"warn",WARN:"warn",INFO:"info",LOG:"log",DEBUG:"debug"};var s=t.logger=new o("CCPWGL");i.Tw2EventEmitter.logger=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(29);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(67);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(33);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(34);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(73);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(74);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(75);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(76);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(77);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.store=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};"uuid"in e&&(0,i.enableUUID)(e.uuid),this.RegisterPaths(e.paths),this.RegisterDynamicPaths(e.dynamicPaths),this.RegisterTypes(e.types),this.RegisterConstructors(e.constructors),this.RegisterExtensions(e.extensions),this.RegisterVariables(e.variables),this.RegisterSchemas(e.schemas)}}],[{key:"GetStoreItem",value:function(e,t,r){var n=e["_"+t];if(n&&(0,i.isString)(r)){if(r in n)return n[r];e._missing[t]||(e._missing[t]=[]),e._missing[t].includes(r)||(e._missing[t].push(r),a.logger.log("store.warning",{log:"warning",msg:"Missing "+t+": '"+r+"'"}))}return null}},{key:"SetStoreItem",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=arguments[3],o=arguments[4];if(o&&!o(n))return a.logger.log("store.error",{log:"error",msg:"Invalid value "+t+": '"+r+"'"}),!1;var s=e["_"+t];if(s&&(0,i.isString)(r)&&!(0,i.isUndefined)(n)){var u=s[r];return s[r]=n,u?a.logger.log("store.registered",{log:"debug",msg:"Re-registered "+t+": '"+r+"'",data:{old_value:u,new_value:n}}):a.logger.log("store.registered",{log:"debug",msg:"Registered "+t+": '"+r+"'",hide:!0}),!0}return!1}},{key:"RegisterFromObject",value:function(e,t,r){if(r&&t in e){r=(0,i.toArray)(r);for(var n=0;nr.size?t.subarray(0,r.size):t,r.offset)}},{key:"Get",value:function(e){return this.elements[e].array}},{key:"GetData",value:function(e){return this.data.subarray(this.elements[e].offset,this.elements[e].offset+this.elements[e].array.length)}},{key:"Create",value:function(){for(var e in this.data=new Float32Array(this.nextOffset),this.elements)if(this.elements.hasOwnProperty(e)){var t=this.elements[e];if(t.array=this.data.subarray(t.offset,t.offset+t.size),null!==t.value){if(1===t.size)t.array[0]=t.value;else for(var r=0;r2&&void 0!==arguments[2]?arguments[2]:null;this.elements[e]={offset:this.nextOffset,size:t,array:null,value:r},this.nextOffset+=t}},{key:"DeclareFromObject",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in e)if(e.hasOwnProperty(t)){var r=e[t];if(a.util.isNumber(r))this.Declare(t,1,r);else{if(!a.util.isArrayLike(r))throw new Error("Invalid declaration type: "+(void 0===r?"undefined":n(r)));1===r.length&&this.Declare(t,r.length,r)}}this.Create()}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(120);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(122);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(38);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(8);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(52);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(123);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(40);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(39);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2ParticleEmitter=void 0;var n=function(){function e(e,t){for(var r=0;r1?0:i<-1?Math.PI:Math.acos(i)},t.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},t.equals=function(e,t){let r=e[0],i=e[1],a=e[2],o=t[0],s=t[1],u=t[2];return Math.abs(r-o)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-s)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(a-u)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(u))};var n=r(3);function i(){let e=new n.ARRAY_TYPE(3);return e[0]=0,e[1]=0,e[2]=0,e}function a(e){let t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function o(e,t,r){let i=new n.ARRAY_TYPE(3);return i[0]=e,i[1]=t,i[2]=r,i}function s(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function u(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function l(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function c(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(r*r+n*n+i*i)}function f(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return r*r+n*n+i*i}function h(e){let t=e[0],r=e[1],n=e[2];return t*t+r*r+n*n}function p(e,t){let r=t[0],n=t[1],i=t[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a),e}function d(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}const v=s;t.sub=v;const m=u;t.mul=m;const y=l;t.div=y;const b=c;t.dist=b;const g=f;t.sqrDist=g;const _=a;t.len=_;const E=h;t.sqrLen=E;const T=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=3),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s0&&(o=1/Math.sqrt(o),e[0]=r*o,e[1]=n*o,e[2]=i*o,e[3]=a*o),e}const d=a;t.sub=d;const v=o;t.mul=v;const m=s;t.div=m;const y=l;t.dist=y;const b=c;t.sqrDist=b;const g=f;t.len=g;const _=h;t.sqrLen=_;const E=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=4),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s1?r-1:0),i=1;i2?n-2:0),a=2;a1?r-1:0),i=1;i1&&(this.activeFrame+=1,this._purgeTime-=Math.floor(this._purgeTime),this._purgeFrame+=1,this._purgeFrame>=5&&this.autoPurgeResources&&this.motherLode.PurgeInactive(this._purgeFrame,this._purgeFrameLimit,this.purgeTime,i.logger)),!0}},{key:"GetResource",value:function(t){var r=void 0;if(t=e.NormalizePath(t),r=this.motherLode.Find(t))return r.IsPurged()&&r.Reload(),r;var n=e.GetPathExt(t);if(null===n)return i.logger.log("res.error",{log:"error",src:["Tw2ResMan","ReloadResource"],msg:"Undefined extension",type:"extension.undefined",path:t}),null;var o=a.store.GetExtension(n);return o?((r=new o).path=t,e.LoadResource(this,r)):(i.logger.log("res.error",{log:"error",src:["Tw2ResMan","ReloadResource"],msg:"Unregistered extension",type:"extension.unregistered",path:t,value:n}),null)}},{key:"GetObject",value:function(t,r){var n={};t=e.NormalizePath(t);var i=this.motherLode.Find(t);i?i.AddObject(n,r):((i=new s.Tw2LoadingObject).path=t,i.AddObject(n,r),e.LoadResource(this,i))}},{key:"ReloadResource",value:function(t){var r=t.path,n=this.motherLode.Find(r);return n&&!n.IsPurged()?n:(i.logger.log("res.event",{msg:"Reloading ",path:r,type:"reload"}),e.LoadResource(this,t))}}],[{key:"BuildUrl",value:function(e){var t=e.indexOf(":/");if(-1===t)return i.logger.log("res.error",{log:"warn",src:["Tw2ResMan","BuildUrl"],msg:"Invalid path",type:"prefix.undefined",path:e}),e;var r=e.substr(0,t),n=a.store.GetPath(r);return n?n+e.substr(t+2):(i.logger.log("res.error",{log:"warn",src:["Tw2ResMan","BuildUrl"],msg:"Unregistered path",path:e,type:"prefix.unregistered",value:r}),e)}},{key:"NormalizePath",value:function(e){return"str:/"===e.substr(0,5)?e:((e=e.toLowerCase()).replace("\\","/"),e)}},{key:"GetPathExt",value:function(e){if("str:/"===e.substr(0,5)){var t=e.indexOf("/",5);return-1===t?null:e.substr(5,t-5)}var r=e.lastIndexOf(".");return-1===r?null:e.substr(r+1)}},{key:"LogPathString",value:function(e){return"str:/"===e.substr(0,5)&&e.length>64?e.substr(0,64)+"...":e}},{key:"LoadResource",value:function(t,r){var n=r.path,a=e.BuildUrl(n);if(r._isPurged=!1,t.motherLode.Add(n,r),r.DoCustomLoad&&r.DoCustomLoad(a))return r;var o=e.CreateHttpRequest(r.requestResponseType);if(o){i.logger.log("res.event",{msg:"Requesting",path:n,type:"request"}),o.onreadystatechange=e.DoLoadResource(t,r),o.open("GET",a),r.LoadStarted();try{o.send(),t._pendingLoads++}catch(e){i.logger.log("res.error",{log:"error",src:["Tw2ResMan","LoadResource"],msg:"Error sending object HTTP request",path:n,type:"http.request",err:e})}}return r}},{key:"DoLoadResource",value:function(e,t){return function(){var r=0;try{r=this.readyState}catch(n){return i.logger.log("res.error",{log:"error",src:["Tw2ResMan","_DoLoadResource"],msg:"Communication error loading",path:t.path,type:"http.readystate",value:r}),t.LoadFinished(!1),void e._pendingLoads--}if(4===r){if(200===this.status){var n=null,a=null;try{n=this.responseText,a=this.responseXML}catch(e){n=this.response}t.LoadFinished(!0),e._prepareQueue.push([t,n,a])}else i.logger.log("res.error",{log:"error",src:["Tw2ResMan","_DoLoadResource"],msg:"Communication error loading",path:t.path,type:"http.status",value:this.status}),t.LoadFinished(!1),t.PrepareFinished(!1);e._pendingLoads--}}}},{key:"CreateHttpRequest",value:function(e){var t=null;if(window.XMLHttpRequest)t=new XMLHttpRequest;else if(window.ActiveXObject)try{t=new window.ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{t=new window.ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}return t?e&&(t.responseType=e):i.logger.log("res.error",{log:"error",src:["Tw2LoadingObject","Prepare"],msg:"Could not create an XMLHTTP instance",type:"http.instance"}),t}}]),e}();t.resMan=new u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2LoadingObject=void 0;var n=function(){function e(e,t){for(var r=0;r127&&(e=e-255-1),e}},{key:"ReadUInt16",value:function(){return this.data[this.cursor++]+(this.data[this.cursor++]<<8)}},{key:"ReadInt16",value:function(){var e=this.data[this.cursor++]+(this.data[this.cursor++]<<8);return e>32767&&(e=e-65535-1),e}},{key:"ReadUInt32",value:function(){return this.data[this.cursor++]+(this.data[this.cursor++]<<8)+(this.data[this.cursor++]<<16)+(this.data[this.cursor++]<<24>>>0)}},{key:"ReadInt32",value:function(){var e=this.data[this.cursor++]+(this.data[this.cursor++]<<8)+(this.data[this.cursor++]<<16)+(this.data[this.cursor++]<<24>>>0);return e>2147483647&&(e=e-4294967295-1),e}},{key:"ReadFloat16",value:function(){var e=this.data[this.cursor++],t=this.data[this.cursor++],r=(t>>2&31)-15,n=(3&t)<<8|e;return 0===n&&-15===r?0:(1-2*(t>>7))*(1+n*Math.pow(2,-10))*Math.pow(2,r)}},{key:"ReadFloat32",value:function(){var e=this.data[this.cursor++],t=this.data[this.cursor++],r=this.data[this.cursor++],n=this.data[this.cursor++],i=(n<<1&255|r>>7)-127,a=(127&r)<<16|t<<8|e;return 0===a&&-127===i?0:(1-2*(n>>7))*(1+a*Math.pow(2,-23))*Math.pow(2,i)}},{key:"ReadString",value:function(){for(var e=this.data[this.cursor++],t="",r=0;r0&&void 0!==arguments[0]?arguments[0]:[];for(var t in this.effectRes&&!e.includes(this.effectRes)&&e.push(this.effectRes),this.parameters)this.parameters.hasOwnProperty(t)&&"GetResources"in this.parameters[t]&&this.parameters[t].GetResources(e);return e}},{key:"RebuildCachedData",value:function(e){this.shader=e.GetShader(this.options),this.BindParameters()}},{key:"UnBindParameters",value:function(){for(var e in this.techniques)if(this.techniques.hasOwnProperty(e))for(var t=this.techniques[e],r=0;r=this.techniques[e].length)){this.shader.ApplyPass(e,t);for(var r=this.techniques[e][t],n=this.shader.techniques[e].passes[t],a=i.device,o=a.IsAlphaTestEnabled()&&n.shadowShaderProgram?n.shadowShaderProgram:n.shaderProgram,s=0;s<2;++s){for(var u=r.stages[s],l=0;l=this.techniques[e].length?null:i.device.IsAlphaTestEnabled()&&this.shader.techniques[e].passes[t].shadowShaderProgram?this.shader.techniques[e].passes[t].shadowShaderProgram.input:this.shader.techniques[e].passes[t].shaderProgram.input}},{key:"Render",value:function(e){for(var t=this.GetPassCount("Main"),r=0;r0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)if(this.parameters.hasOwnProperty(t)&&this.parameters[t]instanceof a.Tw2TextureParameter){var r=this.parameters[t].GetValue();r&&(e[t]=r)}return e}},{key:"SetTextures",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=e[r],i=this.parameters[r];a.Tw2TextureParameter.is(n)&&(i?i.EqualsValue(n)||(i.SetTexturePath(n),t=!0):(this.parameters[r]=new a.Tw2TextureParameter(r,n),t=!0))}return t}},{key:"GetParameters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)!this.parameters.hasOwnProperty(t)||this.parameters[t]instanceof a.Tw2TextureParameter||(e[t]=this.parameters[t].GetValue(!0));return e}},{key:"SetParameters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=e[r],a=this.parameters[r];if(a)a.constructor.is(n)&&!a.EqualsValue(n)&&(this.parameters[r].SetValue(n),t=!0);else{var o=i.store.CreateType(r,n);o&&(this.parameters[r]=o,t=!0)}}return t}},{key:"SetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=this.parameters[r];if(n&&n instanceof a.Tw2TextureParameter){var i=!1,o=e[r];for(var s in o)if(o.hasOwnProperty(s)&&a.Tw2TextureParameter.overrideProperties.includes(s)&&o[s]!==n[s]){i=!0;break}i&&(n.SetOverrides(e[r]),t=!0)}}return t}},{key:"GetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)if(this.parameters.hasOwnProperty(t)){var r=this.parameters[t];r&&r instanceof a.Tw2TextureParameter&&r.useAllOverrides&&(e[t]=this.parameters[t].GetOverrides())}return e}}],[{key:"ToEffectResPath",value:function(e){return(e=e?e.substr(0,e.lastIndexOf(".")).replace("/effect/",i.device.effectDir)+".sm_"+i.device.shaderModel:"").toLowerCase()}},{key:"FromEffectResPath",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"fx";return(e=e.substr(0,e.lastIndexOf(".")).replace(i.device.effectDir,"/effect/")+"."+t).toLowerCase()}},{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new this;if(i.util.assignIfExists(t,e,["name","effectFilePath","display","autoParameter"]),"parameters"in e&&t.SetParameters(e.parameters),"textures"in e&&t.SetTextures(e.textures),"overrides"in e&&t.SetOverrides(e.overrides),""===t.name&&""!==e.effectFilePath){var r=e.effectFilePath;t.name=r.substring(r.lastIndexOf("/")+1,r.length)}return t.Initialize(),t}}]),e}()).ConstantIgnore=["PerFrameVS","PerObjectVS","PerFramePS","PerObjectPS","PerObjectPSInt"]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TextureParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.resourcePath=r,n.useAllOverrides=!1,n.addressUMode=1,n.addressVMode=1,n.addressWMode=1,n.filterMode=2,n.mipFilterMode=2,n.maxAnisotropy=4,n.textureRes=null,n._sampler=null,r&&n.Initialize(),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,o.Tw2Parameter),n(t,[{key:"Initialize",value:function(){this.OnValueChanged()}},{key:"SetTexturePath",value:function(e){this.resourcePath=e,this.OnValueChanged()}},{key:"GetValue",value:function(){return this.isTextureAttached?null:this.resourcePath}},{key:"SetTextureRes",value:function(e){this.textureRes!==e&&(this.resourcePath="",this.textureRes=e),this.textureRes._isAttached=!0}},{key:"OnValueChanged",value:function(e,r){""!==this.resourcePath&&(this.resourcePath=this.resourcePath.toLowerCase(),this.textureRes=""!==this.resourcePath?i.resMan.GetResource(this.resourcePath):null),this.UpdateOverrides(),function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,r,n)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(n):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"OnValueChanged",this).call(this,e,r)}},{key:"Apply",value:function(e,t,r){this.textureRes&&(this.useAllOverrides&&(this._sampler.samplerType=t.samplerType,this._sampler.isVolume=t.isVolume,this._sampler.registerIndex=t.registerIndex,t=this._sampler),i.device.gl.activeTexture(i.device.gl.TEXTURE0+e),this.textureRes.Bind(t,r))}},{key:"SetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i.util.assignIfExists(this,e,t.overrideProperties),this.OnValueChanged()}},{key:"GetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.util.assignIfExists(e,this,t.overrideProperties),e}},{key:"UpdateOverrides",value:function(){if(this.useAllOverrides){this._sampler=this._sampler||new a.Tw2SamplerState;var e=this._sampler;if(1===this.filterMode){switch(this.mipFilterMode){case 0:e.minFilter=i.device.gl.NEAREST;break;case 1:e.minFilter=i.device.gl.NEAREST_MIPMAP_NEAREST;break;default:e.minFilter=i.device.gl.NEAREST_MIPMAP_LINEAR}e.minFilterNoMips=i.device.gl.NEAREST,e.magFilter=i.device.gl.NEAREST}else{switch(this.mipFilterMode){case 0:e.minFilter=i.device.gl.LINEAR;break;case 1:e.minFilter=i.device.gl.LINEAR_MIPMAP_NEAREST;break;default:e.minFilter=i.device.gl.LINEAR_MIPMAP_LINEAR}e.minFilterNoMips=i.device.gl.LINEAR,e.magFilter=i.device.gl.LINEAR}e.addressU=i.device.wrapModes[this.addressUMode],e.addressV=i.device.wrapModes[this.addressVMode],e.addressW=i.device.wrapModes[this.addressWMode],e.anisotropy=this.maxAnisotropy,e.ComputeHash()}else this._sampler&&(this._sampler=null)}},{key:"EqualsValue",value:function(e){return e.toLowerCase()===this.GetValue()}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.resourcePath=e.resourcePath,this.SetOverrides(e.GetOverrides)}},{key:"Clone",value:function(){var e=new t;return e.Copy(this,!0),e}},{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.textureRes&&!e.includes(this.textureRes)&&e.push(this.textureRes),e}},{key:"isTextureAttached",get:function(){return this.textureRes&&this.textureRes._isAttached}}],[{key:"isValue",value:function(e){return i.util.isString(e)}}]),t}();s.prototype.SetValue=s.prototype.SetTexturePath,s.overrideProperties=["useAllOverrides","addressUMode","addressVMode","addressWMode","filterMode","mipFilterMode","maxAnisotropy"]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SamplerState=void 0;var n=function(){function e(e,t){for(var r=0;r4&&void 0!==arguments[4]?arguments[4]:0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.usage=t,this.usageIndex=r,this.type=n,this.elements=i,this.offset=a,this.location=null,this.customSetter=null}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(96);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(97);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(98);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(99);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(100);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(101);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(102);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(42);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PerObjectData=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};e.VSData&&(this.perObjectVSData=new a.Tw2RawData(e.VSData)),e.PSData&&(this.perObjectPSData=new a.Tw2RawData(e.PSData))}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(105);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(106);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(107);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(108);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(109);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(110);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(111);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(112);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(113);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})});var h=r(114);Object.keys(h).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return h[e]}})});var p=r(115);Object.keys(p).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return p[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(41);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(116);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(49);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(50);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(117);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Mesh=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[];return e.includes(this.geometryResource)||e.push(this.geometryResource),i.util.perArrayChild(this.opaqueAreas,"GetResources",e),i.util.perArrayChild(this.transparentAreas,"GetResources",e),i.util.perArrayChild(this.additiveAreas,"GetResources",e),i.util.perArrayChild(this.pickableAreas,"GetResources",e),i.util.perArrayChild(this.decalAreas,"GetResources",e),i.util.perArrayChild(this.depthAreas,"GetResources",e),e}},{key:"GetBatches",value:function(e,t,r){if(!this.IsGood()||!this.display)return!1;var n=this.constructor.GetAreaBatches;switch(e){case i.device.RM_OPAQUE:return void(this.visible.opaqueAreas&&n(this,this.opaqueAreas,e,t,r));case i.device.RM_DECAL:return void(this.visible.decalAreas&&n(this,this.opaqueAreas,e,t,r));case i.device.RM_TRANSPARENT:return void(this.visible.transparentAreas&&n(this,this.transparentAreas,e,t,r));case i.device.RM_ADDITIVE:return void(this.visible.transparentAreas&&n(this,this.additiveAreas,e,t,r));case i.device.RM_PICKABLE:return void(this.visible.pickableAreas&&n(this,this.pickableAreas,e,t,r))}}}],[{key:"GetAreaBatches",value:function(e,t,r,n,i){for(var a=0;a=this.animationRes.duration}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TextureRes=void 0;var n=function(){function e(e,t){for(var r=0;r0?"."+t.mipLevelSkipCount.toString():"";if(t.mipLevelSkipCount>0){var n=e.lastIndexOf(".");n>=0&&(e=e.substr(0,n-2)+r+e.substr(n))}return e}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Bone=void 0;var n=r(0);t.Tw2Bone=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.boneRes=null,this.localTransform=n.mat4.create(),this.worldTransform=n.mat4.create(),this.offsetTransform=n.mat4.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2Model=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.modelRes=null,this.bones=[],this.bonesByName={}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2Track=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.trackRes=null,this.bone=null}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2TrackGroup=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.trackGroupRes=null,this.model=null,this.transformTracks=[]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2RenderTarget=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];if(this.mesh&&this.mesh.GetResources(e),!t)for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];return this.mesh&&this.mesh.GetResources(e),this.animation&&this.animation.GetResources(e),i.util.perArrayChild(this.spriteSets,"GetResources",e),i.util.perArrayChild(this.turretSets,"GetResources",e),i.util.perArrayChild(this.decals,"GetResources",e),i.util.perArrayChild(this.spotlightSets,"GetResources",e),i.util.perArrayChild(this.planeSets,"GetResources",e),i.util.perArrayChild(this.lineSets,"GetResources",e),i.util.perArrayChild(this.overlayEffects,"GetResources",e),i.util.perArrayChild(this.effectChildren,"GetResources",e),t||i.util.perArrayChild(this.children,"GetResources",e),e}},{key:"UpdateViewDependentData",value:function(){for(var e=0;e0?(t[0]=this.shapeEllipsoidCenter[0],t[1]=this.shapeEllipsoidCenter[1],t[2]=this.shapeEllipsoidCenter[2],r[0]=this.shapeEllipsoidRadius[0],r[1]=this.shapeEllipsoidRadius[1],r[2]=this.shapeEllipsoidRadius[2]):this.mesh&&this.mesh.IsGood()&&(i.vec3.subtract(t,this.mesh.geometryResource.maxBounds,this.mesh.geometryResource.minBounds),i.vec3.scale(t,t,.8660254035),i.vec3.add(r,this.mesh.geometryResource.maxBounds,this.mesh.geometryResource.minBounds),i.vec3.scale(r,r,.5));for(var n=0;n0){for(var t=0;t0&&this.mesh.GetBatches(e,t,this._perObjectData),this.lod>1){if(r.spriteSets)for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:null;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.batches=[],this._sortMethod=t}return n(e,[{key:"Commit",value:function(e){this.batches.push(e)}},{key:"Clear",value:function(){this.batches=[]}},{key:"Render",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Main";this._sortMethod&&this.batches.sort(this._sortMethod);for(var r=0;r0?(n=2*Math.sqrt(r+1),e[3]=.25*n,e[0]=(t[6]-t[9])/n,e[1]=(t[8]-t[2])/n,e[2]=(t[1]-t[4])/n):t[0]>t[5]&t[0]>t[10]?(n=2*Math.sqrt(1+t[0]-t[5]-t[10]),e[3]=(t[6]-t[9])/n,e[0]=.25*n,e[1]=(t[1]+t[4])/n,e[2]=(t[8]+t[2])/n):t[5]>t[10]?(n=2*Math.sqrt(1+t[5]-t[0]-t[10]),e[3]=(t[8]-t[2])/n,e[0]=(t[1]+t[4])/n,e[1]=.25*n,e[2]=(t[6]+t[9])/n):(n=2*Math.sqrt(1+t[10]-t[0]-t[5]),e[3]=(t[1]-t[4])/n,e[0]=(t[8]+t[2])/n,e[1]=(t[6]+t[9])/n,e[2]=.25*n);return e},t.fromRotationTranslationScale=function(e,t,r,n){let i=t[0],a=t[1],o=t[2],s=t[3],u=i+i,l=a+a,c=o+o,f=i*u,h=i*l,p=i*c,d=a*l,v=a*c,m=o*c,y=s*u,b=s*l,g=s*c,_=n[0],E=n[1],T=n[2];return e[0]=(1-(d+m))*_,e[1]=(h+g)*_,e[2]=(p-b)*_,e[3]=0,e[4]=(h-g)*E,e[5]=(1-(f+m))*E,e[6]=(v+y)*E,e[7]=0,e[8]=(p+b)*T,e[9]=(v-y)*T,e[10]=(1-(f+d))*T,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e},t.fromRotationTranslationScaleOrigin=function(e,t,r,n,i){let a=t[0],o=t[1],s=t[2],u=t[3],l=a+a,c=o+o,f=s+s,h=a*l,p=a*c,d=a*f,v=o*c,m=o*f,y=s*f,b=u*l,g=u*c,_=u*f,E=n[0],T=n[1],O=n[2],w=i[0],S=i[1],R=i[2];return e[0]=(1-(v+y))*E,e[1]=(p+_)*E,e[2]=(d-g)*E,e[3]=0,e[4]=(p-_)*T,e[5]=(1-(h+y))*T,e[6]=(m+b)*T,e[7]=0,e[8]=(d+g)*O,e[9]=(m-b)*O,e[10]=(1-(h+v))*O,e[11]=0,e[12]=r[0]+w-(e[0]*w+e[4]*S+e[8]*R),e[13]=r[1]+S-(e[1]*w+e[5]*S+e[9]*R),e[14]=r[2]+R-(e[2]*w+e[6]*S+e[10]*R),e[15]=1,e},t.fromQuat=function(e,t){let r=t[0],n=t[1],i=t[2],a=t[3],o=r+r,s=n+n,u=i+i,l=r*o,c=n*o,f=n*s,h=i*o,p=i*s,d=i*u,v=a*o,m=a*s,y=a*u;return e[0]=1-f-d,e[1]=c+y,e[2]=h-m,e[3]=0,e[4]=c-y,e[5]=1-l-d,e[6]=p+v,e[7]=0,e[8]=h+m,e[9]=p-v,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},t.frustum=function(e,t,r,n,i,a,o){let s=1/(r-t),u=1/(i-n),l=1/(a-o);return e[0]=2*a*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*u,e[6]=0,e[7]=0,e[8]=(r+t)*s,e[9]=(i+n)*u,e[10]=(o+a)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*l,e[15]=0,e},t.perspective=function(e,t,r,n,i){let a=1/Math.tan(t/2),o=1/(n-i);return e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(i+n)*o,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*i*n*o,e[15]=0,e},t.perspectiveFromFieldOfView=function(e,t,r,n){let i=Math.tan(t.upDegrees*Math.PI/180),a=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),s=Math.tan(t.rightDegrees*Math.PI/180),u=2/(o+s),l=2/(i+a);return e[0]=u,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-(o-s)*u*.5,e[9]=(i-a)*l*.5,e[10]=n/(r-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*r/(r-n),e[15]=0,e},t.ortho=function(e,t,r,n,i,a,o){let s=1/(t-r),u=1/(n-i),l=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*s,e[13]=(i+n)*u,e[14]=(o+a)*l,e[15]=1,e},t.lookAt=function(e,t,r,i){let a,o,s,u,l,c,f,h,p,d,v=t[0],m=t[1],y=t[2],b=i[0],g=i[1],_=i[2],E=r[0],T=r[1],O=r[2];if(Math.abs(v-E)0&&(p=1/Math.sqrt(p),c*=p,f*=p,h*=p);let d=u*h-l*f,v=l*c-s*h,m=s*f-u*c;return e[0]=d,e[1]=v,e[2]=m,e[3]=0,e[4]=f*m-h*v,e[5]=h*d-c*m,e[6]=c*v-f*d,e[7]=0,e[8]=c,e[9]=f,e[10]=h,e[11]=0,e[12]=i,e[13]=a,e[14]=o,e[15]=1,e},t.str=function(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},t.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2)+Math.pow(e[9],2)+Math.pow(e[10],2)+Math.pow(e[11],2)+Math.pow(e[12],2)+Math.pow(e[13],2)+Math.pow(e[14],2)+Math.pow(e[15],2))},t.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e},t.subtract=a,t.multiplyScalar=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e},t.multiplyScalarAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e[9]=t[9]+r[9]*n,e[10]=t[10]+r[10]*n,e[11]=t[11]+r[11]*n,e[12]=t[12]+r[12]*n,e[13]=t[13]+r[13]*n,e[14]=t[14]+r[14]*n,e[15]=t[15]+r[15]*n,e},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},t.equals=function(e,t){let r=e[0],i=e[1],a=e[2],o=e[3],s=e[4],u=e[5],l=e[6],c=e[7],f=e[8],h=e[9],p=e[10],d=e[11],v=e[12],m=e[13],y=e[14],b=e[15],g=t[0],_=t[1],E=t[2],T=t[3],O=t[4],w=t[5],S=t[6],R=t[7],P=t[8],A=t[9],M=t[10],j=t[11],D=t[12],C=t[13],I=t[14],k=t[15];return Math.abs(r-g)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(g))&&Math.abs(i-_)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(_))&&Math.abs(a-E)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(E))&&Math.abs(o-T)<=n.EPSILON*Math.max(1,Math.abs(o),Math.abs(T))&&Math.abs(s-O)<=n.EPSILON*Math.max(1,Math.abs(s),Math.abs(O))&&Math.abs(u-w)<=n.EPSILON*Math.max(1,Math.abs(u),Math.abs(w))&&Math.abs(l-S)<=n.EPSILON*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(c-R)<=n.EPSILON*Math.max(1,Math.abs(c),Math.abs(R))&&Math.abs(f-P)<=n.EPSILON*Math.max(1,Math.abs(f),Math.abs(P))&&Math.abs(h-A)<=n.EPSILON*Math.max(1,Math.abs(h),Math.abs(A))&&Math.abs(p-M)<=n.EPSILON*Math.max(1,Math.abs(p),Math.abs(M))&&Math.abs(d-j)<=n.EPSILON*Math.max(1,Math.abs(d),Math.abs(j))&&Math.abs(v-D)<=n.EPSILON*Math.max(1,Math.abs(v),Math.abs(D))&&Math.abs(m-C)<=n.EPSILON*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(y-I)<=n.EPSILON*Math.max(1,Math.abs(y),Math.abs(I))&&Math.abs(b-k)<=n.EPSILON*Math.max(1,Math.abs(b),Math.abs(k))};var n=r(3);function i(e,t,r){let n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],l=t[6],c=t[7],f=t[8],h=t[9],p=t[10],d=t[11],v=t[12],m=t[13],y=t[14],b=t[15],g=r[0],_=r[1],E=r[2],T=r[3];return e[0]=g*n+_*s+E*f+T*v,e[1]=g*i+_*u+E*h+T*m,e[2]=g*a+_*l+E*p+T*y,e[3]=g*o+_*c+E*d+T*b,g=r[4],_=r[5],E=r[6],T=r[7],e[4]=g*n+_*s+E*f+T*v,e[5]=g*i+_*u+E*h+T*m,e[6]=g*a+_*l+E*p+T*y,e[7]=g*o+_*c+E*d+T*b,g=r[8],_=r[9],E=r[10],T=r[11],e[8]=g*n+_*s+E*f+T*v,e[9]=g*i+_*u+E*h+T*m,e[10]=g*a+_*l+E*p+T*y,e[11]=g*o+_*c+E*d+T*b,g=r[12],_=r[13],E=r[14],T=r[15],e[12]=g*n+_*s+E*f+T*v,e[13]=g*i+_*u+E*h+T*m,e[14]=g*a+_*l+E*p+T*y,e[15]=g*o+_*c+E*d+T*b,e}function a(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}const o=i;t.mul=o;const s=a;t.sub=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=s,t.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},t.setAxisAngle=u,t.getAxisAngle=function(e,t){let r=2*Math.acos(t[3]),n=Math.sin(r/2);0!=n?(e[0]=t[0]/n,e[1]=t[1]/n,e[2]=t[2]/n):(e[0]=1,e[1]=0,e[2]=0);return r},t.multiply=l,t.rotateX=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u+o*s,e[1]=i*u+a*s,e[2]=a*u-i*s,e[3]=o*u-n*s,e},t.rotateY=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u-a*s,e[1]=i*u+o*s,e[2]=a*u+n*s,e[3]=o*u-i*s,e},t.rotateZ=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u+i*s,e[1]=i*u-n*s,e[2]=a*u+o*s,e[3]=o*u-a*s,e},t.calculateW=function(e,t){let r=t[0],n=t[1],i=t[2];return e[0]=r,e[1]=n,e[2]=i,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),e},t.slerp=c,t.invert=function(e,t){let r=t[0],n=t[1],i=t[2],a=t[3],o=r*r+n*n+i*i+a*a,s=o?1/o:0;return e[0]=-r*s,e[1]=-n*s,e[2]=-i*s,e[3]=a*s,e},t.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},t.fromMat3=f,t.fromEuler=function(e,t,r,n){let i=.5*Math.PI/180;t*=i,r*=i,n*=i;let a=Math.sin(t),o=Math.cos(t),s=Math.sin(r),u=Math.cos(r),l=Math.sin(n),c=Math.cos(n);return e[0]=a*u*c-o*s*l,e[1]=o*s*c+a*u*l,e[2]=o*u*l-a*s*c,e[3]=o*u*c+a*s*l,e},t.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"};var n=r(3),i=r(30),a=r(31),o=r(32);function s(){let e=new n.ARRAY_TYPE(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function u(e,t,r){r*=.5;let n=Math.sin(r);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r),e}function l(e,t,r){let n=t[0],i=t[1],a=t[2],o=t[3],s=r[0],u=r[1],l=r[2],c=r[3];return e[0]=n*c+o*s+i*l-a*u,e[1]=i*c+o*u+a*s-n*l,e[2]=a*c+o*l+n*u-i*s,e[3]=o*c-n*s-i*u-a*l,e}function c(e,t,r,n){let i,a,o,s,u,l=t[0],c=t[1],f=t[2],h=t[3],p=r[0],d=r[1],v=r[2],m=r[3];return(a=l*p+c*d+f*v+h*m)<0&&(a=-a,p=-p,d=-d,v=-v,m=-m),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,u=Math.sin(n*i)/o):(s=1-n,u=n),e[0]=s*l+u*p,e[1]=s*c+u*d,e[2]=s*f+u*v,e[3]=s*h+u*m,e}function f(e,t){let r,n=t[0]+t[4]+t[8];if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{let n=0;t[4]>t[0]&&(n=1),t[8]>t[3*n+n]&&(n=2);let i=(n+1)%3,a=(n+2)%3;r=Math.sqrt(t[3*n+n]-t[3*i+i]-t[3*a+a]+1),e[n]=.5*r,r=.5/r,e[3]=(t[3*i+a]-t[3*a+i])*r,e[i]=(t[3*i+n]+t[3*n+i])*r,e[a]=(t[3*a+n]+t[3*n+a])*r}return e}const h=o.clone;t.clone=h;const p=o.fromValues;t.fromValues=p;const d=o.copy;t.copy=d;const v=o.set;t.set=v;const m=o.add;t.add=m;const y=l;t.mul=y;const b=o.scale;t.scale=b;const g=o.dot;t.dot=g;const _=o.lerp;t.lerp=_;const E=o.length;t.length=E;const T=E;t.len=T;const O=o.squaredLength;t.squaredLength=O;const w=O;t.sqrLen=w;const S=o.normalize;t.normalize=S;const R=o.exactEquals;t.exactEquals=R;const P=o.equals;t.equals=P;const A=function(){let e=a.create(),t=a.fromValues(1,0,0),r=a.fromValues(0,1,0);return function(n,i,o){let s=a.dot(i,o);return s<-.999999?(a.cross(e,t,i),a.len(e)<1e-6&&a.cross(e,r,i),a.normalize(e,e),u(n,e,Math.PI),n):s>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(a.cross(e,i,o),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+s,S(n,n))}}();t.rotationTo=A;const M=function(){let e=s(),t=s();return function(r,n,i,a,o,s){return c(e,n,o,s),c(t,i,a,s),c(r,e,t,2*s*(1-s)),r}}();t.sqlerp=M;const j=function(){let e=i.create();return function(t,r,n,i){return e[0]=n[0],e[3]=n[1],e[6]=n[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-r[0],e[5]=-r[1],e[8]=-r[2],S(t,f(t,e))}}();t.setAxes=j},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=i,t.clone=function(e){let t=new n.ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t},t.fromValues=function(e,t){let r=new n.ARRAY_TYPE(2);return r[0]=e,r[1]=t,r},t.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},t.set=function(e,t,r){return e[0]=t,e[1]=r,e},t.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e},t.subtract=a,t.multiply=o,t.divide=s,t.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},t.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},t.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e},t.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e},t.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},t.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e},t.scaleAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e},t.distance=u,t.squaredDistance=l,t.length=c,t.squaredLength=f,t.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},t.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},t.normalize=function(e,t){var r=t[0],n=t[1],i=r*r+n*n;i>0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i);return e},t.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},t.cross=function(e,t,r){var n=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=n,e},t.lerp=function(e,t,r,n){var i=t[0],a=t[1];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e},t.random=function(e,t){t=t||1;var r=2*n.RANDOM()*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e},t.transformMat2=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e},t.transformMat2d=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i+r[4],e[1]=r[1]*n+r[3]*i+r[5],e},t.transformMat3=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[3]*i+r[6],e[1]=r[1]*n+r[4]*i+r[7],e},t.transformMat4=function(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[4]*i+r[12],e[1]=r[1]*n+r[5]*i+r[13],e},t.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]},t.equals=function(e,t){let r=e[0],i=e[1],a=t[0],o=t[1];return Math.abs(r-a)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-o)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))};var n=r(3);function i(){let e=new n.ARRAY_TYPE(2);return e[0]=0,e[1]=0,e}function a(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function o(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function s(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function u(e,t){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function l(e,t){var r=t[0]-e[0],n=t[1]-e[1];return r*r+n*n}function c(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function f(e){var t=e[0],r=e[1];return t*t+r*r}const h=c;t.len=h;const p=a;t.sub=p;const d=o;t.mul=d;const v=s;t.div=v;const m=u;t.dist=m;const y=l;t.sqrDist=y;const b=f;t.sqrLen=b;const g=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=2),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s1.0001||r<.99999)e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=0;else if(r=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])){var i=Math.atan2(r,t[3])/r;e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=0}else e[0]=0,e[1]=0,e[2]=0,e[3]=0;return e},n.quat.pow=function(e,t,r){return 1===r?n.quat.copy(e,t):(n.quat.ln(e,t),e[0]*=r,e[1]*=r,e[2]*=r,e[3]*=r,n.quat.exp(e,e),e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mat3=void 0;var n=r(7);t.mat3=n.mat3},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mat4=void 0;var n=r(7);t.mat4=n.mat4,n.mat4.arcFromForward=function(){var e=void 0;return function(t,r){e||(e=n.vec3.create());var i=n.vec3.normalize(e,r);if(n.mat4.identity(t),i[2]<-.99999)return t;if(i[2]>.99999)return t[5]=-1,t[10]=-1,t;var a=(1+i[2])/(i[0]*i[0]+i[1]*i[1]);return t[0]=a*i[1]*i[1]-i[2],t[1]=-a*i[0]*i[1],t[2]=i[0],t[4]=t[1],t[5]=a*i[0]*i[0]-i[2],t[6]=i[1],t[8]=-i[0],t[9]=-i[1],t[10]=-i[2],t}}(),n.mat4.copyTranslation=function(e,t){return e[12]=t[12],e[13]=t[13],e[14]=t[14],e},n.mat4.fromMat3=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[4]=t[3],e[5]=t[4],e[6]=t[5],e[8]=t[6],e[9]=t[7],e[10]=t[8],e[3]=e[7]=e[11]=e[12]=e[13]=e[14]=0,e[15]=1,e},n.mat4.lookAtGL=function(){var e=void 0,t=void 0,r=void 0;return function(i,a,o,s){return e||(e=n.vec3.create(),t=n.vec3.create(),r=n.vec3.create()),n.vec3.subtract(r,a,o),0===n.vec3.squaredLength(r)&&(r[2]=1),n.vec3.normalize(r,r),n.vec3.cross(e,s,r),0===n.vec3.squaredLength(e)&&(r[2]+=1e-4,n.vec3.cross(e,s,r)),n.vec3.normalize(e,e),n.vec3.cross(t,r,e),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[4]=t[0],i[5]=t[1],i[6]=t[2],i[8]=r[0],i[9]=r[1],i[10]=r[2],i}}(),n.mat4.perspectiveGL=function(e,t,r,i,a){var o=Math.tan(t/360*Math.PI)*i,s=o*r;return n.mat4.frustum(e,-s,s,-o,o,i,a),e},n.mat4.setTranslation=function(e,t){return e[12]=t[0],e[13]=t[1],e[14]=t[2],e},n.mat4.setTranslationFromValues=function(e,t,r,n){return e[12]=t,e[13]=r,e[14]=n,e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.noise=void 0;var n=r(33),i=r(34),a=t.noise={};a.turbulence=function(){var e=[],t=[],r=[],a=!1;return function(o,s,u,l,c,f){a||function(){for(var o=0;o<256;o++)e[o]=i.vec4.fromValues(Math.random()-.5,Math.random()-.5,Math.random()-.5,Math.random()-.5),t[o]=o;for(var s=256;--s;){var u=t[s],l=Math.floor(256*Math.random());t[s]=t[l],t[l]=u}for(var c=0;c<256;c++)t[256+c]=t[c],e[256+c]=e[c],e[512+c]=e[c];for(var f=0;f<15;++f)r[f]=n.vec3.create();a=!0}(),s+=4096,u+=4096,l+=4096,c+=4096;var h=Math.floor(s),p=Math.floor(u),d=Math.floor(l),v=Math.floor(c),m=s-h,y=u-p,b=l-d,g=c-v,_=(h&=255)+1,E=(p&=255)+1,T=(d&=255)+1,O=(v&=255)+1,w=t[h],S=t[_],R=t[w+p],P=t[S+p],A=t[w+E],M=t[S+E],j=n.vec3.lerp(r[0],e[R+d+v],e[P+d+v],m),D=n.vec3.lerp(r[1],e[A+d+v],e[M+d+v],m),C=n.vec3.lerp(r[2],e[R+T+v],e[P+T+v],m),I=n.vec3.lerp(r[3],e[R+T+v],e[P+T+v],m),k=n.vec3.lerp(r[4],j,D,y),x=n.vec3.lerp(r[5],C,I,y),L=n.vec3.lerp(r[6],k,x,b);j=n.vec3.lerp(r[7],e[R+d+O],e[P+d+O],m),D=n.vec3.lerp(r[8],e[A+d+O],e[M+d+O],m),C=n.vec3.lerp(r[9],e[R+T+O],e[P+T+O],m),I=n.vec3.lerp(r[10],e[R+T+O],e[P+T+O],m),k=n.vec3.lerp(r[11],j,D,y),x=n.vec3.lerp(r[12],C,I,y);var B=n.vec3.lerp(r[13],k,x,b),F=n.vec3.lerp(r[14],L,B,g);return o[0]+=F[0]*f,o[1]+=F[1]*f,o[2]+=F[2]*f,o}}(),a.perlin1=function(){var e=!1,t=256,r=null,n=null;return function(i){e||function(){r=new Array(t+t+2),n=new Array(t+t+2);var i=0,a=0,o=0;for(i=0;it){o=u;break}if(0===e.degree)for(var l=0;l0&&(s=(t-e.knots[e.knots.length-1])/f);for(var h=0;h_&&(_+=i,E+=i,t+=i),g>_&&(_+=i,E+=i,t+=i),E<_&&(E+=i);var T=t-g,O=T/(_-g),w=(t-b)/(_-b),S=w+O-O*w,R=O*(T/(E-g)),P=S-R;S=1-S;for(var A=0;A=0;)n=r*n+e[t];return n},n.ag_zeroin2=function(e,t,r,i,a,o){var s=void 0,u=void 0,l=void 0,c=void 0,f=void 0,h=void 0,p=void 0,d=void 0,v=void 0,m=void 0;for(var y=!0;y&&(s=e,c=r,l=u=t-e),Math.abs(c)f&&0!==i;)Math.abs(l)0?d=-d:p=-p,m=l,l=u,2*p<3*h*d-Math.abs(f*d)&&pf?t+=u:h>0?t+=f:t-=f,(i=n.ag_horner1(o.p,o.deg,t))*(c/Math.abs(c))>0&&(y=!0);return t},n.ag_zeroin=function(e,t,r,i){var a,o;return a=n.ag_horner1(i.p,i.deg,e),Math.abs(a)<1.192092896e-7?e:(o=n.ag_horner1(i.p,i.deg,t),Math.abs(o)<1.192092896e-7?t:n.ag_zeroin2(e,t,a,o,r,i))},n.polyZeroes=function(e,t,r,i,a,o,s){var u,l,c=void 0,f=void 0,h=void 0,p=void 0,d=void 0,v=void 0,m=void 0,y=void 0,b=void 0,g=void 0,_=void 0,E=void 0,T=new Array(22),O=void 0,w=new Array(22),S=new Array(22),R={p:[],deg:0};for(m=g=0,y=0,c=0;cs[0]-u:a>s[0]+u,(p=f&&h?1:0)&&(i&&s[0]a&&(s[0]=a)),p;for(R.p=E,R.deg=t,c=1;c<=t;c++)O[c-1]=c*E[c];if(0===(d=n.polyZeroes(O,t-1,r,0,a,0,l)).length)return 0;for(c=v=0;c<=d;c++){if(p>t)return p;0===c?(b=r,_=n.ag_horner1(E,t,b),Math.abs(_)<=u&&i&&(s[p++]=r)):(b=m,_=g),c===d?(m=a,v=0):m=l[c],g=n.ag_horner1(E,t,m),v?v=0:Math.abs(g)0||_>0&&g<0)&&(s[p++]=n.ag_zeroin(b,m,0,R),p>1&&s[p-2]>=s[p-1]-u&&(s[p-2]=.5*(s[p-2]+s[p-1]),p--))}return p}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(79);Object.defineProperty(t,"device",{enumerable:!0,get:function(){return n.device}});var i=r(37);Object.defineProperty(t,"resMan",{enumerable:!0,get:function(){return i.resMan}});var a=r(19);Object.defineProperty(t,"store",{enumerable:!0,get:function(){return a.store}});var o=r(17);Object.defineProperty(t,"logger",{enumerable:!0,get:function(){return o.logger}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.device=t.Tw2Device=void 0;var n=function(){function e(e,t){for(var r=0;r1,this.canvas=t,this.Resize();return this._quadBuffer=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,this._quadBuffer),n.bufferData(n.ARRAY_BUFFER,new Float32Array([1,1,0,1,1,1,-1,1,0,1,0,1,1,-1,0,1,1,0,-1,-1,0,1,0,0]),n.STATIC_DRAW),this._cameraQuadBuffer=n.createBuffer(),this._quadDecl=new l.Tw2VertexDeclaration,this._quadDecl.elements.push(new l.Tw2VertexElement(l.Tw2VertexDeclaration.Type.POSITION,0,n.FLOAT,4,0)),this._quadDecl.elements.push(new l.Tw2VertexElement(l.Tw2VertexDeclaration.Type.TEXCOORD,0,n.FLOAT,2,16)),this._quadDecl.RebuildHash(),this._alphaTestState={},this._alphaTestState.states={},this._alphaTestState.states[this.RS_ALPHATESTENABLE]=0,this._alphaTestState.states[this.RS_ALPHAREF]=-1,this._alphaTestState.states[this.RS_ALPHAFUNC]=this.CMP_GREATER,this._alphaTestState.states[this.RS_CLIPPING]=0,this._alphaTestState.states[this.RS_CLIPPLANEENABLE]=0,this._alphaTestState.dirty=!1,this._alphaBlendState={},this._alphaBlendState.states={},this._alphaBlendState.states[this.RS_SRCBLEND]=this.BLEND_SRCALPHA,this._alphaBlendState.states[this.RS_DESTBLEND]=this.BLEND_INVSRCALPHA,this._alphaBlendState.states[this.RS_BLENDOP]=this.BLENDOP_ADD,this._alphaBlendState.states[this.RS_SEPARATEALPHABLENDENABLE]=0,this._alphaBlendState.states[this.RS_BLENDOPALPHA]=this.BLENDOP_ADD,this._alphaBlendState.states[this.RS_SRCBLENDALPHA]=this.BLEND_SRCALPHA,this._alphaBlendState.states[this.RS_DESTBLENDALPHA]=this.BLEND_INVSRCALPHA,this._alphaBlendState.dirty=!1,this._depthOffsetState={},this._depthOffsetState.states={},this._depthOffsetState.states[this.RS_SLOPESCALEDEPTHBIAS]=0,this._depthOffsetState.states[this.RS_DEPTHBIAS]=0,this._depthOffsetState.dirty=!1,this.wrapModes=[],this.wrapModes[0]=0,this.wrapModes[1]=n.REPEAT,this.wrapModes[2]=n.MIRRORED_REPEAT,this.wrapModes[3]=n.CLAMP_TO_EDGE,this.wrapModes[4]=n.CLAMP_TO_EDGE,this.wrapModes[5]=n.CLAMP_TO_EDGE,this._shadowStateBuffer=new Float32Array(24),this._blendTable=[-1,n.ZERO,n.ONE,n.SRC_COLOR,n.ONE_MINUS_SRC_COLOR,n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.DST_ALPHA,n.ONE_MINUS_DST_ALPHA,n.DST_COLOR,n.ONE_MINUS_DST_COLOR,n.SRC_ALPHA_SATURATE,-1,-1,n.CONSTANT_COLOR,n.ONE_MINUS_CONSTANT_COLOR],this.glVersion}},{key:"Schedule",value:function(e){this._scheduled.includes(e)||this._scheduled.push(e)}},{key:"OnResize",value:function(e){this._onResize=e}},{key:"Resize",value:function(){if(this.vrDisplay&&this.vrDisplay.isPresenting){var e=this.vrDisplay.getEyeParameters("left"),t=this.vrDisplay.getEyeParameters("right");this.canvas.width=2*Math.max(e.renderWidth,t.renderWidth),this.canvas.height=Math.max(t.renderHeight,t.renderHeight)}else this.canvas.width=this.canvas.offsetWidth*this.viewportPixelRatio,this.canvas.height=this.canvas.offsetHeight*this.viewportPixelRatio;this.viewportWidth=this.canvas.clientWidth,this.viewportHeight=this.canvas.clientHeight,this.viewportAspect=this.viewportWidth/this.viewportHeight,this._onResize&&this._onResize(this.viewportWidth,this.viewportHeight),a.store.SetVariableValue("ViewportSize",[this.viewportWidth,this.viewportHeight,this.viewportWidth,this.viewportHeight])}},{key:"Tick",value:function(){this.canvas.clientWidth===this.viewportWidth&&this.canvas.clientHeight===this.viewportHeight||this.Resize();var e=null===this.previousTime?0:this.previousTime,t=this.Now();this.currentTime=.001*(t-this.startTime),this.dt=null===this.previousTime?0:.001*(t-this.previousTime),this.previousTime=t,a.store.SetVariableValue("Time",[this.currentTime,this.currentTime-Math.floor(this.currentTime),this.frameCounter,e]),s.resMan.PrepareLoop(this.dt);for(var r=0;r1.6&&(r=t/1.6);var n=2*Math.atan(r/this.projection[5]);return e[0]=this.viewportWidth,e[1]=this.viewportHeight,e[2]=n,e[3]=n*t,e}},{key:"GetEyePosition",value:function(e){return i.vec3.copy(e,this.eyePosition)}},{key:"IsAlphaTestEnabled",value:function(){return this._alphaTestState.states[this.RS_ALPHATESTENABLE]}},{key:"IsFrameBufferComplete",value:function(e){return this.gl.checkFramebufferStatus(e)===this.gl.FRAMEBUFFER_COMPLETE}},{key:"GetExtension",value:function(t){for(var r in e.WebglVendorPrefixes)if(e.WebglVendorPrefixes.hasOwnProperty(r)){var n=this.gl.getExtension(e.WebglVendorPrefixes[r]+t);if(n)return n}return null}},{key:"GetFallbackTexture",value:function(){return this._fallbackTexture||(this._fallbackTexture=this.CreateSolidTexture()),this._fallbackTexture}},{key:"GetFallbackCubeMap",value:function(){return this._fallbackCube||(this._fallbackCube=this.CreateSolidCube()),this._fallbackCube}},{key:"CreateSolidTexture",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],t=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,1,1,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(e)),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.bindTexture(this.gl.TEXTURE_2D,null),t}},{key:"CreateSolidCube",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],t=this.gl.createTexture();this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP,t);for(var r=0;r<6;++r)this.gl.texImage2D(this.gl.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,this.gl.RGBA,1,1,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(e));return this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP,null),t}},{key:"RenderFullScreenQuad",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Main";if(!e||!e.IsGood())return!1;this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._quadBuffer);for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:"Main";if(!e||!e.IsGood())return!1;for(var r=new Float32Array([1,1,0,1,1,1,-1,1,0,1,0,1,1,-1,0,1,1,0,-1,-1,0,1,0,0]),n=this.projectionInverse,a=0;a<4;++a){var o=r.subarray(6*a,6*a+4);i.vec4.transformMat4(o,o,n),i.vec3.scale(o,o,1/o[3]),o[3]=1}this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._cameraQuadBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,r,this.gl.STATIC_DRAW);for(var s=0;s>16,r=(4278190080&e)>>24,n=(r<<1&255|t>>7)-127,i=(127&t)<<16|(65280&e)>>8<<8|255&e;return 0===i&&-127===n?0:(1-2*(r>>7))*(1+i*Math.pow(2,-23))*Math.pow(2,n)}},{key:"CreateContext",value:function(e,t,r){r=Array.isArray(r)?r:[r];for(var n=0;n>8&255]+a[e>>16&255]+a[e>>24&255]+"-"+a[255&t]+a[t>>8&255]+"-"+a[t>>16&15|64]+a[t>>24&255]+"-"+a[63&r|128]+a[r>>8&255]+"-"+a[r>>16&255]+a[r>>24&255]+a[255&n]+a[n>>8&255]+a[n>>16&255]+a[n>>24&255]}():i++};var n=null,i=0,a=null},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getURL=function(){return Object.assign({},n)},t.getURLString=function(e,t){return(e=e.toLowerCase())in n?n[e]:t},t.getURLInteger=function(e,t){return(e=e.toLowerCase())in n?parseInt(n[e],10):t},t.getURLFloat=function(e,t){return(e=e.toLowerCase())in n?parseFloat(n[e]):t},t.getURLBoolean=function(e,t){return(e=e.toLowerCase())in n?n[e]:t};for(var n={},i=window.location.search.substring(1).split("&"),a=0;a1&&void 0!==arguments[1]?arguments[1]:{};if(i.has(this)){var r=i.get(this);e=e.toLowerCase(),t.log&&!t.log.logged&&(t.log=this.log(e,t.log)),e in r?r[e].forEach(function(n,i){i.call(n.context,t),n.once&&r[e].delete(i)}):(r[e]=new Set,this.emit("event_added",{eventName:e}))}return this}},{key:"on",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i.has(this)||i.set(this,{});var o=i.get(this);return o[e=e.toLowerCase()]||(o[e]=new Set,o[e].add(function(){return r.emit("event_added",{eventName:e})},{once:!0})),o[e].add(t,{context:n,once:a}),this}},{key:"once",value:function(e,t,r){return this.on(e,t,r,!0)}},{key:"off",value:function(e,t){if(i.has(this)){var r=i.get(this);(e=e.toLowerCase())in r&&r[e].delete(t)}return this}},{key:"del",value:function(e){if(i.has(this)){var t=i.get(this);(e=e.toLowerCase())in t&&(this.emit("event_removed",{eventName:e}),delete t[e])}return this}},{key:"clr",value:function(e){if(i.has(this)){var t=i.get(this);for(var r in t)t.hasOwnProperty(r)&&t[r].has(e)&&t[r].delete(e)}return this}},{key:"kill",value:function(){return i.has(this)&&(this.emit("event_kill"),i.set(this,{})),this}},{key:"log",value:function(e,t){return this.constructor.logger&&this.constructor.logger.log(e,t),t}}],[{key:"assign",value:function(t){Object.assign(t.prototype,e.prototype)}}]),e}()).logger=null},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Error=void 0;var n=r(16);function i(e){function t(){var t=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(t,Object.getPrototypeOf(this)),t}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}var a=(0,n.isFunction)(Error.captureStackTrace);(t.Tw2Error=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Undefined error";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var i=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return(0,n.isString)(e)?e={message:e}:e.message=e.message||r,i.message=e.message,i.name=i.constructor.name,i.data=e,a?Error.captureStackTrace(i,t):i.stack=new Error(e.message).stack,i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i(Error)),t}()).isError=!0},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r=r&&a.Unload()&&(n.log("res.event",{msg:"Unloaded ",path:a.path,type:"unused"}),delete this._loadedObjects[i]))}}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SamplerOverride=void 0;var n=r(0),i=r(43);t.Tw2SamplerOverride=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="",this.addressU=0,this.addressV=0,this.addressW=0,this.filter=0,this.mipFilter=0,this.lodBias=0,this.maxMipLevel=0,this.maxAnisotropy=0;var t=null;this.GetSampler=function(e){if(!t){if((t=new i.Tw2SamplerState).registerIndex=e.registerIndex,t.name=e.name,1===this.filter){switch(this.mipFilter){case 0:t.minFilter=n.device.gl.NEAREST;break;case 1:t.minFilter=n.device.gl.NEAREST_MIPMAP_NEAREST;break;default:t.minFilter=n.device.gl.NEAREST_MIPMAP_LINEAR}t.minFilterNoMips=n.device.gl.NEAREST}else{switch(this.mipFilter){case 0:t.minFilter=n.device.gl.LINEAR;break;case 1:t.minFilter=n.device.gl.LINEAR_MIPMAP_NEAREST;break;default:t.minFilter=n.device.gl.LINEAR_MIPMAP_LINEAR}t.minFilterNoMips=n.device.gl.LINEAR}3!==this.filter&&3!==this.mipFilter||(t.anisotropy=Math.max(this.maxAnisotropy,1)),t.magFilter=1===this.filter?n.device.gl.NEAREST:n.device.gl.LINEAR,t.addressU=n.device.wrapModes[this.addressU],t.addressV=n.device.wrapModes[this.addressV],t.addressW=n.device.wrapModes[this.addressW],t.samplerType=e.samplerType,t.isVolume=e.isVolume,t.ComputeHash()}return t}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VertexDeclaration=void 0;var n=function(){function e(e,t){for(var r=0;rt)return null}if(n.usage>e)return null}return null}},{key:"SetDeclaration",value:function(t,r){for(var n=0,a=0;a=this._elementsSorted.length){i.device.gl.disableVertexAttribArray(o.location),i.device.gl.vertexAttrib4f(o.location,0,0,0,0);break}var s=this._elementsSorted[n],u=e.CompareDeclarationElements(s,o);if(u>0){i.device.gl.disableVertexAttribArray(o.location),i.device.gl.vertexAttrib4f(o.location,0,0,0,0);break}if(0===u){s.customSetter?s.customSetter(o):(i.device.gl.enableVertexAttribArray(o.location),i.device.gl.vertexAttribPointer(o.location,s.elements,s.type,!1,r,s.offset));break}n++}}return!0}},{key:"SetPartialDeclaration",value:function(t,r){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=[],s=0,u=0;u0){a||(i.device.gl.disableVertexAttribArray(l.location),i.device.gl.vertexAttrib4f(l.location,0,0,0,0));break}if(++s>=this._elementsSorted.length)return a||(i.device.gl.disableVertexAttribArray(l.location),i.device.gl.vertexAttrib4f(l.location,0,0,0,0)),o}}return o}},{key:"ResetInstanceDivisors",value:function(e){if(e)for(var t=0;t2&&void 0!==arguments[2]?arguments[2]:0;return e.usaget.usage?1:e.usageIndex+rt.usageIndex?1:0}}]),e}()).Type={POSITION:0,COLOR:1,NORMAL:2,TANGENT:3,BINORMAL:4,TEXCOORD:5,BLENDWEIGHT:6,BLENDINDICES:7}},function(e,t,r){(function(t){WebGLDebugUtils=function(){var e;void 0===e&&(e=t);var r=function(t){e.console&&e.console.error?e.console.error(t):function(t){e.console&&e.console.log&&e.console.log(t)}(t)},n={enable:{1:{0:!0}},disable:{1:{0:!0}},getParameter:{1:{0:!0}},drawArrays:{3:{0:!0}},drawElements:{4:{0:!0,2:!0}},createShader:{1:{0:!0}},getShaderParameter:{2:{1:!0}},getProgramParameter:{2:{1:!0}},getShaderPrecisionFormat:{2:{0:!0,1:!0}},getVertexAttrib:{2:{1:!0}},vertexAttribPointer:{6:{2:!0}},bindTexture:{2:{0:!0}},activeTexture:{1:{0:!0}},getTexParameter:{2:{0:!0,1:!0}},texParameterf:{3:{0:!0,1:!0}},texParameteri:{3:{0:!0,1:!0,2:!0}},copyTexImage2D:{8:{0:!0,2:!0}},copyTexSubImage2D:{8:{0:!0}},generateMipmap:{1:{0:!0}},bindBuffer:{2:{0:!0}},getBufferParameter:{2:{0:!0,1:!0}},pixelStorei:{2:{0:!0,1:!0}},bindRenderbuffer:{2:{0:!0}},bindFramebuffer:{2:{0:!0}},checkFramebufferStatus:{1:{0:!0}},framebufferRenderbuffer:{4:{0:!0,1:!0,2:!0}},framebufferTexture2D:{5:{0:!0,1:!0,2:!0}},getFramebufferAttachmentParameter:{3:{0:!0,1:!0,2:!0}},getRenderbufferParameter:{2:{0:!0,1:!0}},renderbufferStorage:{4:{0:!0,1:!0}},clear:{1:{0:{enumBitwiseOr:["COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT"]}}},depthFunc:{1:{0:!0}},blendFunc:{2:{0:!0,1:!0}},blendFuncSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},blendEquation:{1:{0:!0}},blendEquationSeparate:{2:{0:!0,1:!0}},stencilFunc:{3:{0:!0}},stencilFuncSeparate:{4:{0:!0,1:!0}},stencilMaskSeparate:{2:{0:!0}},stencilOp:{3:{0:!0,1:!0,2:!0}},stencilOpSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},cullFace:{1:{0:!0}},frontFace:{1:{0:!0}},drawArraysInstancedANGLE:{4:{0:!0}},drawElementsInstancedANGLE:{5:{0:!0,2:!0}},blendEquationEXT:{1:{0:!0}},bufferData:{3:{0:!0,2:!0},4:{0:!0,2:!0},5:{0:!0,2:!0}},bufferSubData:{3:{0:!0},4:{0:!0},5:{0:!0}},copyBufferSubData:{5:{0:!0,1:!0}},getBufferSubData:{3:{0:!0},4:{0:!0},5:{0:!0}},blitFramebuffer:{10:{8:{enumBitwiseOr:["COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT"]},9:!0}},framebufferTextureLayer:{5:{0:!0,1:!0}},invalidateFramebuffer:{2:{0:!0}},invalidateSubFramebuffer:{6:{0:!0}},readBuffer:{1:{0:!0}},getInternalformatParameter:{3:{0:!0,1:!0,2:!0}},renderbufferStorageMultisample:{5:{0:!0,2:!0}},texStorage2D:{5:{0:!0,2:!0}},texStorage3D:{6:{0:!0,2:!0}},texImage2D:{9:{0:!0,2:!0,6:!0,7:!0},6:{0:!0,2:!0,3:!0,4:!0},10:{0:!0,2:!0,6:!0,7:!0}},texImage3D:{10:{0:!0,2:!0,7:!0,8:!0},11:{0:!0,2:!0,7:!0,8:!0}},texSubImage2D:{9:{0:!0,6:!0,7:!0},7:{0:!0,4:!0,5:!0},10:{0:!0,6:!0,7:!0}},texSubImage3D:{11:{0:!0,8:!0,9:!0},12:{0:!0,8:!0,9:!0}},copyTexSubImage3D:{9:{0:!0}},compressedTexImage2D:{7:{0:!0,2:!0},8:{0:!0,2:!0},9:{0:!0,2:!0}},compressedTexImage3D:{8:{0:!0,2:!0},9:{0:!0,2:!0},10:{0:!0,2:!0}},compressedTexSubImage2D:{8:{0:!0,6:!0},9:{0:!0,6:!0},10:{0:!0,6:!0}},compressedTexSubImage3D:{10:{0:!0,8:!0},11:{0:!0,8:!0},12:{0:!0,8:!0}},vertexAttribIPointer:{5:{2:!0}},drawArraysInstanced:{4:{0:!0}},drawElementsInstanced:{5:{0:!0,2:!0}},drawRangeElements:{6:{0:!0,4:!0}},readPixels:{7:{4:!0,5:!0},8:{4:!0,5:!0}},clearBufferfv:{3:{0:!0},4:{0:!0}},clearBufferiv:{3:{0:!0},4:{0:!0}},clearBufferuiv:{3:{0:!0},4:{0:!0}},clearBufferfi:{4:{0:!0}},beginQuery:{2:{0:!0}},endQuery:{1:{0:!0}},getQuery:{2:{0:!0,1:!0}},getQueryParameter:{2:{1:!0}},samplerParameteri:{3:{1:!0,2:!0}},samplerParameterf:{3:{1:!0}},getSamplerParameter:{2:{1:!0}},fenceSync:{2:{0:!0,1:{enumBitwiseOr:[]}}},clientWaitSync:{3:{1:{enumBitwiseOr:["SYNC_FLUSH_COMMANDS_BIT"]}}},waitSync:{3:{1:{enumBitwiseOr:[]}}},getSyncParameter:{2:{1:!0}},bindTransformFeedback:{2:{0:!0}},beginTransformFeedback:{1:{0:!0}},transformFeedbackVaryings:{3:{2:!0}},bindBufferBase:{3:{0:!0}},bindBufferRange:{5:{0:!0}},getIndexedParameter:{2:{0:!0}},getActiveUniforms:{3:{2:!0}},getActiveUniformBlockParameter:{3:{2:!0}}},i=null,a=null;function o(e){if(null==i)for(var t in i={},a={},e)"number"==typeof e[t]&&(i[e[t]]=t,a[t]=e[t])}function s(){if(null==i)throw"WebGLDebugUtils.init(ctx) not called"}function u(e){s();var t=i[e];return void 0!==t?"gl."+t:"/*UNKNOWN WebGL ENUM*/ 0x"+e.toString(16)}function l(e,t,r,i){var o;if(void 0!==(o=n[e])&&(void 0!==(o=o[t])&&o[r])){if("object"==typeof o[r]&&void 0!==o[r].enumBitwiseOr){for(var s=o[r].enumBitwiseOr,l=0,c=[],f=0;f=0&&setTimeout(function(){t.restoreContext()},v)},0)}},t.restoreContext=function(){u&&a.length&&setTimeout(function(){if(!d)throw"can not restore. webglcontestlost listener did not call event.preventDefault";!function(){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:0;this.isPlaying=!0,this.scaledTime=e}},{key:"Stop",value:function(){this.isPlaying=!1}},{key:"Update",value:function(e){if(this.isPlaying){this.scaledTime+=e*this.scale;for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:this;this._copyFunc&&(this._copyFunc.call(this),"OnValueChanged"in this.destinationObject&&this.destinationObject.OnValueChanged(e,[this.destinationAttribute]))}}],[{key:"CopyValueToValue",value:function(){this.destinationObject[this.destinationAttribute]=this.sourceObject[this.sourceAttribute]*this.scale+this.offset[0]}},{key:"CopyArray",value:function(){for(var e=Math.min(this.destinationObject[this.destinationAttribute].length,this.sourceObject[this.sourceAttribute].length),t=0;t0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.value=a.util.isArrayLike(r)?r[0]:r,n.constantBuffer=null,n.offset=null,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.Tw2Parameter),n(t,[{key:"SetValue",value:function(e){this.value=e,this.OnValueChanged()}},{key:"GetValue",value:function(){return this.value}},{key:"Apply",value:function(e,t){e[t]=this.value}},{key:"EqualsValue",value:function(e){return this.value===e}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.SetValue(e.GetValue())}}],[{key:"isValue",value:function(e){return a.util.isNumber(e)}}]),t}()).constantBufferSize=1},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MatrixParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.mat4.create();return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"Compose",value:function(e,t,r){"value"in e&&(e=e.value),"value"in t&&(t=t.value),"value"in r&&(r=r.value),i.mat4.fromRotationTranslationScale(this.value,e,t,r),this.OnValueChanged()}},{key:"Decompose",value:function(e,t,r){i.mat4.getRotation("value"in e?e.value:e,this.value),i.mat4.getTranslation("value"in t?t.value:t,this.value),i.mat4.getScaling("value"in r?r.value:r,this.value),"OnValueChanged"in e&&e.OnValueChanged(),"OnValueChanged"in t&&t.OnValueChanged(),"OnValueChanged"in r&&r.OnValueChanged()}},{key:"x",get:function(){return this.GetIndexValue(12)},set:function(e){this.SetIndexValue(12,e)}},{key:"y",get:function(){return this.GetIndexValue(13)},set:function(e){this.SetIndexValue(13,e)}},{key:"z",get:function(){return this.GetIndexValue(14)},set:function(e){this.SetIndexValue(14,e)}}]),t}()).constantBufferSize=16},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TransformParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.scaling=i.vec3.fromValues(1,1,1),r.rotationCenter=i.vec3.create(),r.rotation=i.quat.create(),r.translation=i.vec3.create(),r.transform=i.mat4.create(),r.worldTransform=i.mat4.create(),r.constantBuffer=null,r.offset=null,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2Parameter),n(t,[{key:"Initialize",value:function(){this.OnValueChanged()}},{key:"GetValue",value:function(e){return e?Array.from(this.transform):new Float32Array(this.transform)}},{key:"OnValueChanged",value:function(e,r){i.mat4.fromRotationTranslationScaleOrigin(this.transform,this.rotation,this.translation,this.scaling,this.rotationCenter),i.mat4.transpose(this.worldTransform,this.transform),function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,r,n)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(n):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"OnValueChanged",this).call(this,e,r)}},{key:"Bind",value:function(e,t,r){return!this.constantBuffer&&r>=this.size&&(this.constantBuffer=e,this.offset=t,this.Apply(e,t,r),!0)}},{key:"Apply",value:function(e,t,r){r>=this.constructor.constantBufferSize?e.set(this.worldTransform,t):e.set(this.worldTransform.subarray(0,r),t)}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),i.quat.copy(this.rotation,e.rotation),i.vec3.copy(this.translation,e.translation),i.vec3.copy(this.scaling,e.scaling),i.vec3.copy(this.rotationCenter,e.rotationCenter),this.OnValueChanged()}}]),t}()).constantBufferSize=16},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VariableParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.variableName=r,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2Parameter),n(t,[{key:"GetValue",value:function(e){return i.store.GetVariableValue(this.variableName,e)}},{key:"Apply",value:function(e,t,r){this.variable&&this.variable.Apply(e,t,r)}},{key:"AddCallback",value:function(){return!1}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.variableName=e.variableName}},{key:"variable",get:function(){return i.store.GetVariable(this.variableName)}},{key:"size",get:function(){return this.variable?this.variable.size:0}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector2Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec2.fromValues(1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}}]),t}()).constantBufferSize=2},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector3Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec3.fromValues(1,1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}},{key:"z",get:function(){return this.GetIndexValue(2)},set:function(e){this.SetIndexValue(2,e)}}]),t}()).constantBufferSize=3},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector4Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec4.fromValues(1,1,1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}},{key:"z",get:function(){return this.GetIndexValue(2)},set:function(e){this.SetIndexValue(2,e)}},{key:"w",get:function(){return this.GetIndexValue(3)},set:function(e){this.SetIndexValue(3,e)}}]),t}()).constantBufferSize=4},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(104);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(46);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(24);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveBasicPerObjectData=t.Tw2BasicPerObjectData=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"DeclareFromObject",this).call(this,e),e.FFEData&&(this.perObjectFFEData=new s.Tw2RawData(e.FFEData))}}]),t}();t.EveBasicPerObjectData=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2BlendShapeData=void 0;var n=r(9);t.Tw2BlendShapeData=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="",this.declaration=new n.Tw2VertexDeclaration,this.buffers=[],this.indexes=null,this.weightProxy=null}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2GeometryAnimation=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="",this.duration=0,this.trackGroups=[]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2GeometryBone=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[];return i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"GetResources",this).call(this,e),this.instanceGeometryResource&&"GetResources"in this.instanceGeometryResource&&this.instanceGeometryResource.GetResources(e),e}},{key:"RenderAreas",value:function(e,t,r,n,i){if(this.IsGood()){var a=this.instanceGeometryResource.GetInstanceBuffer(this.instanceMeshIndex);a&&this.geometryResource.RenderAreasInstanced(e,t,r,n,i,a,this.instanceGeometryResource.GetInstanceDeclaration(this.instanceMeshIndex),this.instanceGeometryResource.GetInstanceStride(this.instanceMeshIndex),this.instanceGeometryResource.GetInstanceCount(this.instanceMeshIndex))}}}],[{key:"GetAreaBatches",value:function(e,t,r,n,i){for(var a=0;a0&&void 0!==arguments[0]?arguments[0]:[],t=0;tf.duration&&(c.callback&&c.callback(this,c),c.cycle?c.time=c.time%f.duration:(c.isPlaying=!1,c.time=f.duration));for(var h=0;h=0){var i=this.models[t].bones[n.boneRes.parentIndex];e.AddLine([n.worldTransform[12],n.worldTransform[13],n.worldTransform[14]],[i.worldTransform[12],i.worldTransform[13],i.worldTransform[14]])}}}}],[{key:"AddModel",value:function(e,t){for(var r=0;r7)return i.logger.log("res.error",{log:"error",src:["Tw2EffectRes","CreateProgram"],msg:"Invalid version of effect file",type:"shader.effectversion",path:this.path,value:o}),void this.PrepareFinished(!1);var s=void 0,u=void 0;if(o<5){if(0===(s=t.ReadUInt32()))return i.logger.log("res.error",{log:"error",src:["Tw2EffectRes","CreateProgram"],msg:"File contains no compiled effects",path:this.path,type:"shader.effectheadersize",value:0}),void this.PrepareFinished(!1);t.ReadUInt32();var l=t.ReadUInt32();t.cursor=8+3*s*4,u=t.ReadUInt32(),this.stringTableOffset=t.cursor,r=String.fromCharCode.apply(null,t.data.subarray(t.cursor,t.cursor+u)),t.cursor=l}else{u=t.ReadUInt32(),this.stringTableOffset=t.cursor,r=String.fromCharCode.apply(null,t.data.subarray(t.cursor,t.cursor+u)),t.cursor+=u;for(var c=t.ReadUInt8(),f=0;f6&&(f=t.ReadUInt8());for(var h=0;h6&&(p.name=l()),this.techniques[p.name]=p;for(var d=t.ReadUInt8(),v=0;v=3&&(t.ReadUInt32(),t.ReadUInt32(),t.ReadUInt32()),_.constantSize=0;for(var D=t.ReadUInt32(),C=0;C_.constantSize&&(_.constantSize=k)}}var x=t.ReadUInt32()/4;if(_.constantValues=new Float32Array(x),r<5)for(var L=0;L=4?l():"";t.ReadUInt8();var W=t.ReadUInt8(),X=t.ReadUInt8(),K=t.ReadUInt8(),Q=t.ReadUInt8(),Z=t.ReadUInt8(),J=t.ReadUInt8();t.ReadFloat32();var $=t.ReadUInt8();t.ReadUInt8();var ee=i.quat.create();ee[0]=t.ReadFloat32(),ee[1]=t.ReadFloat32(),ee[2]=t.ReadFloat32(),ee[3]=t.ReadFloat32(),t.ReadFloat32(),t.ReadFloat32(),r<4&&t.ReadUInt8();var te=new o.Tw2SamplerState;if(te.registerIndex=H,te.name=Y,1===W){switch(K){case 0:te.minFilter=c.gl.NEAREST;break;case 1:te.minFilter=c.gl.NEAREST_MIPMAP_NEAREST;break;default:te.minFilter=c.gl.NEAREST_MIPMAP_LINEAR}te.minFilterNoMips=c.gl.NEAREST}else{switch(K){case 0:te.minFilter=c.gl.LINEAR;break;case 1:te.minFilter=c.gl.LINEAR_MIPMAP_NEAREST;break;default:te.minFilter=c.gl.LINEAR_MIPMAP_LINEAR}te.minFilterNoMips=c.gl.LINEAR}te.magFilter=1===X?c.gl.NEAREST:c.gl.LINEAR,te.addressU=c.wrapModes[Q],te.addressV=c.wrapModes[Z],te.addressW=c.wrapModes[J],3!==W&&3!==X&&3!==K||(te.anisotropy=Math.max($,1));for(var re=0;re<_.textures.length;++re)if(_.textures[re].registerIndex===te.registerIndex){te.samplerType=4===_.textures[re].type?c.gl.TEXTURE_CUBE_MAP:c.gl.TEXTURE_2D,te.isVolume=3===_.textures[re].type;break}te.ComputeHash(),_.samplers.push(te)}r>=3&&t.ReadUInt8(),m.stages[E]=_}m.states=[];for(var ne=t.ReadUInt8(),ie=0;ie=0){var p=new a.Tw2VertexElement(r.stages[0].inputDefinition.elements[f].usage,r.stages[0].inputDefinition.elements[f].usageIndex);p.location=h,s.input.elements.push(p)}}s.input.RebuildHash(),s.shadowStateInt=o.gl.getUniformLocation(s.program,"ssi"),s.shadowStateFloat=o.gl.getUniformLocation(s.program,"ssf"),s.shadowStateYFlip=o.gl.getUniformLocation(s.program,"ssyf"),o.gl.uniform3f(s.shadowStateYFlip,0,0,1),s.volumeSlices=[];for(var d=0;d=this.meshes.length)return!1;var c=i.device,f=this.meshes[e],h=n.GetPassCount(a);c.gl.bindBuffer(c.gl.ELEMENT_ARRAY_BUFFER,f.indexes);for(var p=0;p=this.meshes.length)return!1;var o=i.device,s=this.meshes[e]||this.meshes[0],u=n.GetPassCount(a);o.gl.bindBuffer(o.gl.ARRAY_BUFFER,s.buffer),o.gl.bindBuffer(o.gl.ELEMENT_ARRAY_BUFFER,s.indexes);for(var l=0;l=this.meshes.length)return!1;var o=i.device,s=this.meshes[e],u=n.GetPassCount(a);o.gl.bindBuffer(o.gl.ARRAY_BUFFER,s.buffer),o.gl.bindBuffer(o.gl.ELEMENT_ARRAY_BUFFER,s.indexes);for(var l=0;l=0){var i=this.models[t].skeleton.bones[n.parentIndex];e.AddLine([n.worldTransform[12],n.worldTransform[13],n.worldTransform[14]],[i.worldTransform[12],i.worldTransform[13],i.worldTransform[14]],[0,.7,0,1],[0,.7,0,1])}}}},{key:"Unload",value:function(){for(var e=0;e>5),s.offset=4*n,t.elements[a]=s,n+=s.elements}t.RebuildHash(),t.stride=4*n;var u=e.ReadUInt32();if(0===u)return null;for(var l=new Float32Array(n*u),c=0,f=0;f0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.cycle=e,this._onEnded=t,this.video&&this._playable?(this.video.loop=this.cycle,this.video.play()):this.playOnLoad=!0}},{key:"Pause",value:function(){this.video?this.video.pause():this.playOnLoad=!1}},{key:"Prepare",value:function(e){var t=i.device.gl;switch(e){case"mp4":case"webm":case"ogg":this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this.video),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.bindTexture(t.TEXTURE_2D,null),this.width=this.video.width,this.height=this.video.height,this.video.loop=this.cycle,this.playOnLoad&&this.video.play(),this.PrepareFinished(!0)}}},{key:"DoCustomLoad",value:function(e){var t=this,r=i.resMan.constructor.GetPathExt(e);return this.LoadStarted(),i.resMan._pendingLoads++,this.video=document.createElement("video"),this.video.crossOrigin="anonymous",this.video.muted=!0,this.video.onerror=function(){i.resMan._pendingLoads--,i.logger.log("res.error",{log:"error",src:["Tw2TextureRes","DoCustomLoad"],msg:"Error loading resource",type:"http.error",path:e}),t.LoadFinished(!1),t.PrepareFinished(!1),t.video=null},this.video.oncanplay=function(){t._playable=!0,t.video.oncanplay=null,i.resMan._pendingLoads--,i.resMan._prepareQueue.push([t,r,null]),t.LoadFinished(!0)},this.video.onended=function(){t._isPlaying=!1,t._onEnded&&t._onEnded(t)},this.video.onpause=function(){t._isPlaying=!1,t._onPause&&t._onPause(t)},this.video.onplaying=function(){t._isPlaying=!0,t._onPlaying&&t._onPlaying(t)},this.video.src=e,!0}},{key:"Unload",value:function(){return this.texture&&(i.device.gl.deleteTexture(this.texture),this.texture=null),this._isPlaying=!1,this._playable=!1,this.playOnLoad=!0,this.video=null,!0}},{key:"Bind",value:function(e){var t=i.device;this.KeepAlive();var r=e.samplerType;r===t.gl.TEXTURE_2D&&(this.texture?(this._currentTime=this.video.currentTime,t.gl.bindTexture(t.gl.TEXTURE_2D,this.texture),t.gl.texImage2D(t.gl.TEXTURE_2D,0,t.gl.RGBA,t.gl.RGBA,t.gl.UNSIGNED_BYTE,this.video),t.gl.bindTexture(t.gl.TEXTURE_2D,null),t.gl.bindTexture(r,this.texture),e.hash!==this._currentSampler&&(e.Apply(!1),this._currentSampler=e.hash)):t.gl.bindTexture(t.gl.TEXTURE_2D,t.GetFallbackTexture()))}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(125);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PostProcess=void 0;var n=function(){function e(e,t){for(var r=0;r=a.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.vec4.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.vec4.copy(r,a.value);case t.Extrapolation.GRADIENT:return i.vec4.scaleAndAdd(r,a.value,a.right,e-a.time);default:e%=a.time}else if(e<0||e=o.time||ethis.length){if(!this.cycle)return this.reversed?i.vec4.copy(t,this.startValue):i.vec4.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec4.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a[2]=o[2]+(s[2]-o[2])*(e/l),a[3]=o[3]+(s[3]-o[3])*(e/l),a;default:return a}}}]),t}();c.inputDimension=4,c.outputDimension=4,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2EventCurve=t.Tw2EventKey=void 0;var n=function(){function e(e,t){for(var r=0;r=this.keys[this._currentKey].time;)this.value=this.keys[this._currentKey].value,++this._currentKey}}]),t}();l.dimension=1,l.outputDimension=1,l.valueProperty="value",l.curveType=i.Tw2Curve.Type.CURVE,l.Key=u,l.Extrapolation={NONE:0,CYCLE:3}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PerlinCurve=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?(t[0]=this.startValue[0],t[1]=this.startValue[1],t[2]=this.startValue[2],t):(t[0]=this.endValue[0],t[1]=this.endValue[1],t[2]=this.endValue[2],t);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var i=0;i+1e));++i);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){a[0]=this.startValue[0],a[1]=this.startValue[1],a[2]=this.startValue[2];var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.SPHERICAL_LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),i.quat.slerp(a,o,s,e/l),a;default:return a}}}]),t}();c.inputDimension=4,c.outputDimension=4,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,SPHERICAL_LINEAR:4}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2RandomConstantCurve=void 0;var n=function(){function e(e,t){for(var r=0;r=this.states[this.states.length-1].time)r=this.states.length-1;else for(;r+1=this.states[r].time&&e=s.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.quat.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.quat.copy(r,s.value);default:e%=s.time}else if(e<0||e=u.time||e0;p--){var d=i.num.biCumulative(c,p);d>1&&i.quat.multiply(r,f,h[p]),r[0]=-h[p-1][0],r[1]=-h[p-1][1],r[2]=-h[p-1][2],r[3]=h[p-1][3],i.quat.multiply(r,r,h[p]),i.quat.pow(r,r,d),i.quat.multiply(f,f,r)}return i.quat.multiply(r,f,l.value);case t.Interpolation.SLERP:return i.quat.slerp(r,l.value,u.value,c);default:return i.quat.sqlerp(r,l.value,l.right,u.left,u.value,c)}}}]),t}();c.outputDimention=4,c.inputDimension=4,c.valueProperty="value",c.curveType=a.Tw2Curve.Type.CURVE,c.Child=l,c.Extrapolation={NONE:0,CONSTANT:1,GRADIENT:2,CYCLE:3},c.Interpolation={NONE:0,CONSTANT:1,LINEAR:2,HERMITE:3,SLERP:5,SQUAD:6}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2ScalarCurve=t.Tw2ScalarKey=void 0;var n=function(){function e(e,t){for(var r=0;r=n.time)switch(this.extrapolation){case t.Extrapolation.NONE:return this.value;case t.Extrapolation.CONSTANT:return n.value;case t.Extrapolation.GRADIENT:return n.value+(e-n.time)*n.right;default:e%=n.time}else if(e<0||e=i.time||ethis.length){if(!this.cycle)return this.reversed?this.startValue:this.endValue;e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null);var t=this.keys[0],r=this.keys[this.keys.length-1];if(e<=t.time)return this.Interpolate(e,null,t);if(e>=r.time)return this.Interpolate(e,r,null);for(var n=0;n+1e));++n);return this.Interpolate(e,t,r)}},{key:"Interpolate",value:function(e,r,n){var i=this.startValue,a=this.endValue,o=this.interpolation,s=this.length;switch(null!==r&&(o=r.interpolation,e-=r.time),o){case t.Interpolation.LINEAR:return r&&n?(i=r.value,a=n.value,s=n.time-r.time):n?(a=n.value,s=n.time):r&&(i=r.value,s=this.length-r.time),i+e/s*(a-i);case t.Interpolation.HERMITE:var u=this.startTangent,l=this.endTangent;r&&n?(i=r.value,u=r.rightTangent,a=n.value,l=n.leftTangent,s=n.time-r.time):n?(a=n.value,l=n.leftTangent,s=n.time):r&&(i=r.value,u=r.rightTangent,s=this.length-r.time);var c=e/s,f=c*c,h=f*c,p=-2*h+3*f,d=h-f;return i*(1-p)+a*p+u*(c+d-f)+l*d;default:return this.startValue}}}]),t}();l.inputDimension=1,l.outputDimension=1,l.valueProperty="currentValue",l.curveType=i.Tw2Curve.Type.CURVE2,l.Key=u,l.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SineCurve=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?i.vec2.copy(t,this.startValue):i.vec2.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec2.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a;case t.Interpolation.HERMITE:var c=this.startTangent,f=this.endTangent;r&&n?(o=r.value,c=r.rightTangent,s=n.value,f=n.leftTangent,l=n.time-r.time):n?(s=n.value,f=n.leftTangent,l=n.time):r&&(o=r.value,c=r.rightTangent,l=this.length-r.time);var h=e/l,p=h*h,d=p*h,v=-2*d+3*p,m=1-v,y=d-p,b=h+y-p;return a[0]=o[0]*m+s[0]*v+c[0]*b+f[0]*y,a[1]=o[1]*m+s[1]*v+c[1]*b+f[1]*y,a;default:return a}}}]),t}();c.inputDimension=2,c.outputDimension=2,c.valueProperty="value",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector3Curve=t.Tw2Vector3Key=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?i.vec3.copy(t,this.startValue):i.vec3.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec3.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a[2]=o[2]+(s[2]-o[2])*(e/l),a;case t.Interpolation.HERMITE:var c=this.startTangent,f=this.endTangent;r&&n?(o=r.value,c=r.rightTangent,s=n.value,f=n.leftTangent,l=n.time-r.time):n?(s=n.value,f=n.leftTangent,l=n.time):r&&(o=r.value,c=r.rightTangent,l=this.length-r.time);var h=e/l,p=h*h,d=p*h,v=-2*d+3*p,m=1-v,y=d-p,b=h+y-p;return a[0]=o[0]*m+s[0]*v+c[0]*b+f[0]*y,a[1]=o[1]*m+s[1]*v+c[1]*b+f[1]*y,a[2]=o[2]*m+s[2]*v+c[2]*b+f[2]*y,a;default:return a}}}]),t}();c.inputDimension=3,c.outputDimension=3,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VectorCurve=t.Tw2VectorKey=void 0;var n=function(){function e(e,t){for(var r=0;r=a.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.vec3.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.vec3.copy(r,a.value);case t.Extrapolation.GRADIENT:return i.vec3.scaleAndAdd(r,a.value,a.right,e-a.time);default:e%=a.time}else if(e<0||e=o.time||e=0&&this._UpdateValue(e))}}function a(){this._id=n.util.generateID(),this.translation=n.vec3.create(),this.rotation=n.quat.create(),this.rotation[3]=1,this.scale=n.vec3.create();var e=null,t=null,r=null,i=n.mat4.create();this._TracksReady=function(){return e||t||r},this._ApplyTracks=function(n,i){for(var a=0;athis.duration||e<0||(i.curve.evaluate(this.positionCurve,e,this.translation,this.cycle,this.duration),i.curve.evaluate(this.orientationCurve,e,this.rotation,this.cycle,this.duration),i.quat.normalize(this.rotation,this.rotation),i.curve.evaluate(this.scaleCurve,e,this.scaleShear,this.cycle,this.duration),i.mat4.getScaling(this.scale,this.scaleCurve))))}},{key:"FindTracks",value:function(){for(var e=null,t=0;t=0&&(this.length=this.animationEngine.GetLength(this.xIndex)),this.yIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.yIndex))),this.zIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.zIndex))))}}]),t}();o.outputDimension=3,o.valueProperty="eulerValue",o.curveType=a.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaScalarCurve=void 0;var n=function(){function e(e,t){for(var r=0;r=0&&(this.length=this.animationEngine.GetLength(this.index))}}]),t}();a.outputDimension=1,a.valueProperty="value",a.curveType=i.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaVector3Curve=void 0;var n=function(){function e(e,t){for(var r=0;r=0&&(this.length=this.animationEngine.GetLength(this.xIndex)),this.yIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.yIndex))),this.zIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.zIndex))))}}]),t}();o.outputDimension=3,o.valueProperty="value",o.curveType=a.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaAnimationEngine=void 0;var n=function(){function e(e,t){for(var r=0;ri[e.AnimCurveFields.END_TIME]?i[e.AnimCurveFields.POST_INFINITY]===e.INFINITY?i[e.AnimCurveFields.END_VALUE]:this._EvaluateInfinities(i,o,a,r,!1):this._EvaluateImpl(i,o,a,r)}},{key:"_EvaluateImpl",value:function(t,r,n,i){var a=!1,o=null,s=null,u=void 0;if(this._evalCache[this._currentCurveIndex]>=0)if(s=n+this._evalCache[this._currentCurveIndex],this._evalCache[this._currentCurveIndex]r[s][e.AnimSegment.TIME]){if(i===r[o=n+this._evalCache[this._currentCurveIndex]+1][e.AnimSegment.TIME])return this._evalCache[this._currentCurveIndex]++,r[o][e.AnimSegment.VALUE];i0&&ir[l][e.AnimSegment.TIME])u=this._evalCache[this._currentCurveIndex],a=!0;else if(i===r[l][e.AnimSegment.TIME])return this._evalCache[this._currentCurveIndex]--,r[l][e.AnimSegment.VALUE]}if(!a){var c=this._Find(t,i,r,n);if(u=c[1],c[0]||0===u)return u===t[e.AnimCurveFields.NUM_SEGMENTS]?(u--,this._evalCache[this._currentCurveIndex]=u,t[e.AnimCurveFields.END_VALUE]):(this._evalCache[this._currentCurveIndex]=u,r[n+u][e.AnimSegment.VALUE]);if(u===t[e.AnimCurveFields.NUM_SEGMENTS]+1)return this._evalCache[this._currentCurveIndex]=0,t[e.AnimCurveFields.END_VALUE]}if(this._evalCache[this._currentCurveIndex]!==u-1&&(this._evalCache[this._currentCurveIndex]=u-1,s=n+this._evalCache[this._currentCurveIndex],null===o&&(o=n+u)),t[e.AnimCurveFields.IS_WEIGHTED]){var f=r[s];if(f[e.BezierSegment.IS_STEP])return f[e.BezierSegment.VALUE];if(f[e.BezierSegment.IS_STEP_NEXT])return null===o?t[e.AnimCurveFields.END_VALUE]:r[o][e.BezierSegment.VALUE];var h=t[e.AnimCurveFields.END_TIME];return this._evalCache[this._currentCurveIndex]+10){s=0,u=a-1;do{if(r<(c=(o=s+u>>1)c))return[!0,l=o];s=o+1}}while(s<=u);l=s}return[!1,l]}},{key:"GetNumberOfCurves",value:function(){return this.curves.length}},{key:"GetLength",value:function(t){if(t<0||t>=this.curves.length)return 0;var r=this.curves[t],n=void 0;return n=r[e.AnimCurveFields.IS_WEIGHTED]?this.bezierSegments[r[e.AnimCurveFields.SEGMENT_OFFSET]]:this.hermiteSegments[r[e.AnimCurveFields.SEGMENT_OFFSET]],r[e.AnimCurveFields.END_TIME]-n[e.AnimSegment.TIME]}}]),e}();a.AnimCurveFields={NUM_SEGMENTS:0,SEGMENT_OFFSET:1,END_TIME:2,END_VALUE:3,IN_TANGENT:4,OUT_TANGENT:5,PRE_INFINITY:6,POST_INFINITY:7,IS_WEIGHTED:8},a.AnimSegment={TIME:0,VALUE:1},a.HermiteSegment={TIME:0,VALUE:1,COEFF:2,IS_STEP:3,IS_STEP_NEXT:4},a.BezierSegment={TIME:0,VALUE:1,COEFF:2,POLYY:3,IS_STEP:4,IS_STEP_NEXT:5,IS_LINEAR:6},a.INFINITY=0},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(59);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(165);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(61);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(64);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(183);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(184);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveChildBillboard=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t0&&void 0!==arguments[0]?arguments[0]:[];this.mesh&&this.mesh.GetResources(e);for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return a.util.perArrayChild(this.opaqueEffects,"GetResources",e),a.util.perArrayChild(this.decalEffects,"GetResources",e),a.util.perArrayChild(this.transparentEffects,"GetResources",e),a.util.perArrayChild(this.additiveEffects,"GetResources",e),a.util.perArrayChild(this.distortionEffects,"GetResources",e),e}},{key:"Update",value:function(e){this.update&&this.curveSet&&this.curveSet.Update(e)}},{key:"GetBatches",value:function(e,t,r,n){if(this.display&&n&&n.IsGood())for(var a=this.GetEffects(e),o=0;o0&&void 0!==arguments[0]?arguments[0]:[];return this.source&&this.source.GetResources&&this.source.GetResources(e),this.dest&&this.dest.GetResources&&this.dest.GetResources(e),this.sourceObject&&this.sourceObject.GetResources&&this.sourceObject.GetResources(e),this.destObject&&this.destObject.GetResources&&this.destObject.GetResources(e),this.stretchObject&&this.stretchObject.GetResources&&this.stretchObject.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(){if(this.display){var t=e.global,r=i.vec3.subtract(t.vec3_0,this._destinationPosition,this._sourcePosition),n=i.mat4.identity(t.mat4_0),a=i.vec3.set(t.vec3_1,0,0,0),o=i.vec3.set(t.vec3_2,0,0,0),s=i.mat4.identity(t.mat4_1),u=i.vec3.length(r);i.vec3.normalize(r,r),this._useTransformsForStretch?(i.mat4.rotateX(n,n,-Math.PI/2),i.mat4.multiply(n,this._sourceTransform,n)):(Math.abs(r[1])>.9?o[2]=1:o[1]=1,i.vec3.cross(a,o,r),i.vec3.normalize(a,a),i.vec3.cross(o,r,a),n[0]=a[0],n[1]=a[1],n[2]=a[2],n[4]=-r[0],n[5]=-r[1],n[6]=-r[2],n[8]=o[0],n[9]=o[1],n[10]=o[2]),this.destObject&&this._displayDestObject&&(i.mat4.setTranslation(n,this._destinationPosition),this.destObject.UpdateViewDependentData(n)),this.sourceObject&&this._displaySourceObject&&(this._useTransformsForStretch?(i.mat4.identity(n),i.mat4.rotateX(n,n,-Math.PI/2),i.mat4.multiply(n,this._sourceTransform,n)):i.mat4.setTranslation(n,this._sourcePosition),this.sourceObject.UpdateViewDependentData(n)),this.stretchObject&&(this._useTransformsForStretch?(i.mat4.identity(n),i.mat4.scale(n,n,[1,1,u]),i.mat4.multiply(n,this._sourceTransform,n)):(n[0]=a[0],n[1]=a[1],n[2]=a[2],n[4]=o[0],n[5]=o[1],n[6]=o[2],n[8]=-r[0],n[9]=-r[1],n[10]=-r[2],this._isNegZForward&&(u=-u),i.mat4.scale(s,s,[1,1,u]),i.mat4.multiply(n,n,s)),this.stretchObject.UpdateViewDependentData(n))}}},{key:"Update",value:function(t){for(var r=0;r0&&(this._perMuzzleData[0].constantDelay=this.firingDelay1),this._perMuzzleData.length>1&&(this._perMuzzleData[1].constantDelay=this.firingDelay2),this._perMuzzleData.length>2&&(this._perMuzzleData[2].constantDelay=this.firingDelay3),this._perMuzzleData.length>3&&(this._perMuzzleData[3].constantDelay=this.firingDelay4),this._perMuzzleData.length>4&&(this._perMuzzleData[4].constantDelay=this.firingDelay5),this._perMuzzleData.length>5&&(this._perMuzzleData[5].constantDelay=this.firingDelay6),this._perMuzzleData.length>6&&(this._perMuzzleData[6].constantDelay=this.firingDelay7),this._perMuzzleData.length>7&&(this._perMuzzleData[7].constantDelay=this.firingDelay8)}},{key:"GetCurveDuration",value:function(){for(var e=0,t=0;t1&&void 0!==arguments[1]?arguments[1]:-1,r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t=this._perMuzzleData[n].elapsedTime||this.isLoopFiring)&&this.stretch[n].GetBatches(e,t,r)}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveStarField=void 0;var n=r(0);t.EveStarField=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._id=n.util.generateID(),this.name="",this.display=!0,this.effect=null,this.maxDist=0,this.maxFlashRate=0,this.minFlashIntensity=0,this.minFlashRate=0,this.seed=20}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveEffectRoot=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t0&&void 0!==arguments[0]?arguments[0]:[];this.mesh&&this.mesh.GetResources(e),this.spriteSet&&this.spriteSet.GetResources(e)}},{key:"UpdateViewDependentData",value:function(){this.display&&this.state!==t.State.DEAD&&(i.mat4.transpose(this._perObjectData.perObjectVSData.Get("WorldMat"),this.transform),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("WorldMatLast"),this.transform))}},{key:"Update",value:function(e,r,n){if(this.state===t.State.IN_FLIGHT){var a=t.global,o=i.mat4.getTranslation(a.vec3_0,this.transform),s=a.vec3_1,u=a.vec3_2,l=a.vec3_3;this.time+=e,this.time>this.durationEjectPhase?(i.vec3.subtract(o,this.velocity,r),i.vec3.lerp(o,o,r,1-Math.exp(.9999*-e)),i.mat4.setTranslation(this.transform,o),i.vec3.subtract(s,n,o),i.vec3.length(s)t.length)this.warheads.splice(t.length);else for(;this.warheads.length0&&void 0!==arguments[0]?arguments[0]:[],t=0;t.1&&(i.vec3.normalize(t,t),i.vec3.scale(t,t,Math.min(e*this.speed,r)),i.vec3.add(this.position,this.position,t));for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:[];return this.highDetail&&this.highDetail.GetResources(e),this.effectHeight&&this.effectHeight.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(e){this.highDetail.UpdateViewDependentData(e),this.zOnlyModel&&(this.zOnlyModel.translation=this.highDetail.translation,this.zOnlyModel.scaling=this.highDetail.scaling,this.zOnlyModel.UpdateViewDependentData(e))}},{key:"Update",value:function(e){this.highDetail.Update(e)}},{key:"GetBatches",value:function(e,t){if(this.display&&this.heightDirty&&this.watchedResources.length&&""!==this.heightMapResPath1){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],r=arguments[1];i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"GetResources",this).call(this,e,r);for(var n=0;n1)for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t.visible,e.visible,["glow","symHalo","halo","trail"]),i.util.assignIfExists(t,e,["name","display","seed","wavePhase","transform","locatorName","updateFromLocator","atlas0","atlas1"]),t}}]),t}(),h=t.EveBoosterSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.visible={},e.visible.glows=!0,e.visible.symHalos=!0,e.visible.halos=!0,e.visible.trails=!0,e.effect=null,e.glows=null,e.alwaysOn=!0,e.maxVel=250,e.glowDistance=2.5,e.glowScale=1,e.glowColor=i.vec4.create(),e.warpGlowColor=i.vec4.create(),e.haloDistance=3.01,e.haloScaleX=1,e.haloScaleY=1,e.haloColor=i.vec4.create(),e.warpHaloColor=i.vec4.create(),e.symHaloDistance=3,e.symHaloScale=1,e.trailColor=i.vec4.create(),e.trailSize=i.vec4.create(),e._parentTransform=i.mat4.create(),e._positions=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,i.device.gl.FLOAT,3,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,2,12)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,20)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,4,36)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,i.device.gl.FLOAT,4,52)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,i.device.gl.FLOAT,4,68)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,i.device.gl.FLOAT,4,84)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,6,i.device.gl.FLOAT,1,100)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,7,i.device.gl.FLOAT,2,104)),e._decl.RebuildHash(),e._perObjectData=new a.Tw2PerObjectData,e._perObjectData.perObjectVSData=new a.Tw2RawData,e._perObjectData.perObjectVSData.Declare("WorldMat",16),e._perObjectData.perObjectVSData.Declare("Shipdata",4),e._perObjectData.perObjectVSData.Create(),e._locatorRebuildPending=!0,e}return l(t,o.EveObjectSet),n(t,[{key:"FindItemByLocatorName",value:function(e){for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),this.glows&&this.glows.effect.GetResources(e),e}},{key:"Update",value:function(e,t){i.mat4.copy(this._parentTransform,t),this._rebuildPending&&this.Rebuild(),this.glows&&this.glows.Update(e)}},{key:"Unload",value:function(){this._positions&&(i.device.gl.deleteBuffer(this._positions),this._positions=null),this.glows&&this.glows.Unload()}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this);var e=this._visibleItems.length;if(this._rebuildPending=!1,e){for(var r=i.device,n=t._box,a=new Float32Array(e*n.length*6*28),o=[0,3,1,3,2,1],s=0,u=0;u0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","type","position1","color1","position2","color2","intermediatePosition","width","multiColor","multiColorBorder","overlayColor","animationSpeed","animationScale","numOfSegments"]),t}}]),t}();c.Type={INVALID:0,STRAIGHT:1,SPHERED:2,CURVED:3},c.DEFAULT_CURVED_SEGMENTS=20,c.DEFAULT_SPHERED_SEGEMENTS=20;var f=t.EveCurveLineSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.lineEffect=a.Tw2Effect.create({effectFilePath:"res:/Graphics/Effect/Managed/Space/SpecialFX/Lines3D.fx",textures:{TexMap:"res:/texture/global/white.dds.0.png",OverlayTexMap:"res:/texture/global/white.dds.0.png"}}),e.pickEffect=null,e.lineWidthFactor=1,e.additive=!1,e.pickable=!0,e.depthOffset=0,e.translation=i.vec3.create(),e.rotation=i.quat.create(),e.scaling=i.vec3.fromValues(1,1,1),e.transform=i.mat4.create(),e.parentTransform=i.mat4.create(),e._vertexSize=26,e._vbSize=0,e._vb=null,e._perObjectData=new a.Tw2PerObjectData,e._perObjectData.perObjectVSData=new a.Tw2RawData,e._perObjectData.perObjectVSData.Declare("WorldMat",16),e._perObjectData.perObjectVSData.Create(),e._perObjectData.perObjectPSData=new a.Tw2RawData,e._perObjectData.perObjectPSData.Declare("WorldMat",16),e._perObjectData.perObjectPSData.Create(),e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,i.device.gl.FLOAT,3,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,4,12)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,28)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,3,44)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,4,56)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,1,i.device.gl.FLOAT,4,72)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,2,i.device.gl.FLOAT,4,88)),e._decl.stride=4*e._vertexSize,e._decl.RebuildHash(),t.init(),e}return l(t,o.EveObjectSet),n(t,[{key:"Initialize",value:function(){this.OnValueChanged(),this.Rebuild()}},{key:"AddStraightLine",value:function(e,t,r,n,i){return this.CreateItem({type:c.Type.STRAIGHT,position1:e,position2:t,color1:n,color2:i,width:r})}},{key:"AddCurvedLineCrt",value:function(e,t,r,n,i,a){return this.CreateItem({type:c.Type.CURVED,position1:e,position2:t,intermediatePosition:r,color1:i,color2:a,width:n,numOfSegments:c.DEFAULT_CURVED_SEGMENTS})}},{key:"AddCurvedLineSph",value:function(e,r,n,a,o,s,u){var l=t.global;return this.CreateItem({type:c.Type.CURVED,position1:i.vec3.fromSpherical(l.vec3_0,e,n),position2:i.vec3.fromSpherical(l.vec3_1,r,n),intermediatePosition:i.vec3.fromSpherical(l.vec3_2,a,n),color1:s,color2:u,width:o,numOfSegments:c.DEFAULT_CURVED_SEGMENTS})}},{key:"AddSpheredLineCrt",value:function(e,t,r,n,i,a){return this.CreateItem({type:c.Type.SPHERED,position1:e,position2:t,intermediatePosition:r,color1:i,color2:a,width:n,numOfSegments:c.DEFAULT_SPHERED_SEGEMENTS})}},{key:"AddSpheredLineSph",value:function(e,r,n,a,o,s,u){var l=t.global;return this.CreateItem({type:c.Type.SPHERED,position1:i.vec3.fromSpherical(l.vec3_0,e,n),position2:i.vec3.fromSpherical(l.vec3_1,r,n),intermediatePosition:i.vec3.fromSpherical(l.vec3_2,a,n),color1:s,color2:u,width:o,numOfSegments:c.DEFAULT_SPHERED_SEGEMENTS})}},{key:"OnValueChanged",value:function(){i.mat4.fromRotationTranslationScale(this.transform,this.rotation,this.translation,this.scaling),this._rebuildPending=!0}},{key:"UpdateViewDependentData",value:function(e){i.mat4.copy(this.parentTransform,e)}},{key:"Update",value:function(){this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){this._vb&&(i.device.gl.deleteBuffer(this._vb),this._vb=null)}},{key:"Rebuild",value:function(){t.RebuildItems(this),this._vb=null,this._vbSize=this.lineCount,this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=t.global,n=new Float32Array(6*this._vbSize*this._vertexSize),a=r.vec3_0,o=r.vec3_1,s=r.vec3_2,u=r.vec3_3,l=r.vec3_4,f=r.vec3_5,h=r.vec3_6,p=r.mat4_0,d=r.vec3_7,v=r.vec3_8,m=r.vec3_9,y=r.vec3_10,b=r.vec4_0,g=r.vec4_1,_=0,E=void 0,T=0;T0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","boneIndex","groupIndex","maskAtlasID","position","scaling","rotation","transform","color","layer1Transform","layer2Transform","layer1Scroll","layer2Scroll"]),t}}]),t}();(t.EvePlaneSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.effect=null,e.hideOnLowQuality=!1,e._time=0,e._vertexBuffer=null,e._indexBuffer=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,4,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,16)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,4,32)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,4,48)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,i.device.gl.FLOAT,4,64)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,i.device.gl.FLOAT,4,80)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,i.device.gl.FLOAT,4,96)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,6,i.device.gl.FLOAT,4,112)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,7,i.device.gl.FLOAT,3,128)),e._decl.RebuildHash(),e}return l(t,o.EveObjectSet),n(t,[{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),e}},{key:"Update",value:function(e){this._time+=e,this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){this._vertexBuffer&&(i.device.gl.deleteBuffer(this._vertexBuffer),this._vertexBuffer=null),this._indexBuffer&&(i.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"Rebuild",value:function(){this.Unload(),t.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=t.global.mat4_0,n=new Float32Array(4*e*35),a=0;a0&&void 0!==arguments[0]?arguments[0]:[];return this.parentGeometry&&!e.includes(this.parentGeometry)&&e.push(this.parentGeometry),this.decalEffect&&this.decalEffect.GetResources(e),this.pickEffect&&this.pickEffect.GetResources(e),e}},{key:"Unload",value:function(){this._indexBuffer&&(i.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"GetBatches",value:function(e,t,r,n){var o=void 0;switch(e){case i.device.RM_DECAL:o=this.decalEffect;break;case i.device.RM_PICKABLE:o=this.pickable?this.pickEffect:null}if(this.display&&o&&o.IsGood()&&this.indexBuffer.length&&this.parentGeometry&&this.parentGeometry.IsGood()){var s=new a.Tw2ForwardingRenderBatch;if(this._perObjectData.perObjectVSData.Set("worldMatrix",r.perObjectVSData.Get("WorldMat")),this.parentBoneIndex>=0){var u=r.perObjectVSData.Get("JointMat"),l=12*this.parentBoneIndex;if(u[l]||u[l+4]||u[l+8]){var c=this._perObjectData.perObjectVSData.Get("parentBoneMatrix");c[0]=u[l],c[1]=u[l+4],c[2]=u[l+8],c[3]=0,c[4]=u[l+1],c[5]=u[l+5],c[6]=u[l+9],c[7]=0,c[8]=u[l+2],c[9]=u[l+6],c[10]=u[l+10],c[11]=0,c[12]=u[l+3],c[13]=u[l+7],c[14]=u[l+11],c[15]=1,i.mat4.transpose(c,c)}}i.mat4.invert(this._perObjectData.perObjectVSData.Get("invWorldMatrix"),this._perObjectData.perObjectVSData.Get("worldMatrix")),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("decalMatrix"),this.decalMatrix),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("invDecalMatrix"),this.invDecalMatrix),this._perObjectData.perObjectPSData.Get("displayData")[0]=n||0,this._perObjectData.perObjectPSData.Set("shipData",r.perObjectPSData.data),s.perObjectData=this._perObjectData,s.geometryProvider=this,s.renderMode=e,s.effect=o,t.Commit(s)}}},{key:"Render",value:function(e,t){var r=this.parentGeometry.meshes[0].indexes,n=this.parentGeometry.meshes[0].areas[0].start,a=this.parentGeometry.meshes[0].areas[0].count,o=this.parentGeometry.meshes[0].indexType;i.store.SetVariableValue("u_DecalMatrix",this.decalMatrix),i.store.SetVariableValue("u_InvDecalMatrix",this.invDecalMatrix),this.parentGeometry.meshes[0].indexes=this._indexBuffer,this.parentGeometry.meshes[0].areas[0].start=0,this.parentGeometry.meshes[0].areas[0].count=this.indexBuffer.length,this.parentGeometry.meshes[0].indexType=i.device.gl.UNSIGNED_SHORT,this.parentGeometry.RenderAreas(0,0,1,e.effect,t),this.parentGeometry.meshes[0].indexes=r,this.parentGeometry.meshes[0].areas[0].start=n,this.parentGeometry.meshes[0].areas[0].count=a,this.parentGeometry.meshes[0].indexType=o}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveSpotlightSet=t.EveSpotlightSetItem=t.EveSpotlightSetBatch=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","boosterGainInfluence","boneIndex","groupIndex","coneIntensity","spriteIntensity","flareIntensity","transform","coneColor","spriteColor","flareColor","spriteScale"]),t}}]),t}();(t.EveSpotlightSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.coneEffect=null,e.glowEffect=null,e._coneVertexBuffer=null,e._spriteVertexBuffer=null,e._indexBuffer=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,4,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,4,16)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,32)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,4,48)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,i.device.gl.FLOAT,3,64)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,i.device.gl.FLOAT,3,76)),e._decl.RebuildHash(),e}return l(t,o.EveObjectSet),n(t,[{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.coneEffect&&this.coneEffect.GetResources(e),this.glowEffect&&this.glowEffect.GetResources(e),e}},{key:"Unload",value:function(){this._coneVertexBuffer&&(i.device.gl.deleteBuffer(this._coneVertexBuffer),this._coneVertexBuffer=null),this._spriteVertexBuffer&&(i.device.gl.deleteBuffer(this._spriteVertexBuffer),this._spriteVertexBuffer=null),this._indexBuffer&&(i.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"Rebuild",value:function(){this.Unload(),t.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=i.device,n=[1,0,2,3],a=new Float32Array(22*(4*e*4)),o=0;o0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","blinkRate","blinkPhase","minScale","maxScale","falloff","boneIndex","groupIndex","position","color","warpColor"]),t}}]),t}();(t.EveSpriteSet=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];s(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.effect=null,n.useQuads=null,n.isSkinned=null,n._time=0,n._vertexBuffer=null,n._indexBuffer=null,n._instanceBuffer=null,n._decl=n._decl=new a.Tw2VertexDeclaration,n._vdecl=new a.Tw2VertexDeclaration,n._vdecl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,i.device.gl.FLOAT,1,0)),n._vdecl.RebuildHash(),n.UseQuads(e,r),n}return l(t,o.EveObjectSet),n(t,[{key:"UseQuads",value:function(e,t){this.useQuads!==e&&(this.useQuads=e,this.isSkinned=t,this._decl.elements.splice(0,this._decl.elements.length),e?(this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,i.device.gl.FLOAT,3,0)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,4,12)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,2,28)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,4,36)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,1,i.device.gl.FLOAT,4,52))):(this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,i.device.gl.FLOAT,2,0)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,i.device.gl.FLOAT,3,8)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,3,20)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,1,32)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,1,36)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,1,40)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,i.device.gl.FLOAT,1,44)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,i.device.gl.FLOAT,1,48))),this._decl.RebuildHash(),this._rebuildPending=!0)}},{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),e}},{key:"Update",value:function(e){this._time+=e,this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){this._vertexBuffer&&(i.device.gl.deleteBuffer(this._vertexBuffer),this._vertexBuffer=null),this._indexBuffer&&(i.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null),this._instanceBuffer&&(i.device.gl.deleteBuffer(this._instanceBuffer),this._instanceBuffer=null)}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){var t=i.device;if(this.useQuads)return this._vertexBuffer=t.gl.createBuffer(),t.gl.bindBuffer(t.gl.ARRAY_BUFFER,this._vertexBuffer),t.gl.bufferData(t.gl.ARRAY_BUFFER,new Float32Array([0,1,2,2,3,0]),t.gl.STATIC_DRAW),t.gl.bindBuffer(t.gl.ARRAY_BUFFER,null),void(this._instanceBuffer=t.gl.createBuffer());for(var r=new Float32Array(4*e*13),n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","locatorName","updateFromLocator","position","rotation","bone","canFireWhenHidden"]),t.UpdateTransforms(),t}}]),t}(),f=t.EveTurretSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.visible={},e.visible.turrets=!0,e.visible.firingEffects=!0,e.activeAnimation=new a.Tw2AnimationController,e.inactiveAnimation=new a.Tw2AnimationController,e.geometryResPath="",e.geometryResource=null,e.turretEffect=null,e.firingEffectResPath="",e.firingEffect=null,e.fireCallback=null,e.fireCallbackPending=!1,e.state=t.State.IDLE,e.bottomClipHeight=0,e.locatorName="",e.sysBoneHeight=0,e.hasCyclingFiringPos=!1,e.targetPosition=i.vec3.create(),e.parentMatrix=i.mat4.create(),e.boundingSphere=i.quat.create(),e._activeTurret=-1,e._recheckTimeLeft=0,e._currentCyclingFiresPos=0,e._perObjectDataActive=new a.Tw2PerObjectData,e._perObjectDataActive.perObjectVSData=new a.Tw2RawData,e._perObjectDataActive.perObjectVSData.Declare("baseCutoffData",4),e._perObjectDataActive.perObjectVSData.Declare("turretSetData",4),e._perObjectDataActive.perObjectVSData.Declare("shipMatrix",16),e._perObjectDataActive.perObjectVSData.Declare("turretTranslation",96),e._perObjectDataActive.perObjectVSData.Declare("turretRotation",96),e._perObjectDataActive.perObjectVSData.Declare("turretPoseTransAndRot",576),e._perObjectDataActive.perObjectVSData.Create(),e._perObjectDataInactive=new a.Tw2PerObjectData,e._perObjectDataInactive.perObjectVSData=new a.Tw2RawData,e._perObjectDataInactive.perObjectVSData.Declare("baseCutoffData",4),e._perObjectDataInactive.perObjectVSData.Declare("turretSetData",4),e._perObjectDataInactive.perObjectVSData.Declare("shipMatrix",16),e._perObjectDataInactive.perObjectVSData.Declare("turretTranslation",96),e._perObjectDataInactive.perObjectVSData.Declare("turretRotation",96),e._perObjectDataInactive.perObjectVSData.Declare("turretPoseTransAndRot",576),e._perObjectDataInactive.perObjectVSData.Create(),e._locatorRebuildPending=!0,e}return l(t,o.EveObjectSet),n(t,[{key:"Initialize",value:function(){var e=this;this.turretEffect&&""!==this.geometryResPath&&(this.geometryResource=i.resMan.GetResource(this.geometryResPath),this.activeAnimation.SetGeometryResource(this.geometryResource),this.inactiveAnimation.SetGeometryResource(this.geometryResource),this.geometryResource&&this.geometryResource.RegisterNotification(this)),""!==this.firingEffectResPath&&i.resMan.GetObject(this.firingEffectResPath,function(t){return e.firingEffect=t}),this.Rebuild()}},{key:"InitializeFiringEffect",value:function(){if(this.firingEffect&&this.geometryResource&&this.geometryResource.models.length)for(var e=this.geometryResource.models[0],r=0;rr&&(e=this.items.indexOf(l),r=c)}}return e}},{key:"EnterStateDeactive",value:function(){var e=this;this.state!==t.State.INACTIVE&&this.state!==t.State.PACKING&&(this.turretEffect?(this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.activeAnimation.PlayAnimation("Pack",!1,function(){e.state=t.State.INACTIVE,e.activeAnimation.PlayAnimation("Inactive",!0)}),this.inactiveAnimation.PlayAnimation("Pack",!1,function(){e.state=t.State.INACTIVE,e.inactiveAnimation.PlayAnimation("Inactive",!0)}),this.state=t.State.PACKING):this.state=t.State.INACTIVE,this._activeTurret=-1,this.firingEffect&&this.firingEffect.StopFiring())}},{key:"EnterStateIdle",value:function(){var e=this;this.state!==t.State.IDLE&&this.state!==t.State.UNPACKING&&(this.turretEffect?(this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.state===t.State.FIRING?(this.activeAnimation.PlayAnimation("Active",!0),this.inactiveAnimation.PlayAnimation("Active",!0)):(this.activeAnimation.PlayAnimation("Deploy",!1,function(){e.state=t.State.IDLE,e.activeAnimation.PlayAnimation("Active",!0)}),this.inactiveAnimation.PlayAnimation("Deploy",!1,function(){e.state=t.State.IDLE,e.inactiveAnimation.PlayAnimation("Active",!0)})),this.state=t.State.UNPACKING):this.state=t.State.IDLE,this._activeTurret=-1,this.firingEffect&&this.firingEffect.StopFiring())}},{key:"EnterStateFiring",value:function(){var e=this;if(!this.turretEffect||this.state===t.State.FIRING)return t.DoStartFiring(this),void(this.turretEffect&&this.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)}));this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.state===t.State.INACTIVE?(this.activeAnimation.PlayAnimation("Deploy",!1,function(){t.DoStartFiring(e),e.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)})}),this.inactiveAnimation.PlayAnimation("Deploy",!1,function(){e.inactiveAnimation.PlayAnimation("Active",!0)}),this.state=t.State.UNPACKING):(t.DoStartFiring(this),this.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)}),this.inactiveAnimation.PlayAnimation("Active",!0))}},{key:"RebuildCachedData",value:function(){for(var e=new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,2),r=this.geometryResource.meshes,n=this.activeAnimation,o=this.inactiveAnimation,s=0;s0&&void 0!==arguments[0]?arguments[0]:[];return this.geometryResource&&!e.includes(this.geometryResource)&&e.push(this.geometryResource),this.turretEffect&&this.turretEffect.GetResources(e),this.firingEffect&&this.firingEffect.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(){this.firingEffect&&this.firingEffect.UpdateViewDependentData()}},{key:"Update",value:function(e,r){if(this._rebuildPending&&this.Rebuild(),this.turretEffect&&(this.activeAnimation.Update(e),this.inactiveAnimation.Update(e)),i.mat4.copy(this.parentMatrix,r),this.firingEffect&&this._visibleItems.length){if(-1!==this._activeTurret){this.firingEffect.isLoopFiring&&this.state===t.State.FIRING&&(this._recheckTimeLeft-=e,this._recheckTimeLeft<=0&&t.DoStartFiring(this));var n=this.items[this._activeTurret];if(this.activeAnimation.models.length)for(var a=this.activeAnimation.models[0].bonesByName,o=0;o0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1],r=0;r2&&void 0!==arguments[2]?arguments[2]:this._batches,n=0;n=0&&(u=e.substr(0,s+1)+o+"/"+e.substr(s+1)),(s=u.lastIndexOf("_"))>=0){u=u.substr(0,s)+"_"+o+u.substr(s);var l=r(n,"textureOverrides",{});if(t in l&&i.name in l[t])return u}}return e}function f(e,t){var r=l(t),n=(e="/"+e).lastIndexOf("/");return e.substr(0,n+1)+r+e.substr(n+1)}function h(e,t){for(var r=0;r=0&&s=0?r||T:t||(r||T);case"not_overridable":case"half_overridable_2":return r||T}return T}function w(t,r,a){var o=e.faction[r],s=e.faction[a],u=null;o&&o.areas&&"hull"in o.areas&&(u=o.areas.hull);var l=null;if(s&&s.areas&&"hull"in s.areas&&(l=s.areas.hull),(u||l)&&t.turretEffect){var c=t.turretEffect.parameters;for(var f in c)if(c.hasOwnProperty(f)){if(c[f].constructor.prototype!==i.Tw2Vector4Parameter.prototype)continue;var h=null,p=null;u&&(h=E(f,o,u)),l&&(p=E(f,o,u)),n.vec4.copy(c[f].value,O(f,h,p,t.turretEffect.name))}t.turretEffect.BindParameters()}}function S(t){if("all"!==t){var r={};for(var n in e[t])e[t].hasOwnProperty(n)&&(r[n]=e[t][n].description||"");return r}return e}this.SetupTurretMaterial=function(t,r,n,i){null===e?this.LoadData(function(){w(t,r,n),i&&i()}):(w(t,r,n),i&&i())},this.GetHullNames=function(e){this.LoadData(function(){e(S("hull"))})},this.GetFactionNames=function(e){this.LoadData(function(){e(S("faction"))})},this.GetRaceNames=function(e){this.LoadData(function(){e(S("race"))})},this.GetSofData=function(e){this.LoadData(function(){e(S("all"))})}};var n=r(0),i=r(1),a=r(58),o=r(64),s=r(59),u=r(61)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(186);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(190);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(197);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(201);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(202);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(14);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(187);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(188);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(189);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2StaticEmitter=void 0;var n=function(){function e(e,t){for(var r=0;rthis.geometryIndex&&this.geometryResource.meshes[this.geometryIndex].bufferData){this._spawned=!0;for(var e=this.geometryResource.meshes[this.geometryIndex],t=this.particleSystem.elements,r=new Array(t.length),n=0;n=this.maxParticleCount?null:this.aliveCount++}},{key:"EndSpawnParticle",value:function(){this.bufferDirty=!0}},{key:"Update",value:function(t){if(t=Math.min(t,.1),this.applyAging&&this.HasElement(o.Tw2ParticleElementDeclaration.Type.LIFETIME)){for(var r=this.GetElement(o.Tw2ParticleElementDeclaration.Type.LIFETIME),n=this.emitParticleOnDeathEmitter?this.GetElement(o.Tw2ParticleElementDeclaration.Type.POSITION):null,a=this.emitParticleOnDeathEmitter?this.GetElement(o.Tw2ParticleElementDeclaration.Type.VELOCITY):null,s=0;s1){if(this.emitParticleOnDeathEmitter&&this.emitParticleOnDeathEmitter.SpawnParticles(n,a,1),this.aliveCount--,s=n&&t>=n)return et?1:0;if(e>=n)return 1;if(t>=n)return-1;var r=a[e],i=a[t];return ri?-1:0})}},{key:"GetInstanceBuffer",value:function(){if(0!==this.aliveCount){var e=i.device;if(this.requiresSorting&&this.HasElement(o.Tw2ParticleElementDeclaration.Type.POSITION)&&this.buffers){this._Sort();for(var t=this.instanceStride[0],r=this.buffers[0],n=0;n 1) - { - for (var i = 0; i < declaration.elements[elementIndex].elements; ++i) - { - data[index][elementIndex][i] = value[i]; - } - } - else - { - data[index][elementIndex] = value; - } - - dataDirty = true; - }; - - /** - * SetItemElementRef - * @param index - * @param elementIndex - * @param value - * @constructor - */ - this.SetItemElementRef = function(index, elementIndex, value) - { - data[index][elementIndex] = value; - dataDirty = true; - }; - - /** - * GetItemElement - * @param index - * @param elementIndex - * @returns {*} - * @method - */ - this.GetItemElement = function(index, elementIndex) - { - return data[index][elementIndex]; - }; - - /** - * UpdateData - * @method - */ - this.UpdateData = function() - { - if (!dataDirty || !declaration) - { - return; - } - - var vbData = new Float32Array(data.length * vertexStride); - var offset = 0; - var i, j, k; - - for (i = 0; i < data.length; ++i) - { - for (j = 0; j < declaration.elements.length; ++j) - { - if (declaration.elements[j].elements === 1) - { - vbData[offset++] = data[i][j]; - } - else - { - for (k = 0; k < declaration.elements[j].elements; ++k) - { - vbData[offset++] = data[i][j][k]; - } - } - } - } - - if (!vb) - { - vb = device.gl.createBuffer(); - } - - device.gl.bindBuffer(device.gl.ARRAY_BUFFER, vb); - device.gl.bufferData(device.gl.ARRAY_BUFFER, vbData, device.gl.STATIC_DRAW); - device.gl.bindBuffer(device.gl.ARRAY_BUFFER, null); - dataDirty = false; - }; - - /** - * Unloads the webgl buffer - * @method - */ - this.Unload = function() - { - if (vb) - { - device.gl.deleteBuffer(vb); - vb = null; - } - }; - - /** - * GetInstanceBuffer - * @returns {WebglArrayBuffer} - * @method - */ - this.GetInstanceBuffer = function() - { - return vb; - }; - - /** - * GetInstanceDeclaration - * @returns {Tw2VertexDeclaration} - * @method - */ - this.GetInstanceDeclaration = function() - { - return declaration; - }; - - /** - * GetInstanceStride - * @returns {number} - * @method - */ - this.GetInstanceStride = function() - { - return vertexStride * 4; - }; - - /** - * GetInstanceCount - * @returns {number} - * @method - */ - this.GetInstanceCount = function() - { - return count; - }; -} diff --git a/src/core/deprecated/Tw2VariableStore.js b/src/core/deprecated/Tw2VariableStore.js deleted file mode 100644 index f2cc383..0000000 --- a/src/core/deprecated/Tw2VariableStore.js +++ /dev/null @@ -1,96 +0,0 @@ -import {util} from '../../math'; -import { - Tw2MatrixParameter, - Tw2Vector4Parameter, - Tw2Vector3Parameter, - Tw2Vector2Parameter, - Tw2FloatParameter, - Tw2TextureParameter -} from '../parameter/index'; - -/** - * Tw2VariableStore - * @property {Object.< string, Parameter>} _variables - * @constructor - */ -export class Tw2VariableStore -{ - constructor() - { - this._variables = {}; - } - - /** - * Registers a variable - * @param {string} name - * @param {string|number|Float32Array|vec3|mat4} value - * @param {Parameter} type - * @returns {Parameter} - * @constructor - */ - RegisterVariableWithType(name, value, type) - { - return this._variables[name] = new type(name, value); - } - - /** - * Registers a variable without a value - * @param {string} name - * @param {Parameter} type - * @returns {Parameter} - * @constructor - */ - RegisterType(name, type) - { - return this._variables[name] = new type(name); - } - - /** - * Registers a variable without a type - * @param {string} name - * @param {string|number|Float32Array} value - * @returns {Parameter} - */ - RegisterVariable(name, value) - { - const Type = Tw2VariableStore.GetTw2ParameterType(value); - return Type ? this.RegisterVariableWithType(name, value, Type) : null; - } - - /** - * Gets A Tw2 parameter constructor from a supplied value - * @param {Number|String|Array.|Float32Array} value - * @returns {null|Parameter} - */ - static GetTw2ParameterType(value) - { - if (util.isArrayLike(value)) - { - switch (value.length) - { - case 16: - return Tw2MatrixParameter; - - case 4: - return Tw2Vector4Parameter; - - case 3: - return Tw2Vector3Parameter; - - case 2: - return Tw2Vector2Parameter; - - case 1: - return Tw2FloatParameter; - } - } - else if (typeof(value) === 'number') - { - return Tw2FloatParameter; - } - else if (typeof(value) === 'string') - { - return Tw2TextureParameter; - } - } -} \ No newline at end of file diff --git a/src/core/deprecated/index.js b/src/core/deprecated/index.js deleted file mode 100644 index 103db73..0000000 --- a/src/core/deprecated/index.js +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Tw2RuntimeInstanceData'; -export * from './Tw2VariableStore'; \ No newline at end of file diff --git a/src/core/geometry/Tw2GeometryBone.js b/src/core/geometry/Tw2GeometryBone.js index 0f4bd69..6209378 100644 --- a/src/core/geometry/Tw2GeometryBone.js +++ b/src/core/geometry/Tw2GeometryBone.js @@ -1,4 +1,4 @@ -import {mat3, mat4, quat, vec3} from '../../math'; +import {mat3, mat4, quat, vec3} from '../../global'; /** * Tw2GeometryBone diff --git a/src/core/geometry/Tw2GeometryMesh.js b/src/core/geometry/Tw2GeometryMesh.js index a6b2206..63d4f47 100644 --- a/src/core/geometry/Tw2GeometryMesh.js +++ b/src/core/geometry/Tw2GeometryMesh.js @@ -1,4 +1,4 @@ -import {vec3} from '../../math'; +import {vec3} from '../../global'; import {Tw2VertexDeclaration} from '../vertex'; /** diff --git a/src/core/geometry/Tw2GeometryMeshArea.js b/src/core/geometry/Tw2GeometryMeshArea.js index 76630ff..1f0e9be 100644 --- a/src/core/geometry/Tw2GeometryMeshArea.js +++ b/src/core/geometry/Tw2GeometryMeshArea.js @@ -1,4 +1,4 @@ -import {vec3} from '../../math'; +import {vec3} from '../../global'; /** * Tw2GeometryMeshArea diff --git a/src/core/global/index.js b/src/core/global/index.js deleted file mode 100644 index eb9b8d5..0000000 --- a/src/core/global/index.js +++ /dev/null @@ -1,4 +0,0 @@ -export * from './Tw2Device'; -export * from './Tw2ResMan'; -export * from './Tw2Store'; -export * from './Tw2Logger'; \ No newline at end of file diff --git a/src/core/index.js b/src/core/index.js index d251fe4..7a55139 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -1,8 +1,6 @@ export * from './batch'; export * from './curve'; export * from './data'; -export * from './deprecated'; -export * from './global'; export * from './geometry'; export * from './mesh'; export * from './model'; @@ -13,7 +11,8 @@ export * from './resource'; export * from './sampler'; export * from './vertex'; +export * from './Tw2Error'; +export * from './Tw2EventEmitter'; export * from './Tw2Float'; export * from './Tw2Frustum'; -export * from './Tw2RenderTarget'; -export * from './Tw2EventEmitter'; \ No newline at end of file +export * from './Tw2RenderTarget'; \ No newline at end of file diff --git a/src/core/mesh/Tw2Effect.js b/src/core/mesh/Tw2Effect.js index 05696de..6b88bc9 100644 --- a/src/core/mesh/Tw2Effect.js +++ b/src/core/mesh/Tw2Effect.js @@ -1,5 +1,4 @@ -import {util} from '../../math'; -import {resMan, device, store} from '../global'; +import {util, resMan, device, store} from '../../global'; import {Tw2TextureParameter} from '../parameter/Tw2TextureParameter'; /** diff --git a/src/core/mesh/Tw2InstancedMesh.js b/src/core/mesh/Tw2InstancedMesh.js index a66a289..32065fe 100644 --- a/src/core/mesh/Tw2InstancedMesh.js +++ b/src/core/mesh/Tw2InstancedMesh.js @@ -1,5 +1,4 @@ -import {resMan} from '../global/Tw2ResMan'; -import {vec3} from '../../math'; +import {vec3, resMan} from '../../global'; import {Tw2InstancedMeshBatch} from '../batch'; import {Tw2Mesh} from './Tw2Mesh'; diff --git a/src/core/mesh/Tw2Mesh.js b/src/core/mesh/Tw2Mesh.js index d96a872..54ab528 100644 --- a/src/core/mesh/Tw2Mesh.js +++ b/src/core/mesh/Tw2Mesh.js @@ -1,6 +1,4 @@ -import {util} from '../../math'; -import {resMan} from '../global/Tw2ResMan'; -import {device} from '../global/Tw2Device'; +import {util, resMan, device} from '../../global'; /** * Tw2Mesh diff --git a/src/core/mesh/Tw2MeshArea.js b/src/core/mesh/Tw2MeshArea.js index 731fd23..839f5bb 100644 --- a/src/core/mesh/Tw2MeshArea.js +++ b/src/core/mesh/Tw2MeshArea.js @@ -1,5 +1,5 @@ import {Tw2GeometryBatch} from '../batch'; -import {util} from '../../math'; +import {util} from '../../global'; /** * Tw2MeshArea diff --git a/src/core/model/Tw2AnimationController.js b/src/core/model/Tw2AnimationController.js index 125af7a..fa8ee64 100644 --- a/src/core/model/Tw2AnimationController.js +++ b/src/core/model/Tw2AnimationController.js @@ -1,4 +1,4 @@ -import {vec3, quat, mat3, mat4, curve} from '../../math'; +import {vec3, quat, mat3, mat4, curve, util} from '../../global'; import {Tw2GeometryRes} from '../resource'; import {Tw2Animation} from './Tw2Animation'; import {Tw2Bone} from './Tw2Bone'; @@ -115,7 +115,7 @@ export class Tw2AnimationController animation.time = 0; animation.isPlaying = true; - if (typeof(cycle) !== 'undefined') + if (!util.isUndefined(cycle)) { animation.cycle = cycle; } @@ -154,7 +154,7 @@ export class Tw2AnimationController animation.time = Math.max(Math.min(from, animation.animationRes.duration), 0); animation.isPlaying = true; - if (typeof(cycle) !== 'undefined') + if (!util.isUndefined(cycle)) { animation.cycle = cycle; } @@ -200,10 +200,7 @@ export class Tw2AnimationController return; } - if (typeof names === 'string' || names instanceof String) - { - names = [names]; - } + names = util.toArray(names); const toStop = {}; for (let n = 0; n < names.length; n++) @@ -255,10 +252,7 @@ export class Tw2AnimationController return; } - if (typeof names === 'string' || names instanceof String) - { - names = [names]; - } + util.toArray(names); const keepAnimating = {}; for (let n = 0; n < names.length; n++) diff --git a/src/core/model/Tw2Bone.js b/src/core/model/Tw2Bone.js index 4a99cd2..db3191c 100644 --- a/src/core/model/Tw2Bone.js +++ b/src/core/model/Tw2Bone.js @@ -1,4 +1,4 @@ -import {mat4} from '../../math'; +import {mat4} from '../../global'; /** * Tw2Bone diff --git a/src/core/parameter/Tw2FloatParameter.js b/src/core/parameter/Tw2FloatParameter.js index be991ec..10fb3f9 100644 --- a/src/core/parameter/Tw2FloatParameter.js +++ b/src/core/parameter/Tw2FloatParameter.js @@ -1,5 +1,5 @@ import {Tw2Parameter} from './Tw2Parameter'; -import {util} from '../../math'; +import {util} from '../../global'; /** * Tw2FloatParameter @@ -74,14 +74,18 @@ export class Tw2FloatParameter extends Tw2Parameter } /** - * Checks if a value is a valid value - * @param {number} value + * Checks if a value is a valid parameter value + * @param {number} a * @returns {boolean} */ - static is(value) + static isValue(a) { - return typeof value === 'number'; + return util.isNumber(a); } } -Tw2FloatParameter.size = 1; +/** + * Float parameter's constant buffer size + * @type {number} + */ +Tw2FloatParameter.constantBufferSize = 1; diff --git a/src/core/parameter/Tw2MatrixParameter.js b/src/core/parameter/Tw2MatrixParameter.js index de38742..aa19053 100644 --- a/src/core/parameter/Tw2MatrixParameter.js +++ b/src/core/parameter/Tw2MatrixParameter.js @@ -1,4 +1,4 @@ -import {mat4} from '../../math'; +import {mat4} from '../../global'; import {Tw2VectorParameter} from './Tw2Parameter'; /** diff --git a/src/core/parameter/Tw2Parameter.js b/src/core/parameter/Tw2Parameter.js index 1b7dc41..7e134ad 100644 --- a/src/core/parameter/Tw2Parameter.js +++ b/src/core/parameter/Tw2Parameter.js @@ -1,5 +1,5 @@ /* eslint no-unused-vars:0 */ -import { util } from '../../math'; +import { util } from '../../global'; /** * Tw2Parameter base class @@ -70,11 +70,11 @@ export class Tw2Parameter /** * Gets the parameter's value * @param {boolean} [serialize] - forces serialized result - * @returns {null} + * @returns {*} */ GetValue(serialize) { - return null; + } /** @@ -299,8 +299,14 @@ export class Tw2VectorParameter extends Tw2Parameter * @param {Float32Array|Array} value * @returns {boolean} */ - static is(value) + static isValue(value) { return (util.isArrayLike(value) && value.length === this.constantBufferSize); } } + +/** + * The parameter's constantBufferSize + * @type {number} + */ +Tw2VectorParameter.constantBufferSize = 0; diff --git a/src/core/parameter/Tw2TextureParameter.js b/src/core/parameter/Tw2TextureParameter.js index f9cff2f..fc2aa8f 100644 --- a/src/core/parameter/Tw2TextureParameter.js +++ b/src/core/parameter/Tw2TextureParameter.js @@ -1,8 +1,6 @@ -import {resMan} from '../global/Tw2ResMan'; -import {device} from '../global/Tw2Device'; +import {resMan, device, util} from '../../global'; import {Tw2SamplerState} from '../sampler'; import {Tw2Parameter} from './Tw2Parameter'; -import {util} from '../../math'; /** * Tw2TextureParameter @@ -259,13 +257,13 @@ export class Tw2TextureParameter extends Tw2Parameter } /** - * - * @param value + * Checks if a value is a valid parameter value + * @param {*} a * @returns {boolean} */ - static is(value) + static isValue(a) { - return typeof value === 'string'; + return util.isString(a); } } diff --git a/src/core/parameter/Tw2TransformParameter.js b/src/core/parameter/Tw2TransformParameter.js index a5b8fcd..7af618a 100644 --- a/src/core/parameter/Tw2TransformParameter.js +++ b/src/core/parameter/Tw2TransformParameter.js @@ -1,4 +1,4 @@ -import {vec3, quat, mat4} from '../../math'; +import {vec3, quat, mat4} from '../../global'; import {Tw2Parameter} from './Tw2Parameter'; /** diff --git a/src/core/parameter/Tw2VariableParameter.js b/src/core/parameter/Tw2VariableParameter.js index 947a8aa..f202a8c 100644 --- a/src/core/parameter/Tw2VariableParameter.js +++ b/src/core/parameter/Tw2VariableParameter.js @@ -1,4 +1,4 @@ -import {store} from '../global/Tw2Store'; +import {store} from '../../global'; import {Tw2Parameter} from './Tw2Parameter'; /** diff --git a/src/core/parameter/Tw2Vector2Parameter.js b/src/core/parameter/Tw2Vector2Parameter.js index 74ee44b..514554c 100644 --- a/src/core/parameter/Tw2Vector2Parameter.js +++ b/src/core/parameter/Tw2Vector2Parameter.js @@ -1,4 +1,4 @@ -import {vec2} from '../../math'; +import {vec2} from '../../global'; import {Tw2VectorParameter} from './Tw2Parameter'; /** diff --git a/src/core/parameter/Tw2Vector3Parameter.js b/src/core/parameter/Tw2Vector3Parameter.js index 16f8f0b..0081da0 100644 --- a/src/core/parameter/Tw2Vector3Parameter.js +++ b/src/core/parameter/Tw2Vector3Parameter.js @@ -1,4 +1,4 @@ -import {vec3} from '../../math'; +import {vec3} from '../../global'; import {Tw2VectorParameter} from './Tw2Parameter'; /** diff --git a/src/core/parameter/Tw2Vector4Parameter.js b/src/core/parameter/Tw2Vector4Parameter.js index 4a0434d..ad55990 100644 --- a/src/core/parameter/Tw2Vector4Parameter.js +++ b/src/core/parameter/Tw2Vector4Parameter.js @@ -1,4 +1,4 @@ -import {vec4} from '../../math'; +import {vec4} from '../../global'; import {Tw2VectorParameter} from './Tw2Parameter'; /** diff --git a/src/core/post/Tw2PostProcess.js b/src/core/post/Tw2PostProcess.js index 01cdc2e..0044ca5 100644 --- a/src/core/post/Tw2PostProcess.js +++ b/src/core/post/Tw2PostProcess.js @@ -1,4 +1,4 @@ -import {device} from '../global'; +import {device} from '../../global'; import {Tw2RenderTarget} from '../Tw2RenderTarget'; import {Tw2Effect} from '../mesh'; import {Tw2TextureRes} from '../resource'; diff --git a/src/core/reader/Tw2ObjectReader.js b/src/core/reader/Tw2ObjectReader.js index 9603f93..e0b67dc 100644 --- a/src/core/reader/Tw2ObjectReader.js +++ b/src/core/reader/Tw2ObjectReader.js @@ -1,5 +1,4 @@ -import {logger} from '../global/Tw2Logger'; -import {store} from '../global/Tw2Store'; +import {logger, store} from '../../global'; import {Tw2BinaryReader} from './Tw2BinaryReader'; /** diff --git a/src/core/resource/Tw2EffectRes.js b/src/core/resource/Tw2EffectRes.js index c05db86..1e3caaa 100644 --- a/src/core/resource/Tw2EffectRes.js +++ b/src/core/resource/Tw2EffectRes.js @@ -1,4 +1,4 @@ -import {logger} from '../global/Tw2Logger'; +import {logger} from '../../global'; import {Tw2BinaryReader} from '../reader'; import {Tw2Resource} from './Tw2Resource'; import {Tw2Shader} from './Tw2Shader'; diff --git a/src/core/resource/Tw2GeometryRes.js b/src/core/resource/Tw2GeometryRes.js index 931dd4a..9f1ce80 100644 --- a/src/core/resource/Tw2GeometryRes.js +++ b/src/core/resource/Tw2GeometryRes.js @@ -1,6 +1,4 @@ -import {vec3, quat, mat3, mat4} from '../../math'; -import {device} from '../global/Tw2Device'; -import {logger} from '../global/Tw2Logger'; +import {vec3, quat, mat3, mat4, device, logger} from '../../global'; import {Tw2BinaryReader} from '../reader'; import {Tw2VertexElement} from '../vertex'; import {Tw2Resource} from './Tw2Resource'; @@ -186,7 +184,7 @@ export class Tw2GeometryRes extends Tw2Resource bone.parentIndex = reader.ReadUInt8(); if (bone.parentIndex === 255) bone.parentIndex = -1; - if ((flags & 1) != 0) + if ((flags & 1) !== 0) { vec3.set(bone.position, reader.ReadFloat32(), reader.ReadFloat32(), reader.ReadFloat32()); } @@ -195,7 +193,7 @@ export class Tw2GeometryRes extends Tw2Resource vec3.set(bone.position, 0, 0, 0); } - if ((flags & 2) != 0) + if ((flags & 2) !== 0) { quat.set(bone.orientation, reader.ReadFloat32(), reader.ReadFloat32(), reader.ReadFloat32(), reader.ReadFloat32()); } @@ -204,7 +202,7 @@ export class Tw2GeometryRes extends Tw2Resource quat.identity(bone.orientation); } - if ((flags & 4) != 0) + if ((flags & 4) !== 0) { for (let k = 0; k < 9; ++k) { @@ -635,7 +633,7 @@ export class Tw2GeometryRes extends Tw2Resource switch (el.fileType & 0xf) { case 0: - if ((el.fileType & 0x10) != 0) + if ((el.fileType & 0x10) !== 0) { for (let i = 0; i < el.elements; ++i) { @@ -652,7 +650,7 @@ export class Tw2GeometryRes extends Tw2Resource break; case 1: - if ((el.fileType & 0x10) != 0) + if ((el.fileType & 0x10) !== 0) { for (let i = 0; i < el.elements; ++i) { @@ -690,7 +688,7 @@ export class Tw2GeometryRes extends Tw2Resource break; case 8: - if ((el.fileType & 0x10) != 0) + if ((el.fileType & 0x10) !== 0) { for (let i = 0; i < el.elements; ++i) { @@ -707,7 +705,7 @@ export class Tw2GeometryRes extends Tw2Resource break; case 9: - if ((el.fileType & 0x10) != 0) + if ((el.fileType & 0x10) !== 0) { for (let i = 0; i < declaration.elements[declIx].elements; ++i) { diff --git a/src/core/resource/Tw2LoadingObject.js b/src/core/resource/Tw2LoadingObject.js index 6ce03ab..ee986ea 100644 --- a/src/core/resource/Tw2LoadingObject.js +++ b/src/core/resource/Tw2LoadingObject.js @@ -1,5 +1,4 @@ -import {resMan} from '../global/Tw2ResMan'; -import {logger} from '../global/Tw2Logger'; +import {resMan, logger} from '../../global'; import {Tw2Resource} from './Tw2Resource'; import {Tw2ObjectReader} from '../reader/Tw2ObjectReader'; diff --git a/src/core/resource/Tw2Resource.js b/src/core/resource/Tw2Resource.js index e4ad194..7d1f9f4 100644 --- a/src/core/resource/Tw2Resource.js +++ b/src/core/resource/Tw2Resource.js @@ -1,4 +1,4 @@ -import {resMan} from '../global/Tw2ResMan'; +import {resMan} from '../../global'; /** * Tw2Resource base class diff --git a/src/core/resource/Tw2Shader.js b/src/core/resource/Tw2Shader.js index 6d03c1b..9fc1df2 100644 --- a/src/core/resource/Tw2Shader.js +++ b/src/core/resource/Tw2Shader.js @@ -1,7 +1,5 @@ -import {device} from '../global/Tw2Device'; -import {logger} from '../global'; +import {quat, util, device, logger} from '../../global'; import {Tw2VertexDeclaration, Tw2VertexElement} from '../vertex'; -import {quat} from '../../math'; import {Tw2SamplerState} from '../sampler'; /** @@ -460,7 +458,7 @@ export class Tw2Shader } else { - let source = prefix + (typeof shaderCode === 'string' ? shaderCode : String.fromCharCode.apply(null, shaderCode)); + let source = prefix + (util.isString(shaderCode) ? shaderCode : String.fromCharCode.apply(null, shaderCode)); source = source.substr(0, source.length - 1); d.gl.shaderSource(shader, source); d.gl.compileShader(shader); diff --git a/src/core/resource/Tw2TextureRes.js b/src/core/resource/Tw2TextureRes.js index f176d50..113cffa 100644 --- a/src/core/resource/Tw2TextureRes.js +++ b/src/core/resource/Tw2TextureRes.js @@ -1,6 +1,4 @@ -import {resMan} from '../global/Tw2ResMan'; -import {device} from '../global/Tw2Device'; -import {logger} from '../global/Tw2Logger'; +import {resMan, device, logger} from '../../global'; import {Tw2Resource} from './Tw2Resource'; /** diff --git a/src/core/resource/Tw2VideoRes.js b/src/core/resource/Tw2VideoRes.js index 2a7ef81..f344770 100644 --- a/src/core/resource/Tw2VideoRes.js +++ b/src/core/resource/Tw2VideoRes.js @@ -1,6 +1,4 @@ -import {device} from '../global/Tw2Device'; -import {resMan} from '../global/Tw2ResMan'; -import {logger} from '../global/Tw2Logger'; +import {device, resMan, logger} from '../../global'; import {Tw2Resource} from './Tw2Resource'; /** diff --git a/src/core/sampler/Tw2SamplerOverride.js b/src/core/sampler/Tw2SamplerOverride.js index 4d7e180..78889ee 100644 --- a/src/core/sampler/Tw2SamplerOverride.js +++ b/src/core/sampler/Tw2SamplerOverride.js @@ -1,4 +1,4 @@ -import {device} from '../global/Tw2Device'; +import {device} from '../../global'; import {Tw2SamplerState} from './Tw2SamplerState'; /** diff --git a/src/core/sampler/Tw2SamplerState.js b/src/core/sampler/Tw2SamplerState.js index 2d7b973..9a17846 100644 --- a/src/core/sampler/Tw2SamplerState.js +++ b/src/core/sampler/Tw2SamplerState.js @@ -1,4 +1,4 @@ -import {device} from '../global/Tw2Device'; +import {device} from '../../global'; /** * Tw2SamplerState diff --git a/src/core/vertex/Tw2VertexDeclaration.js b/src/core/vertex/Tw2VertexDeclaration.js index 233a919..126715f 100644 --- a/src/core/vertex/Tw2VertexDeclaration.js +++ b/src/core/vertex/Tw2VertexDeclaration.js @@ -1,4 +1,4 @@ -import {device} from '../global/Tw2Device'; +import {util, device} from '../../global'; import {Tw2VertexElement} from './Tw2VertexElement'; /** @@ -234,34 +234,39 @@ export class Tw2VertexDeclaration const decl = declarations[i]; let usage, usageIndex, type, elements, offset; - if (Array.isArray(decl)) + if (util.isArray(decl)) { usage = decl[0]; usageIndex = decl[1]; - type = decl[2]; - elements = decl[3]; + elements = decl[2]; + type = decl[3]; offset = decl[4]; } else { usage = decl.usage; usageIndex = decl.usageIndex; - type = decl.type; elements = decl.elements; + type = decl.type; offset = decl.offset; } - if (typeof usage === 'string') + if (util.isString(usage)) { usage = Tw2VertexDeclaration.Type[usage.toUpperCase()]; } - if (typeof type === 'string') + if (util.isNoU(type)) + { + type = 'FLOAT'; + } + + if (util.isString(type)) { type = device.gl[type.toUpperCase()]; } - if (offset === undefined) + if (util.isNoU(offset)) { offset = currentOffset; } diff --git a/src/curve/curves/Tw2ColorCurve.js b/src/curve/curves/Tw2ColorCurve.js index cd14533..2741959 100644 --- a/src/curve/curves/Tw2ColorCurve.js +++ b/src/curve/curves/Tw2ColorCurve.js @@ -1,4 +1,4 @@ -import {vec4} from '../../math'; +import {vec4} from '../../global'; import {Tw2CurveKey, Tw2Curve} from './Tw2Curve'; /** diff --git a/src/curve/curves/Tw2ColorCurve2.js b/src/curve/curves/Tw2ColorCurve2.js index c7bf95a..b796877 100644 --- a/src/curve/curves/Tw2ColorCurve2.js +++ b/src/curve/curves/Tw2ColorCurve2.js @@ -1,4 +1,4 @@ -import {vec4} from '../../math'; +import {vec4} from '../../global'; import {Tw2CurveKey, Tw2Curve} from './Tw2Curve'; /** diff --git a/src/curve/curves/Tw2Curve.js b/src/curve/curves/Tw2Curve.js index 943e703..f7f969c 100644 --- a/src/curve/curves/Tw2Curve.js +++ b/src/curve/curves/Tw2Curve.js @@ -1,5 +1,5 @@ /* eslint no-unused-vars:0 */ -import {vec3, vec4, quat, util} from '../../math'; +import {vec3, vec4, quat, util} from '../../global'; /** * Tw2CurveKey base class diff --git a/src/curve/curves/Tw2PerlinCurve.js b/src/curve/curves/Tw2PerlinCurve.js index 513152f..86cf707 100644 --- a/src/curve/curves/Tw2PerlinCurve.js +++ b/src/curve/curves/Tw2PerlinCurve.js @@ -1,4 +1,4 @@ -import {noise} from '../../math'; +import {noise} from '../../global'; import {Tw2Curve} from './Tw2Curve'; /** diff --git a/src/curve/curves/Tw2QuaternionCurve.js b/src/curve/curves/Tw2QuaternionCurve.js index bf6720c..0ddc06a 100644 --- a/src/curve/curves/Tw2QuaternionCurve.js +++ b/src/curve/curves/Tw2QuaternionCurve.js @@ -1,4 +1,4 @@ -import {vec4, quat} from '../../math'; +import {vec4, quat} from '../../global'; import {Tw2CurveKey, Tw2Curve} from './Tw2Curve'; /** diff --git a/src/curve/curves/Tw2RigidOrientation.js b/src/curve/curves/Tw2RigidOrientation.js index 0ac9489..877c4ef 100644 --- a/src/curve/curves/Tw2RigidOrientation.js +++ b/src/curve/curves/Tw2RigidOrientation.js @@ -1,4 +1,4 @@ -import {vec3, quat} from '../../math'; +import {vec3, quat} from '../../global'; import {Tw2CurveKey, Tw2Curve} from './Tw2Curve'; /** diff --git a/src/curve/curves/Tw2RotationCurve.js b/src/curve/curves/Tw2RotationCurve.js index 8ddd4b9..5264b7e 100644 --- a/src/curve/curves/Tw2RotationCurve.js +++ b/src/curve/curves/Tw2RotationCurve.js @@ -1,4 +1,4 @@ -import {num, vec4, quat} from '../../math'; +import {num, vec4, quat} from '../../global'; import {Tw2CurveKey, Tw2Curve} from './Tw2Curve'; /** diff --git a/src/curve/curves/Tw2Vector2Curve.js b/src/curve/curves/Tw2Vector2Curve.js index d3e278d..c1e15e8 100644 --- a/src/curve/curves/Tw2Vector2Curve.js +++ b/src/curve/curves/Tw2Vector2Curve.js @@ -1,4 +1,4 @@ -import {vec2} from '../../math'; +import {vec2} from '../../global'; import {Tw2CurveKey, Tw2Curve} from './Tw2Curve'; /** diff --git a/src/curve/curves/Tw2Vector3Curve.js b/src/curve/curves/Tw2Vector3Curve.js index bb49d6d..ee49beb 100644 --- a/src/curve/curves/Tw2Vector3Curve.js +++ b/src/curve/curves/Tw2Vector3Curve.js @@ -1,4 +1,4 @@ -import {vec3} from '../../math'; +import {vec3} from '../../global'; import {Tw2CurveKey, Tw2Curve} from './Tw2Curve'; /** diff --git a/src/curve/curves/Tw2VectorCurve.js b/src/curve/curves/Tw2VectorCurve.js index 4ac1871..8dccaf4 100644 --- a/src/curve/curves/Tw2VectorCurve.js +++ b/src/curve/curves/Tw2VectorCurve.js @@ -1,4 +1,4 @@ -import {vec3} from '../../math'; +import {vec3} from '../../global'; import {Tw2CurveKey, Tw2Curve} from './Tw2Curve'; /** diff --git a/src/curve/maya/Tw2MayaAnimationEngine.js b/src/curve/maya/Tw2MayaAnimationEngine.js index 8db55a8..3975299 100644 --- a/src/curve/maya/Tw2MayaAnimationEngine.js +++ b/src/curve/maya/Tw2MayaAnimationEngine.js @@ -1,4 +1,4 @@ -import {curve, util, vec4} from '../../math'; +import {curve, util, vec4} from '../../global'; /** * Tw2MayaAnimationEngine diff --git a/src/curve/maya/Tw2MayaEulerRotationCurve.js b/src/curve/maya/Tw2MayaEulerRotationCurve.js index 527a253..6f2ea54 100644 --- a/src/curve/maya/Tw2MayaEulerRotationCurve.js +++ b/src/curve/maya/Tw2MayaEulerRotationCurve.js @@ -1,4 +1,4 @@ -import {vec3, quat} from '../../math'; +import {vec3, quat} from '../../global'; import {Tw2Curve} from '../curves'; /** diff --git a/src/curve/maya/Tw2MayaVector3Curve.js b/src/curve/maya/Tw2MayaVector3Curve.js index eddad6d..21d9251 100644 --- a/src/curve/maya/Tw2MayaVector3Curve.js +++ b/src/curve/maya/Tw2MayaVector3Curve.js @@ -1,4 +1,4 @@ -import {vec3} from '../../math'; +import {vec3} from '../../global'; import {Tw2Curve} from '../curves'; /** diff --git a/src/curve/sequencers/Tw2ColorSequencer.js b/src/curve/sequencers/Tw2ColorSequencer.js index 6f5fce4..fd5f2a9 100644 --- a/src/curve/sequencers/Tw2ColorSequencer.js +++ b/src/curve/sequencers/Tw2ColorSequencer.js @@ -1,4 +1,4 @@ -import {vec4} from '../../math'; +import {vec4} from '../../global'; import {Tw2CurveSequencer} from './Tw2CurveSequencer'; /** diff --git a/src/curve/sequencers/Tw2EulerRotation.js b/src/curve/sequencers/Tw2EulerRotation.js index 2d1c47d..31e5bf5 100644 --- a/src/curve/sequencers/Tw2EulerRotation.js +++ b/src/curve/sequencers/Tw2EulerRotation.js @@ -1,4 +1,4 @@ -import {quat} from '../../math'; +import {quat} from '../../global'; import {Tw2CurveSequencer} from './Tw2CurveSequencer'; /** diff --git a/src/curve/sequencers/Tw2QuaternionSequencer.js b/src/curve/sequencers/Tw2QuaternionSequencer.js index 48d9183..c64d468 100644 --- a/src/curve/sequencers/Tw2QuaternionSequencer.js +++ b/src/curve/sequencers/Tw2QuaternionSequencer.js @@ -1,4 +1,4 @@ -import {quat} from '../../math'; +import {quat} from '../../global'; import {Tw2CurveSequencer} from './Tw2CurveSequencer'; /** diff --git a/src/curve/sequencers/Tw2RGBAScalarSequencer.js b/src/curve/sequencers/Tw2RGBAScalarSequencer.js index 542f238..2a45d20 100644 --- a/src/curve/sequencers/Tw2RGBAScalarSequencer.js +++ b/src/curve/sequencers/Tw2RGBAScalarSequencer.js @@ -1,4 +1,4 @@ -import {vec4} from '../../math'; +import {vec4} from '../../global'; import {Tw2CurveSequencer} from './Tw2CurveSequencer'; /** diff --git a/src/curve/sequencers/Tw2VectorSequencer.js b/src/curve/sequencers/Tw2VectorSequencer.js index a833d29..b00d8de 100644 --- a/src/curve/sequencers/Tw2VectorSequencer.js +++ b/src/curve/sequencers/Tw2VectorSequencer.js @@ -1,4 +1,4 @@ -import {vec3} from '../../math'; +import {vec3} from '../../global'; import {Tw2CurveSequencer } from './Tw2CurveSequencer'; /** diff --git a/src/curve/sequencers/Tw2XYZScalarSequencer.js b/src/curve/sequencers/Tw2XYZScalarSequencer.js index 4b13a2f..32c103a 100644 --- a/src/curve/sequencers/Tw2XYZScalarSequencer.js +++ b/src/curve/sequencers/Tw2XYZScalarSequencer.js @@ -1,4 +1,4 @@ -import {vec3} from '../../math'; +import {vec3} from '../../global'; import {Tw2CurveSequencer } from './Tw2CurveSequencer'; /** diff --git a/src/curve/sequencers/Tw2YPRSequencer.js b/src/curve/sequencers/Tw2YPRSequencer.js index e257836..bd1c2eb 100644 --- a/src/curve/sequencers/Tw2YPRSequencer.js +++ b/src/curve/sequencers/Tw2YPRSequencer.js @@ -1,4 +1,4 @@ -import {quat, vec3} from '../../math'; +import {quat, vec3} from '../../global'; import {Tw2CurveSequencer} from './Tw2CurveSequencer'; /** diff --git a/src/curve/tracks/Tw2TransformTrack.js b/src/curve/tracks/Tw2TransformTrack.js index 84e33e0..850aa69 100644 --- a/src/curve/tracks/Tw2TransformTrack.js +++ b/src/curve/tracks/Tw2TransformTrack.js @@ -1,5 +1,4 @@ -import {curve, vec3, quat, mat4, util} from '../../math'; -import {resMan} from '../../core'; +import {curve, vec3, quat, mat4, util, resMan} from '../../global'; /** * Tw2TransformTrack diff --git a/src/curve/tracks/Tw2WbgTrack.js b/src/curve/tracks/Tw2WbgTrack.js index 63037ab..de5af95 100644 --- a/src/curve/tracks/Tw2WbgTrack.js +++ b/src/curve/tracks/Tw2WbgTrack.js @@ -1,5 +1,4 @@ -import {vec3, quat, mat4, curve, util} from '../../math'; -import {resMan} from '../../core'; +import {vec3, quat, mat4, curve, util, resMan} from '../../global'; /** * Tw2WbgTrack diff --git a/src/eve/EveSOF.js b/src/eve/EveSOF.js index a276109..1401964 100644 --- a/src/eve/EveSOF.js +++ b/src/eve/EveSOF.js @@ -1,5 +1,4 @@ -import {vec3, vec4, quat, mat4} from '../math'; -import {resMan} from '../core'; +import {vec3, vec4, quat, mat4, resMan} from '../global'; import {Tw2FloatParameter} from '../core'; import {Tw2TextureParameter} from '../core'; import {Tw2Vector4Parameter} from '../core'; diff --git a/src/eve/EveSpaceScene.js b/src/eve/EveSpaceScene.js index d185dde..391bd30 100644 --- a/src/eve/EveSpaceScene.js +++ b/src/eve/EveSpaceScene.js @@ -1,5 +1,5 @@ -import {vec3, vec4, quat, mat4, util} from '../math'; -import {device, resMan, store, Tw2BatchAccumulator, Tw2RawData, Tw2Frustum} from '../core'; +import {vec3, vec4, quat, mat4, util, device, resMan, store} from '../global'; +import {Tw2BatchAccumulator, Tw2RawData, Tw2Frustum} from '../core'; /** * EveSpaceScene diff --git a/src/eve/child/EveChild.js b/src/eve/child/EveChild.js index d162181..71772e9 100644 --- a/src/eve/child/EveChild.js +++ b/src/eve/child/EveChild.js @@ -1,5 +1,5 @@ /* eslint no-unused-vars:0 */ -import { vec3, quat, mat4, util } from '../../math'; +import { vec3, quat, mat4, util } from '../../global'; /** * EveChild base class diff --git a/src/eve/child/EveChildBillboard.js b/src/eve/child/EveChildBillboard.js index a54e0ec..8b3f087 100644 --- a/src/eve/child/EveChildBillboard.js +++ b/src/eve/child/EveChildBillboard.js @@ -1,5 +1,5 @@ -import {vec3, mat4} from '../../math'; -import {device, Tw2BasicPerObjectData, Tw2RawData} from '../../core'; +import {vec3, mat4, device} from '../../global'; +import {Tw2BasicPerObjectData, Tw2RawData} from '../../core'; import {EveChild} from './EveChild'; /** diff --git a/src/eve/child/EveChildMesh.js b/src/eve/child/EveChildMesh.js index 61f970c..9dad42f 100644 --- a/src/eve/child/EveChildMesh.js +++ b/src/eve/child/EveChildMesh.js @@ -1,4 +1,4 @@ -import {mat4} from '../../math'; +import {mat4} from '../../global'; import {Tw2PerObjectData, Tw2BasicPerObjectData, Tw2RawData} from '../../core'; import {EveChild} from './EveChild'; diff --git a/src/eve/child/EveChildParticleSystem.js b/src/eve/child/EveChildParticleSystem.js index 7474514..011c510 100644 --- a/src/eve/child/EveChildParticleSystem.js +++ b/src/eve/child/EveChildParticleSystem.js @@ -1,4 +1,4 @@ -import {mat4} from '../../math'; +import {mat4} from '../../global'; import {Tw2BasicPerObjectData, Tw2RawData} from '../../core'; import {EveChild} from './EveChild'; diff --git a/src/eve/effect/EveLensflare.js b/src/eve/effect/EveLensflare.js index dd6995c..7c8ba96 100644 --- a/src/eve/effect/EveLensflare.js +++ b/src/eve/effect/EveLensflare.js @@ -1,5 +1,5 @@ -import {vec3, vec4, mat4, util} from '../../math'; -import {device, store, Tw2TextureRes, Tw2RenderTarget} from '../../core'; +import {vec3, vec4, mat4, util, device, store} from '../../global'; +import {Tw2TextureRes, Tw2RenderTarget} from '../../core'; import {EveOccluder} from './EveOccluder'; /** diff --git a/src/eve/effect/EveMeshOverlayEffect.js b/src/eve/effect/EveMeshOverlayEffect.js index 2a3d52e..db95ff7 100644 --- a/src/eve/effect/EveMeshOverlayEffect.js +++ b/src/eve/effect/EveMeshOverlayEffect.js @@ -1,5 +1,5 @@ -import {device, Tw2GeometryBatch} from '../../core'; -import {util} from '../../math'; +import {Tw2GeometryBatch} from '../../core'; +import {util, device} from '../../global'; /** * Constructor for Overlay Effects diff --git a/src/eve/effect/EveOccluder.js b/src/eve/effect/EveOccluder.js index 11ff8ca..ee891c5 100644 --- a/src/eve/effect/EveOccluder.js +++ b/src/eve/effect/EveOccluder.js @@ -1,12 +1,5 @@ -import {vec4, mat4, util} from '../../math'; -import { - device, - store, - Tw2Effect, - Tw2VertexDeclaration, - Tw2VertexElement, - Tw2BatchAccumulator -} from '../../core'; +import {vec4, mat4, util, device, store} from '../../global'; +import { Tw2Effect, Tw2VertexDeclaration, Tw2VertexElement, Tw2BatchAccumulator} from '../../core'; /** * EveOccluder diff --git a/src/eve/object/EveStarField.js b/src/eve/effect/EveStarField.js similarity index 78% rename from src/eve/object/EveStarField.js rename to src/eve/effect/EveStarField.js index 9d4c4f0..59d9887 100644 --- a/src/eve/object/EveStarField.js +++ b/src/eve/effect/EveStarField.js @@ -1,5 +1,5 @@ -/*eslint no-unused-vars:0 */ -import {EveObject} from './EveObject'; +import {util} from '../../global'; + /** * EveStarField - not implemented yet * @@ -13,11 +13,13 @@ import {EveObject} from './EveObject'; * @property {number} minFlashRate * @property {number} seed */ -export class EveStarField extends EveObject +export class EveStarField { constructor() { - super(); + this._id = util.generateID(); + this.name = ''; + this.display = true; this.effect = null; this.maxDist = 0; this.maxFlashRate = 0; diff --git a/src/eve/effect/EveStretch.js b/src/eve/effect/EveStretch.js index 0d15a51..92f3173 100644 --- a/src/eve/effect/EveStretch.js +++ b/src/eve/effect/EveStretch.js @@ -1,5 +1,5 @@ -import {vec3, mat4, util} from '../../math/index'; -import {Tw2Float} from '../../core/index'; +import {vec3, mat4, util} from '../../global'; +import {Tw2Float} from '../../core'; /** * EveStretch diff --git a/src/eve/effect/EveTurretFiringFX.js b/src/eve/effect/EveTurretFiringFX.js index 9593ae0..004e083 100644 --- a/src/eve/effect/EveTurretFiringFX.js +++ b/src/eve/effect/EveTurretFiringFX.js @@ -1,4 +1,4 @@ -import {vec3, mat4, util} from '../../math/index'; +import {vec3, mat4, util} from '../../global'; /** * EvePerMuzzleData diff --git a/src/eve/effect/index.js b/src/eve/effect/index.js index 4341369..0496862 100644 --- a/src/eve/effect/index.js +++ b/src/eve/effect/index.js @@ -2,4 +2,5 @@ export * from './EveLensflare'; export * from './EveMeshOverlayEffect'; export * from './EveOccluder'; export * from './EveStretch'; -export * from './EveTurretFiringFX'; \ No newline at end of file +export * from './EveTurretFiringFX'; +export * from './EveStarField'; \ No newline at end of file diff --git a/src/eve/item/EveBoosterSet.js b/src/eve/item/EveBoosterSet.js index 940df61..37f9422 100644 --- a/src/eve/item/EveBoosterSet.js +++ b/src/eve/item/EveBoosterSet.js @@ -1,5 +1,5 @@ -import {vec3, vec4, mat4, util} from '../../math'; -import {device, Tw2VertexDeclaration, Tw2VertexElement, Tw2PerObjectData, Tw2RawData, Tw2RenderBatch} from '../../core'; +import {vec3, vec4, mat4, util, device} from '../../global'; +import {Tw2VertexDeclaration, Tw2VertexElement, Tw2PerObjectData, Tw2RawData, Tw2RenderBatch} from '../../core'; import {EveObjectSet, EveObjectSetItem} from './EveObjectSet'; /** diff --git a/src/eve/item/EveCurveLineSet.js b/src/eve/item/EveCurveLineSet.js index 4ac1f60..1295b7e 100644 --- a/src/eve/item/EveCurveLineSet.js +++ b/src/eve/item/EveCurveLineSet.js @@ -1,6 +1,5 @@ -import {vec3, vec4, quat, mat4, util} from '../../math'; +import {vec3, vec4, quat, mat4, util, device} from '../../global'; import { - device, Tw2Effect, Tw2PerObjectData, Tw2RawData, diff --git a/src/eve/item/EveLocator.js b/src/eve/item/EveLocator.js index 5df8a56..91ab336 100644 --- a/src/eve/item/EveLocator.js +++ b/src/eve/item/EveLocator.js @@ -1,4 +1,4 @@ -import {mat4} from '../../math/index'; +import {mat4} from '../../global'; /** * Contains transform information for T3 Attachments, Boosters, Turrets and XLTurrets diff --git a/src/eve/item/EveObjectSet.js b/src/eve/item/EveObjectSet.js index 688092d..2772f9e 100644 --- a/src/eve/item/EveObjectSet.js +++ b/src/eve/item/EveObjectSet.js @@ -1,5 +1,5 @@ /* eslint no-unused-vars:0 */ -import { vec3, vec4, mat4, util } from '../../math'; +import { vec3, vec4, mat4, util } from '../../global'; /** * EveObjectSetItem base class diff --git a/src/eve/item/EvePlaneSet.js b/src/eve/item/EvePlaneSet.js index e5d3bd4..6faba39 100644 --- a/src/eve/item/EvePlaneSet.js +++ b/src/eve/item/EvePlaneSet.js @@ -1,5 +1,5 @@ -import {vec3, vec4, quat, mat4, util} from '../../math'; -import {device, Tw2VertexDeclaration, Tw2VertexElement, Tw2RenderBatch} from '../../core'; +import {vec3, vec4, quat, mat4, util, device} from '../../global'; +import {Tw2VertexDeclaration, Tw2VertexElement, Tw2RenderBatch} from '../../core'; import {EveObjectSet, EveObjectSetItem} from './EveObjectSet'; /** diff --git a/src/eve/item/EveSpaceObjectDecal.js b/src/eve/item/EveSpaceObjectDecal.js index 464b0c3..c27bcbc 100644 --- a/src/eve/item/EveSpaceObjectDecal.js +++ b/src/eve/item/EveSpaceObjectDecal.js @@ -1,11 +1,5 @@ -import {vec3, quat, mat4, util} from '../../math'; -import { - device, - store, - Tw2PerObjectData, - Tw2RawData, - Tw2ForwardingRenderBatch -} from '../../core/'; +import {vec3, quat, mat4, util, device, store} from '../../global'; +import { Tw2PerObjectData, Tw2RawData, Tw2ForwardingRenderBatch} from '../../core/'; /** * EveSpaceObjectDecal diff --git a/src/eve/item/EveSpotlightSet.js b/src/eve/item/EveSpotlightSet.js index fc25079..5430821 100644 --- a/src/eve/item/EveSpotlightSet.js +++ b/src/eve/item/EveSpotlightSet.js @@ -1,5 +1,5 @@ -import {vec3, vec4, mat4, util} from '../../math'; -import {device, Tw2VertexDeclaration, Tw2VertexElement, Tw2RenderBatch} from '../../core'; +import {vec3, vec4, mat4, util, device} from '../../global'; +import {Tw2VertexDeclaration, Tw2VertexElement, Tw2RenderBatch} from '../../core'; import {EveObjectSet, EveObjectSetItem} from './EveObjectSet'; /** diff --git a/src/eve/item/EveSpriteSet.js b/src/eve/item/EveSpriteSet.js index b1f90ed..4d0f6f5 100644 --- a/src/eve/item/EveSpriteSet.js +++ b/src/eve/item/EveSpriteSet.js @@ -1,5 +1,5 @@ -import {vec3, vec4, util} from '../../math'; -import {device, Tw2VertexDeclaration, Tw2VertexElement, Tw2RenderBatch} from '../../core'; +import {vec3, vec4, util, device} from '../../global'; +import {Tw2VertexDeclaration, Tw2VertexElement, Tw2RenderBatch} from '../../core'; import {EveObjectSet, EveObjectSetItem} from './EveObjectSet'; /** diff --git a/src/eve/item/EveTurretSet.js b/src/eve/item/EveTurretSet.js index a0f981f..3fad588 100644 --- a/src/eve/item/EveTurretSet.js +++ b/src/eve/item/EveTurretSet.js @@ -1,7 +1,5 @@ -import {vec3, vec4, quat, mat4, util} from '../../math'; +import {vec3, vec4, quat, mat4, util, resMan, device} from '../../global'; import { - device, - resMan, Tw2PerObjectData, Tw2VertexElement, Tw2VertexDeclaration, diff --git a/src/eve/object/EveEffectRoot.js b/src/eve/object/EveEffectRoot.js index de3a682..2092de0 100644 --- a/src/eve/object/EveEffectRoot.js +++ b/src/eve/object/EveEffectRoot.js @@ -1,5 +1,5 @@ -import {vec3, quat, mat4} from '../../math/index'; -import {Tw2PerObjectData, Tw2RawData} from '../../core/index'; +import {vec3, quat, mat4} from '../../global'; +import {Tw2PerObjectData, Tw2RawData} from '../../core'; import {EveObject} from './EveObject'; /** diff --git a/src/eve/object/EveMissile.js b/src/eve/object/EveMissile.js index b49f3a4..bac68f0 100644 --- a/src/eve/object/EveMissile.js +++ b/src/eve/object/EveMissile.js @@ -1,4 +1,4 @@ -import {vec3, mat4, util} from '../../math'; +import {vec3, mat4, util} from '../../global'; import {Tw2PerObjectData, Tw2RawData} from '../../core'; import {EveObject} from './EveObject'; diff --git a/src/eve/object/EveObject.js b/src/eve/object/EveObject.js index 6078b45..e36dee7 100644 --- a/src/eve/object/EveObject.js +++ b/src/eve/object/EveObject.js @@ -1,5 +1,5 @@ /* eslint no-unused-vars:0 */ -import {mat4, util, vec3} from '../../math'; +import {mat4, util, vec3} from '../../global'; /** * EveObject base class diff --git a/src/eve/object/EvePlanet.js b/src/eve/object/EvePlanet.js index 06dfc86..3b8ce76 100644 --- a/src/eve/object/EvePlanet.js +++ b/src/eve/object/EvePlanet.js @@ -1,4 +1,5 @@ -import {device, resMan, Tw2Effect, Tw2RenderTarget, Tw2TextureParameter, Tw2FloatParameter} from '../../core'; +import {util, device, resMan} from '../../global'; +import {Tw2Effect, Tw2RenderTarget, Tw2TextureParameter, Tw2FloatParameter} from '../../core'; import {EveTransform} from './EveTransform'; import {EveObject} from './EveObject'; @@ -73,7 +74,7 @@ export class EvePlanet extends EveObject if (visited.includes(obj)) return; visited.push(obj); - if (obj && typeof(obj['doNotPurge']) !== typeof(undefined)) + if (obj && !util.isUndefined(obj['doNotPurge'])) { result.push(obj); return; @@ -83,7 +84,7 @@ export class EvePlanet extends EveObject { if (obj.hasOwnProperty(prop)) { - if (typeof(obj[prop]) === 'object') + if (util.isObjectLike(obj[prop])) { this.GetPlanetResources(obj[prop], visited, result); } diff --git a/src/eve/object/EveSpaceObject.js b/src/eve/object/EveSpaceObject.js index 28a19dd..950ad69 100644 --- a/src/eve/object/EveSpaceObject.js +++ b/src/eve/object/EveSpaceObject.js @@ -1,4 +1,4 @@ -import {vec3, vec4, mat4, util} from '../../math'; +import {vec3, vec4, mat4, util} from '../../global'; import {Tw2AnimationController, Tw2PerObjectData, Tw2RawData} from '../../core'; import {EveObject} from './EveObject'; diff --git a/src/eve/object/EveTransform.js b/src/eve/object/EveTransform.js index df8885a..dbfaa44 100644 --- a/src/eve/object/EveTransform.js +++ b/src/eve/object/EveTransform.js @@ -1,5 +1,5 @@ -import {vec3, quat, mat4} from '../../math'; -import {device, Tw2BasicPerObjectData, Tw2RawData} from '../../core'; +import {vec3, quat, mat4, device} from '../../global'; +import {Tw2BasicPerObjectData, Tw2RawData} from '../../core'; import {EveObject} from './EveObject'; /** diff --git a/src/core/global/Tw2Device.js b/src/global/engine/Tw2Device.js similarity index 99% rename from src/core/global/Tw2Device.js rename to src/global/engine/Tw2Device.js index 1287991..9223fa4 100644 --- a/src/core/global/Tw2Device.js +++ b/src/global/engine/Tw2Device.js @@ -1,9 +1,9 @@ -import {vec3, vec4, mat4} from '../../math'; +import {vec3, vec4, mat4} from '../math'; import {store} from './Tw2Store'; import {logger} from './Tw2Logger'; import {resMan} from './Tw2ResMan'; -import {Tw2Effect} from '../mesh/Tw2Effect'; -import {Tw2VertexElement, Tw2VertexDeclaration} from '../vertex'; +import {Tw2Effect} from '../../core/mesh/Tw2Effect'; +import {Tw2VertexElement, Tw2VertexDeclaration} from '../../core/vertex'; const WebGLDebugUtil = require('webgl-debug'); @@ -15,6 +15,7 @@ const WebGLDebugUtil = require('webgl-debug'); * @property {?VRDisplay} vrDisplay - An optional VRDisplay context * @property {?{}} ext - An object containing compatibility extensions * @property {boolean} debugMode - Toggles debug mode + * @property {{}} debugUtils - Webgl debug utils * @property {number} dt - Clock delta time * @property {number} startTime - Clock start time * @property {number} currentTime - Clock current time @@ -59,7 +60,6 @@ const WebGLDebugUtil = require('webgl-debug'); * @property {WebGLTexture} _fallbackTexture - A fallback texture * @property {Tw2Effect} _blitEffect - The blit effect used for rendering textures * @property {?Function} _onResize - An optional function which is called when the canvas resizes - * @property {{}} utils - Webgl debug utils * @class */ export class Tw2Device @@ -72,6 +72,7 @@ export class Tw2Device this.ext = null; this.debugMode = false; + this.debugUtils = null; this.dt = 0; this.frameCounter = 0; @@ -123,8 +124,6 @@ export class Tw2Device this._fallbackTexture = null; this._blitEffect = null; this._onResize = null; - - this.utils = WebGLDebugUtil; } /** @@ -241,7 +240,8 @@ export class Tw2Device if (gl && this.debugMode) { - this.gl = this.utils.makeDebugContext(gl); + this.debugUtils = WebGLDebugUtil; + this.gl = this.debugUtils.makeDebugContext(gl); } logger.log('webgl', { diff --git a/src/core/global/Tw2Logger.js b/src/global/engine/Tw2Logger.js similarity index 92% rename from src/core/global/Tw2Logger.js rename to src/global/engine/Tw2Logger.js index 9cbba02..b542a44 100644 --- a/src/core/global/Tw2Logger.js +++ b/src/global/engine/Tw2Logger.js @@ -1,5 +1,5 @@ -import {Tw2EventEmitter} from '../Tw2EventEmitter'; -import {util} from '../../math'; +import {Tw2EventEmitter} from '../../core/Tw2EventEmitter'; +import {assignIfExists} from '../util'; /** * Event log @@ -32,7 +32,7 @@ import {util} from '../../math'; * @property {Array} _logs - Stored logs * @property {?Function} _onNewLog - On new log */ -export class Tw2Logger extends Tw2EventEmitter +class Tw2Logger extends Tw2EventEmitter { constructor(name='') { @@ -57,6 +57,8 @@ export class Tw2Logger extends Tw2EventEmitter */ log(eventName, log) { + if (log.logged) return log; + log.log = Tw2Logger.Type[log.log ? log.log.toUpperCase() : 'LOG'] || 'log'; if (!log.hide && this.display && this.visible[log.log]) @@ -107,6 +109,7 @@ export class Tw2Logger extends Tw2EventEmitter } this.emit('log', log); + log.logged = true; return log; } @@ -126,8 +129,8 @@ export class Tw2Logger extends Tw2EventEmitter */ Set(opt={}) { - util.assignIfExists(this, opt, ['name', 'maxLogs', 'display']); - util.assignIfExists(this.visible, opt.visible, ['log','info','debug','warn','error']); + assignIfExists(this, opt, ['name', 'maxLogs', 'display']); + assignIfExists(this.visible, opt.visible, ['log','info','debug','warn','error']); } } diff --git a/src/core/global/Tw2MotherLode.js b/src/global/engine/Tw2MotherLode.js similarity index 97% rename from src/core/global/Tw2MotherLode.js rename to src/global/engine/Tw2MotherLode.js index 8a48641..0e2f1cd 100644 --- a/src/core/global/Tw2MotherLode.js +++ b/src/global/engine/Tw2MotherLode.js @@ -1,5 +1,3 @@ -import {logger} from './Tw2Logger'; - /** * Manages loaded resources * @@ -105,8 +103,9 @@ export class Tw2MotherLode * @param {Number} curFrame - the current frame count * @param {Number} frameLimit - how many frames the object can stay alive for before being purged * @param {Number} frameDistance - how long the resource has been alive for + * @param {Tw2Logger} logger */ - PurgeInactive(curFrame, frameLimit, frameDistance) + PurgeInactive(curFrame, frameLimit, frameDistance, logger) { for (const path in this._loadedObjects) { diff --git a/src/core/global/Tw2ResMan.js b/src/global/engine/Tw2ResMan.js similarity index 99% rename from src/core/global/Tw2ResMan.js rename to src/global/engine/Tw2ResMan.js index 9c87fe8..1e7e451 100644 --- a/src/core/global/Tw2ResMan.js +++ b/src/global/engine/Tw2ResMan.js @@ -1,7 +1,7 @@ import {logger} from './Tw2Logger'; import {store} from './Tw2Store'; import {Tw2MotherLode} from './Tw2MotherLode'; -import {Tw2LoadingObject} from '../resource/Tw2LoadingObject'; +import {Tw2LoadingObject} from '../../core/resource/Tw2LoadingObject'; /** * Resource Manager @@ -135,7 +135,7 @@ export class Tw2ResMan { if (this.autoPurgeResources) { - this.motherLode.PurgeInactive(this._purgeFrame, this._purgeFrameLimit, this.purgeTime); + this.motherLode.PurgeInactive(this._purgeFrame, this._purgeFrameLimit, this.purgeTime, logger); } } } diff --git a/src/core/global/Tw2Store.js b/src/global/engine/Tw2Store.js similarity index 62% rename from src/core/global/Tw2Store.js rename to src/global/engine/Tw2Store.js index dad9df2..fffacfb 100644 --- a/src/core/global/Tw2Store.js +++ b/src/global/engine/Tw2Store.js @@ -1,15 +1,16 @@ -import {util} from '../../math'; +import {isString, isPlain, isArray, isFunction, toArray, isUndefined, enableUUID} from '../util'; import {logger} from './Tw2Logger'; /** * Stores engine data * - * @property {Object.< string, string>} _paths - * @property {Object.< string, Array>} _dynamicPaths - * @property {Object.< string, Tw2Parameter>} _variables - * @property {Object.< string, Function>} _types - * @property {Object.< string, Function>} _extensions - * @property {Object.< string, Function>} _constructors + * @property {Object.< string, string>} _path + * @property {Object.< string, Array>} _dynamicPath + * @property {Object.< string, Tw2Parameter>} _variable + * @property {Object.< string, Function>} _type + * @property {Object.< string, Function>} _extension + * @property {Object.< string, Function>} _constructor + * @property {Object.< string, Tw2Schema>} _schema * @property {Object.< string, Array>} _missing * @class */ @@ -17,12 +18,13 @@ class Tw2Store { constructor() { - this._types = {}; - this._paths = {}; - this._variables = {}; - this._extensions = {}; - this._constructors = {}; - this._dynamicPaths = {}; + this._type = {}; + this._path = {}; + this._variable = {}; + this._extension = {}; + this._constructor = {}; + this._dynamicPath = {}; + this._schema = {}; this._missing = {}; } @@ -33,7 +35,7 @@ class Tw2Store */ HasPath(prefix) { - return (prefix && prefix in this._paths); + return (prefix && prefix in this._path); } @@ -44,7 +46,7 @@ class Tw2Store */ GetPath(prefix) { - return Tw2Store.GetStoreItem(this, 'paths', prefix); + return Tw2Store.GetStoreItem(this, 'path', prefix); } /** @@ -55,7 +57,7 @@ class Tw2Store */ RegisterPath(prefix, path) { - return !!Tw2Store.SetStoreItem(this, 'paths', prefix, path); + return Tw2Store.SetStoreItem(this, 'path', prefix, path, isString); } /** @@ -75,7 +77,7 @@ class Tw2Store */ HasDynamicPath(prefix) { - return (prefix && prefix in this._dynamicPaths); + return (prefix && prefix in this._dynamicPath); } /** @@ -85,7 +87,7 @@ class Tw2Store */ GetDynamicPath(prefix) { - return Tw2Store.GetStoreItem(this, 'dynamicPaths', prefix); + return Tw2Store.GetStoreItem(this, 'dynamicPath', prefix); } /** @@ -96,7 +98,7 @@ class Tw2Store */ RegisterDynamicPath(prefix, paths) { - return !!Tw2Store.SetStoreItem(this, 'dynamicPaths', prefix, paths); + return Tw2Store.SetStoreItem(this, 'dynamicPath', prefix, paths, isArray); } /** @@ -116,7 +118,7 @@ class Tw2Store */ HasExtension(ext) { - return (ext && ext in this._extensions); + return (ext && ext in this._extension); } /** @@ -126,22 +128,18 @@ class Tw2Store */ GetExtension(ext) { - return Tw2Store.GetStoreItem(this, 'extensions', ext); + return Tw2Store.GetStoreItem(this, 'extension', ext); } /** * Registers a resource extension - * @param {name} ext + * @param {string} ext * @param {Function} Constructor * @returns {boolean} */ RegisterExtension(ext, Constructor) { - if (typeof Constructor === 'function') - { - return !!Tw2Store.SetStoreItem(this, 'extensions', ext, Constructor); - } - return false; + return Tw2Store.SetStoreItem(this, 'extension', ext, Constructor, isFunction); } /** @@ -161,7 +159,7 @@ class Tw2Store */ HasConstructor(name) { - return (name && name in this._constructors); + return (name && name in this._constructor); } /** @@ -171,7 +169,7 @@ class Tw2Store */ GetConstructor(name) { - return Tw2Store.GetStoreItem(this, 'constructors', name); + return Tw2Store.GetStoreItem(this, 'constructor', name); } /** @@ -182,9 +180,9 @@ class Tw2Store */ RegisterConstructor(name, Constructor) { - if (typeof Constructor === 'function') + if (isFunction(Constructor)) { - return !!Tw2Store.SetStoreItem(this, 'constructors', name, Constructor); + return Tw2Store.SetStoreItem(this, 'constructor', name, Constructor); } return false; } @@ -206,7 +204,7 @@ class Tw2Store */ HasVariable(name) { - return (name && name in this._variables); + return (name && name in this._variable); } /** @@ -216,7 +214,7 @@ class Tw2Store */ GetVariable(name) { - return Tw2Store.GetStoreItem(this, 'variables', name); + return Tw2Store.GetStoreItem(this, 'variable', name); } /** @@ -251,14 +249,15 @@ class Tw2Store /** * Registers a variable * @param {string} name - * @param {*|{value:*, type: string|Function}} [value] + * @param {*|{value:*, Type: string|Function}} [value] * @param {string|Function} [Type] * @returns {?*} */ RegisterVariable(name, value, Type) { const variable = this.CreateType(name, value, Type); - return Tw2Store.SetStoreItem(this, 'variables', name, variable); + Tw2Store.SetStoreItem(this, 'variable', name, variable); + return variable; } /** @@ -277,7 +276,7 @@ class Tw2Store */ GetType(name) { - return Tw2Store.GetStoreItem(this, 'types', name); + return Tw2Store.GetStoreItem(this, 'type', name); } /** @@ -287,7 +286,7 @@ class Tw2Store */ HasType(name) { - return (name && name in this._types); + return (name && name in this._type); } /** @@ -297,11 +296,14 @@ class Tw2Store */ GetTypeByValue(value) { - for (let type in this._types) + for (let type in this._type) { - if (this._types.hasOwnProperty(type) && 'is' in this._types[type]) + if (this._type.hasOwnProperty(type) && 'isValue' in this._type[type]) { - if (this._types[type]['is'](value)) return this._types[type]; + if (this._type[type]['isValue'](value)) + { + return this._type[type]; + } } } return null; @@ -316,7 +318,7 @@ class Tw2Store */ CreateType(name, value, Type) { - if (value && value.constructor.name === 'Object') + if (isPlain(value)) { Type = value['Type'] || value['type']; value = value['value']; @@ -326,12 +328,13 @@ class Tw2Store { Type = this.GetTypeByValue(value); } - else if (typeof Type === 'string') + + if (isString(Type)) { Type = this.GetType(Type); } - if (typeof Type === 'function') + if (isFunction(Type)) { return new Type(name, value); } @@ -347,11 +350,7 @@ class Tw2Store */ RegisterType(name, Constructor) { - if (typeof Constructor === 'function') - { - return !!Tw2Store.SetStoreItem(this, 'types', name, Constructor); - } - return false; + return Tw2Store.SetStoreItem(this, 'type', name, Constructor, isFunction); } /** @@ -364,6 +363,51 @@ class Tw2Store return Tw2Store.RegisterFromObject(this, 'RegisterType', obj); } + /** + * Checks if a schema exists + * @param {string} name + * @returns {boolean} + */ + HasSchema(name) + { + return (name && name in this._schema); + } + + + /** + * Gets a schema by it's name + * @param {string} name + * @returns {?string} + */ + GetSchema(name) + { + return Tw2Store.GetStoreItem(this, 'schema', name); + } + + /** + * Registers a schema + * @param {string} name + * @param {string} schema + * @returns {boolean} + */ + RegisterSchema(name, schema) + { + return Tw2Store.SetStoreItem(this, 'schema', name, schema, a => + { + return a && a.constructor.name === 'Tw2Schema'; + }); + } + + /** + * Registers schemas from an object or an array of objects + * @param {{string:string}|Array<{string:string}>} obj + * @returns {boolean} + */ + RegisterSchemas(obj) + { + return Tw2Store.RegisterFromObject(this, 'RegisterSchema', obj); + } + /** * Registers store values * @param {{}} [opt={}] @@ -374,16 +418,18 @@ class Tw2Store * @param {*} opt.constructors * @param {*} opt.extensions * @param {*} opt.variables + * @param {*} opt.schemas */ Register(opt = {}) { - if ('uuid' in opt) util.enableUUID(opt.uuid); + if ('uuid' in opt) enableUUID(opt.uuid); this.RegisterPaths(opt.paths); this.RegisterDynamicPaths(opt.dynamicPaths); this.RegisterTypes(opt.types); this.RegisterConstructors(opt.constructors); this.RegisterExtensions(opt.extensions); this.RegisterVariables(opt.variables); + this.RegisterSchemas(opt.schemas); } /** @@ -396,33 +442,27 @@ class Tw2Store */ static GetStoreItem(store, type, key) { - if (typeof key === 'string') + const storeSet = store['_' + type]; + if (storeSet && isString(key)) { - const - storeSet = store[`_${type}`], - singular = type.substring(0, type.length - 1); - - if (storeSet) + if (key in storeSet) { - if (key in storeSet) - { - return storeSet[key]; - } + return storeSet[key]; + } - if (!store._missing[type]) - { - store._missing[type] = []; - } + if (!store._missing[type]) + { + store._missing[type] = []; + } - if (!store._missing[type].includes(key)) - { - store._missing[type].push(key); + if (!store._missing[type].includes(key)) + { + store._missing[type].push(key); - logger.log('store.warning', { - log: 'warning', - msg: `Missing ${singular}: '${key}'` - }); - } + logger.log('store.warning', { + log: 'warning', + msg: `Missing ${type}: '${key}'` + }); } } @@ -435,42 +475,46 @@ class Tw2Store * @param {string} type * @param {string} key * @param {*} value + * @param {Function} [validator] + * @returns {boolean} true if successful */ - static SetStoreItem(store, type, key = '', value) + static SetStoreItem(store, type, key = '', value, validator) { - if (typeof key === 'string' && value !== undefined) + if (validator && !validator(value)) { - const storeSet = store[`_${type}`]; - if (storeSet) - { - const - existing = storeSet[key], - singular = type.substring(0, type.length - 1); - - storeSet[key] = value; + logger.log('store.error', { + log: 'error', + msg: `Invalid value ${type}: '${key}'`, + }); + return false; + } - if (!existing) - { - logger.log('store.registered', { - log: 'debug', - msg: `Registered ${singular}: '${key}'`, - hide: true - }); - } - else - { - logger.log('store.registered', { - log: 'debug', - msg: `Re-registered ${singular}: '${key}'`, - data: { - old_value: existing, - new_value: value - } - }); - } + const storeSet = store['_' + type]; + if (storeSet && isString(key) && !isUndefined(value)) + { + const existing = storeSet[key]; + storeSet[key] = value; - return value; + if (!existing) + { + logger.log('store.registered', { + log: 'debug', + msg: `Registered ${type}: '${key}'`, + hide: true + }); } + else + { + logger.log('store.registered', { + log: 'debug', + msg: `Re-registered ${type}: '${key}'`, + data: { + old_value: existing, + new_value: value + } + }); + } + return true; } return false; } @@ -486,7 +530,7 @@ class Tw2Store { if (obj && funcName in store) { - obj = Array.isArray(obj) ? obj : [obj]; + obj = toArray(obj); for (let i = 0; i < obj.length; i++) { for (let key in obj[i]) diff --git a/src/global/engine/index.js b/src/global/engine/index.js new file mode 100644 index 0000000..4742c2b --- /dev/null +++ b/src/global/engine/index.js @@ -0,0 +1,4 @@ +export { device } from './Tw2Device'; +export { resMan } from './Tw2ResMan'; +export { store } from './Tw2Store'; +export { logger } from './Tw2Logger'; \ No newline at end of file diff --git a/src/global/index.js b/src/global/index.js new file mode 100644 index 0000000..c7584a4 --- /dev/null +++ b/src/global/index.js @@ -0,0 +1,7 @@ +export * from './math'; +export * from './engine'; + +import * as util from './util'; +export { util }; + + diff --git a/src/math/curve.js b/src/global/math/curve.js similarity index 100% rename from src/math/curve.js rename to src/global/math/curve.js diff --git a/src/math/index.js b/src/global/math/index.js similarity index 93% rename from src/math/index.js rename to src/global/math/index.js index fe9222e..d3d1fe5 100644 --- a/src/math/index.js +++ b/src/global/math/index.js @@ -7,7 +7,6 @@ export * from './mat3'; export * from './mat4'; export * from './noise'; export * from './curve'; -export * from './util'; /** * TypedArray diff --git a/src/math/mat3.js b/src/global/math/mat3.js similarity index 100% rename from src/math/mat3.js rename to src/global/math/mat3.js diff --git a/src/math/mat4.js b/src/global/math/mat4.js similarity index 100% rename from src/math/mat4.js rename to src/global/math/mat4.js diff --git a/src/math/noise.js b/src/global/math/noise.js similarity index 100% rename from src/math/noise.js rename to src/global/math/noise.js diff --git a/src/math/num.js b/src/global/math/num.js similarity index 100% rename from src/math/num.js rename to src/global/math/num.js diff --git a/src/math/quat.js b/src/global/math/quat.js similarity index 100% rename from src/math/quat.js rename to src/global/math/quat.js diff --git a/src/math/vec2.js b/src/global/math/vec2.js similarity index 100% rename from src/math/vec2.js rename to src/global/math/vec2.js diff --git a/src/math/vec3.js b/src/global/math/vec3.js similarity index 100% rename from src/math/vec3.js rename to src/global/math/vec3.js diff --git a/src/math/vec4.js b/src/global/math/vec4.js similarity index 100% rename from src/math/vec4.js rename to src/global/math/vec4.js diff --git a/src/global/util/arr.js b/src/global/util/arr.js new file mode 100644 index 0000000..d258fb0 --- /dev/null +++ b/src/global/util/arr.js @@ -0,0 +1,77 @@ +import { isArray } from './type'; + +/** + * Adds arguments to an array if they don't already exist in it + * @param {Array} arr + * @param args + * @returns {boolean} true if something was added + */ +export function addToArray(arr, ...args) +{ + let added = false; + for (let i = 0; i < args.length; i++) + { + if (arr.indexOf(args[i]) === -1) + { + arr.push(args[i]); + added = true; + } + } + return added; +} + +/** + * Calls a function with arguments for each child in an array where that function exists + * @param {Array} arr + * @param {string} func + * @param args + */ +export function perArrayChild(arr, func, ...args) +{ + const len = arr.length; + for (let i = 0; i < len; i++) + { + if (func in arr) arr[i][func](...args); + } +} + +/** + * Removes arguments from an array if they exist in it + * @param {Array} arr + * @param args + * @returns {boolean} true if something was removed + */ +export function removeFromArray(arr, ...args) +{ + let removed = false; + for (let i = 0; i < args.length; i++) + { + const index = arr.indexOf(args[i]); + if (index !== -1) + { + arr.splice(index, 1); + removed = true; + } + } + return removed; +} + +/** + * Returns a value if it is an array, or a new array with the object in it + * @param {*} a + * @returns {Array} + */ +export function toArray(a) +{ + return isArray(a) ? a : [a]; +} + +/** + * Returns an array containing only unique numbers + * @param {*} a + * @returns {Array} + */ +export function toUniqueArray(a) +{ + return Array.from(new Set(toArray(a))); +} \ No newline at end of file diff --git a/src/global/util/index.js b/src/global/util/index.js new file mode 100644 index 0000000..76feb72 --- /dev/null +++ b/src/global/util/index.js @@ -0,0 +1,5 @@ +export * from './arr'; +export * from './obj'; +export * from './type'; +export * from './uuid'; +export * from './url'; \ No newline at end of file diff --git a/src/global/util/obj.js b/src/global/util/obj.js new file mode 100644 index 0000000..28a562b --- /dev/null +++ b/src/global/util/obj.js @@ -0,0 +1,68 @@ +import {isTyped, isArrayLike} from './type'; +import {toArray} from './arr'; + +/** + * Assigns property values if they exist in a source object + * - Typed arrays are cloned/ copied to ensure no pass-by-reference errors + * + * @param {*} dest + * @param {*} src + * @param {string|string[]} attrs + */ +export function assignIfExists(dest, src, attrs) +{ + if (!src) return; + + attrs = toArray(attrs); + for (let i = 0; i < attrs.length; i++) + { + const attr = attrs[i]; + if (src[attr] !== undefined) + { + if (isArrayLike(dest[attr])) + { + if (isTyped(dest[attr])) + { + if (dest[attr].length !== src[attr].length) + { + const Constructor = dest[attr].constructor; + dest[attr] = new Constructor(src[attr]); + } + else + { + dest[attr].set(src[attr]); + } + } + else + { + dest[attr] = dest[attr].splice(dest[attr].length, 0); + for (let i = 0; i < src[attr].length; i++) + { + dest[attr].push(src[attr][i]); + } + } + } + else if (isTyped(src[attr])) + { + const Constructor = src[attr].constructor; + dest[attr] = new Constructor(src[attr]); + } + else + { + dest[attr] = src[attr]; + } + } + } +} + +/** + * Gets a source's property value if it exists else returns a default value + * @param {*} src + * @param {string} prop + * @param {*} defaultValue + * @returns {*} + */ +export function get(src, prop, defaultValue) +{ + return src && prop in src ? src[prop] : defaultValue; +} diff --git a/src/global/util/type.js b/src/global/util/type.js new file mode 100644 index 0000000..abe4c10 --- /dev/null +++ b/src/global/util/type.js @@ -0,0 +1,230 @@ +const toString = Object.prototype.toString; + +/** + * Checks if a value is an array + * @param {*} a + * @returns {boolean} + */ +export const isArray = Array.isArray; + +/** + * Checks if a value is an array or a typed array + * @param {*} a + * @returns {boolean} + */ +export function isArrayLike(a) +{ + return a ? isArray(a) || isTyped(a) : false; +} + +/** + * Checks if a value is a boolean + * @param {*} a + * @returns {boolean} + */ +export function isBoolean(a) +{ + return isTag(a, '[object Boolean]'); +} + +/** + * Checks if a value is a descriptor + * @author jay phelps + * @param {*} a + * @returns {boolean} + */ +export function isDescriptor(a) +{ + if (!a || !a.hasOwnProperty) + { + return false; + } + + const keys = ['value', 'initializer', 'get', 'set']; + + for (let i = 0, l = keys.length; i < l; i++) + { + if (a.hasOwnProperty(keys[i])) + { + return true; + } + } + + return false; +} + +/** + * Checks if a value is a number + * @param {*} a + * @returns {boolean} + */ +export function isNumber(a) +{ + return isTag(a, '[object Number]'); +} + +/** + * Checks if a value is a function + * @param {*} a + * @returns {boolean} + */ +export function isFunction(a) +{ + return typeof a === 'function'; +} + +/** + * Checks if a value is null or undefined + * @param {*} a + * @returns {boolean} + */ +export function isNoU(a) +{ + return a == null; +} + +/** + * Checks if a value is null + * @param {*} a + * @returns {boolean} + */ +export function isNull(a) +{ + return a === null; +} + +/** + * Checks if a value is an object and not null + * @param {*} a + * @returns {boolean} + */ +export function isObject(a) +{ + const type = typeof a; + return a !== null && (type === 'object' || type === 'function'); +} + +/** + * Checks if a value has the type object, and is not null + * @param {*} a + * @returns {boolean} + */ +export function isObjectLike(a) +{ + return a !== null && typeof a === 'object'; +} + +/** + * Checks if a value is a plain object + * @author lodash + * @param {*} a + * @returns {boolean} + */ +export function isPlain(a) +{ + if (!isObject(a) || !isTag(a,'[object Object]')) + { + return false; + } + + if (Object.getPrototypeOf(a) === null) + { + return true; + } + + let proto = a; + while (Object.getPrototypeOf(proto) !== null) + { + proto = Object.getPrototypeOf(proto); + } + + return Object.getPrototypeOf(a) === proto; +} + +/** + * Checks if a value is a primary type + * @param {*} a + * @returns {boolean} + */ +export function isPrimary(a) +{ + return isBoolean(a) || isNumber(a) || isString(a); +} + +/** + * Checks if a value is a string + * @param {*} a + * @returns {boolean} + */ +export function isString(a) +{ + return isTag(a, '[object String]'); +} + +/** + * Checks if a value is a symbol + * @param {*} a + * @returns {boolean} + */ +export function isSymbol(a) +{ + return typeof a === 'symbol' || isTag(a, '[object Symbol]'); +} + +/** + * Checks if a value has a given tag + * @param {*} a + * @param {string} tag + * @returns {boolean} + */ +export function isTag(a, tag) +{ + return toString.call(a) === tag; +} + +/** + * Checks if a value is a typed array + * @param {*} a + * @returns {boolean} + */ +export function isTyped(a) +{ + return a ? !!(a.buffer instanceof ArrayBuffer && a.BYTES_PER_ELEMENT) : false; +} + +/** + * Checks if a value is undefined + * @param {*} a + * @returns {boolean} + */ +export function isUndefined(a) +{ + return a === undefined; +} + +/** + * Checks if a value is arraylike and only contains numbers + * @param {*} a + * @returns {boolean} + */ +export function isVector(a) +{ + if (!a) + { + return false; + } + + if (isTyped(a)) + { + return true; + } + + if (isArray(a)) + { + for (let i = 0; i < a.length; i++) + { + if (!isNumber(a[i])) return false; + } + return true; + } +} \ No newline at end of file diff --git a/src/global/util/url.js b/src/global/util/url.js new file mode 100644 index 0000000..913a28f --- /dev/null +++ b/src/global/util/url.js @@ -0,0 +1,76 @@ + +const + url = {}, + query = window.location.search.substring(1), + split = query.split('&'); + +for (let i = 0; i < split.length; i++) +{ + const + result = split[i].split('='), + key = result[0].toLowerCase(), + value = unescape(result[1]); + + if (key) + { + let v = value.toLowerCase(); + url[key] = v === 'true' ? true : v === 'false' ? false : value; + } +} + +/** + * Gets the url as an object + * @returns {*} + */ +export function getURL() +{ + return Object.assign({}, url); +} + +/** + * Gets a string from the url, returning a default value if not found + * @param {string} key + * @param {string} defaultValue + * @returns {string} + */ +export function getURLString(key, defaultValue) +{ + key = key.toLowerCase(); + return key in url ? url[key] : defaultValue; +} + +/** + * Gets an integer from the url, returning a default value if not found + * @param {string} key + * @param {number} defaultValue + * @returns {number} + */ +export function getURLInteger(key, defaultValue) +{ + key = key.toLowerCase(); + return key in url ? parseInt(url[key], 10) : defaultValue; +} + +/** + * Gets a float from the url, returning a default value if not found + * @param {string} key + * @param {number} defaultValue + * @returns {number} + */ +export function getURLFloat(key, defaultValue) +{ + key = key.toLowerCase(); + return key in url ? parseFloat(url[key]) : defaultValue; +} + +/** + * Gets a boolean from the url, returning a default value if not found + * @param {string} key + * @param {boolean} defaultValue + * @returns {boolean} + */ +export function getURLBoolean(key, defaultValue) +{ + key = key.toLowerCase(); + return key in url ? url[key] : defaultValue; +} \ No newline at end of file diff --git a/src/global/util/uuid.js b/src/global/util/uuid.js new file mode 100644 index 0000000..fabb7c6 --- /dev/null +++ b/src/global/util/uuid.js @@ -0,0 +1,80 @@ +/** + * Identifies if UUIDs should be used for ID generation + * @type {?boolean} + */ +let USE_UUID = null; + +/** + * Internal object count + * @type {number} + */ +let OBJECT_COUNT = 0; + +/** + * Stores uuid scratch + * @type {?Array} + */ +let LUT = null; + +/** + * Generates a UUID + * @author Three.js + * @returns {string} + */ +function generateUUID() +{ + const + d0 = Math.random() * 0xffffffff | 0, + d1 = Math.random() * 0xffffffff | 0, + d2 = Math.random() * 0xffffffff | 0, + d3 = Math.random() * 0xffffffff | 0; + + return LUT[d0 & 0xff] + LUT[d0 >> 8 & 0xff] + LUT[d0 >> 16 & 0xff] + LUT[d0 >> 24 & 0xff] + '-' + + LUT[d1 & 0xff] + LUT[d1 >> 8 & 0xff] + '-' + LUT[d1 >> 16 & 0x0f | 0x40] + LUT[d1 >> 24 & 0xff] + '-' + + LUT[d2 & 0x3f | 0x80] + LUT[d2 >> 8 & 0xff] + '-' + LUT[d2 >> 16 & 0xff] + LUT[d2 >> 24 & 0xff] + + LUT[d3 & 0xff] + LUT[d3 >> 8 & 0xff] + LUT[d3 >> 16 & 0xff] + LUT[d3 >> 24 & 0xff]; +} + +/** + * Enables UUID's for ID generation + * @param {boolean} bool + * @throws When generateID has already been used and trying to set a different ID type + */ +export function enableUUID(bool) +{ + if (bool === USE_UUID) + { + return; + } + + if (USE_UUID !== null) + { + throw new Error('Cannot change id generation type once set'); + } + + if (bool) + { + LUT = []; + for (let i = 0; i < 256; i++) + { + LUT[i] = (i < 16 ? '0' : '') + (i).toString(16).toUpperCase(); + } + } + + USE_UUID = (bool); +} + +/** + * Generates an id + * - Defaults to Object IDs + * @returns {string|number} + */ +export function generateID() +{ + if (USE_UUID === null) + { + USE_UUID = false; + } + + return USE_UUID ? generateUUID() : OBJECT_COUNT++; +} diff --git a/src/index.js b/src/index.js index 478d466..3d61fd6 100644 --- a/src/index.js +++ b/src/index.js @@ -1,21 +1,22 @@ -import * as math from './math'; +import * as math from './global/math'; import * as core from './core'; import * as curve from './curve'; import * as eve from './eve'; import * as particle from './particle'; +import { device, store, resMan, logger, util } from './global'; export * from './core'; export * from './curve'; export * from './eve'; export * from './particle'; -export {math}; +export {math, util, device, store, resMan, logger}; const {vec4, mat4} = math; /** * Register globals */ -core.store.Register({ +store.Register({ paths: { 'res': 'https://developers.eveonline.com/ccpwgl/assetpath/1097993/' diff --git a/src/math/util.js b/src/math/util.js deleted file mode 100644 index fe30b1d..0000000 --- a/src/math/util.js +++ /dev/null @@ -1,247 +0,0 @@ -export const util = {}; - -/** - * Adds arguments to an array if they don't already exist in it - * @param {Array} arr - * @param args - * @returns {boolean} true if something was added - */ -util.addToArray = function(arr, ...args) -{ - let added = false; - for (let i = 0; i < args.length; i++) - { - if (arr.indexOf(args[i]) !== -1) - { - arr.push(args[i]); - added = true; - } - } - return added; -}; - -/** - * Assigns property values if they exist in a source object - * - Typed arrays are cloned/ copied to ensure no pass-by-reference errors - * - * @param {*} dest - * @param {*} src - * @param {string|string[]} attrs - */ -util.assignIfExists = function (dest, src, attrs) -{ - if (!src) return; - - attrs = util.toArray(attrs); - for (let i = 0; i < attrs.length; i++) - { - const attr = attrs[i]; - if (src[attr] !== undefined) - { - if (util.isTyped(dest[attr])) - { - if (dest[attr].length !== src[attr].length) - { - dest[attr] = new dest[attr]['constructor'](src[attr]); - } - else - { - dest[attr].set(src[attr]); - } - } - else if (util.isTyped(src[attr])) - { - dest[attr] = new src[attr]['constructor'](src[attr]); - } - else - { - dest[attr] = src[attr]; - } - } - } -}; - -/** - * Identifies if UUIDs should be used for ID generation - * @type {?boolean} - */ -let USE_UUID = null; - -/** - * Generates an object id - * @returns {number} - * @private - */ -const _generateObjectID = (function () -{ - let OBJECT_COUNT = 0; - return function _generateObjectID() - { - return OBJECT_COUNT++; - }; -})(); - -/** - * Generates a UUID - * @author Three.js - * @returns {string} - * @private - */ -const _generateUUID = (function () -{ - const lut = []; - for (let i = 0; i < 256; i++) - { - lut[i] = (i < 16 ? '0' : '') + (i).toString(16).toUpperCase(); - } - - return function _generateUUID() - { - const - d0 = Math.random() * 0xffffffff | 0, - d1 = Math.random() * 0xffffffff | 0, - d2 = Math.random() * 0xffffffff | 0, - d3 = Math.random() * 0xffffffff | 0; - - return lut[d0 & 0xff] + lut[d0 >> 8 & 0xff] + lut[d0 >> 16 & 0xff] + lut[d0 >> 24 & 0xff] + '-' + - lut[d1 & 0xff] + lut[d1 >> 8 & 0xff] + '-' + lut[d1 >> 16 & 0x0f | 0x40] + lut[d1 >> 24 & 0xff] + '-' + - lut[d2 & 0x3f | 0x80] + lut[d2 >> 8 & 0xff] + '-' + lut[d2 >> 16 & 0xff] + lut[d2 >> 24 & 0xff] + - lut[d3 & 0xff] + lut[d3 >> 8 & 0xff] + lut[d3 >> 16 & 0xff] + lut[d3 >> 24 & 0xff]; - }; -})(); - -/** - * Enables UUID's for ID generation - * @param {boolean} bool - * @throws When generateID have already been used and trying to set a different ID type - */ -util.enableUUID = function (bool) -{ - if (USE_UUID !== null && bool !== USE_UUID) - { - throw new Error('Cannot change id generation type once used'); - } - USE_UUID = (bool); -}; - -/** - * Generates an id - * - Defaults to Object IDs - * @returns {string|number} - */ -util.generateID = function () -{ - if (USE_UUID === null) USE_UUID = false; - return USE_UUID ? _generateUUID() : _generateObjectID(); -}; - -/** - * Gets a source's property value if it exists else returns a default value - * @param {*} src - * @param {string} prop - * @param {*} defaultValue - * @returns {*} - */ -util.get = function (src, prop, defaultValue) -{ - return src && prop in src ? src[prop] : defaultValue; -}; - -/** - * Checks if a value is an array - * @param {*} a - * @returns {boolean} - */ -util.isArray = Array.isArray; - -/** - * Checks if a value is array like - * @param {*} a - * @returns {boolean} - */ -util.isArrayLike = function (a) -{ - return a ? util.isArray(a) || util.isTyped(a) : false; -}; - -/** - * Checks if a value is a vector - * @param {*} a - * @returns {boolean} - */ -util.isVector = function (a) -{ - if (a) - { - if (util.isTyped(a)) - { - return true; - } - - if (util.isArray(a)) - { - for (let i = 0; i < a.length; i++) - { - if (typeof a[i] !== 'number') return false; - } - return true; - } - } - return false; -}; - -/** - * Checks if a value is a typed array - * @param {*} a - * @returns {boolean} - */ -util.isTyped = function (a) -{ - return a ? !!(a.buffer instanceof ArrayBuffer && a.BYTES_PER_ELEMENT) : false; -}; - -/** - * Calls a function with arguments for each child in an array where that function exists - * @param {Array} arr - * @param {string} func - * @param args - */ -util.perArrayChild = function (arr, func, ...args) -{ - const len = arr.length; - for (let i = 0; i < len; i++) - { - if (func in arr) arr[i][func](...args); - } -}; - -/** - * Removes arguments from an array if they exist in it - * @param {Array} arr - * @param args - * @returns {boolean} true if something was removed - */ -util.removeFromArray = function(arr, ...args) -{ - let removed = false; - for (let i = 0; i < args.length; i++) - { - const index = arr.indexOf(args[i]); - if (index !== -1) - { - arr.splice(index, 1); - removed = true; - } - } - return removed; -}; - -/** - * Returns a value if it is an array, or a new array with the object in it - * @param {*} a - * @returns {Array} - */ -util.toArray = function (a) -{ - return Array.isArray(a) ? a : [a]; -}; \ No newline at end of file diff --git a/src/particle/Tw2ParticleSystem.js b/src/particle/Tw2ParticleSystem.js index 175abcd..5e50e9c 100644 --- a/src/particle/Tw2ParticleSystem.js +++ b/src/particle/Tw2ParticleSystem.js @@ -1,5 +1,4 @@ -import {vec3, mat4, util} from '../math'; -import {device} from '../core'; +import {vec3, mat4, util, device} from '../global'; import {Tw2VertexDeclaration} from '../core'; import {Tw2ParticleElement} from './Tw2ParticleElement'; import {Tw2ParticleElementDeclaration} from './Tw2ParticleElement'; diff --git a/src/particle/constraints/Tw2ParticleConstraint.js b/src/particle/constraints/Tw2ParticleConstraint.js index 98a3808..cf24b36 100644 --- a/src/particle/constraints/Tw2ParticleConstraint.js +++ b/src/particle/constraints/Tw2ParticleConstraint.js @@ -1,5 +1,5 @@ /* eslint no-unused-vars:0 */ -import {util} from '../../math'; +import {util} from '../../global'; /** * Tw2ParticleConstraint base class diff --git a/src/particle/emitters/Tw2GpuUniqueEmitter.js b/src/particle/emitters/Tw2GpuUniqueEmitter.js index 3d56271..24b757c 100644 --- a/src/particle/emitters/Tw2GpuUniqueEmitter.js +++ b/src/particle/emitters/Tw2GpuUniqueEmitter.js @@ -1,4 +1,4 @@ -import { vec3, vec4 } from '../../math'; +import { vec3, vec4 } from '../../global'; import {Tw2ParticleEmitter} from './Tw2ParticleEmitter'; /** diff --git a/src/particle/emitters/Tw2ParticleEmitter.js b/src/particle/emitters/Tw2ParticleEmitter.js index 2005dbf..5db6c3f 100644 --- a/src/particle/emitters/Tw2ParticleEmitter.js +++ b/src/particle/emitters/Tw2ParticleEmitter.js @@ -1,5 +1,5 @@ /* eslint no-unused-vars:0 */ -import {util} from '../../math'; +import {util} from '../../global'; /** * Particle Emitter base class diff --git a/src/particle/forces/Tw2ParticleAttractorForce.js b/src/particle/forces/Tw2ParticleAttractorForce.js index 36b5d6b..cb0ca70 100644 --- a/src/particle/forces/Tw2ParticleAttractorForce.js +++ b/src/particle/forces/Tw2ParticleAttractorForce.js @@ -1,4 +1,4 @@ -import {vec3} from '../../math'; +import {vec3} from '../../global'; import {Tw2ParticleForce} from './Tw2ParticleForce'; /** diff --git a/src/particle/forces/Tw2ParticleDirectForce.js b/src/particle/forces/Tw2ParticleDirectForce.js index 1fcc92c..3affc70 100644 --- a/src/particle/forces/Tw2ParticleDirectForce.js +++ b/src/particle/forces/Tw2ParticleDirectForce.js @@ -1,4 +1,4 @@ -import {vec3} from '../../math'; +import {vec3} from '../../global'; import {Tw2ParticleForce} from './Tw2ParticleForce'; /** diff --git a/src/particle/forces/Tw2ParticleFluidDragForce.js b/src/particle/forces/Tw2ParticleFluidDragForce.js index 2b25004..097387e 100644 --- a/src/particle/forces/Tw2ParticleFluidDragForce.js +++ b/src/particle/forces/Tw2ParticleFluidDragForce.js @@ -1,4 +1,4 @@ -import {vec3} from '../../math'; +import {vec3} from '../../global'; import {Tw2ParticleForce} from './Tw2ParticleForce'; /** diff --git a/src/particle/forces/Tw2ParticleForce.js b/src/particle/forces/Tw2ParticleForce.js index 7f2b63e..28fde88 100644 --- a/src/particle/forces/Tw2ParticleForce.js +++ b/src/particle/forces/Tw2ParticleForce.js @@ -1,5 +1,5 @@ /* eslint no-unused-vars:0 */ -import {util, vec3, vec4} from '../../math'; +import {util, vec3, vec4} from '../../global'; /** * Tw2ParticleForce base class diff --git a/src/particle/forces/Tw2ParticleSpring.js b/src/particle/forces/Tw2ParticleSpring.js index a5e2e55..bd8e879 100644 --- a/src/particle/forces/Tw2ParticleSpring.js +++ b/src/particle/forces/Tw2ParticleSpring.js @@ -1,4 +1,4 @@ -import {vec3} from '../../math'; +import {vec3} from '../../global'; import {Tw2ParticleForce} from './Tw2ParticleForce'; /** diff --git a/src/particle/forces/Tw2ParticleTurbulenceForce.js b/src/particle/forces/Tw2ParticleTurbulenceForce.js index b3f2776..e723b19 100644 --- a/src/particle/forces/Tw2ParticleTurbulenceForce.js +++ b/src/particle/forces/Tw2ParticleTurbulenceForce.js @@ -1,4 +1,4 @@ -import {vec3, vec4, noise} from '../../math'; +import {vec3, vec4, noise} from '../../global'; import {Tw2ParticleForce} from './Tw2ParticleForce'; /** diff --git a/src/particle/generators/Tw2ParticleAttributeGenerator.js b/src/particle/generators/Tw2ParticleAttributeGenerator.js index a5a7eed..579ba91 100644 --- a/src/particle/generators/Tw2ParticleAttributeGenerator.js +++ b/src/particle/generators/Tw2ParticleAttributeGenerator.js @@ -1,5 +1,5 @@ /* eslint no-unused-vars:0 */ -import {util, vec3} from '../../math'; +import {util, vec3} from '../../global'; /** * Tw2ParticleAttributeGenerator base class diff --git a/src/particle/generators/Tw2RandomIntegerAttributeGenerator.js b/src/particle/generators/Tw2RandomIntegerAttributeGenerator.js index 441a833..5dff2a5 100644 --- a/src/particle/generators/Tw2RandomIntegerAttributeGenerator.js +++ b/src/particle/generators/Tw2RandomIntegerAttributeGenerator.js @@ -1,4 +1,4 @@ -import {vec4} from '../../math'; +import {vec4} from '../../global'; import {Tw2ParticleElementDeclaration} from '../Tw2ParticleElement'; import {Tw2ParticleAttributeGenerator} from './Tw2ParticleAttributeGenerator'; diff --git a/src/particle/generators/Tw2RandomUniformAttributeGenerator.js b/src/particle/generators/Tw2RandomUniformAttributeGenerator.js index b148f16..5504ab0 100644 --- a/src/particle/generators/Tw2RandomUniformAttributeGenerator.js +++ b/src/particle/generators/Tw2RandomUniformAttributeGenerator.js @@ -1,4 +1,4 @@ -import {vec4} from '../../math'; +import {vec4} from '../../global'; import {Tw2ParticleElementDeclaration} from '../Tw2ParticleElement'; import {Tw2ParticleAttributeGenerator} from './Tw2ParticleAttributeGenerator'; diff --git a/src/particle/generators/Tw2SphereShapeAttributeGenerator.js b/src/particle/generators/Tw2SphereShapeAttributeGenerator.js index 63b42a2..8b3ac9b 100644 --- a/src/particle/generators/Tw2SphereShapeAttributeGenerator.js +++ b/src/particle/generators/Tw2SphereShapeAttributeGenerator.js @@ -1,4 +1,4 @@ -import {vec3, quat} from '../../math'; +import {vec3, quat} from '../../global'; import {Tw2ParticleElementDeclaration} from '../Tw2ParticleElement'; import {Tw2ParticleAttributeGenerator} from './Tw2ParticleAttributeGenerator'; diff --git a/webpack.config.js b/webpack.config.js index 614c719..8a7ecfc 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -45,6 +45,18 @@ module.exports = { exclude: [/node_modules/], loader: 'babel-loader', options: { + 'plugins': [ + 'transform-decorators-legacy', + 'transform-class-properties', + [ + 'transform-builtin-extend', + { + 'globals': [ + 'Error' + ] + } + ] + ], 'presets': [ 'env' ] From de29581c77002b51ec110cb9fb6c10e39ccc3a84 Mon Sep 17 00:00:00 2001 From: cppctamber Date: Tue, 14 Aug 2018 23:46:08 +1200 Subject: [PATCH 02/25] Added new error classes for future Promise support - Added new error classes which will be used for future Promises support - Ran beautification rules - Reduced library size by a teeeeeny tiny bit :3 --- dist/ccpwgl_int.js | 2273 ++++++++++------- dist/ccpwgl_int.min.js | 2 +- src/core/Tw2Error.js | 309 ++- src/core/Tw2EventEmitter.js | 4 +- src/core/batch/Tw2BatchAccumulator.js | 2 +- src/core/curve/Tw2CurveSet.js | 2 +- src/core/data/Tw2BasicPerObjectData.js | 2 +- src/core/data/Tw2PerObjectData.js | 6 +- src/core/data/Tw2RawData.js | 4 +- src/core/mesh/Tw2Effect.js | 17 +- src/core/model/Tw2AnimationController.js | 4 +- src/core/parameter/Tw2Parameter.js | 2 +- src/core/parameter/Tw2TextureParameter.js | 39 +- src/core/post/Tw2PostProcess.js | 19 +- src/core/resource/Tw2GeometryRes.js | 47 +- src/core/resource/Tw2Resource.js | 11 +- src/core/resource/Tw2Shader.js | 94 +- src/core/resource/Tw2TextureRes.js | 38 +- src/core/resource/Tw2VideoRes.js | 20 +- src/core/sampler/Tw2SamplerOverride.js | 28 +- src/core/sampler/Tw2SamplerState.js | 30 +- src/core/vertex/Tw2VertexDeclaration.js | 35 +- src/curve/curves/Tw2ColorCurve2.js | 2 +- src/curve/curves/Tw2Curve.js | 4 +- src/curve/curves/Tw2ScalarCurve2.js | 2 +- src/curve/maya/Tw2MayaEulerRotationCurve.js | 2 +- src/curve/sequencers/Tw2ColorSequencer.js | 2 +- src/curve/sequencers/Tw2CurveSequencer.js | 2 +- src/curve/sequencers/Tw2EulerRotation.js | 2 +- .../sequencers/Tw2RGBAScalarSequencer.js | 6 +- src/curve/sequencers/Tw2ScalarSequencer.js | 14 +- src/curve/sequencers/Tw2VectorSequencer.js | 4 +- src/curve/sequencers/Tw2XYZScalarSequencer.js | 4 +- src/curve/sequencers/Tw2YPRSequencer.js | 6 +- src/curve/tracks/Tw2WbgTrack.js | 12 +- src/eve/EveSpaceScene.js | 2 +- src/eve/child/EveChild.js | 10 +- src/eve/child/EveChildContainer.js | 2 +- src/eve/effect/EveLensflare.js | 10 +- src/eve/effect/EveOccluder.js | 2 +- src/eve/effect/EveStretch.js | 2 +- src/eve/item/EveObjectSet.js | 10 +- src/eve/item/EveSpaceObjectDecal.js | 13 +- src/eve/item/EveSpriteSet.js | 100 +- src/eve/item/EveTurretSet.js | 14 +- src/eve/object/EveObject.js | 2 +- src/eve/object/EveShip.js | 2 +- src/eve/object/EveSpaceObject.js | 4 +- src/eve/object/EveTransform.js | 2 +- src/global/engine/Tw2Device.js | 36 +- src/global/engine/Tw2Logger.js | 6 +- src/global/engine/Tw2MotherLode.js | 17 +- src/global/engine/Tw2ResMan.js | 2 +- src/global/engine/Tw2Store.js | 13 +- src/global/engine/index.js | 8 +- src/global/index.js | 3 +- src/global/math/curve.js | 10 +- src/global/math/mat3.js | 1 + src/global/math/mat4.js | 5 +- src/global/math/noise.js | 5 +- src/global/math/num.js | 2 +- src/global/math/quat.js | 7 +- src/global/math/vec2.js | 1 + src/global/math/vec3.js | 1 + src/global/math/vec4.js | 1 + src/global/util/arr.js | 2 +- src/global/util/type.js | 2 +- src/global/util/url.js | 1 - src/index.js | 8 +- src/particle/Tw2ParticleSystem.js | 139 +- src/particle/emitters/Tw2GpuUniqueEmitter.js | 4 +- 71 files changed, 2165 insertions(+), 1334 deletions(-) diff --git a/dist/ccpwgl_int.js b/dist/ccpwgl_int.js index 819a4e3..9690112 100644 --- a/dist/ccpwgl_int.js +++ b/dist/ccpwgl_int.js @@ -140,19 +140,7 @@ Object.keys(_batch).forEach(function (key) { }); }); -var _class = __webpack_require__(36); - -Object.keys(_class).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _class[key]; - } - }); -}); - -var _curve = __webpack_require__(93); +var _curve = __webpack_require__(91); Object.keys(_curve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -164,7 +152,7 @@ Object.keys(_curve).forEach(function (key) { }); }); -var _data = __webpack_require__(103); +var _data = __webpack_require__(101); Object.keys(_data).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -200,7 +188,7 @@ Object.keys(_mesh).forEach(function (key) { }); }); -var _model = __webpack_require__(118); +var _model = __webpack_require__(116); Object.keys(_model).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -224,7 +212,7 @@ Object.keys(_parameter).forEach(function (key) { }); }); -var _post = __webpack_require__(124); +var _post = __webpack_require__(122); Object.keys(_post).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -284,7 +272,31 @@ Object.keys(_vertex).forEach(function (key) { }); }); -var _Tw2Float = __webpack_require__(126); +var _Tw2Error = __webpack_require__(124); + +Object.keys(_Tw2Error).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2Error[key]; + } + }); +}); + +var _Tw2EventEmitter = __webpack_require__(36); + +Object.keys(_Tw2EventEmitter).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _Tw2EventEmitter[key]; + } + }); +}); + +var _Tw2Float = __webpack_require__(125); Object.keys(_Tw2Float).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -296,7 +308,7 @@ Object.keys(_Tw2Float).forEach(function (key) { }); }); -var _Tw2Frustum = __webpack_require__(127); +var _Tw2Frustum = __webpack_require__(126); Object.keys(_Tw2Frustum).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -1504,12 +1516,23 @@ var Tw2Resource = exports.Tw2Resource = function () { } /** - * Checks to see if the resource is loading - * @returns {boolean} + * Gets an array of resource errors, or an empty array if there are none + * @returns {Array.} */ _createClass(Tw2Resource, [{ + key: 'GetErrors', + value: function GetErrors() { + return _global.resMan.motherLode.GetErrors(this.path); + } + + /** + * Checks to see if the resource is loading + * @returns {boolean} + */ + + }, { key: 'IsLoading', value: function IsLoading() { this.KeepAlive(); @@ -1627,7 +1650,7 @@ var Tw2Resource = exports.Tw2Resource = function () { value: function RegisterNotification(notification) { if (!this._notifications.includes(notification)) { this._notifications.push(notification); - if (this._isGood && 'RebuildCachedData' in notification) { + if (this.IsGood() && 'RebuildCachedData' in notification) { notification.RebuildCachedData(this); } } @@ -1690,7 +1713,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2VertexDeclaration = __webpack_require__(87); +var _Tw2VertexDeclaration = __webpack_require__(85); Object.keys(_Tw2VertexDeclaration).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2027,7 +2050,7 @@ Object.keys(_Tw2Curve).forEach(function (key) { }); }); -var _Tw2ColorCurve = __webpack_require__(128); +var _Tw2ColorCurve = __webpack_require__(127); Object.keys(_Tw2ColorCurve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2039,7 +2062,7 @@ Object.keys(_Tw2ColorCurve).forEach(function (key) { }); }); -var _Tw2ColorCurve2 = __webpack_require__(129); +var _Tw2ColorCurve2 = __webpack_require__(128); Object.keys(_Tw2ColorCurve2).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2051,7 +2074,7 @@ Object.keys(_Tw2ColorCurve2).forEach(function (key) { }); }); -var _Tw2EventCurve = __webpack_require__(130); +var _Tw2EventCurve = __webpack_require__(129); Object.keys(_Tw2EventCurve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2063,7 +2086,7 @@ Object.keys(_Tw2EventCurve).forEach(function (key) { }); }); -var _Tw2PerlinCurve = __webpack_require__(131); +var _Tw2PerlinCurve = __webpack_require__(130); Object.keys(_Tw2PerlinCurve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2075,7 +2098,7 @@ Object.keys(_Tw2PerlinCurve).forEach(function (key) { }); }); -var _Tw2QuaternionCurve = __webpack_require__(132); +var _Tw2QuaternionCurve = __webpack_require__(131); Object.keys(_Tw2QuaternionCurve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2087,7 +2110,7 @@ Object.keys(_Tw2QuaternionCurve).forEach(function (key) { }); }); -var _Tw2RandomConstantCurve = __webpack_require__(133); +var _Tw2RandomConstantCurve = __webpack_require__(132); Object.keys(_Tw2RandomConstantCurve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2099,7 +2122,7 @@ Object.keys(_Tw2RandomConstantCurve).forEach(function (key) { }); }); -var _Tw2RigidOrientation = __webpack_require__(134); +var _Tw2RigidOrientation = __webpack_require__(133); Object.keys(_Tw2RigidOrientation).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2111,7 +2134,7 @@ Object.keys(_Tw2RigidOrientation).forEach(function (key) { }); }); -var _Tw2RotationCurve = __webpack_require__(135); +var _Tw2RotationCurve = __webpack_require__(134); Object.keys(_Tw2RotationCurve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2123,7 +2146,7 @@ Object.keys(_Tw2RotationCurve).forEach(function (key) { }); }); -var _Tw2ScalarCurve = __webpack_require__(136); +var _Tw2ScalarCurve = __webpack_require__(135); Object.keys(_Tw2ScalarCurve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2135,7 +2158,7 @@ Object.keys(_Tw2ScalarCurve).forEach(function (key) { }); }); -var _Tw2ScalarCurve2 = __webpack_require__(137); +var _Tw2ScalarCurve2 = __webpack_require__(136); Object.keys(_Tw2ScalarCurve2).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2147,7 +2170,7 @@ Object.keys(_Tw2ScalarCurve2).forEach(function (key) { }); }); -var _Tw2SineCurve = __webpack_require__(138); +var _Tw2SineCurve = __webpack_require__(137); Object.keys(_Tw2SineCurve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2159,7 +2182,7 @@ Object.keys(_Tw2SineCurve).forEach(function (key) { }); }); -var _Tw2Vector2Curve = __webpack_require__(139); +var _Tw2Vector2Curve = __webpack_require__(138); Object.keys(_Tw2Vector2Curve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2171,7 +2194,7 @@ Object.keys(_Tw2Vector2Curve).forEach(function (key) { }); }); -var _Tw2Vector3Curve = __webpack_require__(140); +var _Tw2Vector3Curve = __webpack_require__(139); Object.keys(_Tw2Vector3Curve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2183,7 +2206,7 @@ Object.keys(_Tw2Vector3Curve).forEach(function (key) { }); }); -var _Tw2VectorCurve = __webpack_require__(141); +var _Tw2VectorCurve = __webpack_require__(140); Object.keys(_Tw2VectorCurve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2368,7 +2391,7 @@ Object.keys(_Tw2BatchAccumulator).forEach(function (key) { }); }); -var _Tw2ForwardingRenderBatch = __webpack_require__(90); +var _Tw2ForwardingRenderBatch = __webpack_require__(88); Object.keys(_Tw2ForwardingRenderBatch).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2392,7 +2415,7 @@ Object.keys(_Tw2GeometryBatch).forEach(function (key) { }); }); -var _Tw2GeometryLineBatch = __webpack_require__(91); +var _Tw2GeometryLineBatch = __webpack_require__(89); Object.keys(_Tw2GeometryLineBatch).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2416,7 +2439,7 @@ Object.keys(_Tw2RenderBatch).forEach(function (key) { }); }); -var _Tw2InstancedMeshBatch = __webpack_require__(92); +var _Tw2InstancedMeshBatch = __webpack_require__(90); Object.keys(_Tw2InstancedMeshBatch).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -2513,7 +2536,7 @@ exports.logger = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -var _class = __webpack_require__(36); +var _Tw2EventEmitter2 = __webpack_require__(36); var _util = __webpack_require__(16); @@ -2662,7 +2685,7 @@ var Tw2Logger = function (_Tw2EventEmitter) { }]); return Tw2Logger; -}(_class.Tw2EventEmitter); +}(_Tw2EventEmitter2.Tw2EventEmitter); /** * Console outputs @@ -2686,7 +2709,7 @@ var logger = exports.logger = new Tw2Logger('CCPWGL'); * The default event logger logger * @type {Tw2Logger} */ -_class.Tw2EventEmitter.logger = logger; +_Tw2EventEmitter2.Tw2EventEmitter.logger = logger; /***/ }), /* 18 */ @@ -2825,6 +2848,8 @@ var _util = __webpack_require__(16); var _Tw2Logger = __webpack_require__(17); +var _core = __webpack_require__(1); + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** @@ -3036,10 +3061,12 @@ var Tw2Store = function () { }, { key: 'RegisterConstructor', value: function RegisterConstructor(name, Constructor) { - if ((0, _util.isFunction)(Constructor)) { - return Tw2Store.SetStoreItem(this, 'constructor', name, Constructor); + // Don't store errors as library constructors + if (Constructor && (Constructor instanceof _core.Tw2Error || Constructor.isError)) { + return false; } - return false; + + return Tw2Store.SetStoreItem(this, 'constructor', name, Constructor, _util.isFunction); } /** @@ -3689,7 +3716,7 @@ Object.keys(_Tw2SamplerState).forEach(function (key) { }); }); -var _Tw2SamplerOverride = __webpack_require__(86); +var _Tw2SamplerOverride = __webpack_require__(84); Object.keys(_Tw2SamplerOverride).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -3989,7 +4016,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2EffectRes = __webpack_require__(120); +var _Tw2EffectRes = __webpack_require__(118); Object.keys(_Tw2EffectRes).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -4001,7 +4028,7 @@ Object.keys(_Tw2EffectRes).forEach(function (key) { }); }); -var _Tw2GeometryRes = __webpack_require__(122); +var _Tw2GeometryRes = __webpack_require__(120); Object.keys(_Tw2GeometryRes).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -4049,7 +4076,7 @@ Object.keys(_Tw2TextureRes).forEach(function (key) { }); }); -var _Tw2VideoRes = __webpack_require__(123); +var _Tw2VideoRes = __webpack_require__(121); Object.keys(_Tw2VideoRes).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -4252,7 +4279,7 @@ num.biCumulative = function (t, order) { /** * Exponential decay - * + * * @param {number} omega0 * @param {number} torque * @param {number} I - inertia @@ -6849,32 +6876,222 @@ function toUniqueArray(a) { Object.defineProperty(exports, "__esModule", { - value: true + value: true }); -var _Tw2EventEmitter = __webpack_require__(83); +var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -Object.keys(_Tw2EventEmitter).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2EventEmitter[key]; - } - }); -}); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var _Tw2Error = __webpack_require__(84); +/** + * Emitter privates + * @type {WeakMap} + */ +var PRIVATE = new WeakMap(); -Object.keys(_Tw2Error).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _Tw2Error[key]; +/** + * Tw2EventEmitter + * @class + */ + +var Tw2EventEmitter = exports.Tw2EventEmitter = function () { + function Tw2EventEmitter() { + _classCallCheck(this, Tw2EventEmitter); } - }); -}); + + _createClass(Tw2EventEmitter, [{ + key: 'emit', + + /** + * Emits an event + * @param {string} eventName + * @param {*} [e={}] + * @returns {Tw2EventEmitter} + * @emit event_added { eventName: string} - the first time an event is emitted + */ + value: function emit(eventName) { + var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + if (PRIVATE.has(this)) { + var events = PRIVATE.get(this); + eventName = eventName.toLowerCase(); + + // Short cut to creating a log output + if (e.log && !e.log.logged) { + e.log = this.log(eventName, e.log); + } + + if (eventName in events) { + events[eventName].forEach(function (value, key) { + key.call(value.context, e); + if (value.once) events[eventName].delete(key); + }); + } else { + events[eventName] = new Set(); + this.emit('event_added', { eventName: eventName }); + } + } + return this; + } + + /** + * Adds a listener to an event + * @param {Array|string} eventName + * @param {Function} listener + * @param {*} [context=undefined] + * @param {boolean} [once=false] + * @returns {Tw2EventEmitter} + */ + + }, { + key: 'on', + value: function on(eventName, listener) { + var _this = this; + + var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; + var once = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + + if (!PRIVATE.has(this)) PRIVATE.set(this, {}); + var events = PRIVATE.get(this); + + eventName = eventName.toLowerCase(); + if (!events[eventName]) { + events[eventName] = new Set(); + events[eventName].add(function () { + return _this.emit('event_added', { eventName: eventName }); + }, { once: true }); + } + events[eventName].add(listener, { context: context, once: once }); + return this; + } + + /** + * Adds a listener to an event, and clears it after it's first emit + * @param {string} eventName + * @param {Function} listener + * @param {*} [context] + * @returns {Tw2EventEmitter} + */ + + }, { + key: 'once', + value: function once(eventName, listener, context) { + return this.on(eventName, listener, context, true); + } + + /** + * Removes a listener from a specific event or from all by passing '*' as the eventName + * @param {string} eventName + * @param {Function} listener + * @returns {Tw2EventEmitter} + */ + + }, { + key: 'off', + value: function off(eventName, listener) { + if (PRIVATE.has(this)) { + var events = PRIVATE.get(this); + eventName = eventName.toLowerCase(); + if (eventName in events) events[eventName].delete(listener); + } + return this; + } + + /** + * Deletes an event and it's listeners + * @param {string} eventName + * @returns {Tw2EventEmitter} + * @emit event_removed { eventName: String } + */ + + }, { + key: 'del', + value: function del(eventName) { + if (PRIVATE.has(this)) { + var events = PRIVATE.get(this); + eventName = eventName.toLowerCase(); + if (eventName in events) { + this.emit('event_removed', { eventName: eventName }); + delete events[eventName]; + } + } + return this; + } + + /** + * Clears a listener from all events + * @param {Function} listener + * @returns {Tw2EventEmitter} + */ + + }, { + key: 'clr', + value: function clr(listener) { + if (PRIVATE.has(this)) { + var events = PRIVATE.get(this); + for (var eventName in events) { + if (events.hasOwnProperty(eventName) && events[eventName].has(listener)) { + events[eventName].delete(listener); + } + } + } + return this; + } + + /** + * Kills all events and listeners from the emitter + * @returns {Tw2EventEmitter} + * @emit event_kill + */ + + }, { + key: 'kill', + value: function kill() { + if (PRIVATE.has(this)) { + this.emit('event_kill'); + PRIVATE.set(this, {}); + } + return this; + } + + /** + * Logs an event log + * @param {string} eventName + * @param {eventLog} eventLog + * @returns {eventLog} + */ + + }, { + key: 'log', + value: function log(eventName, eventLog) { + if (this.constructor.logger) { + this.constructor.logger.log(eventName, eventLog); + } + return eventLog; + } + + /** + * Assigns the event emitter's prototypes to a constructor/class + * @param Constructor + */ + + }], [{ + key: 'assign', + value: function assign(Constructor) { + Object.assign(Constructor.prototype, Tw2EventEmitter.prototype); + } + }]); + + return Tw2EventEmitter; +}(); + +/** + * Global logger + * @type {*} + */ + + +Tw2EventEmitter.logger = null; /***/ }), /* 37 */ @@ -6894,7 +7111,7 @@ var _Tw2Logger = __webpack_require__(17); var _Tw2Store = __webpack_require__(19); -var _Tw2MotherLode = __webpack_require__(85); +var _Tw2MotherLode = __webpack_require__(83); var _Tw2LoadingObject = __webpack_require__(38); @@ -8404,7 +8621,8 @@ var Tw2Effect = exports.Tw2Effect = function () { var p = this.techniques[technique][pass], rp = this.shader.techniques[technique].passes[pass], - d = _global.device; + d = _global.device, + gl = d.gl; var program = d.IsAlphaTestEnabled() && rp.shadowShaderProgram ? rp.shadowShaderProgram : rp.shaderProgram; @@ -8423,10 +8641,10 @@ var Tw2Effect = exports.Tw2Effect = function () { } var cbh = program.constantBufferHandles; - if (cbh[0]) d.gl.uniform4fv(cbh[0], p.stages[0].constantBuffer); - if (cbh[7]) d.gl.uniform4fv(cbh[7], p.stages[1].constantBuffer); - if (d.perFrameVSData && cbh[1]) d.gl.uniform4fv(cbh[1], d.perFrameVSData.data); - if (d.perFramePSData && cbh[2]) d.gl.uniform4fv(cbh[2], d.perFramePSData.data); + if (cbh[0]) gl.uniform4fv(cbh[0], p.stages[0].constantBuffer); + if (cbh[7]) gl.uniform4fv(cbh[7], p.stages[1].constantBuffer); + if (d.perFrameVSData && cbh[1]) gl.uniform4fv(cbh[1], d.perFrameVSData.data); + if (d.perFramePSData && cbh[2]) gl.uniform4fv(cbh[2], d.perFramePSData.data); if (d.perObjectData) d.perObjectData.SetPerObjectDataToDevice(cbh); } @@ -8754,7 +8972,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" /** * Tw2TextureParameter - * + * * @param {string} [name=''] - Name of the texture parameter * @param {string} [texturePath=''] - The texture's resource path * @property {string} name @@ -8929,44 +9147,48 @@ var Tw2TextureParameter = exports.Tw2TextureParameter = function (_Tw2Parameter) value: function UpdateOverrides() { if (this.useAllOverrides) { this._sampler = this._sampler || new _sampler.Tw2SamplerState(); - var sampler = this._sampler; + + var wrapModes = _global.device.wrapModes, + gl = _global.device.gl, + sampler = this._sampler; + if (this.filterMode === 1) { switch (this.mipFilterMode) { case 0: - sampler.minFilter = _global.device.gl.NEAREST; + sampler.minFilter = gl.NEAREST; break; case 1: - sampler.minFilter = _global.device.gl.NEAREST_MIPMAP_NEAREST; + sampler.minFilter = gl.NEAREST_MIPMAP_NEAREST; break; default: - sampler.minFilter = _global.device.gl.NEAREST_MIPMAP_LINEAR; + sampler.minFilter = gl.NEAREST_MIPMAP_LINEAR; } - sampler.minFilterNoMips = _global.device.gl.NEAREST; - sampler.magFilter = _global.device.gl.NEAREST; + sampler.minFilterNoMips = gl.NEAREST; + sampler.magFilter = gl.NEAREST; } else { switch (this.mipFilterMode) { case 0: - sampler.minFilter = _global.device.gl.LINEAR; + sampler.minFilter = gl.LINEAR; break; case 1: - sampler.minFilter = _global.device.gl.LINEAR_MIPMAP_NEAREST; + sampler.minFilter = gl.LINEAR_MIPMAP_NEAREST; break; default: - sampler.minFilter = _global.device.gl.LINEAR_MIPMAP_LINEAR; + sampler.minFilter = gl.LINEAR_MIPMAP_LINEAR; } - sampler.minFilterNoMips = _global.device.gl.LINEAR; - sampler.magFilter = _global.device.gl.LINEAR; + sampler.minFilterNoMips = gl.LINEAR; + sampler.magFilter = gl.LINEAR; } - sampler.addressU = _global.device.wrapModes[this.addressUMode]; - sampler.addressV = _global.device.wrapModes[this.addressVMode]; - sampler.addressW = _global.device.wrapModes[this.addressWMode]; + sampler.addressU = wrapModes[this.addressUMode]; + sampler.addressV = wrapModes[this.addressVMode]; + sampler.addressW = wrapModes[this.addressWMode]; sampler.anisotropy = this.maxAnisotropy; sampler.ComputeHash(); } else if (this._sampler) { @@ -9104,16 +9326,17 @@ var Tw2SamplerState = exports.Tw2SamplerState = function () { function Tw2SamplerState() { _classCallCheck(this, Tw2SamplerState); + var gl = _global.device.gl; this.name = ''; this.registerIndex = 0; - this.minFilter = _global.device.gl.LINEAR; - this.maxFilter = _global.device.gl.LINEAR; - this.minFilterNoMips = _global.device.gl.LINEAR; - this.addressU = _global.device.gl.REPEAT; - this.addressV = _global.device.gl.REPEAT; - this.addressW = _global.device.gl.REPEAT; + this.minFilter = gl.LINEAR; + this.maxFilter = gl.LINEAR; + this.minFilterNoMips = gl.LINEAR; + this.addressU = gl.REPEAT; + this.addressV = gl.REPEAT; + this.addressW = gl.REPEAT; this.anisotropy = 1; - this.samplerType = _global.device.gl.TEXTURE_2D; + this.samplerType = gl.TEXTURE_2D; this.isVolume = false; this.hash = 0; } @@ -9148,14 +9371,15 @@ var Tw2SamplerState = exports.Tw2SamplerState = function () { key: 'Apply', value: function Apply(hasMipMaps) { var targetType = this.samplerType, - d = _global.device; + d = _global.device, + gl = d.gl; - d.gl.texParameteri(targetType, d.gl.TEXTURE_WRAP_S, hasMipMaps ? this.addressU : d.gl.CLAMP_TO_EDGE); - d.gl.texParameteri(targetType, d.gl.TEXTURE_WRAP_T, hasMipMaps ? this.addressV : d.gl.CLAMP_TO_EDGE); - d.gl.texParameteri(targetType, d.gl.TEXTURE_MIN_FILTER, hasMipMaps ? this.minFilter : this.minFilterNoMips); - d.gl.texParameteri(targetType, d.gl.TEXTURE_MAG_FILTER, this.magFilter); + gl.texParameteri(targetType, gl.TEXTURE_WRAP_S, hasMipMaps ? this.addressU : gl.CLAMP_TO_EDGE); + gl.texParameteri(targetType, gl.TEXTURE_WRAP_T, hasMipMaps ? this.addressV : gl.CLAMP_TO_EDGE); + gl.texParameteri(targetType, gl.TEXTURE_MIN_FILTER, hasMipMaps ? this.minFilter : this.minFilterNoMips); + gl.texParameteri(targetType, gl.TEXTURE_MAG_FILTER, this.magFilter); if (d.ext.AnisotropicFilter && d.enableAnisotropicFiltering) { - d.gl.texParameterf(targetType, d.ext.AnisotropicFilter.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(this.anisotropy, d.ext.AnisotropicFilter.maxAnisotropy)); + gl.texParameterf(targetType, d.ext.AnisotropicFilter.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(this.anisotropy, d.ext.AnisotropicFilter.maxAnisotropy)); } } @@ -9274,7 +9498,7 @@ Object.keys(_Tw2Parameter).forEach(function (key) { }); }); -var _Tw2FloatParameter = __webpack_require__(96); +var _Tw2FloatParameter = __webpack_require__(94); Object.keys(_Tw2FloatParameter).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9286,7 +9510,7 @@ Object.keys(_Tw2FloatParameter).forEach(function (key) { }); }); -var _Tw2MatrixParameter = __webpack_require__(97); +var _Tw2MatrixParameter = __webpack_require__(95); Object.keys(_Tw2MatrixParameter).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9298,7 +9522,7 @@ Object.keys(_Tw2MatrixParameter).forEach(function (key) { }); }); -var _Tw2TransformParameter = __webpack_require__(98); +var _Tw2TransformParameter = __webpack_require__(96); Object.keys(_Tw2TransformParameter).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9310,7 +9534,7 @@ Object.keys(_Tw2TransformParameter).forEach(function (key) { }); }); -var _Tw2VariableParameter = __webpack_require__(99); +var _Tw2VariableParameter = __webpack_require__(97); Object.keys(_Tw2VariableParameter).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9322,7 +9546,7 @@ Object.keys(_Tw2VariableParameter).forEach(function (key) { }); }); -var _Tw2Vector2Parameter = __webpack_require__(100); +var _Tw2Vector2Parameter = __webpack_require__(98); Object.keys(_Tw2Vector2Parameter).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9334,7 +9558,7 @@ Object.keys(_Tw2Vector2Parameter).forEach(function (key) { }); }); -var _Tw2Vector3Parameter = __webpack_require__(101); +var _Tw2Vector3Parameter = __webpack_require__(99); Object.keys(_Tw2Vector3Parameter).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9346,7 +9570,7 @@ Object.keys(_Tw2Vector3Parameter).forEach(function (key) { }); }); -var _Tw2Vector4Parameter = __webpack_require__(102); +var _Tw2Vector4Parameter = __webpack_require__(100); Object.keys(_Tw2Vector4Parameter).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9419,12 +9643,14 @@ var Tw2PerObjectData = exports.Tw2PerObjectData = function () { _createClass(Tw2PerObjectData, [{ key: 'SetPerObjectDataToDevice', value: function SetPerObjectDataToDevice(constantBufferHandles) { + var gl = _global.device.gl; + if (this.perObjectVSData && constantBufferHandles[3]) { - _global.device.gl.uniform4fv(constantBufferHandles[3], this.perObjectVSData.data); + gl.uniform4fv(constantBufferHandles[3], this.perObjectVSData.data); } if (this.perObjectPSData && constantBufferHandles[4]) { - _global.device.gl.uniform4fv(constantBufferHandles[4], this.perObjectPSData.data); + gl.uniform4fv(constantBufferHandles[4], this.perObjectPSData.data); } } @@ -9462,7 +9688,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2BlendShapeData = __webpack_require__(105); +var _Tw2BlendShapeData = __webpack_require__(103); Object.keys(_Tw2BlendShapeData).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9474,7 +9700,7 @@ Object.keys(_Tw2BlendShapeData).forEach(function (key) { }); }); -var _Tw2GeometryAnimation = __webpack_require__(106); +var _Tw2GeometryAnimation = __webpack_require__(104); Object.keys(_Tw2GeometryAnimation).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9486,7 +9712,7 @@ Object.keys(_Tw2GeometryAnimation).forEach(function (key) { }); }); -var _Tw2GeometryBone = __webpack_require__(107); +var _Tw2GeometryBone = __webpack_require__(105); Object.keys(_Tw2GeometryBone).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9498,7 +9724,7 @@ Object.keys(_Tw2GeometryBone).forEach(function (key) { }); }); -var _Tw2GeometryCurve = __webpack_require__(108); +var _Tw2GeometryCurve = __webpack_require__(106); Object.keys(_Tw2GeometryCurve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9510,7 +9736,7 @@ Object.keys(_Tw2GeometryCurve).forEach(function (key) { }); }); -var _Tw2GeometryMesh = __webpack_require__(109); +var _Tw2GeometryMesh = __webpack_require__(107); Object.keys(_Tw2GeometryMesh).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9522,7 +9748,7 @@ Object.keys(_Tw2GeometryMesh).forEach(function (key) { }); }); -var _Tw2GeometryMeshArea = __webpack_require__(110); +var _Tw2GeometryMeshArea = __webpack_require__(108); Object.keys(_Tw2GeometryMeshArea).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9534,7 +9760,7 @@ Object.keys(_Tw2GeometryMeshArea).forEach(function (key) { }); }); -var _Tw2GeometryMeshBinding = __webpack_require__(111); +var _Tw2GeometryMeshBinding = __webpack_require__(109); Object.keys(_Tw2GeometryMeshBinding).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9546,7 +9772,7 @@ Object.keys(_Tw2GeometryMeshBinding).forEach(function (key) { }); }); -var _Tw2GeometryModel = __webpack_require__(112); +var _Tw2GeometryModel = __webpack_require__(110); Object.keys(_Tw2GeometryModel).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9558,7 +9784,7 @@ Object.keys(_Tw2GeometryModel).forEach(function (key) { }); }); -var _Tw2GeometrySkeleton = __webpack_require__(113); +var _Tw2GeometrySkeleton = __webpack_require__(111); Object.keys(_Tw2GeometrySkeleton).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9570,7 +9796,7 @@ Object.keys(_Tw2GeometrySkeleton).forEach(function (key) { }); }); -var _Tw2GeometryTrackGroup = __webpack_require__(114); +var _Tw2GeometryTrackGroup = __webpack_require__(112); Object.keys(_Tw2GeometryTrackGroup).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9582,7 +9808,7 @@ Object.keys(_Tw2GeometryTrackGroup).forEach(function (key) { }); }); -var _Tw2GeometryTransformTrack = __webpack_require__(115); +var _Tw2GeometryTransformTrack = __webpack_require__(113); Object.keys(_Tw2GeometryTransformTrack).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9617,7 +9843,7 @@ Object.keys(_Tw2Effect).forEach(function (key) { }); }); -var _Tw2InstancedMesh = __webpack_require__(116); +var _Tw2InstancedMesh = __webpack_require__(114); Object.keys(_Tw2InstancedMesh).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -9653,7 +9879,7 @@ Object.keys(_Tw2MeshArea).forEach(function (key) { }); }); -var _Tw2MeshLineArea = __webpack_require__(117); +var _Tw2MeshLineArea = __webpack_require__(115); Object.keys(_Tw2MeshLineArea).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10031,22 +10257,22 @@ var Tw2TextureRes = exports.Tw2TextureRes = function (_Tw2Resource) { _createClass(Tw2TextureRes, [{ key: 'Prepare', value: function Prepare(text) { - var d = _global.device, - format = this.images[0]['ccpGLFormat'] ? this.images[0]['ccpGLFormat'] : d.gl.RGBA; + var gl = _global.device.gl, + format = this.images[0]['ccpGLFormat'] ? this.images[0]['ccpGLFormat'] : gl.RGBA; switch (text) { case 'cube': - this.texture = d.gl.createTexture(); - d.gl.bindTexture(d.gl.TEXTURE_CUBE_MAP, this.texture); + this.texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_CUBE_MAP, this.texture); var canvas = document.createElement('canvas'); canvas.width = canvas.height = this.images[0].height; var ctx = canvas.getContext('2d'); for (var j = 0; j < 6; ++j) { ctx.drawImage(this.images[0], j * canvas.width, 0, canvas.width, canvas.height, 0, 0, canvas.width, canvas.height); - d.gl.texImage2D(d.gl.TEXTURE_CUBE_MAP_POSITIVE_X + j, 0, format, format, d.gl.UNSIGNED_BYTE, canvas); + gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + j, 0, format, format, gl.UNSIGNED_BYTE, canvas); } - d.gl.generateMipmap(d.gl.TEXTURE_CUBE_MAP); - d.gl.bindTexture(d.gl.TEXTURE_CUBE_MAP, null); + gl.generateMipmap(gl.TEXTURE_CUBE_MAP); + gl.bindTexture(gl.TEXTURE_CUBE_MAP, null); this.width = canvas.width; this.height = canvas.height; this.hasMipMaps = true; @@ -10056,12 +10282,12 @@ var Tw2TextureRes = exports.Tw2TextureRes = function (_Tw2Resource) { //case 'png': default: - this.texture = d.gl.createTexture(); - d.gl.bindTexture(d.gl.TEXTURE_2D, this.texture); - d.gl.texImage2D(d.gl.TEXTURE_2D, 0, format, format, d.gl.UNSIGNED_BYTE, this.images[0]); + this.texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, format, format, gl.UNSIGNED_BYTE, this.images[0]); this.hasMipMaps = Tw2TextureRes.IsPowerOfTwo(this.images[0].width) && Tw2TextureRes.IsPowerOfTwo(this.images[0].height); - if (this.hasMipMaps) d.gl.generateMipmap(d.gl.TEXTURE_2D); - d.gl.bindTexture(d.gl.TEXTURE_2D, null); + if (this.hasMipMaps) gl.generateMipmap(gl.TEXTURE_2D); + gl.bindTexture(gl.TEXTURE_2D, null); this.width = this.images[0].width; this.height = this.images[0].height; this._isAttached = false; @@ -10174,23 +10400,24 @@ var Tw2TextureRes = exports.Tw2TextureRes = function (_Tw2Resource) { }, { key: 'Bind', value: function Bind(sampler, slices) { - var d = _global.device; + var d = _global.device, + gl = d.gl; this.KeepAlive(); var targetType = sampler.samplerType; - if (targetType !== (this.isCube ? d.gl.TEXTURE_CUBE_MAP : d.gl.TEXTURE_2D)) return; + if (targetType !== (this.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D)) return; if (!this.texture) { - var texture = targetType === d.gl.TEXTURE_2D ? d.GetFallbackTexture() : d.GetFallbackCubeMap(); - d.gl.bindTexture(targetType, texture); + var texture = targetType === gl.TEXTURE_2D ? d.GetFallbackTexture() : d.GetFallbackCubeMap(); + gl.bindTexture(targetType, texture); return; } if (sampler.isVolume) { - d.gl.uniform1f(slices, this.height / this.width); + gl.uniform1f(slices, this.height / this.width); } - d.gl.bindTexture(targetType, this.texture); + gl.bindTexture(targetType, this.texture); if (sampler.hash !== this._currentSampler) { sampler.Apply(this.hasMipMaps); this._currentSampler = sampler.hash; @@ -10519,7 +10746,7 @@ Object.keys(_curves).forEach(function (key) { }); }); -var _sequencers = __webpack_require__(142); +var _sequencers = __webpack_require__(141); Object.keys(_sequencers).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10531,7 +10758,7 @@ Object.keys(_sequencers).forEach(function (key) { }); }); -var _tracks = __webpack_require__(151); +var _tracks = __webpack_require__(150); Object.keys(_tracks).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10543,7 +10770,7 @@ Object.keys(_tracks).forEach(function (key) { }); }); -var _maya = __webpack_require__(154); +var _maya = __webpack_require__(153); Object.keys(_maya).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10578,7 +10805,7 @@ Object.keys(_EveChild).forEach(function (key) { }); }); -var _EveChildBillboard = __webpack_require__(160); +var _EveChildBillboard = __webpack_require__(159); Object.keys(_EveChildBillboard).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10590,7 +10817,7 @@ Object.keys(_EveChildBillboard).forEach(function (key) { }); }); -var _EveChildContainer = __webpack_require__(161); +var _EveChildContainer = __webpack_require__(160); Object.keys(_EveChildContainer).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10602,7 +10829,7 @@ Object.keys(_EveChildContainer).forEach(function (key) { }); }); -var _EveChildExplosion = __webpack_require__(162); +var _EveChildExplosion = __webpack_require__(161); Object.keys(_EveChildExplosion).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10614,7 +10841,7 @@ Object.keys(_EveChildExplosion).forEach(function (key) { }); }); -var _EveChildMesh = __webpack_require__(163); +var _EveChildMesh = __webpack_require__(162); Object.keys(_EveChildMesh).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10626,7 +10853,7 @@ Object.keys(_EveChildMesh).forEach(function (key) { }); }); -var _EveChildParticleSystem = __webpack_require__(164); +var _EveChildParticleSystem = __webpack_require__(163); Object.keys(_EveChildParticleSystem).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10870,7 +11097,7 @@ Object.keys(_EveObject).forEach(function (key) { }); }); -var _EveEffectRoot = __webpack_require__(171); +var _EveEffectRoot = __webpack_require__(170); Object.keys(_EveEffectRoot).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10882,7 +11109,7 @@ Object.keys(_EveEffectRoot).forEach(function (key) { }); }); -var _EveMissile = __webpack_require__(172); +var _EveMissile = __webpack_require__(171); Object.keys(_EveMissile).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10894,7 +11121,7 @@ Object.keys(_EveMissile).forEach(function (key) { }); }); -var _EvePlanet = __webpack_require__(173); +var _EvePlanet = __webpack_require__(172); Object.keys(_EvePlanet).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -10906,7 +11133,7 @@ Object.keys(_EvePlanet).forEach(function (key) { }); }); -var _EveShip = __webpack_require__(174); +var _EveShip = __webpack_require__(173); Object.keys(_EveShip).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11862,7 +12089,7 @@ Object.keys(_EveObjectSet).forEach(function (key) { }); }); -var _EveBoosterSet = __webpack_require__(175); +var _EveBoosterSet = __webpack_require__(174); Object.keys(_EveBoosterSet).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11874,7 +12101,7 @@ Object.keys(_EveBoosterSet).forEach(function (key) { }); }); -var _EveCurveLineSet = __webpack_require__(176); +var _EveCurveLineSet = __webpack_require__(175); Object.keys(_EveCurveLineSet).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11886,7 +12113,7 @@ Object.keys(_EveCurveLineSet).forEach(function (key) { }); }); -var _EveLocator = __webpack_require__(177); +var _EveLocator = __webpack_require__(176); Object.keys(_EveLocator).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11898,7 +12125,7 @@ Object.keys(_EveLocator).forEach(function (key) { }); }); -var _EvePlaneSet = __webpack_require__(178); +var _EvePlaneSet = __webpack_require__(177); Object.keys(_EvePlaneSet).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11910,7 +12137,7 @@ Object.keys(_EvePlaneSet).forEach(function (key) { }); }); -var _EveSpaceObjectDecal = __webpack_require__(179); +var _EveSpaceObjectDecal = __webpack_require__(178); Object.keys(_EveSpaceObjectDecal).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11922,7 +12149,7 @@ Object.keys(_EveSpaceObjectDecal).forEach(function (key) { }); }); -var _EveSpotlightSet = __webpack_require__(180); +var _EveSpotlightSet = __webpack_require__(179); Object.keys(_EveSpotlightSet).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11934,7 +12161,7 @@ Object.keys(_EveSpotlightSet).forEach(function (key) { }); }); -var _EveSpriteSet = __webpack_require__(181); +var _EveSpriteSet = __webpack_require__(180); Object.keys(_EveSpriteSet).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11946,7 +12173,7 @@ Object.keys(_EveSpriteSet).forEach(function (key) { }); }); -var _EveTurretSet = __webpack_require__(182); +var _EveTurretSet = __webpack_require__(181); Object.keys(_EveTurretSet).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -11994,7 +12221,7 @@ Object.keys(_curve).forEach(function (key) { }); }); -var _eve = __webpack_require__(159); +var _eve = __webpack_require__(158); Object.keys(_eve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -12006,7 +12233,7 @@ Object.keys(_eve).forEach(function (key) { }); }); -var _particle = __webpack_require__(185); +var _particle = __webpack_require__(184); Object.keys(_particle).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -17194,7 +17421,7 @@ var _vertex = __webpack_require__(9); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var WebGLDebugUtil = __webpack_require__(88); +var WebGLDebugUtil = __webpack_require__(86); /** * Tw2Device @@ -18605,7 +18832,6 @@ exports.getURLString = getURLString; exports.getURLInteger = getURLInteger; exports.getURLFloat = getURLFloat; exports.getURLBoolean = getURLBoolean; - var url = {}, query = window.location.search.substring(1), split = query.split('&'); @@ -18680,324 +18906,6 @@ function getURLBoolean(key, defaultValue) { "use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/** - * Emitter privates - * @type {WeakMap} - */ -var PRIVATE = new WeakMap(); - -/** - * Tw2EventEmitter - * @class - */ - -var Tw2EventEmitter = exports.Tw2EventEmitter = function () { - function Tw2EventEmitter() { - _classCallCheck(this, Tw2EventEmitter); - } - - _createClass(Tw2EventEmitter, [{ - key: 'emit', - - /** - * Emits an event - * @param {string} eventName - * @param {*} [e={}] - * @returns {Tw2EventEmitter} - * @emit event_added { eventName: string} - the first time an event is emitted - */ - value: function emit(eventName) { - var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - if (PRIVATE.has(this)) { - var events = PRIVATE.get(this); - eventName = eventName.toLowerCase(); - - // Short cut to creating a log output - if (e.log && !e.log.logged) { - e.log = this.log(eventName, e.log); - } - - if (eventName in events) { - events[eventName].forEach(function (value, key) { - key.call(value.context, e); - if (value.once) events[eventName].delete(key); - }); - } else { - events[eventName] = new Set(); - this.emit('event_added', { eventName: eventName }); - } - } - return this; - } - - /** - * Adds a listener to an event - * @param {Array|string} eventName - * @param {Function} listener - * @param {*} [context=undefined] - * @param {boolean} [once=false] - * @returns {Tw2EventEmitter} - */ - - }, { - key: 'on', - value: function on(eventName, listener) { - var _this = this; - - var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; - var once = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; - - if (!PRIVATE.has(this)) PRIVATE.set(this, {}); - var events = PRIVATE.get(this); - - eventName = eventName.toLowerCase(); - if (!events[eventName]) { - events[eventName] = new Set(); - events[eventName].add(function () { - return _this.emit('event_added', { eventName: eventName }); - }, { once: true }); - } - events[eventName].add(listener, { context: context, once: once }); - return this; - } - - /** - * Adds a listener to an event, and clears it after it's first emit - * @param {string} eventName - * @param {Function} listener - * @param {*} [context] - * @returns {Tw2EventEmitter} - */ - - }, { - key: 'once', - value: function once(eventName, listener, context) { - return this.on(eventName, listener, context, true); - } - - /** - * Removes a listener from a specific event or from all by passing '*' as the eventName - * @param {string} eventName - * @param {Function} listener - * @returns {Tw2EventEmitter} - */ - - }, { - key: 'off', - value: function off(eventName, listener) { - if (PRIVATE.has(this)) { - var events = PRIVATE.get(this); - eventName = eventName.toLowerCase(); - if (eventName in events) events[eventName].delete(listener); - } - return this; - } - - /** - * Deletes an event and it's listeners - * @param {string} eventName - * @returns {Tw2EventEmitter} - * @emit event_removed { eventName: String } - */ - - }, { - key: 'del', - value: function del(eventName) { - if (PRIVATE.has(this)) { - var events = PRIVATE.get(this); - eventName = eventName.toLowerCase(); - if (eventName in events) { - this.emit('event_removed', { eventName: eventName }); - delete events[eventName]; - } - } - return this; - } - - /** - * Clears a listener from all events - * @param {Function} listener - * @returns {Tw2EventEmitter} - */ - - }, { - key: 'clr', - value: function clr(listener) { - if (PRIVATE.has(this)) { - var events = PRIVATE.get(this); - for (var eventName in events) { - if (events.hasOwnProperty(eventName) && events[eventName].has(listener)) { - events[eventName].delete(listener); - } - } - } - return this; - } - - /** - * Kills all events and listeners from the emitter - * @returns {Tw2EventEmitter} - * @emit event_kill - */ - - }, { - key: 'kill', - value: function kill() { - if (PRIVATE.has(this)) { - this.emit('event_kill'); - PRIVATE.set(this, {}); - } - return this; - } - - /** - * Logs an event log - * @param {string} eventName - * @param {eventLog} eventLog - * @returns {eventLog} - */ - - }, { - key: 'log', - value: function log(eventName, eventLog) { - if (this.constructor.logger) { - this.constructor.logger.log(eventName, eventLog); - } - return eventLog; - } - - /** - * Assigns the event emitter's prototypes to a constructor/class - * @param Constructor - */ - - }], [{ - key: 'assign', - value: function assign(Constructor) { - Object.assign(Constructor.prototype, Tw2EventEmitter.prototype); - } - }]); - - return Tw2EventEmitter; -}(); - -/** - * Global logger - * @type {*} - */ - - -Tw2EventEmitter.logger = null; - -/***/ }), -/* 84 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Tw2Error = undefined; - -var _index = __webpack_require__(16); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -function _extendableBuiltin(cls) { - function ExtendableBuiltin() { - var instance = Reflect.construct(cls, Array.from(arguments)); - Object.setPrototypeOf(instance, Object.getPrototypeOf(this)); - return instance; - } - - ExtendableBuiltin.prototype = Object.create(cls.prototype, { - constructor: { - value: cls, - enumerable: false, - writable: true, - configurable: true - } - }); - - if (Object.setPrototypeOf) { - Object.setPrototypeOf(ExtendableBuiltin, cls); - } else { - ExtendableBuiltin.__proto__ = cls; - } - - return ExtendableBuiltin; -} - -var HAS_CAPTURE_STACK_TRACE = (0, _index.isFunction)(Error['captureStackTrace']); - -/** - * Extends standard errors - * @param {string|{}} data - Error message or an object containing relevant data - * @param {string} [defaultMessage] - The default error message - */ - -var Tw2Error = exports.Tw2Error = function (_extendableBuiltin2) { - _inherits(Tw2Error, _extendableBuiltin2); - - function Tw2Error() { - var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var defaultMessage = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Undefined error'; - - _classCallCheck(this, Tw2Error); - - var _this = _possibleConstructorReturn(this, (Tw2Error.__proto__ || Object.getPrototypeOf(Tw2Error)).call(this)); - - if ((0, _index.isString)(data)) { - data = { message: data }; - } else { - data.message = data.message || defaultMessage; - } - - _this.message = data.message; - _this.name = _this.constructor.name; - _this.data = data; - - if (HAS_CAPTURE_STACK_TRACE) { - Error['captureStackTrace'](_this, Tw2Error); - } else { - _this.stack = new Error(data.message).stack; - } - return _this; - } - - return Tw2Error; -}(_extendableBuiltin(Error)); - -/** - * Fallback if instanceof Error isn't supported by client - * @type {boolean} - */ - - -Tw2Error.isError = true; - -/***/ }), -/* 85 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - Object.defineProperty(exports, "__esModule", { value: true }); @@ -19008,7 +18916,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons /** * Manages loaded resources - * + * * @property {Object} _loadedObjects - loaded resources * @property {{string:Array}} _errors - Not implemented yet * @class @@ -19024,23 +18932,24 @@ var Tw2MotherLode = exports.Tw2MotherLode = function () { /** * Adds an error log for a given path * @param {string} path - * @param {eventLog} log + * @param {Tw2Error|Error} err */ _createClass(Tw2MotherLode, [{ key: 'AddError', - value: function AddError(path, log) { + value: function AddError(path, err) { this._errors[path] = this._errors[path] || []; - if (!this._errors[path].includes(log)) { - this._errors[path].push(log); + + if (!this._errors[path].includes(err)) { + this._errors[path].push(err); } } /** * Gets a path's error logs * @param {string} path - * @returns {?Array} + * @returns {?Array} */ }, { @@ -19052,7 +18961,7 @@ var Tw2MotherLode = exports.Tw2MotherLode = function () { /** * Finds a loaded object by it's file path * @param {string} path - * @returns {Tw2LoadingObject} + * @returns {Tw2LoadingObject|Tw2Resource} */ }, { @@ -19132,7 +19041,7 @@ var Tw2MotherLode = exports.Tw2MotherLode = function () { if (this._loadedObjects.hasOwnProperty(path)) { var res = this._loadedObjects[path]; if (!res.doNotPurge) { - if (res._isPurged) { + if (res.IsPurged()) { logger.log('res.event', { msg: 'Unloaded ', path: res.path, @@ -19161,7 +19070,7 @@ var Tw2MotherLode = exports.Tw2MotherLode = function () { }(); /***/ }), -/* 86 */ +/* 84 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -19217,46 +19126,50 @@ var Tw2SamplerOverride = exports.Tw2SamplerOverride = function Tw2SamplerOverrid sampler.registerIndex = originalSampler.registerIndex; sampler.name = originalSampler.name; + var wrapModes = _global.device.wrapModes, + gl = _global.device.gl; + + if (this.filter === 1) { switch (this.mipFilter) { case 0: - sampler.minFilter = _global.device.gl.NEAREST; + sampler.minFilter = gl.NEAREST; break; case 1: - sampler.minFilter = _global.device.gl.NEAREST_MIPMAP_NEAREST; + sampler.minFilter = gl.NEAREST_MIPMAP_NEAREST; break; default: - sampler.minFilter = _global.device.gl.NEAREST_MIPMAP_LINEAR; + sampler.minFilter = gl.NEAREST_MIPMAP_LINEAR; } - sampler.minFilterNoMips = _global.device.gl.NEAREST; + sampler.minFilterNoMips = gl.NEAREST; } else { switch (this.mipFilter) { case 0: - sampler.minFilter = _global.device.gl.LINEAR; + sampler.minFilter = gl.LINEAR; break; case 1: - sampler.minFilter = _global.device.gl.LINEAR_MIPMAP_NEAREST; + sampler.minFilter = gl.LINEAR_MIPMAP_NEAREST; break; default: - sampler.minFilter = _global.device.gl.LINEAR_MIPMAP_LINEAR; + sampler.minFilter = gl.LINEAR_MIPMAP_LINEAR; } - sampler.minFilterNoMips = _global.device.gl.LINEAR; + sampler.minFilterNoMips = gl.LINEAR; } if (this.filter === 3 || this.mipFilter === 3) { sampler.anisotropy = Math.max(this.maxAnisotropy, 1); } - sampler.magFilter = this.filter === 1 ? _global.device.gl.NEAREST : _global.device.gl.LINEAR; - sampler.addressU = _global.device.wrapModes[this.addressU]; - sampler.addressV = _global.device.wrapModes[this.addressV]; - sampler.addressW = _global.device.wrapModes[this.addressW]; + sampler.magFilter = this.filter === 1 ? gl.NEAREST : gl.LINEAR; + sampler.addressU = wrapModes[this.addressU]; + sampler.addressV = wrapModes[this.addressV]; + sampler.addressW = wrapModes[this.addressW]; sampler.samplerType = originalSampler.samplerType; sampler.isVolume = originalSampler.isVolume; sampler.ComputeHash(); @@ -19267,7 +19180,7 @@ var Tw2SamplerOverride = exports.Tw2SamplerOverride = function Tw2SamplerOverrid }; /***/ }), -/* 87 */ +/* 85 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -19363,6 +19276,8 @@ var Tw2VertexDeclaration = exports.Tw2VertexDeclaration = function () { }, { key: 'SetDeclaration', value: function SetDeclaration(inputDecl, stride) { + var gl = _global.device.gl; + var index = 0; for (var i = 0; i < inputDecl._elementsSorted.length; ++i) { var el = inputDecl._elementsSorted[i]; @@ -19370,8 +19285,8 @@ var Tw2VertexDeclaration = exports.Tw2VertexDeclaration = function () { while (true) { if (index >= this._elementsSorted.length) { - _global.device.gl.disableVertexAttribArray(el.location); - _global.device.gl.vertexAttrib4f(el.location, 0, 0, 0, 0); + gl.disableVertexAttribArray(el.location); + gl.vertexAttrib4f(el.location, 0, 0, 0, 0); break; } @@ -19379,8 +19294,8 @@ var Tw2VertexDeclaration = exports.Tw2VertexDeclaration = function () { cmp = Tw2VertexDeclaration.CompareDeclarationElements(input, el); if (cmp > 0) { - _global.device.gl.disableVertexAttribArray(el.location); - _global.device.gl.vertexAttrib4f(el.location, 0, 0, 0, 0); + gl.disableVertexAttribArray(el.location); + gl.vertexAttrib4f(el.location, 0, 0, 0, 0); break; } @@ -19388,8 +19303,8 @@ var Tw2VertexDeclaration = exports.Tw2VertexDeclaration = function () { if (input.customSetter) { input.customSetter(el); } else { - _global.device.gl.enableVertexAttribArray(el.location); - _global.device.gl.vertexAttribPointer(el.location, input.elements, input.type, false, stride, input.offset); + gl.enableVertexAttribArray(el.location); + gl.vertexAttribPointer(el.location, input.elements, input.type, false, stride, input.offset); } break; } @@ -19413,8 +19328,10 @@ var Tw2VertexDeclaration = exports.Tw2VertexDeclaration = function () { value: function SetPartialDeclaration(inputDecl, stride) { var usageOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; var divisor = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; + var ext = _global.device.ext, + gl = _global.device.gl, + resetData = []; - var resetData = []; var index = 0; for (var i = 0; i < inputDecl._elementsSorted.length; ++i) { @@ -19429,9 +19346,10 @@ var Tw2VertexDeclaration = exports.Tw2VertexDeclaration = function () { if (input.customSetter) { input.customSetter(el); } else { - _global.device.gl.enableVertexAttribArray(el.location); - _global.device.gl.vertexAttribPointer(el.location, input.elements, input.type, false, stride, input.offset); - _global.device.ext.vertexAttribDivisor(el.location, divisor); + gl.enableVertexAttribArray(el.location); + gl.vertexAttribPointer(el.location, input.elements, input.type, false, stride, input.offset); + + ext.vertexAttribDivisor(el.location, divisor); if (divisor) { resetData.push(el.location); @@ -19440,8 +19358,8 @@ var Tw2VertexDeclaration = exports.Tw2VertexDeclaration = function () { break; } else if (cmp > 0) { if (!divisor) { - _global.device.gl.disableVertexAttribArray(el.location); - _global.device.gl.vertexAttrib4f(el.location, 0, 0, 0, 0); + gl.disableVertexAttribArray(el.location); + gl.vertexAttrib4f(el.location, 0, 0, 0, 0); } break; } @@ -19449,8 +19367,8 @@ var Tw2VertexDeclaration = exports.Tw2VertexDeclaration = function () { index++; if (index >= this._elementsSorted.length) { if (!divisor) { - _global.device.gl.disableVertexAttribArray(el.location); - _global.device.gl.vertexAttrib4f(el.location, 0, 0, 0, 0); + gl.disableVertexAttribArray(el.location); + gl.vertexAttrib4f(el.location, 0, 0, 0, 0); } return resetData; } @@ -19573,7 +19491,7 @@ Tw2VertexDeclaration.Type = { }; /***/ }), -/* 88 */ +/* 86 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global) {/* @@ -20777,10 +20695,10 @@ return { module.exports = WebGLDebugUtils; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(89))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(87))) /***/ }), -/* 89 */ +/* 87 */ /***/ (function(module, exports) { var g; @@ -20807,7 +20725,7 @@ module.exports = g; /***/ }), -/* 90 */ +/* 88 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -20865,7 +20783,7 @@ var Tw2ForwardingRenderBatch = exports.Tw2ForwardingRenderBatch = function (_Tw2 }(_Tw2RenderBatch2.Tw2RenderBatch); /***/ }), -/* 91 */ +/* 89 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -20919,7 +20837,7 @@ var Tw2GeometryLineBatch = exports.Tw2GeometryLineBatch = function (_Tw2Geometry }(_Tw2GeometryBatch2.Tw2GeometryBatch); /***/ }), -/* 92 */ +/* 90 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -20977,7 +20895,7 @@ var Tw2InstancedMeshBatch = exports.Tw2InstancedMeshBatch = function (_Tw2Geomet }(_Tw2GeometryBatch2.Tw2GeometryBatch); /***/ }), -/* 93 */ +/* 91 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -20987,7 +20905,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2CurveSet = __webpack_require__(94); +var _Tw2CurveSet = __webpack_require__(92); Object.keys(_Tw2CurveSet).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -20999,7 +20917,7 @@ Object.keys(_Tw2CurveSet).forEach(function (key) { }); }); -var _Tw2ValueBinding = __webpack_require__(95); +var _Tw2ValueBinding = __webpack_require__(93); Object.keys(_Tw2ValueBinding).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -21012,7 +20930,7 @@ Object.keys(_Tw2ValueBinding).forEach(function (key) { }); /***/ }), -/* 94 */ +/* 92 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -21145,7 +21063,7 @@ var Tw2CurveSet = exports.Tw2CurveSet = function () { }(); /***/ }), -/* 95 */ +/* 93 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -21450,7 +21368,7 @@ var Tw2ValueBinding = exports.Tw2ValueBinding = function () { }(); /***/ }), -/* 96 */ +/* 94 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -21588,7 +21506,7 @@ var Tw2FloatParameter = exports.Tw2FloatParameter = function (_Tw2Parameter) { Tw2FloatParameter.constantBufferSize = 1; /***/ }), -/* 97 */ +/* 95 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -21735,7 +21653,7 @@ var Tw2MatrixParameter = exports.Tw2MatrixParameter = function (_Tw2VectorParame Tw2MatrixParameter.constantBufferSize = 16; /***/ }), -/* 98 */ +/* 96 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -21897,7 +21815,7 @@ var Tw2TransformParameter = exports.Tw2TransformParameter = function (_Tw2Parame Tw2TransformParameter.constantBufferSize = 16; /***/ }), -/* 99 */ +/* 97 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22022,7 +21940,7 @@ var Tw2VariableParameter = exports.Tw2VariableParameter = function (_Tw2Paramete }(_Tw2Parameter2.Tw2Parameter); /***/ }), -/* 100 */ +/* 98 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22118,7 +22036,7 @@ var Tw2Vector2Parameter = exports.Tw2Vector2Parameter = function (_Tw2VectorPara Tw2Vector2Parameter.constantBufferSize = 2; /***/ }), -/* 101 */ +/* 99 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22234,7 +22152,7 @@ var Tw2Vector3Parameter = exports.Tw2Vector3Parameter = function (_Tw2VectorPara Tw2Vector3Parameter.constantBufferSize = 3; /***/ }), -/* 102 */ +/* 100 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22370,7 +22288,7 @@ var Tw2Vector4Parameter = exports.Tw2Vector4Parameter = function (_Tw2VectorPara Tw2Vector4Parameter.constantBufferSize = 4; /***/ }), -/* 103 */ +/* 101 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22380,7 +22298,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2BasicPerObjectData = __webpack_require__(104); +var _Tw2BasicPerObjectData = __webpack_require__(102); Object.keys(_Tw2BasicPerObjectData).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -22417,7 +22335,7 @@ Object.keys(_Tw2RawData).forEach(function (key) { }); /***/ }), -/* 104 */ +/* 102 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22505,7 +22423,7 @@ var Tw2BasicPerObjectData = exports.Tw2BasicPerObjectData = function (_Tw2PerObj exports.EveBasicPerObjectData = Tw2BasicPerObjectData; /***/ }), -/* 105 */ +/* 103 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22540,7 +22458,7 @@ var Tw2BlendShapeData = exports.Tw2BlendShapeData = function Tw2BlendShapeData() }; /***/ }), -/* 106 */ +/* 104 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22568,7 +22486,7 @@ var Tw2GeometryAnimation = exports.Tw2GeometryAnimation = function Tw2GeometryAn }; /***/ }), -/* 107 */ +/* 105 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22644,7 +22562,7 @@ Tw2GeometryBone.global = { }; /***/ }), -/* 108 */ +/* 106 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22674,7 +22592,7 @@ var Tw2GeometryCurve = exports.Tw2GeometryCurve = function Tw2GeometryCurve() { }; /***/ }), -/* 109 */ +/* 107 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22731,7 +22649,7 @@ var Tw2GeometryMesh = exports.Tw2GeometryMesh = function Tw2GeometryMesh() { }; /***/ }), -/* 110 */ +/* 108 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22770,7 +22688,7 @@ var Tw2GeometryMeshArea = exports.Tw2GeometryMeshArea = function Tw2GeometryMesh }; /***/ }), -/* 111 */ +/* 109 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22796,7 +22714,7 @@ var Tw2GeometryMeshBinding = exports.Tw2GeometryMeshBinding = function Tw2Geomet }; /***/ }), -/* 112 */ +/* 110 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22854,7 +22772,7 @@ var Tw2GeometryModel = exports.Tw2GeometryModel = function () { }(); /***/ }), -/* 113 */ +/* 111 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22878,7 +22796,7 @@ var Tw2GeometrySkeleton = exports.Tw2GeometrySkeleton = function Tw2GeometrySkel }; /***/ }), -/* 114 */ +/* 112 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22906,7 +22824,7 @@ var Tw2GeometryTrackGroup = exports.Tw2GeometryTrackGroup = function Tw2Geometry }; /***/ }), -/* 115 */ +/* 113 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -22936,7 +22854,7 @@ var Tw2GeometryTransformTrack = exports.Tw2GeometryTransformTrack = function Tw2 }; /***/ }), -/* 116 */ +/* 114 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -23089,7 +23007,7 @@ var Tw2InstancedMesh = exports.Tw2InstancedMesh = function (_Tw2Mesh) { }(_Tw2Mesh2.Tw2Mesh); /***/ }), -/* 117 */ +/* 115 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -23136,7 +23054,7 @@ var Tw2MeshLineArea = exports.Tw2MeshLineArea = function (_Tw2MeshArea) { Tw2MeshLineArea.batchType = _batch.Tw2GeometryLineBatch; /***/ }), -/* 118 */ +/* 116 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -23158,7 +23076,7 @@ Object.keys(_Tw2Animation).forEach(function (key) { }); }); -var _Tw2AnimationController = __webpack_require__(119); +var _Tw2AnimationController = __webpack_require__(117); Object.keys(_Tw2AnimationController).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -23219,7 +23137,7 @@ Object.keys(_Tw2TrackGroup).forEach(function (key) { }); /***/ }), -/* 119 */ +/* 117 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -24040,7 +23958,7 @@ Tw2AnimationController.scratch = { }; /***/ }), -/* 120 */ +/* 118 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -24059,7 +23977,7 @@ var _reader = __webpack_require__(26); var _Tw2Resource2 = __webpack_require__(8); -var _Tw2Shader = __webpack_require__(121); +var _Tw2Shader = __webpack_require__(119); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -24292,7 +24210,7 @@ var Tw2EffectRes = exports.Tw2EffectRes = function (_Tw2Resource) { Tw2EffectRes.prototype.requestResponseType = 'arraybuffer'; /***/ }), -/* 121 */ +/* 119 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -24341,20 +24259,25 @@ var Tw2Shader = exports.Tw2Shader = function () { this.techniques = {}; this.annotations = {}; - var d = _global.device; + var wrapModes = _global.device.wrapModes, + gl = _global.device.gl; + var techniqueCount = 1; if (version > 6) { techniqueCount = reader.ReadUInt8(); } + for (var t = 0; t < techniqueCount; ++t) { var technique = { name: 'Main', passes: [] }; + if (version > 6) { technique.name = ReadString(); } + this.techniques[technique.name] = technique; var passCount = reader.ReadUInt8(); @@ -24519,37 +24442,37 @@ var Tw2Shader = exports.Tw2Shader = function () { if (minFilter === 1) { switch (mipFilter) { case 0: - sampler.minFilter = d.gl.NEAREST; + sampler.minFilter = gl.NEAREST; break; case 1: - sampler.minFilter = d.gl.NEAREST_MIPMAP_NEAREST; + sampler.minFilter = gl.NEAREST_MIPMAP_NEAREST; break; default: - sampler.minFilter = d.gl.NEAREST_MIPMAP_LINEAR; + sampler.minFilter = gl.NEAREST_MIPMAP_LINEAR; } - sampler.minFilterNoMips = d.gl.NEAREST; + sampler.minFilterNoMips = gl.NEAREST; } else { switch (mipFilter) { case 0: - sampler.minFilter = d.gl.LINEAR; + sampler.minFilter = gl.LINEAR; break; case 1: - sampler.minFilter = d.gl.LINEAR_MIPMAP_NEAREST; + sampler.minFilter = gl.LINEAR_MIPMAP_NEAREST; break; default: - sampler.minFilter = d.gl.LINEAR_MIPMAP_LINEAR; + sampler.minFilter = gl.LINEAR_MIPMAP_LINEAR; } - sampler.minFilterNoMips = d.gl.LINEAR; + sampler.minFilterNoMips = gl.LINEAR; } - sampler.magFilter = magFilter === 1 ? d.gl.NEAREST : d.gl.LINEAR; - sampler.addressU = d.wrapModes[addressU]; - sampler.addressV = d.wrapModes[addressV]; - sampler.addressW = d.wrapModes[addressW]; + sampler.magFilter = magFilter === 1 ? gl.NEAREST : gl.LINEAR; + sampler.addressU = wrapModes[addressU]; + sampler.addressV = wrapModes[addressV]; + sampler.addressW = wrapModes[addressW]; if (minFilter === 3 || magFilter === 3 || mipFilter === 3) { sampler.anisotropy = Math.max(maxAnisotropy, 1); @@ -24557,7 +24480,7 @@ var Tw2Shader = exports.Tw2Shader = function () { for (var n = 0; n < stage.textures.length; ++n) { if (stage.textures[n].registerIndex === sampler.registerIndex) { - sampler.samplerType = stage.textures[n].type === 4 ? d.gl.TEXTURE_CUBE_MAP : d.gl.TEXTURE_2D; + sampler.samplerType = stage.textures[n].type === 4 ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D; sampler.isVolume = stage.textures[n].type === 3; break; } @@ -24642,7 +24565,9 @@ var Tw2Shader = exports.Tw2Shader = function () { _createClass(Tw2Shader, [{ key: 'ApplyPass', value: function ApplyPass(technique, pass) { - var d = _global.device; + var d = _global.device, + gl = d.gl; + pass = this.techniques[technique].passes[pass]; for (var i = 0; i < pass.states.length; ++i) { @@ -24650,10 +24575,10 @@ var Tw2Shader = exports.Tw2Shader = function () { } if (d.IsAlphaTestEnabled()) { - d.gl.useProgram(pass.shadowShaderProgram.program); + gl.useProgram(pass.shadowShaderProgram.program); d.shadowHandles = pass.shadowShaderProgram; } else { - d.gl.useProgram(pass.shaderProgram.program); + gl.useProgram(pass.shaderProgram.program); d.shadowHandles = null; } } @@ -24705,19 +24630,21 @@ var Tw2Shader = exports.Tw2Shader = function () { }], [{ key: 'CompileShader', value: function CompileShader(stageType, prefix, shaderCode, path) { - var d = _global.device, - shader = d.gl.createShader(stageType === 0 ? d.gl.VERTEX_SHADER : d.gl.FRAGMENT_SHADER); + var ext = _global.device.ext, + gl = _global.device.gl, + shader = gl.createShader(stageType === 0 ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER); - if (d.ext.ShaderBinary) { - d.ext.ShaderBinary['shaderBinary'](shader, shaderCode); + + if (ext.ShaderBinary) { + ext.ShaderBinary['shaderBinary'](shader, shaderCode); } else { var source = prefix + (_global.util.isString(shaderCode) ? shaderCode : String.fromCharCode.apply(null, shaderCode)); source = source.substr(0, source.length - 1); - d.gl.shaderSource(shader, source); - d.gl.compileShader(shader); + gl.shaderSource(shader, source); + gl.compileShader(shader); } - if (!d.gl.getShaderParameter(shader, d.gl.COMPILE_STATUS)) { + if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { _global.logger.log('res.error', { log: 'error', src: ['Tw2Shader', 'CompileShader'], @@ -24725,7 +24652,7 @@ var Tw2Shader = exports.Tw2Shader = function () { path: path, type: 'shader.compile', value: stageType === 0 ? 'VERTEX' : 'FRAGMENT', - data: _global.device.gl.getShaderInfoLog(shader) + data: gl.getShaderInfoLog(shader) }); return null; } @@ -24744,46 +24671,46 @@ var Tw2Shader = exports.Tw2Shader = function () { }, { key: 'CreateProgram', value: function CreateProgram(vertexShader, fragmentShader, pass, path) { - var d = _global.device, + var gl = _global.device.gl, program = {}; - program.program = d.gl.createProgram(); - d.gl.attachShader(program.program, vertexShader); - d.gl.attachShader(program.program, fragmentShader); - d.gl.linkProgram(program.program); + program.program = gl.createProgram(); + gl.attachShader(program.program, vertexShader); + gl.attachShader(program.program, fragmentShader); + gl.linkProgram(program.program); - if (!d.gl.getProgramParameter(program.program, d.gl.LINK_STATUS)) { + if (!gl.getProgramParameter(program.program, gl.LINK_STATUS)) { _global.logger.log('res.error', { log: 'error', src: ['Tw2Shader', 'CreateProgram'], msg: 'Error linking shaders', path: path, type: 'shader.linkstatus', - data: _global.device.gl.getProgramInfoLog(program.program) + data: gl.getProgramInfoLog(program.program) }); return null; } - d.gl.useProgram(program.program); + gl.useProgram(program.program); program.constantBufferHandles = []; for (var j = 0; j < 16; ++j) { - program.constantBufferHandles[j] = d.gl.getUniformLocation(program.program, 'cb' + j); + program.constantBufferHandles[j] = gl.getUniformLocation(program.program, 'cb' + j); } program.samplerHandles = []; for (var _j = 0; _j < 16; ++_j) { - program.samplerHandles[_j] = d.gl.getUniformLocation(program.program, 's' + _j); - d.gl.uniform1i(program.samplerHandles[_j], _j); + program.samplerHandles[_j] = gl.getUniformLocation(program.program, 's' + _j); + gl.uniform1i(program.samplerHandles[_j], _j); } for (var _j2 = 0; _j2 < 16; ++_j2) { - program.samplerHandles[_j2 + 12] = d.gl.getUniformLocation(program.program, 'vs' + _j2); - d.gl.uniform1i(program.samplerHandles[_j2 + 12], _j2 + 12); + program.samplerHandles[_j2 + 12] = gl.getUniformLocation(program.program, 'vs' + _j2); + gl.uniform1i(program.samplerHandles[_j2 + 12], _j2 + 12); } program.input = new _vertex.Tw2VertexDeclaration(); for (var _j3 = 0; _j3 < pass.stages[0].inputDefinition.elements.length; ++_j3) { - var location = d.gl.getAttribLocation(program.program, 'attr' + _j3); + var location = gl.getAttribLocation(program.program, 'attr' + _j3); if (location >= 0) { var el = new _vertex.Tw2VertexElement(pass.stages[0].inputDefinition.elements[_j3].usage, pass.stages[0].inputDefinition.elements[_j3].usageIndex); el.location = location; @@ -24792,14 +24719,14 @@ var Tw2Shader = exports.Tw2Shader = function () { } program.input.RebuildHash(); - program.shadowStateInt = d.gl.getUniformLocation(program.program, 'ssi'); - program.shadowStateFloat = d.gl.getUniformLocation(program.program, 'ssf'); - program.shadowStateYFlip = d.gl.getUniformLocation(program.program, 'ssyf'); - d.gl.uniform3f(program.shadowStateYFlip, 0, 0, 1); + program.shadowStateInt = gl.getUniformLocation(program.program, 'ssi'); + program.shadowStateFloat = gl.getUniformLocation(program.program, 'ssf'); + program.shadowStateYFlip = gl.getUniformLocation(program.program, 'ssyf'); + gl.uniform3f(program.shadowStateYFlip, 0, 0, 1); program.volumeSlices = []; for (var _j4 = 0; _j4 < pass.stages[1].samplers.length; ++_j4) { if (pass.stages[1].samplers[_j4].isVolume) { - program.volumeSlices[pass.stages[1].samplers[_j4].registerIndex] = d.gl.getUniformLocation(program.program, 's' + pass.stages[1].samplers[_j4].registerIndex + 'sl'); + program.volumeSlices[pass.stages[1].samplers[_j4].registerIndex] = gl.getUniformLocation(program.program, 's' + pass.stages[1].samplers[_j4].registerIndex + 'sl'); } } return program; @@ -24818,7 +24745,7 @@ var Tw2Shader = exports.Tw2Shader = function () { Tw2Shader.ConstantIgnore = ['PerFrameVS', 'PerObjectVS', 'PerFramePS', 'PerObjectPS']; /***/ }), -/* 122 */ +/* 120 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -24936,7 +24863,7 @@ var Tw2GeometryRes = exports.Tw2GeometryRes = function (_Tw2Resource) { }, { key: 'Prepare', value: function Prepare(data) { - var d = _global.device, + var gl = _global.device.gl, reader = new _reader.Tw2BinaryReader(new Uint8Array(data)); /* let fileVersion = */ @@ -24949,19 +24876,19 @@ var Tw2GeometryRes = exports.Tw2GeometryRes = function (_Tw2Resource) { if (buffer) { mesh.bufferLength = buffer.length; - mesh.buffer = d.gl.createBuffer(); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, mesh.buffer); - d.gl.bufferData(d.gl.ARRAY_BUFFER, buffer, d.gl.STATIC_DRAW); + mesh.buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, mesh.buffer); + gl.bufferData(gl.ARRAY_BUFFER, buffer, gl.STATIC_DRAW); } else { mesh.buffer = null; } var indexes = Tw2GeometryRes.ReadIndexBuffer(reader); if (indexes) { - mesh.indexes = d.gl.createBuffer(); - mesh.indexType = indexes.BYTES_PER_ELEMENT === 2 ? d.gl.UNSIGNED_SHORT : d.gl.UNSIGNED_INT; - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); - d.gl.bufferData(d.gl.ELEMENT_ARRAY_BUFFER, indexes, d.gl.STATIC_DRAW); + mesh.indexes = gl.createBuffer(); + mesh.indexType = indexes.BYTES_PER_ELEMENT === 2 ? gl.UNSIGNED_SHORT : gl.UNSIGNED_INT; + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indexes, gl.STATIC_DRAW); } else { mesh.indexes = null; } @@ -25015,19 +24942,19 @@ var Tw2GeometryRes = exports.Tw2GeometryRes = function (_Tw2Resource) { bone.parentIndex = reader.ReadUInt8(); if (bone.parentIndex === 255) bone.parentIndex = -1; - if ((flags & 1) != 0) { + if ((flags & 1) !== 0) { _global.vec3.set(bone.position, reader.ReadFloat32(), reader.ReadFloat32(), reader.ReadFloat32()); } else { _global.vec3.set(bone.position, 0, 0, 0); } - if ((flags & 2) != 0) { + if ((flags & 2) !== 0) { _global.quat.set(bone.orientation, reader.ReadFloat32(), reader.ReadFloat32(), reader.ReadFloat32(), reader.ReadFloat32()); } else { _global.quat.identity(bone.orientation); } - if ((flags & 4) != 0) { + if ((flags & 4) !== 0) { for (var k = 0; k < 9; ++k) { bone.scaleShear[k] = reader.ReadFloat32(); } @@ -25142,19 +25069,22 @@ var Tw2GeometryRes = exports.Tw2GeometryRes = function (_Tw2Resource) { if (!this.IsGood() || !effect.IsGood() || meshIx >= this.meshes.length) return false; var d = _global.device, + ext = d.ext, + gl = d.gl, mesh = this.meshes[meshIx], passCount = effect.GetPassCount(technique); - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); + + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); for (var pass = 0; pass < passCount; ++pass) { effect.ApplyPass(technique, pass); var passInput = effect.GetPassInput(technique, pass); if (passInput.elements.length === 0) continue; - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, mesh.buffer); + gl.bindBuffer(gl.ARRAY_BUFFER, mesh.buffer); mesh.declaration.SetPartialDeclaration(passInput, mesh.declaration.stride); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, instanceVB); + gl.bindBuffer(gl.ARRAY_BUFFER, instanceVB); var resetData = instanceDecl.SetPartialDeclaration(passInput, instanceStride, 8, 1); d.ApplyShadowState(); @@ -25170,7 +25100,7 @@ var Tw2GeometryRes = exports.Tw2GeometryRes = function (_Tw2Resource) { acount += area.count; ++i; } - d.ext.drawElementsInstanced(d.gl.TRIANGLES, acount, mesh.indexType, areaStart, instanceCount); + ext.drawElementsInstanced(gl.TRIANGLES, acount, mesh.indexType, areaStart, instanceCount); } } instanceDecl.ResetInstanceDivisors(resetData); @@ -25195,11 +25125,12 @@ var Tw2GeometryRes = exports.Tw2GeometryRes = function (_Tw2Resource) { if (!this.IsGood() || !effect.IsGood() || meshIx >= this.meshes.length) return false; var d = _global.device, + gl = d.gl, mesh = this.meshes[meshIx] || this.meshes[0], passCount = effect.GetPassCount(technique); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, mesh.buffer); - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); + gl.bindBuffer(gl.ARRAY_BUFFER, mesh.buffer); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); for (var pass = 0; pass < passCount; ++pass) { effect.ApplyPass(technique, pass); @@ -25234,7 +25165,7 @@ var Tw2GeometryRes = exports.Tw2GeometryRes = function (_Tw2Resource) { acount += area.count; ++i; } - d.gl.drawElements(d.gl.TRIANGLES, acount, mesh.indexType, areaStart); + gl.drawElements(gl.TRIANGLES, acount, mesh.indexType, areaStart); } } } @@ -25258,11 +25189,12 @@ var Tw2GeometryRes = exports.Tw2GeometryRes = function (_Tw2Resource) { if (!this.IsGood() || !effect.IsGood() || meshIx >= this.meshes.length) return false; var d = _global.device, + gl = d.gl, mesh = this.meshes[meshIx], passCount = effect.GetPassCount(technique); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, mesh.buffer); - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); + gl.bindBuffer(gl.ARRAY_BUFFER, mesh.buffer); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); for (var pass = 0; pass < passCount; ++pass) { effect.ApplyPass(technique, pass); @@ -25297,7 +25229,7 @@ var Tw2GeometryRes = exports.Tw2GeometryRes = function (_Tw2Resource) { acount += area.count; ++i; } - d.gl.drawElements(d.gl.LINES, acount, mesh.indexType, areaStart); + gl.drawElements(gl.LINES, acount, mesh.indexType, areaStart); } } } @@ -25337,13 +25269,15 @@ var Tw2GeometryRes = exports.Tw2GeometryRes = function (_Tw2Resource) { key: 'Unload', value: function Unload() { for (var i = 0; i < this.meshes.length; ++i) { + var gl = _global.device.gl; + if (this.meshes[i].buffer) { - _global.device.gl.deleteBuffer(this.meshes[i].buffer); + gl.deleteBuffer(this.meshes[i].buffer); this.meshes[i].buffer = null; } if (this.meshes[i].indexes) { - _global.device.gl.deleteBuffer(this.meshes[i].indexes); + gl.deleteBuffer(this.meshes[i].indexes); this.meshes[i].indexes = null; } } @@ -25418,7 +25352,7 @@ var Tw2GeometryRes = exports.Tw2GeometryRes = function (_Tw2Resource) { var el = declaration.elements[_declIx]; switch (el.fileType & 0xf) { case 0: - if ((el.fileType & 0x10) != 0) { + if ((el.fileType & 0x10) !== 0) { for (var i = 0; i < el.elements; ++i) { buffer[index++] = reader.ReadInt8() / 127.0; } @@ -25430,7 +25364,7 @@ var Tw2GeometryRes = exports.Tw2GeometryRes = function (_Tw2Resource) { break; case 1: - if ((el.fileType & 0x10) != 0) { + if ((el.fileType & 0x10) !== 0) { for (var _i8 = 0; _i8 < el.elements; ++_i8) { buffer[index++] = reader.ReadInt8() / 32767.0; } @@ -25460,7 +25394,7 @@ var Tw2GeometryRes = exports.Tw2GeometryRes = function (_Tw2Resource) { break; case 8: - if ((el.fileType & 0x10) != 0) { + if ((el.fileType & 0x10) !== 0) { for (var _i13 = 0; _i13 < el.elements; ++_i13) { buffer[index++] = reader.ReadUInt8() / 255.0; } @@ -25472,7 +25406,7 @@ var Tw2GeometryRes = exports.Tw2GeometryRes = function (_Tw2Resource) { break; case 9: - if ((el.fileType & 0x10) != 0) { + if ((el.fileType & 0x10) !== 0) { for (var _i15 = 0; _i15 < declaration.elements[_declIx].elements; ++_i15) { buffer[index++] = reader.ReadUInt8() / 65535.0; } @@ -25573,7 +25507,7 @@ var Tw2GeometryRes = exports.Tw2GeometryRes = function (_Tw2Resource) { Tw2GeometryRes.prototype.requestResponseType = 'arraybuffer'; /***/ }), -/* 123 */ +/* 121 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -25586,6 +25520,8 @@ exports.Tw2VideoRes = undefined; var _createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + var _global = __webpack_require__(0); var _Tw2Resource2 = __webpack_require__(8); @@ -25650,7 +25586,7 @@ var Tw2VideoRes = exports.Tw2VideoRes = function (_Tw2Resource) { key: 'IsGood', value: function IsGood() { this.KeepAlive(); - return this._isGood && this.video && this._playable; + return _get(Tw2VideoRes.prototype.__proto__ || Object.getPrototypeOf(Tw2VideoRes.prototype), 'IsGood', this).call(this) && this.video && this._playable; } /** @@ -25832,23 +25768,24 @@ var Tw2VideoRes = exports.Tw2VideoRes = function (_Tw2Resource) { }, { key: 'Bind', value: function Bind(sampler) { - var d = _global.device; + var d = _global.device, + gl = d.gl; this.KeepAlive(); var targetType = sampler.samplerType; - if (targetType !== d.gl.TEXTURE_2D) return; + if (targetType !== gl.TEXTURE_2D) return; if (!this.texture) { - d.gl.bindTexture(d.gl.TEXTURE_2D, d.GetFallbackTexture()); + gl.bindTexture(gl.TEXTURE_2D, d.GetFallbackTexture()); return; } this._currentTime = this.video.currentTime; - d.gl.bindTexture(d.gl.TEXTURE_2D, this.texture); - d.gl.texImage2D(d.gl.TEXTURE_2D, 0, d.gl.RGBA, d.gl.RGBA, d.gl.UNSIGNED_BYTE, this.video); - d.gl.bindTexture(d.gl.TEXTURE_2D, null); + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.video); + gl.bindTexture(gl.TEXTURE_2D, null); - d.gl.bindTexture(targetType, this.texture); + gl.bindTexture(targetType, this.texture); if (sampler.hash !== this._currentSampler) { sampler.Apply(false); this._currentSampler = sampler.hash; @@ -25860,7 +25797,7 @@ var Tw2VideoRes = exports.Tw2VideoRes = function (_Tw2Resource) { }(_Tw2Resource2.Tw2Resource); /***/ }), -/* 124 */ +/* 122 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -25870,7 +25807,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2PostProcess = __webpack_require__(125); +var _Tw2PostProcess = __webpack_require__(123); Object.keys(_Tw2PostProcess).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -25883,7 +25820,7 @@ Object.keys(_Tw2PostProcess).forEach(function (key) { }); /***/ }), -/* 125 */ +/* 123 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -26001,20 +25938,21 @@ var Tw2PostProcess = exports.Tw2PostProcess = function () { _createClass(Tw2PostProcess, [{ key: 'Render', value: function Render() { - var width = _global.device.viewportWidth, + var gl = _global.device.gl, + width = _global.device.viewportWidth, height = _global.device.viewportHeight; if (width <= 0 || height <= 0) return; if (this.texture === null) { this.texture = new _resource.Tw2TextureRes(); - this.texture.Attach(_global.device.gl.createTexture()); + this.texture.Attach(gl.createTexture()); } if (width !== this.width || height !== this.height) { - _global.device.gl.bindTexture(_global.device.gl.TEXTURE_2D, this.texture.texture); - _global.device.gl.texImage2D(_global.device.gl.TEXTURE_2D, 0, _global.device.gl.RGBA, width, height, 0, _global.device.gl.RGBA, _global.device.gl.UNSIGNED_BYTE, null); - _global.device.gl.bindTexture(_global.device.gl.TEXTURE_2D, null); + gl.bindTexture(gl.TEXTURE_2D, this.texture.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + gl.bindTexture(gl.TEXTURE_2D, null); this.quadRT0.Create(width / 4, height / 4, false); this.quadRT1.Create(width / 4, height / 4, false); @@ -26050,9 +25988,9 @@ var Tw2PostProcess = exports.Tw2PostProcess = function () { } } - _global.device.gl.bindTexture(_global.device.gl.TEXTURE_2D, this.texture.texture); - _global.device.gl.copyTexImage2D(_global.device.gl.TEXTURE_2D, 0, _global.device.alphaBlendBackBuffer ? _global.device.gl.RGBA : _global.device.gl.RGB, 0, 0, width, height, 0); - _global.device.gl.bindTexture(_global.device.gl.TEXTURE_2D, null); + gl.bindTexture(gl.TEXTURE_2D, this.texture.texture); + gl.copyTexImage2D(gl.TEXTURE_2D, 0, _global.device.alphaBlendBackBuffer ? gl.RGBA : gl.RGB, 0, 0, width, height, 0); + gl.bindTexture(gl.TEXTURE_2D, null); _global.device.SetStandardStates(_global.device.RM_OPAQUE); for (var _i = 0; _i < this.steps.length; ++_i) { @@ -26060,8 +25998,8 @@ var Tw2PostProcess = exports.Tw2PostProcess = function () { if (_step.rt !== null) { _step.rt.Set(); } else { - _global.device.gl.bindFramebuffer(_global.device.gl.FRAMEBUFFER, null); - _global.device.gl.viewport(0, 0, width, height); + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + gl.viewport(0, 0, width, height); } _global.device.RenderFullScreenQuad(_step.effect); } @@ -26072,7 +26010,524 @@ var Tw2PostProcess = exports.Tw2PostProcess = function () { }(); /***/ }), -/* 126 */ +/* 124 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Tw2FeatureNotImplementedError = exports.Tw2AbstractClassMethodError = exports.Tw2SingleInstantiationError = exports.Tw2DeclarationValueTypeError = exports.Tw2ShaderLinkError = exports.Tw2ShaderCompileError = exports.Tw2ShaderPermutationValueError = exports.Tw2ShaderHeaderSizeError = exports.Tw2ShaderVersionError = exports.Tw2ResourceExtensionUndefinedError = exports.Tw2ResourceExtensionUnregisteredError = exports.Tw2ResourcePrefixUndefinedError = exports.Tw2ResourcePrefixUnregisteredError = exports.Tw2GeometryFileTypeError = exports.Tw2GeometryMeshEffectBindError = exports.Tw2GeometryMeshInvalidBoneError = exports.Tw2GeometryMeshElementComponentError = exports.Tw2GeometryMeshParticleElementError = exports.Tw2XMLObjectTypeUndefinedError = exports.Tw2XMLBinaryError = exports.HTTPReadyStateError = exports.HTTPStatusError = exports.HTTPInstanceError = exports.HTTPRequestSendError = exports.HTTPRequestError = exports.Tw2Error = undefined; + +var _util = __webpack_require__(16); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +function _extendableBuiltin(cls) { + function ExtendableBuiltin() { + var instance = Reflect.construct(cls, Array.from(arguments)); + Object.setPrototypeOf(instance, Object.getPrototypeOf(this)); + return instance; + } + + ExtendableBuiltin.prototype = Object.create(cls.prototype, { + constructor: { + value: cls, + enumerable: false, + writable: true, + configurable: true + } + }); + + if (Object.setPrototypeOf) { + Object.setPrototypeOf(ExtendableBuiltin, cls); + } else { + ExtendableBuiltin.__proto__ = cls; + } + + return ExtendableBuiltin; +} + +var HAS_CAPTURE_STACK_TRACE = (0, _util.isFunction)(Error['captureStackTrace']); + +/** + * Extends standard errors + * @param {string|{}} data - Error message or an object containing relevant data + * @param {string} [defaultMessage] - The default error message + */ + +var Tw2Error = exports.Tw2Error = function (_extendableBuiltin2) { + _inherits(Tw2Error, _extendableBuiltin2); + + function Tw2Error() { + var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var defaultMessage = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Undefined error'; + + _classCallCheck(this, Tw2Error); + + var _this = _possibleConstructorReturn(this, (Tw2Error.__proto__ || Object.getPrototypeOf(Tw2Error)).call(this)); + + if (typeof data === 'string') { + data = { message: data }; + } else { + data.message = data.message || defaultMessage; + } + + _this.message = data.message; + _this.name = _this.constructor.name; + _this.data = data; + + if (HAS_CAPTURE_STACK_TRACE) { + Error['captureStackTrace'](_this, Tw2Error); + } else { + _this.stack = new Error(data.message).stack; + } + return _this; + } + + return Tw2Error; +}(_extendableBuiltin(Error)); + +/** + * Fallback if instanceof Error isn't supported by client + * @type {boolean} + */ + + +Tw2Error.isError = true; + +/** + * Throws on http request errors + */ + +var HTTPRequestError = exports.HTTPRequestError = function (_Tw2Error) { + _inherits(HTTPRequestError, _Tw2Error); + + function HTTPRequestError(data) { + _classCallCheck(this, HTTPRequestError); + + return _possibleConstructorReturn(this, (HTTPRequestError.__proto__ || Object.getPrototypeOf(HTTPRequestError)).call(this, data, 'Communication error while requesting resource')); + } + + return HTTPRequestError; +}(Tw2Error); + +/** + * Throws on http request send errors + */ + + +var HTTPRequestSendError = exports.HTTPRequestSendError = function (_Tw2Error2) { + _inherits(HTTPRequestSendError, _Tw2Error2); + + function HTTPRequestSendError(data) { + _classCallCheck(this, HTTPRequestSendError); + + return _possibleConstructorReturn(this, (HTTPRequestSendError.__proto__ || Object.getPrototypeOf(HTTPRequestSendError)).call(this, data, 'Communication send error while requesting resource')); + } + + return HTTPRequestSendError; +}(Tw2Error); + +/** + * Throws when an xml http instance cannot be created + */ + + +var HTTPInstanceError = exports.HTTPInstanceError = function (_Tw2Error3) { + _inherits(HTTPInstanceError, _Tw2Error3); + + function HTTPInstanceError(data) { + _classCallCheck(this, HTTPInstanceError); + + return _possibleConstructorReturn(this, (HTTPInstanceError.__proto__ || Object.getPrototypeOf(HTTPInstanceError)).call(this, data, 'Could not create an XML HTTP instance')); + } + + return HTTPInstanceError; +}(Tw2Error); + +/** + * Throws on http status errors + */ + + +var HTTPStatusError = exports.HTTPStatusError = function (_Tw2Error4) { + _inherits(HTTPStatusError, _Tw2Error4); + + function HTTPStatusError(data) { + _classCallCheck(this, HTTPStatusError); + + return _possibleConstructorReturn(this, (HTTPStatusError.__proto__ || Object.getPrototypeOf(HTTPStatusError)).call(this, data, 'Communication status error while loading resource')); + } + + return HTTPStatusError; +}(Tw2Error); + +/** + * Throws on http ready state errors + */ + + +var HTTPReadyStateError = exports.HTTPReadyStateError = function (_Tw2Error5) { + _inherits(HTTPReadyStateError, _Tw2Error5); + + function HTTPReadyStateError(data) { + _classCallCheck(this, HTTPReadyStateError); + + return _possibleConstructorReturn(this, (HTTPReadyStateError.__proto__ || Object.getPrototypeOf(HTTPReadyStateError)).call(this, data, 'Communication ready state error while loading resource')); + } + + return HTTPReadyStateError; +}(Tw2Error); + +/** + * Throws when xml is not a valid format + */ + + +var Tw2XMLBinaryError = exports.Tw2XMLBinaryError = function (_Tw2Error6) { + _inherits(Tw2XMLBinaryError, _Tw2Error6); + + function Tw2XMLBinaryError(data) { + _classCallCheck(this, Tw2XMLBinaryError); + + return _possibleConstructorReturn(this, (Tw2XMLBinaryError.__proto__ || Object.getPrototypeOf(Tw2XMLBinaryError)).call(this, data, 'Invalid binary')); + } + + return Tw2XMLBinaryError; +}(Tw2Error); + +/** + * Throws when an xml object type is undefined + */ + + +var Tw2XMLObjectTypeUndefinedError = exports.Tw2XMLObjectTypeUndefinedError = function (_Tw2Error7) { + _inherits(Tw2XMLObjectTypeUndefinedError, _Tw2Error7); + + function Tw2XMLObjectTypeUndefinedError(data) { + _classCallCheck(this, Tw2XMLObjectTypeUndefinedError); + + return _possibleConstructorReturn(this, (Tw2XMLObjectTypeUndefinedError.__proto__ || Object.getPrototypeOf(Tw2XMLObjectTypeUndefinedError)).call(this, data, 'XML Object with undefined type')); + } + + return Tw2XMLObjectTypeUndefinedError; +}(Tw2Error); + +/** + * Throws when a geometry mesh lacks an element required for a particle system + */ + + +var Tw2GeometryMeshParticleElementError = exports.Tw2GeometryMeshParticleElementError = function (_Tw2Error8) { + _inherits(Tw2GeometryMeshParticleElementError, _Tw2Error8); + + function Tw2GeometryMeshParticleElementError(data) { + _classCallCheck(this, Tw2GeometryMeshParticleElementError); + + return _possibleConstructorReturn(this, (Tw2GeometryMeshParticleElementError.__proto__ || Object.getPrototypeOf(Tw2GeometryMeshParticleElementError)).call(this, data, 'Input geometry mesh lacks element required by particle system')); + } + + return Tw2GeometryMeshParticleElementError; +}(Tw2Error); + +/** + * Throws when a geometry mesh element doesn't have the required number of components + */ + + +var Tw2GeometryMeshElementComponentError = exports.Tw2GeometryMeshElementComponentError = function (_Tw2Error9) { + _inherits(Tw2GeometryMeshElementComponentError, _Tw2Error9); + + function Tw2GeometryMeshElementComponentError(data) { + _classCallCheck(this, Tw2GeometryMeshElementComponentError); + + return _possibleConstructorReturn(this, (Tw2GeometryMeshElementComponentError.__proto__ || Object.getPrototypeOf(Tw2GeometryMeshElementComponentError)).call(this, data, 'Input geometry mesh elements do not have the required number of components')); + } + + return Tw2GeometryMeshElementComponentError; +}(Tw2Error); + +/** + * Throws when a geometry mesh has an invalid bone name for a model + */ + + +var Tw2GeometryMeshInvalidBoneError = exports.Tw2GeometryMeshInvalidBoneError = function (_Tw2Error10) { + _inherits(Tw2GeometryMeshInvalidBoneError, _Tw2Error10); + + function Tw2GeometryMeshInvalidBoneError(data) { + _classCallCheck(this, Tw2GeometryMeshInvalidBoneError); + + return _possibleConstructorReturn(this, (Tw2GeometryMeshInvalidBoneError.__proto__ || Object.getPrototypeOf(Tw2GeometryMeshInvalidBoneError)).call(this, data, 'Geometry mesh has invalid bone name for model')); + } + + return Tw2GeometryMeshInvalidBoneError; +}(Tw2Error); + +/** + * Throws when there is an error binding a geometry mesh to an effect + */ + + +var Tw2GeometryMeshEffectBindError = exports.Tw2GeometryMeshEffectBindError = function (_Tw2Error11) { + _inherits(Tw2GeometryMeshEffectBindError, _Tw2Error11); + + function Tw2GeometryMeshEffectBindError(data) { + _classCallCheck(this, Tw2GeometryMeshEffectBindError); + + return _possibleConstructorReturn(this, (Tw2GeometryMeshEffectBindError.__proto__ || Object.getPrototypeOf(Tw2GeometryMeshEffectBindError)).call(this, data, 'Error binding geometry mesh to effect')); + } + + return Tw2GeometryMeshEffectBindError; +}(Tw2Error); + +/** + * Throws when a geometry mesh has an invalid file type + */ + + +var Tw2GeometryFileTypeError = exports.Tw2GeometryFileTypeError = function (_Tw2Error12) { + _inherits(Tw2GeometryFileTypeError, _Tw2Error12); + + function Tw2GeometryFileTypeError(data) { + _classCallCheck(this, Tw2GeometryFileTypeError); + + return _possibleConstructorReturn(this, (Tw2GeometryFileTypeError.__proto__ || Object.getPrototypeOf(Tw2GeometryFileTypeError)).call(this, data, 'Invalid geometry file type')); + } + + return Tw2GeometryFileTypeError; +}(Tw2Error); + +/** + * Throws when a resource path has an unregistered prefix + */ + + +var Tw2ResourcePrefixUnregisteredError = exports.Tw2ResourcePrefixUnregisteredError = function (_Tw2Error13) { + _inherits(Tw2ResourcePrefixUnregisteredError, _Tw2Error13); + + function Tw2ResourcePrefixUnregisteredError(data) { + _classCallCheck(this, Tw2ResourcePrefixUnregisteredError); + + return _possibleConstructorReturn(this, (Tw2ResourcePrefixUnregisteredError.__proto__ || Object.getPrototypeOf(Tw2ResourcePrefixUnregisteredError)).call(this, data, 'Unregistered resource prefix')); + } + + return Tw2ResourcePrefixUnregisteredError; +}(Tw2Error); + +/** + * Throws when a resource path has no prefix + */ + + +var Tw2ResourcePrefixUndefinedError = exports.Tw2ResourcePrefixUndefinedError = function (_Tw2Error14) { + _inherits(Tw2ResourcePrefixUndefinedError, _Tw2Error14); + + function Tw2ResourcePrefixUndefinedError(data) { + _classCallCheck(this, Tw2ResourcePrefixUndefinedError); + + return _possibleConstructorReturn(this, (Tw2ResourcePrefixUndefinedError.__proto__ || Object.getPrototypeOf(Tw2ResourcePrefixUndefinedError)).call(this, data, 'Undefined resource prefix')); + } + + return Tw2ResourcePrefixUndefinedError; +}(Tw2Error); + +/** + * Throws when a resource path has an unregistered file extension + */ + + +var Tw2ResourceExtensionUnregisteredError = exports.Tw2ResourceExtensionUnregisteredError = function (_Tw2Error15) { + _inherits(Tw2ResourceExtensionUnregisteredError, _Tw2Error15); + + function Tw2ResourceExtensionUnregisteredError(data) { + _classCallCheck(this, Tw2ResourceExtensionUnregisteredError); + + return _possibleConstructorReturn(this, (Tw2ResourceExtensionUnregisteredError.__proto__ || Object.getPrototypeOf(Tw2ResourceExtensionUnregisteredError)).call(this, data, 'Unregistered resource extension')); + } + + return Tw2ResourceExtensionUnregisteredError; +}(Tw2Error); + +/** + * Throws when a resource path has no file extension + */ + + +var Tw2ResourceExtensionUndefinedError = exports.Tw2ResourceExtensionUndefinedError = function (_Tw2Error16) { + _inherits(Tw2ResourceExtensionUndefinedError, _Tw2Error16); + + function Tw2ResourceExtensionUndefinedError(data) { + _classCallCheck(this, Tw2ResourceExtensionUndefinedError); + + return _possibleConstructorReturn(this, (Tw2ResourceExtensionUndefinedError.__proto__ || Object.getPrototypeOf(Tw2ResourceExtensionUndefinedError)).call(this, data, 'Undefined resource extension')); + } + + return Tw2ResourceExtensionUndefinedError; +}(Tw2Error); + +/** + * Throws when an effect has an invalid shader version + */ + + +var Tw2ShaderVersionError = exports.Tw2ShaderVersionError = function (_Tw2Error17) { + _inherits(Tw2ShaderVersionError, _Tw2Error17); + + function Tw2ShaderVersionError(data) { + _classCallCheck(this, Tw2ShaderVersionError); + + return _possibleConstructorReturn(this, (Tw2ShaderVersionError.__proto__ || Object.getPrototypeOf(Tw2ShaderVersionError)).call(this, data, 'Invalid version of effect file')); + } + + return Tw2ShaderVersionError; +}(Tw2Error); + +/** + * Throws when an effect has no header + */ + + +var Tw2ShaderHeaderSizeError = exports.Tw2ShaderHeaderSizeError = function (_Tw2Error18) { + _inherits(Tw2ShaderHeaderSizeError, _Tw2Error18); + + function Tw2ShaderHeaderSizeError(data) { + _classCallCheck(this, Tw2ShaderHeaderSizeError); + + return _possibleConstructorReturn(this, (Tw2ShaderHeaderSizeError.__proto__ || Object.getPrototypeOf(Tw2ShaderHeaderSizeError)).call(this, data, 'Effect file contains no compiled effects')); + } + + return Tw2ShaderHeaderSizeError; +}(Tw2Error); + +/** + * Throws when a shader has an invalid permutation value + */ + + +var Tw2ShaderPermutationValueError = exports.Tw2ShaderPermutationValueError = function (_Tw2Error19) { + _inherits(Tw2ShaderPermutationValueError, _Tw2Error19); + + function Tw2ShaderPermutationValueError(data) { + _classCallCheck(this, Tw2ShaderPermutationValueError); + + return _possibleConstructorReturn(this, (Tw2ShaderPermutationValueError.__proto__ || Object.getPrototypeOf(Tw2ShaderPermutationValueError)).call(this, data, 'Invalid shader permutation value')); + } + + return Tw2ShaderPermutationValueError; +}(Tw2Error); + +/** + * Throws when a shader cannot compile + */ + + +var Tw2ShaderCompileError = exports.Tw2ShaderCompileError = function (_Tw2Error20) { + _inherits(Tw2ShaderCompileError, _Tw2Error20); + + function Tw2ShaderCompileError(data) { + _classCallCheck(this, Tw2ShaderCompileError); + + return _possibleConstructorReturn(this, (Tw2ShaderCompileError.__proto__ || Object.getPrototypeOf(Tw2ShaderCompileError)).call(this, data, 'Error compiling shader')); + } + + return Tw2ShaderCompileError; +}(Tw2Error); + +/** + * Throws when unable to link a vertex shader and fragment shader + */ + + +var Tw2ShaderLinkError = exports.Tw2ShaderLinkError = function (_Tw2Error21) { + _inherits(Tw2ShaderLinkError, _Tw2Error21); + + function Tw2ShaderLinkError(data) { + _classCallCheck(this, Tw2ShaderLinkError); + + return _possibleConstructorReturn(this, (Tw2ShaderLinkError.__proto__ || Object.getPrototypeOf(Tw2ShaderLinkError)).call(this, data, 'Error linking shaders')); + } + + return Tw2ShaderLinkError; +}(Tw2Error); + +/** + * Throws on invalid raw data declaration types + */ + + +var Tw2DeclarationValueTypeError = exports.Tw2DeclarationValueTypeError = function (_Tw2Error22) { + _inherits(Tw2DeclarationValueTypeError, _Tw2Error22); + + function Tw2DeclarationValueTypeError(data) { + _classCallCheck(this, Tw2DeclarationValueTypeError); + + return _possibleConstructorReturn(this, (Tw2DeclarationValueTypeError.__proto__ || Object.getPrototypeOf(Tw2DeclarationValueTypeError)).call(this, data, 'Invalid declaration value type')); + } + + return Tw2DeclarationValueTypeError; +}(Tw2Error); + +/** + * Throws when a class can only be instantiated once + */ + + +var Tw2SingleInstantiationError = exports.Tw2SingleInstantiationError = function (_Tw2Error23) { + _inherits(Tw2SingleInstantiationError, _Tw2Error23); + + function Tw2SingleInstantiationError(data) { + _classCallCheck(this, Tw2SingleInstantiationError); + + return _possibleConstructorReturn(this, (Tw2SingleInstantiationError.__proto__ || Object.getPrototypeOf(Tw2SingleInstantiationError)).call(this, data, 'Class can only be instantiated once')); + } + + return Tw2SingleInstantiationError; +}(Tw2Error); + +/** + * Throws when an abstract classes' method is not implemented directly on a child class + */ + + +var Tw2AbstractClassMethodError = exports.Tw2AbstractClassMethodError = function (_Tw2Error24) { + _inherits(Tw2AbstractClassMethodError, _Tw2Error24); + + function Tw2AbstractClassMethodError(data) { + _classCallCheck(this, Tw2AbstractClassMethodError); + + return _possibleConstructorReturn(this, (Tw2AbstractClassMethodError.__proto__ || Object.getPrototypeOf(Tw2AbstractClassMethodError)).call(this, data, 'Abstract class method not implemented directly on child class')); + } + + return Tw2AbstractClassMethodError; +}(Tw2Error); + +/** + * Throws when a feature is not implemented + */ + + +var Tw2FeatureNotImplementedError = exports.Tw2FeatureNotImplementedError = function (_Tw2Error25) { + _inherits(Tw2FeatureNotImplementedError, _Tw2Error25); + + function Tw2FeatureNotImplementedError(data) { + _classCallCheck(this, Tw2FeatureNotImplementedError); + + return _possibleConstructorReturn(this, (Tw2FeatureNotImplementedError.__proto__ || Object.getPrototypeOf(Tw2FeatureNotImplementedError)).call(this, data, 'Feature not implemented')); + } + + return Tw2FeatureNotImplementedError; +}(Tw2Error); + +/***/ }), +/* 125 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -26097,7 +26552,7 @@ var Tw2Float = exports.Tw2Float = function Tw2Float() { }; /***/ }), -/* 127 */ +/* 126 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -26251,7 +26706,7 @@ Tw2Frustum.global = { }; /***/ }), -/* 128 */ +/* 127 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -26491,7 +26946,7 @@ Tw2ColorCurve.Interpolation = { }; /***/ }), -/* 129 */ +/* 128 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -26761,7 +27216,7 @@ Tw2ColorCurve2.Interpolation = { }; /***/ }), -/* 130 */ +/* 129 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -26934,7 +27389,7 @@ Tw2EventCurve.Extrapolation = { }; /***/ }), -/* 131 */ +/* 130 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -27040,7 +27495,7 @@ Tw2PerlinCurve.valueProperty = 'value'; Tw2PerlinCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE_NO_KEYS; /***/ }), -/* 132 */ +/* 131 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -27320,7 +27775,7 @@ Tw2QuaternionCurve.Interpolation = { }; /***/ }), -/* 133 */ +/* 132 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -27412,7 +27867,7 @@ Tw2RandomConstantCurve.valueProperty = 'value'; Tw2RandomConstantCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE_NO_KEYS; /***/ }), -/* 134 */ +/* 133 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -27597,7 +28052,7 @@ Tw2RigidOrientation.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE; Tw2RigidOrientation.Key = Tw2Torque; /***/ }), -/* 135 */ +/* 134 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -27858,7 +28313,7 @@ Tw2RotationCurve.Interpolation = { }; /***/ }), -/* 136 */ +/* 135 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -28111,7 +28566,7 @@ Tw2ScalarCurve.Interpolation = { }; /***/ }), -/* 137 */ +/* 136 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -28403,7 +28858,7 @@ Tw2ScalarCurve2.Interpolation = { }; /***/ }), -/* 138 */ +/* 137 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -28497,7 +28952,7 @@ Tw2SineCurve.valueProperty = 'value'; Tw2SineCurve.curveType = _Tw2Curve2.Tw2Curve.Type.CURVE_NO_KEYS; /***/ }), -/* 139 */ +/* 138 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -28800,7 +29255,7 @@ Tw2Vector2Curve.Interpolation = { }; /***/ }), -/* 140 */ +/* 139 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -29106,7 +29561,7 @@ Tw2Vector3Curve.Interpolation = { }; /***/ }), -/* 141 */ +/* 140 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -29361,7 +29816,7 @@ Tw2VectorCurve.Interpolation = { }; /***/ }), -/* 142 */ +/* 141 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -29371,7 +29826,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2ColorSequencer = __webpack_require__(143); +var _Tw2ColorSequencer = __webpack_require__(142); Object.keys(_Tw2ColorSequencer).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -29383,7 +29838,7 @@ Object.keys(_Tw2ColorSequencer).forEach(function (key) { }); }); -var _Tw2EulerRotation = __webpack_require__(144); +var _Tw2EulerRotation = __webpack_require__(143); Object.keys(_Tw2EulerRotation).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -29395,7 +29850,7 @@ Object.keys(_Tw2EulerRotation).forEach(function (key) { }); }); -var _Tw2QuaternionSequencer = __webpack_require__(145); +var _Tw2QuaternionSequencer = __webpack_require__(144); Object.keys(_Tw2QuaternionSequencer).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -29407,7 +29862,7 @@ Object.keys(_Tw2QuaternionSequencer).forEach(function (key) { }); }); -var _Tw2RGBAScalarSequencer = __webpack_require__(146); +var _Tw2RGBAScalarSequencer = __webpack_require__(145); Object.keys(_Tw2RGBAScalarSequencer).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -29419,7 +29874,7 @@ Object.keys(_Tw2RGBAScalarSequencer).forEach(function (key) { }); }); -var _Tw2ScalarSequencer = __webpack_require__(147); +var _Tw2ScalarSequencer = __webpack_require__(146); Object.keys(_Tw2ScalarSequencer).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -29431,7 +29886,7 @@ Object.keys(_Tw2ScalarSequencer).forEach(function (key) { }); }); -var _Tw2VectorSequencer = __webpack_require__(148); +var _Tw2VectorSequencer = __webpack_require__(147); Object.keys(_Tw2VectorSequencer).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -29443,7 +29898,7 @@ Object.keys(_Tw2VectorSequencer).forEach(function (key) { }); }); -var _Tw2XYZScalarSequencer = __webpack_require__(149); +var _Tw2XYZScalarSequencer = __webpack_require__(148); Object.keys(_Tw2XYZScalarSequencer).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -29455,7 +29910,7 @@ Object.keys(_Tw2XYZScalarSequencer).forEach(function (key) { }); }); -var _Tw2YPRSequencer = __webpack_require__(150); +var _Tw2YPRSequencer = __webpack_require__(149); Object.keys(_Tw2YPRSequencer).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -29468,7 +29923,7 @@ Object.keys(_Tw2YPRSequencer).forEach(function (key) { }); /***/ }), -/* 143 */ +/* 142 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -29631,7 +30086,7 @@ Tw2ColorSequencer.Operator = { }; /***/ }), -/* 144 */ +/* 143 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -29782,7 +30237,7 @@ Tw2EulerRotation.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCE Tw2EulerRotation.childProperties = ['yawCurve', 'pitchCurve', 'rollCurve']; /***/ }), -/* 145 */ +/* 144 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -29923,7 +30378,7 @@ Tw2QuaternionSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SE Tw2QuaternionSequencer.childArray = 'functions'; /***/ }), -/* 146 */ +/* 145 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -30064,7 +30519,7 @@ Tw2RGBAScalarSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SE Tw2RGBAScalarSequencer.childProperties = ['RedCurve', 'GreenCurve', 'BlueCurve', 'AlphaCurve']; /***/ }), -/* 147 */ +/* 146 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -30246,7 +30701,7 @@ Tw2ScalarSequencer.Operator = { }; /***/ }), -/* 148 */ +/* 147 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -30410,7 +30865,7 @@ Tw2VectorSequencer.Operator = { }; /***/ }), -/* 149 */ +/* 148 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -30548,14 +31003,14 @@ Tw2XYZScalarSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQ Tw2XYZScalarSequencer.childProperties = ['XCurve', 'YCurve', 'ZCurve']; /***/ }), -/* 150 */ +/* 149 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { - value: true + value: true }); exports.Tw2YPRSequencer = undefined; @@ -30582,91 +31037,91 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" * @class */ var Tw2YPRSequencer = exports.Tw2YPRSequencer = function (_Tw2CurveSequencer) { - _inherits(Tw2YPRSequencer, _Tw2CurveSequencer); - - function Tw2YPRSequencer() { - _classCallCheck(this, Tw2YPRSequencer); + _inherits(Tw2YPRSequencer, _Tw2CurveSequencer); - var _this = _possibleConstructorReturn(this, (Tw2YPRSequencer.__proto__ || Object.getPrototypeOf(Tw2YPRSequencer)).call(this)); + function Tw2YPRSequencer() { + _classCallCheck(this, Tw2YPRSequencer); - _this.value = _global.quat.create(); - _this.YawPitchRoll = _global.vec3.create(); - _this.YawCurve = null; - _this.PitchCurve = null; - _this.RollCurve = null; - return _this; - } - - /** - * Sorts the sequencer - */ + var _this = _possibleConstructorReturn(this, (Tw2YPRSequencer.__proto__ || Object.getPrototypeOf(Tw2YPRSequencer)).call(this)); - - _createClass(Tw2YPRSequencer, [{ - key: 'Sort', - value: function Sort() { - _Tw2CurveSequencer2.Tw2CurveSequencer.Sort2(this); + _this.value = _global.quat.create(); + _this.YawPitchRoll = _global.vec3.create(); + _this.YawCurve = null; + _this.PitchCurve = null; + _this.RollCurve = null; + return _this; } /** - * Gets sequencer length - * @returns {number} + * Sorts the sequencer */ - }, { - key: 'GetLength', - value: function GetLength() { - var len = 0; - if (this.YawCurve && 'GetLength' in this.YawCurve) len = this.YawCurve.GetLength(); - if (this.PitchCurve && 'GetLength' in this.PitchCurve) len = Math.max(len, this.PitchCurve.GetLength()); - if (this.RollCurve && 'GetLength' in this.RollCurve) len = Math.max(len, this.RollCurve.GetLength()); - return len; - } - /** - * Updates a value at a specific time - * - * @param {number} time - */ + _createClass(Tw2YPRSequencer, [{ + key: 'Sort', + value: function Sort() { + _Tw2CurveSequencer2.Tw2CurveSequencer.Sort2(this); + } - }, { - key: 'UpdateValue', - value: function UpdateValue(time) { - this.GetValueAt(time, this.value); - } + /** + * Gets sequencer length + * @returns {number} + */ - /** - * Gets a value at a specific time - * - * @param {number} time - * @param {quat} value - * @returns {quat} - */ + }, { + key: 'GetLength', + value: function GetLength() { + var len = 0; + if (this.YawCurve && 'GetLength' in this.YawCurve) len = this.YawCurve.GetLength(); + if (this.PitchCurve && 'GetLength' in this.PitchCurve) len = Math.max(len, this.PitchCurve.GetLength()); + if (this.RollCurve && 'GetLength' in this.RollCurve) len = Math.max(len, this.RollCurve.GetLength()); + return len; + } - }, { - key: 'GetValueAt', - value: function GetValueAt(time, value) { - if (this.YawCurve) this.YawPitchRoll[0] = this.YawCurve.GetValueAt(time); - if (this.PitchCurve) this.YawPitchRoll[1] = this.PitchCurve.GetValueAt(time); - if (this.RollCurve) this.YawPitchRoll[2] = this.RollCurve.GetValueAt(time); - - var sinYaw = Math.sin(this.YawPitchRoll[0] / 180 * Math.PI / 2.0), - cosYaw = Math.cos(this.YawPitchRoll[0] / 180 * Math.PI / 2.0), - sinPitch = Math.sin(this.YawPitchRoll[1] / 180 * Math.PI / 2.0), - cosPitch = Math.cos(this.YawPitchRoll[1] / 180 * Math.PI / 2.0), - sinRoll = Math.sin(this.YawPitchRoll[2] / 180 * Math.PI / 2.0), - cosRoll = Math.cos(this.YawPitchRoll[2] / 180 * Math.PI / 2.0); - - value[0] = sinYaw * cosPitch * sinRoll + cosYaw * sinPitch * cosRoll; - value[1] = sinYaw * cosPitch * cosRoll - cosYaw * sinPitch * sinRoll; - value[2] = cosYaw * cosPitch * sinRoll - sinYaw * sinPitch * cosRoll; - value[3] = cosYaw * cosPitch * cosRoll + sinYaw * sinPitch * sinRoll; + /** + * Updates a value at a specific time + * + * @param {number} time + */ - return value; - } - }]); + }, { + key: 'UpdateValue', + value: function UpdateValue(time) { + this.GetValueAt(time, this.value); + } + + /** + * Gets a value at a specific time + * + * @param {number} time + * @param {quat} value + * @returns {quat} + */ + + }, { + key: 'GetValueAt', + value: function GetValueAt(time, value) { + if (this.YawCurve) this.YawPitchRoll[0] = this.YawCurve.GetValueAt(time); + if (this.PitchCurve) this.YawPitchRoll[1] = this.PitchCurve.GetValueAt(time); + if (this.RollCurve) this.YawPitchRoll[2] = this.RollCurve.GetValueAt(time); + + var sinYaw = Math.sin(this.YawPitchRoll[0] / 180 * Math.PI / 2.0), + cosYaw = Math.cos(this.YawPitchRoll[0] / 180 * Math.PI / 2.0), + sinPitch = Math.sin(this.YawPitchRoll[1] / 180 * Math.PI / 2.0), + cosPitch = Math.cos(this.YawPitchRoll[1] / 180 * Math.PI / 2.0), + sinRoll = Math.sin(this.YawPitchRoll[2] / 180 * Math.PI / 2.0), + cosRoll = Math.cos(this.YawPitchRoll[2] / 180 * Math.PI / 2.0); + + value[0] = sinYaw * cosPitch * sinRoll + cosYaw * sinPitch * cosRoll; + value[1] = sinYaw * cosPitch * cosRoll - cosYaw * sinPitch * sinRoll; + value[2] = cosYaw * cosPitch * sinRoll - sinYaw * sinPitch * cosRoll; + value[3] = cosYaw * cosPitch * cosRoll + sinYaw * sinPitch * sinRoll; + + return value; + } + }]); - return Tw2YPRSequencer; + return Tw2YPRSequencer; }(_Tw2CurveSequencer2.Tw2CurveSequencer); /** @@ -30702,7 +31157,7 @@ Tw2YPRSequencer.curveType = _Tw2CurveSequencer2.Tw2CurveSequencer.Type.SEQUENCER Tw2YPRSequencer.childProperties = ['YawCurve', 'PitchCurve', 'RollCurve']; /***/ }), -/* 151 */ +/* 150 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -30712,7 +31167,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2WbgTrack = __webpack_require__(152); +var _Tw2WbgTrack = __webpack_require__(151); Object.keys(_Tw2WbgTrack).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -30724,7 +31179,7 @@ Object.keys(_Tw2WbgTrack).forEach(function (key) { }); }); -var _Tw2TransformTrack = __webpack_require__(153); +var _Tw2TransformTrack = __webpack_require__(152); Object.keys(_Tw2TransformTrack).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -30737,7 +31192,7 @@ Object.keys(_Tw2TransformTrack).forEach(function (key) { }); /***/ }), -/* 152 */ +/* 151 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -30903,7 +31358,7 @@ function Tw2WbgTransformTrack() { Tw2WbgTransformTrack.prototype = new Tw2WbgTrack(); /***/ }), -/* 153 */ +/* 152 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -31041,7 +31496,7 @@ var Tw2TransformTrack = exports.Tw2TransformTrack = function () { }(); /***/ }), -/* 154 */ +/* 153 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -31051,7 +31506,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2MayaEulerRotationCurve = __webpack_require__(155); +var _Tw2MayaEulerRotationCurve = __webpack_require__(154); Object.keys(_Tw2MayaEulerRotationCurve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -31063,7 +31518,7 @@ Object.keys(_Tw2MayaEulerRotationCurve).forEach(function (key) { }); }); -var _Tw2MayaScalarCurve = __webpack_require__(156); +var _Tw2MayaScalarCurve = __webpack_require__(155); Object.keys(_Tw2MayaScalarCurve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -31075,7 +31530,7 @@ Object.keys(_Tw2MayaScalarCurve).forEach(function (key) { }); }); -var _Tw2MayaVector3Curve = __webpack_require__(157); +var _Tw2MayaVector3Curve = __webpack_require__(156); Object.keys(_Tw2MayaVector3Curve).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -31087,7 +31542,7 @@ Object.keys(_Tw2MayaVector3Curve).forEach(function (key) { }); }); -var _Tw2MayaAnimationEngine = __webpack_require__(158); +var _Tw2MayaAnimationEngine = __webpack_require__(157); Object.keys(_Tw2MayaAnimationEngine).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -31100,7 +31555,7 @@ Object.keys(_Tw2MayaAnimationEngine).forEach(function (key) { }); /***/ }), -/* 155 */ +/* 154 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -31271,7 +31726,7 @@ Tw2MayaEulerRotationCurve.valueProperty = 'eulerValue'; Tw2MayaEulerRotationCurve.curveType = _curves.Tw2Curve.Type.CURVE_MAYA; /***/ }), -/* 156 */ +/* 155 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -31387,7 +31842,7 @@ Tw2MayaScalarCurve.valueProperty = 'value'; Tw2MayaScalarCurve.curveType = _curves.Tw2Curve.Type.CURVE_MAYA; /***/ }), -/* 157 */ +/* 156 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -31539,7 +31994,7 @@ Tw2MayaVector3Curve.valueProperty = 'value'; Tw2MayaVector3Curve.curveType = _curves.Tw2Curve.Type.CURVE_MAYA; /***/ }), -/* 158 */ +/* 157 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -31916,7 +32371,7 @@ Tw2MayaAnimationEngine.BezierSegment = { Tw2MayaAnimationEngine.INFINITY = 0; /***/ }), -/* 159 */ +/* 158 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -31938,7 +32393,7 @@ Object.keys(_child).forEach(function (key) { }); }); -var _effect = __webpack_require__(165); +var _effect = __webpack_require__(164); Object.keys(_effect).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -31974,7 +32429,7 @@ Object.keys(_item).forEach(function (key) { }); }); -var _EveSpaceScene = __webpack_require__(183); +var _EveSpaceScene = __webpack_require__(182); Object.keys(_EveSpaceScene).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -31986,7 +32441,7 @@ Object.keys(_EveSpaceScene).forEach(function (key) { }); }); -var _EveSOF = __webpack_require__(184); +var _EveSOF = __webpack_require__(183); Object.keys(_EveSOF).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -31999,7 +32454,7 @@ Object.keys(_EveSOF).forEach(function (key) { }); /***/ }), -/* 160 */ +/* 159 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32115,7 +32570,7 @@ var EveChildBillboard = exports.EveChildBillboard = function (_EveChild) { }(_EveChild2.EveChild); /***/ }), -/* 161 */ +/* 160 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32220,7 +32675,7 @@ var EveChildContainer = exports.EveChildContainer = function (_EveChild) { }(_EveChild2.EveChild); /***/ }), -/* 162 */ +/* 161 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32257,7 +32712,7 @@ var EveChildExplosion = exports.EveChildExplosion = function (_EveChild) { }(_EveChild2.EveChild); /***/ }), -/* 163 */ +/* 162 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32368,7 +32823,7 @@ var EveChildMesh = exports.EveChildMesh = function (_EveChild) { }(_EveChild2.EveChild); /***/ }), -/* 164 */ +/* 163 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32478,7 +32933,7 @@ var EveChildParticleSystem = exports.EveChildParticleSystem = function (_EveChil }(_EveChild2.EveChild); /***/ }), -/* 165 */ +/* 164 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32488,7 +32943,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _EveLensflare = __webpack_require__(166); +var _EveLensflare = __webpack_require__(165); Object.keys(_EveLensflare).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -32500,7 +32955,7 @@ Object.keys(_EveLensflare).forEach(function (key) { }); }); -var _EveMeshOverlayEffect = __webpack_require__(167); +var _EveMeshOverlayEffect = __webpack_require__(166); Object.keys(_EveMeshOverlayEffect).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -32524,7 +32979,7 @@ Object.keys(_EveOccluder).forEach(function (key) { }); }); -var _EveStretch = __webpack_require__(168); +var _EveStretch = __webpack_require__(167); Object.keys(_EveStretch).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -32536,7 +32991,7 @@ Object.keys(_EveStretch).forEach(function (key) { }); }); -var _EveTurretFiringFX = __webpack_require__(169); +var _EveTurretFiringFX = __webpack_require__(168); Object.keys(_EveTurretFiringFX).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -32548,7 +33003,7 @@ Object.keys(_EveTurretFiringFX).forEach(function (key) { }); }); -var _EveStarField = __webpack_require__(170); +var _EveStarField = __webpack_require__(169); Object.keys(_EveStarField).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -32561,7 +33016,7 @@ Object.keys(_EveStarField).forEach(function (key) { }); /***/ }), -/* 166 */ +/* 165 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32902,7 +33357,7 @@ var EveLensflare = exports.EveLensflare = function () { EveLensflare.global = null; /***/ }), -/* 167 */ +/* 166 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33058,7 +33513,7 @@ var EveMeshOverlayEffect = exports.EveMeshOverlayEffect = function () { }(); /***/ }), -/* 168 */ +/* 167 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33377,7 +33832,7 @@ var EveStretch = exports.EveStretch = function () { EveStretch.global = null; /***/ }), -/* 169 */ +/* 168 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33723,7 +34178,7 @@ var EveTurretFiringFX = exports.EveTurretFiringFX = function () { }(); /***/ }), -/* 170 */ +/* 169 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33766,7 +34221,7 @@ var EveStarField = exports.EveStarField = function EveStarField() { }; /***/ }), -/* 171 */ +/* 170 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33939,7 +34394,7 @@ var EveEffectRoot = exports.EveEffectRoot = function (_EveObject) { }(_EveObject2.EveObject); /***/ }), -/* 172 */ +/* 171 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -34350,7 +34805,7 @@ var EveMissile = exports.EveMissile = function () { }(); /***/ }), -/* 173 */ +/* 172 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -34677,7 +35132,7 @@ var EvePlanet = exports.EvePlanet = function (_EveObject) { }(_EveObject2.EveObject); /***/ }), -/* 174 */ +/* 173 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -34899,7 +35354,7 @@ var EveShip = exports.EveShip = function (_EveSpaceObject) { }(_EveSpaceObject2.EveSpaceObject); /***/ }), -/* 175 */ +/* 174 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -35480,7 +35935,7 @@ EveBoosterSet.Item = EveBoosterSetItem; EveBoosterSet._box = [[[-1.0, -1.0, 0.0], [1.0, -1.0, 0.0], [1.0, 1.0, 0.0], [-1.0, 1.0, 0.0]], [[-1.0, -1.0, -1.0], [-1.0, 1.0, -1.0], [1.0, 1.0, -1.0], [1.0, -1.0, -1.0]], [[-1.0, -1.0, 0.0], [-1.0, 1.0, 0.0], [-1.0, 1.0, -1.0], [-1.0, -1.0, -1.0]], [[1.0, -1.0, 0.0], [1.0, -1.0, -1.0], [1.0, 1.0, -1.0], [1.0, 1.0, 0.0]], [[-1.0, -1.0, 0.0], [-1.0, -1.0, -1.0], [1.0, -1.0, -1.0], [1.0, -1.0, 0.0]], [[-1.0, 1.0, 0.0], [1.0, 1.0, 0.0], [1.0, 1.0, -1.0], [-1.0, 1.0, -1.0]]]; /***/ }), -/* 176 */ +/* 175 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -36438,7 +36893,7 @@ EveCurveLineSet.global = null; EveCurveLineSet.Item = EveCurveLineSetItem; /***/ }), -/* 177 */ +/* 176 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -36517,7 +36972,7 @@ EveLocator.Prefix = { }; /***/ }), -/* 178 */ +/* 177 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -36906,7 +37361,7 @@ var EvePlaneSet = exports.EvePlaneSet = function (_EveObjectSet) { EvePlaneSet.Item = EvePlaneSetItem; /***/ }), -/* 179 */ +/* 178 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -37004,10 +37459,12 @@ var EveSpaceObjectDecal = exports.EveSpaceObjectDecal = function () { key: 'OnValueChanged', value: function OnValueChanged() { if (!this._indexBuffer && this.indexBuffer) { - var indexes = new Uint16Array(this.indexBuffer); - this._indexBuffer = _global.device.gl.createBuffer(); - _global.device.gl.bindBuffer(_global.device.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - _global.device.gl.bufferData(_global.device.gl.ELEMENT_ARRAY_BUFFER, indexes, _global.device.gl.STATIC_DRAW); + var gl = _global.device.gl, + indexes = new Uint16Array(this.indexBuffer); + + this._indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indexes, gl.STATIC_DRAW); } _global.mat4.fromRotationTranslationScale(this.decalMatrix, this.rotation, this.position, this.scaling); @@ -37171,7 +37628,7 @@ var EveSpaceObjectDecal = exports.EveSpaceObjectDecal = function () { }(); /***/ }), -/* 180 */ +/* 179 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -37624,7 +38081,7 @@ var EveSpotlightSet = exports.EveSpotlightSet = function (_EveObjectSet) { EveSpotlightSet.Item = EveSpotlightSetItem; /***/ }), -/* 181 */ +/* 180 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -37817,22 +38274,24 @@ var EveSpriteSet = exports.EveSpriteSet = function (_EveObjectSet) { this.useQuads = useQuads; this.isSkinned = isSkinned; + var gl = _global.device.gl; + this._decl.elements.splice(0, this._decl.elements.length); if (!useQuads) { - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 5, _global.device.gl.FLOAT, 2, 0)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.POSITION, 0, _global.device.gl.FLOAT, 3, 8)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 0, _global.device.gl.FLOAT, 3, 20)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 0, _global.device.gl.FLOAT, 1, 32)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 1, _global.device.gl.FLOAT, 1, 36)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 2, _global.device.gl.FLOAT, 1, 40)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 3, _global.device.gl.FLOAT, 1, 44)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 4, _global.device.gl.FLOAT, 1, 48)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 5, gl.FLOAT, 2, 0)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.POSITION, 0, gl.FLOAT, 3, 8)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 0, gl.FLOAT, 3, 20)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 0, gl.FLOAT, 1, 32)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 1, gl.FLOAT, 1, 36)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 2, gl.FLOAT, 1, 40)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 3, gl.FLOAT, 1, 44)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 4, gl.FLOAT, 1, 48)); } else { - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.POSITION, 0, _global.device.gl.FLOAT, 3, 0)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 0, _global.device.gl.FLOAT, 4, 12)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 1, _global.device.gl.FLOAT, 2, 28)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 0, _global.device.gl.FLOAT, 4, 36)); - this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 1, _global.device.gl.FLOAT, 4, 52)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.POSITION, 0, gl.FLOAT, 3, 0)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 0, gl.FLOAT, 4, 12)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.TEXCOORD, 1, gl.FLOAT, 2, 28)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 0, gl.FLOAT, 4, 36)); + this._decl.elements.push(new _core.Tw2VertexElement(_core.Tw2VertexDeclaration.Type.COLOR, 1, gl.FLOAT, 4, 52)); } this._decl.RebuildHash(); @@ -37878,20 +38337,22 @@ var EveSpriteSet = exports.EveSpriteSet = function (_EveObjectSet) { }, { key: 'Unload', value: function Unload() { + var gl = _global.device.gl; + if (this._vertexBuffer) { - _global.device.gl.deleteBuffer(this._vertexBuffer); + gl.deleteBuffer(this._vertexBuffer); this._vertexBuffer = null; } // Standard if (this._indexBuffer) { - _global.device.gl.deleteBuffer(this._indexBuffer); + gl.deleteBuffer(this._indexBuffer); this._indexBuffer = null; } // Quad if (this._instanceBuffer) { - _global.device.gl.deleteBuffer(this._instanceBuffer); + gl.deleteBuffer(this._instanceBuffer); this._instanceBuffer = null; } } @@ -37908,14 +38369,14 @@ var EveSpriteSet = exports.EveSpriteSet = function (_EveObjectSet) { var itemCount = this._visibleItems.length; if (!itemCount) return; - var d = _global.device; + var gl = _global.device.gl; if (this.useQuads) { - this._vertexBuffer = d.gl.createBuffer(); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vertexBuffer); - d.gl.bufferData(d.gl.ARRAY_BUFFER, new Float32Array([0, 1, 2, 2, 3, 0]), d.gl.STATIC_DRAW); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, null); - this._instanceBuffer = d.gl.createBuffer(); + this._vertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 1, 2, 2, 3, 0]), gl.STATIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, null); + this._instanceBuffer = gl.createBuffer(); return; } @@ -37948,10 +38409,10 @@ var EveSpriteSet = exports.EveSpriteSet = function (_EveObjectSet) { } } - this._vertexBuffer = d.gl.createBuffer(); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vertexBuffer); - d.gl.bufferData(d.gl.ARRAY_BUFFER, array, d.gl.STATIC_DRAW); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, null); + this._vertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, null); var indexes = new Uint16Array(itemCount * 6); for (var _i = 0; _i < itemCount; ++_i) { @@ -37966,10 +38427,10 @@ var EveSpriteSet = exports.EveSpriteSet = function (_EveObjectSet) { indexes[_offset + 5] = _vtxOffset + 2; } - this._indexBuffer = d.gl.createBuffer(); - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - d.gl.bufferData(d.gl.ELEMENT_ARRAY_BUFFER, indexes, d.gl.STATIC_DRAW); - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, null); + this._indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indexes, gl.STATIC_DRAW); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null); this._indexBuffer.count = itemCount * 6; } @@ -38037,15 +38498,18 @@ var EveSpriteSet = exports.EveSpriteSet = function (_EveObjectSet) { if (!this.effect || !this.effect.IsGood() || !this._indexBuffer) return false; - _global.device.SetStandardStates(_global.device.RM_ADDITIVE); - _global.device.gl.bindBuffer(_global.device.gl.ARRAY_BUFFER, this._vertexBuffer); - _global.device.gl.bindBuffer(_global.device.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + var d = _global.device, + gl = d.gl; + + d.SetStandardStates(d.RM_ADDITIVE); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); for (var pass = 0; pass < this.effect.GetPassCount(technique); ++pass) { this.effect.ApplyPass(technique, pass); if (!this._decl.SetDeclaration(this.effect.GetPassInput(technique, pass), 52)) return false; - _global.device.ApplyShadowState(); - _global.device.gl.drawElements(_global.device.gl.TRIANGLES, this._indexBuffer.count, _global.device.gl.UNSIGNED_SHORT, 0); + d.ApplyShadowState(); + gl.drawElements(gl.TRIANGLES, this._indexBuffer.count, gl.UNSIGNED_SHORT, 0); } return true; } @@ -38065,6 +38529,7 @@ var EveSpriteSet = exports.EveSpriteSet = function (_EveObjectSet) { if (!this.effect || !this.effect.IsGood() || !this._instanceBuffer) return false; var d = _global.device, + gl = d.gl, pos = _EveObjectSet2.EveObjectSet.global.vec3_0, itemCount = this._visibleItems.length, array = new Float32Array(17 * itemCount); @@ -38094,18 +38559,18 @@ var EveSpriteSet = exports.EveSpriteSet = function (_EveObjectSet) { array[index++] = warpIntensity; } - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._instanceBuffer); - d.gl.bufferData(d.gl.ARRAY_BUFFER, array, d.gl.DYNAMIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, this._instanceBuffer); + gl.bufferData(gl.ARRAY_BUFFER, array, gl.DYNAMIC_DRAW); for (var pass = 0; pass < this.effect.GetPassCount(technique); ++pass) { this.effect.ApplyPass(technique, pass); var passInput = this.effect.GetPassInput(technique, pass); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); this._vdecl.SetPartialDeclaration(passInput, 4); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._instanceBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, this._instanceBuffer); var resetData = this._decl.SetPartialDeclaration(passInput, 17 * 4, 0, 1); d.ApplyShadowState(); - d.ext.drawArraysInstanced(d.gl.TRIANGLES, 0, 6, itemCount); + d.ext.drawArraysInstanced(gl.TRIANGLES, 0, 6, itemCount); this._decl.ResetInstanceDivisors(resetData); } @@ -38126,6 +38591,7 @@ var EveSpriteSet = exports.EveSpriteSet = function (_EveObjectSet) { if (!this.effect || !this.effect.IsGood() || !this._instanceBuffer) return false; var d = _global.device, + gl = d.gl, itemCount = this._visibleItems.length, array = new Float32Array(17 * itemCount), pos = _EveObjectSet2.EveObjectSet.global.vec3_0, @@ -38165,18 +38631,18 @@ var EveSpriteSet = exports.EveSpriteSet = function (_EveObjectSet) { array[index++] = 1; } - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._instanceBuffer); - d.gl.bufferData(d.gl.ARRAY_BUFFER, array, d.gl.DYNAMIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, this._instanceBuffer); + gl.bufferData(gl.ARRAY_BUFFER, array, gl.DYNAMIC_DRAW); for (var pass = 0; pass < this.effect.GetPassCount(technique); ++pass) { this.effect.ApplyPass(technique, pass); var passInput = this.effect.GetPassInput(technique, pass); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); this._vdecl.SetPartialDeclaration(passInput, 4); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._instanceBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, this._instanceBuffer); var resetData = this._decl.SetPartialDeclaration(passInput, 17 * 4, 0, 1); d.ApplyShadowState(); - d.ext.drawArraysInstanced(d.gl.TRIANGLES, 0, 6, itemCount); + d.ext.drawArraysInstanced(gl.TRIANGLES, 0, 6, itemCount); this._decl.ResetInstanceDivisors(resetData); } @@ -38210,7 +38676,7 @@ var EveSpriteSet = exports.EveSpriteSet = function (_EveObjectSet) { EveSpriteSet.Item = EveSpriteSetItem; /***/ }), -/* 182 */ +/* 181 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -39120,7 +39586,7 @@ EveTurretSet.worldNames = ['turretWorld0', 'turretWorld1', 'turretWorld2']; EveTurretSet.positionBoneSkeletonNames = ['Pos_Fire01', 'Pos_Fire02', 'Pos_Fire03', 'Pos_Fire04', 'Pos_Fire05', 'Pos_Fire06', 'Pos_Fire07', 'Pos_Fire08']; /***/ }), -/* 183 */ +/* 182 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -39706,7 +40172,7 @@ EveSpaceScene.global = null; EveSpaceScene.DebugRenderer = 'Tw2DebugRenderer' in window ? window['Tw2DebugRenderer'] : null; /***/ }), -/* 184 */ +/* 183 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -40587,7 +41053,7 @@ function EveSOF() { } /***/ }), -/* 185 */ +/* 184 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -40597,7 +41063,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _emitters = __webpack_require__(186); +var _emitters = __webpack_require__(185); Object.keys(_emitters).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -40609,7 +41075,7 @@ Object.keys(_emitters).forEach(function (key) { }); }); -var _forces = __webpack_require__(190); +var _forces = __webpack_require__(189); Object.keys(_forces).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -40621,7 +41087,7 @@ Object.keys(_forces).forEach(function (key) { }); }); -var _generators = __webpack_require__(197); +var _generators = __webpack_require__(196); Object.keys(_generators).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -40633,7 +41099,7 @@ Object.keys(_generators).forEach(function (key) { }); }); -var _constraints = __webpack_require__(201); +var _constraints = __webpack_require__(200); Object.keys(_constraints).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -40645,7 +41111,7 @@ Object.keys(_constraints).forEach(function (key) { }); }); -var _Tw2ParticleSystem = __webpack_require__(202); +var _Tw2ParticleSystem = __webpack_require__(201); Object.keys(_Tw2ParticleSystem).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -40670,7 +41136,7 @@ Object.keys(_Tw2ParticleElement).forEach(function (key) { }); /***/ }), -/* 186 */ +/* 185 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -40680,7 +41146,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2StaticEmitter = __webpack_require__(187); +var _Tw2StaticEmitter = __webpack_require__(186); Object.keys(_Tw2StaticEmitter).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -40692,7 +41158,7 @@ Object.keys(_Tw2StaticEmitter).forEach(function (key) { }); }); -var _Tw2DynamicEmitter = __webpack_require__(188); +var _Tw2DynamicEmitter = __webpack_require__(187); Object.keys(_Tw2DynamicEmitter).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -40704,7 +41170,7 @@ Object.keys(_Tw2DynamicEmitter).forEach(function (key) { }); }); -var _Tw2GpuUniqueEmitter = __webpack_require__(189); +var _Tw2GpuUniqueEmitter = __webpack_require__(188); Object.keys(_Tw2GpuUniqueEmitter).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -40717,7 +41183,7 @@ Object.keys(_Tw2GpuUniqueEmitter).forEach(function (key) { }); /***/ }), -/* 187 */ +/* 186 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -40871,7 +41337,7 @@ var Tw2StaticEmitter = exports.Tw2StaticEmitter = function (_Tw2ParticleEmitter) }(_Tw2ParticleEmitter2.Tw2ParticleEmitter); /***/ }), -/* 188 */ +/* 187 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -40990,7 +41456,7 @@ var Tw2DynamicEmitter = exports.Tw2DynamicEmitter = function (_Tw2ParticleEmitte }(_Tw2ParticleEmitter2.Tw2ParticleEmitter); /***/ }), -/* 189 */ +/* 188 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41084,7 +41550,7 @@ var Tw2GpuUniqueEmitter = exports.Tw2GpuUniqueEmitter = function (_Tw2ParticleEm exports.Tr2GpuUniqueEmitter = Tw2GpuUniqueEmitter; /***/ }), -/* 190 */ +/* 189 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41094,7 +41560,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2ParticleAttractorForce = __webpack_require__(191); +var _Tw2ParticleAttractorForce = __webpack_require__(190); Object.keys(_Tw2ParticleAttractorForce).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -41106,7 +41572,7 @@ Object.keys(_Tw2ParticleAttractorForce).forEach(function (key) { }); }); -var _Tw2ParticleDirectForce = __webpack_require__(192); +var _Tw2ParticleDirectForce = __webpack_require__(191); Object.keys(_Tw2ParticleDirectForce).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -41118,7 +41584,7 @@ Object.keys(_Tw2ParticleDirectForce).forEach(function (key) { }); }); -var _Tw2ParticleDragForce = __webpack_require__(193); +var _Tw2ParticleDragForce = __webpack_require__(192); Object.keys(_Tw2ParticleDragForce).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -41130,7 +41596,7 @@ Object.keys(_Tw2ParticleDragForce).forEach(function (key) { }); }); -var _Tw2ParticleFluidDragForce = __webpack_require__(194); +var _Tw2ParticleFluidDragForce = __webpack_require__(193); Object.keys(_Tw2ParticleFluidDragForce).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -41142,7 +41608,7 @@ Object.keys(_Tw2ParticleFluidDragForce).forEach(function (key) { }); }); -var _Tw2ParticleSpring = __webpack_require__(195); +var _Tw2ParticleSpring = __webpack_require__(194); Object.keys(_Tw2ParticleSpring).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -41154,7 +41620,7 @@ Object.keys(_Tw2ParticleSpring).forEach(function (key) { }); }); -var _Tw2ParticleTurbulenceForce = __webpack_require__(196); +var _Tw2ParticleTurbulenceForce = __webpack_require__(195); Object.keys(_Tw2ParticleTurbulenceForce).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -41167,7 +41633,7 @@ Object.keys(_Tw2ParticleTurbulenceForce).forEach(function (key) { }); /***/ }), -/* 191 */ +/* 190 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41239,7 +41705,7 @@ var Tw2ParticleAttractorForce = exports.Tw2ParticleAttractorForce = function (_T }(_Tw2ParticleForce2.Tw2ParticleForce); /***/ }), -/* 192 */ +/* 191 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41300,7 +41766,7 @@ var Tw2ParticleDirectForce = exports.Tw2ParticleDirectForce = function (_Tw2Part }(_Tw2ParticleForce2.Tw2ParticleForce); /***/ }), -/* 193 */ +/* 192 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41361,7 +41827,7 @@ var Tw2ParticleDragForce = exports.Tw2ParticleDragForce = function (_Tw2Particle }(_Tw2ParticleForce2.Tw2ParticleForce); /***/ }), -/* 194 */ +/* 193 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41447,7 +41913,7 @@ var Tw2ParticleFluidDragForce = exports.Tw2ParticleFluidDragForce = function (_T }(_Tw2ParticleForce2.Tw2ParticleForce); /***/ }), -/* 195 */ +/* 194 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41512,7 +41978,7 @@ var Tw2ParticleSpring = exports.Tw2ParticleSpring = function (_Tw2ParticleForce) }(_Tw2ParticleForce2.Tw2ParticleForce); /***/ }), -/* 196 */ +/* 195 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41617,7 +42083,7 @@ var Tw2ParticleTurbulenceForce = exports.Tw2ParticleTurbulenceForce = function ( }(_Tw2ParticleForce2.Tw2ParticleForce); /***/ }), -/* 197 */ +/* 196 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41627,7 +42093,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -var _Tw2RandomIntegerAttributeGenerator = __webpack_require__(198); +var _Tw2RandomIntegerAttributeGenerator = __webpack_require__(197); Object.keys(_Tw2RandomIntegerAttributeGenerator).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -41639,7 +42105,7 @@ Object.keys(_Tw2RandomIntegerAttributeGenerator).forEach(function (key) { }); }); -var _Tw2RandomUniformAttributeGenerator = __webpack_require__(199); +var _Tw2RandomUniformAttributeGenerator = __webpack_require__(198); Object.keys(_Tw2RandomUniformAttributeGenerator).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -41651,7 +42117,7 @@ Object.keys(_Tw2RandomUniformAttributeGenerator).forEach(function (key) { }); }); -var _Tw2SphereShapeAttributeGenerator = __webpack_require__(200); +var _Tw2SphereShapeAttributeGenerator = __webpack_require__(199); Object.keys(_Tw2SphereShapeAttributeGenerator).forEach(function (key) { if (key === "default" || key === "__esModule") return; @@ -41664,7 +42130,7 @@ Object.keys(_Tw2SphereShapeAttributeGenerator).forEach(function (key) { }); /***/ }), -/* 198 */ +/* 197 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41755,7 +42221,7 @@ var Tw2RandomIntegerAttributeGenerator = exports.Tw2RandomIntegerAttributeGenera }(_Tw2ParticleAttributeGenerator.Tw2ParticleAttributeGenerator); /***/ }), -/* 199 */ +/* 198 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41846,7 +42312,7 @@ var Tw2RandomUniformAttributeGenerator = exports.Tw2RandomUniformAttributeGenera }(_Tw2ParticleAttributeGenerator.Tw2ParticleAttributeGenerator); /***/ }), -/* 200 */ +/* 199 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -41996,14 +42462,14 @@ var Tw2SphereShapeAttributeGenerator = exports.Tw2SphereShapeAttributeGenerator }(_Tw2ParticleAttributeGenerator.Tw2ParticleAttributeGenerator); /***/ }), -/* 201 */ +/* 200 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /***/ }), -/* 202 */ +/* 201 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -42113,9 +42579,10 @@ var Tw2ParticleSystem = exports.Tw2ParticleSystem = function () { key: 'UpdateElementDeclaration', value: function UpdateElementDeclaration() { this.isValid = false; + var gl = _global.device.gl; if (this._vb) { - _global.device.gl.deleteBuffer(this._vb); + gl.deleteBuffer(this._vb); this._vb = null; } @@ -42168,10 +42635,10 @@ var Tw2ParticleSystem = exports.Tw2ParticleSystem = function () { this.buffers = [null, null]; if (this.instanceStride[0] && this.maxParticleCount) { this.buffers[0] = new Float32Array(this.instanceStride[0] * this.maxParticleCount); - this._vb = _global.device.gl.createBuffer(); - _global.device.gl.bindBuffer(_global.device.gl.ARRAY_BUFFER, this._vb); - _global.device.gl.bufferData(_global.device.gl.ARRAY_BUFFER, this.buffers[0].length, _global.device.gl.DYNAMIC_DRAW); - _global.device.gl.bindBuffer(_global.device.gl.ARRAY_BUFFER, null); + this._vb = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vb); + gl.bufferData(gl.ARRAY_BUFFER, this.buffers[0].length, gl.DYNAMIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, null); } if (this.instanceStride[1]) { @@ -42459,7 +42926,7 @@ var Tw2ParticleSystem = exports.Tw2ParticleSystem = function () { value: function GetInstanceBuffer() { if (this.aliveCount === 0) return undefined; - var d = _global.device; + var gl = _global.device.gl; if (this.requiresSorting && this.HasElement(_Tw2ParticleElement.Tw2ParticleElementDeclaration.Type.POSITION) && this.buffers) { this._Sort(); @@ -42475,12 +42942,12 @@ var Tw2ParticleSystem = exports.Tw2ParticleSystem = function () { } } - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vb); - d.gl.bufferSubData(d.gl.ARRAY_BUFFER, 0, this._sortedBuffer.subarray(0, this.vertexStride[0] * this.aliveCount)); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vb); + gl.bufferSubData(gl.ARRAY_BUFFER, 0, this._sortedBuffer.subarray(0, this.vertexStride[0] * this.aliveCount)); this.bufferDirty = false; } else if (this.bufferDirty) { - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vb); - d.gl.bufferSubData(d.gl.ARRAY_BUFFER, 0, this.buffers[0].subarray(0, this.vertexStride[0] * this.aliveCount)); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vb); + gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.buffers[0].subarray(0, this.vertexStride[0] * this.aliveCount)); this.bufferDirty = false; } diff --git a/dist/ccpwgl_int.min.js b/dist/ccpwgl_int.min.js index e1dfadd..156c3f7 100644 --- a/dist/ccpwgl_int.min.js +++ b/dist/ccpwgl_int.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ccpwgl_int=t():e.ccpwgl_int=t()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=65)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.util=void 0;var n=r(18);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(78);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(16));t.util=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(15);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(36);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(93);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(103);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(47);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(48);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(118);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(45);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(124);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})});var h=r(26);Object.keys(h).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return h[e]}})});var p=r(25);Object.keys(p).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return p[e]}})});var d=r(21);Object.keys(d).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return d[e]}})});var v=r(9);Object.keys(v).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return v[e]}})});var m=r(126);Object.keys(m).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return m[e]}})});var y=r(127);Object.keys(y).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return y[e]}})});var b=r(57);Object.keys(b).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return b[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Curve=t.Tw2CurveKey=void 0;var n=function(){function e(e,t){for(var r=0;rt.time?1:0}},{key:"Sort",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.keys;r&&r.length&&(r.sort(e.Compare),t.length=r[r.length-1].time)}},{key:"Sort2",value:function(t){if(t.keys&&t.keys.length){t.keys.sort(e.Compare);var r=t.keys[t.keys.length-1];if(r.time>t.length){var n=t.length,i=t.endValue,a=t.endTangent;t.length=r.time,t.endValue=r.value,t.endTangent=r.leftTangent,n>0&&(r.time=n,r.value=i,r.leftTangent=a)}}}}]),e}();o.inputDimension=null,o.outputDimension=null,o.valueProperty=null,o.curveType=null,o.Key=null,o.Interpolation=null,o.Extrapolation=null,o.Type={CURVE:1,CURVE2:2,CURVE_MAYA:3,CURVE_NO_KEYS:4,SEQUENCER:100,SEQUENCER2:101},o.global={vec3_0:i.vec3.create(),vec4_0:i.vec4.create(),quat_0:i.quat.create(),quat_1:i.quat.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r.d(t,"ARRAY_TYPE",function(){return i}),t.setMatrixArrayType=function(e){i=e},t.toRadian=function(e){return e*o},t.equals=function(e,t){return Math.abs(e-t)<=n*Math.max(1,Math.abs(e),Math.abs(t))};const n=1e-6;t.EPSILON=n;let i="undefined"!=typeof Float32Array?Float32Array:Array;const a=Math.random;t.RANDOM=a;const o=Math.PI/180},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VectorParameter=t.Tw2Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";a(this,e),this._id=i.util.generateID(),this.name=t,this._onModified=[]}return n(e,[{key:"OnValueChanged",value:function(e,t){for(var r=0;r=this.size&&(this.constantBuffer=e,this.offset=t,this.Apply(e,t,r),!0)}},{key:"Unbind",value:function(){this.constantBuffer=null}},{key:"Apply",value:function(e,t,r){e.set(this.value,t)}},{key:"EqualsValue",value:function(e){for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:{},t=this.constructor.Item;if(t&&"create"in t){var r=t.create(e);return this.AddItem(r),r}return null}},{key:"AddItem",value:function(e){this.items.includes(e)||(e._onModified=this._onChildModified,this.items.push(e),this.OnValueChanged())}},{key:"RemoveItem",value:function(e){var t=this.items.indexOf(e);-1!==t&&(e._onModified=null,this.items.splice(t,1),this.OnValueChanged())}},{key:"ClearItems",value:function(){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:null;if(null!==e)for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e){this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this),this._rebuildPending=!1}},{key:"GetBatches",value:function(e,t,r){}},{key:"Render",value:function(){}}],[{key:"RebuildItems",value:function(e){e._visibleItems=[];for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e,t){this.useSRT&&(i.quat.normalize(this.rotation,this.rotation),i.mat4.fromRotationTranslationScale(this.localTransform,this.rotation,this.translation,this.scaling)),i.mat4.copy(this.worldTransformLast,this.worldTransform),i.mat4.multiply(this.worldTransform,t,this.localTransform)}},{key:"GetBatches",value:function(e,t){}}]),e}()).global={mat4_0:i.mat4.create(),vec3_0:i.vec3.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveObject=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e){}},{key:"GetBatches",value:function(e,t){}}]),e}()).global={vec3_0:i.vec3.create(),vec3_1:i.vec3.create(),vec3_2:i.vec3.create(),vec3_3:i.vec3.create(),vec3_4:i.vec3.create(),vec3_5:i.vec3.create(),vec3_6:i.vec3.create(),vec3_7:i.vec3.create(),mat4_0:i.mat4.create(),mat4_1:i.mat4.create(),mat4_2:i.mat4.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2ParticleForce=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r.name=e,r.display=!0,r.visible={},r.visible.log=!0,r.visible.info=!0,r.visible.debug=!0,r.visible.warn=!0,r.visible.error=!0,r.maxLogs=100,r._logs=[],r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.Tw2EventEmitter),n(t,[{key:"log",value:function(e,r){if(r.logged)return r;if(r.log=t.Type[r.log?r.log.toUpperCase():"LOG"]||"log",!r.hide&&this.display&&this.visible[r.log]){var n=this.name+": {"+e+"}",i=r.msg||"";r.path&&(i+=" '"+r.path+"'","time"in r&&(i+=" in "+r.time.toFixed(3)+" secs")),(void 0!==r.value||r.type)&&(i+=" (",r.type&&(i+=r.type),r.type&&void 0!==r.value&&(i+=":"),void 0!==r.value&&(i+=r.value),i+=")"),"data"in r||"err"in r?(console.group(n),console[r.log](i),r.data&&console.debug(r.data),r.err&&console.debug(r.err.stack||r.err.toString()),console.groupEnd()):console[r.log](n,i)}return this.maxLogs?(this._logs.length>=this.maxLogs&&this._logs.splice(this.maxLogs,this._logs.length-1),this._logs.unshift(r)):this._logs=[],this.emit("log",r),r.logged=!0,r}},{key:"GetLogs",value:function(e){return Object.assign([],void 0===e?this._logs:this._logs.splice(0,e))}},{key:"Set",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,a.assignIfExists)(this,e,["name","maxLogs","display"]),(0,a.assignIfExists)(this.visible,e.visible,["log","info","debug","warn","error"])}}]),t}();o.Type={THROW:"error",ERROR:"error",WARNING:"warn",WARN:"warn",INFO:"info",LOG:"log",DEBUG:"debug"};var s=t.logger=new o("CCPWGL");i.Tw2EventEmitter.logger=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(29);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(67);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(33);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(34);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(73);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(74);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(75);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(76);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(77);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.store=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};"uuid"in e&&(0,i.enableUUID)(e.uuid),this.RegisterPaths(e.paths),this.RegisterDynamicPaths(e.dynamicPaths),this.RegisterTypes(e.types),this.RegisterConstructors(e.constructors),this.RegisterExtensions(e.extensions),this.RegisterVariables(e.variables),this.RegisterSchemas(e.schemas)}}],[{key:"GetStoreItem",value:function(e,t,r){var n=e["_"+t];if(n&&(0,i.isString)(r)){if(r in n)return n[r];e._missing[t]||(e._missing[t]=[]),e._missing[t].includes(r)||(e._missing[t].push(r),a.logger.log("store.warning",{log:"warning",msg:"Missing "+t+": '"+r+"'"}))}return null}},{key:"SetStoreItem",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=arguments[3],o=arguments[4];if(o&&!o(n))return a.logger.log("store.error",{log:"error",msg:"Invalid value "+t+": '"+r+"'"}),!1;var s=e["_"+t];if(s&&(0,i.isString)(r)&&!(0,i.isUndefined)(n)){var u=s[r];return s[r]=n,u?a.logger.log("store.registered",{log:"debug",msg:"Re-registered "+t+": '"+r+"'",data:{old_value:u,new_value:n}}):a.logger.log("store.registered",{log:"debug",msg:"Registered "+t+": '"+r+"'",hide:!0}),!0}return!1}},{key:"RegisterFromObject",value:function(e,t,r){if(r&&t in e){r=(0,i.toArray)(r);for(var n=0;nr.size?t.subarray(0,r.size):t,r.offset)}},{key:"Get",value:function(e){return this.elements[e].array}},{key:"GetData",value:function(e){return this.data.subarray(this.elements[e].offset,this.elements[e].offset+this.elements[e].array.length)}},{key:"Create",value:function(){for(var e in this.data=new Float32Array(this.nextOffset),this.elements)if(this.elements.hasOwnProperty(e)){var t=this.elements[e];if(t.array=this.data.subarray(t.offset,t.offset+t.size),null!==t.value){if(1===t.size)t.array[0]=t.value;else for(var r=0;r2&&void 0!==arguments[2]?arguments[2]:null;this.elements[e]={offset:this.nextOffset,size:t,array:null,value:r},this.nextOffset+=t}},{key:"DeclareFromObject",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in e)if(e.hasOwnProperty(t)){var r=e[t];if(a.util.isNumber(r))this.Declare(t,1,r);else{if(!a.util.isArrayLike(r))throw new Error("Invalid declaration type: "+(void 0===r?"undefined":n(r)));1===r.length&&this.Declare(t,r.length,r)}}this.Create()}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(120);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(122);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(38);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(8);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(52);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(123);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(40);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(39);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2ParticleEmitter=void 0;var n=function(){function e(e,t){for(var r=0;r1?0:i<-1?Math.PI:Math.acos(i)},t.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},t.equals=function(e,t){let r=e[0],i=e[1],a=e[2],o=t[0],s=t[1],u=t[2];return Math.abs(r-o)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-s)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(a-u)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(u))};var n=r(3);function i(){let e=new n.ARRAY_TYPE(3);return e[0]=0,e[1]=0,e[2]=0,e}function a(e){let t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function o(e,t,r){let i=new n.ARRAY_TYPE(3);return i[0]=e,i[1]=t,i[2]=r,i}function s(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function u(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function l(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function c(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(r*r+n*n+i*i)}function f(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return r*r+n*n+i*i}function h(e){let t=e[0],r=e[1],n=e[2];return t*t+r*r+n*n}function p(e,t){let r=t[0],n=t[1],i=t[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a),e}function d(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}const v=s;t.sub=v;const m=u;t.mul=m;const y=l;t.div=y;const b=c;t.dist=b;const g=f;t.sqrDist=g;const _=a;t.len=_;const E=h;t.sqrLen=E;const T=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=3),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s0&&(o=1/Math.sqrt(o),e[0]=r*o,e[1]=n*o,e[2]=i*o,e[3]=a*o),e}const d=a;t.sub=d;const v=o;t.mul=v;const m=s;t.div=m;const y=l;t.dist=y;const b=c;t.sqrDist=b;const g=f;t.len=g;const _=h;t.sqrLen=_;const E=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=4),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s1?r-1:0),i=1;i2?n-2:0),a=2;a1?r-1:0),i=1;i1&&(this.activeFrame+=1,this._purgeTime-=Math.floor(this._purgeTime),this._purgeFrame+=1,this._purgeFrame>=5&&this.autoPurgeResources&&this.motherLode.PurgeInactive(this._purgeFrame,this._purgeFrameLimit,this.purgeTime,i.logger)),!0}},{key:"GetResource",value:function(t){var r=void 0;if(t=e.NormalizePath(t),r=this.motherLode.Find(t))return r.IsPurged()&&r.Reload(),r;var n=e.GetPathExt(t);if(null===n)return i.logger.log("res.error",{log:"error",src:["Tw2ResMan","ReloadResource"],msg:"Undefined extension",type:"extension.undefined",path:t}),null;var o=a.store.GetExtension(n);return o?((r=new o).path=t,e.LoadResource(this,r)):(i.logger.log("res.error",{log:"error",src:["Tw2ResMan","ReloadResource"],msg:"Unregistered extension",type:"extension.unregistered",path:t,value:n}),null)}},{key:"GetObject",value:function(t,r){var n={};t=e.NormalizePath(t);var i=this.motherLode.Find(t);i?i.AddObject(n,r):((i=new s.Tw2LoadingObject).path=t,i.AddObject(n,r),e.LoadResource(this,i))}},{key:"ReloadResource",value:function(t){var r=t.path,n=this.motherLode.Find(r);return n&&!n.IsPurged()?n:(i.logger.log("res.event",{msg:"Reloading ",path:r,type:"reload"}),e.LoadResource(this,t))}}],[{key:"BuildUrl",value:function(e){var t=e.indexOf(":/");if(-1===t)return i.logger.log("res.error",{log:"warn",src:["Tw2ResMan","BuildUrl"],msg:"Invalid path",type:"prefix.undefined",path:e}),e;var r=e.substr(0,t),n=a.store.GetPath(r);return n?n+e.substr(t+2):(i.logger.log("res.error",{log:"warn",src:["Tw2ResMan","BuildUrl"],msg:"Unregistered path",path:e,type:"prefix.unregistered",value:r}),e)}},{key:"NormalizePath",value:function(e){return"str:/"===e.substr(0,5)?e:((e=e.toLowerCase()).replace("\\","/"),e)}},{key:"GetPathExt",value:function(e){if("str:/"===e.substr(0,5)){var t=e.indexOf("/",5);return-1===t?null:e.substr(5,t-5)}var r=e.lastIndexOf(".");return-1===r?null:e.substr(r+1)}},{key:"LogPathString",value:function(e){return"str:/"===e.substr(0,5)&&e.length>64?e.substr(0,64)+"...":e}},{key:"LoadResource",value:function(t,r){var n=r.path,a=e.BuildUrl(n);if(r._isPurged=!1,t.motherLode.Add(n,r),r.DoCustomLoad&&r.DoCustomLoad(a))return r;var o=e.CreateHttpRequest(r.requestResponseType);if(o){i.logger.log("res.event",{msg:"Requesting",path:n,type:"request"}),o.onreadystatechange=e.DoLoadResource(t,r),o.open("GET",a),r.LoadStarted();try{o.send(),t._pendingLoads++}catch(e){i.logger.log("res.error",{log:"error",src:["Tw2ResMan","LoadResource"],msg:"Error sending object HTTP request",path:n,type:"http.request",err:e})}}return r}},{key:"DoLoadResource",value:function(e,t){return function(){var r=0;try{r=this.readyState}catch(n){return i.logger.log("res.error",{log:"error",src:["Tw2ResMan","_DoLoadResource"],msg:"Communication error loading",path:t.path,type:"http.readystate",value:r}),t.LoadFinished(!1),void e._pendingLoads--}if(4===r){if(200===this.status){var n=null,a=null;try{n=this.responseText,a=this.responseXML}catch(e){n=this.response}t.LoadFinished(!0),e._prepareQueue.push([t,n,a])}else i.logger.log("res.error",{log:"error",src:["Tw2ResMan","_DoLoadResource"],msg:"Communication error loading",path:t.path,type:"http.status",value:this.status}),t.LoadFinished(!1),t.PrepareFinished(!1);e._pendingLoads--}}}},{key:"CreateHttpRequest",value:function(e){var t=null;if(window.XMLHttpRequest)t=new XMLHttpRequest;else if(window.ActiveXObject)try{t=new window.ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{t=new window.ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}return t?e&&(t.responseType=e):i.logger.log("res.error",{log:"error",src:["Tw2LoadingObject","Prepare"],msg:"Could not create an XMLHTTP instance",type:"http.instance"}),t}}]),e}();t.resMan=new u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2LoadingObject=void 0;var n=function(){function e(e,t){for(var r=0;r127&&(e=e-255-1),e}},{key:"ReadUInt16",value:function(){return this.data[this.cursor++]+(this.data[this.cursor++]<<8)}},{key:"ReadInt16",value:function(){var e=this.data[this.cursor++]+(this.data[this.cursor++]<<8);return e>32767&&(e=e-65535-1),e}},{key:"ReadUInt32",value:function(){return this.data[this.cursor++]+(this.data[this.cursor++]<<8)+(this.data[this.cursor++]<<16)+(this.data[this.cursor++]<<24>>>0)}},{key:"ReadInt32",value:function(){var e=this.data[this.cursor++]+(this.data[this.cursor++]<<8)+(this.data[this.cursor++]<<16)+(this.data[this.cursor++]<<24>>>0);return e>2147483647&&(e=e-4294967295-1),e}},{key:"ReadFloat16",value:function(){var e=this.data[this.cursor++],t=this.data[this.cursor++],r=(t>>2&31)-15,n=(3&t)<<8|e;return 0===n&&-15===r?0:(1-2*(t>>7))*(1+n*Math.pow(2,-10))*Math.pow(2,r)}},{key:"ReadFloat32",value:function(){var e=this.data[this.cursor++],t=this.data[this.cursor++],r=this.data[this.cursor++],n=this.data[this.cursor++],i=(n<<1&255|r>>7)-127,a=(127&r)<<16|t<<8|e;return 0===a&&-127===i?0:(1-2*(n>>7))*(1+a*Math.pow(2,-23))*Math.pow(2,i)}},{key:"ReadString",value:function(){for(var e=this.data[this.cursor++],t="",r=0;r0&&void 0!==arguments[0]?arguments[0]:[];for(var t in this.effectRes&&!e.includes(this.effectRes)&&e.push(this.effectRes),this.parameters)this.parameters.hasOwnProperty(t)&&"GetResources"in this.parameters[t]&&this.parameters[t].GetResources(e);return e}},{key:"RebuildCachedData",value:function(e){this.shader=e.GetShader(this.options),this.BindParameters()}},{key:"UnBindParameters",value:function(){for(var e in this.techniques)if(this.techniques.hasOwnProperty(e))for(var t=this.techniques[e],r=0;r=this.techniques[e].length)){this.shader.ApplyPass(e,t);for(var r=this.techniques[e][t],n=this.shader.techniques[e].passes[t],a=i.device,o=a.IsAlphaTestEnabled()&&n.shadowShaderProgram?n.shadowShaderProgram:n.shaderProgram,s=0;s<2;++s){for(var u=r.stages[s],l=0;l=this.techniques[e].length?null:i.device.IsAlphaTestEnabled()&&this.shader.techniques[e].passes[t].shadowShaderProgram?this.shader.techniques[e].passes[t].shadowShaderProgram.input:this.shader.techniques[e].passes[t].shaderProgram.input}},{key:"Render",value:function(e){for(var t=this.GetPassCount("Main"),r=0;r0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)if(this.parameters.hasOwnProperty(t)&&this.parameters[t]instanceof a.Tw2TextureParameter){var r=this.parameters[t].GetValue();r&&(e[t]=r)}return e}},{key:"SetTextures",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=e[r],i=this.parameters[r];a.Tw2TextureParameter.is(n)&&(i?i.EqualsValue(n)||(i.SetTexturePath(n),t=!0):(this.parameters[r]=new a.Tw2TextureParameter(r,n),t=!0))}return t}},{key:"GetParameters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)!this.parameters.hasOwnProperty(t)||this.parameters[t]instanceof a.Tw2TextureParameter||(e[t]=this.parameters[t].GetValue(!0));return e}},{key:"SetParameters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=e[r],a=this.parameters[r];if(a)a.constructor.is(n)&&!a.EqualsValue(n)&&(this.parameters[r].SetValue(n),t=!0);else{var o=i.store.CreateType(r,n);o&&(this.parameters[r]=o,t=!0)}}return t}},{key:"SetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=this.parameters[r];if(n&&n instanceof a.Tw2TextureParameter){var i=!1,o=e[r];for(var s in o)if(o.hasOwnProperty(s)&&a.Tw2TextureParameter.overrideProperties.includes(s)&&o[s]!==n[s]){i=!0;break}i&&(n.SetOverrides(e[r]),t=!0)}}return t}},{key:"GetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)if(this.parameters.hasOwnProperty(t)){var r=this.parameters[t];r&&r instanceof a.Tw2TextureParameter&&r.useAllOverrides&&(e[t]=this.parameters[t].GetOverrides())}return e}}],[{key:"ToEffectResPath",value:function(e){return(e=e?e.substr(0,e.lastIndexOf(".")).replace("/effect/",i.device.effectDir)+".sm_"+i.device.shaderModel:"").toLowerCase()}},{key:"FromEffectResPath",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"fx";return(e=e.substr(0,e.lastIndexOf(".")).replace(i.device.effectDir,"/effect/")+"."+t).toLowerCase()}},{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new this;if(i.util.assignIfExists(t,e,["name","effectFilePath","display","autoParameter"]),"parameters"in e&&t.SetParameters(e.parameters),"textures"in e&&t.SetTextures(e.textures),"overrides"in e&&t.SetOverrides(e.overrides),""===t.name&&""!==e.effectFilePath){var r=e.effectFilePath;t.name=r.substring(r.lastIndexOf("/")+1,r.length)}return t.Initialize(),t}}]),e}()).ConstantIgnore=["PerFrameVS","PerObjectVS","PerFramePS","PerObjectPS","PerObjectPSInt"]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TextureParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.resourcePath=r,n.useAllOverrides=!1,n.addressUMode=1,n.addressVMode=1,n.addressWMode=1,n.filterMode=2,n.mipFilterMode=2,n.maxAnisotropy=4,n.textureRes=null,n._sampler=null,r&&n.Initialize(),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,o.Tw2Parameter),n(t,[{key:"Initialize",value:function(){this.OnValueChanged()}},{key:"SetTexturePath",value:function(e){this.resourcePath=e,this.OnValueChanged()}},{key:"GetValue",value:function(){return this.isTextureAttached?null:this.resourcePath}},{key:"SetTextureRes",value:function(e){this.textureRes!==e&&(this.resourcePath="",this.textureRes=e),this.textureRes._isAttached=!0}},{key:"OnValueChanged",value:function(e,r){""!==this.resourcePath&&(this.resourcePath=this.resourcePath.toLowerCase(),this.textureRes=""!==this.resourcePath?i.resMan.GetResource(this.resourcePath):null),this.UpdateOverrides(),function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,r,n)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(n):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"OnValueChanged",this).call(this,e,r)}},{key:"Apply",value:function(e,t,r){this.textureRes&&(this.useAllOverrides&&(this._sampler.samplerType=t.samplerType,this._sampler.isVolume=t.isVolume,this._sampler.registerIndex=t.registerIndex,t=this._sampler),i.device.gl.activeTexture(i.device.gl.TEXTURE0+e),this.textureRes.Bind(t,r))}},{key:"SetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i.util.assignIfExists(this,e,t.overrideProperties),this.OnValueChanged()}},{key:"GetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.util.assignIfExists(e,this,t.overrideProperties),e}},{key:"UpdateOverrides",value:function(){if(this.useAllOverrides){this._sampler=this._sampler||new a.Tw2SamplerState;var e=this._sampler;if(1===this.filterMode){switch(this.mipFilterMode){case 0:e.minFilter=i.device.gl.NEAREST;break;case 1:e.minFilter=i.device.gl.NEAREST_MIPMAP_NEAREST;break;default:e.minFilter=i.device.gl.NEAREST_MIPMAP_LINEAR}e.minFilterNoMips=i.device.gl.NEAREST,e.magFilter=i.device.gl.NEAREST}else{switch(this.mipFilterMode){case 0:e.minFilter=i.device.gl.LINEAR;break;case 1:e.minFilter=i.device.gl.LINEAR_MIPMAP_NEAREST;break;default:e.minFilter=i.device.gl.LINEAR_MIPMAP_LINEAR}e.minFilterNoMips=i.device.gl.LINEAR,e.magFilter=i.device.gl.LINEAR}e.addressU=i.device.wrapModes[this.addressUMode],e.addressV=i.device.wrapModes[this.addressVMode],e.addressW=i.device.wrapModes[this.addressWMode],e.anisotropy=this.maxAnisotropy,e.ComputeHash()}else this._sampler&&(this._sampler=null)}},{key:"EqualsValue",value:function(e){return e.toLowerCase()===this.GetValue()}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.resourcePath=e.resourcePath,this.SetOverrides(e.GetOverrides)}},{key:"Clone",value:function(){var e=new t;return e.Copy(this,!0),e}},{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.textureRes&&!e.includes(this.textureRes)&&e.push(this.textureRes),e}},{key:"isTextureAttached",get:function(){return this.textureRes&&this.textureRes._isAttached}}],[{key:"isValue",value:function(e){return i.util.isString(e)}}]),t}();s.prototype.SetValue=s.prototype.SetTexturePath,s.overrideProperties=["useAllOverrides","addressUMode","addressVMode","addressWMode","filterMode","mipFilterMode","maxAnisotropy"]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SamplerState=void 0;var n=function(){function e(e,t){for(var r=0;r4&&void 0!==arguments[4]?arguments[4]:0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.usage=t,this.usageIndex=r,this.type=n,this.elements=i,this.offset=a,this.location=null,this.customSetter=null}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(96);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(97);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(98);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(99);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(100);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(101);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(102);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(42);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PerObjectData=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};e.VSData&&(this.perObjectVSData=new a.Tw2RawData(e.VSData)),e.PSData&&(this.perObjectPSData=new a.Tw2RawData(e.PSData))}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(105);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(106);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(107);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(108);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(109);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(110);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(111);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(112);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(113);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})});var h=r(114);Object.keys(h).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return h[e]}})});var p=r(115);Object.keys(p).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return p[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(41);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(116);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(49);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(50);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(117);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Mesh=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[];return e.includes(this.geometryResource)||e.push(this.geometryResource),i.util.perArrayChild(this.opaqueAreas,"GetResources",e),i.util.perArrayChild(this.transparentAreas,"GetResources",e),i.util.perArrayChild(this.additiveAreas,"GetResources",e),i.util.perArrayChild(this.pickableAreas,"GetResources",e),i.util.perArrayChild(this.decalAreas,"GetResources",e),i.util.perArrayChild(this.depthAreas,"GetResources",e),e}},{key:"GetBatches",value:function(e,t,r){if(!this.IsGood()||!this.display)return!1;var n=this.constructor.GetAreaBatches;switch(e){case i.device.RM_OPAQUE:return void(this.visible.opaqueAreas&&n(this,this.opaqueAreas,e,t,r));case i.device.RM_DECAL:return void(this.visible.decalAreas&&n(this,this.opaqueAreas,e,t,r));case i.device.RM_TRANSPARENT:return void(this.visible.transparentAreas&&n(this,this.transparentAreas,e,t,r));case i.device.RM_ADDITIVE:return void(this.visible.transparentAreas&&n(this,this.additiveAreas,e,t,r));case i.device.RM_PICKABLE:return void(this.visible.pickableAreas&&n(this,this.pickableAreas,e,t,r))}}}],[{key:"GetAreaBatches",value:function(e,t,r,n,i){for(var a=0;a=this.animationRes.duration}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TextureRes=void 0;var n=function(){function e(e,t){for(var r=0;r0?"."+t.mipLevelSkipCount.toString():"";if(t.mipLevelSkipCount>0){var n=e.lastIndexOf(".");n>=0&&(e=e.substr(0,n-2)+r+e.substr(n))}return e}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Bone=void 0;var n=r(0);t.Tw2Bone=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.boneRes=null,this.localTransform=n.mat4.create(),this.worldTransform=n.mat4.create(),this.offsetTransform=n.mat4.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2Model=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.modelRes=null,this.bones=[],this.bonesByName={}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2Track=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.trackRes=null,this.bone=null}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2TrackGroup=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.trackGroupRes=null,this.model=null,this.transformTracks=[]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2RenderTarget=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];if(this.mesh&&this.mesh.GetResources(e),!t)for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];return this.mesh&&this.mesh.GetResources(e),this.animation&&this.animation.GetResources(e),i.util.perArrayChild(this.spriteSets,"GetResources",e),i.util.perArrayChild(this.turretSets,"GetResources",e),i.util.perArrayChild(this.decals,"GetResources",e),i.util.perArrayChild(this.spotlightSets,"GetResources",e),i.util.perArrayChild(this.planeSets,"GetResources",e),i.util.perArrayChild(this.lineSets,"GetResources",e),i.util.perArrayChild(this.overlayEffects,"GetResources",e),i.util.perArrayChild(this.effectChildren,"GetResources",e),t||i.util.perArrayChild(this.children,"GetResources",e),e}},{key:"UpdateViewDependentData",value:function(){for(var e=0;e0?(t[0]=this.shapeEllipsoidCenter[0],t[1]=this.shapeEllipsoidCenter[1],t[2]=this.shapeEllipsoidCenter[2],r[0]=this.shapeEllipsoidRadius[0],r[1]=this.shapeEllipsoidRadius[1],r[2]=this.shapeEllipsoidRadius[2]):this.mesh&&this.mesh.IsGood()&&(i.vec3.subtract(t,this.mesh.geometryResource.maxBounds,this.mesh.geometryResource.minBounds),i.vec3.scale(t,t,.8660254035),i.vec3.add(r,this.mesh.geometryResource.maxBounds,this.mesh.geometryResource.minBounds),i.vec3.scale(r,r,.5));for(var n=0;n0){for(var t=0;t0&&this.mesh.GetBatches(e,t,this._perObjectData),this.lod>1){if(r.spriteSets)for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:null;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.batches=[],this._sortMethod=t}return n(e,[{key:"Commit",value:function(e){this.batches.push(e)}},{key:"Clear",value:function(){this.batches=[]}},{key:"Render",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Main";this._sortMethod&&this.batches.sort(this._sortMethod);for(var r=0;r0?(n=2*Math.sqrt(r+1),e[3]=.25*n,e[0]=(t[6]-t[9])/n,e[1]=(t[8]-t[2])/n,e[2]=(t[1]-t[4])/n):t[0]>t[5]&t[0]>t[10]?(n=2*Math.sqrt(1+t[0]-t[5]-t[10]),e[3]=(t[6]-t[9])/n,e[0]=.25*n,e[1]=(t[1]+t[4])/n,e[2]=(t[8]+t[2])/n):t[5]>t[10]?(n=2*Math.sqrt(1+t[5]-t[0]-t[10]),e[3]=(t[8]-t[2])/n,e[0]=(t[1]+t[4])/n,e[1]=.25*n,e[2]=(t[6]+t[9])/n):(n=2*Math.sqrt(1+t[10]-t[0]-t[5]),e[3]=(t[1]-t[4])/n,e[0]=(t[8]+t[2])/n,e[1]=(t[6]+t[9])/n,e[2]=.25*n);return e},t.fromRotationTranslationScale=function(e,t,r,n){let i=t[0],a=t[1],o=t[2],s=t[3],u=i+i,l=a+a,c=o+o,f=i*u,h=i*l,p=i*c,d=a*l,v=a*c,m=o*c,y=s*u,b=s*l,g=s*c,_=n[0],E=n[1],T=n[2];return e[0]=(1-(d+m))*_,e[1]=(h+g)*_,e[2]=(p-b)*_,e[3]=0,e[4]=(h-g)*E,e[5]=(1-(f+m))*E,e[6]=(v+y)*E,e[7]=0,e[8]=(p+b)*T,e[9]=(v-y)*T,e[10]=(1-(f+d))*T,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e},t.fromRotationTranslationScaleOrigin=function(e,t,r,n,i){let a=t[0],o=t[1],s=t[2],u=t[3],l=a+a,c=o+o,f=s+s,h=a*l,p=a*c,d=a*f,v=o*c,m=o*f,y=s*f,b=u*l,g=u*c,_=u*f,E=n[0],T=n[1],O=n[2],w=i[0],S=i[1],R=i[2];return e[0]=(1-(v+y))*E,e[1]=(p+_)*E,e[2]=(d-g)*E,e[3]=0,e[4]=(p-_)*T,e[5]=(1-(h+y))*T,e[6]=(m+b)*T,e[7]=0,e[8]=(d+g)*O,e[9]=(m-b)*O,e[10]=(1-(h+v))*O,e[11]=0,e[12]=r[0]+w-(e[0]*w+e[4]*S+e[8]*R),e[13]=r[1]+S-(e[1]*w+e[5]*S+e[9]*R),e[14]=r[2]+R-(e[2]*w+e[6]*S+e[10]*R),e[15]=1,e},t.fromQuat=function(e,t){let r=t[0],n=t[1],i=t[2],a=t[3],o=r+r,s=n+n,u=i+i,l=r*o,c=n*o,f=n*s,h=i*o,p=i*s,d=i*u,v=a*o,m=a*s,y=a*u;return e[0]=1-f-d,e[1]=c+y,e[2]=h-m,e[3]=0,e[4]=c-y,e[5]=1-l-d,e[6]=p+v,e[7]=0,e[8]=h+m,e[9]=p-v,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},t.frustum=function(e,t,r,n,i,a,o){let s=1/(r-t),u=1/(i-n),l=1/(a-o);return e[0]=2*a*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*u,e[6]=0,e[7]=0,e[8]=(r+t)*s,e[9]=(i+n)*u,e[10]=(o+a)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*l,e[15]=0,e},t.perspective=function(e,t,r,n,i){let a=1/Math.tan(t/2),o=1/(n-i);return e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(i+n)*o,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*i*n*o,e[15]=0,e},t.perspectiveFromFieldOfView=function(e,t,r,n){let i=Math.tan(t.upDegrees*Math.PI/180),a=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),s=Math.tan(t.rightDegrees*Math.PI/180),u=2/(o+s),l=2/(i+a);return e[0]=u,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-(o-s)*u*.5,e[9]=(i-a)*l*.5,e[10]=n/(r-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*r/(r-n),e[15]=0,e},t.ortho=function(e,t,r,n,i,a,o){let s=1/(t-r),u=1/(n-i),l=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*s,e[13]=(i+n)*u,e[14]=(o+a)*l,e[15]=1,e},t.lookAt=function(e,t,r,i){let a,o,s,u,l,c,f,h,p,d,v=t[0],m=t[1],y=t[2],b=i[0],g=i[1],_=i[2],E=r[0],T=r[1],O=r[2];if(Math.abs(v-E)0&&(p=1/Math.sqrt(p),c*=p,f*=p,h*=p);let d=u*h-l*f,v=l*c-s*h,m=s*f-u*c;return e[0]=d,e[1]=v,e[2]=m,e[3]=0,e[4]=f*m-h*v,e[5]=h*d-c*m,e[6]=c*v-f*d,e[7]=0,e[8]=c,e[9]=f,e[10]=h,e[11]=0,e[12]=i,e[13]=a,e[14]=o,e[15]=1,e},t.str=function(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},t.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2)+Math.pow(e[9],2)+Math.pow(e[10],2)+Math.pow(e[11],2)+Math.pow(e[12],2)+Math.pow(e[13],2)+Math.pow(e[14],2)+Math.pow(e[15],2))},t.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e},t.subtract=a,t.multiplyScalar=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e},t.multiplyScalarAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e[9]=t[9]+r[9]*n,e[10]=t[10]+r[10]*n,e[11]=t[11]+r[11]*n,e[12]=t[12]+r[12]*n,e[13]=t[13]+r[13]*n,e[14]=t[14]+r[14]*n,e[15]=t[15]+r[15]*n,e},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},t.equals=function(e,t){let r=e[0],i=e[1],a=e[2],o=e[3],s=e[4],u=e[5],l=e[6],c=e[7],f=e[8],h=e[9],p=e[10],d=e[11],v=e[12],m=e[13],y=e[14],b=e[15],g=t[0],_=t[1],E=t[2],T=t[3],O=t[4],w=t[5],S=t[6],R=t[7],P=t[8],A=t[9],M=t[10],j=t[11],D=t[12],C=t[13],I=t[14],k=t[15];return Math.abs(r-g)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(g))&&Math.abs(i-_)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(_))&&Math.abs(a-E)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(E))&&Math.abs(o-T)<=n.EPSILON*Math.max(1,Math.abs(o),Math.abs(T))&&Math.abs(s-O)<=n.EPSILON*Math.max(1,Math.abs(s),Math.abs(O))&&Math.abs(u-w)<=n.EPSILON*Math.max(1,Math.abs(u),Math.abs(w))&&Math.abs(l-S)<=n.EPSILON*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(c-R)<=n.EPSILON*Math.max(1,Math.abs(c),Math.abs(R))&&Math.abs(f-P)<=n.EPSILON*Math.max(1,Math.abs(f),Math.abs(P))&&Math.abs(h-A)<=n.EPSILON*Math.max(1,Math.abs(h),Math.abs(A))&&Math.abs(p-M)<=n.EPSILON*Math.max(1,Math.abs(p),Math.abs(M))&&Math.abs(d-j)<=n.EPSILON*Math.max(1,Math.abs(d),Math.abs(j))&&Math.abs(v-D)<=n.EPSILON*Math.max(1,Math.abs(v),Math.abs(D))&&Math.abs(m-C)<=n.EPSILON*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(y-I)<=n.EPSILON*Math.max(1,Math.abs(y),Math.abs(I))&&Math.abs(b-k)<=n.EPSILON*Math.max(1,Math.abs(b),Math.abs(k))};var n=r(3);function i(e,t,r){let n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],l=t[6],c=t[7],f=t[8],h=t[9],p=t[10],d=t[11],v=t[12],m=t[13],y=t[14],b=t[15],g=r[0],_=r[1],E=r[2],T=r[3];return e[0]=g*n+_*s+E*f+T*v,e[1]=g*i+_*u+E*h+T*m,e[2]=g*a+_*l+E*p+T*y,e[3]=g*o+_*c+E*d+T*b,g=r[4],_=r[5],E=r[6],T=r[7],e[4]=g*n+_*s+E*f+T*v,e[5]=g*i+_*u+E*h+T*m,e[6]=g*a+_*l+E*p+T*y,e[7]=g*o+_*c+E*d+T*b,g=r[8],_=r[9],E=r[10],T=r[11],e[8]=g*n+_*s+E*f+T*v,e[9]=g*i+_*u+E*h+T*m,e[10]=g*a+_*l+E*p+T*y,e[11]=g*o+_*c+E*d+T*b,g=r[12],_=r[13],E=r[14],T=r[15],e[12]=g*n+_*s+E*f+T*v,e[13]=g*i+_*u+E*h+T*m,e[14]=g*a+_*l+E*p+T*y,e[15]=g*o+_*c+E*d+T*b,e}function a(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}const o=i;t.mul=o;const s=a;t.sub=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=s,t.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},t.setAxisAngle=u,t.getAxisAngle=function(e,t){let r=2*Math.acos(t[3]),n=Math.sin(r/2);0!=n?(e[0]=t[0]/n,e[1]=t[1]/n,e[2]=t[2]/n):(e[0]=1,e[1]=0,e[2]=0);return r},t.multiply=l,t.rotateX=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u+o*s,e[1]=i*u+a*s,e[2]=a*u-i*s,e[3]=o*u-n*s,e},t.rotateY=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u-a*s,e[1]=i*u+o*s,e[2]=a*u+n*s,e[3]=o*u-i*s,e},t.rotateZ=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u+i*s,e[1]=i*u-n*s,e[2]=a*u+o*s,e[3]=o*u-a*s,e},t.calculateW=function(e,t){let r=t[0],n=t[1],i=t[2];return e[0]=r,e[1]=n,e[2]=i,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),e},t.slerp=c,t.invert=function(e,t){let r=t[0],n=t[1],i=t[2],a=t[3],o=r*r+n*n+i*i+a*a,s=o?1/o:0;return e[0]=-r*s,e[1]=-n*s,e[2]=-i*s,e[3]=a*s,e},t.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},t.fromMat3=f,t.fromEuler=function(e,t,r,n){let i=.5*Math.PI/180;t*=i,r*=i,n*=i;let a=Math.sin(t),o=Math.cos(t),s=Math.sin(r),u=Math.cos(r),l=Math.sin(n),c=Math.cos(n);return e[0]=a*u*c-o*s*l,e[1]=o*s*c+a*u*l,e[2]=o*u*l-a*s*c,e[3]=o*u*c+a*s*l,e},t.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"};var n=r(3),i=r(30),a=r(31),o=r(32);function s(){let e=new n.ARRAY_TYPE(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function u(e,t,r){r*=.5;let n=Math.sin(r);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r),e}function l(e,t,r){let n=t[0],i=t[1],a=t[2],o=t[3],s=r[0],u=r[1],l=r[2],c=r[3];return e[0]=n*c+o*s+i*l-a*u,e[1]=i*c+o*u+a*s-n*l,e[2]=a*c+o*l+n*u-i*s,e[3]=o*c-n*s-i*u-a*l,e}function c(e,t,r,n){let i,a,o,s,u,l=t[0],c=t[1],f=t[2],h=t[3],p=r[0],d=r[1],v=r[2],m=r[3];return(a=l*p+c*d+f*v+h*m)<0&&(a=-a,p=-p,d=-d,v=-v,m=-m),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,u=Math.sin(n*i)/o):(s=1-n,u=n),e[0]=s*l+u*p,e[1]=s*c+u*d,e[2]=s*f+u*v,e[3]=s*h+u*m,e}function f(e,t){let r,n=t[0]+t[4]+t[8];if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{let n=0;t[4]>t[0]&&(n=1),t[8]>t[3*n+n]&&(n=2);let i=(n+1)%3,a=(n+2)%3;r=Math.sqrt(t[3*n+n]-t[3*i+i]-t[3*a+a]+1),e[n]=.5*r,r=.5/r,e[3]=(t[3*i+a]-t[3*a+i])*r,e[i]=(t[3*i+n]+t[3*n+i])*r,e[a]=(t[3*a+n]+t[3*n+a])*r}return e}const h=o.clone;t.clone=h;const p=o.fromValues;t.fromValues=p;const d=o.copy;t.copy=d;const v=o.set;t.set=v;const m=o.add;t.add=m;const y=l;t.mul=y;const b=o.scale;t.scale=b;const g=o.dot;t.dot=g;const _=o.lerp;t.lerp=_;const E=o.length;t.length=E;const T=E;t.len=T;const O=o.squaredLength;t.squaredLength=O;const w=O;t.sqrLen=w;const S=o.normalize;t.normalize=S;const R=o.exactEquals;t.exactEquals=R;const P=o.equals;t.equals=P;const A=function(){let e=a.create(),t=a.fromValues(1,0,0),r=a.fromValues(0,1,0);return function(n,i,o){let s=a.dot(i,o);return s<-.999999?(a.cross(e,t,i),a.len(e)<1e-6&&a.cross(e,r,i),a.normalize(e,e),u(n,e,Math.PI),n):s>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(a.cross(e,i,o),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+s,S(n,n))}}();t.rotationTo=A;const M=function(){let e=s(),t=s();return function(r,n,i,a,o,s){return c(e,n,o,s),c(t,i,a,s),c(r,e,t,2*s*(1-s)),r}}();t.sqlerp=M;const j=function(){let e=i.create();return function(t,r,n,i){return e[0]=n[0],e[3]=n[1],e[6]=n[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-r[0],e[5]=-r[1],e[8]=-r[2],S(t,f(t,e))}}();t.setAxes=j},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=i,t.clone=function(e){let t=new n.ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t},t.fromValues=function(e,t){let r=new n.ARRAY_TYPE(2);return r[0]=e,r[1]=t,r},t.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},t.set=function(e,t,r){return e[0]=t,e[1]=r,e},t.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e},t.subtract=a,t.multiply=o,t.divide=s,t.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},t.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},t.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e},t.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e},t.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},t.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e},t.scaleAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e},t.distance=u,t.squaredDistance=l,t.length=c,t.squaredLength=f,t.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},t.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},t.normalize=function(e,t){var r=t[0],n=t[1],i=r*r+n*n;i>0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i);return e},t.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},t.cross=function(e,t,r){var n=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=n,e},t.lerp=function(e,t,r,n){var i=t[0],a=t[1];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e},t.random=function(e,t){t=t||1;var r=2*n.RANDOM()*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e},t.transformMat2=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e},t.transformMat2d=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i+r[4],e[1]=r[1]*n+r[3]*i+r[5],e},t.transformMat3=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[3]*i+r[6],e[1]=r[1]*n+r[4]*i+r[7],e},t.transformMat4=function(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[4]*i+r[12],e[1]=r[1]*n+r[5]*i+r[13],e},t.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]},t.equals=function(e,t){let r=e[0],i=e[1],a=t[0],o=t[1];return Math.abs(r-a)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-o)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))};var n=r(3);function i(){let e=new n.ARRAY_TYPE(2);return e[0]=0,e[1]=0,e}function a(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function o(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function s(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function u(e,t){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function l(e,t){var r=t[0]-e[0],n=t[1]-e[1];return r*r+n*n}function c(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function f(e){var t=e[0],r=e[1];return t*t+r*r}const h=c;t.len=h;const p=a;t.sub=p;const d=o;t.mul=d;const v=s;t.div=v;const m=u;t.dist=m;const y=l;t.sqrDist=y;const b=f;t.sqrLen=b;const g=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=2),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s1.0001||r<.99999)e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=0;else if(r=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])){var i=Math.atan2(r,t[3])/r;e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=0}else e[0]=0,e[1]=0,e[2]=0,e[3]=0;return e},n.quat.pow=function(e,t,r){return 1===r?n.quat.copy(e,t):(n.quat.ln(e,t),e[0]*=r,e[1]*=r,e[2]*=r,e[3]*=r,n.quat.exp(e,e),e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mat3=void 0;var n=r(7);t.mat3=n.mat3},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mat4=void 0;var n=r(7);t.mat4=n.mat4,n.mat4.arcFromForward=function(){var e=void 0;return function(t,r){e||(e=n.vec3.create());var i=n.vec3.normalize(e,r);if(n.mat4.identity(t),i[2]<-.99999)return t;if(i[2]>.99999)return t[5]=-1,t[10]=-1,t;var a=(1+i[2])/(i[0]*i[0]+i[1]*i[1]);return t[0]=a*i[1]*i[1]-i[2],t[1]=-a*i[0]*i[1],t[2]=i[0],t[4]=t[1],t[5]=a*i[0]*i[0]-i[2],t[6]=i[1],t[8]=-i[0],t[9]=-i[1],t[10]=-i[2],t}}(),n.mat4.copyTranslation=function(e,t){return e[12]=t[12],e[13]=t[13],e[14]=t[14],e},n.mat4.fromMat3=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[4]=t[3],e[5]=t[4],e[6]=t[5],e[8]=t[6],e[9]=t[7],e[10]=t[8],e[3]=e[7]=e[11]=e[12]=e[13]=e[14]=0,e[15]=1,e},n.mat4.lookAtGL=function(){var e=void 0,t=void 0,r=void 0;return function(i,a,o,s){return e||(e=n.vec3.create(),t=n.vec3.create(),r=n.vec3.create()),n.vec3.subtract(r,a,o),0===n.vec3.squaredLength(r)&&(r[2]=1),n.vec3.normalize(r,r),n.vec3.cross(e,s,r),0===n.vec3.squaredLength(e)&&(r[2]+=1e-4,n.vec3.cross(e,s,r)),n.vec3.normalize(e,e),n.vec3.cross(t,r,e),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[4]=t[0],i[5]=t[1],i[6]=t[2],i[8]=r[0],i[9]=r[1],i[10]=r[2],i}}(),n.mat4.perspectiveGL=function(e,t,r,i,a){var o=Math.tan(t/360*Math.PI)*i,s=o*r;return n.mat4.frustum(e,-s,s,-o,o,i,a),e},n.mat4.setTranslation=function(e,t){return e[12]=t[0],e[13]=t[1],e[14]=t[2],e},n.mat4.setTranslationFromValues=function(e,t,r,n){return e[12]=t,e[13]=r,e[14]=n,e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.noise=void 0;var n=r(33),i=r(34),a=t.noise={};a.turbulence=function(){var e=[],t=[],r=[],a=!1;return function(o,s,u,l,c,f){a||function(){for(var o=0;o<256;o++)e[o]=i.vec4.fromValues(Math.random()-.5,Math.random()-.5,Math.random()-.5,Math.random()-.5),t[o]=o;for(var s=256;--s;){var u=t[s],l=Math.floor(256*Math.random());t[s]=t[l],t[l]=u}for(var c=0;c<256;c++)t[256+c]=t[c],e[256+c]=e[c],e[512+c]=e[c];for(var f=0;f<15;++f)r[f]=n.vec3.create();a=!0}(),s+=4096,u+=4096,l+=4096,c+=4096;var h=Math.floor(s),p=Math.floor(u),d=Math.floor(l),v=Math.floor(c),m=s-h,y=u-p,b=l-d,g=c-v,_=(h&=255)+1,E=(p&=255)+1,T=(d&=255)+1,O=(v&=255)+1,w=t[h],S=t[_],R=t[w+p],P=t[S+p],A=t[w+E],M=t[S+E],j=n.vec3.lerp(r[0],e[R+d+v],e[P+d+v],m),D=n.vec3.lerp(r[1],e[A+d+v],e[M+d+v],m),C=n.vec3.lerp(r[2],e[R+T+v],e[P+T+v],m),I=n.vec3.lerp(r[3],e[R+T+v],e[P+T+v],m),k=n.vec3.lerp(r[4],j,D,y),x=n.vec3.lerp(r[5],C,I,y),L=n.vec3.lerp(r[6],k,x,b);j=n.vec3.lerp(r[7],e[R+d+O],e[P+d+O],m),D=n.vec3.lerp(r[8],e[A+d+O],e[M+d+O],m),C=n.vec3.lerp(r[9],e[R+T+O],e[P+T+O],m),I=n.vec3.lerp(r[10],e[R+T+O],e[P+T+O],m),k=n.vec3.lerp(r[11],j,D,y),x=n.vec3.lerp(r[12],C,I,y);var B=n.vec3.lerp(r[13],k,x,b),F=n.vec3.lerp(r[14],L,B,g);return o[0]+=F[0]*f,o[1]+=F[1]*f,o[2]+=F[2]*f,o}}(),a.perlin1=function(){var e=!1,t=256,r=null,n=null;return function(i){e||function(){r=new Array(t+t+2),n=new Array(t+t+2);var i=0,a=0,o=0;for(i=0;it){o=u;break}if(0===e.degree)for(var l=0;l0&&(s=(t-e.knots[e.knots.length-1])/f);for(var h=0;h_&&(_+=i,E+=i,t+=i),g>_&&(_+=i,E+=i,t+=i),E<_&&(E+=i);var T=t-g,O=T/(_-g),w=(t-b)/(_-b),S=w+O-O*w,R=O*(T/(E-g)),P=S-R;S=1-S;for(var A=0;A=0;)n=r*n+e[t];return n},n.ag_zeroin2=function(e,t,r,i,a,o){var s=void 0,u=void 0,l=void 0,c=void 0,f=void 0,h=void 0,p=void 0,d=void 0,v=void 0,m=void 0;for(var y=!0;y&&(s=e,c=r,l=u=t-e),Math.abs(c)f&&0!==i;)Math.abs(l)0?d=-d:p=-p,m=l,l=u,2*p<3*h*d-Math.abs(f*d)&&pf?t+=u:h>0?t+=f:t-=f,(i=n.ag_horner1(o.p,o.deg,t))*(c/Math.abs(c))>0&&(y=!0);return t},n.ag_zeroin=function(e,t,r,i){var a,o;return a=n.ag_horner1(i.p,i.deg,e),Math.abs(a)<1.192092896e-7?e:(o=n.ag_horner1(i.p,i.deg,t),Math.abs(o)<1.192092896e-7?t:n.ag_zeroin2(e,t,a,o,r,i))},n.polyZeroes=function(e,t,r,i,a,o,s){var u,l,c=void 0,f=void 0,h=void 0,p=void 0,d=void 0,v=void 0,m=void 0,y=void 0,b=void 0,g=void 0,_=void 0,E=void 0,T=new Array(22),O=void 0,w=new Array(22),S=new Array(22),R={p:[],deg:0};for(m=g=0,y=0,c=0;cs[0]-u:a>s[0]+u,(p=f&&h?1:0)&&(i&&s[0]a&&(s[0]=a)),p;for(R.p=E,R.deg=t,c=1;c<=t;c++)O[c-1]=c*E[c];if(0===(d=n.polyZeroes(O,t-1,r,0,a,0,l)).length)return 0;for(c=v=0;c<=d;c++){if(p>t)return p;0===c?(b=r,_=n.ag_horner1(E,t,b),Math.abs(_)<=u&&i&&(s[p++]=r)):(b=m,_=g),c===d?(m=a,v=0):m=l[c],g=n.ag_horner1(E,t,m),v?v=0:Math.abs(g)0||_>0&&g<0)&&(s[p++]=n.ag_zeroin(b,m,0,R),p>1&&s[p-2]>=s[p-1]-u&&(s[p-2]=.5*(s[p-2]+s[p-1]),p--))}return p}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(79);Object.defineProperty(t,"device",{enumerable:!0,get:function(){return n.device}});var i=r(37);Object.defineProperty(t,"resMan",{enumerable:!0,get:function(){return i.resMan}});var a=r(19);Object.defineProperty(t,"store",{enumerable:!0,get:function(){return a.store}});var o=r(17);Object.defineProperty(t,"logger",{enumerable:!0,get:function(){return o.logger}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.device=t.Tw2Device=void 0;var n=function(){function e(e,t){for(var r=0;r1,this.canvas=t,this.Resize();return this._quadBuffer=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,this._quadBuffer),n.bufferData(n.ARRAY_BUFFER,new Float32Array([1,1,0,1,1,1,-1,1,0,1,0,1,1,-1,0,1,1,0,-1,-1,0,1,0,0]),n.STATIC_DRAW),this._cameraQuadBuffer=n.createBuffer(),this._quadDecl=new l.Tw2VertexDeclaration,this._quadDecl.elements.push(new l.Tw2VertexElement(l.Tw2VertexDeclaration.Type.POSITION,0,n.FLOAT,4,0)),this._quadDecl.elements.push(new l.Tw2VertexElement(l.Tw2VertexDeclaration.Type.TEXCOORD,0,n.FLOAT,2,16)),this._quadDecl.RebuildHash(),this._alphaTestState={},this._alphaTestState.states={},this._alphaTestState.states[this.RS_ALPHATESTENABLE]=0,this._alphaTestState.states[this.RS_ALPHAREF]=-1,this._alphaTestState.states[this.RS_ALPHAFUNC]=this.CMP_GREATER,this._alphaTestState.states[this.RS_CLIPPING]=0,this._alphaTestState.states[this.RS_CLIPPLANEENABLE]=0,this._alphaTestState.dirty=!1,this._alphaBlendState={},this._alphaBlendState.states={},this._alphaBlendState.states[this.RS_SRCBLEND]=this.BLEND_SRCALPHA,this._alphaBlendState.states[this.RS_DESTBLEND]=this.BLEND_INVSRCALPHA,this._alphaBlendState.states[this.RS_BLENDOP]=this.BLENDOP_ADD,this._alphaBlendState.states[this.RS_SEPARATEALPHABLENDENABLE]=0,this._alphaBlendState.states[this.RS_BLENDOPALPHA]=this.BLENDOP_ADD,this._alphaBlendState.states[this.RS_SRCBLENDALPHA]=this.BLEND_SRCALPHA,this._alphaBlendState.states[this.RS_DESTBLENDALPHA]=this.BLEND_INVSRCALPHA,this._alphaBlendState.dirty=!1,this._depthOffsetState={},this._depthOffsetState.states={},this._depthOffsetState.states[this.RS_SLOPESCALEDEPTHBIAS]=0,this._depthOffsetState.states[this.RS_DEPTHBIAS]=0,this._depthOffsetState.dirty=!1,this.wrapModes=[],this.wrapModes[0]=0,this.wrapModes[1]=n.REPEAT,this.wrapModes[2]=n.MIRRORED_REPEAT,this.wrapModes[3]=n.CLAMP_TO_EDGE,this.wrapModes[4]=n.CLAMP_TO_EDGE,this.wrapModes[5]=n.CLAMP_TO_EDGE,this._shadowStateBuffer=new Float32Array(24),this._blendTable=[-1,n.ZERO,n.ONE,n.SRC_COLOR,n.ONE_MINUS_SRC_COLOR,n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.DST_ALPHA,n.ONE_MINUS_DST_ALPHA,n.DST_COLOR,n.ONE_MINUS_DST_COLOR,n.SRC_ALPHA_SATURATE,-1,-1,n.CONSTANT_COLOR,n.ONE_MINUS_CONSTANT_COLOR],this.glVersion}},{key:"Schedule",value:function(e){this._scheduled.includes(e)||this._scheduled.push(e)}},{key:"OnResize",value:function(e){this._onResize=e}},{key:"Resize",value:function(){if(this.vrDisplay&&this.vrDisplay.isPresenting){var e=this.vrDisplay.getEyeParameters("left"),t=this.vrDisplay.getEyeParameters("right");this.canvas.width=2*Math.max(e.renderWidth,t.renderWidth),this.canvas.height=Math.max(t.renderHeight,t.renderHeight)}else this.canvas.width=this.canvas.offsetWidth*this.viewportPixelRatio,this.canvas.height=this.canvas.offsetHeight*this.viewportPixelRatio;this.viewportWidth=this.canvas.clientWidth,this.viewportHeight=this.canvas.clientHeight,this.viewportAspect=this.viewportWidth/this.viewportHeight,this._onResize&&this._onResize(this.viewportWidth,this.viewportHeight),a.store.SetVariableValue("ViewportSize",[this.viewportWidth,this.viewportHeight,this.viewportWidth,this.viewportHeight])}},{key:"Tick",value:function(){this.canvas.clientWidth===this.viewportWidth&&this.canvas.clientHeight===this.viewportHeight||this.Resize();var e=null===this.previousTime?0:this.previousTime,t=this.Now();this.currentTime=.001*(t-this.startTime),this.dt=null===this.previousTime?0:.001*(t-this.previousTime),this.previousTime=t,a.store.SetVariableValue("Time",[this.currentTime,this.currentTime-Math.floor(this.currentTime),this.frameCounter,e]),s.resMan.PrepareLoop(this.dt);for(var r=0;r1.6&&(r=t/1.6);var n=2*Math.atan(r/this.projection[5]);return e[0]=this.viewportWidth,e[1]=this.viewportHeight,e[2]=n,e[3]=n*t,e}},{key:"GetEyePosition",value:function(e){return i.vec3.copy(e,this.eyePosition)}},{key:"IsAlphaTestEnabled",value:function(){return this._alphaTestState.states[this.RS_ALPHATESTENABLE]}},{key:"IsFrameBufferComplete",value:function(e){return this.gl.checkFramebufferStatus(e)===this.gl.FRAMEBUFFER_COMPLETE}},{key:"GetExtension",value:function(t){for(var r in e.WebglVendorPrefixes)if(e.WebglVendorPrefixes.hasOwnProperty(r)){var n=this.gl.getExtension(e.WebglVendorPrefixes[r]+t);if(n)return n}return null}},{key:"GetFallbackTexture",value:function(){return this._fallbackTexture||(this._fallbackTexture=this.CreateSolidTexture()),this._fallbackTexture}},{key:"GetFallbackCubeMap",value:function(){return this._fallbackCube||(this._fallbackCube=this.CreateSolidCube()),this._fallbackCube}},{key:"CreateSolidTexture",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],t=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,1,1,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(e)),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.bindTexture(this.gl.TEXTURE_2D,null),t}},{key:"CreateSolidCube",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],t=this.gl.createTexture();this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP,t);for(var r=0;r<6;++r)this.gl.texImage2D(this.gl.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,this.gl.RGBA,1,1,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(e));return this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP,null),t}},{key:"RenderFullScreenQuad",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Main";if(!e||!e.IsGood())return!1;this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._quadBuffer);for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:"Main";if(!e||!e.IsGood())return!1;for(var r=new Float32Array([1,1,0,1,1,1,-1,1,0,1,0,1,1,-1,0,1,1,0,-1,-1,0,1,0,0]),n=this.projectionInverse,a=0;a<4;++a){var o=r.subarray(6*a,6*a+4);i.vec4.transformMat4(o,o,n),i.vec3.scale(o,o,1/o[3]),o[3]=1}this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._cameraQuadBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,r,this.gl.STATIC_DRAW);for(var s=0;s>16,r=(4278190080&e)>>24,n=(r<<1&255|t>>7)-127,i=(127&t)<<16|(65280&e)>>8<<8|255&e;return 0===i&&-127===n?0:(1-2*(r>>7))*(1+i*Math.pow(2,-23))*Math.pow(2,n)}},{key:"CreateContext",value:function(e,t,r){r=Array.isArray(r)?r:[r];for(var n=0;n>8&255]+a[e>>16&255]+a[e>>24&255]+"-"+a[255&t]+a[t>>8&255]+"-"+a[t>>16&15|64]+a[t>>24&255]+"-"+a[63&r|128]+a[r>>8&255]+"-"+a[r>>16&255]+a[r>>24&255]+a[255&n]+a[n>>8&255]+a[n>>16&255]+a[n>>24&255]}():i++};var n=null,i=0,a=null},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getURL=function(){return Object.assign({},n)},t.getURLString=function(e,t){return(e=e.toLowerCase())in n?n[e]:t},t.getURLInteger=function(e,t){return(e=e.toLowerCase())in n?parseInt(n[e],10):t},t.getURLFloat=function(e,t){return(e=e.toLowerCase())in n?parseFloat(n[e]):t},t.getURLBoolean=function(e,t){return(e=e.toLowerCase())in n?n[e]:t};for(var n={},i=window.location.search.substring(1).split("&"),a=0;a1&&void 0!==arguments[1]?arguments[1]:{};if(i.has(this)){var r=i.get(this);e=e.toLowerCase(),t.log&&!t.log.logged&&(t.log=this.log(e,t.log)),e in r?r[e].forEach(function(n,i){i.call(n.context,t),n.once&&r[e].delete(i)}):(r[e]=new Set,this.emit("event_added",{eventName:e}))}return this}},{key:"on",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i.has(this)||i.set(this,{});var o=i.get(this);return o[e=e.toLowerCase()]||(o[e]=new Set,o[e].add(function(){return r.emit("event_added",{eventName:e})},{once:!0})),o[e].add(t,{context:n,once:a}),this}},{key:"once",value:function(e,t,r){return this.on(e,t,r,!0)}},{key:"off",value:function(e,t){if(i.has(this)){var r=i.get(this);(e=e.toLowerCase())in r&&r[e].delete(t)}return this}},{key:"del",value:function(e){if(i.has(this)){var t=i.get(this);(e=e.toLowerCase())in t&&(this.emit("event_removed",{eventName:e}),delete t[e])}return this}},{key:"clr",value:function(e){if(i.has(this)){var t=i.get(this);for(var r in t)t.hasOwnProperty(r)&&t[r].has(e)&&t[r].delete(e)}return this}},{key:"kill",value:function(){return i.has(this)&&(this.emit("event_kill"),i.set(this,{})),this}},{key:"log",value:function(e,t){return this.constructor.logger&&this.constructor.logger.log(e,t),t}}],[{key:"assign",value:function(t){Object.assign(t.prototype,e.prototype)}}]),e}()).logger=null},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Error=void 0;var n=r(16);function i(e){function t(){var t=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(t,Object.getPrototypeOf(this)),t}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}var a=(0,n.isFunction)(Error.captureStackTrace);(t.Tw2Error=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Undefined error";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var i=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return(0,n.isString)(e)?e={message:e}:e.message=e.message||r,i.message=e.message,i.name=i.constructor.name,i.data=e,a?Error.captureStackTrace(i,t):i.stack=new Error(e.message).stack,i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i(Error)),t}()).isError=!0},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r=r&&a.Unload()&&(n.log("res.event",{msg:"Unloaded ",path:a.path,type:"unused"}),delete this._loadedObjects[i]))}}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SamplerOverride=void 0;var n=r(0),i=r(43);t.Tw2SamplerOverride=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="",this.addressU=0,this.addressV=0,this.addressW=0,this.filter=0,this.mipFilter=0,this.lodBias=0,this.maxMipLevel=0,this.maxAnisotropy=0;var t=null;this.GetSampler=function(e){if(!t){if((t=new i.Tw2SamplerState).registerIndex=e.registerIndex,t.name=e.name,1===this.filter){switch(this.mipFilter){case 0:t.minFilter=n.device.gl.NEAREST;break;case 1:t.minFilter=n.device.gl.NEAREST_MIPMAP_NEAREST;break;default:t.minFilter=n.device.gl.NEAREST_MIPMAP_LINEAR}t.minFilterNoMips=n.device.gl.NEAREST}else{switch(this.mipFilter){case 0:t.minFilter=n.device.gl.LINEAR;break;case 1:t.minFilter=n.device.gl.LINEAR_MIPMAP_NEAREST;break;default:t.minFilter=n.device.gl.LINEAR_MIPMAP_LINEAR}t.minFilterNoMips=n.device.gl.LINEAR}3!==this.filter&&3!==this.mipFilter||(t.anisotropy=Math.max(this.maxAnisotropy,1)),t.magFilter=1===this.filter?n.device.gl.NEAREST:n.device.gl.LINEAR,t.addressU=n.device.wrapModes[this.addressU],t.addressV=n.device.wrapModes[this.addressV],t.addressW=n.device.wrapModes[this.addressW],t.samplerType=e.samplerType,t.isVolume=e.isVolume,t.ComputeHash()}return t}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VertexDeclaration=void 0;var n=function(){function e(e,t){for(var r=0;rt)return null}if(n.usage>e)return null}return null}},{key:"SetDeclaration",value:function(t,r){for(var n=0,a=0;a=this._elementsSorted.length){i.device.gl.disableVertexAttribArray(o.location),i.device.gl.vertexAttrib4f(o.location,0,0,0,0);break}var s=this._elementsSorted[n],u=e.CompareDeclarationElements(s,o);if(u>0){i.device.gl.disableVertexAttribArray(o.location),i.device.gl.vertexAttrib4f(o.location,0,0,0,0);break}if(0===u){s.customSetter?s.customSetter(o):(i.device.gl.enableVertexAttribArray(o.location),i.device.gl.vertexAttribPointer(o.location,s.elements,s.type,!1,r,s.offset));break}n++}}return!0}},{key:"SetPartialDeclaration",value:function(t,r){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=[],s=0,u=0;u0){a||(i.device.gl.disableVertexAttribArray(l.location),i.device.gl.vertexAttrib4f(l.location,0,0,0,0));break}if(++s>=this._elementsSorted.length)return a||(i.device.gl.disableVertexAttribArray(l.location),i.device.gl.vertexAttrib4f(l.location,0,0,0,0)),o}}return o}},{key:"ResetInstanceDivisors",value:function(e){if(e)for(var t=0;t2&&void 0!==arguments[2]?arguments[2]:0;return e.usaget.usage?1:e.usageIndex+rt.usageIndex?1:0}}]),e}()).Type={POSITION:0,COLOR:1,NORMAL:2,TANGENT:3,BINORMAL:4,TEXCOORD:5,BLENDWEIGHT:6,BLENDINDICES:7}},function(e,t,r){(function(t){WebGLDebugUtils=function(){var e;void 0===e&&(e=t);var r=function(t){e.console&&e.console.error?e.console.error(t):function(t){e.console&&e.console.log&&e.console.log(t)}(t)},n={enable:{1:{0:!0}},disable:{1:{0:!0}},getParameter:{1:{0:!0}},drawArrays:{3:{0:!0}},drawElements:{4:{0:!0,2:!0}},createShader:{1:{0:!0}},getShaderParameter:{2:{1:!0}},getProgramParameter:{2:{1:!0}},getShaderPrecisionFormat:{2:{0:!0,1:!0}},getVertexAttrib:{2:{1:!0}},vertexAttribPointer:{6:{2:!0}},bindTexture:{2:{0:!0}},activeTexture:{1:{0:!0}},getTexParameter:{2:{0:!0,1:!0}},texParameterf:{3:{0:!0,1:!0}},texParameteri:{3:{0:!0,1:!0,2:!0}},copyTexImage2D:{8:{0:!0,2:!0}},copyTexSubImage2D:{8:{0:!0}},generateMipmap:{1:{0:!0}},bindBuffer:{2:{0:!0}},getBufferParameter:{2:{0:!0,1:!0}},pixelStorei:{2:{0:!0,1:!0}},bindRenderbuffer:{2:{0:!0}},bindFramebuffer:{2:{0:!0}},checkFramebufferStatus:{1:{0:!0}},framebufferRenderbuffer:{4:{0:!0,1:!0,2:!0}},framebufferTexture2D:{5:{0:!0,1:!0,2:!0}},getFramebufferAttachmentParameter:{3:{0:!0,1:!0,2:!0}},getRenderbufferParameter:{2:{0:!0,1:!0}},renderbufferStorage:{4:{0:!0,1:!0}},clear:{1:{0:{enumBitwiseOr:["COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT"]}}},depthFunc:{1:{0:!0}},blendFunc:{2:{0:!0,1:!0}},blendFuncSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},blendEquation:{1:{0:!0}},blendEquationSeparate:{2:{0:!0,1:!0}},stencilFunc:{3:{0:!0}},stencilFuncSeparate:{4:{0:!0,1:!0}},stencilMaskSeparate:{2:{0:!0}},stencilOp:{3:{0:!0,1:!0,2:!0}},stencilOpSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},cullFace:{1:{0:!0}},frontFace:{1:{0:!0}},drawArraysInstancedANGLE:{4:{0:!0}},drawElementsInstancedANGLE:{5:{0:!0,2:!0}},blendEquationEXT:{1:{0:!0}},bufferData:{3:{0:!0,2:!0},4:{0:!0,2:!0},5:{0:!0,2:!0}},bufferSubData:{3:{0:!0},4:{0:!0},5:{0:!0}},copyBufferSubData:{5:{0:!0,1:!0}},getBufferSubData:{3:{0:!0},4:{0:!0},5:{0:!0}},blitFramebuffer:{10:{8:{enumBitwiseOr:["COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT"]},9:!0}},framebufferTextureLayer:{5:{0:!0,1:!0}},invalidateFramebuffer:{2:{0:!0}},invalidateSubFramebuffer:{6:{0:!0}},readBuffer:{1:{0:!0}},getInternalformatParameter:{3:{0:!0,1:!0,2:!0}},renderbufferStorageMultisample:{5:{0:!0,2:!0}},texStorage2D:{5:{0:!0,2:!0}},texStorage3D:{6:{0:!0,2:!0}},texImage2D:{9:{0:!0,2:!0,6:!0,7:!0},6:{0:!0,2:!0,3:!0,4:!0},10:{0:!0,2:!0,6:!0,7:!0}},texImage3D:{10:{0:!0,2:!0,7:!0,8:!0},11:{0:!0,2:!0,7:!0,8:!0}},texSubImage2D:{9:{0:!0,6:!0,7:!0},7:{0:!0,4:!0,5:!0},10:{0:!0,6:!0,7:!0}},texSubImage3D:{11:{0:!0,8:!0,9:!0},12:{0:!0,8:!0,9:!0}},copyTexSubImage3D:{9:{0:!0}},compressedTexImage2D:{7:{0:!0,2:!0},8:{0:!0,2:!0},9:{0:!0,2:!0}},compressedTexImage3D:{8:{0:!0,2:!0},9:{0:!0,2:!0},10:{0:!0,2:!0}},compressedTexSubImage2D:{8:{0:!0,6:!0},9:{0:!0,6:!0},10:{0:!0,6:!0}},compressedTexSubImage3D:{10:{0:!0,8:!0},11:{0:!0,8:!0},12:{0:!0,8:!0}},vertexAttribIPointer:{5:{2:!0}},drawArraysInstanced:{4:{0:!0}},drawElementsInstanced:{5:{0:!0,2:!0}},drawRangeElements:{6:{0:!0,4:!0}},readPixels:{7:{4:!0,5:!0},8:{4:!0,5:!0}},clearBufferfv:{3:{0:!0},4:{0:!0}},clearBufferiv:{3:{0:!0},4:{0:!0}},clearBufferuiv:{3:{0:!0},4:{0:!0}},clearBufferfi:{4:{0:!0}},beginQuery:{2:{0:!0}},endQuery:{1:{0:!0}},getQuery:{2:{0:!0,1:!0}},getQueryParameter:{2:{1:!0}},samplerParameteri:{3:{1:!0,2:!0}},samplerParameterf:{3:{1:!0}},getSamplerParameter:{2:{1:!0}},fenceSync:{2:{0:!0,1:{enumBitwiseOr:[]}}},clientWaitSync:{3:{1:{enumBitwiseOr:["SYNC_FLUSH_COMMANDS_BIT"]}}},waitSync:{3:{1:{enumBitwiseOr:[]}}},getSyncParameter:{2:{1:!0}},bindTransformFeedback:{2:{0:!0}},beginTransformFeedback:{1:{0:!0}},transformFeedbackVaryings:{3:{2:!0}},bindBufferBase:{3:{0:!0}},bindBufferRange:{5:{0:!0}},getIndexedParameter:{2:{0:!0}},getActiveUniforms:{3:{2:!0}},getActiveUniformBlockParameter:{3:{2:!0}}},i=null,a=null;function o(e){if(null==i)for(var t in i={},a={},e)"number"==typeof e[t]&&(i[e[t]]=t,a[t]=e[t])}function s(){if(null==i)throw"WebGLDebugUtils.init(ctx) not called"}function u(e){s();var t=i[e];return void 0!==t?"gl."+t:"/*UNKNOWN WebGL ENUM*/ 0x"+e.toString(16)}function l(e,t,r,i){var o;if(void 0!==(o=n[e])&&(void 0!==(o=o[t])&&o[r])){if("object"==typeof o[r]&&void 0!==o[r].enumBitwiseOr){for(var s=o[r].enumBitwiseOr,l=0,c=[],f=0;f=0&&setTimeout(function(){t.restoreContext()},v)},0)}},t.restoreContext=function(){u&&a.length&&setTimeout(function(){if(!d)throw"can not restore. webglcontestlost listener did not call event.preventDefault";!function(){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:0;this.isPlaying=!0,this.scaledTime=e}},{key:"Stop",value:function(){this.isPlaying=!1}},{key:"Update",value:function(e){if(this.isPlaying){this.scaledTime+=e*this.scale;for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:this;this._copyFunc&&(this._copyFunc.call(this),"OnValueChanged"in this.destinationObject&&this.destinationObject.OnValueChanged(e,[this.destinationAttribute]))}}],[{key:"CopyValueToValue",value:function(){this.destinationObject[this.destinationAttribute]=this.sourceObject[this.sourceAttribute]*this.scale+this.offset[0]}},{key:"CopyArray",value:function(){for(var e=Math.min(this.destinationObject[this.destinationAttribute].length,this.sourceObject[this.sourceAttribute].length),t=0;t0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.value=a.util.isArrayLike(r)?r[0]:r,n.constantBuffer=null,n.offset=null,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.Tw2Parameter),n(t,[{key:"SetValue",value:function(e){this.value=e,this.OnValueChanged()}},{key:"GetValue",value:function(){return this.value}},{key:"Apply",value:function(e,t){e[t]=this.value}},{key:"EqualsValue",value:function(e){return this.value===e}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.SetValue(e.GetValue())}}],[{key:"isValue",value:function(e){return a.util.isNumber(e)}}]),t}()).constantBufferSize=1},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MatrixParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.mat4.create();return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"Compose",value:function(e,t,r){"value"in e&&(e=e.value),"value"in t&&(t=t.value),"value"in r&&(r=r.value),i.mat4.fromRotationTranslationScale(this.value,e,t,r),this.OnValueChanged()}},{key:"Decompose",value:function(e,t,r){i.mat4.getRotation("value"in e?e.value:e,this.value),i.mat4.getTranslation("value"in t?t.value:t,this.value),i.mat4.getScaling("value"in r?r.value:r,this.value),"OnValueChanged"in e&&e.OnValueChanged(),"OnValueChanged"in t&&t.OnValueChanged(),"OnValueChanged"in r&&r.OnValueChanged()}},{key:"x",get:function(){return this.GetIndexValue(12)},set:function(e){this.SetIndexValue(12,e)}},{key:"y",get:function(){return this.GetIndexValue(13)},set:function(e){this.SetIndexValue(13,e)}},{key:"z",get:function(){return this.GetIndexValue(14)},set:function(e){this.SetIndexValue(14,e)}}]),t}()).constantBufferSize=16},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TransformParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.scaling=i.vec3.fromValues(1,1,1),r.rotationCenter=i.vec3.create(),r.rotation=i.quat.create(),r.translation=i.vec3.create(),r.transform=i.mat4.create(),r.worldTransform=i.mat4.create(),r.constantBuffer=null,r.offset=null,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2Parameter),n(t,[{key:"Initialize",value:function(){this.OnValueChanged()}},{key:"GetValue",value:function(e){return e?Array.from(this.transform):new Float32Array(this.transform)}},{key:"OnValueChanged",value:function(e,r){i.mat4.fromRotationTranslationScaleOrigin(this.transform,this.rotation,this.translation,this.scaling,this.rotationCenter),i.mat4.transpose(this.worldTransform,this.transform),function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,r,n)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(n):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"OnValueChanged",this).call(this,e,r)}},{key:"Bind",value:function(e,t,r){return!this.constantBuffer&&r>=this.size&&(this.constantBuffer=e,this.offset=t,this.Apply(e,t,r),!0)}},{key:"Apply",value:function(e,t,r){r>=this.constructor.constantBufferSize?e.set(this.worldTransform,t):e.set(this.worldTransform.subarray(0,r),t)}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),i.quat.copy(this.rotation,e.rotation),i.vec3.copy(this.translation,e.translation),i.vec3.copy(this.scaling,e.scaling),i.vec3.copy(this.rotationCenter,e.rotationCenter),this.OnValueChanged()}}]),t}()).constantBufferSize=16},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VariableParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.variableName=r,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2Parameter),n(t,[{key:"GetValue",value:function(e){return i.store.GetVariableValue(this.variableName,e)}},{key:"Apply",value:function(e,t,r){this.variable&&this.variable.Apply(e,t,r)}},{key:"AddCallback",value:function(){return!1}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.variableName=e.variableName}},{key:"variable",get:function(){return i.store.GetVariable(this.variableName)}},{key:"size",get:function(){return this.variable?this.variable.size:0}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector2Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec2.fromValues(1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}}]),t}()).constantBufferSize=2},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector3Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec3.fromValues(1,1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}},{key:"z",get:function(){return this.GetIndexValue(2)},set:function(e){this.SetIndexValue(2,e)}}]),t}()).constantBufferSize=3},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector4Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec4.fromValues(1,1,1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}},{key:"z",get:function(){return this.GetIndexValue(2)},set:function(e){this.SetIndexValue(2,e)}},{key:"w",get:function(){return this.GetIndexValue(3)},set:function(e){this.SetIndexValue(3,e)}}]),t}()).constantBufferSize=4},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(104);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(46);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(24);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveBasicPerObjectData=t.Tw2BasicPerObjectData=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"DeclareFromObject",this).call(this,e),e.FFEData&&(this.perObjectFFEData=new s.Tw2RawData(e.FFEData))}}]),t}();t.EveBasicPerObjectData=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2BlendShapeData=void 0;var n=r(9);t.Tw2BlendShapeData=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="",this.declaration=new n.Tw2VertexDeclaration,this.buffers=[],this.indexes=null,this.weightProxy=null}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2GeometryAnimation=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="",this.duration=0,this.trackGroups=[]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2GeometryBone=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[];return i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"GetResources",this).call(this,e),this.instanceGeometryResource&&"GetResources"in this.instanceGeometryResource&&this.instanceGeometryResource.GetResources(e),e}},{key:"RenderAreas",value:function(e,t,r,n,i){if(this.IsGood()){var a=this.instanceGeometryResource.GetInstanceBuffer(this.instanceMeshIndex);a&&this.geometryResource.RenderAreasInstanced(e,t,r,n,i,a,this.instanceGeometryResource.GetInstanceDeclaration(this.instanceMeshIndex),this.instanceGeometryResource.GetInstanceStride(this.instanceMeshIndex),this.instanceGeometryResource.GetInstanceCount(this.instanceMeshIndex))}}}],[{key:"GetAreaBatches",value:function(e,t,r,n,i){for(var a=0;a0&&void 0!==arguments[0]?arguments[0]:[],t=0;tf.duration&&(c.callback&&c.callback(this,c),c.cycle?c.time=c.time%f.duration:(c.isPlaying=!1,c.time=f.duration));for(var h=0;h=0){var i=this.models[t].bones[n.boneRes.parentIndex];e.AddLine([n.worldTransform[12],n.worldTransform[13],n.worldTransform[14]],[i.worldTransform[12],i.worldTransform[13],i.worldTransform[14]])}}}}],[{key:"AddModel",value:function(e,t){for(var r=0;r7)return i.logger.log("res.error",{log:"error",src:["Tw2EffectRes","CreateProgram"],msg:"Invalid version of effect file",type:"shader.effectversion",path:this.path,value:o}),void this.PrepareFinished(!1);var s=void 0,u=void 0;if(o<5){if(0===(s=t.ReadUInt32()))return i.logger.log("res.error",{log:"error",src:["Tw2EffectRes","CreateProgram"],msg:"File contains no compiled effects",path:this.path,type:"shader.effectheadersize",value:0}),void this.PrepareFinished(!1);t.ReadUInt32();var l=t.ReadUInt32();t.cursor=8+3*s*4,u=t.ReadUInt32(),this.stringTableOffset=t.cursor,r=String.fromCharCode.apply(null,t.data.subarray(t.cursor,t.cursor+u)),t.cursor=l}else{u=t.ReadUInt32(),this.stringTableOffset=t.cursor,r=String.fromCharCode.apply(null,t.data.subarray(t.cursor,t.cursor+u)),t.cursor+=u;for(var c=t.ReadUInt8(),f=0;f6&&(f=t.ReadUInt8());for(var h=0;h6&&(p.name=l()),this.techniques[p.name]=p;for(var d=t.ReadUInt8(),v=0;v=3&&(t.ReadUInt32(),t.ReadUInt32(),t.ReadUInt32()),_.constantSize=0;for(var D=t.ReadUInt32(),C=0;C_.constantSize&&(_.constantSize=k)}}var x=t.ReadUInt32()/4;if(_.constantValues=new Float32Array(x),r<5)for(var L=0;L=4?l():"";t.ReadUInt8();var W=t.ReadUInt8(),X=t.ReadUInt8(),K=t.ReadUInt8(),Q=t.ReadUInt8(),Z=t.ReadUInt8(),J=t.ReadUInt8();t.ReadFloat32();var $=t.ReadUInt8();t.ReadUInt8();var ee=i.quat.create();ee[0]=t.ReadFloat32(),ee[1]=t.ReadFloat32(),ee[2]=t.ReadFloat32(),ee[3]=t.ReadFloat32(),t.ReadFloat32(),t.ReadFloat32(),r<4&&t.ReadUInt8();var te=new o.Tw2SamplerState;if(te.registerIndex=H,te.name=Y,1===W){switch(K){case 0:te.minFilter=c.gl.NEAREST;break;case 1:te.minFilter=c.gl.NEAREST_MIPMAP_NEAREST;break;default:te.minFilter=c.gl.NEAREST_MIPMAP_LINEAR}te.minFilterNoMips=c.gl.NEAREST}else{switch(K){case 0:te.minFilter=c.gl.LINEAR;break;case 1:te.minFilter=c.gl.LINEAR_MIPMAP_NEAREST;break;default:te.minFilter=c.gl.LINEAR_MIPMAP_LINEAR}te.minFilterNoMips=c.gl.LINEAR}te.magFilter=1===X?c.gl.NEAREST:c.gl.LINEAR,te.addressU=c.wrapModes[Q],te.addressV=c.wrapModes[Z],te.addressW=c.wrapModes[J],3!==W&&3!==X&&3!==K||(te.anisotropy=Math.max($,1));for(var re=0;re<_.textures.length;++re)if(_.textures[re].registerIndex===te.registerIndex){te.samplerType=4===_.textures[re].type?c.gl.TEXTURE_CUBE_MAP:c.gl.TEXTURE_2D,te.isVolume=3===_.textures[re].type;break}te.ComputeHash(),_.samplers.push(te)}r>=3&&t.ReadUInt8(),m.stages[E]=_}m.states=[];for(var ne=t.ReadUInt8(),ie=0;ie=0){var p=new a.Tw2VertexElement(r.stages[0].inputDefinition.elements[f].usage,r.stages[0].inputDefinition.elements[f].usageIndex);p.location=h,s.input.elements.push(p)}}s.input.RebuildHash(),s.shadowStateInt=o.gl.getUniformLocation(s.program,"ssi"),s.shadowStateFloat=o.gl.getUniformLocation(s.program,"ssf"),s.shadowStateYFlip=o.gl.getUniformLocation(s.program,"ssyf"),o.gl.uniform3f(s.shadowStateYFlip,0,0,1),s.volumeSlices=[];for(var d=0;d=this.meshes.length)return!1;var c=i.device,f=this.meshes[e],h=n.GetPassCount(a);c.gl.bindBuffer(c.gl.ELEMENT_ARRAY_BUFFER,f.indexes);for(var p=0;p=this.meshes.length)return!1;var o=i.device,s=this.meshes[e]||this.meshes[0],u=n.GetPassCount(a);o.gl.bindBuffer(o.gl.ARRAY_BUFFER,s.buffer),o.gl.bindBuffer(o.gl.ELEMENT_ARRAY_BUFFER,s.indexes);for(var l=0;l=this.meshes.length)return!1;var o=i.device,s=this.meshes[e],u=n.GetPassCount(a);o.gl.bindBuffer(o.gl.ARRAY_BUFFER,s.buffer),o.gl.bindBuffer(o.gl.ELEMENT_ARRAY_BUFFER,s.indexes);for(var l=0;l=0){var i=this.models[t].skeleton.bones[n.parentIndex];e.AddLine([n.worldTransform[12],n.worldTransform[13],n.worldTransform[14]],[i.worldTransform[12],i.worldTransform[13],i.worldTransform[14]],[0,.7,0,1],[0,.7,0,1])}}}},{key:"Unload",value:function(){for(var e=0;e>5),s.offset=4*n,t.elements[a]=s,n+=s.elements}t.RebuildHash(),t.stride=4*n;var u=e.ReadUInt32();if(0===u)return null;for(var l=new Float32Array(n*u),c=0,f=0;f0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.cycle=e,this._onEnded=t,this.video&&this._playable?(this.video.loop=this.cycle,this.video.play()):this.playOnLoad=!0}},{key:"Pause",value:function(){this.video?this.video.pause():this.playOnLoad=!1}},{key:"Prepare",value:function(e){var t=i.device.gl;switch(e){case"mp4":case"webm":case"ogg":this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this.video),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.bindTexture(t.TEXTURE_2D,null),this.width=this.video.width,this.height=this.video.height,this.video.loop=this.cycle,this.playOnLoad&&this.video.play(),this.PrepareFinished(!0)}}},{key:"DoCustomLoad",value:function(e){var t=this,r=i.resMan.constructor.GetPathExt(e);return this.LoadStarted(),i.resMan._pendingLoads++,this.video=document.createElement("video"),this.video.crossOrigin="anonymous",this.video.muted=!0,this.video.onerror=function(){i.resMan._pendingLoads--,i.logger.log("res.error",{log:"error",src:["Tw2TextureRes","DoCustomLoad"],msg:"Error loading resource",type:"http.error",path:e}),t.LoadFinished(!1),t.PrepareFinished(!1),t.video=null},this.video.oncanplay=function(){t._playable=!0,t.video.oncanplay=null,i.resMan._pendingLoads--,i.resMan._prepareQueue.push([t,r,null]),t.LoadFinished(!0)},this.video.onended=function(){t._isPlaying=!1,t._onEnded&&t._onEnded(t)},this.video.onpause=function(){t._isPlaying=!1,t._onPause&&t._onPause(t)},this.video.onplaying=function(){t._isPlaying=!0,t._onPlaying&&t._onPlaying(t)},this.video.src=e,!0}},{key:"Unload",value:function(){return this.texture&&(i.device.gl.deleteTexture(this.texture),this.texture=null),this._isPlaying=!1,this._playable=!1,this.playOnLoad=!0,this.video=null,!0}},{key:"Bind",value:function(e){var t=i.device;this.KeepAlive();var r=e.samplerType;r===t.gl.TEXTURE_2D&&(this.texture?(this._currentTime=this.video.currentTime,t.gl.bindTexture(t.gl.TEXTURE_2D,this.texture),t.gl.texImage2D(t.gl.TEXTURE_2D,0,t.gl.RGBA,t.gl.RGBA,t.gl.UNSIGNED_BYTE,this.video),t.gl.bindTexture(t.gl.TEXTURE_2D,null),t.gl.bindTexture(r,this.texture),e.hash!==this._currentSampler&&(e.Apply(!1),this._currentSampler=e.hash)):t.gl.bindTexture(t.gl.TEXTURE_2D,t.GetFallbackTexture()))}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(125);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PostProcess=void 0;var n=function(){function e(e,t){for(var r=0;r=a.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.vec4.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.vec4.copy(r,a.value);case t.Extrapolation.GRADIENT:return i.vec4.scaleAndAdd(r,a.value,a.right,e-a.time);default:e%=a.time}else if(e<0||e=o.time||ethis.length){if(!this.cycle)return this.reversed?i.vec4.copy(t,this.startValue):i.vec4.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec4.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a[2]=o[2]+(s[2]-o[2])*(e/l),a[3]=o[3]+(s[3]-o[3])*(e/l),a;default:return a}}}]),t}();c.inputDimension=4,c.outputDimension=4,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2EventCurve=t.Tw2EventKey=void 0;var n=function(){function e(e,t){for(var r=0;r=this.keys[this._currentKey].time;)this.value=this.keys[this._currentKey].value,++this._currentKey}}]),t}();l.dimension=1,l.outputDimension=1,l.valueProperty="value",l.curveType=i.Tw2Curve.Type.CURVE,l.Key=u,l.Extrapolation={NONE:0,CYCLE:3}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PerlinCurve=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?(t[0]=this.startValue[0],t[1]=this.startValue[1],t[2]=this.startValue[2],t):(t[0]=this.endValue[0],t[1]=this.endValue[1],t[2]=this.endValue[2],t);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var i=0;i+1e));++i);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){a[0]=this.startValue[0],a[1]=this.startValue[1],a[2]=this.startValue[2];var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.SPHERICAL_LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),i.quat.slerp(a,o,s,e/l),a;default:return a}}}]),t}();c.inputDimension=4,c.outputDimension=4,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,SPHERICAL_LINEAR:4}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2RandomConstantCurve=void 0;var n=function(){function e(e,t){for(var r=0;r=this.states[this.states.length-1].time)r=this.states.length-1;else for(;r+1=this.states[r].time&&e=s.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.quat.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.quat.copy(r,s.value);default:e%=s.time}else if(e<0||e=u.time||e0;p--){var d=i.num.biCumulative(c,p);d>1&&i.quat.multiply(r,f,h[p]),r[0]=-h[p-1][0],r[1]=-h[p-1][1],r[2]=-h[p-1][2],r[3]=h[p-1][3],i.quat.multiply(r,r,h[p]),i.quat.pow(r,r,d),i.quat.multiply(f,f,r)}return i.quat.multiply(r,f,l.value);case t.Interpolation.SLERP:return i.quat.slerp(r,l.value,u.value,c);default:return i.quat.sqlerp(r,l.value,l.right,u.left,u.value,c)}}}]),t}();c.outputDimention=4,c.inputDimension=4,c.valueProperty="value",c.curveType=a.Tw2Curve.Type.CURVE,c.Child=l,c.Extrapolation={NONE:0,CONSTANT:1,GRADIENT:2,CYCLE:3},c.Interpolation={NONE:0,CONSTANT:1,LINEAR:2,HERMITE:3,SLERP:5,SQUAD:6}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2ScalarCurve=t.Tw2ScalarKey=void 0;var n=function(){function e(e,t){for(var r=0;r=n.time)switch(this.extrapolation){case t.Extrapolation.NONE:return this.value;case t.Extrapolation.CONSTANT:return n.value;case t.Extrapolation.GRADIENT:return n.value+(e-n.time)*n.right;default:e%=n.time}else if(e<0||e=i.time||ethis.length){if(!this.cycle)return this.reversed?this.startValue:this.endValue;e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null);var t=this.keys[0],r=this.keys[this.keys.length-1];if(e<=t.time)return this.Interpolate(e,null,t);if(e>=r.time)return this.Interpolate(e,r,null);for(var n=0;n+1e));++n);return this.Interpolate(e,t,r)}},{key:"Interpolate",value:function(e,r,n){var i=this.startValue,a=this.endValue,o=this.interpolation,s=this.length;switch(null!==r&&(o=r.interpolation,e-=r.time),o){case t.Interpolation.LINEAR:return r&&n?(i=r.value,a=n.value,s=n.time-r.time):n?(a=n.value,s=n.time):r&&(i=r.value,s=this.length-r.time),i+e/s*(a-i);case t.Interpolation.HERMITE:var u=this.startTangent,l=this.endTangent;r&&n?(i=r.value,u=r.rightTangent,a=n.value,l=n.leftTangent,s=n.time-r.time):n?(a=n.value,l=n.leftTangent,s=n.time):r&&(i=r.value,u=r.rightTangent,s=this.length-r.time);var c=e/s,f=c*c,h=f*c,p=-2*h+3*f,d=h-f;return i*(1-p)+a*p+u*(c+d-f)+l*d;default:return this.startValue}}}]),t}();l.inputDimension=1,l.outputDimension=1,l.valueProperty="currentValue",l.curveType=i.Tw2Curve.Type.CURVE2,l.Key=u,l.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SineCurve=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?i.vec2.copy(t,this.startValue):i.vec2.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec2.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a;case t.Interpolation.HERMITE:var c=this.startTangent,f=this.endTangent;r&&n?(o=r.value,c=r.rightTangent,s=n.value,f=n.leftTangent,l=n.time-r.time):n?(s=n.value,f=n.leftTangent,l=n.time):r&&(o=r.value,c=r.rightTangent,l=this.length-r.time);var h=e/l,p=h*h,d=p*h,v=-2*d+3*p,m=1-v,y=d-p,b=h+y-p;return a[0]=o[0]*m+s[0]*v+c[0]*b+f[0]*y,a[1]=o[1]*m+s[1]*v+c[1]*b+f[1]*y,a;default:return a}}}]),t}();c.inputDimension=2,c.outputDimension=2,c.valueProperty="value",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector3Curve=t.Tw2Vector3Key=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?i.vec3.copy(t,this.startValue):i.vec3.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec3.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a[2]=o[2]+(s[2]-o[2])*(e/l),a;case t.Interpolation.HERMITE:var c=this.startTangent,f=this.endTangent;r&&n?(o=r.value,c=r.rightTangent,s=n.value,f=n.leftTangent,l=n.time-r.time):n?(s=n.value,f=n.leftTangent,l=n.time):r&&(o=r.value,c=r.rightTangent,l=this.length-r.time);var h=e/l,p=h*h,d=p*h,v=-2*d+3*p,m=1-v,y=d-p,b=h+y-p;return a[0]=o[0]*m+s[0]*v+c[0]*b+f[0]*y,a[1]=o[1]*m+s[1]*v+c[1]*b+f[1]*y,a[2]=o[2]*m+s[2]*v+c[2]*b+f[2]*y,a;default:return a}}}]),t}();c.inputDimension=3,c.outputDimension=3,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VectorCurve=t.Tw2VectorKey=void 0;var n=function(){function e(e,t){for(var r=0;r=a.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.vec3.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.vec3.copy(r,a.value);case t.Extrapolation.GRADIENT:return i.vec3.scaleAndAdd(r,a.value,a.right,e-a.time);default:e%=a.time}else if(e<0||e=o.time||e=0&&this._UpdateValue(e))}}function a(){this._id=n.util.generateID(),this.translation=n.vec3.create(),this.rotation=n.quat.create(),this.rotation[3]=1,this.scale=n.vec3.create();var e=null,t=null,r=null,i=n.mat4.create();this._TracksReady=function(){return e||t||r},this._ApplyTracks=function(n,i){for(var a=0;athis.duration||e<0||(i.curve.evaluate(this.positionCurve,e,this.translation,this.cycle,this.duration),i.curve.evaluate(this.orientationCurve,e,this.rotation,this.cycle,this.duration),i.quat.normalize(this.rotation,this.rotation),i.curve.evaluate(this.scaleCurve,e,this.scaleShear,this.cycle,this.duration),i.mat4.getScaling(this.scale,this.scaleCurve))))}},{key:"FindTracks",value:function(){for(var e=null,t=0;t=0&&(this.length=this.animationEngine.GetLength(this.xIndex)),this.yIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.yIndex))),this.zIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.zIndex))))}}]),t}();o.outputDimension=3,o.valueProperty="eulerValue",o.curveType=a.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaScalarCurve=void 0;var n=function(){function e(e,t){for(var r=0;r=0&&(this.length=this.animationEngine.GetLength(this.index))}}]),t}();a.outputDimension=1,a.valueProperty="value",a.curveType=i.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaVector3Curve=void 0;var n=function(){function e(e,t){for(var r=0;r=0&&(this.length=this.animationEngine.GetLength(this.xIndex)),this.yIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.yIndex))),this.zIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.zIndex))))}}]),t}();o.outputDimension=3,o.valueProperty="value",o.curveType=a.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaAnimationEngine=void 0;var n=function(){function e(e,t){for(var r=0;ri[e.AnimCurveFields.END_TIME]?i[e.AnimCurveFields.POST_INFINITY]===e.INFINITY?i[e.AnimCurveFields.END_VALUE]:this._EvaluateInfinities(i,o,a,r,!1):this._EvaluateImpl(i,o,a,r)}},{key:"_EvaluateImpl",value:function(t,r,n,i){var a=!1,o=null,s=null,u=void 0;if(this._evalCache[this._currentCurveIndex]>=0)if(s=n+this._evalCache[this._currentCurveIndex],this._evalCache[this._currentCurveIndex]r[s][e.AnimSegment.TIME]){if(i===r[o=n+this._evalCache[this._currentCurveIndex]+1][e.AnimSegment.TIME])return this._evalCache[this._currentCurveIndex]++,r[o][e.AnimSegment.VALUE];i0&&ir[l][e.AnimSegment.TIME])u=this._evalCache[this._currentCurveIndex],a=!0;else if(i===r[l][e.AnimSegment.TIME])return this._evalCache[this._currentCurveIndex]--,r[l][e.AnimSegment.VALUE]}if(!a){var c=this._Find(t,i,r,n);if(u=c[1],c[0]||0===u)return u===t[e.AnimCurveFields.NUM_SEGMENTS]?(u--,this._evalCache[this._currentCurveIndex]=u,t[e.AnimCurveFields.END_VALUE]):(this._evalCache[this._currentCurveIndex]=u,r[n+u][e.AnimSegment.VALUE]);if(u===t[e.AnimCurveFields.NUM_SEGMENTS]+1)return this._evalCache[this._currentCurveIndex]=0,t[e.AnimCurveFields.END_VALUE]}if(this._evalCache[this._currentCurveIndex]!==u-1&&(this._evalCache[this._currentCurveIndex]=u-1,s=n+this._evalCache[this._currentCurveIndex],null===o&&(o=n+u)),t[e.AnimCurveFields.IS_WEIGHTED]){var f=r[s];if(f[e.BezierSegment.IS_STEP])return f[e.BezierSegment.VALUE];if(f[e.BezierSegment.IS_STEP_NEXT])return null===o?t[e.AnimCurveFields.END_VALUE]:r[o][e.BezierSegment.VALUE];var h=t[e.AnimCurveFields.END_TIME];return this._evalCache[this._currentCurveIndex]+10){s=0,u=a-1;do{if(r<(c=(o=s+u>>1)c))return[!0,l=o];s=o+1}}while(s<=u);l=s}return[!1,l]}},{key:"GetNumberOfCurves",value:function(){return this.curves.length}},{key:"GetLength",value:function(t){if(t<0||t>=this.curves.length)return 0;var r=this.curves[t],n=void 0;return n=r[e.AnimCurveFields.IS_WEIGHTED]?this.bezierSegments[r[e.AnimCurveFields.SEGMENT_OFFSET]]:this.hermiteSegments[r[e.AnimCurveFields.SEGMENT_OFFSET]],r[e.AnimCurveFields.END_TIME]-n[e.AnimSegment.TIME]}}]),e}();a.AnimCurveFields={NUM_SEGMENTS:0,SEGMENT_OFFSET:1,END_TIME:2,END_VALUE:3,IN_TANGENT:4,OUT_TANGENT:5,PRE_INFINITY:6,POST_INFINITY:7,IS_WEIGHTED:8},a.AnimSegment={TIME:0,VALUE:1},a.HermiteSegment={TIME:0,VALUE:1,COEFF:2,IS_STEP:3,IS_STEP_NEXT:4},a.BezierSegment={TIME:0,VALUE:1,COEFF:2,POLYY:3,IS_STEP:4,IS_STEP_NEXT:5,IS_LINEAR:6},a.INFINITY=0},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(59);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(165);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(61);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(64);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(183);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(184);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveChildBillboard=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t0&&void 0!==arguments[0]?arguments[0]:[];this.mesh&&this.mesh.GetResources(e);for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return a.util.perArrayChild(this.opaqueEffects,"GetResources",e),a.util.perArrayChild(this.decalEffects,"GetResources",e),a.util.perArrayChild(this.transparentEffects,"GetResources",e),a.util.perArrayChild(this.additiveEffects,"GetResources",e),a.util.perArrayChild(this.distortionEffects,"GetResources",e),e}},{key:"Update",value:function(e){this.update&&this.curveSet&&this.curveSet.Update(e)}},{key:"GetBatches",value:function(e,t,r,n){if(this.display&&n&&n.IsGood())for(var a=this.GetEffects(e),o=0;o0&&void 0!==arguments[0]?arguments[0]:[];return this.source&&this.source.GetResources&&this.source.GetResources(e),this.dest&&this.dest.GetResources&&this.dest.GetResources(e),this.sourceObject&&this.sourceObject.GetResources&&this.sourceObject.GetResources(e),this.destObject&&this.destObject.GetResources&&this.destObject.GetResources(e),this.stretchObject&&this.stretchObject.GetResources&&this.stretchObject.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(){if(this.display){var t=e.global,r=i.vec3.subtract(t.vec3_0,this._destinationPosition,this._sourcePosition),n=i.mat4.identity(t.mat4_0),a=i.vec3.set(t.vec3_1,0,0,0),o=i.vec3.set(t.vec3_2,0,0,0),s=i.mat4.identity(t.mat4_1),u=i.vec3.length(r);i.vec3.normalize(r,r),this._useTransformsForStretch?(i.mat4.rotateX(n,n,-Math.PI/2),i.mat4.multiply(n,this._sourceTransform,n)):(Math.abs(r[1])>.9?o[2]=1:o[1]=1,i.vec3.cross(a,o,r),i.vec3.normalize(a,a),i.vec3.cross(o,r,a),n[0]=a[0],n[1]=a[1],n[2]=a[2],n[4]=-r[0],n[5]=-r[1],n[6]=-r[2],n[8]=o[0],n[9]=o[1],n[10]=o[2]),this.destObject&&this._displayDestObject&&(i.mat4.setTranslation(n,this._destinationPosition),this.destObject.UpdateViewDependentData(n)),this.sourceObject&&this._displaySourceObject&&(this._useTransformsForStretch?(i.mat4.identity(n),i.mat4.rotateX(n,n,-Math.PI/2),i.mat4.multiply(n,this._sourceTransform,n)):i.mat4.setTranslation(n,this._sourcePosition),this.sourceObject.UpdateViewDependentData(n)),this.stretchObject&&(this._useTransformsForStretch?(i.mat4.identity(n),i.mat4.scale(n,n,[1,1,u]),i.mat4.multiply(n,this._sourceTransform,n)):(n[0]=a[0],n[1]=a[1],n[2]=a[2],n[4]=o[0],n[5]=o[1],n[6]=o[2],n[8]=-r[0],n[9]=-r[1],n[10]=-r[2],this._isNegZForward&&(u=-u),i.mat4.scale(s,s,[1,1,u]),i.mat4.multiply(n,n,s)),this.stretchObject.UpdateViewDependentData(n))}}},{key:"Update",value:function(t){for(var r=0;r0&&(this._perMuzzleData[0].constantDelay=this.firingDelay1),this._perMuzzleData.length>1&&(this._perMuzzleData[1].constantDelay=this.firingDelay2),this._perMuzzleData.length>2&&(this._perMuzzleData[2].constantDelay=this.firingDelay3),this._perMuzzleData.length>3&&(this._perMuzzleData[3].constantDelay=this.firingDelay4),this._perMuzzleData.length>4&&(this._perMuzzleData[4].constantDelay=this.firingDelay5),this._perMuzzleData.length>5&&(this._perMuzzleData[5].constantDelay=this.firingDelay6),this._perMuzzleData.length>6&&(this._perMuzzleData[6].constantDelay=this.firingDelay7),this._perMuzzleData.length>7&&(this._perMuzzleData[7].constantDelay=this.firingDelay8)}},{key:"GetCurveDuration",value:function(){for(var e=0,t=0;t1&&void 0!==arguments[1]?arguments[1]:-1,r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t=this._perMuzzleData[n].elapsedTime||this.isLoopFiring)&&this.stretch[n].GetBatches(e,t,r)}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveStarField=void 0;var n=r(0);t.EveStarField=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._id=n.util.generateID(),this.name="",this.display=!0,this.effect=null,this.maxDist=0,this.maxFlashRate=0,this.minFlashIntensity=0,this.minFlashRate=0,this.seed=20}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveEffectRoot=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t0&&void 0!==arguments[0]?arguments[0]:[];this.mesh&&this.mesh.GetResources(e),this.spriteSet&&this.spriteSet.GetResources(e)}},{key:"UpdateViewDependentData",value:function(){this.display&&this.state!==t.State.DEAD&&(i.mat4.transpose(this._perObjectData.perObjectVSData.Get("WorldMat"),this.transform),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("WorldMatLast"),this.transform))}},{key:"Update",value:function(e,r,n){if(this.state===t.State.IN_FLIGHT){var a=t.global,o=i.mat4.getTranslation(a.vec3_0,this.transform),s=a.vec3_1,u=a.vec3_2,l=a.vec3_3;this.time+=e,this.time>this.durationEjectPhase?(i.vec3.subtract(o,this.velocity,r),i.vec3.lerp(o,o,r,1-Math.exp(.9999*-e)),i.mat4.setTranslation(this.transform,o),i.vec3.subtract(s,n,o),i.vec3.length(s)t.length)this.warheads.splice(t.length);else for(;this.warheads.length0&&void 0!==arguments[0]?arguments[0]:[],t=0;t.1&&(i.vec3.normalize(t,t),i.vec3.scale(t,t,Math.min(e*this.speed,r)),i.vec3.add(this.position,this.position,t));for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:[];return this.highDetail&&this.highDetail.GetResources(e),this.effectHeight&&this.effectHeight.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(e){this.highDetail.UpdateViewDependentData(e),this.zOnlyModel&&(this.zOnlyModel.translation=this.highDetail.translation,this.zOnlyModel.scaling=this.highDetail.scaling,this.zOnlyModel.UpdateViewDependentData(e))}},{key:"Update",value:function(e){this.highDetail.Update(e)}},{key:"GetBatches",value:function(e,t){if(this.display&&this.heightDirty&&this.watchedResources.length&&""!==this.heightMapResPath1){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],r=arguments[1];i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"GetResources",this).call(this,e,r);for(var n=0;n1)for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t.visible,e.visible,["glow","symHalo","halo","trail"]),i.util.assignIfExists(t,e,["name","display","seed","wavePhase","transform","locatorName","updateFromLocator","atlas0","atlas1"]),t}}]),t}(),h=t.EveBoosterSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.visible={},e.visible.glows=!0,e.visible.symHalos=!0,e.visible.halos=!0,e.visible.trails=!0,e.effect=null,e.glows=null,e.alwaysOn=!0,e.maxVel=250,e.glowDistance=2.5,e.glowScale=1,e.glowColor=i.vec4.create(),e.warpGlowColor=i.vec4.create(),e.haloDistance=3.01,e.haloScaleX=1,e.haloScaleY=1,e.haloColor=i.vec4.create(),e.warpHaloColor=i.vec4.create(),e.symHaloDistance=3,e.symHaloScale=1,e.trailColor=i.vec4.create(),e.trailSize=i.vec4.create(),e._parentTransform=i.mat4.create(),e._positions=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,i.device.gl.FLOAT,3,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,2,12)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,20)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,4,36)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,i.device.gl.FLOAT,4,52)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,i.device.gl.FLOAT,4,68)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,i.device.gl.FLOAT,4,84)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,6,i.device.gl.FLOAT,1,100)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,7,i.device.gl.FLOAT,2,104)),e._decl.RebuildHash(),e._perObjectData=new a.Tw2PerObjectData,e._perObjectData.perObjectVSData=new a.Tw2RawData,e._perObjectData.perObjectVSData.Declare("WorldMat",16),e._perObjectData.perObjectVSData.Declare("Shipdata",4),e._perObjectData.perObjectVSData.Create(),e._locatorRebuildPending=!0,e}return l(t,o.EveObjectSet),n(t,[{key:"FindItemByLocatorName",value:function(e){for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),this.glows&&this.glows.effect.GetResources(e),e}},{key:"Update",value:function(e,t){i.mat4.copy(this._parentTransform,t),this._rebuildPending&&this.Rebuild(),this.glows&&this.glows.Update(e)}},{key:"Unload",value:function(){this._positions&&(i.device.gl.deleteBuffer(this._positions),this._positions=null),this.glows&&this.glows.Unload()}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this);var e=this._visibleItems.length;if(this._rebuildPending=!1,e){for(var r=i.device,n=t._box,a=new Float32Array(e*n.length*6*28),o=[0,3,1,3,2,1],s=0,u=0;u0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","type","position1","color1","position2","color2","intermediatePosition","width","multiColor","multiColorBorder","overlayColor","animationSpeed","animationScale","numOfSegments"]),t}}]),t}();c.Type={INVALID:0,STRAIGHT:1,SPHERED:2,CURVED:3},c.DEFAULT_CURVED_SEGMENTS=20,c.DEFAULT_SPHERED_SEGEMENTS=20;var f=t.EveCurveLineSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.lineEffect=a.Tw2Effect.create({effectFilePath:"res:/Graphics/Effect/Managed/Space/SpecialFX/Lines3D.fx",textures:{TexMap:"res:/texture/global/white.dds.0.png",OverlayTexMap:"res:/texture/global/white.dds.0.png"}}),e.pickEffect=null,e.lineWidthFactor=1,e.additive=!1,e.pickable=!0,e.depthOffset=0,e.translation=i.vec3.create(),e.rotation=i.quat.create(),e.scaling=i.vec3.fromValues(1,1,1),e.transform=i.mat4.create(),e.parentTransform=i.mat4.create(),e._vertexSize=26,e._vbSize=0,e._vb=null,e._perObjectData=new a.Tw2PerObjectData,e._perObjectData.perObjectVSData=new a.Tw2RawData,e._perObjectData.perObjectVSData.Declare("WorldMat",16),e._perObjectData.perObjectVSData.Create(),e._perObjectData.perObjectPSData=new a.Tw2RawData,e._perObjectData.perObjectPSData.Declare("WorldMat",16),e._perObjectData.perObjectPSData.Create(),e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,i.device.gl.FLOAT,3,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,4,12)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,28)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,3,44)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,4,56)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,1,i.device.gl.FLOAT,4,72)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,2,i.device.gl.FLOAT,4,88)),e._decl.stride=4*e._vertexSize,e._decl.RebuildHash(),t.init(),e}return l(t,o.EveObjectSet),n(t,[{key:"Initialize",value:function(){this.OnValueChanged(),this.Rebuild()}},{key:"AddStraightLine",value:function(e,t,r,n,i){return this.CreateItem({type:c.Type.STRAIGHT,position1:e,position2:t,color1:n,color2:i,width:r})}},{key:"AddCurvedLineCrt",value:function(e,t,r,n,i,a){return this.CreateItem({type:c.Type.CURVED,position1:e,position2:t,intermediatePosition:r,color1:i,color2:a,width:n,numOfSegments:c.DEFAULT_CURVED_SEGMENTS})}},{key:"AddCurvedLineSph",value:function(e,r,n,a,o,s,u){var l=t.global;return this.CreateItem({type:c.Type.CURVED,position1:i.vec3.fromSpherical(l.vec3_0,e,n),position2:i.vec3.fromSpherical(l.vec3_1,r,n),intermediatePosition:i.vec3.fromSpherical(l.vec3_2,a,n),color1:s,color2:u,width:o,numOfSegments:c.DEFAULT_CURVED_SEGMENTS})}},{key:"AddSpheredLineCrt",value:function(e,t,r,n,i,a){return this.CreateItem({type:c.Type.SPHERED,position1:e,position2:t,intermediatePosition:r,color1:i,color2:a,width:n,numOfSegments:c.DEFAULT_SPHERED_SEGEMENTS})}},{key:"AddSpheredLineSph",value:function(e,r,n,a,o,s,u){var l=t.global;return this.CreateItem({type:c.Type.SPHERED,position1:i.vec3.fromSpherical(l.vec3_0,e,n),position2:i.vec3.fromSpherical(l.vec3_1,r,n),intermediatePosition:i.vec3.fromSpherical(l.vec3_2,a,n),color1:s,color2:u,width:o,numOfSegments:c.DEFAULT_SPHERED_SEGEMENTS})}},{key:"OnValueChanged",value:function(){i.mat4.fromRotationTranslationScale(this.transform,this.rotation,this.translation,this.scaling),this._rebuildPending=!0}},{key:"UpdateViewDependentData",value:function(e){i.mat4.copy(this.parentTransform,e)}},{key:"Update",value:function(){this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){this._vb&&(i.device.gl.deleteBuffer(this._vb),this._vb=null)}},{key:"Rebuild",value:function(){t.RebuildItems(this),this._vb=null,this._vbSize=this.lineCount,this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=t.global,n=new Float32Array(6*this._vbSize*this._vertexSize),a=r.vec3_0,o=r.vec3_1,s=r.vec3_2,u=r.vec3_3,l=r.vec3_4,f=r.vec3_5,h=r.vec3_6,p=r.mat4_0,d=r.vec3_7,v=r.vec3_8,m=r.vec3_9,y=r.vec3_10,b=r.vec4_0,g=r.vec4_1,_=0,E=void 0,T=0;T0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","boneIndex","groupIndex","maskAtlasID","position","scaling","rotation","transform","color","layer1Transform","layer2Transform","layer1Scroll","layer2Scroll"]),t}}]),t}();(t.EvePlaneSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.effect=null,e.hideOnLowQuality=!1,e._time=0,e._vertexBuffer=null,e._indexBuffer=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,4,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,16)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,4,32)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,4,48)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,i.device.gl.FLOAT,4,64)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,i.device.gl.FLOAT,4,80)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,i.device.gl.FLOAT,4,96)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,6,i.device.gl.FLOAT,4,112)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,7,i.device.gl.FLOAT,3,128)),e._decl.RebuildHash(),e}return l(t,o.EveObjectSet),n(t,[{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),e}},{key:"Update",value:function(e){this._time+=e,this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){this._vertexBuffer&&(i.device.gl.deleteBuffer(this._vertexBuffer),this._vertexBuffer=null),this._indexBuffer&&(i.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"Rebuild",value:function(){this.Unload(),t.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=t.global.mat4_0,n=new Float32Array(4*e*35),a=0;a0&&void 0!==arguments[0]?arguments[0]:[];return this.parentGeometry&&!e.includes(this.parentGeometry)&&e.push(this.parentGeometry),this.decalEffect&&this.decalEffect.GetResources(e),this.pickEffect&&this.pickEffect.GetResources(e),e}},{key:"Unload",value:function(){this._indexBuffer&&(i.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"GetBatches",value:function(e,t,r,n){var o=void 0;switch(e){case i.device.RM_DECAL:o=this.decalEffect;break;case i.device.RM_PICKABLE:o=this.pickable?this.pickEffect:null}if(this.display&&o&&o.IsGood()&&this.indexBuffer.length&&this.parentGeometry&&this.parentGeometry.IsGood()){var s=new a.Tw2ForwardingRenderBatch;if(this._perObjectData.perObjectVSData.Set("worldMatrix",r.perObjectVSData.Get("WorldMat")),this.parentBoneIndex>=0){var u=r.perObjectVSData.Get("JointMat"),l=12*this.parentBoneIndex;if(u[l]||u[l+4]||u[l+8]){var c=this._perObjectData.perObjectVSData.Get("parentBoneMatrix");c[0]=u[l],c[1]=u[l+4],c[2]=u[l+8],c[3]=0,c[4]=u[l+1],c[5]=u[l+5],c[6]=u[l+9],c[7]=0,c[8]=u[l+2],c[9]=u[l+6],c[10]=u[l+10],c[11]=0,c[12]=u[l+3],c[13]=u[l+7],c[14]=u[l+11],c[15]=1,i.mat4.transpose(c,c)}}i.mat4.invert(this._perObjectData.perObjectVSData.Get("invWorldMatrix"),this._perObjectData.perObjectVSData.Get("worldMatrix")),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("decalMatrix"),this.decalMatrix),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("invDecalMatrix"),this.invDecalMatrix),this._perObjectData.perObjectPSData.Get("displayData")[0]=n||0,this._perObjectData.perObjectPSData.Set("shipData",r.perObjectPSData.data),s.perObjectData=this._perObjectData,s.geometryProvider=this,s.renderMode=e,s.effect=o,t.Commit(s)}}},{key:"Render",value:function(e,t){var r=this.parentGeometry.meshes[0].indexes,n=this.parentGeometry.meshes[0].areas[0].start,a=this.parentGeometry.meshes[0].areas[0].count,o=this.parentGeometry.meshes[0].indexType;i.store.SetVariableValue("u_DecalMatrix",this.decalMatrix),i.store.SetVariableValue("u_InvDecalMatrix",this.invDecalMatrix),this.parentGeometry.meshes[0].indexes=this._indexBuffer,this.parentGeometry.meshes[0].areas[0].start=0,this.parentGeometry.meshes[0].areas[0].count=this.indexBuffer.length,this.parentGeometry.meshes[0].indexType=i.device.gl.UNSIGNED_SHORT,this.parentGeometry.RenderAreas(0,0,1,e.effect,t),this.parentGeometry.meshes[0].indexes=r,this.parentGeometry.meshes[0].areas[0].start=n,this.parentGeometry.meshes[0].areas[0].count=a,this.parentGeometry.meshes[0].indexType=o}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveSpotlightSet=t.EveSpotlightSetItem=t.EveSpotlightSetBatch=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","boosterGainInfluence","boneIndex","groupIndex","coneIntensity","spriteIntensity","flareIntensity","transform","coneColor","spriteColor","flareColor","spriteScale"]),t}}]),t}();(t.EveSpotlightSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.coneEffect=null,e.glowEffect=null,e._coneVertexBuffer=null,e._spriteVertexBuffer=null,e._indexBuffer=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,4,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,4,16)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,32)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,4,48)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,i.device.gl.FLOAT,3,64)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,i.device.gl.FLOAT,3,76)),e._decl.RebuildHash(),e}return l(t,o.EveObjectSet),n(t,[{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.coneEffect&&this.coneEffect.GetResources(e),this.glowEffect&&this.glowEffect.GetResources(e),e}},{key:"Unload",value:function(){this._coneVertexBuffer&&(i.device.gl.deleteBuffer(this._coneVertexBuffer),this._coneVertexBuffer=null),this._spriteVertexBuffer&&(i.device.gl.deleteBuffer(this._spriteVertexBuffer),this._spriteVertexBuffer=null),this._indexBuffer&&(i.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"Rebuild",value:function(){this.Unload(),t.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=i.device,n=[1,0,2,3],a=new Float32Array(22*(4*e*4)),o=0;o0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","blinkRate","blinkPhase","minScale","maxScale","falloff","boneIndex","groupIndex","position","color","warpColor"]),t}}]),t}();(t.EveSpriteSet=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];s(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.effect=null,n.useQuads=null,n.isSkinned=null,n._time=0,n._vertexBuffer=null,n._indexBuffer=null,n._instanceBuffer=null,n._decl=n._decl=new a.Tw2VertexDeclaration,n._vdecl=new a.Tw2VertexDeclaration,n._vdecl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,i.device.gl.FLOAT,1,0)),n._vdecl.RebuildHash(),n.UseQuads(e,r),n}return l(t,o.EveObjectSet),n(t,[{key:"UseQuads",value:function(e,t){this.useQuads!==e&&(this.useQuads=e,this.isSkinned=t,this._decl.elements.splice(0,this._decl.elements.length),e?(this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,i.device.gl.FLOAT,3,0)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,4,12)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,2,28)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,4,36)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,1,i.device.gl.FLOAT,4,52))):(this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,i.device.gl.FLOAT,2,0)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,i.device.gl.FLOAT,3,8)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,3,20)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,1,32)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,1,36)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,1,40)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,i.device.gl.FLOAT,1,44)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,i.device.gl.FLOAT,1,48))),this._decl.RebuildHash(),this._rebuildPending=!0)}},{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),e}},{key:"Update",value:function(e){this._time+=e,this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){this._vertexBuffer&&(i.device.gl.deleteBuffer(this._vertexBuffer),this._vertexBuffer=null),this._indexBuffer&&(i.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null),this._instanceBuffer&&(i.device.gl.deleteBuffer(this._instanceBuffer),this._instanceBuffer=null)}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){var t=i.device;if(this.useQuads)return this._vertexBuffer=t.gl.createBuffer(),t.gl.bindBuffer(t.gl.ARRAY_BUFFER,this._vertexBuffer),t.gl.bufferData(t.gl.ARRAY_BUFFER,new Float32Array([0,1,2,2,3,0]),t.gl.STATIC_DRAW),t.gl.bindBuffer(t.gl.ARRAY_BUFFER,null),void(this._instanceBuffer=t.gl.createBuffer());for(var r=new Float32Array(4*e*13),n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","locatorName","updateFromLocator","position","rotation","bone","canFireWhenHidden"]),t.UpdateTransforms(),t}}]),t}(),f=t.EveTurretSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.visible={},e.visible.turrets=!0,e.visible.firingEffects=!0,e.activeAnimation=new a.Tw2AnimationController,e.inactiveAnimation=new a.Tw2AnimationController,e.geometryResPath="",e.geometryResource=null,e.turretEffect=null,e.firingEffectResPath="",e.firingEffect=null,e.fireCallback=null,e.fireCallbackPending=!1,e.state=t.State.IDLE,e.bottomClipHeight=0,e.locatorName="",e.sysBoneHeight=0,e.hasCyclingFiringPos=!1,e.targetPosition=i.vec3.create(),e.parentMatrix=i.mat4.create(),e.boundingSphere=i.quat.create(),e._activeTurret=-1,e._recheckTimeLeft=0,e._currentCyclingFiresPos=0,e._perObjectDataActive=new a.Tw2PerObjectData,e._perObjectDataActive.perObjectVSData=new a.Tw2RawData,e._perObjectDataActive.perObjectVSData.Declare("baseCutoffData",4),e._perObjectDataActive.perObjectVSData.Declare("turretSetData",4),e._perObjectDataActive.perObjectVSData.Declare("shipMatrix",16),e._perObjectDataActive.perObjectVSData.Declare("turretTranslation",96),e._perObjectDataActive.perObjectVSData.Declare("turretRotation",96),e._perObjectDataActive.perObjectVSData.Declare("turretPoseTransAndRot",576),e._perObjectDataActive.perObjectVSData.Create(),e._perObjectDataInactive=new a.Tw2PerObjectData,e._perObjectDataInactive.perObjectVSData=new a.Tw2RawData,e._perObjectDataInactive.perObjectVSData.Declare("baseCutoffData",4),e._perObjectDataInactive.perObjectVSData.Declare("turretSetData",4),e._perObjectDataInactive.perObjectVSData.Declare("shipMatrix",16),e._perObjectDataInactive.perObjectVSData.Declare("turretTranslation",96),e._perObjectDataInactive.perObjectVSData.Declare("turretRotation",96),e._perObjectDataInactive.perObjectVSData.Declare("turretPoseTransAndRot",576),e._perObjectDataInactive.perObjectVSData.Create(),e._locatorRebuildPending=!0,e}return l(t,o.EveObjectSet),n(t,[{key:"Initialize",value:function(){var e=this;this.turretEffect&&""!==this.geometryResPath&&(this.geometryResource=i.resMan.GetResource(this.geometryResPath),this.activeAnimation.SetGeometryResource(this.geometryResource),this.inactiveAnimation.SetGeometryResource(this.geometryResource),this.geometryResource&&this.geometryResource.RegisterNotification(this)),""!==this.firingEffectResPath&&i.resMan.GetObject(this.firingEffectResPath,function(t){return e.firingEffect=t}),this.Rebuild()}},{key:"InitializeFiringEffect",value:function(){if(this.firingEffect&&this.geometryResource&&this.geometryResource.models.length)for(var e=this.geometryResource.models[0],r=0;rr&&(e=this.items.indexOf(l),r=c)}}return e}},{key:"EnterStateDeactive",value:function(){var e=this;this.state!==t.State.INACTIVE&&this.state!==t.State.PACKING&&(this.turretEffect?(this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.activeAnimation.PlayAnimation("Pack",!1,function(){e.state=t.State.INACTIVE,e.activeAnimation.PlayAnimation("Inactive",!0)}),this.inactiveAnimation.PlayAnimation("Pack",!1,function(){e.state=t.State.INACTIVE,e.inactiveAnimation.PlayAnimation("Inactive",!0)}),this.state=t.State.PACKING):this.state=t.State.INACTIVE,this._activeTurret=-1,this.firingEffect&&this.firingEffect.StopFiring())}},{key:"EnterStateIdle",value:function(){var e=this;this.state!==t.State.IDLE&&this.state!==t.State.UNPACKING&&(this.turretEffect?(this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.state===t.State.FIRING?(this.activeAnimation.PlayAnimation("Active",!0),this.inactiveAnimation.PlayAnimation("Active",!0)):(this.activeAnimation.PlayAnimation("Deploy",!1,function(){e.state=t.State.IDLE,e.activeAnimation.PlayAnimation("Active",!0)}),this.inactiveAnimation.PlayAnimation("Deploy",!1,function(){e.state=t.State.IDLE,e.inactiveAnimation.PlayAnimation("Active",!0)})),this.state=t.State.UNPACKING):this.state=t.State.IDLE,this._activeTurret=-1,this.firingEffect&&this.firingEffect.StopFiring())}},{key:"EnterStateFiring",value:function(){var e=this;if(!this.turretEffect||this.state===t.State.FIRING)return t.DoStartFiring(this),void(this.turretEffect&&this.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)}));this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.state===t.State.INACTIVE?(this.activeAnimation.PlayAnimation("Deploy",!1,function(){t.DoStartFiring(e),e.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)})}),this.inactiveAnimation.PlayAnimation("Deploy",!1,function(){e.inactiveAnimation.PlayAnimation("Active",!0)}),this.state=t.State.UNPACKING):(t.DoStartFiring(this),this.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)}),this.inactiveAnimation.PlayAnimation("Active",!0))}},{key:"RebuildCachedData",value:function(){for(var e=new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,2),r=this.geometryResource.meshes,n=this.activeAnimation,o=this.inactiveAnimation,s=0;s0&&void 0!==arguments[0]?arguments[0]:[];return this.geometryResource&&!e.includes(this.geometryResource)&&e.push(this.geometryResource),this.turretEffect&&this.turretEffect.GetResources(e),this.firingEffect&&this.firingEffect.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(){this.firingEffect&&this.firingEffect.UpdateViewDependentData()}},{key:"Update",value:function(e,r){if(this._rebuildPending&&this.Rebuild(),this.turretEffect&&(this.activeAnimation.Update(e),this.inactiveAnimation.Update(e)),i.mat4.copy(this.parentMatrix,r),this.firingEffect&&this._visibleItems.length){if(-1!==this._activeTurret){this.firingEffect.isLoopFiring&&this.state===t.State.FIRING&&(this._recheckTimeLeft-=e,this._recheckTimeLeft<=0&&t.DoStartFiring(this));var n=this.items[this._activeTurret];if(this.activeAnimation.models.length)for(var a=this.activeAnimation.models[0].bonesByName,o=0;o0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1],r=0;r2&&void 0!==arguments[2]?arguments[2]:this._batches,n=0;n=0&&(u=e.substr(0,s+1)+o+"/"+e.substr(s+1)),(s=u.lastIndexOf("_"))>=0){u=u.substr(0,s)+"_"+o+u.substr(s);var l=r(n,"textureOverrides",{});if(t in l&&i.name in l[t])return u}}return e}function f(e,t){var r=l(t),n=(e="/"+e).lastIndexOf("/");return e.substr(0,n+1)+r+e.substr(n+1)}function h(e,t){for(var r=0;r=0&&s=0?r||T:t||(r||T);case"not_overridable":case"half_overridable_2":return r||T}return T}function w(t,r,a){var o=e.faction[r],s=e.faction[a],u=null;o&&o.areas&&"hull"in o.areas&&(u=o.areas.hull);var l=null;if(s&&s.areas&&"hull"in s.areas&&(l=s.areas.hull),(u||l)&&t.turretEffect){var c=t.turretEffect.parameters;for(var f in c)if(c.hasOwnProperty(f)){if(c[f].constructor.prototype!==i.Tw2Vector4Parameter.prototype)continue;var h=null,p=null;u&&(h=E(f,o,u)),l&&(p=E(f,o,u)),n.vec4.copy(c[f].value,O(f,h,p,t.turretEffect.name))}t.turretEffect.BindParameters()}}function S(t){if("all"!==t){var r={};for(var n in e[t])e[t].hasOwnProperty(n)&&(r[n]=e[t][n].description||"");return r}return e}this.SetupTurretMaterial=function(t,r,n,i){null===e?this.LoadData(function(){w(t,r,n),i&&i()}):(w(t,r,n),i&&i())},this.GetHullNames=function(e){this.LoadData(function(){e(S("hull"))})},this.GetFactionNames=function(e){this.LoadData(function(){e(S("faction"))})},this.GetRaceNames=function(e){this.LoadData(function(){e(S("race"))})},this.GetSofData=function(e){this.LoadData(function(){e(S("all"))})}};var n=r(0),i=r(1),a=r(58),o=r(64),s=r(59),u=r(61)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(186);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(190);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(197);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(201);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(202);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(14);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(187);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(188);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(189);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2StaticEmitter=void 0;var n=function(){function e(e,t){for(var r=0;rthis.geometryIndex&&this.geometryResource.meshes[this.geometryIndex].bufferData){this._spawned=!0;for(var e=this.geometryResource.meshes[this.geometryIndex],t=this.particleSystem.elements,r=new Array(t.length),n=0;n=this.maxParticleCount?null:this.aliveCount++}},{key:"EndSpawnParticle",value:function(){this.bufferDirty=!0}},{key:"Update",value:function(t){if(t=Math.min(t,.1),this.applyAging&&this.HasElement(o.Tw2ParticleElementDeclaration.Type.LIFETIME)){for(var r=this.GetElement(o.Tw2ParticleElementDeclaration.Type.LIFETIME),n=this.emitParticleOnDeathEmitter?this.GetElement(o.Tw2ParticleElementDeclaration.Type.POSITION):null,a=this.emitParticleOnDeathEmitter?this.GetElement(o.Tw2ParticleElementDeclaration.Type.VELOCITY):null,s=0;s1){if(this.emitParticleOnDeathEmitter&&this.emitParticleOnDeathEmitter.SpawnParticles(n,a,1),this.aliveCount--,s=n&&t>=n)return et?1:0;if(e>=n)return 1;if(t>=n)return-1;var r=a[e],i=a[t];return ri?-1:0})}},{key:"GetInstanceBuffer",value:function(){if(0!==this.aliveCount){var e=i.device;if(this.requiresSorting&&this.HasElement(o.Tw2ParticleElementDeclaration.Type.POSITION)&&this.buffers){this._Sort();for(var t=this.instanceStride[0],r=this.buffers[0],n=0;nt.time?1:0}},{key:"Sort",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.keys;r&&r.length&&(r.sort(e.Compare),t.length=r[r.length-1].time)}},{key:"Sort2",value:function(t){if(t.keys&&t.keys.length){t.keys.sort(e.Compare);var r=t.keys[t.keys.length-1];if(r.time>t.length){var n=t.length,i=t.endValue,a=t.endTangent;t.length=r.time,t.endValue=r.value,t.endTangent=r.leftTangent,n>0&&(r.time=n,r.value=i,r.leftTangent=a)}}}}]),e}();o.inputDimension=null,o.outputDimension=null,o.valueProperty=null,o.curveType=null,o.Key=null,o.Interpolation=null,o.Extrapolation=null,o.Type={CURVE:1,CURVE2:2,CURVE_MAYA:3,CURVE_NO_KEYS:4,SEQUENCER:100,SEQUENCER2:101},o.global={vec3_0:i.vec3.create(),vec4_0:i.vec4.create(),quat_0:i.quat.create(),quat_1:i.quat.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r.d(t,"ARRAY_TYPE",function(){return i}),t.setMatrixArrayType=function(e){i=e},t.toRadian=function(e){return e*o},t.equals=function(e,t){return Math.abs(e-t)<=n*Math.max(1,Math.abs(e),Math.abs(t))};const n=1e-6;t.EPSILON=n;let i="undefined"!=typeof Float32Array?Float32Array:Array;const a=Math.random;t.RANDOM=a;const o=Math.PI/180},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VectorParameter=t.Tw2Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";a(this,e),this._id=i.util.generateID(),this.name=t,this._onModified=[]}return n(e,[{key:"OnValueChanged",value:function(e,t){for(var r=0;r=this.size&&(this.constantBuffer=e,this.offset=t,this.Apply(e,t,r),!0)}},{key:"Unbind",value:function(){this.constantBuffer=null}},{key:"Apply",value:function(e,t,r){e.set(this.value,t)}},{key:"EqualsValue",value:function(e){for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:{},t=this.constructor.Item;if(t&&"create"in t){var r=t.create(e);return this.AddItem(r),r}return null}},{key:"AddItem",value:function(e){this.items.includes(e)||(e._onModified=this._onChildModified,this.items.push(e),this.OnValueChanged())}},{key:"RemoveItem",value:function(e){var t=this.items.indexOf(e);-1!==t&&(e._onModified=null,this.items.splice(t,1),this.OnValueChanged())}},{key:"ClearItems",value:function(){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:null;if(null!==e)for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e){this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this),this._rebuildPending=!1}},{key:"GetBatches",value:function(e,t,r){}},{key:"Render",value:function(){}}],[{key:"RebuildItems",value:function(e){e._visibleItems=[];for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e,t){this.useSRT&&(i.quat.normalize(this.rotation,this.rotation),i.mat4.fromRotationTranslationScale(this.localTransform,this.rotation,this.translation,this.scaling)),i.mat4.copy(this.worldTransformLast,this.worldTransform),i.mat4.multiply(this.worldTransform,t,this.localTransform)}},{key:"GetBatches",value:function(e,t){}}]),e}()).global={mat4_0:i.mat4.create(),vec3_0:i.vec3.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveObject=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e){}},{key:"GetBatches",value:function(e,t){}}]),e}()).global={vec3_0:i.vec3.create(),vec3_1:i.vec3.create(),vec3_2:i.vec3.create(),vec3_3:i.vec3.create(),vec3_4:i.vec3.create(),vec3_5:i.vec3.create(),vec3_6:i.vec3.create(),vec3_7:i.vec3.create(),mat4_0:i.mat4.create(),mat4_1:i.mat4.create(),mat4_2:i.mat4.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2ParticleForce=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r.name=e,r.display=!0,r.visible={},r.visible.log=!0,r.visible.info=!0,r.visible.debug=!0,r.visible.warn=!0,r.visible.error=!0,r.maxLogs=100,r._logs=[],r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.Tw2EventEmitter),n(t,[{key:"log",value:function(e,r){if(r.logged)return r;if(r.log=t.Type[r.log?r.log.toUpperCase():"LOG"]||"log",!r.hide&&this.display&&this.visible[r.log]){var n=this.name+": {"+e+"}",i=r.msg||"";r.path&&(i+=" '"+r.path+"'","time"in r&&(i+=" in "+r.time.toFixed(3)+" secs")),(void 0!==r.value||r.type)&&(i+=" (",r.type&&(i+=r.type),r.type&&void 0!==r.value&&(i+=":"),void 0!==r.value&&(i+=r.value),i+=")"),"data"in r||"err"in r?(console.group(n),console[r.log](i),r.data&&console.debug(r.data),r.err&&console.debug(r.err.stack||r.err.toString()),console.groupEnd()):console[r.log](n,i)}return this.maxLogs?(this._logs.length>=this.maxLogs&&this._logs.splice(this.maxLogs,this._logs.length-1),this._logs.unshift(r)):this._logs=[],this.emit("log",r),r.logged=!0,r}},{key:"GetLogs",value:function(e){return Object.assign([],void 0===e?this._logs:this._logs.splice(0,e))}},{key:"Set",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,a.assignIfExists)(this,e,["name","maxLogs","display"]),(0,a.assignIfExists)(this.visible,e.visible,["log","info","debug","warn","error"])}}]),t}();o.Type={THROW:"error",ERROR:"error",WARNING:"warn",WARN:"warn",INFO:"info",LOG:"log",DEBUG:"debug"};var s=t.logger=new o("CCPWGL");i.Tw2EventEmitter.logger=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(29);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(67);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(33);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(34);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(73);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(74);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(75);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(76);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(77);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.store=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};"uuid"in e&&(0,i.enableUUID)(e.uuid),this.RegisterPaths(e.paths),this.RegisterDynamicPaths(e.dynamicPaths),this.RegisterTypes(e.types),this.RegisterConstructors(e.constructors),this.RegisterExtensions(e.extensions),this.RegisterVariables(e.variables),this.RegisterSchemas(e.schemas)}}],[{key:"GetStoreItem",value:function(e,t,r){var n=e["_"+t];if(n&&(0,i.isString)(r)){if(r in n)return n[r];e._missing[t]||(e._missing[t]=[]),e._missing[t].includes(r)||(e._missing[t].push(r),a.logger.log("store.warning",{log:"warning",msg:"Missing "+t+": '"+r+"'"}))}return null}},{key:"SetStoreItem",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=arguments[3],o=arguments[4];if(o&&!o(n))return a.logger.log("store.error",{log:"error",msg:"Invalid value "+t+": '"+r+"'"}),!1;var s=e["_"+t];if(s&&(0,i.isString)(r)&&!(0,i.isUndefined)(n)){var u=s[r];return s[r]=n,u?a.logger.log("store.registered",{log:"debug",msg:"Re-registered "+t+": '"+r+"'",data:{old_value:u,new_value:n}}):a.logger.log("store.registered",{log:"debug",msg:"Registered "+t+": '"+r+"'",hide:!0}),!0}return!1}},{key:"RegisterFromObject",value:function(e,t,r){if(r&&t in e){r=(0,i.toArray)(r);for(var n=0;nr.size?t.subarray(0,r.size):t,r.offset)}},{key:"Get",value:function(e){return this.elements[e].array}},{key:"GetData",value:function(e){return this.data.subarray(this.elements[e].offset,this.elements[e].offset+this.elements[e].array.length)}},{key:"Create",value:function(){for(var e in this.data=new Float32Array(this.nextOffset),this.elements)if(this.elements.hasOwnProperty(e)){var t=this.elements[e];if(t.array=this.data.subarray(t.offset,t.offset+t.size),null!==t.value){if(1===t.size)t.array[0]=t.value;else for(var r=0;r2&&void 0!==arguments[2]?arguments[2]:null;this.elements[e]={offset:this.nextOffset,size:t,array:null,value:r},this.nextOffset+=t}},{key:"DeclareFromObject",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in e)if(e.hasOwnProperty(t)){var r=e[t];if(a.util.isNumber(r))this.Declare(t,1,r);else{if(!a.util.isArrayLike(r))throw new Error("Invalid declaration type: "+(void 0===r?"undefined":n(r)));1===r.length&&this.Declare(t,r.length,r)}}this.Create()}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(118);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(120);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(38);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(8);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(52);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(121);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(40);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(39);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2ParticleEmitter=void 0;var n=function(){function e(e,t){for(var r=0;r1?0:i<-1?Math.PI:Math.acos(i)},t.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},t.equals=function(e,t){let r=e[0],i=e[1],a=e[2],o=t[0],s=t[1],u=t[2];return Math.abs(r-o)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-s)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(a-u)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(u))};var n=r(3);function i(){let e=new n.ARRAY_TYPE(3);return e[0]=0,e[1]=0,e[2]=0,e}function a(e){let t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function o(e,t,r){let i=new n.ARRAY_TYPE(3);return i[0]=e,i[1]=t,i[2]=r,i}function s(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function u(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function l(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function c(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(r*r+n*n+i*i)}function f(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return r*r+n*n+i*i}function h(e){let t=e[0],r=e[1],n=e[2];return t*t+r*r+n*n}function p(e,t){let r=t[0],n=t[1],i=t[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a),e}function d(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}const v=s;t.sub=v;const m=u;t.mul=m;const y=l;t.div=y;const b=c;t.dist=b;const _=f;t.sqrDist=_;const g=a;t.len=g;const E=h;t.sqrLen=E;const T=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=3),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s0&&(o=1/Math.sqrt(o),e[0]=r*o,e[1]=n*o,e[2]=i*o,e[3]=a*o),e}const d=a;t.sub=d;const v=o;t.mul=v;const m=s;t.div=m;const y=l;t.dist=y;const b=c;t.sqrDist=b;const _=f;t.len=_;const g=h;t.sqrLen=g;const E=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=4),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s1?r-1:0),i=1;i2?n-2:0),a=2;a1?r-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:{};if(i.has(this)){var r=i.get(this);e=e.toLowerCase(),t.log&&!t.log.logged&&(t.log=this.log(e,t.log)),e in r?r[e].forEach(function(n,i){i.call(n.context,t),n.once&&r[e].delete(i)}):(r[e]=new Set,this.emit("event_added",{eventName:e}))}return this}},{key:"on",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i.has(this)||i.set(this,{});var o=i.get(this);return o[e=e.toLowerCase()]||(o[e]=new Set,o[e].add(function(){return r.emit("event_added",{eventName:e})},{once:!0})),o[e].add(t,{context:n,once:a}),this}},{key:"once",value:function(e,t,r){return this.on(e,t,r,!0)}},{key:"off",value:function(e,t){if(i.has(this)){var r=i.get(this);(e=e.toLowerCase())in r&&r[e].delete(t)}return this}},{key:"del",value:function(e){if(i.has(this)){var t=i.get(this);(e=e.toLowerCase())in t&&(this.emit("event_removed",{eventName:e}),delete t[e])}return this}},{key:"clr",value:function(e){if(i.has(this)){var t=i.get(this);for(var r in t)t.hasOwnProperty(r)&&t[r].has(e)&&t[r].delete(e)}return this}},{key:"kill",value:function(){return i.has(this)&&(this.emit("event_kill"),i.set(this,{})),this}},{key:"log",value:function(e,t){return this.constructor.logger&&this.constructor.logger.log(e,t),t}}],[{key:"assign",value:function(t){Object.assign(t.prototype,e.prototype)}}]),e}()).logger=null},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resMan=t.Tw2ResMan=void 0;var n=function(){function e(e,t){for(var r=0;r1&&(this.activeFrame+=1,this._purgeTime-=Math.floor(this._purgeTime),this._purgeFrame+=1,this._purgeFrame>=5&&this.autoPurgeResources&&this.motherLode.PurgeInactive(this._purgeFrame,this._purgeFrameLimit,this.purgeTime,i.logger)),!0}},{key:"GetResource",value:function(t){var r=void 0;if(t=e.NormalizePath(t),r=this.motherLode.Find(t))return r.IsPurged()&&r.Reload(),r;var n=e.GetPathExt(t);if(null===n)return i.logger.log("res.error",{log:"error",src:["Tw2ResMan","ReloadResource"],msg:"Undefined extension",type:"extension.undefined",path:t}),null;var o=a.store.GetExtension(n);return o?((r=new o).path=t,e.LoadResource(this,r)):(i.logger.log("res.error",{log:"error",src:["Tw2ResMan","ReloadResource"],msg:"Unregistered extension",type:"extension.unregistered",path:t,value:n}),null)}},{key:"GetObject",value:function(t,r){var n={};t=e.NormalizePath(t);var i=this.motherLode.Find(t);i?i.AddObject(n,r):((i=new s.Tw2LoadingObject).path=t,i.AddObject(n,r),e.LoadResource(this,i))}},{key:"ReloadResource",value:function(t){var r=t.path,n=this.motherLode.Find(r);return n&&!n.IsPurged()?n:(i.logger.log("res.event",{msg:"Reloading ",path:r,type:"reload"}),e.LoadResource(this,t))}}],[{key:"BuildUrl",value:function(e){var t=e.indexOf(":/");if(-1===t)return i.logger.log("res.error",{log:"warn",src:["Tw2ResMan","BuildUrl"],msg:"Invalid path",type:"prefix.undefined",path:e}),e;var r=e.substr(0,t),n=a.store.GetPath(r);return n?n+e.substr(t+2):(i.logger.log("res.error",{log:"warn",src:["Tw2ResMan","BuildUrl"],msg:"Unregistered path",path:e,type:"prefix.unregistered",value:r}),e)}},{key:"NormalizePath",value:function(e){return"str:/"===e.substr(0,5)?e:((e=e.toLowerCase()).replace("\\","/"),e)}},{key:"GetPathExt",value:function(e){if("str:/"===e.substr(0,5)){var t=e.indexOf("/",5);return-1===t?null:e.substr(5,t-5)}var r=e.lastIndexOf(".");return-1===r?null:e.substr(r+1)}},{key:"LogPathString",value:function(e){return"str:/"===e.substr(0,5)&&e.length>64?e.substr(0,64)+"...":e}},{key:"LoadResource",value:function(t,r){var n=r.path,a=e.BuildUrl(n);if(r._isPurged=!1,t.motherLode.Add(n,r),r.DoCustomLoad&&r.DoCustomLoad(a))return r;var o=e.CreateHttpRequest(r.requestResponseType);if(o){i.logger.log("res.event",{msg:"Requesting",path:n,type:"request"}),o.onreadystatechange=e.DoLoadResource(t,r),o.open("GET",a),r.LoadStarted();try{o.send(),t._pendingLoads++}catch(e){i.logger.log("res.error",{log:"error",src:["Tw2ResMan","LoadResource"],msg:"Error sending object HTTP request",path:n,type:"http.request",err:e})}}return r}},{key:"DoLoadResource",value:function(e,t){return function(){var r=0;try{r=this.readyState}catch(n){return i.logger.log("res.error",{log:"error",src:["Tw2ResMan","_DoLoadResource"],msg:"Communication error loading",path:t.path,type:"http.readystate",value:r}),t.LoadFinished(!1),void e._pendingLoads--}if(4===r){if(200===this.status){var n=null,a=null;try{n=this.responseText,a=this.responseXML}catch(e){n=this.response}t.LoadFinished(!0),e._prepareQueue.push([t,n,a])}else i.logger.log("res.error",{log:"error",src:["Tw2ResMan","_DoLoadResource"],msg:"Communication error loading",path:t.path,type:"http.status",value:this.status}),t.LoadFinished(!1),t.PrepareFinished(!1);e._pendingLoads--}}}},{key:"CreateHttpRequest",value:function(e){var t=null;if(window.XMLHttpRequest)t=new XMLHttpRequest;else if(window.ActiveXObject)try{t=new window.ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{t=new window.ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}return t?e&&(t.responseType=e):i.logger.log("res.error",{log:"error",src:["Tw2LoadingObject","Prepare"],msg:"Could not create an XMLHTTP instance",type:"http.instance"}),t}}]),e}();t.resMan=new u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2LoadingObject=void 0;var n=function(){function e(e,t){for(var r=0;r127&&(e=e-255-1),e}},{key:"ReadUInt16",value:function(){return this.data[this.cursor++]+(this.data[this.cursor++]<<8)}},{key:"ReadInt16",value:function(){var e=this.data[this.cursor++]+(this.data[this.cursor++]<<8);return e>32767&&(e=e-65535-1),e}},{key:"ReadUInt32",value:function(){return this.data[this.cursor++]+(this.data[this.cursor++]<<8)+(this.data[this.cursor++]<<16)+(this.data[this.cursor++]<<24>>>0)}},{key:"ReadInt32",value:function(){var e=this.data[this.cursor++]+(this.data[this.cursor++]<<8)+(this.data[this.cursor++]<<16)+(this.data[this.cursor++]<<24>>>0);return e>2147483647&&(e=e-4294967295-1),e}},{key:"ReadFloat16",value:function(){var e=this.data[this.cursor++],t=this.data[this.cursor++],r=(t>>2&31)-15,n=(3&t)<<8|e;return 0===n&&-15===r?0:(1-2*(t>>7))*(1+n*Math.pow(2,-10))*Math.pow(2,r)}},{key:"ReadFloat32",value:function(){var e=this.data[this.cursor++],t=this.data[this.cursor++],r=this.data[this.cursor++],n=this.data[this.cursor++],i=(n<<1&255|r>>7)-127,a=(127&r)<<16|t<<8|e;return 0===a&&-127===i?0:(1-2*(n>>7))*(1+a*Math.pow(2,-23))*Math.pow(2,i)}},{key:"ReadString",value:function(){for(var e=this.data[this.cursor++],t="",r=0;r0&&void 0!==arguments[0]?arguments[0]:[];for(var t in this.effectRes&&!e.includes(this.effectRes)&&e.push(this.effectRes),this.parameters)this.parameters.hasOwnProperty(t)&&"GetResources"in this.parameters[t]&&this.parameters[t].GetResources(e);return e}},{key:"RebuildCachedData",value:function(e){this.shader=e.GetShader(this.options),this.BindParameters()}},{key:"UnBindParameters",value:function(){for(var e in this.techniques)if(this.techniques.hasOwnProperty(e))for(var t=this.techniques[e],r=0;r=this.techniques[e].length)){this.shader.ApplyPass(e,t);for(var r=this.techniques[e][t],n=this.shader.techniques[e].passes[t],a=i.device,o=a.gl,s=a.IsAlphaTestEnabled()&&n.shadowShaderProgram?n.shadowShaderProgram:n.shaderProgram,u=0;u<2;++u){for(var l=r.stages[u],c=0;c=this.techniques[e].length?null:i.device.IsAlphaTestEnabled()&&this.shader.techniques[e].passes[t].shadowShaderProgram?this.shader.techniques[e].passes[t].shadowShaderProgram.input:this.shader.techniques[e].passes[t].shaderProgram.input}},{key:"Render",value:function(e){for(var t=this.GetPassCount("Main"),r=0;r0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)if(this.parameters.hasOwnProperty(t)&&this.parameters[t]instanceof a.Tw2TextureParameter){var r=this.parameters[t].GetValue();r&&(e[t]=r)}return e}},{key:"SetTextures",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=e[r],i=this.parameters[r];a.Tw2TextureParameter.is(n)&&(i?i.EqualsValue(n)||(i.SetTexturePath(n),t=!0):(this.parameters[r]=new a.Tw2TextureParameter(r,n),t=!0))}return t}},{key:"GetParameters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)!this.parameters.hasOwnProperty(t)||this.parameters[t]instanceof a.Tw2TextureParameter||(e[t]=this.parameters[t].GetValue(!0));return e}},{key:"SetParameters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=e[r],a=this.parameters[r];if(a)a.constructor.is(n)&&!a.EqualsValue(n)&&(this.parameters[r].SetValue(n),t=!0);else{var o=i.store.CreateType(r,n);o&&(this.parameters[r]=o,t=!0)}}return t}},{key:"SetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=this.parameters[r];if(n&&n instanceof a.Tw2TextureParameter){var i=!1,o=e[r];for(var s in o)if(o.hasOwnProperty(s)&&a.Tw2TextureParameter.overrideProperties.includes(s)&&o[s]!==n[s]){i=!0;break}i&&(n.SetOverrides(e[r]),t=!0)}}return t}},{key:"GetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)if(this.parameters.hasOwnProperty(t)){var r=this.parameters[t];r&&r instanceof a.Tw2TextureParameter&&r.useAllOverrides&&(e[t]=this.parameters[t].GetOverrides())}return e}}],[{key:"ToEffectResPath",value:function(e){return(e=e?e.substr(0,e.lastIndexOf(".")).replace("/effect/",i.device.effectDir)+".sm_"+i.device.shaderModel:"").toLowerCase()}},{key:"FromEffectResPath",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"fx";return(e=e.substr(0,e.lastIndexOf(".")).replace(i.device.effectDir,"/effect/")+"."+t).toLowerCase()}},{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new this;if(i.util.assignIfExists(t,e,["name","effectFilePath","display","autoParameter"]),"parameters"in e&&t.SetParameters(e.parameters),"textures"in e&&t.SetTextures(e.textures),"overrides"in e&&t.SetOverrides(e.overrides),""===t.name&&""!==e.effectFilePath){var r=e.effectFilePath;t.name=r.substring(r.lastIndexOf("/")+1,r.length)}return t.Initialize(),t}}]),e}()).ConstantIgnore=["PerFrameVS","PerObjectVS","PerFramePS","PerObjectPS","PerObjectPSInt"]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TextureParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.resourcePath=r,n.useAllOverrides=!1,n.addressUMode=1,n.addressVMode=1,n.addressWMode=1,n.filterMode=2,n.mipFilterMode=2,n.maxAnisotropy=4,n.textureRes=null,n._sampler=null,r&&n.Initialize(),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,o.Tw2Parameter),n(t,[{key:"Initialize",value:function(){this.OnValueChanged()}},{key:"SetTexturePath",value:function(e){this.resourcePath=e,this.OnValueChanged()}},{key:"GetValue",value:function(){return this.isTextureAttached?null:this.resourcePath}},{key:"SetTextureRes",value:function(e){this.textureRes!==e&&(this.resourcePath="",this.textureRes=e),this.textureRes._isAttached=!0}},{key:"OnValueChanged",value:function(e,r){""!==this.resourcePath&&(this.resourcePath=this.resourcePath.toLowerCase(),this.textureRes=""!==this.resourcePath?i.resMan.GetResource(this.resourcePath):null),this.UpdateOverrides(),function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,r,n)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(n):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"OnValueChanged",this).call(this,e,r)}},{key:"Apply",value:function(e,t,r){this.textureRes&&(this.useAllOverrides&&(this._sampler.samplerType=t.samplerType,this._sampler.isVolume=t.isVolume,this._sampler.registerIndex=t.registerIndex,t=this._sampler),i.device.gl.activeTexture(i.device.gl.TEXTURE0+e),this.textureRes.Bind(t,r))}},{key:"SetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i.util.assignIfExists(this,e,t.overrideProperties),this.OnValueChanged()}},{key:"GetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.util.assignIfExists(e,this,t.overrideProperties),e}},{key:"UpdateOverrides",value:function(){if(this.useAllOverrides){this._sampler=this._sampler||new a.Tw2SamplerState;var e=i.device.wrapModes,t=i.device.gl,r=this._sampler;if(1===this.filterMode){switch(this.mipFilterMode){case 0:r.minFilter=t.NEAREST;break;case 1:r.minFilter=t.NEAREST_MIPMAP_NEAREST;break;default:r.minFilter=t.NEAREST_MIPMAP_LINEAR}r.minFilterNoMips=t.NEAREST,r.magFilter=t.NEAREST}else{switch(this.mipFilterMode){case 0:r.minFilter=t.LINEAR;break;case 1:r.minFilter=t.LINEAR_MIPMAP_NEAREST;break;default:r.minFilter=t.LINEAR_MIPMAP_LINEAR}r.minFilterNoMips=t.LINEAR,r.magFilter=t.LINEAR}r.addressU=e[this.addressUMode],r.addressV=e[this.addressVMode],r.addressW=e[this.addressWMode],r.anisotropy=this.maxAnisotropy,r.ComputeHash()}else this._sampler&&(this._sampler=null)}},{key:"EqualsValue",value:function(e){return e.toLowerCase()===this.GetValue()}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.resourcePath=e.resourcePath,this.SetOverrides(e.GetOverrides)}},{key:"Clone",value:function(){var e=new t;return e.Copy(this,!0),e}},{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.textureRes&&!e.includes(this.textureRes)&&e.push(this.textureRes),e}},{key:"isTextureAttached",get:function(){return this.textureRes&&this.textureRes._isAttached}}],[{key:"isValue",value:function(e){return i.util.isString(e)}}]),t}();s.prototype.SetValue=s.prototype.SetTexturePath,s.overrideProperties=["useAllOverrides","addressUMode","addressVMode","addressWMode","filterMode","mipFilterMode","maxAnisotropy"]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SamplerState=void 0;var n=function(){function e(e,t){for(var r=0;r4&&void 0!==arguments[4]?arguments[4]:0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.usage=t,this.usageIndex=r,this.type=n,this.elements=i,this.offset=a,this.location=null,this.customSetter=null}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(94);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(95);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(96);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(97);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(98);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(99);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(100);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(42);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PerObjectData=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};e.VSData&&(this.perObjectVSData=new a.Tw2RawData(e.VSData)),e.PSData&&(this.perObjectPSData=new a.Tw2RawData(e.PSData))}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(103);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(104);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(105);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(106);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(107);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(108);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(109);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(110);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(111);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})});var h=r(112);Object.keys(h).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return h[e]}})});var p=r(113);Object.keys(p).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return p[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(41);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(114);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(49);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(50);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(115);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Mesh=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[];return e.includes(this.geometryResource)||e.push(this.geometryResource),i.util.perArrayChild(this.opaqueAreas,"GetResources",e),i.util.perArrayChild(this.transparentAreas,"GetResources",e),i.util.perArrayChild(this.additiveAreas,"GetResources",e),i.util.perArrayChild(this.pickableAreas,"GetResources",e),i.util.perArrayChild(this.decalAreas,"GetResources",e),i.util.perArrayChild(this.depthAreas,"GetResources",e),e}},{key:"GetBatches",value:function(e,t,r){if(!this.IsGood()||!this.display)return!1;var n=this.constructor.GetAreaBatches;switch(e){case i.device.RM_OPAQUE:return void(this.visible.opaqueAreas&&n(this,this.opaqueAreas,e,t,r));case i.device.RM_DECAL:return void(this.visible.decalAreas&&n(this,this.opaqueAreas,e,t,r));case i.device.RM_TRANSPARENT:return void(this.visible.transparentAreas&&n(this,this.transparentAreas,e,t,r));case i.device.RM_ADDITIVE:return void(this.visible.transparentAreas&&n(this,this.additiveAreas,e,t,r));case i.device.RM_PICKABLE:return void(this.visible.pickableAreas&&n(this,this.pickableAreas,e,t,r))}}}],[{key:"GetAreaBatches",value:function(e,t,r,n,i){for(var a=0;a=this.animationRes.duration}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TextureRes=void 0;var n=function(){function e(e,t){for(var r=0;r0?"."+t.mipLevelSkipCount.toString():"";if(t.mipLevelSkipCount>0){var n=e.lastIndexOf(".");n>=0&&(e=e.substr(0,n-2)+r+e.substr(n))}return e}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Bone=void 0;var n=r(0);t.Tw2Bone=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.boneRes=null,this.localTransform=n.mat4.create(),this.worldTransform=n.mat4.create(),this.offsetTransform=n.mat4.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2Model=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.modelRes=null,this.bones=[],this.bonesByName={}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2Track=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.trackRes=null,this.bone=null}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2TrackGroup=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.trackGroupRes=null,this.model=null,this.transformTracks=[]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2RenderTarget=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];if(this.mesh&&this.mesh.GetResources(e),!t)for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];return this.mesh&&this.mesh.GetResources(e),this.animation&&this.animation.GetResources(e),i.util.perArrayChild(this.spriteSets,"GetResources",e),i.util.perArrayChild(this.turretSets,"GetResources",e),i.util.perArrayChild(this.decals,"GetResources",e),i.util.perArrayChild(this.spotlightSets,"GetResources",e),i.util.perArrayChild(this.planeSets,"GetResources",e),i.util.perArrayChild(this.lineSets,"GetResources",e),i.util.perArrayChild(this.overlayEffects,"GetResources",e),i.util.perArrayChild(this.effectChildren,"GetResources",e),t||i.util.perArrayChild(this.children,"GetResources",e),e}},{key:"UpdateViewDependentData",value:function(){for(var e=0;e0?(t[0]=this.shapeEllipsoidCenter[0],t[1]=this.shapeEllipsoidCenter[1],t[2]=this.shapeEllipsoidCenter[2],r[0]=this.shapeEllipsoidRadius[0],r[1]=this.shapeEllipsoidRadius[1],r[2]=this.shapeEllipsoidRadius[2]):this.mesh&&this.mesh.IsGood()&&(i.vec3.subtract(t,this.mesh.geometryResource.maxBounds,this.mesh.geometryResource.minBounds),i.vec3.scale(t,t,.8660254035),i.vec3.add(r,this.mesh.geometryResource.maxBounds,this.mesh.geometryResource.minBounds),i.vec3.scale(r,r,.5));for(var n=0;n0){for(var t=0;t0&&this.mesh.GetBatches(e,t,this._perObjectData),this.lod>1){if(r.spriteSets)for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:null;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.batches=[],this._sortMethod=t}return n(e,[{key:"Commit",value:function(e){this.batches.push(e)}},{key:"Clear",value:function(){this.batches=[]}},{key:"Render",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Main";this._sortMethod&&this.batches.sort(this._sortMethod);for(var r=0;r0?(n=2*Math.sqrt(r+1),e[3]=.25*n,e[0]=(t[6]-t[9])/n,e[1]=(t[8]-t[2])/n,e[2]=(t[1]-t[4])/n):t[0]>t[5]&t[0]>t[10]?(n=2*Math.sqrt(1+t[0]-t[5]-t[10]),e[3]=(t[6]-t[9])/n,e[0]=.25*n,e[1]=(t[1]+t[4])/n,e[2]=(t[8]+t[2])/n):t[5]>t[10]?(n=2*Math.sqrt(1+t[5]-t[0]-t[10]),e[3]=(t[8]-t[2])/n,e[0]=(t[1]+t[4])/n,e[1]=.25*n,e[2]=(t[6]+t[9])/n):(n=2*Math.sqrt(1+t[10]-t[0]-t[5]),e[3]=(t[1]-t[4])/n,e[0]=(t[8]+t[2])/n,e[1]=(t[6]+t[9])/n,e[2]=.25*n);return e},t.fromRotationTranslationScale=function(e,t,r,n){let i=t[0],a=t[1],o=t[2],s=t[3],u=i+i,l=a+a,c=o+o,f=i*u,h=i*l,p=i*c,d=a*l,v=a*c,m=o*c,y=s*u,b=s*l,_=s*c,g=n[0],E=n[1],T=n[2];return e[0]=(1-(d+m))*g,e[1]=(h+_)*g,e[2]=(p-b)*g,e[3]=0,e[4]=(h-_)*E,e[5]=(1-(f+m))*E,e[6]=(v+y)*E,e[7]=0,e[8]=(p+b)*T,e[9]=(v-y)*T,e[10]=(1-(f+d))*T,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e},t.fromRotationTranslationScaleOrigin=function(e,t,r,n,i){let a=t[0],o=t[1],s=t[2],u=t[3],l=a+a,c=o+o,f=s+s,h=a*l,p=a*c,d=a*f,v=o*c,m=o*f,y=s*f,b=u*l,_=u*c,g=u*f,E=n[0],T=n[1],O=n[2],w=i[0],S=i[1],R=i[2];return e[0]=(1-(v+y))*E,e[1]=(p+g)*E,e[2]=(d-_)*E,e[3]=0,e[4]=(p-g)*T,e[5]=(1-(h+y))*T,e[6]=(m+b)*T,e[7]=0,e[8]=(d+_)*O,e[9]=(m-b)*O,e[10]=(1-(h+v))*O,e[11]=0,e[12]=r[0]+w-(e[0]*w+e[4]*S+e[8]*R),e[13]=r[1]+S-(e[1]*w+e[5]*S+e[9]*R),e[14]=r[2]+R-(e[2]*w+e[6]*S+e[10]*R),e[15]=1,e},t.fromQuat=function(e,t){let r=t[0],n=t[1],i=t[2],a=t[3],o=r+r,s=n+n,u=i+i,l=r*o,c=n*o,f=n*s,h=i*o,p=i*s,d=i*u,v=a*o,m=a*s,y=a*u;return e[0]=1-f-d,e[1]=c+y,e[2]=h-m,e[3]=0,e[4]=c-y,e[5]=1-l-d,e[6]=p+v,e[7]=0,e[8]=h+m,e[9]=p-v,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},t.frustum=function(e,t,r,n,i,a,o){let s=1/(r-t),u=1/(i-n),l=1/(a-o);return e[0]=2*a*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*u,e[6]=0,e[7]=0,e[8]=(r+t)*s,e[9]=(i+n)*u,e[10]=(o+a)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*l,e[15]=0,e},t.perspective=function(e,t,r,n,i){let a=1/Math.tan(t/2),o=1/(n-i);return e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(i+n)*o,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*i*n*o,e[15]=0,e},t.perspectiveFromFieldOfView=function(e,t,r,n){let i=Math.tan(t.upDegrees*Math.PI/180),a=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),s=Math.tan(t.rightDegrees*Math.PI/180),u=2/(o+s),l=2/(i+a);return e[0]=u,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-(o-s)*u*.5,e[9]=(i-a)*l*.5,e[10]=n/(r-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*r/(r-n),e[15]=0,e},t.ortho=function(e,t,r,n,i,a,o){let s=1/(t-r),u=1/(n-i),l=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*s,e[13]=(i+n)*u,e[14]=(o+a)*l,e[15]=1,e},t.lookAt=function(e,t,r,i){let a,o,s,u,l,c,f,h,p,d,v=t[0],m=t[1],y=t[2],b=i[0],_=i[1],g=i[2],E=r[0],T=r[1],O=r[2];if(Math.abs(v-E)0&&(p=1/Math.sqrt(p),c*=p,f*=p,h*=p);let d=u*h-l*f,v=l*c-s*h,m=s*f-u*c;return e[0]=d,e[1]=v,e[2]=m,e[3]=0,e[4]=f*m-h*v,e[5]=h*d-c*m,e[6]=c*v-f*d,e[7]=0,e[8]=c,e[9]=f,e[10]=h,e[11]=0,e[12]=i,e[13]=a,e[14]=o,e[15]=1,e},t.str=function(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},t.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2)+Math.pow(e[9],2)+Math.pow(e[10],2)+Math.pow(e[11],2)+Math.pow(e[12],2)+Math.pow(e[13],2)+Math.pow(e[14],2)+Math.pow(e[15],2))},t.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e},t.subtract=a,t.multiplyScalar=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e},t.multiplyScalarAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e[9]=t[9]+r[9]*n,e[10]=t[10]+r[10]*n,e[11]=t[11]+r[11]*n,e[12]=t[12]+r[12]*n,e[13]=t[13]+r[13]*n,e[14]=t[14]+r[14]*n,e[15]=t[15]+r[15]*n,e},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},t.equals=function(e,t){let r=e[0],i=e[1],a=e[2],o=e[3],s=e[4],u=e[5],l=e[6],c=e[7],f=e[8],h=e[9],p=e[10],d=e[11],v=e[12],m=e[13],y=e[14],b=e[15],_=t[0],g=t[1],E=t[2],T=t[3],O=t[4],w=t[5],S=t[6],R=t[7],P=t[8],A=t[9],M=t[10],j=t[11],D=t[12],C=t[13],I=t[14],k=t[15];return Math.abs(r-_)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(_))&&Math.abs(i-g)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(g))&&Math.abs(a-E)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(E))&&Math.abs(o-T)<=n.EPSILON*Math.max(1,Math.abs(o),Math.abs(T))&&Math.abs(s-O)<=n.EPSILON*Math.max(1,Math.abs(s),Math.abs(O))&&Math.abs(u-w)<=n.EPSILON*Math.max(1,Math.abs(u),Math.abs(w))&&Math.abs(l-S)<=n.EPSILON*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(c-R)<=n.EPSILON*Math.max(1,Math.abs(c),Math.abs(R))&&Math.abs(f-P)<=n.EPSILON*Math.max(1,Math.abs(f),Math.abs(P))&&Math.abs(h-A)<=n.EPSILON*Math.max(1,Math.abs(h),Math.abs(A))&&Math.abs(p-M)<=n.EPSILON*Math.max(1,Math.abs(p),Math.abs(M))&&Math.abs(d-j)<=n.EPSILON*Math.max(1,Math.abs(d),Math.abs(j))&&Math.abs(v-D)<=n.EPSILON*Math.max(1,Math.abs(v),Math.abs(D))&&Math.abs(m-C)<=n.EPSILON*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(y-I)<=n.EPSILON*Math.max(1,Math.abs(y),Math.abs(I))&&Math.abs(b-k)<=n.EPSILON*Math.max(1,Math.abs(b),Math.abs(k))};var n=r(3);function i(e,t,r){let n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],l=t[6],c=t[7],f=t[8],h=t[9],p=t[10],d=t[11],v=t[12],m=t[13],y=t[14],b=t[15],_=r[0],g=r[1],E=r[2],T=r[3];return e[0]=_*n+g*s+E*f+T*v,e[1]=_*i+g*u+E*h+T*m,e[2]=_*a+g*l+E*p+T*y,e[3]=_*o+g*c+E*d+T*b,_=r[4],g=r[5],E=r[6],T=r[7],e[4]=_*n+g*s+E*f+T*v,e[5]=_*i+g*u+E*h+T*m,e[6]=_*a+g*l+E*p+T*y,e[7]=_*o+g*c+E*d+T*b,_=r[8],g=r[9],E=r[10],T=r[11],e[8]=_*n+g*s+E*f+T*v,e[9]=_*i+g*u+E*h+T*m,e[10]=_*a+g*l+E*p+T*y,e[11]=_*o+g*c+E*d+T*b,_=r[12],g=r[13],E=r[14],T=r[15],e[12]=_*n+g*s+E*f+T*v,e[13]=_*i+g*u+E*h+T*m,e[14]=_*a+g*l+E*p+T*y,e[15]=_*o+g*c+E*d+T*b,e}function a(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}const o=i;t.mul=o;const s=a;t.sub=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=s,t.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},t.setAxisAngle=u,t.getAxisAngle=function(e,t){let r=2*Math.acos(t[3]),n=Math.sin(r/2);0!=n?(e[0]=t[0]/n,e[1]=t[1]/n,e[2]=t[2]/n):(e[0]=1,e[1]=0,e[2]=0);return r},t.multiply=l,t.rotateX=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u+o*s,e[1]=i*u+a*s,e[2]=a*u-i*s,e[3]=o*u-n*s,e},t.rotateY=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u-a*s,e[1]=i*u+o*s,e[2]=a*u+n*s,e[3]=o*u-i*s,e},t.rotateZ=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u+i*s,e[1]=i*u-n*s,e[2]=a*u+o*s,e[3]=o*u-a*s,e},t.calculateW=function(e,t){let r=t[0],n=t[1],i=t[2];return e[0]=r,e[1]=n,e[2]=i,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),e},t.slerp=c,t.invert=function(e,t){let r=t[0],n=t[1],i=t[2],a=t[3],o=r*r+n*n+i*i+a*a,s=o?1/o:0;return e[0]=-r*s,e[1]=-n*s,e[2]=-i*s,e[3]=a*s,e},t.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},t.fromMat3=f,t.fromEuler=function(e,t,r,n){let i=.5*Math.PI/180;t*=i,r*=i,n*=i;let a=Math.sin(t),o=Math.cos(t),s=Math.sin(r),u=Math.cos(r),l=Math.sin(n),c=Math.cos(n);return e[0]=a*u*c-o*s*l,e[1]=o*s*c+a*u*l,e[2]=o*u*l-a*s*c,e[3]=o*u*c+a*s*l,e},t.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"};var n=r(3),i=r(30),a=r(31),o=r(32);function s(){let e=new n.ARRAY_TYPE(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function u(e,t,r){r*=.5;let n=Math.sin(r);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r),e}function l(e,t,r){let n=t[0],i=t[1],a=t[2],o=t[3],s=r[0],u=r[1],l=r[2],c=r[3];return e[0]=n*c+o*s+i*l-a*u,e[1]=i*c+o*u+a*s-n*l,e[2]=a*c+o*l+n*u-i*s,e[3]=o*c-n*s-i*u-a*l,e}function c(e,t,r,n){let i,a,o,s,u,l=t[0],c=t[1],f=t[2],h=t[3],p=r[0],d=r[1],v=r[2],m=r[3];return(a=l*p+c*d+f*v+h*m)<0&&(a=-a,p=-p,d=-d,v=-v,m=-m),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,u=Math.sin(n*i)/o):(s=1-n,u=n),e[0]=s*l+u*p,e[1]=s*c+u*d,e[2]=s*f+u*v,e[3]=s*h+u*m,e}function f(e,t){let r,n=t[0]+t[4]+t[8];if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{let n=0;t[4]>t[0]&&(n=1),t[8]>t[3*n+n]&&(n=2);let i=(n+1)%3,a=(n+2)%3;r=Math.sqrt(t[3*n+n]-t[3*i+i]-t[3*a+a]+1),e[n]=.5*r,r=.5/r,e[3]=(t[3*i+a]-t[3*a+i])*r,e[i]=(t[3*i+n]+t[3*n+i])*r,e[a]=(t[3*a+n]+t[3*n+a])*r}return e}const h=o.clone;t.clone=h;const p=o.fromValues;t.fromValues=p;const d=o.copy;t.copy=d;const v=o.set;t.set=v;const m=o.add;t.add=m;const y=l;t.mul=y;const b=o.scale;t.scale=b;const _=o.dot;t.dot=_;const g=o.lerp;t.lerp=g;const E=o.length;t.length=E;const T=E;t.len=T;const O=o.squaredLength;t.squaredLength=O;const w=O;t.sqrLen=w;const S=o.normalize;t.normalize=S;const R=o.exactEquals;t.exactEquals=R;const P=o.equals;t.equals=P;const A=function(){let e=a.create(),t=a.fromValues(1,0,0),r=a.fromValues(0,1,0);return function(n,i,o){let s=a.dot(i,o);return s<-.999999?(a.cross(e,t,i),a.len(e)<1e-6&&a.cross(e,r,i),a.normalize(e,e),u(n,e,Math.PI),n):s>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(a.cross(e,i,o),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+s,S(n,n))}}();t.rotationTo=A;const M=function(){let e=s(),t=s();return function(r,n,i,a,o,s){return c(e,n,o,s),c(t,i,a,s),c(r,e,t,2*s*(1-s)),r}}();t.sqlerp=M;const j=function(){let e=i.create();return function(t,r,n,i){return e[0]=n[0],e[3]=n[1],e[6]=n[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-r[0],e[5]=-r[1],e[8]=-r[2],S(t,f(t,e))}}();t.setAxes=j},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=i,t.clone=function(e){let t=new n.ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t},t.fromValues=function(e,t){let r=new n.ARRAY_TYPE(2);return r[0]=e,r[1]=t,r},t.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},t.set=function(e,t,r){return e[0]=t,e[1]=r,e},t.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e},t.subtract=a,t.multiply=o,t.divide=s,t.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},t.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},t.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e},t.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e},t.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},t.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e},t.scaleAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e},t.distance=u,t.squaredDistance=l,t.length=c,t.squaredLength=f,t.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},t.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},t.normalize=function(e,t){var r=t[0],n=t[1],i=r*r+n*n;i>0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i);return e},t.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},t.cross=function(e,t,r){var n=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=n,e},t.lerp=function(e,t,r,n){var i=t[0],a=t[1];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e},t.random=function(e,t){t=t||1;var r=2*n.RANDOM()*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e},t.transformMat2=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e},t.transformMat2d=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i+r[4],e[1]=r[1]*n+r[3]*i+r[5],e},t.transformMat3=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[3]*i+r[6],e[1]=r[1]*n+r[4]*i+r[7],e},t.transformMat4=function(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[4]*i+r[12],e[1]=r[1]*n+r[5]*i+r[13],e},t.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]},t.equals=function(e,t){let r=e[0],i=e[1],a=t[0],o=t[1];return Math.abs(r-a)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-o)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))};var n=r(3);function i(){let e=new n.ARRAY_TYPE(2);return e[0]=0,e[1]=0,e}function a(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function o(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function s(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function u(e,t){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function l(e,t){var r=t[0]-e[0],n=t[1]-e[1];return r*r+n*n}function c(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function f(e){var t=e[0],r=e[1];return t*t+r*r}const h=c;t.len=h;const p=a;t.sub=p;const d=o;t.mul=d;const v=s;t.div=v;const m=u;t.dist=m;const y=l;t.sqrDist=y;const b=f;t.sqrLen=b;const _=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=2),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s1.0001||r<.99999)e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=0;else if(r=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])){var i=Math.atan2(r,t[3])/r;e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=0}else e[0]=0,e[1]=0,e[2]=0,e[3]=0;return e},n.quat.pow=function(e,t,r){return 1===r?n.quat.copy(e,t):(n.quat.ln(e,t),e[0]*=r,e[1]*=r,e[2]*=r,e[3]*=r,n.quat.exp(e,e),e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mat3=void 0;var n=r(7);t.mat3=n.mat3},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mat4=void 0;var n=r(7);t.mat4=n.mat4,n.mat4.arcFromForward=function(){var e=void 0;return function(t,r){e||(e=n.vec3.create());var i=n.vec3.normalize(e,r);if(n.mat4.identity(t),i[2]<-.99999)return t;if(i[2]>.99999)return t[5]=-1,t[10]=-1,t;var a=(1+i[2])/(i[0]*i[0]+i[1]*i[1]);return t[0]=a*i[1]*i[1]-i[2],t[1]=-a*i[0]*i[1],t[2]=i[0],t[4]=t[1],t[5]=a*i[0]*i[0]-i[2],t[6]=i[1],t[8]=-i[0],t[9]=-i[1],t[10]=-i[2],t}}(),n.mat4.copyTranslation=function(e,t){return e[12]=t[12],e[13]=t[13],e[14]=t[14],e},n.mat4.fromMat3=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[4]=t[3],e[5]=t[4],e[6]=t[5],e[8]=t[6],e[9]=t[7],e[10]=t[8],e[3]=e[7]=e[11]=e[12]=e[13]=e[14]=0,e[15]=1,e},n.mat4.lookAtGL=function(){var e=void 0,t=void 0,r=void 0;return function(i,a,o,s){return e||(e=n.vec3.create(),t=n.vec3.create(),r=n.vec3.create()),n.vec3.subtract(r,a,o),0===n.vec3.squaredLength(r)&&(r[2]=1),n.vec3.normalize(r,r),n.vec3.cross(e,s,r),0===n.vec3.squaredLength(e)&&(r[2]+=1e-4,n.vec3.cross(e,s,r)),n.vec3.normalize(e,e),n.vec3.cross(t,r,e),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[4]=t[0],i[5]=t[1],i[6]=t[2],i[8]=r[0],i[9]=r[1],i[10]=r[2],i}}(),n.mat4.perspectiveGL=function(e,t,r,i,a){var o=Math.tan(t/360*Math.PI)*i,s=o*r;return n.mat4.frustum(e,-s,s,-o,o,i,a),e},n.mat4.setTranslation=function(e,t){return e[12]=t[0],e[13]=t[1],e[14]=t[2],e},n.mat4.setTranslationFromValues=function(e,t,r,n){return e[12]=t,e[13]=r,e[14]=n,e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.noise=void 0;var n=r(33),i=r(34),a=t.noise={};a.turbulence=function(){var e=[],t=[],r=[],a=!1;return function(o,s,u,l,c,f){a||function(){for(var o=0;o<256;o++)e[o]=i.vec4.fromValues(Math.random()-.5,Math.random()-.5,Math.random()-.5,Math.random()-.5),t[o]=o;for(var s=256;--s;){var u=t[s],l=Math.floor(256*Math.random());t[s]=t[l],t[l]=u}for(var c=0;c<256;c++)t[256+c]=t[c],e[256+c]=e[c],e[512+c]=e[c];for(var f=0;f<15;++f)r[f]=n.vec3.create();a=!0}(),s+=4096,u+=4096,l+=4096,c+=4096;var h=Math.floor(s),p=Math.floor(u),d=Math.floor(l),v=Math.floor(c),m=s-h,y=u-p,b=l-d,_=c-v,g=(h&=255)+1,E=(p&=255)+1,T=(d&=255)+1,O=(v&=255)+1,w=t[h],S=t[g],R=t[w+p],P=t[S+p],A=t[w+E],M=t[S+E],j=n.vec3.lerp(r[0],e[R+d+v],e[P+d+v],m),D=n.vec3.lerp(r[1],e[A+d+v],e[M+d+v],m),C=n.vec3.lerp(r[2],e[R+T+v],e[P+T+v],m),I=n.vec3.lerp(r[3],e[R+T+v],e[P+T+v],m),k=n.vec3.lerp(r[4],j,D,y),x=n.vec3.lerp(r[5],C,I,y),L=n.vec3.lerp(r[6],k,x,b);j=n.vec3.lerp(r[7],e[R+d+O],e[P+d+O],m),D=n.vec3.lerp(r[8],e[A+d+O],e[M+d+O],m),C=n.vec3.lerp(r[9],e[R+T+O],e[P+T+O],m),I=n.vec3.lerp(r[10],e[R+T+O],e[P+T+O],m),k=n.vec3.lerp(r[11],j,D,y),x=n.vec3.lerp(r[12],C,I,y);var B=n.vec3.lerp(r[13],k,x,b),F=n.vec3.lerp(r[14],L,B,_);return o[0]+=F[0]*f,o[1]+=F[1]*f,o[2]+=F[2]*f,o}}(),a.perlin1=function(){var e=!1,t=256,r=null,n=null;return function(i){e||function(){r=new Array(t+t+2),n=new Array(t+t+2);var i=0,a=0,o=0;for(i=0;it){o=u;break}if(0===e.degree)for(var l=0;l0&&(s=(t-e.knots[e.knots.length-1])/f);for(var h=0;hg&&(g+=i,E+=i,t+=i),_>g&&(g+=i,E+=i,t+=i),E=0;)n=r*n+e[t];return n},n.ag_zeroin2=function(e,t,r,i,a,o){var s=void 0,u=void 0,l=void 0,c=void 0,f=void 0,h=void 0,p=void 0,d=void 0,v=void 0,m=void 0;for(var y=!0;y&&(s=e,c=r,l=u=t-e),Math.abs(c)f&&0!==i;)Math.abs(l)0?d=-d:p=-p,m=l,l=u,2*p<3*h*d-Math.abs(f*d)&&pf?t+=u:h>0?t+=f:t-=f,(i=n.ag_horner1(o.p,o.deg,t))*(c/Math.abs(c))>0&&(y=!0);return t},n.ag_zeroin=function(e,t,r,i){var a,o;return a=n.ag_horner1(i.p,i.deg,e),Math.abs(a)<1.192092896e-7?e:(o=n.ag_horner1(i.p,i.deg,t),Math.abs(o)<1.192092896e-7?t:n.ag_zeroin2(e,t,a,o,r,i))},n.polyZeroes=function(e,t,r,i,a,o,s){var u,l,c=void 0,f=void 0,h=void 0,p=void 0,d=void 0,v=void 0,m=void 0,y=void 0,b=void 0,_=void 0,g=void 0,E=void 0,T=new Array(22),O=void 0,w=new Array(22),S=new Array(22),R={p:[],deg:0};for(m=_=0,y=0,c=0;cs[0]-u:a>s[0]+u,(p=f&&h?1:0)&&(i&&s[0]a&&(s[0]=a)),p;for(R.p=E,R.deg=t,c=1;c<=t;c++)O[c-1]=c*E[c];if(0===(d=n.polyZeroes(O,t-1,r,0,a,0,l)).length)return 0;for(c=v=0;c<=d;c++){if(p>t)return p;0===c?(b=r,g=n.ag_horner1(E,t,b),Math.abs(g)<=u&&i&&(s[p++]=r)):(b=m,g=_),c===d?(m=a,v=0):m=l[c],_=n.ag_horner1(E,t,m),v?v=0:Math.abs(_)0||g>0&&_<0)&&(s[p++]=n.ag_zeroin(b,m,0,R),p>1&&s[p-2]>=s[p-1]-u&&(s[p-2]=.5*(s[p-2]+s[p-1]),p--))}return p}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(79);Object.defineProperty(t,"device",{enumerable:!0,get:function(){return n.device}});var i=r(37);Object.defineProperty(t,"resMan",{enumerable:!0,get:function(){return i.resMan}});var a=r(19);Object.defineProperty(t,"store",{enumerable:!0,get:function(){return a.store}});var o=r(17);Object.defineProperty(t,"logger",{enumerable:!0,get:function(){return o.logger}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.device=t.Tw2Device=void 0;var n=function(){function e(e,t){for(var r=0;r1,this.canvas=t,this.Resize();return this._quadBuffer=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,this._quadBuffer),n.bufferData(n.ARRAY_BUFFER,new Float32Array([1,1,0,1,1,1,-1,1,0,1,0,1,1,-1,0,1,1,0,-1,-1,0,1,0,0]),n.STATIC_DRAW),this._cameraQuadBuffer=n.createBuffer(),this._quadDecl=new l.Tw2VertexDeclaration,this._quadDecl.elements.push(new l.Tw2VertexElement(l.Tw2VertexDeclaration.Type.POSITION,0,n.FLOAT,4,0)),this._quadDecl.elements.push(new l.Tw2VertexElement(l.Tw2VertexDeclaration.Type.TEXCOORD,0,n.FLOAT,2,16)),this._quadDecl.RebuildHash(),this._alphaTestState={},this._alphaTestState.states={},this._alphaTestState.states[this.RS_ALPHATESTENABLE]=0,this._alphaTestState.states[this.RS_ALPHAREF]=-1,this._alphaTestState.states[this.RS_ALPHAFUNC]=this.CMP_GREATER,this._alphaTestState.states[this.RS_CLIPPING]=0,this._alphaTestState.states[this.RS_CLIPPLANEENABLE]=0,this._alphaTestState.dirty=!1,this._alphaBlendState={},this._alphaBlendState.states={},this._alphaBlendState.states[this.RS_SRCBLEND]=this.BLEND_SRCALPHA,this._alphaBlendState.states[this.RS_DESTBLEND]=this.BLEND_INVSRCALPHA,this._alphaBlendState.states[this.RS_BLENDOP]=this.BLENDOP_ADD,this._alphaBlendState.states[this.RS_SEPARATEALPHABLENDENABLE]=0,this._alphaBlendState.states[this.RS_BLENDOPALPHA]=this.BLENDOP_ADD,this._alphaBlendState.states[this.RS_SRCBLENDALPHA]=this.BLEND_SRCALPHA,this._alphaBlendState.states[this.RS_DESTBLENDALPHA]=this.BLEND_INVSRCALPHA,this._alphaBlendState.dirty=!1,this._depthOffsetState={},this._depthOffsetState.states={},this._depthOffsetState.states[this.RS_SLOPESCALEDEPTHBIAS]=0,this._depthOffsetState.states[this.RS_DEPTHBIAS]=0,this._depthOffsetState.dirty=!1,this.wrapModes=[],this.wrapModes[0]=0,this.wrapModes[1]=n.REPEAT,this.wrapModes[2]=n.MIRRORED_REPEAT,this.wrapModes[3]=n.CLAMP_TO_EDGE,this.wrapModes[4]=n.CLAMP_TO_EDGE,this.wrapModes[5]=n.CLAMP_TO_EDGE,this._shadowStateBuffer=new Float32Array(24),this._blendTable=[-1,n.ZERO,n.ONE,n.SRC_COLOR,n.ONE_MINUS_SRC_COLOR,n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.DST_ALPHA,n.ONE_MINUS_DST_ALPHA,n.DST_COLOR,n.ONE_MINUS_DST_COLOR,n.SRC_ALPHA_SATURATE,-1,-1,n.CONSTANT_COLOR,n.ONE_MINUS_CONSTANT_COLOR],this.glVersion}},{key:"Schedule",value:function(e){this._scheduled.includes(e)||this._scheduled.push(e)}},{key:"OnResize",value:function(e){this._onResize=e}},{key:"Resize",value:function(){if(this.vrDisplay&&this.vrDisplay.isPresenting){var e=this.vrDisplay.getEyeParameters("left"),t=this.vrDisplay.getEyeParameters("right");this.canvas.width=2*Math.max(e.renderWidth,t.renderWidth),this.canvas.height=Math.max(t.renderHeight,t.renderHeight)}else this.canvas.width=this.canvas.offsetWidth*this.viewportPixelRatio,this.canvas.height=this.canvas.offsetHeight*this.viewportPixelRatio;this.viewportWidth=this.canvas.clientWidth,this.viewportHeight=this.canvas.clientHeight,this.viewportAspect=this.viewportWidth/this.viewportHeight,this._onResize&&this._onResize(this.viewportWidth,this.viewportHeight),a.store.SetVariableValue("ViewportSize",[this.viewportWidth,this.viewportHeight,this.viewportWidth,this.viewportHeight])}},{key:"Tick",value:function(){this.canvas.clientWidth===this.viewportWidth&&this.canvas.clientHeight===this.viewportHeight||this.Resize();var e=null===this.previousTime?0:this.previousTime,t=this.Now();this.currentTime=.001*(t-this.startTime),this.dt=null===this.previousTime?0:.001*(t-this.previousTime),this.previousTime=t,a.store.SetVariableValue("Time",[this.currentTime,this.currentTime-Math.floor(this.currentTime),this.frameCounter,e]),s.resMan.PrepareLoop(this.dt);for(var r=0;r1.6&&(r=t/1.6);var n=2*Math.atan(r/this.projection[5]);return e[0]=this.viewportWidth,e[1]=this.viewportHeight,e[2]=n,e[3]=n*t,e}},{key:"GetEyePosition",value:function(e){return i.vec3.copy(e,this.eyePosition)}},{key:"IsAlphaTestEnabled",value:function(){return this._alphaTestState.states[this.RS_ALPHATESTENABLE]}},{key:"IsFrameBufferComplete",value:function(e){return this.gl.checkFramebufferStatus(e)===this.gl.FRAMEBUFFER_COMPLETE}},{key:"GetExtension",value:function(t){for(var r in e.WebglVendorPrefixes)if(e.WebglVendorPrefixes.hasOwnProperty(r)){var n=this.gl.getExtension(e.WebglVendorPrefixes[r]+t);if(n)return n}return null}},{key:"GetFallbackTexture",value:function(){return this._fallbackTexture||(this._fallbackTexture=this.CreateSolidTexture()),this._fallbackTexture}},{key:"GetFallbackCubeMap",value:function(){return this._fallbackCube||(this._fallbackCube=this.CreateSolidCube()),this._fallbackCube}},{key:"CreateSolidTexture",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],t=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,1,1,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(e)),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.bindTexture(this.gl.TEXTURE_2D,null),t}},{key:"CreateSolidCube",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],t=this.gl.createTexture();this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP,t);for(var r=0;r<6;++r)this.gl.texImage2D(this.gl.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,this.gl.RGBA,1,1,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(e));return this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP,null),t}},{key:"RenderFullScreenQuad",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Main";if(!e||!e.IsGood())return!1;this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._quadBuffer);for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:"Main";if(!e||!e.IsGood())return!1;for(var r=new Float32Array([1,1,0,1,1,1,-1,1,0,1,0,1,1,-1,0,1,1,0,-1,-1,0,1,0,0]),n=this.projectionInverse,a=0;a<4;++a){var o=r.subarray(6*a,6*a+4);i.vec4.transformMat4(o,o,n),i.vec3.scale(o,o,1/o[3]),o[3]=1}this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._cameraQuadBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,r,this.gl.STATIC_DRAW);for(var s=0;s>16,r=(4278190080&e)>>24,n=(r<<1&255|t>>7)-127,i=(127&t)<<16|(65280&e)>>8<<8|255&e;return 0===i&&-127===n?0:(1-2*(r>>7))*(1+i*Math.pow(2,-23))*Math.pow(2,n)}},{key:"CreateContext",value:function(e,t,r){r=Array.isArray(r)?r:[r];for(var n=0;n>8&255]+a[e>>16&255]+a[e>>24&255]+"-"+a[255&t]+a[t>>8&255]+"-"+a[t>>16&15|64]+a[t>>24&255]+"-"+a[63&r|128]+a[r>>8&255]+"-"+a[r>>16&255]+a[r>>24&255]+a[255&n]+a[n>>8&255]+a[n>>16&255]+a[n>>24&255]}():i++};var n=null,i=0,a=null},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getURL=function(){return Object.assign({},n)},t.getURLString=function(e,t){return(e=e.toLowerCase())in n?n[e]:t},t.getURLInteger=function(e,t){return(e=e.toLowerCase())in n?parseInt(n[e],10):t},t.getURLFloat=function(e,t){return(e=e.toLowerCase())in n?parseFloat(n[e]):t},t.getURLBoolean=function(e,t){return(e=e.toLowerCase())in n?n[e]:t};for(var n={},i=window.location.search.substring(1).split("&"),a=0;a=r&&a.Unload()&&(n.log("res.event",{msg:"Unloaded ",path:a.path,type:"unused"}),delete this._loadedObjects[i]))}}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SamplerOverride=void 0;var n=r(0),i=r(43);t.Tw2SamplerOverride=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="",this.addressU=0,this.addressV=0,this.addressW=0,this.filter=0,this.mipFilter=0,this.lodBias=0,this.maxMipLevel=0,this.maxAnisotropy=0;var t=null;this.GetSampler=function(e){if(!t){(t=new i.Tw2SamplerState).registerIndex=e.registerIndex,t.name=e.name;var r=n.device.wrapModes,a=n.device.gl;if(1===this.filter){switch(this.mipFilter){case 0:t.minFilter=a.NEAREST;break;case 1:t.minFilter=a.NEAREST_MIPMAP_NEAREST;break;default:t.minFilter=a.NEAREST_MIPMAP_LINEAR}t.minFilterNoMips=a.NEAREST}else{switch(this.mipFilter){case 0:t.minFilter=a.LINEAR;break;case 1:t.minFilter=a.LINEAR_MIPMAP_NEAREST;break;default:t.minFilter=a.LINEAR_MIPMAP_LINEAR}t.minFilterNoMips=a.LINEAR}3!==this.filter&&3!==this.mipFilter||(t.anisotropy=Math.max(this.maxAnisotropy,1)),t.magFilter=1===this.filter?a.NEAREST:a.LINEAR,t.addressU=r[this.addressU],t.addressV=r[this.addressV],t.addressW=r[this.addressW],t.samplerType=e.samplerType,t.isVolume=e.isVolume,t.ComputeHash()}return t}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VertexDeclaration=void 0;var n=function(){function e(e,t){for(var r=0;rt)return null}if(n.usage>e)return null}return null}},{key:"SetDeclaration",value:function(t,r){for(var n=i.device.gl,a=0,o=0;o=this._elementsSorted.length){n.disableVertexAttribArray(s.location),n.vertexAttrib4f(s.location,0,0,0,0);break}var u=this._elementsSorted[a],l=e.CompareDeclarationElements(u,s);if(l>0){n.disableVertexAttribArray(s.location),n.vertexAttrib4f(s.location,0,0,0,0);break}if(0===l){u.customSetter?u.customSetter(s):(n.enableVertexAttribArray(s.location),n.vertexAttribPointer(s.location,u.elements,u.type,!1,r,u.offset));break}a++}}return!0}},{key:"SetPartialDeclaration",value:function(t,r){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=i.device.ext,s=i.device.gl,u=[],l=0,c=0;c0){a||(s.disableVertexAttribArray(f.location),s.vertexAttrib4f(f.location,0,0,0,0));break}if(++l>=this._elementsSorted.length)return a||(s.disableVertexAttribArray(f.location),s.vertexAttrib4f(f.location,0,0,0,0)),u}}return u}},{key:"ResetInstanceDivisors",value:function(e){if(e)for(var t=0;t2&&void 0!==arguments[2]?arguments[2]:0;return e.usaget.usage?1:e.usageIndex+rt.usageIndex?1:0}}]),e}()).Type={POSITION:0,COLOR:1,NORMAL:2,TANGENT:3,BINORMAL:4,TEXCOORD:5,BLENDWEIGHT:6,BLENDINDICES:7}},function(e,t,r){(function(t){WebGLDebugUtils=function(){var e;void 0===e&&(e=t);var r=function(t){e.console&&e.console.error?e.console.error(t):function(t){e.console&&e.console.log&&e.console.log(t)}(t)},n={enable:{1:{0:!0}},disable:{1:{0:!0}},getParameter:{1:{0:!0}},drawArrays:{3:{0:!0}},drawElements:{4:{0:!0,2:!0}},createShader:{1:{0:!0}},getShaderParameter:{2:{1:!0}},getProgramParameter:{2:{1:!0}},getShaderPrecisionFormat:{2:{0:!0,1:!0}},getVertexAttrib:{2:{1:!0}},vertexAttribPointer:{6:{2:!0}},bindTexture:{2:{0:!0}},activeTexture:{1:{0:!0}},getTexParameter:{2:{0:!0,1:!0}},texParameterf:{3:{0:!0,1:!0}},texParameteri:{3:{0:!0,1:!0,2:!0}},copyTexImage2D:{8:{0:!0,2:!0}},copyTexSubImage2D:{8:{0:!0}},generateMipmap:{1:{0:!0}},bindBuffer:{2:{0:!0}},getBufferParameter:{2:{0:!0,1:!0}},pixelStorei:{2:{0:!0,1:!0}},bindRenderbuffer:{2:{0:!0}},bindFramebuffer:{2:{0:!0}},checkFramebufferStatus:{1:{0:!0}},framebufferRenderbuffer:{4:{0:!0,1:!0,2:!0}},framebufferTexture2D:{5:{0:!0,1:!0,2:!0}},getFramebufferAttachmentParameter:{3:{0:!0,1:!0,2:!0}},getRenderbufferParameter:{2:{0:!0,1:!0}},renderbufferStorage:{4:{0:!0,1:!0}},clear:{1:{0:{enumBitwiseOr:["COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT"]}}},depthFunc:{1:{0:!0}},blendFunc:{2:{0:!0,1:!0}},blendFuncSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},blendEquation:{1:{0:!0}},blendEquationSeparate:{2:{0:!0,1:!0}},stencilFunc:{3:{0:!0}},stencilFuncSeparate:{4:{0:!0,1:!0}},stencilMaskSeparate:{2:{0:!0}},stencilOp:{3:{0:!0,1:!0,2:!0}},stencilOpSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},cullFace:{1:{0:!0}},frontFace:{1:{0:!0}},drawArraysInstancedANGLE:{4:{0:!0}},drawElementsInstancedANGLE:{5:{0:!0,2:!0}},blendEquationEXT:{1:{0:!0}},bufferData:{3:{0:!0,2:!0},4:{0:!0,2:!0},5:{0:!0,2:!0}},bufferSubData:{3:{0:!0},4:{0:!0},5:{0:!0}},copyBufferSubData:{5:{0:!0,1:!0}},getBufferSubData:{3:{0:!0},4:{0:!0},5:{0:!0}},blitFramebuffer:{10:{8:{enumBitwiseOr:["COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT"]},9:!0}},framebufferTextureLayer:{5:{0:!0,1:!0}},invalidateFramebuffer:{2:{0:!0}},invalidateSubFramebuffer:{6:{0:!0}},readBuffer:{1:{0:!0}},getInternalformatParameter:{3:{0:!0,1:!0,2:!0}},renderbufferStorageMultisample:{5:{0:!0,2:!0}},texStorage2D:{5:{0:!0,2:!0}},texStorage3D:{6:{0:!0,2:!0}},texImage2D:{9:{0:!0,2:!0,6:!0,7:!0},6:{0:!0,2:!0,3:!0,4:!0},10:{0:!0,2:!0,6:!0,7:!0}},texImage3D:{10:{0:!0,2:!0,7:!0,8:!0},11:{0:!0,2:!0,7:!0,8:!0}},texSubImage2D:{9:{0:!0,6:!0,7:!0},7:{0:!0,4:!0,5:!0},10:{0:!0,6:!0,7:!0}},texSubImage3D:{11:{0:!0,8:!0,9:!0},12:{0:!0,8:!0,9:!0}},copyTexSubImage3D:{9:{0:!0}},compressedTexImage2D:{7:{0:!0,2:!0},8:{0:!0,2:!0},9:{0:!0,2:!0}},compressedTexImage3D:{8:{0:!0,2:!0},9:{0:!0,2:!0},10:{0:!0,2:!0}},compressedTexSubImage2D:{8:{0:!0,6:!0},9:{0:!0,6:!0},10:{0:!0,6:!0}},compressedTexSubImage3D:{10:{0:!0,8:!0},11:{0:!0,8:!0},12:{0:!0,8:!0}},vertexAttribIPointer:{5:{2:!0}},drawArraysInstanced:{4:{0:!0}},drawElementsInstanced:{5:{0:!0,2:!0}},drawRangeElements:{6:{0:!0,4:!0}},readPixels:{7:{4:!0,5:!0},8:{4:!0,5:!0}},clearBufferfv:{3:{0:!0},4:{0:!0}},clearBufferiv:{3:{0:!0},4:{0:!0}},clearBufferuiv:{3:{0:!0},4:{0:!0}},clearBufferfi:{4:{0:!0}},beginQuery:{2:{0:!0}},endQuery:{1:{0:!0}},getQuery:{2:{0:!0,1:!0}},getQueryParameter:{2:{1:!0}},samplerParameteri:{3:{1:!0,2:!0}},samplerParameterf:{3:{1:!0}},getSamplerParameter:{2:{1:!0}},fenceSync:{2:{0:!0,1:{enumBitwiseOr:[]}}},clientWaitSync:{3:{1:{enumBitwiseOr:["SYNC_FLUSH_COMMANDS_BIT"]}}},waitSync:{3:{1:{enumBitwiseOr:[]}}},getSyncParameter:{2:{1:!0}},bindTransformFeedback:{2:{0:!0}},beginTransformFeedback:{1:{0:!0}},transformFeedbackVaryings:{3:{2:!0}},bindBufferBase:{3:{0:!0}},bindBufferRange:{5:{0:!0}},getIndexedParameter:{2:{0:!0}},getActiveUniforms:{3:{2:!0}},getActiveUniformBlockParameter:{3:{2:!0}}},i=null,a=null;function o(e){if(null==i)for(var t in i={},a={},e)"number"==typeof e[t]&&(i[e[t]]=t,a[t]=e[t])}function s(){if(null==i)throw"WebGLDebugUtils.init(ctx) not called"}function u(e){s();var t=i[e];return void 0!==t?"gl."+t:"/*UNKNOWN WebGL ENUM*/ 0x"+e.toString(16)}function l(e,t,r,i){var o;if(void 0!==(o=n[e])&&(void 0!==(o=o[t])&&o[r])){if("object"==typeof o[r]&&void 0!==o[r].enumBitwiseOr){for(var s=o[r].enumBitwiseOr,l=0,c=[],f=0;f=0&&setTimeout(function(){t.restoreContext()},v)},0)}},t.restoreContext=function(){u&&a.length&&setTimeout(function(){if(!d)throw"can not restore. webglcontestlost listener did not call event.preventDefault";!function(){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:0;this.isPlaying=!0,this.scaledTime=e}},{key:"Stop",value:function(){this.isPlaying=!1}},{key:"Update",value:function(e){if(this.isPlaying){this.scaledTime+=e*this.scale;for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:this;this._copyFunc&&(this._copyFunc.call(this),"OnValueChanged"in this.destinationObject&&this.destinationObject.OnValueChanged(e,[this.destinationAttribute]))}}],[{key:"CopyValueToValue",value:function(){this.destinationObject[this.destinationAttribute]=this.sourceObject[this.sourceAttribute]*this.scale+this.offset[0]}},{key:"CopyArray",value:function(){for(var e=Math.min(this.destinationObject[this.destinationAttribute].length,this.sourceObject[this.sourceAttribute].length),t=0;t0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.value=a.util.isArrayLike(r)?r[0]:r,n.constantBuffer=null,n.offset=null,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.Tw2Parameter),n(t,[{key:"SetValue",value:function(e){this.value=e,this.OnValueChanged()}},{key:"GetValue",value:function(){return this.value}},{key:"Apply",value:function(e,t){e[t]=this.value}},{key:"EqualsValue",value:function(e){return this.value===e}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.SetValue(e.GetValue())}}],[{key:"isValue",value:function(e){return a.util.isNumber(e)}}]),t}()).constantBufferSize=1},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MatrixParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.mat4.create();return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"Compose",value:function(e,t,r){"value"in e&&(e=e.value),"value"in t&&(t=t.value),"value"in r&&(r=r.value),i.mat4.fromRotationTranslationScale(this.value,e,t,r),this.OnValueChanged()}},{key:"Decompose",value:function(e,t,r){i.mat4.getRotation("value"in e?e.value:e,this.value),i.mat4.getTranslation("value"in t?t.value:t,this.value),i.mat4.getScaling("value"in r?r.value:r,this.value),"OnValueChanged"in e&&e.OnValueChanged(),"OnValueChanged"in t&&t.OnValueChanged(),"OnValueChanged"in r&&r.OnValueChanged()}},{key:"x",get:function(){return this.GetIndexValue(12)},set:function(e){this.SetIndexValue(12,e)}},{key:"y",get:function(){return this.GetIndexValue(13)},set:function(e){this.SetIndexValue(13,e)}},{key:"z",get:function(){return this.GetIndexValue(14)},set:function(e){this.SetIndexValue(14,e)}}]),t}()).constantBufferSize=16},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TransformParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.scaling=i.vec3.fromValues(1,1,1),r.rotationCenter=i.vec3.create(),r.rotation=i.quat.create(),r.translation=i.vec3.create(),r.transform=i.mat4.create(),r.worldTransform=i.mat4.create(),r.constantBuffer=null,r.offset=null,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2Parameter),n(t,[{key:"Initialize",value:function(){this.OnValueChanged()}},{key:"GetValue",value:function(e){return e?Array.from(this.transform):new Float32Array(this.transform)}},{key:"OnValueChanged",value:function(e,r){i.mat4.fromRotationTranslationScaleOrigin(this.transform,this.rotation,this.translation,this.scaling,this.rotationCenter),i.mat4.transpose(this.worldTransform,this.transform),function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,r,n)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(n):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"OnValueChanged",this).call(this,e,r)}},{key:"Bind",value:function(e,t,r){return!this.constantBuffer&&r>=this.size&&(this.constantBuffer=e,this.offset=t,this.Apply(e,t,r),!0)}},{key:"Apply",value:function(e,t,r){r>=this.constructor.constantBufferSize?e.set(this.worldTransform,t):e.set(this.worldTransform.subarray(0,r),t)}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),i.quat.copy(this.rotation,e.rotation),i.vec3.copy(this.translation,e.translation),i.vec3.copy(this.scaling,e.scaling),i.vec3.copy(this.rotationCenter,e.rotationCenter),this.OnValueChanged()}}]),t}()).constantBufferSize=16},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VariableParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.variableName=r,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2Parameter),n(t,[{key:"GetValue",value:function(e){return i.store.GetVariableValue(this.variableName,e)}},{key:"Apply",value:function(e,t,r){this.variable&&this.variable.Apply(e,t,r)}},{key:"AddCallback",value:function(){return!1}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.variableName=e.variableName}},{key:"variable",get:function(){return i.store.GetVariable(this.variableName)}},{key:"size",get:function(){return this.variable?this.variable.size:0}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector2Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec2.fromValues(1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}}]),t}()).constantBufferSize=2},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector3Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec3.fromValues(1,1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}},{key:"z",get:function(){return this.GetIndexValue(2)},set:function(e){this.SetIndexValue(2,e)}}]),t}()).constantBufferSize=3},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector4Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec4.fromValues(1,1,1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}},{key:"z",get:function(){return this.GetIndexValue(2)},set:function(e){this.SetIndexValue(2,e)}},{key:"w",get:function(){return this.GetIndexValue(3)},set:function(e){this.SetIndexValue(3,e)}}]),t}()).constantBufferSize=4},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(102);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(46);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(24);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveBasicPerObjectData=t.Tw2BasicPerObjectData=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"DeclareFromObject",this).call(this,e),e.FFEData&&(this.perObjectFFEData=new s.Tw2RawData(e.FFEData))}}]),t}();t.EveBasicPerObjectData=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2BlendShapeData=void 0;var n=r(9);t.Tw2BlendShapeData=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="",this.declaration=new n.Tw2VertexDeclaration,this.buffers=[],this.indexes=null,this.weightProxy=null}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2GeometryAnimation=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="",this.duration=0,this.trackGroups=[]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2GeometryBone=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[];return i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"GetResources",this).call(this,e),this.instanceGeometryResource&&"GetResources"in this.instanceGeometryResource&&this.instanceGeometryResource.GetResources(e),e}},{key:"RenderAreas",value:function(e,t,r,n,i){if(this.IsGood()){var a=this.instanceGeometryResource.GetInstanceBuffer(this.instanceMeshIndex);a&&this.geometryResource.RenderAreasInstanced(e,t,r,n,i,a,this.instanceGeometryResource.GetInstanceDeclaration(this.instanceMeshIndex),this.instanceGeometryResource.GetInstanceStride(this.instanceMeshIndex),this.instanceGeometryResource.GetInstanceCount(this.instanceMeshIndex))}}}],[{key:"GetAreaBatches",value:function(e,t,r,n,i){for(var a=0;a0&&void 0!==arguments[0]?arguments[0]:[],t=0;tf.duration&&(c.callback&&c.callback(this,c),c.cycle?c.time=c.time%f.duration:(c.isPlaying=!1,c.time=f.duration));for(var h=0;h=0){var i=this.models[t].bones[n.boneRes.parentIndex];e.AddLine([n.worldTransform[12],n.worldTransform[13],n.worldTransform[14]],[i.worldTransform[12],i.worldTransform[13],i.worldTransform[14]])}}}}],[{key:"AddModel",value:function(e,t){for(var r=0;r7)return i.logger.log("res.error",{log:"error",src:["Tw2EffectRes","CreateProgram"],msg:"Invalid version of effect file",type:"shader.effectversion",path:this.path,value:o}),void this.PrepareFinished(!1);var s=void 0,u=void 0;if(o<5){if(0===(s=t.ReadUInt32()))return i.logger.log("res.error",{log:"error",src:["Tw2EffectRes","CreateProgram"],msg:"File contains no compiled effects",path:this.path,type:"shader.effectheadersize",value:0}),void this.PrepareFinished(!1);t.ReadUInt32();var l=t.ReadUInt32();t.cursor=8+3*s*4,u=t.ReadUInt32(),this.stringTableOffset=t.cursor,r=String.fromCharCode.apply(null,t.data.subarray(t.cursor,t.cursor+u)),t.cursor=l}else{u=t.ReadUInt32(),this.stringTableOffset=t.cursor,r=String.fromCharCode.apply(null,t.data.subarray(t.cursor,t.cursor+u)),t.cursor+=u;for(var c=t.ReadUInt8(),f=0;f6&&(h=t.ReadUInt8());for(var p=0;p6&&(d.name=l()),this.techniques[d.name]=d;for(var v=t.ReadUInt8(),m=0;m=3&&(t.ReadUInt32(),t.ReadUInt32(),t.ReadUInt32()),E.constantSize=0;for(var C=t.ReadUInt32(),I=0;IE.constantSize&&(E.constantSize=x)}}var L=t.ReadUInt32()/4;if(E.constantValues=new Float32Array(L),r<5)for(var B=0;B=4?l():"";t.ReadUInt8();var X=t.ReadUInt8(),K=t.ReadUInt8(),Q=t.ReadUInt8(),Z=t.ReadUInt8(),J=t.ReadUInt8(),$=t.ReadUInt8();t.ReadFloat32();var ee=t.ReadUInt8();t.ReadUInt8();var te=i.quat.create();te[0]=t.ReadFloat32(),te[1]=t.ReadFloat32(),te[2]=t.ReadFloat32(),te[3]=t.ReadFloat32(),t.ReadFloat32(),t.ReadFloat32(),r<4&&t.ReadUInt8();var re=new o.Tw2SamplerState;if(re.registerIndex=Y,re.name=W,1===X){switch(Q){case 0:re.minFilter=f.NEAREST;break;case 1:re.minFilter=f.NEAREST_MIPMAP_NEAREST;break;default:re.minFilter=f.NEAREST_MIPMAP_LINEAR}re.minFilterNoMips=f.NEAREST}else{switch(Q){case 0:re.minFilter=f.LINEAR;break;case 1:re.minFilter=f.LINEAR_MIPMAP_NEAREST;break;default:re.minFilter=f.LINEAR_MIPMAP_LINEAR}re.minFilterNoMips=f.LINEAR}re.magFilter=1===K?f.NEAREST:f.LINEAR,re.addressU=c[Z],re.addressV=c[J],re.addressW=c[$],3!==X&&3!==K&&3!==Q||(re.anisotropy=Math.max(ee,1));for(var ne=0;ne=3&&t.ReadUInt8(),y.stages[T]=E}y.states=[];for(var ie=t.ReadUInt8(),ae=0;ae=0){var p=new a.Tw2VertexElement(r.stages[0].inputDefinition.elements[f].usage,r.stages[0].inputDefinition.elements[f].usageIndex);p.location=h,s.input.elements.push(p)}}s.input.RebuildHash(),s.shadowStateInt=o.getUniformLocation(s.program,"ssi"),s.shadowStateFloat=o.getUniformLocation(s.program,"ssf"),s.shadowStateYFlip=o.getUniformLocation(s.program,"ssyf"),o.uniform3f(s.shadowStateYFlip,0,0,1),s.volumeSlices=[];for(var d=0;d=this.meshes.length)return!1;var c=i.device,f=c.ext,h=c.gl,p=this.meshes[e],d=n.GetPassCount(a);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,p.indexes);for(var v=0;v=this.meshes.length)return!1;var o=i.device,s=o.gl,u=this.meshes[e]||this.meshes[0],l=n.GetPassCount(a);s.bindBuffer(s.ARRAY_BUFFER,u.buffer),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,u.indexes);for(var c=0;c=this.meshes.length)return!1;var o=i.device,s=o.gl,u=this.meshes[e],l=n.GetPassCount(a);s.bindBuffer(s.ARRAY_BUFFER,u.buffer),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,u.indexes);for(var c=0;c=0){var i=this.models[t].skeleton.bones[n.parentIndex];e.AddLine([n.worldTransform[12],n.worldTransform[13],n.worldTransform[14]],[i.worldTransform[12],i.worldTransform[13],i.worldTransform[14]],[0,.7,0,1],[0,.7,0,1])}}}},{key:"Unload",value:function(){for(var e=0;e>5),s.offset=4*n,t.elements[a]=s,n+=s.elements}t.RebuildHash(),t.stride=4*n;var u=e.ReadUInt32();if(0===u)return null;for(var l=new Float32Array(n*u),c=0,f=0;f0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.cycle=e,this._onEnded=t,this.video&&this._playable?(this.video.loop=this.cycle,this.video.play()):this.playOnLoad=!0}},{key:"Pause",value:function(){this.video?this.video.pause():this.playOnLoad=!1}},{key:"Prepare",value:function(e){var t=i.device.gl;switch(e){case"mp4":case"webm":case"ogg":this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this.video),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.bindTexture(t.TEXTURE_2D,null),this.width=this.video.width,this.height=this.video.height,this.video.loop=this.cycle,this.playOnLoad&&this.video.play(),this.PrepareFinished(!0)}}},{key:"DoCustomLoad",value:function(e){var t=this,r=i.resMan.constructor.GetPathExt(e);return this.LoadStarted(),i.resMan._pendingLoads++,this.video=document.createElement("video"),this.video.crossOrigin="anonymous",this.video.muted=!0,this.video.onerror=function(){i.resMan._pendingLoads--,i.logger.log("res.error",{log:"error",src:["Tw2TextureRes","DoCustomLoad"],msg:"Error loading resource",type:"http.error",path:e}),t.LoadFinished(!1),t.PrepareFinished(!1),t.video=null},this.video.oncanplay=function(){t._playable=!0,t.video.oncanplay=null,i.resMan._pendingLoads--,i.resMan._prepareQueue.push([t,r,null]),t.LoadFinished(!0)},this.video.onended=function(){t._isPlaying=!1,t._onEnded&&t._onEnded(t)},this.video.onpause=function(){t._isPlaying=!1,t._onPause&&t._onPause(t)},this.video.onplaying=function(){t._isPlaying=!0,t._onPlaying&&t._onPlaying(t)},this.video.src=e,!0}},{key:"Unload",value:function(){return this.texture&&(i.device.gl.deleteTexture(this.texture),this.texture=null),this._isPlaying=!1,this._playable=!1,this.playOnLoad=!0,this.video=null,!0}},{key:"Bind",value:function(e){var t=i.device,r=t.gl;this.KeepAlive();var n=e.samplerType;n===r.TEXTURE_2D&&(this.texture?(this._currentTime=this.video.currentTime,r.bindTexture(r.TEXTURE_2D,this.texture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,this.video),r.bindTexture(r.TEXTURE_2D,null),r.bindTexture(n,this.texture),e.hash!==this._currentSampler&&(e.Apply(!1),this._currentSampler=e.hash)):r.bindTexture(r.TEXTURE_2D,t.GetFallbackTexture()))}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(123);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PostProcess=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Undefined error";n(this,t);var a=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return"string"==typeof e?e={message:e}:e.message=e.message||r,a.message=e.message,a.name=a.constructor.name,a.data=e,s?Error.captureStackTrace(a,t):a.stack=new Error(e.message).stack,a}return a(t,o(Error)),t}();u.isError=!0;t.HTTPRequestError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Communication error while requesting resource"))}return a(t,u),t}(),t.HTTPRequestSendError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Communication send error while requesting resource"))}return a(t,u),t}(),t.HTTPInstanceError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Could not create an XML HTTP instance"))}return a(t,u),t}(),t.HTTPStatusError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Communication status error while loading resource"))}return a(t,u),t}(),t.HTTPReadyStateError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Communication ready state error while loading resource"))}return a(t,u),t}(),t.Tw2XMLBinaryError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Invalid binary"))}return a(t,u),t}(),t.Tw2XMLObjectTypeUndefinedError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"XML Object with undefined type"))}return a(t,u),t}(),t.Tw2GeometryMeshParticleElementError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Input geometry mesh lacks element required by particle system"))}return a(t,u),t}(),t.Tw2GeometryMeshElementComponentError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Input geometry mesh elements do not have the required number of components"))}return a(t,u),t}(),t.Tw2GeometryMeshInvalidBoneError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Geometry mesh has invalid bone name for model"))}return a(t,u),t}(),t.Tw2GeometryMeshEffectBindError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Error binding geometry mesh to effect"))}return a(t,u),t}(),t.Tw2GeometryFileTypeError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Invalid geometry file type"))}return a(t,u),t}(),t.Tw2ResourcePrefixUnregisteredError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Unregistered resource prefix"))}return a(t,u),t}(),t.Tw2ResourcePrefixUndefinedError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Undefined resource prefix"))}return a(t,u),t}(),t.Tw2ResourceExtensionUnregisteredError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Unregistered resource extension"))}return a(t,u),t}(),t.Tw2ResourceExtensionUndefinedError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Undefined resource extension"))}return a(t,u),t}(),t.Tw2ShaderVersionError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Invalid version of effect file"))}return a(t,u),t}(),t.Tw2ShaderHeaderSizeError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Effect file contains no compiled effects"))}return a(t,u),t}(),t.Tw2ShaderPermutationValueError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Invalid shader permutation value"))}return a(t,u),t}(),t.Tw2ShaderCompileError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Error compiling shader"))}return a(t,u),t}(),t.Tw2ShaderLinkError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Error linking shaders"))}return a(t,u),t}(),t.Tw2DeclarationValueTypeError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Invalid declaration value type"))}return a(t,u),t}(),t.Tw2SingleInstantiationError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Class can only be instantiated once"))}return a(t,u),t}(),t.Tw2AbstractClassMethodError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Abstract class method not implemented directly on child class"))}return a(t,u),t}(),t.Tw2FeatureNotImplementedError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Feature not implemented"))}return a(t,u),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2Float=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.value=0}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Frustum=void 0;var n=function(){function e(e,t){for(var r=0;r=a.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.vec4.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.vec4.copy(r,a.value);case t.Extrapolation.GRADIENT:return i.vec4.scaleAndAdd(r,a.value,a.right,e-a.time);default:e%=a.time}else if(e<0||e=o.time||ethis.length){if(!this.cycle)return this.reversed?i.vec4.copy(t,this.startValue):i.vec4.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec4.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a[2]=o[2]+(s[2]-o[2])*(e/l),a[3]=o[3]+(s[3]-o[3])*(e/l),a;default:return a}}}]),t}();c.inputDimension=4,c.outputDimension=4,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2EventCurve=t.Tw2EventKey=void 0;var n=function(){function e(e,t){for(var r=0;r=this.keys[this._currentKey].time;)this.value=this.keys[this._currentKey].value,++this._currentKey}}]),t}();l.dimension=1,l.outputDimension=1,l.valueProperty="value",l.curveType=i.Tw2Curve.Type.CURVE,l.Key=u,l.Extrapolation={NONE:0,CYCLE:3}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PerlinCurve=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?(t[0]=this.startValue[0],t[1]=this.startValue[1],t[2]=this.startValue[2],t):(t[0]=this.endValue[0],t[1]=this.endValue[1],t[2]=this.endValue[2],t);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var i=0;i+1e));++i);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){a[0]=this.startValue[0],a[1]=this.startValue[1],a[2]=this.startValue[2];var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.SPHERICAL_LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),i.quat.slerp(a,o,s,e/l),a;default:return a}}}]),t}();c.inputDimension=4,c.outputDimension=4,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,SPHERICAL_LINEAR:4}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2RandomConstantCurve=void 0;var n=function(){function e(e,t){for(var r=0;r=this.states[this.states.length-1].time)r=this.states.length-1;else for(;r+1=this.states[r].time&&e=s.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.quat.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.quat.copy(r,s.value);default:e%=s.time}else if(e<0||e=u.time||e0;p--){var d=i.num.biCumulative(c,p);d>1&&i.quat.multiply(r,f,h[p]),r[0]=-h[p-1][0],r[1]=-h[p-1][1],r[2]=-h[p-1][2],r[3]=h[p-1][3],i.quat.multiply(r,r,h[p]),i.quat.pow(r,r,d),i.quat.multiply(f,f,r)}return i.quat.multiply(r,f,l.value);case t.Interpolation.SLERP:return i.quat.slerp(r,l.value,u.value,c);default:return i.quat.sqlerp(r,l.value,l.right,u.left,u.value,c)}}}]),t}();c.outputDimention=4,c.inputDimension=4,c.valueProperty="value",c.curveType=a.Tw2Curve.Type.CURVE,c.Child=l,c.Extrapolation={NONE:0,CONSTANT:1,GRADIENT:2,CYCLE:3},c.Interpolation={NONE:0,CONSTANT:1,LINEAR:2,HERMITE:3,SLERP:5,SQUAD:6}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2ScalarCurve=t.Tw2ScalarKey=void 0;var n=function(){function e(e,t){for(var r=0;r=n.time)switch(this.extrapolation){case t.Extrapolation.NONE:return this.value;case t.Extrapolation.CONSTANT:return n.value;case t.Extrapolation.GRADIENT:return n.value+(e-n.time)*n.right;default:e%=n.time}else if(e<0||e=i.time||ethis.length){if(!this.cycle)return this.reversed?this.startValue:this.endValue;e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null);var t=this.keys[0],r=this.keys[this.keys.length-1];if(e<=t.time)return this.Interpolate(e,null,t);if(e>=r.time)return this.Interpolate(e,r,null);for(var n=0;n+1e));++n);return this.Interpolate(e,t,r)}},{key:"Interpolate",value:function(e,r,n){var i=this.startValue,a=this.endValue,o=this.interpolation,s=this.length;switch(null!==r&&(o=r.interpolation,e-=r.time),o){case t.Interpolation.LINEAR:return r&&n?(i=r.value,a=n.value,s=n.time-r.time):n?(a=n.value,s=n.time):r&&(i=r.value,s=this.length-r.time),i+e/s*(a-i);case t.Interpolation.HERMITE:var u=this.startTangent,l=this.endTangent;r&&n?(i=r.value,u=r.rightTangent,a=n.value,l=n.leftTangent,s=n.time-r.time):n?(a=n.value,l=n.leftTangent,s=n.time):r&&(i=r.value,u=r.rightTangent,s=this.length-r.time);var c=e/s,f=c*c,h=f*c,p=-2*h+3*f,d=h-f;return i*(1-p)+a*p+u*(c+d-f)+l*d;default:return this.startValue}}}]),t}();l.inputDimension=1,l.outputDimension=1,l.valueProperty="currentValue",l.curveType=i.Tw2Curve.Type.CURVE2,l.Key=u,l.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SineCurve=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?i.vec2.copy(t,this.startValue):i.vec2.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec2.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a;case t.Interpolation.HERMITE:var c=this.startTangent,f=this.endTangent;r&&n?(o=r.value,c=r.rightTangent,s=n.value,f=n.leftTangent,l=n.time-r.time):n?(s=n.value,f=n.leftTangent,l=n.time):r&&(o=r.value,c=r.rightTangent,l=this.length-r.time);var h=e/l,p=h*h,d=p*h,v=-2*d+3*p,m=1-v,y=d-p,b=h+y-p;return a[0]=o[0]*m+s[0]*v+c[0]*b+f[0]*y,a[1]=o[1]*m+s[1]*v+c[1]*b+f[1]*y,a;default:return a}}}]),t}();c.inputDimension=2,c.outputDimension=2,c.valueProperty="value",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector3Curve=t.Tw2Vector3Key=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?i.vec3.copy(t,this.startValue):i.vec3.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec3.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a[2]=o[2]+(s[2]-o[2])*(e/l),a;case t.Interpolation.HERMITE:var c=this.startTangent,f=this.endTangent;r&&n?(o=r.value,c=r.rightTangent,s=n.value,f=n.leftTangent,l=n.time-r.time):n?(s=n.value,f=n.leftTangent,l=n.time):r&&(o=r.value,c=r.rightTangent,l=this.length-r.time);var h=e/l,p=h*h,d=p*h,v=-2*d+3*p,m=1-v,y=d-p,b=h+y-p;return a[0]=o[0]*m+s[0]*v+c[0]*b+f[0]*y,a[1]=o[1]*m+s[1]*v+c[1]*b+f[1]*y,a[2]=o[2]*m+s[2]*v+c[2]*b+f[2]*y,a;default:return a}}}]),t}();c.inputDimension=3,c.outputDimension=3,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VectorCurve=t.Tw2VectorKey=void 0;var n=function(){function e(e,t){for(var r=0;r=a.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.vec3.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.vec3.copy(r,a.value);case t.Extrapolation.GRADIENT:return i.vec3.scaleAndAdd(r,a.value,a.right,e-a.time);default:e%=a.time}else if(e<0||e=o.time||e=0&&this._UpdateValue(e))}}function a(){this._id=n.util.generateID(),this.translation=n.vec3.create(),this.rotation=n.quat.create(),this.rotation[3]=1,this.scale=n.vec3.create();var e=null,t=null,r=null,i=n.mat4.create();this._TracksReady=function(){return e||t||r},this._ApplyTracks=function(n,i){for(var a=0;athis.duration||e<0||(i.curve.evaluate(this.positionCurve,e,this.translation,this.cycle,this.duration),i.curve.evaluate(this.orientationCurve,e,this.rotation,this.cycle,this.duration),i.quat.normalize(this.rotation,this.rotation),i.curve.evaluate(this.scaleCurve,e,this.scaleShear,this.cycle,this.duration),i.mat4.getScaling(this.scale,this.scaleCurve))))}},{key:"FindTracks",value:function(){for(var e=null,t=0;t=0&&(this.length=this.animationEngine.GetLength(this.xIndex)),this.yIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.yIndex))),this.zIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.zIndex))))}}]),t}();o.outputDimension=3,o.valueProperty="eulerValue",o.curveType=a.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaScalarCurve=void 0;var n=function(){function e(e,t){for(var r=0;r=0&&(this.length=this.animationEngine.GetLength(this.index))}}]),t}();a.outputDimension=1,a.valueProperty="value",a.curveType=i.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaVector3Curve=void 0;var n=function(){function e(e,t){for(var r=0;r=0&&(this.length=this.animationEngine.GetLength(this.xIndex)),this.yIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.yIndex))),this.zIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.zIndex))))}}]),t}();o.outputDimension=3,o.valueProperty="value",o.curveType=a.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaAnimationEngine=void 0;var n=function(){function e(e,t){for(var r=0;ri[e.AnimCurveFields.END_TIME]?i[e.AnimCurveFields.POST_INFINITY]===e.INFINITY?i[e.AnimCurveFields.END_VALUE]:this._EvaluateInfinities(i,o,a,r,!1):this._EvaluateImpl(i,o,a,r)}},{key:"_EvaluateImpl",value:function(t,r,n,i){var a=!1,o=null,s=null,u=void 0;if(this._evalCache[this._currentCurveIndex]>=0)if(s=n+this._evalCache[this._currentCurveIndex],this._evalCache[this._currentCurveIndex]r[s][e.AnimSegment.TIME]){if(i===r[o=n+this._evalCache[this._currentCurveIndex]+1][e.AnimSegment.TIME])return this._evalCache[this._currentCurveIndex]++,r[o][e.AnimSegment.VALUE];i0&&ir[l][e.AnimSegment.TIME])u=this._evalCache[this._currentCurveIndex],a=!0;else if(i===r[l][e.AnimSegment.TIME])return this._evalCache[this._currentCurveIndex]--,r[l][e.AnimSegment.VALUE]}if(!a){var c=this._Find(t,i,r,n);if(u=c[1],c[0]||0===u)return u===t[e.AnimCurveFields.NUM_SEGMENTS]?(u--,this._evalCache[this._currentCurveIndex]=u,t[e.AnimCurveFields.END_VALUE]):(this._evalCache[this._currentCurveIndex]=u,r[n+u][e.AnimSegment.VALUE]);if(u===t[e.AnimCurveFields.NUM_SEGMENTS]+1)return this._evalCache[this._currentCurveIndex]=0,t[e.AnimCurveFields.END_VALUE]}if(this._evalCache[this._currentCurveIndex]!==u-1&&(this._evalCache[this._currentCurveIndex]=u-1,s=n+this._evalCache[this._currentCurveIndex],null===o&&(o=n+u)),t[e.AnimCurveFields.IS_WEIGHTED]){var f=r[s];if(f[e.BezierSegment.IS_STEP])return f[e.BezierSegment.VALUE];if(f[e.BezierSegment.IS_STEP_NEXT])return null===o?t[e.AnimCurveFields.END_VALUE]:r[o][e.BezierSegment.VALUE];var h=t[e.AnimCurveFields.END_TIME];return this._evalCache[this._currentCurveIndex]+10){s=0,u=a-1;do{if(r<(c=(o=s+u>>1)c))return[!0,l=o];s=o+1}}while(s<=u);l=s}return[!1,l]}},{key:"GetNumberOfCurves",value:function(){return this.curves.length}},{key:"GetLength",value:function(t){if(t<0||t>=this.curves.length)return 0;var r=this.curves[t],n=void 0;return n=r[e.AnimCurveFields.IS_WEIGHTED]?this.bezierSegments[r[e.AnimCurveFields.SEGMENT_OFFSET]]:this.hermiteSegments[r[e.AnimCurveFields.SEGMENT_OFFSET]],r[e.AnimCurveFields.END_TIME]-n[e.AnimSegment.TIME]}}]),e}();a.AnimCurveFields={NUM_SEGMENTS:0,SEGMENT_OFFSET:1,END_TIME:2,END_VALUE:3,IN_TANGENT:4,OUT_TANGENT:5,PRE_INFINITY:6,POST_INFINITY:7,IS_WEIGHTED:8},a.AnimSegment={TIME:0,VALUE:1},a.HermiteSegment={TIME:0,VALUE:1,COEFF:2,IS_STEP:3,IS_STEP_NEXT:4},a.BezierSegment={TIME:0,VALUE:1,COEFF:2,POLYY:3,IS_STEP:4,IS_STEP_NEXT:5,IS_LINEAR:6},a.INFINITY=0},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(59);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(164);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(61);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(64);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(182);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(183);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveChildBillboard=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t0&&void 0!==arguments[0]?arguments[0]:[];this.mesh&&this.mesh.GetResources(e);for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return a.util.perArrayChild(this.opaqueEffects,"GetResources",e),a.util.perArrayChild(this.decalEffects,"GetResources",e),a.util.perArrayChild(this.transparentEffects,"GetResources",e),a.util.perArrayChild(this.additiveEffects,"GetResources",e),a.util.perArrayChild(this.distortionEffects,"GetResources",e),e}},{key:"Update",value:function(e){this.update&&this.curveSet&&this.curveSet.Update(e)}},{key:"GetBatches",value:function(e,t,r,n){if(this.display&&n&&n.IsGood())for(var a=this.GetEffects(e),o=0;o0&&void 0!==arguments[0]?arguments[0]:[];return this.source&&this.source.GetResources&&this.source.GetResources(e),this.dest&&this.dest.GetResources&&this.dest.GetResources(e),this.sourceObject&&this.sourceObject.GetResources&&this.sourceObject.GetResources(e),this.destObject&&this.destObject.GetResources&&this.destObject.GetResources(e),this.stretchObject&&this.stretchObject.GetResources&&this.stretchObject.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(){if(this.display){var t=e.global,r=i.vec3.subtract(t.vec3_0,this._destinationPosition,this._sourcePosition),n=i.mat4.identity(t.mat4_0),a=i.vec3.set(t.vec3_1,0,0,0),o=i.vec3.set(t.vec3_2,0,0,0),s=i.mat4.identity(t.mat4_1),u=i.vec3.length(r);i.vec3.normalize(r,r),this._useTransformsForStretch?(i.mat4.rotateX(n,n,-Math.PI/2),i.mat4.multiply(n,this._sourceTransform,n)):(Math.abs(r[1])>.9?o[2]=1:o[1]=1,i.vec3.cross(a,o,r),i.vec3.normalize(a,a),i.vec3.cross(o,r,a),n[0]=a[0],n[1]=a[1],n[2]=a[2],n[4]=-r[0],n[5]=-r[1],n[6]=-r[2],n[8]=o[0],n[9]=o[1],n[10]=o[2]),this.destObject&&this._displayDestObject&&(i.mat4.setTranslation(n,this._destinationPosition),this.destObject.UpdateViewDependentData(n)),this.sourceObject&&this._displaySourceObject&&(this._useTransformsForStretch?(i.mat4.identity(n),i.mat4.rotateX(n,n,-Math.PI/2),i.mat4.multiply(n,this._sourceTransform,n)):i.mat4.setTranslation(n,this._sourcePosition),this.sourceObject.UpdateViewDependentData(n)),this.stretchObject&&(this._useTransformsForStretch?(i.mat4.identity(n),i.mat4.scale(n,n,[1,1,u]),i.mat4.multiply(n,this._sourceTransform,n)):(n[0]=a[0],n[1]=a[1],n[2]=a[2],n[4]=o[0],n[5]=o[1],n[6]=o[2],n[8]=-r[0],n[9]=-r[1],n[10]=-r[2],this._isNegZForward&&(u=-u),i.mat4.scale(s,s,[1,1,u]),i.mat4.multiply(n,n,s)),this.stretchObject.UpdateViewDependentData(n))}}},{key:"Update",value:function(t){for(var r=0;r0&&(this._perMuzzleData[0].constantDelay=this.firingDelay1),this._perMuzzleData.length>1&&(this._perMuzzleData[1].constantDelay=this.firingDelay2),this._perMuzzleData.length>2&&(this._perMuzzleData[2].constantDelay=this.firingDelay3),this._perMuzzleData.length>3&&(this._perMuzzleData[3].constantDelay=this.firingDelay4),this._perMuzzleData.length>4&&(this._perMuzzleData[4].constantDelay=this.firingDelay5),this._perMuzzleData.length>5&&(this._perMuzzleData[5].constantDelay=this.firingDelay6),this._perMuzzleData.length>6&&(this._perMuzzleData[6].constantDelay=this.firingDelay7),this._perMuzzleData.length>7&&(this._perMuzzleData[7].constantDelay=this.firingDelay8)}},{key:"GetCurveDuration",value:function(){for(var e=0,t=0;t1&&void 0!==arguments[1]?arguments[1]:-1,r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t=this._perMuzzleData[n].elapsedTime||this.isLoopFiring)&&this.stretch[n].GetBatches(e,t,r)}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveStarField=void 0;var n=r(0);t.EveStarField=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._id=n.util.generateID(),this.name="",this.display=!0,this.effect=null,this.maxDist=0,this.maxFlashRate=0,this.minFlashIntensity=0,this.minFlashRate=0,this.seed=20}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveEffectRoot=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t0&&void 0!==arguments[0]?arguments[0]:[];this.mesh&&this.mesh.GetResources(e),this.spriteSet&&this.spriteSet.GetResources(e)}},{key:"UpdateViewDependentData",value:function(){this.display&&this.state!==t.State.DEAD&&(i.mat4.transpose(this._perObjectData.perObjectVSData.Get("WorldMat"),this.transform),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("WorldMatLast"),this.transform))}},{key:"Update",value:function(e,r,n){if(this.state===t.State.IN_FLIGHT){var a=t.global,o=i.mat4.getTranslation(a.vec3_0,this.transform),s=a.vec3_1,u=a.vec3_2,l=a.vec3_3;this.time+=e,this.time>this.durationEjectPhase?(i.vec3.subtract(o,this.velocity,r),i.vec3.lerp(o,o,r,1-Math.exp(.9999*-e)),i.mat4.setTranslation(this.transform,o),i.vec3.subtract(s,n,o),i.vec3.length(s)t.length)this.warheads.splice(t.length);else for(;this.warheads.length0&&void 0!==arguments[0]?arguments[0]:[],t=0;t.1&&(i.vec3.normalize(t,t),i.vec3.scale(t,t,Math.min(e*this.speed,r)),i.vec3.add(this.position,this.position,t));for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:[];return this.highDetail&&this.highDetail.GetResources(e),this.effectHeight&&this.effectHeight.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(e){this.highDetail.UpdateViewDependentData(e),this.zOnlyModel&&(this.zOnlyModel.translation=this.highDetail.translation,this.zOnlyModel.scaling=this.highDetail.scaling,this.zOnlyModel.UpdateViewDependentData(e))}},{key:"Update",value:function(e){this.highDetail.Update(e)}},{key:"GetBatches",value:function(e,t){if(this.display&&this.heightDirty&&this.watchedResources.length&&""!==this.heightMapResPath1){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],r=arguments[1];i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"GetResources",this).call(this,e,r);for(var n=0;n1)for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t.visible,e.visible,["glow","symHalo","halo","trail"]),i.util.assignIfExists(t,e,["name","display","seed","wavePhase","transform","locatorName","updateFromLocator","atlas0","atlas1"]),t}}]),t}(),h=t.EveBoosterSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.visible={},e.visible.glows=!0,e.visible.symHalos=!0,e.visible.halos=!0,e.visible.trails=!0,e.effect=null,e.glows=null,e.alwaysOn=!0,e.maxVel=250,e.glowDistance=2.5,e.glowScale=1,e.glowColor=i.vec4.create(),e.warpGlowColor=i.vec4.create(),e.haloDistance=3.01,e.haloScaleX=1,e.haloScaleY=1,e.haloColor=i.vec4.create(),e.warpHaloColor=i.vec4.create(),e.symHaloDistance=3,e.symHaloScale=1,e.trailColor=i.vec4.create(),e.trailSize=i.vec4.create(),e._parentTransform=i.mat4.create(),e._positions=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,i.device.gl.FLOAT,3,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,2,12)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,20)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,4,36)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,i.device.gl.FLOAT,4,52)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,i.device.gl.FLOAT,4,68)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,i.device.gl.FLOAT,4,84)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,6,i.device.gl.FLOAT,1,100)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,7,i.device.gl.FLOAT,2,104)),e._decl.RebuildHash(),e._perObjectData=new a.Tw2PerObjectData,e._perObjectData.perObjectVSData=new a.Tw2RawData,e._perObjectData.perObjectVSData.Declare("WorldMat",16),e._perObjectData.perObjectVSData.Declare("Shipdata",4),e._perObjectData.perObjectVSData.Create(),e._locatorRebuildPending=!0,e}return l(t,o.EveObjectSet),n(t,[{key:"FindItemByLocatorName",value:function(e){for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),this.glows&&this.glows.effect.GetResources(e),e}},{key:"Update",value:function(e,t){i.mat4.copy(this._parentTransform,t),this._rebuildPending&&this.Rebuild(),this.glows&&this.glows.Update(e)}},{key:"Unload",value:function(){this._positions&&(i.device.gl.deleteBuffer(this._positions),this._positions=null),this.glows&&this.glows.Unload()}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this);var e=this._visibleItems.length;if(this._rebuildPending=!1,e){for(var r=i.device,n=t._box,a=new Float32Array(e*n.length*6*28),o=[0,3,1,3,2,1],s=0,u=0;u0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","type","position1","color1","position2","color2","intermediatePosition","width","multiColor","multiColorBorder","overlayColor","animationSpeed","animationScale","numOfSegments"]),t}}]),t}();c.Type={INVALID:0,STRAIGHT:1,SPHERED:2,CURVED:3},c.DEFAULT_CURVED_SEGMENTS=20,c.DEFAULT_SPHERED_SEGEMENTS=20;var f=t.EveCurveLineSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.lineEffect=a.Tw2Effect.create({effectFilePath:"res:/Graphics/Effect/Managed/Space/SpecialFX/Lines3D.fx",textures:{TexMap:"res:/texture/global/white.dds.0.png",OverlayTexMap:"res:/texture/global/white.dds.0.png"}}),e.pickEffect=null,e.lineWidthFactor=1,e.additive=!1,e.pickable=!0,e.depthOffset=0,e.translation=i.vec3.create(),e.rotation=i.quat.create(),e.scaling=i.vec3.fromValues(1,1,1),e.transform=i.mat4.create(),e.parentTransform=i.mat4.create(),e._vertexSize=26,e._vbSize=0,e._vb=null,e._perObjectData=new a.Tw2PerObjectData,e._perObjectData.perObjectVSData=new a.Tw2RawData,e._perObjectData.perObjectVSData.Declare("WorldMat",16),e._perObjectData.perObjectVSData.Create(),e._perObjectData.perObjectPSData=new a.Tw2RawData,e._perObjectData.perObjectPSData.Declare("WorldMat",16),e._perObjectData.perObjectPSData.Create(),e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,i.device.gl.FLOAT,3,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,4,12)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,28)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,3,44)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,4,56)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,1,i.device.gl.FLOAT,4,72)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,2,i.device.gl.FLOAT,4,88)),e._decl.stride=4*e._vertexSize,e._decl.RebuildHash(),t.init(),e}return l(t,o.EveObjectSet),n(t,[{key:"Initialize",value:function(){this.OnValueChanged(),this.Rebuild()}},{key:"AddStraightLine",value:function(e,t,r,n,i){return this.CreateItem({type:c.Type.STRAIGHT,position1:e,position2:t,color1:n,color2:i,width:r})}},{key:"AddCurvedLineCrt",value:function(e,t,r,n,i,a){return this.CreateItem({type:c.Type.CURVED,position1:e,position2:t,intermediatePosition:r,color1:i,color2:a,width:n,numOfSegments:c.DEFAULT_CURVED_SEGMENTS})}},{key:"AddCurvedLineSph",value:function(e,r,n,a,o,s,u){var l=t.global;return this.CreateItem({type:c.Type.CURVED,position1:i.vec3.fromSpherical(l.vec3_0,e,n),position2:i.vec3.fromSpherical(l.vec3_1,r,n),intermediatePosition:i.vec3.fromSpherical(l.vec3_2,a,n),color1:s,color2:u,width:o,numOfSegments:c.DEFAULT_CURVED_SEGMENTS})}},{key:"AddSpheredLineCrt",value:function(e,t,r,n,i,a){return this.CreateItem({type:c.Type.SPHERED,position1:e,position2:t,intermediatePosition:r,color1:i,color2:a,width:n,numOfSegments:c.DEFAULT_SPHERED_SEGEMENTS})}},{key:"AddSpheredLineSph",value:function(e,r,n,a,o,s,u){var l=t.global;return this.CreateItem({type:c.Type.SPHERED,position1:i.vec3.fromSpherical(l.vec3_0,e,n),position2:i.vec3.fromSpherical(l.vec3_1,r,n),intermediatePosition:i.vec3.fromSpherical(l.vec3_2,a,n),color1:s,color2:u,width:o,numOfSegments:c.DEFAULT_SPHERED_SEGEMENTS})}},{key:"OnValueChanged",value:function(){i.mat4.fromRotationTranslationScale(this.transform,this.rotation,this.translation,this.scaling),this._rebuildPending=!0}},{key:"UpdateViewDependentData",value:function(e){i.mat4.copy(this.parentTransform,e)}},{key:"Update",value:function(){this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){this._vb&&(i.device.gl.deleteBuffer(this._vb),this._vb=null)}},{key:"Rebuild",value:function(){t.RebuildItems(this),this._vb=null,this._vbSize=this.lineCount,this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=t.global,n=new Float32Array(6*this._vbSize*this._vertexSize),a=r.vec3_0,o=r.vec3_1,s=r.vec3_2,u=r.vec3_3,l=r.vec3_4,f=r.vec3_5,h=r.vec3_6,p=r.mat4_0,d=r.vec3_7,v=r.vec3_8,m=r.vec3_9,y=r.vec3_10,b=r.vec4_0,_=r.vec4_1,g=0,E=void 0,T=0;T0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","boneIndex","groupIndex","maskAtlasID","position","scaling","rotation","transform","color","layer1Transform","layer2Transform","layer1Scroll","layer2Scroll"]),t}}]),t}();(t.EvePlaneSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.effect=null,e.hideOnLowQuality=!1,e._time=0,e._vertexBuffer=null,e._indexBuffer=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,4,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,16)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,4,32)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,4,48)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,i.device.gl.FLOAT,4,64)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,i.device.gl.FLOAT,4,80)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,i.device.gl.FLOAT,4,96)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,6,i.device.gl.FLOAT,4,112)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,7,i.device.gl.FLOAT,3,128)),e._decl.RebuildHash(),e}return l(t,o.EveObjectSet),n(t,[{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),e}},{key:"Update",value:function(e){this._time+=e,this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){this._vertexBuffer&&(i.device.gl.deleteBuffer(this._vertexBuffer),this._vertexBuffer=null),this._indexBuffer&&(i.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"Rebuild",value:function(){this.Unload(),t.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=t.global.mat4_0,n=new Float32Array(4*e*35),a=0;a0&&void 0!==arguments[0]?arguments[0]:[];return this.parentGeometry&&!e.includes(this.parentGeometry)&&e.push(this.parentGeometry),this.decalEffect&&this.decalEffect.GetResources(e),this.pickEffect&&this.pickEffect.GetResources(e),e}},{key:"Unload",value:function(){this._indexBuffer&&(i.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"GetBatches",value:function(e,t,r,n){var o=void 0;switch(e){case i.device.RM_DECAL:o=this.decalEffect;break;case i.device.RM_PICKABLE:o=this.pickable?this.pickEffect:null}if(this.display&&o&&o.IsGood()&&this.indexBuffer.length&&this.parentGeometry&&this.parentGeometry.IsGood()){var s=new a.Tw2ForwardingRenderBatch;if(this._perObjectData.perObjectVSData.Set("worldMatrix",r.perObjectVSData.Get("WorldMat")),this.parentBoneIndex>=0){var u=r.perObjectVSData.Get("JointMat"),l=12*this.parentBoneIndex;if(u[l]||u[l+4]||u[l+8]){var c=this._perObjectData.perObjectVSData.Get("parentBoneMatrix");c[0]=u[l],c[1]=u[l+4],c[2]=u[l+8],c[3]=0,c[4]=u[l+1],c[5]=u[l+5],c[6]=u[l+9],c[7]=0,c[8]=u[l+2],c[9]=u[l+6],c[10]=u[l+10],c[11]=0,c[12]=u[l+3],c[13]=u[l+7],c[14]=u[l+11],c[15]=1,i.mat4.transpose(c,c)}}i.mat4.invert(this._perObjectData.perObjectVSData.Get("invWorldMatrix"),this._perObjectData.perObjectVSData.Get("worldMatrix")),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("decalMatrix"),this.decalMatrix),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("invDecalMatrix"),this.invDecalMatrix),this._perObjectData.perObjectPSData.Get("displayData")[0]=n||0,this._perObjectData.perObjectPSData.Set("shipData",r.perObjectPSData.data),s.perObjectData=this._perObjectData,s.geometryProvider=this,s.renderMode=e,s.effect=o,t.Commit(s)}}},{key:"Render",value:function(e,t){var r=this.parentGeometry.meshes[0].indexes,n=this.parentGeometry.meshes[0].areas[0].start,a=this.parentGeometry.meshes[0].areas[0].count,o=this.parentGeometry.meshes[0].indexType;i.store.SetVariableValue("u_DecalMatrix",this.decalMatrix),i.store.SetVariableValue("u_InvDecalMatrix",this.invDecalMatrix),this.parentGeometry.meshes[0].indexes=this._indexBuffer,this.parentGeometry.meshes[0].areas[0].start=0,this.parentGeometry.meshes[0].areas[0].count=this.indexBuffer.length,this.parentGeometry.meshes[0].indexType=i.device.gl.UNSIGNED_SHORT,this.parentGeometry.RenderAreas(0,0,1,e.effect,t),this.parentGeometry.meshes[0].indexes=r,this.parentGeometry.meshes[0].areas[0].start=n,this.parentGeometry.meshes[0].areas[0].count=a,this.parentGeometry.meshes[0].indexType=o}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveSpotlightSet=t.EveSpotlightSetItem=t.EveSpotlightSetBatch=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","boosterGainInfluence","boneIndex","groupIndex","coneIntensity","spriteIntensity","flareIntensity","transform","coneColor","spriteColor","flareColor","spriteScale"]),t}}]),t}();(t.EveSpotlightSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.coneEffect=null,e.glowEffect=null,e._coneVertexBuffer=null,e._spriteVertexBuffer=null,e._indexBuffer=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,4,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,4,16)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,32)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,4,48)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,i.device.gl.FLOAT,3,64)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,i.device.gl.FLOAT,3,76)),e._decl.RebuildHash(),e}return l(t,o.EveObjectSet),n(t,[{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.coneEffect&&this.coneEffect.GetResources(e),this.glowEffect&&this.glowEffect.GetResources(e),e}},{key:"Unload",value:function(){this._coneVertexBuffer&&(i.device.gl.deleteBuffer(this._coneVertexBuffer),this._coneVertexBuffer=null),this._spriteVertexBuffer&&(i.device.gl.deleteBuffer(this._spriteVertexBuffer),this._spriteVertexBuffer=null),this._indexBuffer&&(i.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"Rebuild",value:function(){this.Unload(),t.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=i.device,n=[1,0,2,3],a=new Float32Array(22*(4*e*4)),o=0;o0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","blinkRate","blinkPhase","minScale","maxScale","falloff","boneIndex","groupIndex","position","color","warpColor"]),t}}]),t}();(t.EveSpriteSet=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];s(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.effect=null,n.useQuads=null,n.isSkinned=null,n._time=0,n._vertexBuffer=null,n._indexBuffer=null,n._instanceBuffer=null,n._decl=n._decl=new a.Tw2VertexDeclaration,n._vdecl=new a.Tw2VertexDeclaration,n._vdecl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,i.device.gl.FLOAT,1,0)),n._vdecl.RebuildHash(),n.UseQuads(e,r),n}return l(t,o.EveObjectSet),n(t,[{key:"UseQuads",value:function(e,t){if(this.useQuads!==e){this.useQuads=e,this.isSkinned=t;var r=i.device.gl;this._decl.elements.splice(0,this._decl.elements.length),e?(this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,r.FLOAT,3,0)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,r.FLOAT,4,12)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,r.FLOAT,2,28)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,r.FLOAT,4,36)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,1,r.FLOAT,4,52))):(this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,r.FLOAT,2,0)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,r.FLOAT,3,8)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,r.FLOAT,3,20)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,r.FLOAT,1,32)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,r.FLOAT,1,36)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,r.FLOAT,1,40)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,r.FLOAT,1,44)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,r.FLOAT,1,48))),this._decl.RebuildHash(),this._rebuildPending=!0}}},{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),e}},{key:"Update",value:function(e){this._time+=e,this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){var e=i.device.gl;this._vertexBuffer&&(e.deleteBuffer(this._vertexBuffer),this._vertexBuffer=null),this._indexBuffer&&(e.deleteBuffer(this._indexBuffer),this._indexBuffer=null),this._instanceBuffer&&(e.deleteBuffer(this._instanceBuffer),this._instanceBuffer=null)}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){var t=i.device.gl;if(this.useQuads)return this._vertexBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._vertexBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,1,2,2,3,0]),t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),void(this._instanceBuffer=t.createBuffer());for(var r=new Float32Array(4*e*13),n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","locatorName","updateFromLocator","position","rotation","bone","canFireWhenHidden"]),t.UpdateTransforms(),t}}]),t}(),f=t.EveTurretSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.visible={},e.visible.turrets=!0,e.visible.firingEffects=!0,e.activeAnimation=new a.Tw2AnimationController,e.inactiveAnimation=new a.Tw2AnimationController,e.geometryResPath="",e.geometryResource=null,e.turretEffect=null,e.firingEffectResPath="",e.firingEffect=null,e.fireCallback=null,e.fireCallbackPending=!1,e.state=t.State.IDLE,e.bottomClipHeight=0,e.locatorName="",e.sysBoneHeight=0,e.hasCyclingFiringPos=!1,e.targetPosition=i.vec3.create(),e.parentMatrix=i.mat4.create(),e.boundingSphere=i.quat.create(),e._activeTurret=-1,e._recheckTimeLeft=0,e._currentCyclingFiresPos=0,e._perObjectDataActive=new a.Tw2PerObjectData,e._perObjectDataActive.perObjectVSData=new a.Tw2RawData,e._perObjectDataActive.perObjectVSData.Declare("baseCutoffData",4),e._perObjectDataActive.perObjectVSData.Declare("turretSetData",4),e._perObjectDataActive.perObjectVSData.Declare("shipMatrix",16),e._perObjectDataActive.perObjectVSData.Declare("turretTranslation",96),e._perObjectDataActive.perObjectVSData.Declare("turretRotation",96),e._perObjectDataActive.perObjectVSData.Declare("turretPoseTransAndRot",576),e._perObjectDataActive.perObjectVSData.Create(),e._perObjectDataInactive=new a.Tw2PerObjectData,e._perObjectDataInactive.perObjectVSData=new a.Tw2RawData,e._perObjectDataInactive.perObjectVSData.Declare("baseCutoffData",4),e._perObjectDataInactive.perObjectVSData.Declare("turretSetData",4),e._perObjectDataInactive.perObjectVSData.Declare("shipMatrix",16),e._perObjectDataInactive.perObjectVSData.Declare("turretTranslation",96),e._perObjectDataInactive.perObjectVSData.Declare("turretRotation",96),e._perObjectDataInactive.perObjectVSData.Declare("turretPoseTransAndRot",576),e._perObjectDataInactive.perObjectVSData.Create(),e._locatorRebuildPending=!0,e}return l(t,o.EveObjectSet),n(t,[{key:"Initialize",value:function(){var e=this;this.turretEffect&&""!==this.geometryResPath&&(this.geometryResource=i.resMan.GetResource(this.geometryResPath),this.activeAnimation.SetGeometryResource(this.geometryResource),this.inactiveAnimation.SetGeometryResource(this.geometryResource),this.geometryResource&&this.geometryResource.RegisterNotification(this)),""!==this.firingEffectResPath&&i.resMan.GetObject(this.firingEffectResPath,function(t){return e.firingEffect=t}),this.Rebuild()}},{key:"InitializeFiringEffect",value:function(){if(this.firingEffect&&this.geometryResource&&this.geometryResource.models.length)for(var e=this.geometryResource.models[0],r=0;rr&&(e=this.items.indexOf(l),r=c)}}return e}},{key:"EnterStateDeactive",value:function(){var e=this;this.state!==t.State.INACTIVE&&this.state!==t.State.PACKING&&(this.turretEffect?(this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.activeAnimation.PlayAnimation("Pack",!1,function(){e.state=t.State.INACTIVE,e.activeAnimation.PlayAnimation("Inactive",!0)}),this.inactiveAnimation.PlayAnimation("Pack",!1,function(){e.state=t.State.INACTIVE,e.inactiveAnimation.PlayAnimation("Inactive",!0)}),this.state=t.State.PACKING):this.state=t.State.INACTIVE,this._activeTurret=-1,this.firingEffect&&this.firingEffect.StopFiring())}},{key:"EnterStateIdle",value:function(){var e=this;this.state!==t.State.IDLE&&this.state!==t.State.UNPACKING&&(this.turretEffect?(this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.state===t.State.FIRING?(this.activeAnimation.PlayAnimation("Active",!0),this.inactiveAnimation.PlayAnimation("Active",!0)):(this.activeAnimation.PlayAnimation("Deploy",!1,function(){e.state=t.State.IDLE,e.activeAnimation.PlayAnimation("Active",!0)}),this.inactiveAnimation.PlayAnimation("Deploy",!1,function(){e.state=t.State.IDLE,e.inactiveAnimation.PlayAnimation("Active",!0)})),this.state=t.State.UNPACKING):this.state=t.State.IDLE,this._activeTurret=-1,this.firingEffect&&this.firingEffect.StopFiring())}},{key:"EnterStateFiring",value:function(){var e=this;if(!this.turretEffect||this.state===t.State.FIRING)return t.DoStartFiring(this),void(this.turretEffect&&this.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)}));this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.state===t.State.INACTIVE?(this.activeAnimation.PlayAnimation("Deploy",!1,function(){t.DoStartFiring(e),e.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)})}),this.inactiveAnimation.PlayAnimation("Deploy",!1,function(){e.inactiveAnimation.PlayAnimation("Active",!0)}),this.state=t.State.UNPACKING):(t.DoStartFiring(this),this.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)}),this.inactiveAnimation.PlayAnimation("Active",!0))}},{key:"RebuildCachedData",value:function(){for(var e=new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,2),r=this.geometryResource.meshes,n=this.activeAnimation,o=this.inactiveAnimation,s=0;s0&&void 0!==arguments[0]?arguments[0]:[];return this.geometryResource&&!e.includes(this.geometryResource)&&e.push(this.geometryResource),this.turretEffect&&this.turretEffect.GetResources(e),this.firingEffect&&this.firingEffect.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(){this.firingEffect&&this.firingEffect.UpdateViewDependentData()}},{key:"Update",value:function(e,r){if(this._rebuildPending&&this.Rebuild(),this.turretEffect&&(this.activeAnimation.Update(e),this.inactiveAnimation.Update(e)),i.mat4.copy(this.parentMatrix,r),this.firingEffect&&this._visibleItems.length){if(-1!==this._activeTurret){this.firingEffect.isLoopFiring&&this.state===t.State.FIRING&&(this._recheckTimeLeft-=e,this._recheckTimeLeft<=0&&t.DoStartFiring(this));var n=this.items[this._activeTurret];if(this.activeAnimation.models.length)for(var a=this.activeAnimation.models[0].bonesByName,o=0;o0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1],r=0;r2&&void 0!==arguments[2]?arguments[2]:this._batches,n=0;n=0&&(u=e.substr(0,s+1)+o+"/"+e.substr(s+1)),(s=u.lastIndexOf("_"))>=0){u=u.substr(0,s)+"_"+o+u.substr(s);var l=r(n,"textureOverrides",{});if(t in l&&i.name in l[t])return u}}return e}function f(e,t){var r=l(t),n=(e="/"+e).lastIndexOf("/");return e.substr(0,n+1)+r+e.substr(n+1)}function h(e,t){for(var r=0;r=0&&s=0?r||T:t||(r||T);case"not_overridable":case"half_overridable_2":return r||T}return T}function w(t,r,a){var o=e.faction[r],s=e.faction[a],u=null;o&&o.areas&&"hull"in o.areas&&(u=o.areas.hull);var l=null;if(s&&s.areas&&"hull"in s.areas&&(l=s.areas.hull),(u||l)&&t.turretEffect){var c=t.turretEffect.parameters;for(var f in c)if(c.hasOwnProperty(f)){if(c[f].constructor.prototype!==i.Tw2Vector4Parameter.prototype)continue;var h=null,p=null;u&&(h=E(f,o,u)),l&&(p=E(f,o,u)),n.vec4.copy(c[f].value,O(f,h,p,t.turretEffect.name))}t.turretEffect.BindParameters()}}function S(t){if("all"!==t){var r={};for(var n in e[t])e[t].hasOwnProperty(n)&&(r[n]=e[t][n].description||"");return r}return e}this.SetupTurretMaterial=function(t,r,n,i){null===e?this.LoadData(function(){w(t,r,n),i&&i()}):(w(t,r,n),i&&i())},this.GetHullNames=function(e){this.LoadData(function(){e(S("hull"))})},this.GetFactionNames=function(e){this.LoadData(function(){e(S("faction"))})},this.GetRaceNames=function(e){this.LoadData(function(){e(S("race"))})},this.GetSofData=function(e){this.LoadData(function(){e(S("all"))})}};var n=r(0),i=r(1),a=r(58),o=r(64),s=r(59),u=r(61)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(185);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(189);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(196);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(200);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(201);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(14);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(186);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(187);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(188);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2StaticEmitter=void 0;var n=function(){function e(e,t){for(var r=0;rthis.geometryIndex&&this.geometryResource.meshes[this.geometryIndex].bufferData){this._spawned=!0;for(var e=this.geometryResource.meshes[this.geometryIndex],t=this.particleSystem.elements,r=new Array(t.length),n=0;n=this.maxParticleCount?null:this.aliveCount++}},{key:"EndSpawnParticle",value:function(){this.bufferDirty=!0}},{key:"Update",value:function(t){if(t=Math.min(t,.1),this.applyAging&&this.HasElement(o.Tw2ParticleElementDeclaration.Type.LIFETIME)){for(var r=this.GetElement(o.Tw2ParticleElementDeclaration.Type.LIFETIME),n=this.emitParticleOnDeathEmitter?this.GetElement(o.Tw2ParticleElementDeclaration.Type.POSITION):null,a=this.emitParticleOnDeathEmitter?this.GetElement(o.Tw2ParticleElementDeclaration.Type.VELOCITY):null,s=0;s1){if(this.emitParticleOnDeathEmitter&&this.emitParticleOnDeathEmitter.SpawnParticles(n,a,1),this.aliveCount--,s=n&&t>=n)return et?1:0;if(e>=n)return 1;if(t>=n)return-1;var r=a[e],i=a[t];return ri?-1:0})}},{key:"GetInstanceBuffer",value:function(){if(0!==this.aliveCount){var e=i.device.gl;if(this.requiresSorting&&this.HasElement(o.Tw2ParticleElementDeclaration.Type.POSITION)&&this.buffers){this._Sort();for(var t=this.instanceStride[0],r=this.buffers[0],n=0;n} */ - GetResources(out=[]) + GetResources(out = []) { if (this.textureRes && !out.includes(this.textureRes)) { diff --git a/src/core/post/Tw2PostProcess.js b/src/core/post/Tw2PostProcess.js index 0044ca5..57cd738 100644 --- a/src/core/post/Tw2PostProcess.js +++ b/src/core/post/Tw2PostProcess.js @@ -96,6 +96,7 @@ export class Tw2PostProcess Render() { const + gl = device.gl, width = device.viewportWidth, height = device.viewportHeight; @@ -104,14 +105,14 @@ export class Tw2PostProcess if (this.texture === null) { this.texture = new Tw2TextureRes(); - this.texture.Attach(device.gl.createTexture()); + this.texture.Attach(gl.createTexture()); } if (width !== this.width || height !== this.height) { - device.gl.bindTexture(device.gl.TEXTURE_2D, this.texture.texture); - device.gl.texImage2D(device.gl.TEXTURE_2D, 0, device.gl.RGBA, width, height, 0, device.gl.RGBA, device.gl.UNSIGNED_BYTE, null); - device.gl.bindTexture(device.gl.TEXTURE_2D, null); + gl.bindTexture(gl.TEXTURE_2D, this.texture.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + gl.bindTexture(gl.TEXTURE_2D, null); this.quadRT0.Create(width / 4, height / 4, false); this.quadRT1.Create(width / 4, height / 4, false); @@ -158,9 +159,9 @@ export class Tw2PostProcess } } - device.gl.bindTexture(device.gl.TEXTURE_2D, this.texture.texture); - device.gl.copyTexImage2D(device.gl.TEXTURE_2D, 0, device.alphaBlendBackBuffer ? device.gl.RGBA : device.gl.RGB, 0, 0, width, height, 0); - device.gl.bindTexture(device.gl.TEXTURE_2D, null); + gl.bindTexture(gl.TEXTURE_2D, this.texture.texture); + gl.copyTexImage2D(gl.TEXTURE_2D, 0, device.alphaBlendBackBuffer ? gl.RGBA : gl.RGB, 0, 0, width, height, 0); + gl.bindTexture(gl.TEXTURE_2D, null); device.SetStandardStates(device.RM_OPAQUE); for (let i = 0; i < this.steps.length; ++i) @@ -172,8 +173,8 @@ export class Tw2PostProcess } else { - device.gl.bindFramebuffer(device.gl.FRAMEBUFFER, null); - device.gl.viewport(0, 0, width, height); + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + gl.viewport(0, 0, width, height); } device.RenderFullScreenQuad(step.effect); } diff --git a/src/core/resource/Tw2GeometryRes.js b/src/core/resource/Tw2GeometryRes.js index 9f1ce80..631f2c7 100644 --- a/src/core/resource/Tw2GeometryRes.js +++ b/src/core/resource/Tw2GeometryRes.js @@ -91,7 +91,7 @@ export class Tw2GeometryRes extends Tw2Resource Prepare(data) { const - d = device, + gl = device.gl, reader = new Tw2BinaryReader(new Uint8Array(data)); /* let fileVersion = */ @@ -106,9 +106,9 @@ export class Tw2GeometryRes extends Tw2Resource if (buffer) { mesh.bufferLength = buffer.length; - mesh.buffer = d.gl.createBuffer(); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, mesh.buffer); - d.gl.bufferData(d.gl.ARRAY_BUFFER, buffer, d.gl.STATIC_DRAW); + mesh.buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, mesh.buffer); + gl.bufferData(gl.ARRAY_BUFFER, buffer, gl.STATIC_DRAW); } else { @@ -118,10 +118,10 @@ export class Tw2GeometryRes extends Tw2Resource const indexes = Tw2GeometryRes.ReadIndexBuffer(reader); if (indexes) { - mesh.indexes = d.gl.createBuffer(); - mesh.indexType = indexes.BYTES_PER_ELEMENT === 2 ? d.gl.UNSIGNED_SHORT : d.gl.UNSIGNED_INT; - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); - d.gl.bufferData(d.gl.ELEMENT_ARRAY_BUFFER, indexes, d.gl.STATIC_DRAW); + mesh.indexes = gl.createBuffer(); + mesh.indexType = indexes.BYTES_PER_ELEMENT === 2 ? gl.UNSIGNED_SHORT : gl.UNSIGNED_INT; + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indexes, gl.STATIC_DRAW); } else { @@ -268,7 +268,7 @@ export class Tw2GeometryRes extends Tw2Resource const track = new Tw2GeometryTransformTrack(); track.name = reader.ReadString(); track.orientation = Tw2GeometryRes.ReadCurve(reader); - track.position =Tw2GeometryRes.ReadCurve(reader); + track.position = Tw2GeometryRes.ReadCurve(reader); track.scaleShear = Tw2GeometryRes.ReadCurve(reader); if (track.orientation) @@ -365,10 +365,11 @@ export class Tw2GeometryRes extends Tw2Resource const d = device, + {ext, gl} = d, mesh = this.meshes[meshIx], passCount = effect.GetPassCount(technique); - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); for (let pass = 0; pass < passCount; ++pass) { @@ -376,9 +377,9 @@ export class Tw2GeometryRes extends Tw2Resource const passInput = effect.GetPassInput(technique, pass); if (passInput.elements.length === 0) continue; - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, mesh.buffer); + gl.bindBuffer(gl.ARRAY_BUFFER, mesh.buffer); mesh.declaration.SetPartialDeclaration(passInput, mesh.declaration.stride); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, instanceVB); + gl.bindBuffer(gl.ARRAY_BUFFER, instanceVB); const resetData = instanceDecl.SetPartialDeclaration(passInput, instanceStride, 8, 1); d.ApplyShadowState(); @@ -397,7 +398,7 @@ export class Tw2GeometryRes extends Tw2Resource acount += area.count; ++i; } - d.ext.drawElementsInstanced(d.gl.TRIANGLES, acount, mesh.indexType, areaStart, instanceCount); + ext.drawElementsInstanced(gl.TRIANGLES, acount, mesh.indexType, areaStart, instanceCount); } } instanceDecl.ResetInstanceDivisors(resetData); @@ -421,11 +422,12 @@ export class Tw2GeometryRes extends Tw2Resource const d = device, + gl = d.gl, mesh = this.meshes[meshIx] || this.meshes[0], passCount = effect.GetPassCount(technique); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, mesh.buffer); - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); + gl.bindBuffer(gl.ARRAY_BUFFER, mesh.buffer); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); for (let pass = 0; pass < passCount; ++pass) { @@ -465,7 +467,7 @@ export class Tw2GeometryRes extends Tw2Resource acount += area.count; ++i; } - d.gl.drawElements(d.gl.TRIANGLES, acount, mesh.indexType, areaStart); + gl.drawElements(gl.TRIANGLES, acount, mesh.indexType, areaStart); } } } @@ -488,11 +490,12 @@ export class Tw2GeometryRes extends Tw2Resource const d = device, + gl = d.gl, mesh = this.meshes[meshIx], passCount = effect.GetPassCount(technique); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, mesh.buffer); - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); + gl.bindBuffer(gl.ARRAY_BUFFER, mesh.buffer); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, mesh.indexes); for (let pass = 0; pass < passCount; ++pass) { @@ -532,7 +535,7 @@ export class Tw2GeometryRes extends Tw2Resource acount += area.count; ++i; } - d.gl.drawElements(d.gl.LINES, acount, mesh.indexType, areaStart); + gl.drawElements(gl.LINES, acount, mesh.indexType, areaStart); } } } @@ -576,15 +579,17 @@ export class Tw2GeometryRes extends Tw2Resource { for (let i = 0; i < this.meshes.length; ++i) { + const gl = device.gl; + if (this.meshes[i].buffer) { - device.gl.deleteBuffer(this.meshes[i].buffer); + gl.deleteBuffer(this.meshes[i].buffer); this.meshes[i].buffer = null; } if (this.meshes[i].indexes) { - device.gl.deleteBuffer(this.meshes[i].indexes); + gl.deleteBuffer(this.meshes[i].indexes); this.meshes[i].indexes = null; } } diff --git a/src/core/resource/Tw2Resource.js b/src/core/resource/Tw2Resource.js index 7d1f9f4..f3f17cf 100644 --- a/src/core/resource/Tw2Resource.js +++ b/src/core/resource/Tw2Resource.js @@ -25,6 +25,15 @@ export class Tw2Resource this.doNotPurge = 0; } + /** + * Gets an array of resource errors, or an empty array if there are none + * @returns {Array.} + */ + GetErrors() + { + return resMan.motherLode.GetErrors(this.path); + } + /** * Checks to see if the resource is loading * @returns {boolean} @@ -129,7 +138,7 @@ export class Tw2Resource if (!this._notifications.includes(notification)) { this._notifications.push(notification); - if (this._isGood && 'RebuildCachedData' in notification) + if (this.IsGood() && 'RebuildCachedData' in notification) { notification.RebuildCachedData(this); } diff --git a/src/core/resource/Tw2Shader.js b/src/core/resource/Tw2Shader.js index 9fc1df2..6405e81 100644 --- a/src/core/resource/Tw2Shader.js +++ b/src/core/resource/Tw2Shader.js @@ -33,23 +33,26 @@ export class Tw2Shader this.techniques = {}; this.annotations = {}; - const d = device; + const {wrapModes, gl} = device; let techniqueCount = 1; if (version > 6) { techniqueCount = reader.ReadUInt8(); } + for (let t = 0; t < techniqueCount; ++t) { let technique = { name: 'Main', passes: [] }; + if (version > 6) { technique.name = ReadString(); } + this.techniques[technique.name] = technique; const passCount = reader.ReadUInt8(); @@ -243,40 +246,40 @@ export class Tw2Shader switch (mipFilter) { case 0: - sampler.minFilter = d.gl.NEAREST; + sampler.minFilter = gl.NEAREST; break; case 1: - sampler.minFilter = d.gl.NEAREST_MIPMAP_NEAREST; + sampler.minFilter = gl.NEAREST_MIPMAP_NEAREST; break; default: - sampler.minFilter = d.gl.NEAREST_MIPMAP_LINEAR; + sampler.minFilter = gl.NEAREST_MIPMAP_LINEAR; } - sampler.minFilterNoMips = d.gl.NEAREST; + sampler.minFilterNoMips = gl.NEAREST; } else { switch (mipFilter) { case 0: - sampler.minFilter = d.gl.LINEAR; + sampler.minFilter = gl.LINEAR; break; case 1: - sampler.minFilter = d.gl.LINEAR_MIPMAP_NEAREST; + sampler.minFilter = gl.LINEAR_MIPMAP_NEAREST; break; default: - sampler.minFilter = d.gl.LINEAR_MIPMAP_LINEAR; + sampler.minFilter = gl.LINEAR_MIPMAP_LINEAR; } - sampler.minFilterNoMips = d.gl.LINEAR; + sampler.minFilterNoMips = gl.LINEAR; } - sampler.magFilter = magFilter === 1 ? d.gl.NEAREST : d.gl.LINEAR; - sampler.addressU = d.wrapModes[addressU]; - sampler.addressV = d.wrapModes[addressV]; - sampler.addressW = d.wrapModes[addressW]; + sampler.magFilter = magFilter === 1 ? gl.NEAREST : gl.LINEAR; + sampler.addressU = wrapModes[addressU]; + sampler.addressV = wrapModes[addressV]; + sampler.addressW = wrapModes[addressW]; if (minFilter === 3 || magFilter === 3 || mipFilter === 3) { @@ -287,7 +290,7 @@ export class Tw2Shader { if (stage.textures[n].registerIndex === sampler.registerIndex) { - sampler.samplerType = stage.textures[n].type === 4 ? d.gl.TEXTURE_CUBE_MAP : d.gl.TEXTURE_2D; + sampler.samplerType = stage.textures[n].type === 4 ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D; sampler.isVolume = stage.textures[n].type === 3; break; } @@ -381,7 +384,10 @@ export class Tw2Shader */ ApplyPass(technique, pass) { - const d = device; + const + d = device, + gl = d.gl; + pass = this.techniques[technique].passes[pass]; for (let i = 0; i < pass.states.length; ++i) @@ -391,12 +397,12 @@ export class Tw2Shader if (d.IsAlphaTestEnabled()) { - d.gl.useProgram(pass.shadowShaderProgram.program); + gl.useProgram(pass.shadowShaderProgram.program); d.shadowHandles = pass.shadowShaderProgram; } else { - d.gl.useProgram(pass.shaderProgram.program); + gl.useProgram(pass.shaderProgram.program); d.shadowHandles = null; } } @@ -449,22 +455,22 @@ export class Tw2Shader static CompileShader(stageType, prefix, shaderCode, path) { const - d = device, - shader = d.gl.createShader(stageType === 0 ? d.gl.VERTEX_SHADER : d.gl.FRAGMENT_SHADER); + {ext, gl} = device, + shader = gl.createShader(stageType === 0 ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER); - if (d.ext.ShaderBinary) + if (ext.ShaderBinary) { - d.ext.ShaderBinary['shaderBinary'](shader, shaderCode); + ext.ShaderBinary['shaderBinary'](shader, shaderCode); } else { let source = prefix + (util.isString(shaderCode) ? shaderCode : String.fromCharCode.apply(null, shaderCode)); source = source.substr(0, source.length - 1); - d.gl.shaderSource(shader, source); - d.gl.compileShader(shader); + gl.shaderSource(shader, source); + gl.compileShader(shader); } - if (!d.gl.getShaderParameter(shader, d.gl.COMPILE_STATUS)) + if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { logger.log('res.error', { log: 'error', @@ -473,7 +479,7 @@ export class Tw2Shader path: path, type: 'shader.compile', value: (stageType === 0) ? 'VERTEX' : 'FRAGMENT', - data: device.gl.getShaderInfoLog(shader) + data: gl.getShaderInfoLog(shader) }); return null; } @@ -491,15 +497,15 @@ export class Tw2Shader static CreateProgram(vertexShader, fragmentShader, pass, path) { const - d = device, + gl = device.gl, program = {}; - program.program = d.gl.createProgram(); - d.gl.attachShader(program.program, vertexShader); - d.gl.attachShader(program.program, fragmentShader); - d.gl.linkProgram(program.program); + program.program = gl.createProgram(); + gl.attachShader(program.program, vertexShader); + gl.attachShader(program.program, fragmentShader); + gl.linkProgram(program.program); - if (!d.gl.getProgramParameter(program.program, d.gl.LINK_STATUS)) + if (!gl.getProgramParameter(program.program, gl.LINK_STATUS)) { logger.log('res.error', { log: 'error', @@ -507,35 +513,35 @@ export class Tw2Shader msg: 'Error linking shaders', path: path, type: 'shader.linkstatus', - data: device.gl.getProgramInfoLog(program.program) + data: gl.getProgramInfoLog(program.program) }); return null; } - d.gl.useProgram(program.program); + gl.useProgram(program.program); program.constantBufferHandles = []; for (let j = 0; j < 16; ++j) { - program.constantBufferHandles[j] = d.gl.getUniformLocation(program.program, 'cb' + j); + program.constantBufferHandles[j] = gl.getUniformLocation(program.program, 'cb' + j); } program.samplerHandles = []; for (let j = 0; j < 16; ++j) { - program.samplerHandles[j] = d.gl.getUniformLocation(program.program, 's' + j); - d.gl.uniform1i(program.samplerHandles[j], j); + program.samplerHandles[j] = gl.getUniformLocation(program.program, 's' + j); + gl.uniform1i(program.samplerHandles[j], j); } for (let j = 0; j < 16; ++j) { - program.samplerHandles[j + 12] = d.gl.getUniformLocation(program.program, 'vs' + j); - d.gl.uniform1i(program.samplerHandles[j + 12], j + 12); + program.samplerHandles[j + 12] = gl.getUniformLocation(program.program, 'vs' + j); + gl.uniform1i(program.samplerHandles[j + 12], j + 12); } program.input = new Tw2VertexDeclaration(); for (let j = 0; j < pass.stages[0].inputDefinition.elements.length; ++j) { - let location = d.gl.getAttribLocation(program.program, 'attr' + j); + let location = gl.getAttribLocation(program.program, 'attr' + j); if (location >= 0) { const el = new Tw2VertexElement( @@ -548,16 +554,16 @@ export class Tw2Shader } program.input.RebuildHash(); - program.shadowStateInt = d.gl.getUniformLocation(program.program, 'ssi'); - program.shadowStateFloat = d.gl.getUniformLocation(program.program, 'ssf'); - program.shadowStateYFlip = d.gl.getUniformLocation(program.program, 'ssyf'); - d.gl.uniform3f(program.shadowStateYFlip, 0, 0, 1); + program.shadowStateInt = gl.getUniformLocation(program.program, 'ssi'); + program.shadowStateFloat = gl.getUniformLocation(program.program, 'ssf'); + program.shadowStateYFlip = gl.getUniformLocation(program.program, 'ssyf'); + gl.uniform3f(program.shadowStateYFlip, 0, 0, 1); program.volumeSlices = []; for (let j = 0; j < pass.stages[1].samplers.length; ++j) { if (pass.stages[1].samplers[j].isVolume) { - program.volumeSlices[pass.stages[1].samplers[j].registerIndex] = d.gl.getUniformLocation(program.program, 's' + pass.stages[1].samplers[j].registerIndex + 'sl'); + program.volumeSlices[pass.stages[1].samplers[j].registerIndex] = gl.getUniformLocation(program.program, 's' + pass.stages[1].samplers[j].registerIndex + 'sl'); } } return program; diff --git a/src/core/resource/Tw2TextureRes.js b/src/core/resource/Tw2TextureRes.js index 113cffa..35a8ec3 100644 --- a/src/core/resource/Tw2TextureRes.js +++ b/src/core/resource/Tw2TextureRes.js @@ -38,24 +38,24 @@ export class Tw2TextureRes extends Tw2Resource Prepare(text) { const - d = device, - format = this.images[0]['ccpGLFormat'] ? this.images[0]['ccpGLFormat'] : d.gl.RGBA; + gl = device.gl, + format = this.images[0]['ccpGLFormat'] ? this.images[0]['ccpGLFormat'] : gl.RGBA; switch (text) { case 'cube': - this.texture = d.gl.createTexture(); - d.gl.bindTexture(d.gl.TEXTURE_CUBE_MAP, this.texture); + this.texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_CUBE_MAP, this.texture); const canvas = document.createElement('canvas'); canvas.width = canvas.height = this.images[0].height; const ctx = canvas.getContext('2d'); for (let j = 0; j < 6; ++j) { ctx.drawImage(this.images[0], j * canvas.width, 0, canvas.width, canvas.height, 0, 0, canvas.width, canvas.height); - d.gl.texImage2D(d.gl.TEXTURE_CUBE_MAP_POSITIVE_X + j, 0, format, format, d.gl.UNSIGNED_BYTE, canvas); + gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + j, 0, format, format, gl.UNSIGNED_BYTE, canvas); } - d.gl.generateMipmap(d.gl.TEXTURE_CUBE_MAP); - d.gl.bindTexture(d.gl.TEXTURE_CUBE_MAP, null); + gl.generateMipmap(gl.TEXTURE_CUBE_MAP); + gl.bindTexture(gl.TEXTURE_CUBE_MAP, null); this.width = canvas.width; this.height = canvas.height; this.hasMipMaps = true; @@ -65,12 +65,12 @@ export class Tw2TextureRes extends Tw2Resource //case 'png': default: - this.texture = d.gl.createTexture(); - d.gl.bindTexture(d.gl.TEXTURE_2D, this.texture); - d.gl.texImage2D(d.gl.TEXTURE_2D, 0, format, format, d.gl.UNSIGNED_BYTE, this.images[0]); + this.texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, format, format, gl.UNSIGNED_BYTE, this.images[0]); this.hasMipMaps = Tw2TextureRes.IsPowerOfTwo(this.images[0].width) && Tw2TextureRes.IsPowerOfTwo(this.images[0].height); - if (this.hasMipMaps) d.gl.generateMipmap(d.gl.TEXTURE_2D); - d.gl.bindTexture(d.gl.TEXTURE_2D, null); + if (this.hasMipMaps) gl.generateMipmap(gl.TEXTURE_2D); + gl.bindTexture(gl.TEXTURE_2D, null); this.width = this.images[0].width; this.height = this.images[0].height; this._isAttached = false; @@ -177,25 +177,27 @@ export class Tw2TextureRes extends Tw2Resource */ Bind(sampler, slices) { - const d = device; + const + d = device, + gl = d.gl; this.KeepAlive(); let targetType = sampler.samplerType; - if (targetType !== (this.isCube ? d.gl.TEXTURE_CUBE_MAP : d.gl.TEXTURE_2D)) return; + if (targetType !== (this.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D)) return; if (!this.texture) { - const texture = targetType === d.gl.TEXTURE_2D ? d.GetFallbackTexture() : d.GetFallbackCubeMap(); - d.gl.bindTexture(targetType, texture); + const texture = targetType === gl.TEXTURE_2D ? d.GetFallbackTexture() : d.GetFallbackCubeMap(); + gl.bindTexture(targetType, texture); return; } if (sampler.isVolume) { - d.gl.uniform1f(slices, this.height / this.width); + gl.uniform1f(slices, this.height / this.width); } - d.gl.bindTexture(targetType, this.texture); + gl.bindTexture(targetType, this.texture); if (sampler.hash !== this._currentSampler) { sampler.Apply(this.hasMipMaps); diff --git a/src/core/resource/Tw2VideoRes.js b/src/core/resource/Tw2VideoRes.js index f344770..037d46b 100644 --- a/src/core/resource/Tw2VideoRes.js +++ b/src/core/resource/Tw2VideoRes.js @@ -48,7 +48,7 @@ export class Tw2VideoRes extends Tw2Resource IsGood() { this.KeepAlive(); - return this._isGood && this.video && this._playable; + return super.IsGood() && this.video && this._playable; } /** @@ -103,7 +103,7 @@ export class Tw2VideoRes extends Tw2Resource { const gl = device.gl; - switch(text) + switch (text) { case 'mp4': case 'webm': @@ -224,24 +224,26 @@ export class Tw2VideoRes extends Tw2Resource */ Bind(sampler) { - const d = device; + const + d = device, + gl = d.gl; this.KeepAlive(); const targetType = sampler.samplerType; - if (targetType !== d.gl.TEXTURE_2D) return; + if (targetType !== gl.TEXTURE_2D) return; if (!this.texture) { - d.gl.bindTexture(d.gl.TEXTURE_2D, d.GetFallbackTexture()); + gl.bindTexture(gl.TEXTURE_2D, d.GetFallbackTexture()); return; } this._currentTime = this.video.currentTime; - d.gl.bindTexture(d.gl.TEXTURE_2D, this.texture); - d.gl.texImage2D(d.gl.TEXTURE_2D, 0, d.gl.RGBA, d.gl.RGBA, d.gl.UNSIGNED_BYTE, this.video); - d.gl.bindTexture(d.gl.TEXTURE_2D, null); + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.video); + gl.bindTexture(gl.TEXTURE_2D, null); - d.gl.bindTexture(targetType, this.texture); + gl.bindTexture(targetType, this.texture); if (sampler.hash !== this._currentSampler) { sampler.Apply(false); diff --git a/src/core/sampler/Tw2SamplerOverride.js b/src/core/sampler/Tw2SamplerOverride.js index 78889ee..97b2da9 100644 --- a/src/core/sampler/Tw2SamplerOverride.js +++ b/src/core/sampler/Tw2SamplerOverride.js @@ -35,7 +35,7 @@ export class Tw2SamplerOverride * @param originalSampler * @returns {Tw2SamplerState} */ - this.GetSampler = function (originalSampler) + this.GetSampler = function(originalSampler) { if (!sampler) { @@ -43,41 +43,43 @@ export class Tw2SamplerOverride sampler.registerIndex = originalSampler.registerIndex; sampler.name = originalSampler.name; + const {wrapModes, gl} = device; + if (this.filter === 1) { switch (this.mipFilter) { case 0: - sampler.minFilter = device.gl.NEAREST; + sampler.minFilter = gl.NEAREST; break; case 1: - sampler.minFilter = device.gl.NEAREST_MIPMAP_NEAREST; + sampler.minFilter = gl.NEAREST_MIPMAP_NEAREST; break; default: - sampler.minFilter = device.gl.NEAREST_MIPMAP_LINEAR; + sampler.minFilter = gl.NEAREST_MIPMAP_LINEAR; } - sampler.minFilterNoMips = device.gl.NEAREST; + sampler.minFilterNoMips = gl.NEAREST; } else { switch (this.mipFilter) { case 0: - sampler.minFilter = device.gl.LINEAR; + sampler.minFilter = gl.LINEAR; break; case 1: - sampler.minFilter = device.gl.LINEAR_MIPMAP_NEAREST; + sampler.minFilter = gl.LINEAR_MIPMAP_NEAREST; break; default: - sampler.minFilter = device.gl.LINEAR_MIPMAP_LINEAR; + sampler.minFilter = gl.LINEAR_MIPMAP_LINEAR; } - sampler.minFilterNoMips = device.gl.LINEAR; + sampler.minFilterNoMips = gl.LINEAR; } if (this.filter === 3 || this.mipFilter === 3) @@ -85,10 +87,10 @@ export class Tw2SamplerOverride sampler.anisotropy = Math.max(this.maxAnisotropy, 1); } - sampler.magFilter = this.filter === 1 ? device.gl.NEAREST : device.gl.LINEAR; - sampler.addressU = device.wrapModes[this.addressU]; - sampler.addressV = device.wrapModes[this.addressV]; - sampler.addressW = device.wrapModes[this.addressW]; + sampler.magFilter = this.filter === 1 ? gl.NEAREST : gl.LINEAR; + sampler.addressU = wrapModes[this.addressU]; + sampler.addressV = wrapModes[this.addressV]; + sampler.addressW = wrapModes[this.addressW]; sampler.samplerType = originalSampler.samplerType; sampler.isVolume = originalSampler.isVolume; sampler.ComputeHash(); diff --git a/src/core/sampler/Tw2SamplerState.js b/src/core/sampler/Tw2SamplerState.js index 9a17846..b82066d 100644 --- a/src/core/sampler/Tw2SamplerState.js +++ b/src/core/sampler/Tw2SamplerState.js @@ -21,16 +21,17 @@ export class Tw2SamplerState { constructor() { + const gl = device.gl; this.name = ''; this.registerIndex = 0; - this.minFilter = device.gl.LINEAR; - this.maxFilter = device.gl.LINEAR; - this.minFilterNoMips = device.gl.LINEAR; - this.addressU = device.gl.REPEAT; - this.addressV = device.gl.REPEAT; - this.addressW = device.gl.REPEAT; + this.minFilter = gl.LINEAR; + this.maxFilter = gl.LINEAR; + this.minFilterNoMips = gl.LINEAR; + this.addressU = gl.REPEAT; + this.addressV = gl.REPEAT; + this.addressW = gl.REPEAT; this.anisotropy = 1; - this.samplerType = device.gl.TEXTURE_2D; + this.samplerType = gl.TEXTURE_2D; this.isVolume = false; this.hash = 0; } @@ -57,19 +58,20 @@ export class Tw2SamplerState * Apply * @param {boolean} hasMipMaps */ - Apply (hasMipMaps) + Apply(hasMipMaps) { const targetType = this.samplerType, - d = device; + d = device, + gl = d.gl; - d.gl.texParameteri(targetType, d.gl.TEXTURE_WRAP_S, hasMipMaps ? this.addressU : d.gl.CLAMP_TO_EDGE); - d.gl.texParameteri(targetType, d.gl.TEXTURE_WRAP_T, hasMipMaps ? this.addressV : d.gl.CLAMP_TO_EDGE); - d.gl.texParameteri(targetType, d.gl.TEXTURE_MIN_FILTER, hasMipMaps ? this.minFilter : this.minFilterNoMips); - d.gl.texParameteri(targetType, d.gl.TEXTURE_MAG_FILTER, this.magFilter); + gl.texParameteri(targetType, gl.TEXTURE_WRAP_S, hasMipMaps ? this.addressU : gl.CLAMP_TO_EDGE); + gl.texParameteri(targetType, gl.TEXTURE_WRAP_T, hasMipMaps ? this.addressV : gl.CLAMP_TO_EDGE); + gl.texParameteri(targetType, gl.TEXTURE_MIN_FILTER, hasMipMaps ? this.minFilter : this.minFilterNoMips); + gl.texParameteri(targetType, gl.TEXTURE_MAG_FILTER, this.magFilter); if (d.ext.AnisotropicFilter && d.enableAnisotropicFiltering) { - d.gl.texParameterf(targetType, + gl.texParameterf(targetType, d.ext.AnisotropicFilter.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(this.anisotropy, d.ext.AnisotropicFilter.maxAnisotropy)); } diff --git a/src/core/vertex/Tw2VertexDeclaration.js b/src/core/vertex/Tw2VertexDeclaration.js index 126715f..f3a3161 100644 --- a/src/core/vertex/Tw2VertexDeclaration.js +++ b/src/core/vertex/Tw2VertexDeclaration.js @@ -80,6 +80,8 @@ export class Tw2VertexDeclaration */ SetDeclaration(inputDecl, stride) { + const gl = device.gl; + let index = 0; for (let i = 0; i < inputDecl._elementsSorted.length; ++i) { @@ -90,8 +92,8 @@ export class Tw2VertexDeclaration { if (index >= this._elementsSorted.length) { - device.gl.disableVertexAttribArray(el.location); - device.gl.vertexAttrib4f(el.location, 0, 0, 0, 0); + gl.disableVertexAttribArray(el.location); + gl.vertexAttrib4f(el.location, 0, 0, 0, 0); break; } @@ -101,8 +103,8 @@ export class Tw2VertexDeclaration if (cmp > 0) { - device.gl.disableVertexAttribArray(el.location); - device.gl.vertexAttrib4f(el.location, 0, 0, 0, 0); + gl.disableVertexAttribArray(el.location); + gl.vertexAttrib4f(el.location, 0, 0, 0, 0); break; } @@ -114,8 +116,8 @@ export class Tw2VertexDeclaration } else { - device.gl.enableVertexAttribArray(el.location); - device.gl.vertexAttribPointer( + gl.enableVertexAttribArray(el.location); + gl.vertexAttribPointer( el.location, input.elements, input.type, @@ -141,13 +143,15 @@ export class Tw2VertexDeclaration */ SetPartialDeclaration(inputDecl, stride, usageOffset = 0, divisor = 0) { - const resetData = []; + const + {ext, gl} = device, + resetData = []; let index = 0; for (let i = 0; i < inputDecl._elementsSorted.length; ++i) { const el = inputDecl._elementsSorted[i]; - if (el.location < 0) continue; + if (el.location < 0) continue; while (true) { @@ -163,15 +167,16 @@ export class Tw2VertexDeclaration } else { - device.gl.enableVertexAttribArray(el.location); - device.gl.vertexAttribPointer( + gl.enableVertexAttribArray(el.location); + gl.vertexAttribPointer( el.location, input.elements, input.type, false, stride, input.offset); - device.ext.vertexAttribDivisor(el.location, divisor); + + ext.vertexAttribDivisor(el.location, divisor); if (divisor) { @@ -184,8 +189,8 @@ export class Tw2VertexDeclaration { if (!divisor) { - device.gl.disableVertexAttribArray(el.location); - device.gl.vertexAttrib4f(el.location, 0, 0, 0, 0); + gl.disableVertexAttribArray(el.location); + gl.vertexAttrib4f(el.location, 0, 0, 0, 0); } break; } @@ -195,8 +200,8 @@ export class Tw2VertexDeclaration { if (!divisor) { - device.gl.disableVertexAttribArray(el.location); - device.gl.vertexAttrib4f(el.location, 0, 0, 0, 0); + gl.disableVertexAttribArray(el.location); + gl.vertexAttrib4f(el.location, 0, 0, 0, 0); } return resetData; } diff --git a/src/curve/curves/Tw2ColorCurve2.js b/src/curve/curves/Tw2ColorCurve2.js index b796877..7fcc905 100644 --- a/src/curve/curves/Tw2ColorCurve2.js +++ b/src/curve/curves/Tw2ColorCurve2.js @@ -66,7 +66,7 @@ export class Tw2ColorCurve2 extends Tw2Curve { Tw2Curve.Sort2(this); } - + /** * Gets the curve's length * @returns {number} diff --git a/src/curve/curves/Tw2Curve.js b/src/curve/curves/Tw2Curve.js index f7f969c..36eaea1 100644 --- a/src/curve/curves/Tw2Curve.js +++ b/src/curve/curves/Tw2Curve.js @@ -59,7 +59,7 @@ export class Tw2Curve { return 0; } - + /** * Updates the current value at the given time * @param {number} time @@ -87,7 +87,7 @@ export class Tw2Curve * @param {*} curve * @param {Array.} [keys=curve.keys] - Optional keys override */ - static Sort(curve, keys=curve.keys) + static Sort(curve, keys = curve.keys) { if (keys && keys.length) { diff --git a/src/curve/curves/Tw2ScalarCurve2.js b/src/curve/curves/Tw2ScalarCurve2.js index dd29602..c7e072b 100644 --- a/src/curve/curves/Tw2ScalarCurve2.js +++ b/src/curve/curves/Tw2ScalarCurve2.js @@ -65,7 +65,7 @@ export class Tw2ScalarCurve2 extends Tw2Curve { Tw2Curve.Sort2(this); } - + /** * Gets the curve's length * @returns {number} diff --git a/src/curve/maya/Tw2MayaEulerRotationCurve.js b/src/curve/maya/Tw2MayaEulerRotationCurve.js index 6f2ea54..d97b575 100644 --- a/src/curve/maya/Tw2MayaEulerRotationCurve.js +++ b/src/curve/maya/Tw2MayaEulerRotationCurve.js @@ -46,7 +46,7 @@ export class Tw2MayaEulerRotationCurve extends Tw2Curve { return this.length; } - + /** * Updates a value at a specific time * @param {number} time diff --git a/src/curve/sequencers/Tw2ColorSequencer.js b/src/curve/sequencers/Tw2ColorSequencer.js index fd5f2a9..90b61d5 100644 --- a/src/curve/sequencers/Tw2ColorSequencer.js +++ b/src/curve/sequencers/Tw2ColorSequencer.js @@ -65,7 +65,7 @@ export class Tw2ColorSequencer extends Tw2CurveSequencer { const vec4_0 = Tw2CurveSequencer.global.vec4_0; - switch(this.operator) + switch (this.operator) { case Tw2ColorSequencer.Operator.MULTIPLY: vec4.set(value, 1, 1, 1, 1); diff --git a/src/curve/sequencers/Tw2CurveSequencer.js b/src/curve/sequencers/Tw2CurveSequencer.js index 909c3e9..32d6db0 100644 --- a/src/curve/sequencers/Tw2CurveSequencer.js +++ b/src/curve/sequencers/Tw2CurveSequencer.js @@ -11,7 +11,7 @@ export class Tw2CurveSequencer extends Tw2Curve { super(); } - + /** * Legacy sequencer sorting * @param {Tw2CurveSequencer} sequencer diff --git a/src/curve/sequencers/Tw2EulerRotation.js b/src/curve/sequencers/Tw2EulerRotation.js index 31e5bf5..2a1d3af 100644 --- a/src/curve/sequencers/Tw2EulerRotation.js +++ b/src/curve/sequencers/Tw2EulerRotation.js @@ -110,4 +110,4 @@ Tw2EulerRotation.curveType = Tw2CurveSequencer.Type.SEQUENCER2; * The sequencer's curve property names * @type {string[]} */ -Tw2EulerRotation.childProperties = [ 'yawCurve', 'pitchCurve', 'rollCurve' ]; \ No newline at end of file +Tw2EulerRotation.childProperties = ['yawCurve', 'pitchCurve', 'rollCurve']; \ No newline at end of file diff --git a/src/curve/sequencers/Tw2RGBAScalarSequencer.js b/src/curve/sequencers/Tw2RGBAScalarSequencer.js index 2a45d20..6d8c9d6 100644 --- a/src/curve/sequencers/Tw2RGBAScalarSequencer.js +++ b/src/curve/sequencers/Tw2RGBAScalarSequencer.js @@ -41,10 +41,10 @@ export class Tw2RGBAScalarSequencer extends Tw2CurveSequencer if (this.RedCurve && ('GetLength' in this.RedCurve)) len = this.RedCurve.GetLength(); if (this.GreenCurve && ('GetLength' in this.GreenCurve)) len = Math.max(len, this.GreenCurve.GetLength()); if (this.BlueCurve && ('GetLength' in this.BlueCurve)) len = Math.max(len, this.BlueCurve.GetLength()); - if (this.AlphaCurve && ('GetLength' in this.AlphaCurve)) len = Math.max(len, this.AlphaCurve.GetLength()); + if (this.AlphaCurve && ('GetLength' in this.AlphaCurve)) len = Math.max(len, this.AlphaCurve.GetLength()); return len; } - + /** * Updates the current value at a specific time * @param {number} time @@ -98,4 +98,4 @@ Tw2RGBAScalarSequencer.curveType = Tw2CurveSequencer.Type.SEQUENCER2; * The sequencer's curve property names * @type {string[]} */ -Tw2RGBAScalarSequencer.childProperties = ['RedCurve', 'GreenCurve', 'BlueCurve', 'AlphaCurve' ]; \ No newline at end of file +Tw2RGBAScalarSequencer.childProperties = ['RedCurve', 'GreenCurve', 'BlueCurve', 'AlphaCurve']; \ No newline at end of file diff --git a/src/curve/sequencers/Tw2ScalarSequencer.js b/src/curve/sequencers/Tw2ScalarSequencer.js index beae0e0..5683ff0 100644 --- a/src/curve/sequencers/Tw2ScalarSequencer.js +++ b/src/curve/sequencers/Tw2ScalarSequencer.js @@ -1,4 +1,4 @@ -import { Tw2CurveSequencer } from './Tw2CurveSequencer'; +import {Tw2CurveSequencer} from './Tw2CurveSequencer'; /** * Tw2ScalarSequencer @@ -74,21 +74,21 @@ export class Tw2ScalarSequencer extends Tw2CurveSequencer { let value; - switch(this.operator) + switch (this.operator) { case Tw2ScalarSequencer.Operator.MULTIPLY: value = 1; for (let i = 0; i < this.functions.length; ++i) { let v = this.functions[i].GetValueAt(time); - if (this.clamping) + if (this.clamping) { v = Math.min(Math.max(v, this.inMinClamp), this.inMaxClamp); } value *= v; } break; - + default: value = 0; for (let i = 0; i < this.functions.length; ++i) @@ -101,12 +101,12 @@ export class Tw2ScalarSequencer extends Tw2CurveSequencer value += v; } } - - if (this.clamping) + + if (this.clamping) { value = Math.min(Math.max(value, this.outMinClamp), this.outMaxClamp); } - + return value; } } diff --git a/src/curve/sequencers/Tw2VectorSequencer.js b/src/curve/sequencers/Tw2VectorSequencer.js index b00d8de..0a177df 100644 --- a/src/curve/sequencers/Tw2VectorSequencer.js +++ b/src/curve/sequencers/Tw2VectorSequencer.js @@ -1,5 +1,5 @@ import {vec3} from '../../global'; -import {Tw2CurveSequencer } from './Tw2CurveSequencer'; +import {Tw2CurveSequencer} from './Tw2CurveSequencer'; /** * Tw2VectorSequencer @@ -66,7 +66,7 @@ export class Tw2VectorSequencer extends Tw2CurveSequencer { const vec3_0 = Tw2CurveSequencer.global.vec3_0; - switch(this.operator) + switch (this.operator) { case Tw2VectorSequencer.Operator.MULTIPLY: vec3.set(value, 1, 1, 1); diff --git a/src/curve/sequencers/Tw2XYZScalarSequencer.js b/src/curve/sequencers/Tw2XYZScalarSequencer.js index 32c103a..d1f307a 100644 --- a/src/curve/sequencers/Tw2XYZScalarSequencer.js +++ b/src/curve/sequencers/Tw2XYZScalarSequencer.js @@ -1,5 +1,5 @@ import {vec3} from '../../global'; -import {Tw2CurveSequencer } from './Tw2CurveSequencer'; +import {Tw2CurveSequencer} from './Tw2CurveSequencer'; /** * Tw2XYZScalarSequencer @@ -95,4 +95,4 @@ Tw2XYZScalarSequencer.curveType = Tw2CurveSequencer.Type.SEQUENCER2; * The sequencer's curve property names * @type {string[]} */ -Tw2XYZScalarSequencer.childProperties = [ 'XCurve', 'YCurve', 'ZCurve' ]; \ No newline at end of file +Tw2XYZScalarSequencer.childProperties = ['XCurve', 'YCurve', 'ZCurve']; \ No newline at end of file diff --git a/src/curve/sequencers/Tw2YPRSequencer.js b/src/curve/sequencers/Tw2YPRSequencer.js index bd1c2eb..2f49391 100644 --- a/src/curve/sequencers/Tw2YPRSequencer.js +++ b/src/curve/sequencers/Tw2YPRSequencer.js @@ -40,10 +40,10 @@ export class Tw2YPRSequencer extends Tw2CurveSequencer let len = 0; if (this.YawCurve && ('GetLength' in this.YawCurve)) len = this.YawCurve.GetLength(); if (this.PitchCurve && ('GetLength' in this.PitchCurve)) len = Math.max(len, this.PitchCurve.GetLength()); - if (this.RollCurve && ('GetLength' in this.RollCurve)) len = Math.max(len, this.RollCurve.GetLength()); + if (this.RollCurve && ('GetLength' in this.RollCurve)) len = Math.max(len, this.RollCurve.GetLength()); return len; } - + /** * Updates a value at a specific time * @@ -112,4 +112,4 @@ Tw2YPRSequencer.curveType = Tw2CurveSequencer.Type.SEQUENCER2; * The sequencer's curve property names * @type {string[]} */ -Tw2YPRSequencer.childProperties = [ 'YawCurve', 'PitchCurve', 'RollCurve' ]; \ No newline at end of file +Tw2YPRSequencer.childProperties = ['YawCurve', 'PitchCurve', 'RollCurve']; \ No newline at end of file diff --git a/src/curve/tracks/Tw2WbgTrack.js b/src/curve/tracks/Tw2WbgTrack.js index de5af95..b255201 100644 --- a/src/curve/tracks/Tw2WbgTrack.js +++ b/src/curve/tracks/Tw2WbgTrack.js @@ -50,14 +50,14 @@ export function Tw2WbgTrack() * Initialize * @method */ - this.Initialize = function () + this.Initialize = function() { if (this.geometryResPath) { this.geometryRes = resMan.GetResource(this.geometryResPath); const self = this; let notification = { - OnResPrepared: function () + OnResPrepared: function() { SetCurves(self); } @@ -71,7 +71,7 @@ export function Tw2WbgTrack() * @param {number} time * @prototype */ - this.UpdateValue = function (time) + this.UpdateValue = function(time) { if (!this._TracksReady()) return; if (this.cycle) time = time % this.duration; @@ -108,7 +108,7 @@ export function Tw2WbgTransformTrack() * @returns {*} * @private */ - this._TracksReady = function () + this._TracksReady = function() { return positionCurve || rotationCurve || scaleCurve; }; @@ -119,7 +119,7 @@ export function Tw2WbgTransformTrack() * @param duration * @private */ - this._ApplyTracks = function (trackGroup, duration) + this._ApplyTracks = function(trackGroup, duration) { for (let i = 0; i < trackGroup.transformTracks.length; ++i) { @@ -140,7 +140,7 @@ export function Tw2WbgTransformTrack() * @param {number} time * @prototype */ - this._UpdateValue = function (time) + this._UpdateValue = function(time) { if (positionCurve) { diff --git a/src/eve/EveSpaceScene.js b/src/eve/EveSpaceScene.js index 391bd30..a36ab08 100644 --- a/src/eve/EveSpaceScene.js +++ b/src/eve/EveSpaceScene.js @@ -312,7 +312,7 @@ export class EveSpaceScene * @param {Array.} objectArray * @param {Tw2BatchAccumulator} accumulator */ - RenderBatches(mode, objectArray, accumulator=this._batches) + RenderBatches(mode, objectArray, accumulator = this._batches) { for (let i = 0; i < objectArray.length; ++i) { diff --git a/src/eve/child/EveChild.js b/src/eve/child/EveChild.js index 71772e9..33ba31d 100644 --- a/src/eve/child/EveChild.js +++ b/src/eve/child/EveChild.js @@ -1,5 +1,5 @@ /* eslint no-unused-vars:0 */ -import { vec3, quat, mat4, util } from '../../global'; +import {vec3, quat, mat4, util} from '../../global'; /** * EveChild base class @@ -31,7 +31,7 @@ export class EveChild this.staticTransform = false; this.rotation = quat.create(); this.translation = vec3.create(); - this.scaling = vec3.fromValues(1,1,1); + this.scaling = vec3.fromValues(1, 1, 1); this.localTransform = mat4.create(); this.worldTransform = mat4.create(); this.worldTransformLast = mat4.create(); @@ -44,7 +44,7 @@ export class EveChild * @param {Array} [out=[]] * @returns {Array} out */ - GetResources(out=[]) + GetResources(out = []) { return out; } @@ -82,6 +82,6 @@ export class EveChild * @type {Object} */ EveChild.global = { - mat4_0 : mat4.create(), - vec3_0 : vec3.create() + mat4_0: mat4.create(), + vec3_0: vec3.create() }; \ No newline at end of file diff --git a/src/eve/child/EveChildContainer.js b/src/eve/child/EveChildContainer.js index 659f9c7..e5b1896 100644 --- a/src/eve/child/EveChildContainer.js +++ b/src/eve/child/EveChildContainer.js @@ -21,7 +21,7 @@ export class EveChildContainer extends EveChild * @param {Array} [out=[]] * @returns {Array} out */ - GetResources(out=[]) + GetResources(out = []) { for (let i = 0; i < this.objects.length; i++) { diff --git a/src/eve/effect/EveLensflare.js b/src/eve/effect/EveLensflare.js index 7c8ba96..a6923a2 100644 --- a/src/eve/effect/EveLensflare.js +++ b/src/eve/effect/EveLensflare.js @@ -66,7 +66,7 @@ export class EveLensflare * @param {Array} [out=[]] - Optional receiving array * @returns {Array.} [out] */ - GetResources(out=[]) + GetResources(out = []) { if (this.mesh) this.mesh.GetResources(out); @@ -178,7 +178,7 @@ export class EveLensflare this.backgroundOcclusionIntensity = this.occlusionIntensity; - store.SetVariableValue('LensflareFxOccScale', [ this.occlusionIntensity, this.occlusionIntensity, 0, 0 ]); + store.SetVariableValue('LensflareFxOccScale', [this.occlusionIntensity, this.occlusionIntensity, 0, 0]); g.occludedLevelIndex = (g.occludedLevelIndex + 1) % g.occluderLevels.length; } @@ -226,7 +226,7 @@ export class EveLensflare negPos = g.vec3_1, dist = g.vec4_1; - vec3.transformMat4(cameraPos, [ 0, 0, 0 ], device.viewInverse); + vec3.transformMat4(cameraPos, [0, 0, 0], device.viewInverse); if (vec3.length(this.position) === 0) { @@ -240,7 +240,7 @@ export class EveLensflare vec3.normalize(this._direction, negPos); } - vec4.transformMat4(viewDir, [ 0, 0, 1, 0 ], device.viewInverse); + vec4.transformMat4(viewDir, [0, 0, 1, 0], device.viewInverse); vec3.scaleAndAdd(cameraSpacePos, cameraPos, viewDir, -this.cameraFactor); vec3.negate(negDirVec, this._direction); mat4.arcFromForward(this._transform, negDirVec); @@ -250,7 +250,7 @@ export class EveLensflare const dir = this._direction; - store.SetVariableValue('LensflareFxDirectionScale', [ dir[0], dir[1], dir[2], 1 ]); + store.SetVariableValue('LensflareFxDirectionScale', [dir[0], dir[1], dir[2], 1]); vec4.set(dist, dir[0], dir[1], dir[2], 0); vec4.transformMat4(dist, dist, device.view); diff --git a/src/eve/effect/EveOccluder.js b/src/eve/effect/EveOccluder.js index ee891c5..5d82752 100644 --- a/src/eve/effect/EveOccluder.js +++ b/src/eve/effect/EveOccluder.js @@ -1,5 +1,5 @@ import {vec4, mat4, util, device, store} from '../../global'; -import { Tw2Effect, Tw2VertexDeclaration, Tw2VertexElement, Tw2BatchAccumulator} from '../../core'; +import {Tw2Effect, Tw2VertexDeclaration, Tw2VertexElement, Tw2BatchAccumulator} from '../../core'; /** * EveOccluder diff --git a/src/eve/effect/EveStretch.js b/src/eve/effect/EveStretch.js index 92f3173..20282db 100644 --- a/src/eve/effect/EveStretch.js +++ b/src/eve/effect/EveStretch.js @@ -97,7 +97,7 @@ export class EveStretch * @param {Array} [out=[]] * @return {Array} out */ - GetResources(out=[]) + GetResources(out = []) { if (this.source && this.source.GetResources) this.source.GetResources(out); if (this.dest && this.dest.GetResources) this.dest.GetResources(out); diff --git a/src/eve/item/EveObjectSet.js b/src/eve/item/EveObjectSet.js index 2772f9e..49deb64 100644 --- a/src/eve/item/EveObjectSet.js +++ b/src/eve/item/EveObjectSet.js @@ -1,5 +1,5 @@ /* eslint no-unused-vars:0 */ -import { vec3, vec4, mat4, util } from '../../global'; +import {vec3, vec4, mat4, util} from '../../global'; /** * EveObjectSetItem base class @@ -75,7 +75,7 @@ export class EveObjectSet * @param {*} [opt={}] * @returns {?EveObjectSetItem|*} */ - CreateItem(opt={}) + CreateItem(opt = {}) { const Item = this.constructor.Item; if (Item && 'create' in Item) @@ -86,7 +86,7 @@ export class EveObjectSet } return null; } - + /** * Adds a set item * @param {EveObjectSetItem|*} item @@ -134,7 +134,7 @@ export class EveObjectSet * @param {?number} [id=null] * @returns {?EveObjectSetItem|*} */ - FindItemByID(id=null) + FindItemByID(id = null) { if (id !== null) { @@ -154,7 +154,7 @@ export class EveObjectSet * @param {Array} [out=[]] * @returns {Array} */ - GetResources(out=[]) + GetResources(out = []) { return out; } diff --git a/src/eve/item/EveSpaceObjectDecal.js b/src/eve/item/EveSpaceObjectDecal.js index c27bcbc..d0eac4f 100644 --- a/src/eve/item/EveSpaceObjectDecal.js +++ b/src/eve/item/EveSpaceObjectDecal.js @@ -1,5 +1,5 @@ import {vec3, quat, mat4, util, device, store} from '../../global'; -import { Tw2PerObjectData, Tw2RawData, Tw2ForwardingRenderBatch} from '../../core/'; +import {Tw2PerObjectData, Tw2RawData, Tw2ForwardingRenderBatch} from '../../core/'; /** * EveSpaceObjectDecal @@ -76,10 +76,13 @@ export class EveSpaceObjectDecal { if (!this._indexBuffer && this.indexBuffer) { - const indexes = new Uint16Array(this.indexBuffer); - this._indexBuffer = device.gl.createBuffer(); - device.gl.bindBuffer(device.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - device.gl.bufferData(device.gl.ELEMENT_ARRAY_BUFFER, indexes, device.gl.STATIC_DRAW); + const + gl = device.gl, + indexes = new Uint16Array(this.indexBuffer); + + this._indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indexes, gl.STATIC_DRAW); } mat4.fromRotationTranslationScale(this.decalMatrix, this.rotation, this.position, this.scaling); diff --git a/src/eve/item/EveSpriteSet.js b/src/eve/item/EveSpriteSet.js index 4d0f6f5..ebaffcf 100644 --- a/src/eve/item/EveSpriteSet.js +++ b/src/eve/item/EveSpriteSet.js @@ -154,25 +154,27 @@ export class EveSpriteSet extends EveObjectSet this.useQuads = useQuads; this.isSkinned = isSkinned; + const gl = device.gl; + this._decl.elements.splice(0, this._decl.elements.length); if (!useQuads) { - this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.TEXCOORD, 5, device.gl.FLOAT, 2, 0)); - this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.POSITION, 0, device.gl.FLOAT, 3, 8)); - this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.COLOR, 0, device.gl.FLOAT, 3, 20)); - this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.TEXCOORD, 0, device.gl.FLOAT, 1, 32)); - this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.TEXCOORD, 1, device.gl.FLOAT, 1, 36)); - this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.TEXCOORD, 2, device.gl.FLOAT, 1, 40)); - this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.TEXCOORD, 3, device.gl.FLOAT, 1, 44)); - this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.TEXCOORD, 4, device.gl.FLOAT, 1, 48)); + this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.TEXCOORD, 5, gl.FLOAT, 2, 0)); + this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.POSITION, 0, gl.FLOAT, 3, 8)); + this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.COLOR, 0, gl.FLOAT, 3, 20)); + this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.TEXCOORD, 0, gl.FLOAT, 1, 32)); + this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.TEXCOORD, 1, gl.FLOAT, 1, 36)); + this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.TEXCOORD, 2, gl.FLOAT, 1, 40)); + this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.TEXCOORD, 3, gl.FLOAT, 1, 44)); + this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.TEXCOORD, 4, gl.FLOAT, 1, 48)); } else { - this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.POSITION, 0, device.gl.FLOAT, 3, 0)); - this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.TEXCOORD, 0, device.gl.FLOAT, 4, 12)); - this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.TEXCOORD, 1, device.gl.FLOAT, 2, 28)); - this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.COLOR, 0, device.gl.FLOAT, 4, 36)); - this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.COLOR, 1, device.gl.FLOAT, 4, 52)); + this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.POSITION, 0, gl.FLOAT, 3, 0)); + this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.TEXCOORD, 0, gl.FLOAT, 4, 12)); + this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.TEXCOORD, 1, gl.FLOAT, 2, 28)); + this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.COLOR, 0, gl.FLOAT, 4, 36)); + this._decl.elements.push(new Tw2VertexElement(Tw2VertexDeclaration.Type.COLOR, 1, gl.FLOAT, 4, 52)); } this._decl.RebuildHash(); @@ -212,23 +214,25 @@ export class EveSpriteSet extends EveObjectSet */ Unload() { + const gl = device.gl; + if (this._vertexBuffer) { - device.gl.deleteBuffer(this._vertexBuffer); + gl.deleteBuffer(this._vertexBuffer); this._vertexBuffer = null; } // Standard if (this._indexBuffer) { - device.gl.deleteBuffer(this._indexBuffer); + gl.deleteBuffer(this._indexBuffer); this._indexBuffer = null; } // Quad if (this._instanceBuffer) { - device.gl.deleteBuffer(this._instanceBuffer); + gl.deleteBuffer(this._instanceBuffer); this._instanceBuffer = null; } } @@ -243,15 +247,15 @@ export class EveSpriteSet extends EveObjectSet const itemCount = this._visibleItems.length; if (!itemCount) return; - const d = device; + const gl = device.gl; if (this.useQuads) { - this._vertexBuffer = d.gl.createBuffer(); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vertexBuffer); - d.gl.bufferData(d.gl.ARRAY_BUFFER, new Float32Array([0, 1, 2, 2, 3, 0]), d.gl.STATIC_DRAW); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, null); - this._instanceBuffer = d.gl.createBuffer(); + this._vertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 1, 2, 2, 3, 0]), gl.STATIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, null); + this._instanceBuffer = gl.createBuffer(); return; } @@ -288,10 +292,10 @@ export class EveSpriteSet extends EveObjectSet } } - this._vertexBuffer = d.gl.createBuffer(); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vertexBuffer); - d.gl.bufferData(d.gl.ARRAY_BUFFER, array, d.gl.STATIC_DRAW); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, null); + this._vertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, null); const indexes = new Uint16Array(itemCount * 6); for (let i = 0; i < itemCount; ++i) @@ -308,10 +312,10 @@ export class EveSpriteSet extends EveObjectSet indexes[offset + 5] = vtxOffset + 2; } - this._indexBuffer = d.gl.createBuffer(); - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - d.gl.bufferData(d.gl.ELEMENT_ARRAY_BUFFER, indexes, d.gl.STATIC_DRAW); - d.gl.bindBuffer(d.gl.ELEMENT_ARRAY_BUFFER, null); + this._indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indexes, gl.STATIC_DRAW); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null); this._indexBuffer.count = itemCount * 6; } @@ -376,16 +380,20 @@ export class EveSpriteSet extends EveObjectSet if (!this.effect || !this.effect.IsGood() || !this._indexBuffer) return false; - device.SetStandardStates(device.RM_ADDITIVE); - device.gl.bindBuffer(device.gl.ARRAY_BUFFER, this._vertexBuffer); - device.gl.bindBuffer(device.gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + const + d = device, + gl = d.gl; + + d.SetStandardStates(d.RM_ADDITIVE); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); for (let pass = 0; pass < this.effect.GetPassCount(technique); ++pass) { this.effect.ApplyPass(technique, pass); if (!this._decl.SetDeclaration(this.effect.GetPassInput(technique, pass), 52)) return false; - device.ApplyShadowState(); - device.gl.drawElements(device.gl.TRIANGLES, this._indexBuffer.count, device.gl.UNSIGNED_SHORT, 0); + d.ApplyShadowState(); + gl.drawElements(gl.TRIANGLES, this._indexBuffer.count, gl.UNSIGNED_SHORT, 0); } return true; } @@ -404,6 +412,7 @@ export class EveSpriteSet extends EveObjectSet const d = device, + gl = d.gl, pos = EveObjectSet.global.vec3_0, itemCount = this._visibleItems.length, array = new Float32Array(17 * itemCount); @@ -434,19 +443,19 @@ export class EveSpriteSet extends EveObjectSet array[index++] = warpIntensity; } - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._instanceBuffer); - d.gl.bufferData(d.gl.ARRAY_BUFFER, array, d.gl.DYNAMIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, this._instanceBuffer); + gl.bufferData(gl.ARRAY_BUFFER, array, gl.DYNAMIC_DRAW); for (let pass = 0; pass < this.effect.GetPassCount(technique); ++pass) { this.effect.ApplyPass(technique, pass); const passInput = this.effect.GetPassInput(technique, pass); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); this._vdecl.SetPartialDeclaration(passInput, 4); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._instanceBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, this._instanceBuffer); const resetData = this._decl.SetPartialDeclaration(passInput, 17 * 4, 0, 1); d.ApplyShadowState(); - d.ext.drawArraysInstanced(d.gl.TRIANGLES, 0, 6, itemCount); + d.ext.drawArraysInstanced(gl.TRIANGLES, 0, 6, itemCount); this._decl.ResetInstanceDivisors(resetData); } @@ -466,6 +475,7 @@ export class EveSpriteSet extends EveObjectSet const d = device, + gl = d.gl, itemCount = this._visibleItems.length, array = new Float32Array(17 * itemCount), pos = EveObjectSet.global.vec3_0, @@ -509,19 +519,19 @@ export class EveSpriteSet extends EveObjectSet array[index++] = 1; } - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._instanceBuffer); - d.gl.bufferData(d.gl.ARRAY_BUFFER, array, d.gl.DYNAMIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, this._instanceBuffer); + gl.bufferData(gl.ARRAY_BUFFER, array, gl.DYNAMIC_DRAW); for (let pass = 0; pass < this.effect.GetPassCount(technique); ++pass) { this.effect.ApplyPass(technique, pass); const passInput = this.effect.GetPassInput(technique, pass); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); this._vdecl.SetPartialDeclaration(passInput, 4); - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._instanceBuffer); + gl.bindBuffer(gl.ARRAY_BUFFER, this._instanceBuffer); const resetData = this._decl.SetPartialDeclaration(passInput, 17 * 4, 0, 1); d.ApplyShadowState(); - d.ext.drawArraysInstanced(d.gl.TRIANGLES, 0, 6, itemCount); + d.ext.drawArraysInstanced(gl.TRIANGLES, 0, 6, itemCount); this._decl.ResetInstanceDivisors(resetData); } diff --git a/src/eve/item/EveTurretSet.js b/src/eve/item/EveTurretSet.js index 3fad588..8f0aded 100644 --- a/src/eve/item/EveTurretSet.js +++ b/src/eve/item/EveTurretSet.js @@ -55,7 +55,7 @@ export class EveTurretSetItem extends EveObjectSetItem quat.copy(this._localRotation, this.rotation); } } - + /** * Creates a turret item from an object * @param {*} [opt={}] @@ -128,7 +128,7 @@ export class EveTurretSet extends EveObjectSet this._activeTurret = -1; this._recheckTimeLeft = 0; this._currentCyclingFiresPos = 0; - + this._perObjectDataActive = new Tw2PerObjectData(); this._perObjectDataActive.perObjectVSData = new Tw2RawData(); this._perObjectDataActive.perObjectVSData.Declare('baseCutoffData', 4); @@ -227,7 +227,7 @@ export class EveTurretSet extends EveObjectSet { const item = this.items[i]; if (!item.display && !item.canFireWhenHidden) continue; - + turretPosition[0] = item._localTransform[12]; turretPosition[1] = item._localTransform[13]; turretPosition[2] = item._localTransform[14]; @@ -459,7 +459,7 @@ export class EveTurretSet extends EveObjectSet for (let i = 0; i < locators.length; i++) { - const {name, transform, bone=null} = locators[i]; + const {name, transform, bone = null} = locators[i]; let item = this.FindItemByLocatorName(name); if (!item) @@ -697,7 +697,7 @@ export class EveTurretSet extends EveObjectSet if (!this.turretEffect || !this.turretEffect.IsGood() || !this._visibleItems.length) return false; let index = 0; - const customSetter = function (el) + const customSetter = function(el) { device.gl.disableVertexAttribArray(el.location); device.gl.vertexAttrib2f(el.location, index, index); @@ -793,7 +793,7 @@ export class EveTurretSet extends EveObjectSet translation[i * 4 + 1] = item._localTransform[13]; translation[i * 4 + 2] = item._localTransform[14]; translation[i * 4 + 3] = 1; - + rotation[i * 4] = item.rotation[0]; rotation[i * 4 + 1] = item.rotation[1]; rotation[i * 4 + 2] = item.rotation[2]; @@ -832,7 +832,7 @@ export class EveTurretSet extends EveObjectSet /** * mat3x4 to quat */ -EveTurretSet.mat3x4toquat = (function () +EveTurretSet.mat3x4toquat = (function() { let m, q; diff --git a/src/eve/object/EveObject.js b/src/eve/object/EveObject.js index e36dee7..6b72567 100644 --- a/src/eve/object/EveObject.js +++ b/src/eve/object/EveObject.js @@ -31,7 +31,7 @@ export class EveObject * @param {Array} [out=[]] * @returns {Array} out */ - GetResources(out=[]) + GetResources(out = []) { return out; } diff --git a/src/eve/object/EveShip.js b/src/eve/object/EveShip.js index 7b91dfe..74170c0 100644 --- a/src/eve/object/EveShip.js +++ b/src/eve/object/EveShip.js @@ -92,7 +92,7 @@ export class EveShip extends EveSpaceObject * @param {Boolean} excludeChildren - True to exclude children's res objects * @returns {Array.} [out] */ - GetResources(out=[], excludeChildren) + GetResources(out = [], excludeChildren) { super.GetResources(out, excludeChildren); diff --git a/src/eve/object/EveSpaceObject.js b/src/eve/object/EveSpaceObject.js index 950ad69..fc2aabb 100644 --- a/src/eve/object/EveSpaceObject.js +++ b/src/eve/object/EveSpaceObject.js @@ -480,7 +480,7 @@ export class EveSpaceObject extends EveObject if (show.lineSets) { - for (let i = 0; i < this.lineSets.length; i++) + for (let i = 0; i < this.lineSets.length; i++) { this.lineSets[i].GetBatches(mode, accumulator); } @@ -523,4 +523,4 @@ export class EveSpaceObject extends EveObject } } -export { EveSpaceObject as EveStation }; \ No newline at end of file +export {EveSpaceObject as EveStation}; \ No newline at end of file diff --git a/src/eve/object/EveTransform.js b/src/eve/object/EveTransform.js index dbfaa44..35c7903 100644 --- a/src/eve/object/EveTransform.js +++ b/src/eve/object/EveTransform.js @@ -73,7 +73,7 @@ export class EveTransform extends EveObject * @param {Boolean} [excludeChildren] - True to exclude children's res objects * @returns {Array.} [out] */ - GetResources(out=[], excludeChildren) + GetResources(out = [], excludeChildren) { if (this.mesh) this.mesh.GetResources(out); diff --git a/src/global/engine/Tw2Device.js b/src/global/engine/Tw2Device.js index 9223fa4..c358074 100644 --- a/src/global/engine/Tw2Device.js +++ b/src/global/engine/Tw2Device.js @@ -162,19 +162,19 @@ export class Tw2Device } this.ext = { - drawElementsInstanced: function () + drawElementsInstanced: function() { return false; }, - drawArraysInstanced: function () + drawArraysInstanced: function() { return false; }, - vertexAttribDivisor: function () + vertexAttribDivisor: function() { return false; }, - hasInstancedArrays: function () + hasInstancedArrays: function() { return false; } @@ -186,19 +186,19 @@ export class Tw2Device { case Tw2Device.WebglVersion.WEBGL2: this.ext = { - drawElementsInstanced: function (mode, count, type, offset, instanceCount) + drawElementsInstanced: function(mode, count, type, offset, instanceCount) { gl.drawElementsInstanced(mode, count, type, offset, instanceCount); }, - drawArraysInstanced: function (mode, first, count, instanceCount) + drawArraysInstanced: function(mode, first, count, instanceCount) { gl.drawArraysInstanced(mode, first, count, instanceCount); }, - vertexAttribDivisor: function (location, divisor) + vertexAttribDivisor: function(location, divisor) { gl.vertexAttribDivisor(location, divisor); }, - hasInstancedArrays: function () + hasInstancedArrays: function() { return true; } @@ -214,19 +214,19 @@ export class Tw2Device if (instancedArrays) { this.ext = { - drawElementsInstanced: function (mode, count, type, offset, instanceCount) + drawElementsInstanced: function(mode, count, type, offset, instanceCount) { instancedArrays['drawElementsInstancedANGLE'](mode, count, type, offset, instanceCount); }, - drawArraysInstanced: function (mode, first, count, instanceCount) + drawArraysInstanced: function(mode, first, count, instanceCount) { instancedArrays['drawArraysInstancedANGLE'](mode, first, count, instanceCount); }, - vertexAttribDivisor: function (location, divisor) + vertexAttribDivisor: function(location, divisor) { instancedArrays['vertexAttribDivisorANGLE'](location, divisor); }, - hasInstancedArrays: function () + hasInstancedArrays: function() { return true; } @@ -648,7 +648,7 @@ export class Tw2Device * @param {string} technique - Technique name * @returns {boolean} */ - RenderFullScreenQuad(effect, technique='Main') + RenderFullScreenQuad(effect, technique = 'Main') { if (!effect || !effect.IsGood()) return false; @@ -690,7 +690,7 @@ export class Tw2Device * @param {string} technique - Technique name * @returns {boolean} */ - RenderCameraSpaceQuad(effect, technique='Main') + RenderCameraSpaceQuad(effect, technique = 'Main') { if (!effect || !effect.IsGood()) return false; @@ -1103,7 +1103,7 @@ let timeOuts; * @param {Function} callback * @returns {number} id */ -Tw2Device.RequestAnimationFrame = (function () +Tw2Device.RequestAnimationFrame = (function() { const requestFrame = window['requestAnimationFrame'] || @@ -1111,7 +1111,7 @@ Tw2Device.RequestAnimationFrame = (function () window['mozRequestAnimationFrame'] || window['oRequestAnimationFrame'] || window['msRequestAnimationFrame'] || - function (callback) + function(callback) { if (!timeOuts) timeOuts = []; timeOuts.push(window.setTimeout(callback, 1000 / 60)); @@ -1129,7 +1129,7 @@ Tw2Device.RequestAnimationFrame = (function () * Cancels an animation frame by it's id * @param {number} id */ -Tw2Device.CancelAnimationFrame = (function () +Tw2Device.CancelAnimationFrame = (function() { const cancelFrame = window['cancelAnimationFrame'] || @@ -1137,7 +1137,7 @@ Tw2Device.CancelAnimationFrame = (function () window['mozRequestAnimationFrame'] || window['oRequestAnimationFrame'] || window['msRequestAnimationFrame'] || - function (id) + function(id) { if (!timeOuts) timeOuts = []; if (timeOuts[id] !== undefined) diff --git a/src/global/engine/Tw2Logger.js b/src/global/engine/Tw2Logger.js index b542a44..47d46fa 100644 --- a/src/global/engine/Tw2Logger.js +++ b/src/global/engine/Tw2Logger.js @@ -34,7 +34,7 @@ import {assignIfExists} from '../util'; */ class Tw2Logger extends Tw2EventEmitter { - constructor(name='') + constructor(name = '') { super(); this.name = name; @@ -127,10 +127,10 @@ class Tw2Logger extends Tw2EventEmitter * Sets the logger's properties * @param {*} [opt={}] */ - Set(opt={}) + Set(opt = {}) { assignIfExists(this, opt, ['name', 'maxLogs', 'display']); - assignIfExists(this.visible, opt.visible, ['log','info','debug','warn','error']); + assignIfExists(this.visible, opt.visible, ['log', 'info', 'debug', 'warn', 'error']); } } diff --git a/src/global/engine/Tw2MotherLode.js b/src/global/engine/Tw2MotherLode.js index 0e2f1cd..2a849ba 100644 --- a/src/global/engine/Tw2MotherLode.js +++ b/src/global/engine/Tw2MotherLode.js @@ -1,6 +1,6 @@ /** * Manages loaded resources - * + * * @property {Object} _loadedObjects - loaded resources * @property {{string:Array}} _errors - Not implemented yet * @class @@ -16,21 +16,22 @@ export class Tw2MotherLode /** * Adds an error log for a given path * @param {string} path - * @param {eventLog} log + * @param {Tw2Error|Error} err */ - AddError(path, log) + AddError(path, err) { this._errors[path] = this._errors[path] || []; - if (!this._errors[path].includes(log)) + + if (!this._errors[path].includes(err)) { - this._errors[path].push(log); + this._errors[path].push(err); } } /** * Gets a path's error logs * @param {string} path - * @returns {?Array} + * @returns {?Array} */ GetErrors(path) { @@ -40,7 +41,7 @@ export class Tw2MotherLode /** * Finds a loaded object by it's file path * @param {string} path - * @returns {Tw2LoadingObject} + * @returns {Tw2LoadingObject|Tw2Resource} */ Find(path) { @@ -114,7 +115,7 @@ export class Tw2MotherLode const res = this._loadedObjects[path]; if (!res.doNotPurge) { - if (res._isPurged) + if (res.IsPurged()) { logger.log('res.event', { msg: 'Unloaded ', diff --git a/src/global/engine/Tw2ResMan.js b/src/global/engine/Tw2ResMan.js index 1e7e451..c4f780b 100644 --- a/src/global/engine/Tw2ResMan.js +++ b/src/global/engine/Tw2ResMan.js @@ -383,7 +383,7 @@ export class Tw2ResMan */ static DoLoadResource(resMan, res) { - return function () + return function() { let readyState = 0; diff --git a/src/global/engine/Tw2Store.js b/src/global/engine/Tw2Store.js index fffacfb..58f23be 100644 --- a/src/global/engine/Tw2Store.js +++ b/src/global/engine/Tw2Store.js @@ -1,5 +1,6 @@ import {isString, isPlain, isArray, isFunction, toArray, isUndefined, enableUUID} from '../util'; import {logger} from './Tw2Logger'; +import {Tw2Error} from '../../core'; /** * Stores engine data @@ -180,11 +181,13 @@ class Tw2Store */ RegisterConstructor(name, Constructor) { - if (isFunction(Constructor)) + // Don't store errors as library constructors + if (Constructor && (Constructor instanceof Tw2Error || Constructor.isError)) { - return Tw2Store.SetStoreItem(this, 'constructor', name, Constructor); + return false; } - return false; + + return Tw2Store.SetStoreItem(this, 'constructor', name, Constructor, isFunction); } /** @@ -328,7 +331,7 @@ class Tw2Store { Type = this.GetTypeByValue(value); } - + if (isString(Type)) { Type = this.GetType(Type); @@ -393,7 +396,7 @@ class Tw2Store RegisterSchema(name, schema) { return Tw2Store.SetStoreItem(this, 'schema', name, schema, a => - { + { return a && a.constructor.name === 'Tw2Schema'; }); } diff --git a/src/global/engine/index.js b/src/global/engine/index.js index 4742c2b..b191150 100644 --- a/src/global/engine/index.js +++ b/src/global/engine/index.js @@ -1,4 +1,4 @@ -export { device } from './Tw2Device'; -export { resMan } from './Tw2ResMan'; -export { store } from './Tw2Store'; -export { logger } from './Tw2Logger'; \ No newline at end of file +export {device} from './Tw2Device'; +export {resMan} from './Tw2ResMan'; +export {store} from './Tw2Store'; +export {logger} from './Tw2Logger'; \ No newline at end of file diff --git a/src/global/index.js b/src/global/index.js index c7584a4..93f09a8 100644 --- a/src/global/index.js +++ b/src/global/index.js @@ -2,6 +2,7 @@ export * from './math'; export * from './engine'; import * as util from './util'; -export { util }; + +export {util}; diff --git a/src/global/math/curve.js b/src/global/math/curve.js index 567f884..3404873 100644 --- a/src/global/math/curve.js +++ b/src/global/math/curve.js @@ -13,7 +13,7 @@ export const curve = {}; * @param {boolean} cycle * @param {number} duration */ -curve.evaluate = function (curve, time, value, cycle, duration) +curve.evaluate = function(curve, time, value, cycle, duration) { let count = curve.knots.length; let knot = count - 1; @@ -117,7 +117,7 @@ curve.evaluate = function (curve, time, value, cycle, duration) * @param s * @returns {*} */ -curve.ag_horner1 = function (P, deg, s) +curve.ag_horner1 = function(P, deg, s) { let h = P[deg]; while (--deg >= 0) h = (s * h) + P[deg]; @@ -135,7 +135,7 @@ curve.ag_horner1 = function (P, deg, s) * @param pars * @returns {*} */ -curve.ag_zeroin2 = function (a, b, fa, fb, tol, pars) +curve.ag_zeroin2 = function(a, b, fa, fb, tol, pars) { let test; let c, d, e, fc, del, m, machtol, p, q, r, s; @@ -240,7 +240,7 @@ curve.ag_zeroin2 = function (a, b, fa, fb, tol, pars) * @param pars * @returns {*} */ -curve.ag_zeroin = function (a, b, tol, pars) +curve.ag_zeroin = function(a, b, tol, pars) { let fa, fb; @@ -265,7 +265,7 @@ curve.ag_zeroin = function (a, b, tol, pars) * @param Roots * @returns {*} */ -curve.polyZeroes = function (Poly, deg, a, a_closed, b, b_closed, Roots) +curve.polyZeroes = function(Poly, deg, a, a_closed, b, b_closed, Roots) { let i, left_ok, right_ok, nr, ndr, skip; diff --git a/src/global/math/mat3.js b/src/global/math/mat3.js index 6a58c6e..0e94ff8 100644 --- a/src/global/math/mat3.js +++ b/src/global/math/mat3.js @@ -1,2 +1,3 @@ import {mat3} from 'gl-matrix'; + export {mat3}; diff --git a/src/global/math/mat4.js b/src/global/math/mat4.js index a4c5536..f4032d3 100644 --- a/src/global/math/mat4.js +++ b/src/global/math/mat4.js @@ -1,4 +1,5 @@ import {mat4, vec3} from 'gl-matrix'; + export {mat4}; /** @@ -18,7 +19,7 @@ mat4.arcFromForward = (function() const norm = vec3.normalize(vec3_0, v); mat4.identity(out); - if (norm[2] < -0.99999) + if (norm[2] < -0.99999) { return out; } @@ -92,7 +93,7 @@ mat4.fromMat3 = function(out, m) * @param {vec3} up - vec3 pointing up * @returns {mat4} out */ -mat4.lookAtGL = (function () +mat4.lookAtGL = (function() { let vec3_0, vec3_1, vec3_2; diff --git a/src/global/math/noise.js b/src/global/math/noise.js index 9981987..a452c10 100644 --- a/src/global/math/noise.js +++ b/src/global/math/noise.js @@ -1,5 +1,6 @@ import {vec3} from './vec3'; import {vec4} from './vec4'; + export const noise = {}; /** @@ -172,7 +173,7 @@ noise.perlin1 = (function() p_initialized = true; } - + return function perlin1(a) { if (!p_initialized) initialize(); @@ -200,7 +201,7 @@ noise.perlin1 = (function() * @param n * @returns {number} */ -noise.perlin1D = function (x, alpha, beta, n) +noise.perlin1D = function(x, alpha, beta, n) { let sum = 0, p = x, diff --git a/src/global/math/num.js b/src/global/math/num.js index 5b41ffa..4f23175 100644 --- a/src/global/math/num.js +++ b/src/global/math/num.js @@ -26,7 +26,7 @@ num.biCumulative = function(t, order) /** * Exponential decay - * + * * @param {number} omega0 * @param {number} torque * @param {number} I - inertia diff --git a/src/global/math/quat.js b/src/global/math/quat.js index e7bc359..a9193bb 100644 --- a/src/global/math/quat.js +++ b/src/global/math/quat.js @@ -1,4 +1,5 @@ import {quat} from 'gl-matrix'; + export {quat}; /** @@ -8,7 +9,7 @@ export {quat}; * @param {quat|vec3} a * @returns {quat} */ -quat.exp = function (out, a) +quat.exp = function(out, a) { let norm = Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]); if (norm) @@ -35,7 +36,7 @@ quat.exp = function (out, a) * @param {quat} q * @returns {quat} */ -quat.ln = function (out, q) +quat.ln = function(out, q) { let norm = quat.length(q); if (norm > 1.0001 || norm < 0.99999) @@ -75,7 +76,7 @@ quat.ln = function (out, q) * @param {number} exponent * @returns {quat} */ -quat.pow = function (out, inq, exponent) +quat.pow = function(out, inq, exponent) { if (exponent === 1) { diff --git a/src/global/math/vec2.js b/src/global/math/vec2.js index a208ab3..808eb6c 100644 --- a/src/global/math/vec2.js +++ b/src/global/math/vec2.js @@ -1,3 +1,4 @@ import {vec2} from 'gl-matrix'; + export {vec2}; diff --git a/src/global/math/vec3.js b/src/global/math/vec3.js index 22f6fd4..eace61e 100644 --- a/src/global/math/vec3.js +++ b/src/global/math/vec3.js @@ -1,5 +1,6 @@ import {vec3, vec4} from 'gl-matrix'; import {num} from './num'; + export {vec3}; /** diff --git a/src/global/math/vec4.js b/src/global/math/vec4.js index 6512eab..5dc3c29 100644 --- a/src/global/math/vec4.js +++ b/src/global/math/vec4.js @@ -1,2 +1,3 @@ import {vec4} from 'gl-matrix'; + export {vec4}; diff --git a/src/global/util/arr.js b/src/global/util/arr.js index d258fb0..379b32a 100644 --- a/src/global/util/arr.js +++ b/src/global/util/arr.js @@ -1,4 +1,4 @@ -import { isArray } from './type'; +import {isArray} from './type'; /** * Adds arguments to an array if they don't already exist in it diff --git a/src/global/util/type.js b/src/global/util/type.js index abe4c10..48ee782 100644 --- a/src/global/util/type.js +++ b/src/global/util/type.js @@ -122,7 +122,7 @@ export function isObjectLike(a) */ export function isPlain(a) { - if (!isObject(a) || !isTag(a,'[object Object]')) + if (!isObject(a) || !isTag(a, '[object Object]')) { return false; } diff --git a/src/global/util/url.js b/src/global/util/url.js index 913a28f..d44458e 100644 --- a/src/global/util/url.js +++ b/src/global/util/url.js @@ -1,4 +1,3 @@ - const url = {}, query = window.location.search.substring(1), diff --git a/src/index.js b/src/index.js index 3d61fd6..e54421d 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,7 @@ import * as core from './core'; import * as curve from './curve'; import * as eve from './eve'; import * as particle from './particle'; -import { device, store, resMan, logger, util } from './global'; +import {device, store, resMan, logger, util} from './global'; export * from './core'; export * from './curve'; @@ -28,9 +28,9 @@ store.Register({ 'wbg': core.Tw2GeometryRes, 'png': core.Tw2TextureRes, 'cube': core.Tw2TextureRes, - 'mp4' : core.Tw2VideoRes, - 'ogg' : core.Tw2VideoRes, - 'webm' : core.Tw2VideoRes + 'mp4': core.Tw2VideoRes, + 'ogg': core.Tw2VideoRes, + 'webm': core.Tw2VideoRes }, constructors: [ diff --git a/src/particle/Tw2ParticleSystem.js b/src/particle/Tw2ParticleSystem.js index 5e50e9c..ef95073 100644 --- a/src/particle/Tw2ParticleSystem.js +++ b/src/particle/Tw2ParticleSystem.js @@ -36,9 +36,9 @@ import {Tw2ParticleElementDeclaration} from './Tw2ParticleElement'; * @property {Array} buffers * @class */ -export class Tw2ParticleSystem +export class Tw2ParticleSystem { - constructor() + constructor() { this._id = util.generateID(); this.name = ''; @@ -77,7 +77,7 @@ export class Tw2ParticleSystem /** * Initializes the Particle System */ - Initialize() + Initialize() { this.UpdateElementDeclaration(); } @@ -85,13 +85,14 @@ export class Tw2ParticleSystem /** * Updates Element Declarations */ - UpdateElementDeclaration() + UpdateElementDeclaration() { this.isValid = false; + const gl = device.gl; - if (this._vb) + if (this._vb) { - device.gl.deleteBuffer(this._vb); + gl.deleteBuffer(this._vb); this._vb = null; } @@ -107,7 +108,7 @@ export class Tw2ParticleSystem this._declaration = new Tw2VertexDeclaration(); this.buffers = [null, null]; - for (let i = 0; i < this.elements.length; ++i) + for (let i = 0; i < this.elements.length; ++i) { const bufferIndex = this.elements[i].usedByGPU ? 0 : 1, @@ -116,13 +117,13 @@ export class Tw2ParticleSystem el.startOffset = this.vertexStride[bufferIndex]; el.offset = el.startOffset; - if (this.elements[i].elementType !== Tw2ParticleElementDeclaration.Type.CUSTOM) + if (this.elements[i].elementType !== Tw2ParticleElementDeclaration.Type.CUSTOM) { this._stdElements[this.elements[i].elementType] = el; } this.vertexStride[bufferIndex] += el.dimension; this._elements.push(el); - if (bufferIndex === 0) + if (bufferIndex === 0) { const d = this.elements[i].GetDeclaration(); d.offset = el.startOffset * 4; @@ -132,7 +133,7 @@ export class Tw2ParticleSystem this._declaration.RebuildHash(); - for (let i = 0; i < this._elements.length; ++i) + for (let i = 0; i < this._elements.length; ++i) { const bufferIndex = this._elements[i].usedByGPU ? 0 : 1; this._elements[i].vertexStride = this.vertexStride[bufferIndex]; @@ -141,34 +142,34 @@ export class Tw2ParticleSystem this.instanceStride[0] = this.vertexStride[0] * 4; this.instanceStride[1] = this.vertexStride[1] * 4; - for (let i = 0; i < this._elements.length; ++i) + for (let i = 0; i < this._elements.length; ++i) { const bufferIndex = this._elements[i].usedByGPU ? 0 : 1; this._elements[i].instanceStride = this.instanceStride[bufferIndex]; } this.buffers = [null, null]; - if (this.instanceStride[0] && this.maxParticleCount) + if (this.instanceStride[0] && this.maxParticleCount) { this.buffers[0] = new Float32Array(this.instanceStride[0] * this.maxParticleCount); - this._vb = device.gl.createBuffer(); - device.gl.bindBuffer(device.gl.ARRAY_BUFFER, this._vb); - device.gl.bufferData(device.gl.ARRAY_BUFFER, this.buffers[0].length, device.gl.DYNAMIC_DRAW); - device.gl.bindBuffer(device.gl.ARRAY_BUFFER, null); + this._vb = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vb); + gl.bufferData(gl.ARRAY_BUFFER, this.buffers[0].length, gl.DYNAMIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, null); } - if (this.instanceStride[1]) + if (this.instanceStride[1]) { this.buffers[1] = new Float32Array(this.instanceStride[1] * this.maxParticleCount); } - for (let i = 0; i < this._elements.length; ++i) + for (let i = 0; i < this._elements.length; ++i) { const bufferIndex = this._elements[i].usedByGPU ? 0 : 1; this._elements[i].buffer = this.buffers[bufferIndex]; } - if (this.requiresSorting) + if (this.requiresSorting) { this._sortedIndexes = new Array(this.maxParticleCount); this._sortedBuffer = new Float32Array(this.instanceStride[0] * this.maxParticleCount); @@ -184,7 +185,7 @@ export class Tw2ParticleSystem * @param {number} type * @returns {boolean} */ - HasElement(type) + HasElement(type) { return this._stdElements[type] !== null; } @@ -194,9 +195,9 @@ export class Tw2ParticleSystem * @param {number} type * @returns {Tw2ParticleElement} */ - GetElement(type) + GetElement(type) { - if (this._stdElements[type]) + if (this._stdElements[type]) { this._stdElements[type].offset = this._stdElements[type].startOffset; } @@ -207,7 +208,7 @@ export class Tw2ParticleSystem * Begins particle spawning * @returns {?number} */ - BeginSpawnParticle() + BeginSpawnParticle() { if (!this.isValid || this.aliveCount >= this.maxParticleCount) return null; return this.aliveCount++; @@ -216,7 +217,7 @@ export class Tw2ParticleSystem /** * Ends particle spawning */ - EndSpawnParticle() + EndSpawnParticle() { this.bufferDirty = true; } @@ -225,33 +226,33 @@ export class Tw2ParticleSystem * Per frame update * @param {number} dt - delta time */ - Update(dt) + Update(dt) { dt = Math.min(dt, 0.1); - if (this.applyAging && this.HasElement(Tw2ParticleElementDeclaration.Type.LIFETIME)) + if (this.applyAging && this.HasElement(Tw2ParticleElementDeclaration.Type.LIFETIME)) { const lifetime = this.GetElement(Tw2ParticleElementDeclaration.Type.LIFETIME), position = this.emitParticleOnDeathEmitter ? this.GetElement(Tw2ParticleElementDeclaration.Type.POSITION) : null, velocity = this.emitParticleOnDeathEmitter ? this.GetElement(Tw2ParticleElementDeclaration.Type.VELOCITY) : null; - for (let i = 0; i < this.aliveCount; ++i) + for (let i = 0; i < this.aliveCount; ++i) { lifetime.buffer[lifetime.offset] += dt / lifetime.buffer[lifetime.offset + 1]; - if (lifetime.buffer[lifetime.offset] > 1) + if (lifetime.buffer[lifetime.offset] > 1) { - if (this.emitParticleOnDeathEmitter) + if (this.emitParticleOnDeathEmitter) { this.emitParticleOnDeathEmitter.SpawnParticles(position, velocity, 1); } this.aliveCount--; - if (i < this.aliveCount) + if (i < this.aliveCount) { - for (let j = 0; j < 2; ++j) + for (let j = 0; j < 2; ++j) { - if (this.buffers[j]) + if (this.buffers[j]) { this.buffers[j].set(this.buffers[j].subarray(this.instanceStride[j] * this.aliveCount, this.instanceStride[j] * this.aliveCount + this.instanceStride[j]), i * this.instanceStride[j]); } @@ -260,7 +261,7 @@ export class Tw2ParticleSystem this.bufferDirty = true; } } - else + else { lifetime.offset += lifetime.instanceStride; if (position) position.offset += position.instanceStride; @@ -272,10 +273,10 @@ export class Tw2ParticleSystem const vec3_0 = Tw2ParticleSystem.global.vec3_0; - if (this.updateSimulation && this.HasElement(Tw2ParticleElementDeclaration.Type.POSITION) && this.HasElement(Tw2ParticleElementDeclaration.Type.VELOCITY)) + if (this.updateSimulation && this.HasElement(Tw2ParticleElementDeclaration.Type.POSITION) && this.HasElement(Tw2ParticleElementDeclaration.Type.VELOCITY)) { const hasForces = this.applyForce && this.forces.length; - for (let i = 0; i < this.forces.length; ++i) + for (let i = 0; i < this.forces.length; ++i) { this.forces[i].Update(dt); } @@ -285,15 +286,15 @@ export class Tw2ParticleSystem velocity = this.GetElement(Tw2ParticleElementDeclaration.Type.VELOCITY), mass = hasForces ? this.GetElement(Tw2ParticleElementDeclaration.Type.MASS) : null; - for (let i = 0; i < this.aliveCount; ++i) + for (let i = 0; i < this.aliveCount; ++i) { - if (hasForces) + if (hasForces) { const amass = mass ? mass.buffer[mass.offset] : 1, force = vec3.set(vec3_0, 0, 0, 0); - for (let j = 0; j < this.forces.length; ++j) + for (let j = 0; j < this.forces.length; ++j) { this.forces[j].ApplyForce(position, velocity, force, dt, amass); } @@ -309,7 +310,7 @@ export class Tw2ParticleSystem position.buffer[position.offset + 1] += velocity.buffer[velocity.offset + 1] * dt; position.buffer[position.offset + 2] += velocity.buffer[velocity.offset + 2] * dt; - if (this.emitParticleDuringLifeEmitter) + if (this.emitParticleDuringLifeEmitter) { this.emitParticleDuringLifeEmitter.SpawnParticles(position, velocity, dt); } @@ -323,26 +324,26 @@ export class Tw2ParticleSystem velocity.dirty = true; } - if (this.updateSimulation && this.constraints.length) + if (this.updateSimulation && this.constraints.length) { - for (let i = 0; i < this.constraints.length; ++i) + for (let i = 0; i < this.constraints.length; ++i) { this.constraints[i].ApplyConstraint(this.buffers, this.instanceStride, this.aliveCount, dt); } } - if (this.updateBoundingBox) + if (this.updateBoundingBox) { this.GetBoundingBox(this.aabbMin, this.aabbMax); } - if (this.emitParticleDuringLifeEmitter && !(this.HasElement(Tw2ParticleElementDeclaration.Type.POSITION) && this.HasElement(Tw2ParticleElementDeclaration.Type.VELOCITY)) && this.updateSimulation) + if (this.emitParticleDuringLifeEmitter && !(this.HasElement(Tw2ParticleElementDeclaration.Type.POSITION) && this.HasElement(Tw2ParticleElementDeclaration.Type.VELOCITY)) && this.updateSimulation) { const position = this.GetElement(Tw2ParticleElementDeclaration.Type.POSITION), velocity = this.GetElement(Tw2ParticleElementDeclaration.Type.VELOCITY); - for (let i = 0; i < this.aliveCount; ++i) + for (let i = 0; i < this.aliveCount; ++i) { this.emitParticleDuringLifeEmitter.SpawnParticles(position, velocity, 1); if (position) position.offset += position.instanceStride; @@ -350,11 +351,11 @@ export class Tw2ParticleSystem } } - for (let i = 0; i < this._elements.length; ++i) + for (let i = 0; i < this._elements.length; ++i) { const el = this._elements[i]; el.offset = el.startOffset; - if (el.dirty) + if (el.dirty) { this.bufferDirty = true; el.dirty = false; @@ -368,9 +369,9 @@ export class Tw2ParticleSystem * @param {vec3} aabbMax * @returns {boolean} */ - GetBoundingBox(aabbMin, aabbMax) + GetBoundingBox(aabbMin, aabbMax) { - if (this.aliveCount && this.HasElement(Tw2ParticleElementDeclaration.Type.POSITION)) + if (this.aliveCount && this.HasElement(Tw2ParticleElementDeclaration.Type.POSITION)) { const position = this.GetElement(Tw2ParticleElementDeclaration.Type.POSITION); aabbMin[0] = position.buffer[position.offset]; @@ -379,7 +380,7 @@ export class Tw2ParticleSystem aabbMax[0] = position.buffer[position.offset]; aabbMax[1] = position.buffer[position.offset + 1]; aabbMax[2] = position.buffer[position.offset + 2]; - for (let i = 0; i < this.aliveCount; ++i) + for (let i = 0; i < this.aliveCount; ++i) { aabbMin[0] = Math.min(aabbMin[0], position.buffer[position.offset]); aabbMin[1] = Math.min(aabbMin[1], position.buffer[position.offset + 1]); @@ -398,7 +399,7 @@ export class Tw2ParticleSystem * _Sort * @private */ - _Sort() + _Sort() { const eye = mat4.multiply(Tw2ParticleSystem.global.mat4_0, device.projection, device.view), //device.viewInverse; @@ -406,7 +407,7 @@ export class Tw2ParticleSystem count = this.aliveCount, distances = this._distancesBuffer; - for (let i = 0; i < count; ++i) + for (let i = 0; i < count; ++i) { const o0 = position.offset + position.instanceStride * i; let dd = position.buffer[o0] - eye[12], @@ -426,9 +427,9 @@ export class Tw2ParticleSystem * @returns {number} * @private */ - function sortItems(a, b) + function sortItems(a, b) { - if (a >= count && b >= count) + if (a >= count && b >= count) { if (a < b) return -1; if (a > b) return 1; @@ -447,7 +448,7 @@ export class Tw2ParticleSystem return 0; } - for (let i = 0; i < this.maxParticleCount; ++i) + for (let i = 0; i < this.maxParticleCount; ++i) { this._sortedIndexes[i] = i; } @@ -459,12 +460,12 @@ export class Tw2ParticleSystem * Updates and gets the particle system's InstanceBuffer * @returns {?WebGLBuffer} */ - GetInstanceBuffer() + GetInstanceBuffer() { if (this.aliveCount === 0) return undefined; - const d = device; - if (this.requiresSorting && this.HasElement(Tw2ParticleElementDeclaration.Type.POSITION) && this.buffers) + const gl = device.gl; + if (this.requiresSorting && this.HasElement(Tw2ParticleElementDeclaration.Type.POSITION) && this.buffers) { this._Sort(); @@ -472,26 +473,26 @@ export class Tw2ParticleSystem stride = this.instanceStride[0], gpuBuffer = this.buffers[0]; - for (let i = 0; i < this.aliveCount; ++i) + for (let i = 0; i < this.aliveCount; ++i) { const toOffset = i * stride, fromOffset = this._sortedIndexes[i] * stride; - for (let j = 0; j < stride; ++j) + for (let j = 0; j < stride; ++j) { this._sortedBuffer[toOffset + j] = gpuBuffer[j + fromOffset]; } } - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vb); - d.gl.bufferSubData(d.gl.ARRAY_BUFFER, 0, this._sortedBuffer.subarray(0, this.vertexStride[0] * this.aliveCount)); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vb); + gl.bufferSubData(gl.ARRAY_BUFFER, 0, this._sortedBuffer.subarray(0, this.vertexStride[0] * this.aliveCount)); this.bufferDirty = false; } - else if (this.bufferDirty) + else if (this.bufferDirty) { - d.gl.bindBuffer(d.gl.ARRAY_BUFFER, this._vb); - d.gl.bufferSubData(d.gl.ARRAY_BUFFER, 0, this.buffers[0].subarray(0, this.vertexStride[0] * this.aliveCount)); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vb); + gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.buffers[0].subarray(0, this.vertexStride[0] * this.aliveCount)); this.bufferDirty = false; } @@ -502,7 +503,7 @@ export class Tw2ParticleSystem * Gets the particle system's InstanceDeclaration * @returns {Tw2VertexDeclaration} */ - GetInstanceDeclaration() + GetInstanceDeclaration() { return this._declaration; } @@ -511,7 +512,7 @@ export class Tw2ParticleSystem * Gets the particle system's InstanceStride * @returns {number} */ - GetInstanceStride() + GetInstanceStride() { return this.instanceStride[0]; } @@ -520,7 +521,7 @@ export class Tw2ParticleSystem * Gets the particle system's InstanceCount * @returns {number} */ - GetInstanceCount() + GetInstanceCount() { return this.aliveCount; } @@ -528,9 +529,9 @@ export class Tw2ParticleSystem /** * Initializes class globals */ - static init() + static init() { - if (!Tw2ParticleSystem.global) + if (!Tw2ParticleSystem.global) { Tw2ParticleSystem.global = { vec3_0: vec3.create(), diff --git a/src/particle/emitters/Tw2GpuUniqueEmitter.js b/src/particle/emitters/Tw2GpuUniqueEmitter.js index 24b757c..1cf92df 100644 --- a/src/particle/emitters/Tw2GpuUniqueEmitter.js +++ b/src/particle/emitters/Tw2GpuUniqueEmitter.js @@ -1,4 +1,4 @@ -import { vec3, vec4 } from '../../global'; +import {vec3, vec4} from '../../global'; import {Tw2ParticleEmitter} from './Tw2ParticleEmitter'; /** @@ -63,4 +63,4 @@ export class Tw2GpuUniqueEmitter extends Tw2ParticleEmitter } // Temporary alias -export { Tw2GpuUniqueEmitter as Tr2GpuUniqueEmitter }; \ No newline at end of file +export {Tw2GpuUniqueEmitter as Tr2GpuUniqueEmitter}; \ No newline at end of file From b7936415d5228b3008f56a3d176e7bcffef8b8fa Mon Sep 17 00:00:00 2001 From: cppctamber Date: Fri, 17 Aug 2018 20:53:36 +1200 Subject: [PATCH 03/25] Added optional onLoaded callback to planets - Updated `EvePlanet.Create` so that it can now take an optional onload callback - Updated `ccpwgl.loadPlanet` so that it can now take an optional onload callback - Updated planet demo to include onload callbacks --- demos/planets.html | 43 +++++++++++++++------ dist/ccpwgl.js | 53 +++++++++++++++++--------- dist/ccpwgl_int.js | 74 +++++++++++++++++++++++++++++-------- dist/ccpwgl_int.min.js | 2 +- src/core/Tw2Error.js | 2 +- src/eve/object/EvePlanet.js | 58 +++++++++++++++++++++++------ src/global/util/type.js | 10 +++++ 7 files changed, 183 insertions(+), 59 deletions(-) diff --git a/demos/planets.html b/demos/planets.html index 5a86a2d..e696086 100644 --- a/demos/planets.html +++ b/demos/planets.html @@ -32,59 +32,78 @@ 'res:/dx9/model/WorldObject/Planet/Template/Moon/p_moon_51.red', undefined, 'res:/dx9/model/worldobject/planet/Moon/Moon01_H.dds.0.png', - 'res:/dx9/model/worldobject/planet/Moon/Moon03_H.dds.0.png'], + 'res:/dx9/model/worldobject/planet/Moon/Moon03_H.dds.0.png', + function() { console.warn('Loaded: Moon 1')}], [40000002, 'res:/dx9/model/WorldObject/Planet/Template/Terrestrial/P_Terrestrial_61.red', undefined, 'res:/dx9/model/worldobject/planet/Terrestrial/Terrestrial03_H.dds.0.png', - 'res:/dx9/model/worldobject/planet/Terrestrial/Terrestrial04_H.dds.0.png'], + 'res:/dx9/model/worldobject/planet/Terrestrial/Terrestrial04_H.dds.0.png', + function() { console.warn('Loaded: Terrestrial planet 1')}], [40000005, 'res:/dx9/model/WorldObject/Planet/Template/Terrestrial/P_Terrestrial_04.red', undefined, 'res:/dx9/Model/WorldObject/planet/Terrestrial/Terrestrial01_H.dds.0.png', - 'res:/dx9/model/worldobject/planet/Terrestrial/Terrestrial02_H.dds.0.png'], + 'res:/dx9/model/worldobject/planet/Terrestrial/Terrestrial02_H.dds.0.png', + function() { console.warn('Loaded: Terrestrial planet 2')}], [40000007, 'res:/dx9/model/WorldObject/Planet/Template/SandStorm/P_SandStorm_84.red', undefined, 'res:/dx9/model/worldobject/planet/Terrestrial/Terrestrial04_H.dds.0.png', - 'res:/dx9/model/worldobject/planet/Moon/Moon01_H.dds.0.png'], + 'res:/dx9/model/worldobject/planet/Moon/Moon01_H.dds.0.png', + function() { console.warn('Loaded: Sandstorm planet')}], [40000008, 'res:/dx9/model/WorldObject/Planet/Template/Ocean/P_Ocean_10.red', undefined, 'res:/dx9/Model/WorldObject/planet/Terrestrial/Terrestrial01_H.dds.0.png', - 'res:/dx9/model/worldobject/planet/Terrestrial/Terrestrial03_H.dds.0.png'], + 'res:/dx9/model/worldobject/planet/Terrestrial/Terrestrial03_H.dds.0.png', + function() { console.warn('Loaded: Ocean planet')}], [40000010, 'res:/dx9/model/WorldObject/Planet/Template/Moon/p_moon_32.red', undefined, 'res:/dx9/model/worldobject/planet/Moon/Moon02_H.dds.0.png', - 'res:/dx9/model/worldobject/planet/Moon/Moon02_H.dds.0.png'], + 'res:/dx9/model/worldobject/planet/Moon/Moon02_H.dds.0.png', + function() { console.warn('Loaded: Moon 2')}], [40000011, 'res:/dx9/model/WorldObject/Planet/Template/Gas/P_GasGiant_48.red', undefined, 'res:/dx9/model/worldobject/planet/Gasgiant/GasGiant01_D.dds.0.png', - 'res:/dx9/model/worldobject/planet/Gasgiant/GasGiant02_D.dds.0.png'], + 'res:/dx9/model/worldobject/planet/Gasgiant/GasGiant02_D.dds.0.png', + function() { console.warn('Loaded: Gas giant 1')}], [40000024, 'res:/dx9/model/WorldObject/Planet/Template/Lava/P_Lava_44_S.red', undefined, 'res:/dx9/model/worldobject/planet/Lava/Lava02_H.dds.0.png', - 'res:/dx9/model/worldobject/planet/Lava/Lava01_H.dds.0.png'], + 'res:/dx9/model/worldobject/planet/Lava/Lava01_H.dds.0.png', + function() { console.warn('Loaded: Lava planet')}], [40000100, 'res:/dx9/model/WorldObject/Planet/Template/Gas/P_GasGiant_12.red', undefined, 'res:/dx9/model/worldobject/planet/Gasgiant/GasGiant01_D.dds.0.png', - 'res:/dx9/model/worldobject/planet/Gasgiant/GasGiant03_D.dds.0.png'], + 'res:/dx9/model/worldobject/planet/Gasgiant/GasGiant03_D.dds.0.png', + function() { console.warn('Loaded: Gas giant 2')} + ], [40000123, 'res:/dx9/model/WorldObject/Planet/Template/Ice/P_Ice_61.red', undefined, 'res:/dx9/model/worldobject/planet/Ice/Ice04_H.dds.0.png', - 'res:/dx9/model/worldobject/planet/Terrestrial/Terrestrial02_H.dds.0.png'] + 'res:/dx9/model/worldobject/planet/Terrestrial/Terrestrial02_H.dds.0.png', + function() { console.warn('Loaded: Terrestrial planet 3')}], ]; window.planets = []; for (var i = 0; i < planets.length; ++i) { - var planet = scene.loadPlanet(planets[i][0], planets[i][1], planets[i][2], planets[i][3], planets[i][4]); + var planet = scene.loadPlanet( + planets[i][0], + planets[i][1], + planets[i][2], + planets[i][3], + planets[i][4], + planets[i][5] + ); + var angle = Math.PI * 2 * i / planets.length; planet.setTransform(mat4.fromValues( 10000, 0, 0, 0, @@ -95,7 +114,7 @@ window.planets.push(planet); } - ccpwgl.onPreRender = function () + ccpwgl.onPreRender = function() { document.getElementById('loading').style.display = ccpwgl.isLoading() ? 'block' : 'none'; }; diff --git a/dist/ccpwgl.js b/dist/ccpwgl.js index dbb4f63..4a5353e 100644 --- a/dist/ccpwgl.js +++ b/dist/ccpwgl.js @@ -1389,21 +1389,30 @@ var ccpwgl = (function(ccpwgl_int) /** * Wrapper for planets. Created with Scene.loadPlanet function. * + * @param {{}} [options={}] - an object containing the planet's options + * @param {number} options.itemID - the item id is used for randomization + * @param {string} options.planetPath - .red file for a planet, or planet template + * @param {string} [options.atmospherePath] - optional .red file for a planet's atmosphere + * @param {string} options.heightMap1 - planet's first height map + * @param {string} options.heightMap2 - planet's second height map + * @param {function} [onLoad] - an optional callback which is fired when the planet has loaded * @constructor - * @param {integer} itemID Planet's item ID. - * @param {string} planetPath Res path to planet's .red template file. - * @param {string} atmospherePath Res path to planet's .red atmosphere file. - * @param {string} heightMap1 Res path to planet's first height map texture. - * @param {string} heightMap2 Res path to planet's second height map texture. */ - function Planet(itemID, planetPath, atmospherePath, heightMap1, heightMap2) + function Planet(options, onLoad) { /** Wrapped ccpwgl_int planet object @type {ccpwgl_int.EvePlanet} **/ this.wrappedObjects = [new ccpwgl_int.EvePlanet()]; - this.wrappedObjects[0].Create(itemID, planetPath, atmospherePath, heightMap1, heightMap2); + + var self = this; + this.wrappedObjects[0].Create(options, function() + { + if (onLoad) onLoad.call(self); + }); + + /** Per-frame on update callback @type {!function(dt): void} **/ this.onUpdate = null; - + /** * Check if planet's resources are loaded and the resulting height map is generated. * @@ -1650,24 +1659,32 @@ var ccpwgl = (function(ccpwgl_int) } return object; }; - + /** * Creates a planet. * - * @param {integer} itemID Planet's item ID. - * @param {string} planetPath Res path to planet's .red template file. - * @param {string} atmospherePath Res path to planet's .red atmosphere file. - * @param {string} heightMap1 Res path to planet's first height map texture. - * @param {string} heightMap2 Res path to planet's second height map texture. + * @param {number} itemID - the item id is used for randomization + * @param {string} planetPath - .red file for a planet, or planet template + * @param {string} [atmospherePath] - optional .red file for a planet's atmosphere + * @param {string} heightMap1 - planet's first height map + * @param {string} heightMap2 - planet's second height map + * @param {function} [onLoad] - an optioanl callback which is fired when the planet has loaded * @returns {ccpwgl.Planet} A newly created planet instance. */ - this.loadPlanet = function(itemID, planetPath, atmospherePath, heightMap1, heightMap2) - { - var object = new Planet(itemID, planetPath, atmospherePath, heightMap1, heightMap2); + this.loadPlanet = function(itemID, planetPath, atmospherePath, heightMap1, heightMap2, onLoad) + { + var object = new Planet({ + itemID: itemID, + planetPath: planetPath, + atmospherePath: atmospherePath, + heightMap1: heightMap1, + heightMap2: heightMap2 + }, onLoad); + this.objects.push(object); rebuildSceneObjects(this); return object; - }; + } /** * Returns object (ship or planet) at a specified index in scene's objects list. diff --git a/dist/ccpwgl_int.js b/dist/ccpwgl_int.js index 9690112..6679886 100644 --- a/dist/ccpwgl_int.js +++ b/dist/ccpwgl_int.js @@ -3474,6 +3474,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol exports.isArrayLike = isArrayLike; exports.isBoolean = isBoolean; +exports.isCanvas = isCanvas; exports.isDescriptor = isDescriptor; exports.isNumber = isNumber; exports.isFunction = isFunction; @@ -3516,6 +3517,15 @@ function isBoolean(a) { return isTag(a, '[object Boolean]'); } +/** + * Checks if a value is an html canvas element + * @param {*} a + * @returns {boolean} + */ +function isCanvas(a) { + return !!(a && a instanceof HTMLCanvasElement); +} + /** * Checks if a value is a descriptor * @author jay phelps @@ -26486,7 +26496,7 @@ var Tw2SingleInstantiationError = exports.Tw2SingleInstantiationError = function function Tw2SingleInstantiationError(data) { _classCallCheck(this, Tw2SingleInstantiationError); - return _possibleConstructorReturn(this, (Tw2SingleInstantiationError.__proto__ || Object.getPrototypeOf(Tw2SingleInstantiationError)).call(this, data, 'Class can only be instantiated once')); + return _possibleConstructorReturn(this, (Tw2SingleInstantiationError.__proto__ || Object.getPrototypeOf(Tw2SingleInstantiationError)).call(this, data, 'Multiple class instantiations not yet supported')); } return Tw2SingleInstantiationError; @@ -34846,7 +34856,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" * @property {string} heightMapResPath2 * @property {boolean} heightDirty * @property {Array} lockedResources - * @property {Array.} watchedResources + * @property {Array.} watchedResources * @class */ var EvePlanet = exports.EvePlanet = function (_EveObject) { @@ -34871,38 +34881,70 @@ var EvePlanet = exports.EvePlanet = function (_EveObject) { } /** - * Creates the planet - * @param {number} itemID - the item id is used for randomization - * @param {string} planetPath - .red file for a planet, or planet template - * @param {string} [atmospherePath] - optional .red file for a planet's atmosphere - * @param {string} heightMap1 - * @param {string} heightMap2 + * Creates the planet from an options object + * @param {{}} options={} - an object containing the planet's options + * @param {number} options.itemID - the item id is used for randomization + * @param {string} options.planetPath - .red file for a planet, or planet template + * @param {string} [options.atmospherePath] - optional .red file for a planet's atmosphere + * @param {string} options.heightMap1 - the planet's first height map + * @param {string} options.heightMap2 - the planet's second height map + * @param {function} [onLoaded] - an optional callback which is fired when the planet has loaded */ _createClass(EvePlanet, [{ key: 'Create', - value: function Create(itemID, planetPath, atmospherePath, heightMap1, heightMap2) { + value: function Create() { var _this2 = this; + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var onLoaded = arguments[1]; + var _options$itemID = options.itemID, + itemID = _options$itemID === undefined ? 0 : _options$itemID, + planetPath = options.planetPath, + atmospherePath = options.atmospherePath, + heightMap1 = options.heightMap1, + heightMap2 = options.heightMap2; + + this.itemID = itemID; this.heightMapResPath1 = heightMap1; this.heightMapResPath2 = heightMap2; this.highDetail.children = []; this.heightDirty = true; - _global.resMan.GetObject(planetPath, function (obj) { - return EvePlanet.MeshLoaded(_this2, obj); - }); - _global.resMan.GetObject('res:/dx9/model/worldobject/planet/planetzonly.red', function (obj) { - return _this2.zOnlyModel = obj; - }); + var loadingParts = 1; + if (planetPath) loadingParts++; + if (atmospherePath) loadingParts++; + + /** + * Handles the optional onLoaded callback which is fired when all parts have loaded + */ + function onPartLoaded() { + loadingParts--; + if (loadingParts < 1 && onLoaded) { + onLoaded(); + } + } + + if (planetPath) { + _global.resMan.GetObject(planetPath, function (obj) { + EvePlanet.MeshLoaded(_this2, obj); + onPartLoaded(); + }); + } if (atmospherePath) { _global.resMan.GetObject(atmospherePath, function (obj) { - return _this2.highDetail.children.push(obj); + _this2.highDetail.children.push(obj); + onPartLoaded(); }); } + + _global.resMan.GetObject('res:/dx9/model/worldobject/planet/planetzonly.red', function (obj) { + _this2.zOnlyModel = obj; + onPartLoaded(); + }); } /** diff --git a/dist/ccpwgl_int.min.js b/dist/ccpwgl_int.min.js index 156c3f7..dee75be 100644 --- a/dist/ccpwgl_int.min.js +++ b/dist/ccpwgl_int.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ccpwgl_int=t():e.ccpwgl_int=t()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=65)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.util=void 0;var n=r(18);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(78);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(16));t.util=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(15);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(91);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(101);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(47);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(48);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(116);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(45);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(122);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(26);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})});var h=r(25);Object.keys(h).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return h[e]}})});var p=r(21);Object.keys(p).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return p[e]}})});var d=r(9);Object.keys(d).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return d[e]}})});var v=r(124);Object.keys(v).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return v[e]}})});var m=r(36);Object.keys(m).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return m[e]}})});var y=r(125);Object.keys(y).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return y[e]}})});var b=r(126);Object.keys(b).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return b[e]}})});var _=r(57);Object.keys(_).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return _[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Curve=t.Tw2CurveKey=void 0;var n=function(){function e(e,t){for(var r=0;rt.time?1:0}},{key:"Sort",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.keys;r&&r.length&&(r.sort(e.Compare),t.length=r[r.length-1].time)}},{key:"Sort2",value:function(t){if(t.keys&&t.keys.length){t.keys.sort(e.Compare);var r=t.keys[t.keys.length-1];if(r.time>t.length){var n=t.length,i=t.endValue,a=t.endTangent;t.length=r.time,t.endValue=r.value,t.endTangent=r.leftTangent,n>0&&(r.time=n,r.value=i,r.leftTangent=a)}}}}]),e}();o.inputDimension=null,o.outputDimension=null,o.valueProperty=null,o.curveType=null,o.Key=null,o.Interpolation=null,o.Extrapolation=null,o.Type={CURVE:1,CURVE2:2,CURVE_MAYA:3,CURVE_NO_KEYS:4,SEQUENCER:100,SEQUENCER2:101},o.global={vec3_0:i.vec3.create(),vec4_0:i.vec4.create(),quat_0:i.quat.create(),quat_1:i.quat.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r.d(t,"ARRAY_TYPE",function(){return i}),t.setMatrixArrayType=function(e){i=e},t.toRadian=function(e){return e*o},t.equals=function(e,t){return Math.abs(e-t)<=n*Math.max(1,Math.abs(e),Math.abs(t))};const n=1e-6;t.EPSILON=n;let i="undefined"!=typeof Float32Array?Float32Array:Array;const a=Math.random;t.RANDOM=a;const o=Math.PI/180},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VectorParameter=t.Tw2Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";a(this,e),this._id=i.util.generateID(),this.name=t,this._onModified=[]}return n(e,[{key:"OnValueChanged",value:function(e,t){for(var r=0;r=this.size&&(this.constantBuffer=e,this.offset=t,this.Apply(e,t,r),!0)}},{key:"Unbind",value:function(){this.constantBuffer=null}},{key:"Apply",value:function(e,t,r){e.set(this.value,t)}},{key:"EqualsValue",value:function(e){for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:{},t=this.constructor.Item;if(t&&"create"in t){var r=t.create(e);return this.AddItem(r),r}return null}},{key:"AddItem",value:function(e){this.items.includes(e)||(e._onModified=this._onChildModified,this.items.push(e),this.OnValueChanged())}},{key:"RemoveItem",value:function(e){var t=this.items.indexOf(e);-1!==t&&(e._onModified=null,this.items.splice(t,1),this.OnValueChanged())}},{key:"ClearItems",value:function(){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:null;if(null!==e)for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e){this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this),this._rebuildPending=!1}},{key:"GetBatches",value:function(e,t,r){}},{key:"Render",value:function(){}}],[{key:"RebuildItems",value:function(e){e._visibleItems=[];for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e,t){this.useSRT&&(i.quat.normalize(this.rotation,this.rotation),i.mat4.fromRotationTranslationScale(this.localTransform,this.rotation,this.translation,this.scaling)),i.mat4.copy(this.worldTransformLast,this.worldTransform),i.mat4.multiply(this.worldTransform,t,this.localTransform)}},{key:"GetBatches",value:function(e,t){}}]),e}()).global={mat4_0:i.mat4.create(),vec3_0:i.vec3.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveObject=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e){}},{key:"GetBatches",value:function(e,t){}}]),e}()).global={vec3_0:i.vec3.create(),vec3_1:i.vec3.create(),vec3_2:i.vec3.create(),vec3_3:i.vec3.create(),vec3_4:i.vec3.create(),vec3_5:i.vec3.create(),vec3_6:i.vec3.create(),vec3_7:i.vec3.create(),mat4_0:i.mat4.create(),mat4_1:i.mat4.create(),mat4_2:i.mat4.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2ParticleForce=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r.name=e,r.display=!0,r.visible={},r.visible.log=!0,r.visible.info=!0,r.visible.debug=!0,r.visible.warn=!0,r.visible.error=!0,r.maxLogs=100,r._logs=[],r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.Tw2EventEmitter),n(t,[{key:"log",value:function(e,r){if(r.logged)return r;if(r.log=t.Type[r.log?r.log.toUpperCase():"LOG"]||"log",!r.hide&&this.display&&this.visible[r.log]){var n=this.name+": {"+e+"}",i=r.msg||"";r.path&&(i+=" '"+r.path+"'","time"in r&&(i+=" in "+r.time.toFixed(3)+" secs")),(void 0!==r.value||r.type)&&(i+=" (",r.type&&(i+=r.type),r.type&&void 0!==r.value&&(i+=":"),void 0!==r.value&&(i+=r.value),i+=")"),"data"in r||"err"in r?(console.group(n),console[r.log](i),r.data&&console.debug(r.data),r.err&&console.debug(r.err.stack||r.err.toString()),console.groupEnd()):console[r.log](n,i)}return this.maxLogs?(this._logs.length>=this.maxLogs&&this._logs.splice(this.maxLogs,this._logs.length-1),this._logs.unshift(r)):this._logs=[],this.emit("log",r),r.logged=!0,r}},{key:"GetLogs",value:function(e){return Object.assign([],void 0===e?this._logs:this._logs.splice(0,e))}},{key:"Set",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,a.assignIfExists)(this,e,["name","maxLogs","display"]),(0,a.assignIfExists)(this.visible,e.visible,["log","info","debug","warn","error"])}}]),t}();o.Type={THROW:"error",ERROR:"error",WARNING:"warn",WARN:"warn",INFO:"info",LOG:"log",DEBUG:"debug"};var s=t.logger=new o("CCPWGL");i.Tw2EventEmitter.logger=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(29);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(67);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(33);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(34);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(73);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(74);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(75);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(76);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(77);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.store=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};"uuid"in e&&(0,i.enableUUID)(e.uuid),this.RegisterPaths(e.paths),this.RegisterDynamicPaths(e.dynamicPaths),this.RegisterTypes(e.types),this.RegisterConstructors(e.constructors),this.RegisterExtensions(e.extensions),this.RegisterVariables(e.variables),this.RegisterSchemas(e.schemas)}}],[{key:"GetStoreItem",value:function(e,t,r){var n=e["_"+t];if(n&&(0,i.isString)(r)){if(r in n)return n[r];e._missing[t]||(e._missing[t]=[]),e._missing[t].includes(r)||(e._missing[t].push(r),a.logger.log("store.warning",{log:"warning",msg:"Missing "+t+": '"+r+"'"}))}return null}},{key:"SetStoreItem",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=arguments[3],o=arguments[4];if(o&&!o(n))return a.logger.log("store.error",{log:"error",msg:"Invalid value "+t+": '"+r+"'"}),!1;var s=e["_"+t];if(s&&(0,i.isString)(r)&&!(0,i.isUndefined)(n)){var u=s[r];return s[r]=n,u?a.logger.log("store.registered",{log:"debug",msg:"Re-registered "+t+": '"+r+"'",data:{old_value:u,new_value:n}}):a.logger.log("store.registered",{log:"debug",msg:"Registered "+t+": '"+r+"'",hide:!0}),!0}return!1}},{key:"RegisterFromObject",value:function(e,t,r){if(r&&t in e){r=(0,i.toArray)(r);for(var n=0;nr.size?t.subarray(0,r.size):t,r.offset)}},{key:"Get",value:function(e){return this.elements[e].array}},{key:"GetData",value:function(e){return this.data.subarray(this.elements[e].offset,this.elements[e].offset+this.elements[e].array.length)}},{key:"Create",value:function(){for(var e in this.data=new Float32Array(this.nextOffset),this.elements)if(this.elements.hasOwnProperty(e)){var t=this.elements[e];if(t.array=this.data.subarray(t.offset,t.offset+t.size),null!==t.value){if(1===t.size)t.array[0]=t.value;else for(var r=0;r2&&void 0!==arguments[2]?arguments[2]:null;this.elements[e]={offset:this.nextOffset,size:t,array:null,value:r},this.nextOffset+=t}},{key:"DeclareFromObject",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in e)if(e.hasOwnProperty(t)){var r=e[t];if(a.util.isNumber(r))this.Declare(t,1,r);else{if(!a.util.isArrayLike(r))throw new Error("Invalid declaration type: "+(void 0===r?"undefined":n(r)));1===r.length&&this.Declare(t,r.length,r)}}this.Create()}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(118);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(120);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(38);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(8);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(52);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(121);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(40);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(39);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2ParticleEmitter=void 0;var n=function(){function e(e,t){for(var r=0;r1?0:i<-1?Math.PI:Math.acos(i)},t.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},t.equals=function(e,t){let r=e[0],i=e[1],a=e[2],o=t[0],s=t[1],u=t[2];return Math.abs(r-o)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-s)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(a-u)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(u))};var n=r(3);function i(){let e=new n.ARRAY_TYPE(3);return e[0]=0,e[1]=0,e[2]=0,e}function a(e){let t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function o(e,t,r){let i=new n.ARRAY_TYPE(3);return i[0]=e,i[1]=t,i[2]=r,i}function s(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function u(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function l(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function c(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(r*r+n*n+i*i)}function f(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return r*r+n*n+i*i}function h(e){let t=e[0],r=e[1],n=e[2];return t*t+r*r+n*n}function p(e,t){let r=t[0],n=t[1],i=t[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a),e}function d(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}const v=s;t.sub=v;const m=u;t.mul=m;const y=l;t.div=y;const b=c;t.dist=b;const _=f;t.sqrDist=_;const g=a;t.len=g;const E=h;t.sqrLen=E;const T=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=3),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s0&&(o=1/Math.sqrt(o),e[0]=r*o,e[1]=n*o,e[2]=i*o,e[3]=a*o),e}const d=a;t.sub=d;const v=o;t.mul=v;const m=s;t.div=m;const y=l;t.dist=y;const b=c;t.sqrDist=b;const _=f;t.len=_;const g=h;t.sqrLen=g;const E=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=4),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s1?r-1:0),i=1;i2?n-2:0),a=2;a1?r-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:{};if(i.has(this)){var r=i.get(this);e=e.toLowerCase(),t.log&&!t.log.logged&&(t.log=this.log(e,t.log)),e in r?r[e].forEach(function(n,i){i.call(n.context,t),n.once&&r[e].delete(i)}):(r[e]=new Set,this.emit("event_added",{eventName:e}))}return this}},{key:"on",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i.has(this)||i.set(this,{});var o=i.get(this);return o[e=e.toLowerCase()]||(o[e]=new Set,o[e].add(function(){return r.emit("event_added",{eventName:e})},{once:!0})),o[e].add(t,{context:n,once:a}),this}},{key:"once",value:function(e,t,r){return this.on(e,t,r,!0)}},{key:"off",value:function(e,t){if(i.has(this)){var r=i.get(this);(e=e.toLowerCase())in r&&r[e].delete(t)}return this}},{key:"del",value:function(e){if(i.has(this)){var t=i.get(this);(e=e.toLowerCase())in t&&(this.emit("event_removed",{eventName:e}),delete t[e])}return this}},{key:"clr",value:function(e){if(i.has(this)){var t=i.get(this);for(var r in t)t.hasOwnProperty(r)&&t[r].has(e)&&t[r].delete(e)}return this}},{key:"kill",value:function(){return i.has(this)&&(this.emit("event_kill"),i.set(this,{})),this}},{key:"log",value:function(e,t){return this.constructor.logger&&this.constructor.logger.log(e,t),t}}],[{key:"assign",value:function(t){Object.assign(t.prototype,e.prototype)}}]),e}()).logger=null},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resMan=t.Tw2ResMan=void 0;var n=function(){function e(e,t){for(var r=0;r1&&(this.activeFrame+=1,this._purgeTime-=Math.floor(this._purgeTime),this._purgeFrame+=1,this._purgeFrame>=5&&this.autoPurgeResources&&this.motherLode.PurgeInactive(this._purgeFrame,this._purgeFrameLimit,this.purgeTime,i.logger)),!0}},{key:"GetResource",value:function(t){var r=void 0;if(t=e.NormalizePath(t),r=this.motherLode.Find(t))return r.IsPurged()&&r.Reload(),r;var n=e.GetPathExt(t);if(null===n)return i.logger.log("res.error",{log:"error",src:["Tw2ResMan","ReloadResource"],msg:"Undefined extension",type:"extension.undefined",path:t}),null;var o=a.store.GetExtension(n);return o?((r=new o).path=t,e.LoadResource(this,r)):(i.logger.log("res.error",{log:"error",src:["Tw2ResMan","ReloadResource"],msg:"Unregistered extension",type:"extension.unregistered",path:t,value:n}),null)}},{key:"GetObject",value:function(t,r){var n={};t=e.NormalizePath(t);var i=this.motherLode.Find(t);i?i.AddObject(n,r):((i=new s.Tw2LoadingObject).path=t,i.AddObject(n,r),e.LoadResource(this,i))}},{key:"ReloadResource",value:function(t){var r=t.path,n=this.motherLode.Find(r);return n&&!n.IsPurged()?n:(i.logger.log("res.event",{msg:"Reloading ",path:r,type:"reload"}),e.LoadResource(this,t))}}],[{key:"BuildUrl",value:function(e){var t=e.indexOf(":/");if(-1===t)return i.logger.log("res.error",{log:"warn",src:["Tw2ResMan","BuildUrl"],msg:"Invalid path",type:"prefix.undefined",path:e}),e;var r=e.substr(0,t),n=a.store.GetPath(r);return n?n+e.substr(t+2):(i.logger.log("res.error",{log:"warn",src:["Tw2ResMan","BuildUrl"],msg:"Unregistered path",path:e,type:"prefix.unregistered",value:r}),e)}},{key:"NormalizePath",value:function(e){return"str:/"===e.substr(0,5)?e:((e=e.toLowerCase()).replace("\\","/"),e)}},{key:"GetPathExt",value:function(e){if("str:/"===e.substr(0,5)){var t=e.indexOf("/",5);return-1===t?null:e.substr(5,t-5)}var r=e.lastIndexOf(".");return-1===r?null:e.substr(r+1)}},{key:"LogPathString",value:function(e){return"str:/"===e.substr(0,5)&&e.length>64?e.substr(0,64)+"...":e}},{key:"LoadResource",value:function(t,r){var n=r.path,a=e.BuildUrl(n);if(r._isPurged=!1,t.motherLode.Add(n,r),r.DoCustomLoad&&r.DoCustomLoad(a))return r;var o=e.CreateHttpRequest(r.requestResponseType);if(o){i.logger.log("res.event",{msg:"Requesting",path:n,type:"request"}),o.onreadystatechange=e.DoLoadResource(t,r),o.open("GET",a),r.LoadStarted();try{o.send(),t._pendingLoads++}catch(e){i.logger.log("res.error",{log:"error",src:["Tw2ResMan","LoadResource"],msg:"Error sending object HTTP request",path:n,type:"http.request",err:e})}}return r}},{key:"DoLoadResource",value:function(e,t){return function(){var r=0;try{r=this.readyState}catch(n){return i.logger.log("res.error",{log:"error",src:["Tw2ResMan","_DoLoadResource"],msg:"Communication error loading",path:t.path,type:"http.readystate",value:r}),t.LoadFinished(!1),void e._pendingLoads--}if(4===r){if(200===this.status){var n=null,a=null;try{n=this.responseText,a=this.responseXML}catch(e){n=this.response}t.LoadFinished(!0),e._prepareQueue.push([t,n,a])}else i.logger.log("res.error",{log:"error",src:["Tw2ResMan","_DoLoadResource"],msg:"Communication error loading",path:t.path,type:"http.status",value:this.status}),t.LoadFinished(!1),t.PrepareFinished(!1);e._pendingLoads--}}}},{key:"CreateHttpRequest",value:function(e){var t=null;if(window.XMLHttpRequest)t=new XMLHttpRequest;else if(window.ActiveXObject)try{t=new window.ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{t=new window.ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}return t?e&&(t.responseType=e):i.logger.log("res.error",{log:"error",src:["Tw2LoadingObject","Prepare"],msg:"Could not create an XMLHTTP instance",type:"http.instance"}),t}}]),e}();t.resMan=new u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2LoadingObject=void 0;var n=function(){function e(e,t){for(var r=0;r127&&(e=e-255-1),e}},{key:"ReadUInt16",value:function(){return this.data[this.cursor++]+(this.data[this.cursor++]<<8)}},{key:"ReadInt16",value:function(){var e=this.data[this.cursor++]+(this.data[this.cursor++]<<8);return e>32767&&(e=e-65535-1),e}},{key:"ReadUInt32",value:function(){return this.data[this.cursor++]+(this.data[this.cursor++]<<8)+(this.data[this.cursor++]<<16)+(this.data[this.cursor++]<<24>>>0)}},{key:"ReadInt32",value:function(){var e=this.data[this.cursor++]+(this.data[this.cursor++]<<8)+(this.data[this.cursor++]<<16)+(this.data[this.cursor++]<<24>>>0);return e>2147483647&&(e=e-4294967295-1),e}},{key:"ReadFloat16",value:function(){var e=this.data[this.cursor++],t=this.data[this.cursor++],r=(t>>2&31)-15,n=(3&t)<<8|e;return 0===n&&-15===r?0:(1-2*(t>>7))*(1+n*Math.pow(2,-10))*Math.pow(2,r)}},{key:"ReadFloat32",value:function(){var e=this.data[this.cursor++],t=this.data[this.cursor++],r=this.data[this.cursor++],n=this.data[this.cursor++],i=(n<<1&255|r>>7)-127,a=(127&r)<<16|t<<8|e;return 0===a&&-127===i?0:(1-2*(n>>7))*(1+a*Math.pow(2,-23))*Math.pow(2,i)}},{key:"ReadString",value:function(){for(var e=this.data[this.cursor++],t="",r=0;r0&&void 0!==arguments[0]?arguments[0]:[];for(var t in this.effectRes&&!e.includes(this.effectRes)&&e.push(this.effectRes),this.parameters)this.parameters.hasOwnProperty(t)&&"GetResources"in this.parameters[t]&&this.parameters[t].GetResources(e);return e}},{key:"RebuildCachedData",value:function(e){this.shader=e.GetShader(this.options),this.BindParameters()}},{key:"UnBindParameters",value:function(){for(var e in this.techniques)if(this.techniques.hasOwnProperty(e))for(var t=this.techniques[e],r=0;r=this.techniques[e].length)){this.shader.ApplyPass(e,t);for(var r=this.techniques[e][t],n=this.shader.techniques[e].passes[t],a=i.device,o=a.gl,s=a.IsAlphaTestEnabled()&&n.shadowShaderProgram?n.shadowShaderProgram:n.shaderProgram,u=0;u<2;++u){for(var l=r.stages[u],c=0;c=this.techniques[e].length?null:i.device.IsAlphaTestEnabled()&&this.shader.techniques[e].passes[t].shadowShaderProgram?this.shader.techniques[e].passes[t].shadowShaderProgram.input:this.shader.techniques[e].passes[t].shaderProgram.input}},{key:"Render",value:function(e){for(var t=this.GetPassCount("Main"),r=0;r0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)if(this.parameters.hasOwnProperty(t)&&this.parameters[t]instanceof a.Tw2TextureParameter){var r=this.parameters[t].GetValue();r&&(e[t]=r)}return e}},{key:"SetTextures",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=e[r],i=this.parameters[r];a.Tw2TextureParameter.is(n)&&(i?i.EqualsValue(n)||(i.SetTexturePath(n),t=!0):(this.parameters[r]=new a.Tw2TextureParameter(r,n),t=!0))}return t}},{key:"GetParameters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)!this.parameters.hasOwnProperty(t)||this.parameters[t]instanceof a.Tw2TextureParameter||(e[t]=this.parameters[t].GetValue(!0));return e}},{key:"SetParameters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=e[r],a=this.parameters[r];if(a)a.constructor.is(n)&&!a.EqualsValue(n)&&(this.parameters[r].SetValue(n),t=!0);else{var o=i.store.CreateType(r,n);o&&(this.parameters[r]=o,t=!0)}}return t}},{key:"SetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=this.parameters[r];if(n&&n instanceof a.Tw2TextureParameter){var i=!1,o=e[r];for(var s in o)if(o.hasOwnProperty(s)&&a.Tw2TextureParameter.overrideProperties.includes(s)&&o[s]!==n[s]){i=!0;break}i&&(n.SetOverrides(e[r]),t=!0)}}return t}},{key:"GetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)if(this.parameters.hasOwnProperty(t)){var r=this.parameters[t];r&&r instanceof a.Tw2TextureParameter&&r.useAllOverrides&&(e[t]=this.parameters[t].GetOverrides())}return e}}],[{key:"ToEffectResPath",value:function(e){return(e=e?e.substr(0,e.lastIndexOf(".")).replace("/effect/",i.device.effectDir)+".sm_"+i.device.shaderModel:"").toLowerCase()}},{key:"FromEffectResPath",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"fx";return(e=e.substr(0,e.lastIndexOf(".")).replace(i.device.effectDir,"/effect/")+"."+t).toLowerCase()}},{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new this;if(i.util.assignIfExists(t,e,["name","effectFilePath","display","autoParameter"]),"parameters"in e&&t.SetParameters(e.parameters),"textures"in e&&t.SetTextures(e.textures),"overrides"in e&&t.SetOverrides(e.overrides),""===t.name&&""!==e.effectFilePath){var r=e.effectFilePath;t.name=r.substring(r.lastIndexOf("/")+1,r.length)}return t.Initialize(),t}}]),e}()).ConstantIgnore=["PerFrameVS","PerObjectVS","PerFramePS","PerObjectPS","PerObjectPSInt"]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TextureParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.resourcePath=r,n.useAllOverrides=!1,n.addressUMode=1,n.addressVMode=1,n.addressWMode=1,n.filterMode=2,n.mipFilterMode=2,n.maxAnisotropy=4,n.textureRes=null,n._sampler=null,r&&n.Initialize(),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,o.Tw2Parameter),n(t,[{key:"Initialize",value:function(){this.OnValueChanged()}},{key:"SetTexturePath",value:function(e){this.resourcePath=e,this.OnValueChanged()}},{key:"GetValue",value:function(){return this.isTextureAttached?null:this.resourcePath}},{key:"SetTextureRes",value:function(e){this.textureRes!==e&&(this.resourcePath="",this.textureRes=e),this.textureRes._isAttached=!0}},{key:"OnValueChanged",value:function(e,r){""!==this.resourcePath&&(this.resourcePath=this.resourcePath.toLowerCase(),this.textureRes=""!==this.resourcePath?i.resMan.GetResource(this.resourcePath):null),this.UpdateOverrides(),function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,r,n)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(n):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"OnValueChanged",this).call(this,e,r)}},{key:"Apply",value:function(e,t,r){this.textureRes&&(this.useAllOverrides&&(this._sampler.samplerType=t.samplerType,this._sampler.isVolume=t.isVolume,this._sampler.registerIndex=t.registerIndex,t=this._sampler),i.device.gl.activeTexture(i.device.gl.TEXTURE0+e),this.textureRes.Bind(t,r))}},{key:"SetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i.util.assignIfExists(this,e,t.overrideProperties),this.OnValueChanged()}},{key:"GetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.util.assignIfExists(e,this,t.overrideProperties),e}},{key:"UpdateOverrides",value:function(){if(this.useAllOverrides){this._sampler=this._sampler||new a.Tw2SamplerState;var e=i.device.wrapModes,t=i.device.gl,r=this._sampler;if(1===this.filterMode){switch(this.mipFilterMode){case 0:r.minFilter=t.NEAREST;break;case 1:r.minFilter=t.NEAREST_MIPMAP_NEAREST;break;default:r.minFilter=t.NEAREST_MIPMAP_LINEAR}r.minFilterNoMips=t.NEAREST,r.magFilter=t.NEAREST}else{switch(this.mipFilterMode){case 0:r.minFilter=t.LINEAR;break;case 1:r.minFilter=t.LINEAR_MIPMAP_NEAREST;break;default:r.minFilter=t.LINEAR_MIPMAP_LINEAR}r.minFilterNoMips=t.LINEAR,r.magFilter=t.LINEAR}r.addressU=e[this.addressUMode],r.addressV=e[this.addressVMode],r.addressW=e[this.addressWMode],r.anisotropy=this.maxAnisotropy,r.ComputeHash()}else this._sampler&&(this._sampler=null)}},{key:"EqualsValue",value:function(e){return e.toLowerCase()===this.GetValue()}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.resourcePath=e.resourcePath,this.SetOverrides(e.GetOverrides)}},{key:"Clone",value:function(){var e=new t;return e.Copy(this,!0),e}},{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.textureRes&&!e.includes(this.textureRes)&&e.push(this.textureRes),e}},{key:"isTextureAttached",get:function(){return this.textureRes&&this.textureRes._isAttached}}],[{key:"isValue",value:function(e){return i.util.isString(e)}}]),t}();s.prototype.SetValue=s.prototype.SetTexturePath,s.overrideProperties=["useAllOverrides","addressUMode","addressVMode","addressWMode","filterMode","mipFilterMode","maxAnisotropy"]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SamplerState=void 0;var n=function(){function e(e,t){for(var r=0;r4&&void 0!==arguments[4]?arguments[4]:0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.usage=t,this.usageIndex=r,this.type=n,this.elements=i,this.offset=a,this.location=null,this.customSetter=null}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(94);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(95);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(96);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(97);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(98);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(99);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(100);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(42);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PerObjectData=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};e.VSData&&(this.perObjectVSData=new a.Tw2RawData(e.VSData)),e.PSData&&(this.perObjectPSData=new a.Tw2RawData(e.PSData))}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(103);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(104);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(105);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(106);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(107);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(108);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(109);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(110);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(111);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})});var h=r(112);Object.keys(h).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return h[e]}})});var p=r(113);Object.keys(p).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return p[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(41);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(114);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(49);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(50);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(115);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Mesh=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[];return e.includes(this.geometryResource)||e.push(this.geometryResource),i.util.perArrayChild(this.opaqueAreas,"GetResources",e),i.util.perArrayChild(this.transparentAreas,"GetResources",e),i.util.perArrayChild(this.additiveAreas,"GetResources",e),i.util.perArrayChild(this.pickableAreas,"GetResources",e),i.util.perArrayChild(this.decalAreas,"GetResources",e),i.util.perArrayChild(this.depthAreas,"GetResources",e),e}},{key:"GetBatches",value:function(e,t,r){if(!this.IsGood()||!this.display)return!1;var n=this.constructor.GetAreaBatches;switch(e){case i.device.RM_OPAQUE:return void(this.visible.opaqueAreas&&n(this,this.opaqueAreas,e,t,r));case i.device.RM_DECAL:return void(this.visible.decalAreas&&n(this,this.opaqueAreas,e,t,r));case i.device.RM_TRANSPARENT:return void(this.visible.transparentAreas&&n(this,this.transparentAreas,e,t,r));case i.device.RM_ADDITIVE:return void(this.visible.transparentAreas&&n(this,this.additiveAreas,e,t,r));case i.device.RM_PICKABLE:return void(this.visible.pickableAreas&&n(this,this.pickableAreas,e,t,r))}}}],[{key:"GetAreaBatches",value:function(e,t,r,n,i){for(var a=0;a=this.animationRes.duration}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TextureRes=void 0;var n=function(){function e(e,t){for(var r=0;r0?"."+t.mipLevelSkipCount.toString():"";if(t.mipLevelSkipCount>0){var n=e.lastIndexOf(".");n>=0&&(e=e.substr(0,n-2)+r+e.substr(n))}return e}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Bone=void 0;var n=r(0);t.Tw2Bone=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.boneRes=null,this.localTransform=n.mat4.create(),this.worldTransform=n.mat4.create(),this.offsetTransform=n.mat4.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2Model=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.modelRes=null,this.bones=[],this.bonesByName={}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2Track=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.trackRes=null,this.bone=null}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2TrackGroup=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.trackGroupRes=null,this.model=null,this.transformTracks=[]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2RenderTarget=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];if(this.mesh&&this.mesh.GetResources(e),!t)for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];return this.mesh&&this.mesh.GetResources(e),this.animation&&this.animation.GetResources(e),i.util.perArrayChild(this.spriteSets,"GetResources",e),i.util.perArrayChild(this.turretSets,"GetResources",e),i.util.perArrayChild(this.decals,"GetResources",e),i.util.perArrayChild(this.spotlightSets,"GetResources",e),i.util.perArrayChild(this.planeSets,"GetResources",e),i.util.perArrayChild(this.lineSets,"GetResources",e),i.util.perArrayChild(this.overlayEffects,"GetResources",e),i.util.perArrayChild(this.effectChildren,"GetResources",e),t||i.util.perArrayChild(this.children,"GetResources",e),e}},{key:"UpdateViewDependentData",value:function(){for(var e=0;e0?(t[0]=this.shapeEllipsoidCenter[0],t[1]=this.shapeEllipsoidCenter[1],t[2]=this.shapeEllipsoidCenter[2],r[0]=this.shapeEllipsoidRadius[0],r[1]=this.shapeEllipsoidRadius[1],r[2]=this.shapeEllipsoidRadius[2]):this.mesh&&this.mesh.IsGood()&&(i.vec3.subtract(t,this.mesh.geometryResource.maxBounds,this.mesh.geometryResource.minBounds),i.vec3.scale(t,t,.8660254035),i.vec3.add(r,this.mesh.geometryResource.maxBounds,this.mesh.geometryResource.minBounds),i.vec3.scale(r,r,.5));for(var n=0;n0){for(var t=0;t0&&this.mesh.GetBatches(e,t,this._perObjectData),this.lod>1){if(r.spriteSets)for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:null;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.batches=[],this._sortMethod=t}return n(e,[{key:"Commit",value:function(e){this.batches.push(e)}},{key:"Clear",value:function(){this.batches=[]}},{key:"Render",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Main";this._sortMethod&&this.batches.sort(this._sortMethod);for(var r=0;r0?(n=2*Math.sqrt(r+1),e[3]=.25*n,e[0]=(t[6]-t[9])/n,e[1]=(t[8]-t[2])/n,e[2]=(t[1]-t[4])/n):t[0]>t[5]&t[0]>t[10]?(n=2*Math.sqrt(1+t[0]-t[5]-t[10]),e[3]=(t[6]-t[9])/n,e[0]=.25*n,e[1]=(t[1]+t[4])/n,e[2]=(t[8]+t[2])/n):t[5]>t[10]?(n=2*Math.sqrt(1+t[5]-t[0]-t[10]),e[3]=(t[8]-t[2])/n,e[0]=(t[1]+t[4])/n,e[1]=.25*n,e[2]=(t[6]+t[9])/n):(n=2*Math.sqrt(1+t[10]-t[0]-t[5]),e[3]=(t[1]-t[4])/n,e[0]=(t[8]+t[2])/n,e[1]=(t[6]+t[9])/n,e[2]=.25*n);return e},t.fromRotationTranslationScale=function(e,t,r,n){let i=t[0],a=t[1],o=t[2],s=t[3],u=i+i,l=a+a,c=o+o,f=i*u,h=i*l,p=i*c,d=a*l,v=a*c,m=o*c,y=s*u,b=s*l,_=s*c,g=n[0],E=n[1],T=n[2];return e[0]=(1-(d+m))*g,e[1]=(h+_)*g,e[2]=(p-b)*g,e[3]=0,e[4]=(h-_)*E,e[5]=(1-(f+m))*E,e[6]=(v+y)*E,e[7]=0,e[8]=(p+b)*T,e[9]=(v-y)*T,e[10]=(1-(f+d))*T,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e},t.fromRotationTranslationScaleOrigin=function(e,t,r,n,i){let a=t[0],o=t[1],s=t[2],u=t[3],l=a+a,c=o+o,f=s+s,h=a*l,p=a*c,d=a*f,v=o*c,m=o*f,y=s*f,b=u*l,_=u*c,g=u*f,E=n[0],T=n[1],O=n[2],w=i[0],S=i[1],R=i[2];return e[0]=(1-(v+y))*E,e[1]=(p+g)*E,e[2]=(d-_)*E,e[3]=0,e[4]=(p-g)*T,e[5]=(1-(h+y))*T,e[6]=(m+b)*T,e[7]=0,e[8]=(d+_)*O,e[9]=(m-b)*O,e[10]=(1-(h+v))*O,e[11]=0,e[12]=r[0]+w-(e[0]*w+e[4]*S+e[8]*R),e[13]=r[1]+S-(e[1]*w+e[5]*S+e[9]*R),e[14]=r[2]+R-(e[2]*w+e[6]*S+e[10]*R),e[15]=1,e},t.fromQuat=function(e,t){let r=t[0],n=t[1],i=t[2],a=t[3],o=r+r,s=n+n,u=i+i,l=r*o,c=n*o,f=n*s,h=i*o,p=i*s,d=i*u,v=a*o,m=a*s,y=a*u;return e[0]=1-f-d,e[1]=c+y,e[2]=h-m,e[3]=0,e[4]=c-y,e[5]=1-l-d,e[6]=p+v,e[7]=0,e[8]=h+m,e[9]=p-v,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},t.frustum=function(e,t,r,n,i,a,o){let s=1/(r-t),u=1/(i-n),l=1/(a-o);return e[0]=2*a*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*u,e[6]=0,e[7]=0,e[8]=(r+t)*s,e[9]=(i+n)*u,e[10]=(o+a)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*l,e[15]=0,e},t.perspective=function(e,t,r,n,i){let a=1/Math.tan(t/2),o=1/(n-i);return e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(i+n)*o,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*i*n*o,e[15]=0,e},t.perspectiveFromFieldOfView=function(e,t,r,n){let i=Math.tan(t.upDegrees*Math.PI/180),a=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),s=Math.tan(t.rightDegrees*Math.PI/180),u=2/(o+s),l=2/(i+a);return e[0]=u,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-(o-s)*u*.5,e[9]=(i-a)*l*.5,e[10]=n/(r-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*r/(r-n),e[15]=0,e},t.ortho=function(e,t,r,n,i,a,o){let s=1/(t-r),u=1/(n-i),l=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*s,e[13]=(i+n)*u,e[14]=(o+a)*l,e[15]=1,e},t.lookAt=function(e,t,r,i){let a,o,s,u,l,c,f,h,p,d,v=t[0],m=t[1],y=t[2],b=i[0],_=i[1],g=i[2],E=r[0],T=r[1],O=r[2];if(Math.abs(v-E)0&&(p=1/Math.sqrt(p),c*=p,f*=p,h*=p);let d=u*h-l*f,v=l*c-s*h,m=s*f-u*c;return e[0]=d,e[1]=v,e[2]=m,e[3]=0,e[4]=f*m-h*v,e[5]=h*d-c*m,e[6]=c*v-f*d,e[7]=0,e[8]=c,e[9]=f,e[10]=h,e[11]=0,e[12]=i,e[13]=a,e[14]=o,e[15]=1,e},t.str=function(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},t.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2)+Math.pow(e[9],2)+Math.pow(e[10],2)+Math.pow(e[11],2)+Math.pow(e[12],2)+Math.pow(e[13],2)+Math.pow(e[14],2)+Math.pow(e[15],2))},t.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e},t.subtract=a,t.multiplyScalar=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e},t.multiplyScalarAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e[9]=t[9]+r[9]*n,e[10]=t[10]+r[10]*n,e[11]=t[11]+r[11]*n,e[12]=t[12]+r[12]*n,e[13]=t[13]+r[13]*n,e[14]=t[14]+r[14]*n,e[15]=t[15]+r[15]*n,e},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},t.equals=function(e,t){let r=e[0],i=e[1],a=e[2],o=e[3],s=e[4],u=e[5],l=e[6],c=e[7],f=e[8],h=e[9],p=e[10],d=e[11],v=e[12],m=e[13],y=e[14],b=e[15],_=t[0],g=t[1],E=t[2],T=t[3],O=t[4],w=t[5],S=t[6],R=t[7],P=t[8],A=t[9],M=t[10],j=t[11],D=t[12],C=t[13],I=t[14],k=t[15];return Math.abs(r-_)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(_))&&Math.abs(i-g)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(g))&&Math.abs(a-E)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(E))&&Math.abs(o-T)<=n.EPSILON*Math.max(1,Math.abs(o),Math.abs(T))&&Math.abs(s-O)<=n.EPSILON*Math.max(1,Math.abs(s),Math.abs(O))&&Math.abs(u-w)<=n.EPSILON*Math.max(1,Math.abs(u),Math.abs(w))&&Math.abs(l-S)<=n.EPSILON*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(c-R)<=n.EPSILON*Math.max(1,Math.abs(c),Math.abs(R))&&Math.abs(f-P)<=n.EPSILON*Math.max(1,Math.abs(f),Math.abs(P))&&Math.abs(h-A)<=n.EPSILON*Math.max(1,Math.abs(h),Math.abs(A))&&Math.abs(p-M)<=n.EPSILON*Math.max(1,Math.abs(p),Math.abs(M))&&Math.abs(d-j)<=n.EPSILON*Math.max(1,Math.abs(d),Math.abs(j))&&Math.abs(v-D)<=n.EPSILON*Math.max(1,Math.abs(v),Math.abs(D))&&Math.abs(m-C)<=n.EPSILON*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(y-I)<=n.EPSILON*Math.max(1,Math.abs(y),Math.abs(I))&&Math.abs(b-k)<=n.EPSILON*Math.max(1,Math.abs(b),Math.abs(k))};var n=r(3);function i(e,t,r){let n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],l=t[6],c=t[7],f=t[8],h=t[9],p=t[10],d=t[11],v=t[12],m=t[13],y=t[14],b=t[15],_=r[0],g=r[1],E=r[2],T=r[3];return e[0]=_*n+g*s+E*f+T*v,e[1]=_*i+g*u+E*h+T*m,e[2]=_*a+g*l+E*p+T*y,e[3]=_*o+g*c+E*d+T*b,_=r[4],g=r[5],E=r[6],T=r[7],e[4]=_*n+g*s+E*f+T*v,e[5]=_*i+g*u+E*h+T*m,e[6]=_*a+g*l+E*p+T*y,e[7]=_*o+g*c+E*d+T*b,_=r[8],g=r[9],E=r[10],T=r[11],e[8]=_*n+g*s+E*f+T*v,e[9]=_*i+g*u+E*h+T*m,e[10]=_*a+g*l+E*p+T*y,e[11]=_*o+g*c+E*d+T*b,_=r[12],g=r[13],E=r[14],T=r[15],e[12]=_*n+g*s+E*f+T*v,e[13]=_*i+g*u+E*h+T*m,e[14]=_*a+g*l+E*p+T*y,e[15]=_*o+g*c+E*d+T*b,e}function a(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}const o=i;t.mul=o;const s=a;t.sub=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=s,t.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},t.setAxisAngle=u,t.getAxisAngle=function(e,t){let r=2*Math.acos(t[3]),n=Math.sin(r/2);0!=n?(e[0]=t[0]/n,e[1]=t[1]/n,e[2]=t[2]/n):(e[0]=1,e[1]=0,e[2]=0);return r},t.multiply=l,t.rotateX=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u+o*s,e[1]=i*u+a*s,e[2]=a*u-i*s,e[3]=o*u-n*s,e},t.rotateY=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u-a*s,e[1]=i*u+o*s,e[2]=a*u+n*s,e[3]=o*u-i*s,e},t.rotateZ=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u+i*s,e[1]=i*u-n*s,e[2]=a*u+o*s,e[3]=o*u-a*s,e},t.calculateW=function(e,t){let r=t[0],n=t[1],i=t[2];return e[0]=r,e[1]=n,e[2]=i,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),e},t.slerp=c,t.invert=function(e,t){let r=t[0],n=t[1],i=t[2],a=t[3],o=r*r+n*n+i*i+a*a,s=o?1/o:0;return e[0]=-r*s,e[1]=-n*s,e[2]=-i*s,e[3]=a*s,e},t.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},t.fromMat3=f,t.fromEuler=function(e,t,r,n){let i=.5*Math.PI/180;t*=i,r*=i,n*=i;let a=Math.sin(t),o=Math.cos(t),s=Math.sin(r),u=Math.cos(r),l=Math.sin(n),c=Math.cos(n);return e[0]=a*u*c-o*s*l,e[1]=o*s*c+a*u*l,e[2]=o*u*l-a*s*c,e[3]=o*u*c+a*s*l,e},t.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"};var n=r(3),i=r(30),a=r(31),o=r(32);function s(){let e=new n.ARRAY_TYPE(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function u(e,t,r){r*=.5;let n=Math.sin(r);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r),e}function l(e,t,r){let n=t[0],i=t[1],a=t[2],o=t[3],s=r[0],u=r[1],l=r[2],c=r[3];return e[0]=n*c+o*s+i*l-a*u,e[1]=i*c+o*u+a*s-n*l,e[2]=a*c+o*l+n*u-i*s,e[3]=o*c-n*s-i*u-a*l,e}function c(e,t,r,n){let i,a,o,s,u,l=t[0],c=t[1],f=t[2],h=t[3],p=r[0],d=r[1],v=r[2],m=r[3];return(a=l*p+c*d+f*v+h*m)<0&&(a=-a,p=-p,d=-d,v=-v,m=-m),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,u=Math.sin(n*i)/o):(s=1-n,u=n),e[0]=s*l+u*p,e[1]=s*c+u*d,e[2]=s*f+u*v,e[3]=s*h+u*m,e}function f(e,t){let r,n=t[0]+t[4]+t[8];if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{let n=0;t[4]>t[0]&&(n=1),t[8]>t[3*n+n]&&(n=2);let i=(n+1)%3,a=(n+2)%3;r=Math.sqrt(t[3*n+n]-t[3*i+i]-t[3*a+a]+1),e[n]=.5*r,r=.5/r,e[3]=(t[3*i+a]-t[3*a+i])*r,e[i]=(t[3*i+n]+t[3*n+i])*r,e[a]=(t[3*a+n]+t[3*n+a])*r}return e}const h=o.clone;t.clone=h;const p=o.fromValues;t.fromValues=p;const d=o.copy;t.copy=d;const v=o.set;t.set=v;const m=o.add;t.add=m;const y=l;t.mul=y;const b=o.scale;t.scale=b;const _=o.dot;t.dot=_;const g=o.lerp;t.lerp=g;const E=o.length;t.length=E;const T=E;t.len=T;const O=o.squaredLength;t.squaredLength=O;const w=O;t.sqrLen=w;const S=o.normalize;t.normalize=S;const R=o.exactEquals;t.exactEquals=R;const P=o.equals;t.equals=P;const A=function(){let e=a.create(),t=a.fromValues(1,0,0),r=a.fromValues(0,1,0);return function(n,i,o){let s=a.dot(i,o);return s<-.999999?(a.cross(e,t,i),a.len(e)<1e-6&&a.cross(e,r,i),a.normalize(e,e),u(n,e,Math.PI),n):s>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(a.cross(e,i,o),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+s,S(n,n))}}();t.rotationTo=A;const M=function(){let e=s(),t=s();return function(r,n,i,a,o,s){return c(e,n,o,s),c(t,i,a,s),c(r,e,t,2*s*(1-s)),r}}();t.sqlerp=M;const j=function(){let e=i.create();return function(t,r,n,i){return e[0]=n[0],e[3]=n[1],e[6]=n[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-r[0],e[5]=-r[1],e[8]=-r[2],S(t,f(t,e))}}();t.setAxes=j},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=i,t.clone=function(e){let t=new n.ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t},t.fromValues=function(e,t){let r=new n.ARRAY_TYPE(2);return r[0]=e,r[1]=t,r},t.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},t.set=function(e,t,r){return e[0]=t,e[1]=r,e},t.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e},t.subtract=a,t.multiply=o,t.divide=s,t.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},t.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},t.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e},t.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e},t.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},t.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e},t.scaleAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e},t.distance=u,t.squaredDistance=l,t.length=c,t.squaredLength=f,t.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},t.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},t.normalize=function(e,t){var r=t[0],n=t[1],i=r*r+n*n;i>0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i);return e},t.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},t.cross=function(e,t,r){var n=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=n,e},t.lerp=function(e,t,r,n){var i=t[0],a=t[1];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e},t.random=function(e,t){t=t||1;var r=2*n.RANDOM()*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e},t.transformMat2=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e},t.transformMat2d=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i+r[4],e[1]=r[1]*n+r[3]*i+r[5],e},t.transformMat3=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[3]*i+r[6],e[1]=r[1]*n+r[4]*i+r[7],e},t.transformMat4=function(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[4]*i+r[12],e[1]=r[1]*n+r[5]*i+r[13],e},t.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]},t.equals=function(e,t){let r=e[0],i=e[1],a=t[0],o=t[1];return Math.abs(r-a)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-o)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))};var n=r(3);function i(){let e=new n.ARRAY_TYPE(2);return e[0]=0,e[1]=0,e}function a(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function o(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function s(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function u(e,t){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function l(e,t){var r=t[0]-e[0],n=t[1]-e[1];return r*r+n*n}function c(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function f(e){var t=e[0],r=e[1];return t*t+r*r}const h=c;t.len=h;const p=a;t.sub=p;const d=o;t.mul=d;const v=s;t.div=v;const m=u;t.dist=m;const y=l;t.sqrDist=y;const b=f;t.sqrLen=b;const _=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=2),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s1.0001||r<.99999)e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=0;else if(r=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])){var i=Math.atan2(r,t[3])/r;e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=0}else e[0]=0,e[1]=0,e[2]=0,e[3]=0;return e},n.quat.pow=function(e,t,r){return 1===r?n.quat.copy(e,t):(n.quat.ln(e,t),e[0]*=r,e[1]*=r,e[2]*=r,e[3]*=r,n.quat.exp(e,e),e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mat3=void 0;var n=r(7);t.mat3=n.mat3},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mat4=void 0;var n=r(7);t.mat4=n.mat4,n.mat4.arcFromForward=function(){var e=void 0;return function(t,r){e||(e=n.vec3.create());var i=n.vec3.normalize(e,r);if(n.mat4.identity(t),i[2]<-.99999)return t;if(i[2]>.99999)return t[5]=-1,t[10]=-1,t;var a=(1+i[2])/(i[0]*i[0]+i[1]*i[1]);return t[0]=a*i[1]*i[1]-i[2],t[1]=-a*i[0]*i[1],t[2]=i[0],t[4]=t[1],t[5]=a*i[0]*i[0]-i[2],t[6]=i[1],t[8]=-i[0],t[9]=-i[1],t[10]=-i[2],t}}(),n.mat4.copyTranslation=function(e,t){return e[12]=t[12],e[13]=t[13],e[14]=t[14],e},n.mat4.fromMat3=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[4]=t[3],e[5]=t[4],e[6]=t[5],e[8]=t[6],e[9]=t[7],e[10]=t[8],e[3]=e[7]=e[11]=e[12]=e[13]=e[14]=0,e[15]=1,e},n.mat4.lookAtGL=function(){var e=void 0,t=void 0,r=void 0;return function(i,a,o,s){return e||(e=n.vec3.create(),t=n.vec3.create(),r=n.vec3.create()),n.vec3.subtract(r,a,o),0===n.vec3.squaredLength(r)&&(r[2]=1),n.vec3.normalize(r,r),n.vec3.cross(e,s,r),0===n.vec3.squaredLength(e)&&(r[2]+=1e-4,n.vec3.cross(e,s,r)),n.vec3.normalize(e,e),n.vec3.cross(t,r,e),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[4]=t[0],i[5]=t[1],i[6]=t[2],i[8]=r[0],i[9]=r[1],i[10]=r[2],i}}(),n.mat4.perspectiveGL=function(e,t,r,i,a){var o=Math.tan(t/360*Math.PI)*i,s=o*r;return n.mat4.frustum(e,-s,s,-o,o,i,a),e},n.mat4.setTranslation=function(e,t){return e[12]=t[0],e[13]=t[1],e[14]=t[2],e},n.mat4.setTranslationFromValues=function(e,t,r,n){return e[12]=t,e[13]=r,e[14]=n,e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.noise=void 0;var n=r(33),i=r(34),a=t.noise={};a.turbulence=function(){var e=[],t=[],r=[],a=!1;return function(o,s,u,l,c,f){a||function(){for(var o=0;o<256;o++)e[o]=i.vec4.fromValues(Math.random()-.5,Math.random()-.5,Math.random()-.5,Math.random()-.5),t[o]=o;for(var s=256;--s;){var u=t[s],l=Math.floor(256*Math.random());t[s]=t[l],t[l]=u}for(var c=0;c<256;c++)t[256+c]=t[c],e[256+c]=e[c],e[512+c]=e[c];for(var f=0;f<15;++f)r[f]=n.vec3.create();a=!0}(),s+=4096,u+=4096,l+=4096,c+=4096;var h=Math.floor(s),p=Math.floor(u),d=Math.floor(l),v=Math.floor(c),m=s-h,y=u-p,b=l-d,_=c-v,g=(h&=255)+1,E=(p&=255)+1,T=(d&=255)+1,O=(v&=255)+1,w=t[h],S=t[g],R=t[w+p],P=t[S+p],A=t[w+E],M=t[S+E],j=n.vec3.lerp(r[0],e[R+d+v],e[P+d+v],m),D=n.vec3.lerp(r[1],e[A+d+v],e[M+d+v],m),C=n.vec3.lerp(r[2],e[R+T+v],e[P+T+v],m),I=n.vec3.lerp(r[3],e[R+T+v],e[P+T+v],m),k=n.vec3.lerp(r[4],j,D,y),x=n.vec3.lerp(r[5],C,I,y),L=n.vec3.lerp(r[6],k,x,b);j=n.vec3.lerp(r[7],e[R+d+O],e[P+d+O],m),D=n.vec3.lerp(r[8],e[A+d+O],e[M+d+O],m),C=n.vec3.lerp(r[9],e[R+T+O],e[P+T+O],m),I=n.vec3.lerp(r[10],e[R+T+O],e[P+T+O],m),k=n.vec3.lerp(r[11],j,D,y),x=n.vec3.lerp(r[12],C,I,y);var B=n.vec3.lerp(r[13],k,x,b),F=n.vec3.lerp(r[14],L,B,_);return o[0]+=F[0]*f,o[1]+=F[1]*f,o[2]+=F[2]*f,o}}(),a.perlin1=function(){var e=!1,t=256,r=null,n=null;return function(i){e||function(){r=new Array(t+t+2),n=new Array(t+t+2);var i=0,a=0,o=0;for(i=0;it){o=u;break}if(0===e.degree)for(var l=0;l0&&(s=(t-e.knots[e.knots.length-1])/f);for(var h=0;hg&&(g+=i,E+=i,t+=i),_>g&&(g+=i,E+=i,t+=i),E=0;)n=r*n+e[t];return n},n.ag_zeroin2=function(e,t,r,i,a,o){var s=void 0,u=void 0,l=void 0,c=void 0,f=void 0,h=void 0,p=void 0,d=void 0,v=void 0,m=void 0;for(var y=!0;y&&(s=e,c=r,l=u=t-e),Math.abs(c)f&&0!==i;)Math.abs(l)0?d=-d:p=-p,m=l,l=u,2*p<3*h*d-Math.abs(f*d)&&pf?t+=u:h>0?t+=f:t-=f,(i=n.ag_horner1(o.p,o.deg,t))*(c/Math.abs(c))>0&&(y=!0);return t},n.ag_zeroin=function(e,t,r,i){var a,o;return a=n.ag_horner1(i.p,i.deg,e),Math.abs(a)<1.192092896e-7?e:(o=n.ag_horner1(i.p,i.deg,t),Math.abs(o)<1.192092896e-7?t:n.ag_zeroin2(e,t,a,o,r,i))},n.polyZeroes=function(e,t,r,i,a,o,s){var u,l,c=void 0,f=void 0,h=void 0,p=void 0,d=void 0,v=void 0,m=void 0,y=void 0,b=void 0,_=void 0,g=void 0,E=void 0,T=new Array(22),O=void 0,w=new Array(22),S=new Array(22),R={p:[],deg:0};for(m=_=0,y=0,c=0;cs[0]-u:a>s[0]+u,(p=f&&h?1:0)&&(i&&s[0]a&&(s[0]=a)),p;for(R.p=E,R.deg=t,c=1;c<=t;c++)O[c-1]=c*E[c];if(0===(d=n.polyZeroes(O,t-1,r,0,a,0,l)).length)return 0;for(c=v=0;c<=d;c++){if(p>t)return p;0===c?(b=r,g=n.ag_horner1(E,t,b),Math.abs(g)<=u&&i&&(s[p++]=r)):(b=m,g=_),c===d?(m=a,v=0):m=l[c],_=n.ag_horner1(E,t,m),v?v=0:Math.abs(_)0||g>0&&_<0)&&(s[p++]=n.ag_zeroin(b,m,0,R),p>1&&s[p-2]>=s[p-1]-u&&(s[p-2]=.5*(s[p-2]+s[p-1]),p--))}return p}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(79);Object.defineProperty(t,"device",{enumerable:!0,get:function(){return n.device}});var i=r(37);Object.defineProperty(t,"resMan",{enumerable:!0,get:function(){return i.resMan}});var a=r(19);Object.defineProperty(t,"store",{enumerable:!0,get:function(){return a.store}});var o=r(17);Object.defineProperty(t,"logger",{enumerable:!0,get:function(){return o.logger}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.device=t.Tw2Device=void 0;var n=function(){function e(e,t){for(var r=0;r1,this.canvas=t,this.Resize();return this._quadBuffer=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,this._quadBuffer),n.bufferData(n.ARRAY_BUFFER,new Float32Array([1,1,0,1,1,1,-1,1,0,1,0,1,1,-1,0,1,1,0,-1,-1,0,1,0,0]),n.STATIC_DRAW),this._cameraQuadBuffer=n.createBuffer(),this._quadDecl=new l.Tw2VertexDeclaration,this._quadDecl.elements.push(new l.Tw2VertexElement(l.Tw2VertexDeclaration.Type.POSITION,0,n.FLOAT,4,0)),this._quadDecl.elements.push(new l.Tw2VertexElement(l.Tw2VertexDeclaration.Type.TEXCOORD,0,n.FLOAT,2,16)),this._quadDecl.RebuildHash(),this._alphaTestState={},this._alphaTestState.states={},this._alphaTestState.states[this.RS_ALPHATESTENABLE]=0,this._alphaTestState.states[this.RS_ALPHAREF]=-1,this._alphaTestState.states[this.RS_ALPHAFUNC]=this.CMP_GREATER,this._alphaTestState.states[this.RS_CLIPPING]=0,this._alphaTestState.states[this.RS_CLIPPLANEENABLE]=0,this._alphaTestState.dirty=!1,this._alphaBlendState={},this._alphaBlendState.states={},this._alphaBlendState.states[this.RS_SRCBLEND]=this.BLEND_SRCALPHA,this._alphaBlendState.states[this.RS_DESTBLEND]=this.BLEND_INVSRCALPHA,this._alphaBlendState.states[this.RS_BLENDOP]=this.BLENDOP_ADD,this._alphaBlendState.states[this.RS_SEPARATEALPHABLENDENABLE]=0,this._alphaBlendState.states[this.RS_BLENDOPALPHA]=this.BLENDOP_ADD,this._alphaBlendState.states[this.RS_SRCBLENDALPHA]=this.BLEND_SRCALPHA,this._alphaBlendState.states[this.RS_DESTBLENDALPHA]=this.BLEND_INVSRCALPHA,this._alphaBlendState.dirty=!1,this._depthOffsetState={},this._depthOffsetState.states={},this._depthOffsetState.states[this.RS_SLOPESCALEDEPTHBIAS]=0,this._depthOffsetState.states[this.RS_DEPTHBIAS]=0,this._depthOffsetState.dirty=!1,this.wrapModes=[],this.wrapModes[0]=0,this.wrapModes[1]=n.REPEAT,this.wrapModes[2]=n.MIRRORED_REPEAT,this.wrapModes[3]=n.CLAMP_TO_EDGE,this.wrapModes[4]=n.CLAMP_TO_EDGE,this.wrapModes[5]=n.CLAMP_TO_EDGE,this._shadowStateBuffer=new Float32Array(24),this._blendTable=[-1,n.ZERO,n.ONE,n.SRC_COLOR,n.ONE_MINUS_SRC_COLOR,n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.DST_ALPHA,n.ONE_MINUS_DST_ALPHA,n.DST_COLOR,n.ONE_MINUS_DST_COLOR,n.SRC_ALPHA_SATURATE,-1,-1,n.CONSTANT_COLOR,n.ONE_MINUS_CONSTANT_COLOR],this.glVersion}},{key:"Schedule",value:function(e){this._scheduled.includes(e)||this._scheduled.push(e)}},{key:"OnResize",value:function(e){this._onResize=e}},{key:"Resize",value:function(){if(this.vrDisplay&&this.vrDisplay.isPresenting){var e=this.vrDisplay.getEyeParameters("left"),t=this.vrDisplay.getEyeParameters("right");this.canvas.width=2*Math.max(e.renderWidth,t.renderWidth),this.canvas.height=Math.max(t.renderHeight,t.renderHeight)}else this.canvas.width=this.canvas.offsetWidth*this.viewportPixelRatio,this.canvas.height=this.canvas.offsetHeight*this.viewportPixelRatio;this.viewportWidth=this.canvas.clientWidth,this.viewportHeight=this.canvas.clientHeight,this.viewportAspect=this.viewportWidth/this.viewportHeight,this._onResize&&this._onResize(this.viewportWidth,this.viewportHeight),a.store.SetVariableValue("ViewportSize",[this.viewportWidth,this.viewportHeight,this.viewportWidth,this.viewportHeight])}},{key:"Tick",value:function(){this.canvas.clientWidth===this.viewportWidth&&this.canvas.clientHeight===this.viewportHeight||this.Resize();var e=null===this.previousTime?0:this.previousTime,t=this.Now();this.currentTime=.001*(t-this.startTime),this.dt=null===this.previousTime?0:.001*(t-this.previousTime),this.previousTime=t,a.store.SetVariableValue("Time",[this.currentTime,this.currentTime-Math.floor(this.currentTime),this.frameCounter,e]),s.resMan.PrepareLoop(this.dt);for(var r=0;r1.6&&(r=t/1.6);var n=2*Math.atan(r/this.projection[5]);return e[0]=this.viewportWidth,e[1]=this.viewportHeight,e[2]=n,e[3]=n*t,e}},{key:"GetEyePosition",value:function(e){return i.vec3.copy(e,this.eyePosition)}},{key:"IsAlphaTestEnabled",value:function(){return this._alphaTestState.states[this.RS_ALPHATESTENABLE]}},{key:"IsFrameBufferComplete",value:function(e){return this.gl.checkFramebufferStatus(e)===this.gl.FRAMEBUFFER_COMPLETE}},{key:"GetExtension",value:function(t){for(var r in e.WebglVendorPrefixes)if(e.WebglVendorPrefixes.hasOwnProperty(r)){var n=this.gl.getExtension(e.WebglVendorPrefixes[r]+t);if(n)return n}return null}},{key:"GetFallbackTexture",value:function(){return this._fallbackTexture||(this._fallbackTexture=this.CreateSolidTexture()),this._fallbackTexture}},{key:"GetFallbackCubeMap",value:function(){return this._fallbackCube||(this._fallbackCube=this.CreateSolidCube()),this._fallbackCube}},{key:"CreateSolidTexture",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],t=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,1,1,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(e)),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.bindTexture(this.gl.TEXTURE_2D,null),t}},{key:"CreateSolidCube",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],t=this.gl.createTexture();this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP,t);for(var r=0;r<6;++r)this.gl.texImage2D(this.gl.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,this.gl.RGBA,1,1,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(e));return this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP,null),t}},{key:"RenderFullScreenQuad",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Main";if(!e||!e.IsGood())return!1;this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._quadBuffer);for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:"Main";if(!e||!e.IsGood())return!1;for(var r=new Float32Array([1,1,0,1,1,1,-1,1,0,1,0,1,1,-1,0,1,1,0,-1,-1,0,1,0,0]),n=this.projectionInverse,a=0;a<4;++a){var o=r.subarray(6*a,6*a+4);i.vec4.transformMat4(o,o,n),i.vec3.scale(o,o,1/o[3]),o[3]=1}this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._cameraQuadBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,r,this.gl.STATIC_DRAW);for(var s=0;s>16,r=(4278190080&e)>>24,n=(r<<1&255|t>>7)-127,i=(127&t)<<16|(65280&e)>>8<<8|255&e;return 0===i&&-127===n?0:(1-2*(r>>7))*(1+i*Math.pow(2,-23))*Math.pow(2,n)}},{key:"CreateContext",value:function(e,t,r){r=Array.isArray(r)?r:[r];for(var n=0;n>8&255]+a[e>>16&255]+a[e>>24&255]+"-"+a[255&t]+a[t>>8&255]+"-"+a[t>>16&15|64]+a[t>>24&255]+"-"+a[63&r|128]+a[r>>8&255]+"-"+a[r>>16&255]+a[r>>24&255]+a[255&n]+a[n>>8&255]+a[n>>16&255]+a[n>>24&255]}():i++};var n=null,i=0,a=null},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getURL=function(){return Object.assign({},n)},t.getURLString=function(e,t){return(e=e.toLowerCase())in n?n[e]:t},t.getURLInteger=function(e,t){return(e=e.toLowerCase())in n?parseInt(n[e],10):t},t.getURLFloat=function(e,t){return(e=e.toLowerCase())in n?parseFloat(n[e]):t},t.getURLBoolean=function(e,t){return(e=e.toLowerCase())in n?n[e]:t};for(var n={},i=window.location.search.substring(1).split("&"),a=0;a=r&&a.Unload()&&(n.log("res.event",{msg:"Unloaded ",path:a.path,type:"unused"}),delete this._loadedObjects[i]))}}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SamplerOverride=void 0;var n=r(0),i=r(43);t.Tw2SamplerOverride=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="",this.addressU=0,this.addressV=0,this.addressW=0,this.filter=0,this.mipFilter=0,this.lodBias=0,this.maxMipLevel=0,this.maxAnisotropy=0;var t=null;this.GetSampler=function(e){if(!t){(t=new i.Tw2SamplerState).registerIndex=e.registerIndex,t.name=e.name;var r=n.device.wrapModes,a=n.device.gl;if(1===this.filter){switch(this.mipFilter){case 0:t.minFilter=a.NEAREST;break;case 1:t.minFilter=a.NEAREST_MIPMAP_NEAREST;break;default:t.minFilter=a.NEAREST_MIPMAP_LINEAR}t.minFilterNoMips=a.NEAREST}else{switch(this.mipFilter){case 0:t.minFilter=a.LINEAR;break;case 1:t.minFilter=a.LINEAR_MIPMAP_NEAREST;break;default:t.minFilter=a.LINEAR_MIPMAP_LINEAR}t.minFilterNoMips=a.LINEAR}3!==this.filter&&3!==this.mipFilter||(t.anisotropy=Math.max(this.maxAnisotropy,1)),t.magFilter=1===this.filter?a.NEAREST:a.LINEAR,t.addressU=r[this.addressU],t.addressV=r[this.addressV],t.addressW=r[this.addressW],t.samplerType=e.samplerType,t.isVolume=e.isVolume,t.ComputeHash()}return t}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VertexDeclaration=void 0;var n=function(){function e(e,t){for(var r=0;rt)return null}if(n.usage>e)return null}return null}},{key:"SetDeclaration",value:function(t,r){for(var n=i.device.gl,a=0,o=0;o=this._elementsSorted.length){n.disableVertexAttribArray(s.location),n.vertexAttrib4f(s.location,0,0,0,0);break}var u=this._elementsSorted[a],l=e.CompareDeclarationElements(u,s);if(l>0){n.disableVertexAttribArray(s.location),n.vertexAttrib4f(s.location,0,0,0,0);break}if(0===l){u.customSetter?u.customSetter(s):(n.enableVertexAttribArray(s.location),n.vertexAttribPointer(s.location,u.elements,u.type,!1,r,u.offset));break}a++}}return!0}},{key:"SetPartialDeclaration",value:function(t,r){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=i.device.ext,s=i.device.gl,u=[],l=0,c=0;c0){a||(s.disableVertexAttribArray(f.location),s.vertexAttrib4f(f.location,0,0,0,0));break}if(++l>=this._elementsSorted.length)return a||(s.disableVertexAttribArray(f.location),s.vertexAttrib4f(f.location,0,0,0,0)),u}}return u}},{key:"ResetInstanceDivisors",value:function(e){if(e)for(var t=0;t2&&void 0!==arguments[2]?arguments[2]:0;return e.usaget.usage?1:e.usageIndex+rt.usageIndex?1:0}}]),e}()).Type={POSITION:0,COLOR:1,NORMAL:2,TANGENT:3,BINORMAL:4,TEXCOORD:5,BLENDWEIGHT:6,BLENDINDICES:7}},function(e,t,r){(function(t){WebGLDebugUtils=function(){var e;void 0===e&&(e=t);var r=function(t){e.console&&e.console.error?e.console.error(t):function(t){e.console&&e.console.log&&e.console.log(t)}(t)},n={enable:{1:{0:!0}},disable:{1:{0:!0}},getParameter:{1:{0:!0}},drawArrays:{3:{0:!0}},drawElements:{4:{0:!0,2:!0}},createShader:{1:{0:!0}},getShaderParameter:{2:{1:!0}},getProgramParameter:{2:{1:!0}},getShaderPrecisionFormat:{2:{0:!0,1:!0}},getVertexAttrib:{2:{1:!0}},vertexAttribPointer:{6:{2:!0}},bindTexture:{2:{0:!0}},activeTexture:{1:{0:!0}},getTexParameter:{2:{0:!0,1:!0}},texParameterf:{3:{0:!0,1:!0}},texParameteri:{3:{0:!0,1:!0,2:!0}},copyTexImage2D:{8:{0:!0,2:!0}},copyTexSubImage2D:{8:{0:!0}},generateMipmap:{1:{0:!0}},bindBuffer:{2:{0:!0}},getBufferParameter:{2:{0:!0,1:!0}},pixelStorei:{2:{0:!0,1:!0}},bindRenderbuffer:{2:{0:!0}},bindFramebuffer:{2:{0:!0}},checkFramebufferStatus:{1:{0:!0}},framebufferRenderbuffer:{4:{0:!0,1:!0,2:!0}},framebufferTexture2D:{5:{0:!0,1:!0,2:!0}},getFramebufferAttachmentParameter:{3:{0:!0,1:!0,2:!0}},getRenderbufferParameter:{2:{0:!0,1:!0}},renderbufferStorage:{4:{0:!0,1:!0}},clear:{1:{0:{enumBitwiseOr:["COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT"]}}},depthFunc:{1:{0:!0}},blendFunc:{2:{0:!0,1:!0}},blendFuncSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},blendEquation:{1:{0:!0}},blendEquationSeparate:{2:{0:!0,1:!0}},stencilFunc:{3:{0:!0}},stencilFuncSeparate:{4:{0:!0,1:!0}},stencilMaskSeparate:{2:{0:!0}},stencilOp:{3:{0:!0,1:!0,2:!0}},stencilOpSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},cullFace:{1:{0:!0}},frontFace:{1:{0:!0}},drawArraysInstancedANGLE:{4:{0:!0}},drawElementsInstancedANGLE:{5:{0:!0,2:!0}},blendEquationEXT:{1:{0:!0}},bufferData:{3:{0:!0,2:!0},4:{0:!0,2:!0},5:{0:!0,2:!0}},bufferSubData:{3:{0:!0},4:{0:!0},5:{0:!0}},copyBufferSubData:{5:{0:!0,1:!0}},getBufferSubData:{3:{0:!0},4:{0:!0},5:{0:!0}},blitFramebuffer:{10:{8:{enumBitwiseOr:["COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT"]},9:!0}},framebufferTextureLayer:{5:{0:!0,1:!0}},invalidateFramebuffer:{2:{0:!0}},invalidateSubFramebuffer:{6:{0:!0}},readBuffer:{1:{0:!0}},getInternalformatParameter:{3:{0:!0,1:!0,2:!0}},renderbufferStorageMultisample:{5:{0:!0,2:!0}},texStorage2D:{5:{0:!0,2:!0}},texStorage3D:{6:{0:!0,2:!0}},texImage2D:{9:{0:!0,2:!0,6:!0,7:!0},6:{0:!0,2:!0,3:!0,4:!0},10:{0:!0,2:!0,6:!0,7:!0}},texImage3D:{10:{0:!0,2:!0,7:!0,8:!0},11:{0:!0,2:!0,7:!0,8:!0}},texSubImage2D:{9:{0:!0,6:!0,7:!0},7:{0:!0,4:!0,5:!0},10:{0:!0,6:!0,7:!0}},texSubImage3D:{11:{0:!0,8:!0,9:!0},12:{0:!0,8:!0,9:!0}},copyTexSubImage3D:{9:{0:!0}},compressedTexImage2D:{7:{0:!0,2:!0},8:{0:!0,2:!0},9:{0:!0,2:!0}},compressedTexImage3D:{8:{0:!0,2:!0},9:{0:!0,2:!0},10:{0:!0,2:!0}},compressedTexSubImage2D:{8:{0:!0,6:!0},9:{0:!0,6:!0},10:{0:!0,6:!0}},compressedTexSubImage3D:{10:{0:!0,8:!0},11:{0:!0,8:!0},12:{0:!0,8:!0}},vertexAttribIPointer:{5:{2:!0}},drawArraysInstanced:{4:{0:!0}},drawElementsInstanced:{5:{0:!0,2:!0}},drawRangeElements:{6:{0:!0,4:!0}},readPixels:{7:{4:!0,5:!0},8:{4:!0,5:!0}},clearBufferfv:{3:{0:!0},4:{0:!0}},clearBufferiv:{3:{0:!0},4:{0:!0}},clearBufferuiv:{3:{0:!0},4:{0:!0}},clearBufferfi:{4:{0:!0}},beginQuery:{2:{0:!0}},endQuery:{1:{0:!0}},getQuery:{2:{0:!0,1:!0}},getQueryParameter:{2:{1:!0}},samplerParameteri:{3:{1:!0,2:!0}},samplerParameterf:{3:{1:!0}},getSamplerParameter:{2:{1:!0}},fenceSync:{2:{0:!0,1:{enumBitwiseOr:[]}}},clientWaitSync:{3:{1:{enumBitwiseOr:["SYNC_FLUSH_COMMANDS_BIT"]}}},waitSync:{3:{1:{enumBitwiseOr:[]}}},getSyncParameter:{2:{1:!0}},bindTransformFeedback:{2:{0:!0}},beginTransformFeedback:{1:{0:!0}},transformFeedbackVaryings:{3:{2:!0}},bindBufferBase:{3:{0:!0}},bindBufferRange:{5:{0:!0}},getIndexedParameter:{2:{0:!0}},getActiveUniforms:{3:{2:!0}},getActiveUniformBlockParameter:{3:{2:!0}}},i=null,a=null;function o(e){if(null==i)for(var t in i={},a={},e)"number"==typeof e[t]&&(i[e[t]]=t,a[t]=e[t])}function s(){if(null==i)throw"WebGLDebugUtils.init(ctx) not called"}function u(e){s();var t=i[e];return void 0!==t?"gl."+t:"/*UNKNOWN WebGL ENUM*/ 0x"+e.toString(16)}function l(e,t,r,i){var o;if(void 0!==(o=n[e])&&(void 0!==(o=o[t])&&o[r])){if("object"==typeof o[r]&&void 0!==o[r].enumBitwiseOr){for(var s=o[r].enumBitwiseOr,l=0,c=[],f=0;f=0&&setTimeout(function(){t.restoreContext()},v)},0)}},t.restoreContext=function(){u&&a.length&&setTimeout(function(){if(!d)throw"can not restore. webglcontestlost listener did not call event.preventDefault";!function(){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:0;this.isPlaying=!0,this.scaledTime=e}},{key:"Stop",value:function(){this.isPlaying=!1}},{key:"Update",value:function(e){if(this.isPlaying){this.scaledTime+=e*this.scale;for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:this;this._copyFunc&&(this._copyFunc.call(this),"OnValueChanged"in this.destinationObject&&this.destinationObject.OnValueChanged(e,[this.destinationAttribute]))}}],[{key:"CopyValueToValue",value:function(){this.destinationObject[this.destinationAttribute]=this.sourceObject[this.sourceAttribute]*this.scale+this.offset[0]}},{key:"CopyArray",value:function(){for(var e=Math.min(this.destinationObject[this.destinationAttribute].length,this.sourceObject[this.sourceAttribute].length),t=0;t0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.value=a.util.isArrayLike(r)?r[0]:r,n.constantBuffer=null,n.offset=null,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.Tw2Parameter),n(t,[{key:"SetValue",value:function(e){this.value=e,this.OnValueChanged()}},{key:"GetValue",value:function(){return this.value}},{key:"Apply",value:function(e,t){e[t]=this.value}},{key:"EqualsValue",value:function(e){return this.value===e}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.SetValue(e.GetValue())}}],[{key:"isValue",value:function(e){return a.util.isNumber(e)}}]),t}()).constantBufferSize=1},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MatrixParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.mat4.create();return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"Compose",value:function(e,t,r){"value"in e&&(e=e.value),"value"in t&&(t=t.value),"value"in r&&(r=r.value),i.mat4.fromRotationTranslationScale(this.value,e,t,r),this.OnValueChanged()}},{key:"Decompose",value:function(e,t,r){i.mat4.getRotation("value"in e?e.value:e,this.value),i.mat4.getTranslation("value"in t?t.value:t,this.value),i.mat4.getScaling("value"in r?r.value:r,this.value),"OnValueChanged"in e&&e.OnValueChanged(),"OnValueChanged"in t&&t.OnValueChanged(),"OnValueChanged"in r&&r.OnValueChanged()}},{key:"x",get:function(){return this.GetIndexValue(12)},set:function(e){this.SetIndexValue(12,e)}},{key:"y",get:function(){return this.GetIndexValue(13)},set:function(e){this.SetIndexValue(13,e)}},{key:"z",get:function(){return this.GetIndexValue(14)},set:function(e){this.SetIndexValue(14,e)}}]),t}()).constantBufferSize=16},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TransformParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.scaling=i.vec3.fromValues(1,1,1),r.rotationCenter=i.vec3.create(),r.rotation=i.quat.create(),r.translation=i.vec3.create(),r.transform=i.mat4.create(),r.worldTransform=i.mat4.create(),r.constantBuffer=null,r.offset=null,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2Parameter),n(t,[{key:"Initialize",value:function(){this.OnValueChanged()}},{key:"GetValue",value:function(e){return e?Array.from(this.transform):new Float32Array(this.transform)}},{key:"OnValueChanged",value:function(e,r){i.mat4.fromRotationTranslationScaleOrigin(this.transform,this.rotation,this.translation,this.scaling,this.rotationCenter),i.mat4.transpose(this.worldTransform,this.transform),function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,r,n)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(n):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"OnValueChanged",this).call(this,e,r)}},{key:"Bind",value:function(e,t,r){return!this.constantBuffer&&r>=this.size&&(this.constantBuffer=e,this.offset=t,this.Apply(e,t,r),!0)}},{key:"Apply",value:function(e,t,r){r>=this.constructor.constantBufferSize?e.set(this.worldTransform,t):e.set(this.worldTransform.subarray(0,r),t)}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),i.quat.copy(this.rotation,e.rotation),i.vec3.copy(this.translation,e.translation),i.vec3.copy(this.scaling,e.scaling),i.vec3.copy(this.rotationCenter,e.rotationCenter),this.OnValueChanged()}}]),t}()).constantBufferSize=16},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VariableParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.variableName=r,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2Parameter),n(t,[{key:"GetValue",value:function(e){return i.store.GetVariableValue(this.variableName,e)}},{key:"Apply",value:function(e,t,r){this.variable&&this.variable.Apply(e,t,r)}},{key:"AddCallback",value:function(){return!1}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.variableName=e.variableName}},{key:"variable",get:function(){return i.store.GetVariable(this.variableName)}},{key:"size",get:function(){return this.variable?this.variable.size:0}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector2Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec2.fromValues(1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}}]),t}()).constantBufferSize=2},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector3Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec3.fromValues(1,1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}},{key:"z",get:function(){return this.GetIndexValue(2)},set:function(e){this.SetIndexValue(2,e)}}]),t}()).constantBufferSize=3},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector4Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec4.fromValues(1,1,1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}},{key:"z",get:function(){return this.GetIndexValue(2)},set:function(e){this.SetIndexValue(2,e)}},{key:"w",get:function(){return this.GetIndexValue(3)},set:function(e){this.SetIndexValue(3,e)}}]),t}()).constantBufferSize=4},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(102);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(46);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(24);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveBasicPerObjectData=t.Tw2BasicPerObjectData=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"DeclareFromObject",this).call(this,e),e.FFEData&&(this.perObjectFFEData=new s.Tw2RawData(e.FFEData))}}]),t}();t.EveBasicPerObjectData=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2BlendShapeData=void 0;var n=r(9);t.Tw2BlendShapeData=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="",this.declaration=new n.Tw2VertexDeclaration,this.buffers=[],this.indexes=null,this.weightProxy=null}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2GeometryAnimation=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="",this.duration=0,this.trackGroups=[]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2GeometryBone=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[];return i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"GetResources",this).call(this,e),this.instanceGeometryResource&&"GetResources"in this.instanceGeometryResource&&this.instanceGeometryResource.GetResources(e),e}},{key:"RenderAreas",value:function(e,t,r,n,i){if(this.IsGood()){var a=this.instanceGeometryResource.GetInstanceBuffer(this.instanceMeshIndex);a&&this.geometryResource.RenderAreasInstanced(e,t,r,n,i,a,this.instanceGeometryResource.GetInstanceDeclaration(this.instanceMeshIndex),this.instanceGeometryResource.GetInstanceStride(this.instanceMeshIndex),this.instanceGeometryResource.GetInstanceCount(this.instanceMeshIndex))}}}],[{key:"GetAreaBatches",value:function(e,t,r,n,i){for(var a=0;a0&&void 0!==arguments[0]?arguments[0]:[],t=0;tf.duration&&(c.callback&&c.callback(this,c),c.cycle?c.time=c.time%f.duration:(c.isPlaying=!1,c.time=f.duration));for(var h=0;h=0){var i=this.models[t].bones[n.boneRes.parentIndex];e.AddLine([n.worldTransform[12],n.worldTransform[13],n.worldTransform[14]],[i.worldTransform[12],i.worldTransform[13],i.worldTransform[14]])}}}}],[{key:"AddModel",value:function(e,t){for(var r=0;r7)return i.logger.log("res.error",{log:"error",src:["Tw2EffectRes","CreateProgram"],msg:"Invalid version of effect file",type:"shader.effectversion",path:this.path,value:o}),void this.PrepareFinished(!1);var s=void 0,u=void 0;if(o<5){if(0===(s=t.ReadUInt32()))return i.logger.log("res.error",{log:"error",src:["Tw2EffectRes","CreateProgram"],msg:"File contains no compiled effects",path:this.path,type:"shader.effectheadersize",value:0}),void this.PrepareFinished(!1);t.ReadUInt32();var l=t.ReadUInt32();t.cursor=8+3*s*4,u=t.ReadUInt32(),this.stringTableOffset=t.cursor,r=String.fromCharCode.apply(null,t.data.subarray(t.cursor,t.cursor+u)),t.cursor=l}else{u=t.ReadUInt32(),this.stringTableOffset=t.cursor,r=String.fromCharCode.apply(null,t.data.subarray(t.cursor,t.cursor+u)),t.cursor+=u;for(var c=t.ReadUInt8(),f=0;f6&&(h=t.ReadUInt8());for(var p=0;p6&&(d.name=l()),this.techniques[d.name]=d;for(var v=t.ReadUInt8(),m=0;m=3&&(t.ReadUInt32(),t.ReadUInt32(),t.ReadUInt32()),E.constantSize=0;for(var C=t.ReadUInt32(),I=0;IE.constantSize&&(E.constantSize=x)}}var L=t.ReadUInt32()/4;if(E.constantValues=new Float32Array(L),r<5)for(var B=0;B=4?l():"";t.ReadUInt8();var X=t.ReadUInt8(),K=t.ReadUInt8(),Q=t.ReadUInt8(),Z=t.ReadUInt8(),J=t.ReadUInt8(),$=t.ReadUInt8();t.ReadFloat32();var ee=t.ReadUInt8();t.ReadUInt8();var te=i.quat.create();te[0]=t.ReadFloat32(),te[1]=t.ReadFloat32(),te[2]=t.ReadFloat32(),te[3]=t.ReadFloat32(),t.ReadFloat32(),t.ReadFloat32(),r<4&&t.ReadUInt8();var re=new o.Tw2SamplerState;if(re.registerIndex=Y,re.name=W,1===X){switch(Q){case 0:re.minFilter=f.NEAREST;break;case 1:re.minFilter=f.NEAREST_MIPMAP_NEAREST;break;default:re.minFilter=f.NEAREST_MIPMAP_LINEAR}re.minFilterNoMips=f.NEAREST}else{switch(Q){case 0:re.minFilter=f.LINEAR;break;case 1:re.minFilter=f.LINEAR_MIPMAP_NEAREST;break;default:re.minFilter=f.LINEAR_MIPMAP_LINEAR}re.minFilterNoMips=f.LINEAR}re.magFilter=1===K?f.NEAREST:f.LINEAR,re.addressU=c[Z],re.addressV=c[J],re.addressW=c[$],3!==X&&3!==K&&3!==Q||(re.anisotropy=Math.max(ee,1));for(var ne=0;ne=3&&t.ReadUInt8(),y.stages[T]=E}y.states=[];for(var ie=t.ReadUInt8(),ae=0;ae=0){var p=new a.Tw2VertexElement(r.stages[0].inputDefinition.elements[f].usage,r.stages[0].inputDefinition.elements[f].usageIndex);p.location=h,s.input.elements.push(p)}}s.input.RebuildHash(),s.shadowStateInt=o.getUniformLocation(s.program,"ssi"),s.shadowStateFloat=o.getUniformLocation(s.program,"ssf"),s.shadowStateYFlip=o.getUniformLocation(s.program,"ssyf"),o.uniform3f(s.shadowStateYFlip,0,0,1),s.volumeSlices=[];for(var d=0;d=this.meshes.length)return!1;var c=i.device,f=c.ext,h=c.gl,p=this.meshes[e],d=n.GetPassCount(a);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,p.indexes);for(var v=0;v=this.meshes.length)return!1;var o=i.device,s=o.gl,u=this.meshes[e]||this.meshes[0],l=n.GetPassCount(a);s.bindBuffer(s.ARRAY_BUFFER,u.buffer),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,u.indexes);for(var c=0;c=this.meshes.length)return!1;var o=i.device,s=o.gl,u=this.meshes[e],l=n.GetPassCount(a);s.bindBuffer(s.ARRAY_BUFFER,u.buffer),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,u.indexes);for(var c=0;c=0){var i=this.models[t].skeleton.bones[n.parentIndex];e.AddLine([n.worldTransform[12],n.worldTransform[13],n.worldTransform[14]],[i.worldTransform[12],i.worldTransform[13],i.worldTransform[14]],[0,.7,0,1],[0,.7,0,1])}}}},{key:"Unload",value:function(){for(var e=0;e>5),s.offset=4*n,t.elements[a]=s,n+=s.elements}t.RebuildHash(),t.stride=4*n;var u=e.ReadUInt32();if(0===u)return null;for(var l=new Float32Array(n*u),c=0,f=0;f0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.cycle=e,this._onEnded=t,this.video&&this._playable?(this.video.loop=this.cycle,this.video.play()):this.playOnLoad=!0}},{key:"Pause",value:function(){this.video?this.video.pause():this.playOnLoad=!1}},{key:"Prepare",value:function(e){var t=i.device.gl;switch(e){case"mp4":case"webm":case"ogg":this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this.video),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.bindTexture(t.TEXTURE_2D,null),this.width=this.video.width,this.height=this.video.height,this.video.loop=this.cycle,this.playOnLoad&&this.video.play(),this.PrepareFinished(!0)}}},{key:"DoCustomLoad",value:function(e){var t=this,r=i.resMan.constructor.GetPathExt(e);return this.LoadStarted(),i.resMan._pendingLoads++,this.video=document.createElement("video"),this.video.crossOrigin="anonymous",this.video.muted=!0,this.video.onerror=function(){i.resMan._pendingLoads--,i.logger.log("res.error",{log:"error",src:["Tw2TextureRes","DoCustomLoad"],msg:"Error loading resource",type:"http.error",path:e}),t.LoadFinished(!1),t.PrepareFinished(!1),t.video=null},this.video.oncanplay=function(){t._playable=!0,t.video.oncanplay=null,i.resMan._pendingLoads--,i.resMan._prepareQueue.push([t,r,null]),t.LoadFinished(!0)},this.video.onended=function(){t._isPlaying=!1,t._onEnded&&t._onEnded(t)},this.video.onpause=function(){t._isPlaying=!1,t._onPause&&t._onPause(t)},this.video.onplaying=function(){t._isPlaying=!0,t._onPlaying&&t._onPlaying(t)},this.video.src=e,!0}},{key:"Unload",value:function(){return this.texture&&(i.device.gl.deleteTexture(this.texture),this.texture=null),this._isPlaying=!1,this._playable=!1,this.playOnLoad=!0,this.video=null,!0}},{key:"Bind",value:function(e){var t=i.device,r=t.gl;this.KeepAlive();var n=e.samplerType;n===r.TEXTURE_2D&&(this.texture?(this._currentTime=this.video.currentTime,r.bindTexture(r.TEXTURE_2D,this.texture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,this.video),r.bindTexture(r.TEXTURE_2D,null),r.bindTexture(n,this.texture),e.hash!==this._currentSampler&&(e.Apply(!1),this._currentSampler=e.hash)):r.bindTexture(r.TEXTURE_2D,t.GetFallbackTexture()))}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(123);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PostProcess=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Undefined error";n(this,t);var a=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return"string"==typeof e?e={message:e}:e.message=e.message||r,a.message=e.message,a.name=a.constructor.name,a.data=e,s?Error.captureStackTrace(a,t):a.stack=new Error(e.message).stack,a}return a(t,o(Error)),t}();u.isError=!0;t.HTTPRequestError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Communication error while requesting resource"))}return a(t,u),t}(),t.HTTPRequestSendError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Communication send error while requesting resource"))}return a(t,u),t}(),t.HTTPInstanceError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Could not create an XML HTTP instance"))}return a(t,u),t}(),t.HTTPStatusError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Communication status error while loading resource"))}return a(t,u),t}(),t.HTTPReadyStateError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Communication ready state error while loading resource"))}return a(t,u),t}(),t.Tw2XMLBinaryError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Invalid binary"))}return a(t,u),t}(),t.Tw2XMLObjectTypeUndefinedError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"XML Object with undefined type"))}return a(t,u),t}(),t.Tw2GeometryMeshParticleElementError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Input geometry mesh lacks element required by particle system"))}return a(t,u),t}(),t.Tw2GeometryMeshElementComponentError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Input geometry mesh elements do not have the required number of components"))}return a(t,u),t}(),t.Tw2GeometryMeshInvalidBoneError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Geometry mesh has invalid bone name for model"))}return a(t,u),t}(),t.Tw2GeometryMeshEffectBindError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Error binding geometry mesh to effect"))}return a(t,u),t}(),t.Tw2GeometryFileTypeError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Invalid geometry file type"))}return a(t,u),t}(),t.Tw2ResourcePrefixUnregisteredError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Unregistered resource prefix"))}return a(t,u),t}(),t.Tw2ResourcePrefixUndefinedError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Undefined resource prefix"))}return a(t,u),t}(),t.Tw2ResourceExtensionUnregisteredError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Unregistered resource extension"))}return a(t,u),t}(),t.Tw2ResourceExtensionUndefinedError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Undefined resource extension"))}return a(t,u),t}(),t.Tw2ShaderVersionError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Invalid version of effect file"))}return a(t,u),t}(),t.Tw2ShaderHeaderSizeError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Effect file contains no compiled effects"))}return a(t,u),t}(),t.Tw2ShaderPermutationValueError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Invalid shader permutation value"))}return a(t,u),t}(),t.Tw2ShaderCompileError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Error compiling shader"))}return a(t,u),t}(),t.Tw2ShaderLinkError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Error linking shaders"))}return a(t,u),t}(),t.Tw2DeclarationValueTypeError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Invalid declaration value type"))}return a(t,u),t}(),t.Tw2SingleInstantiationError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Class can only be instantiated once"))}return a(t,u),t}(),t.Tw2AbstractClassMethodError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Abstract class method not implemented directly on child class"))}return a(t,u),t}(),t.Tw2FeatureNotImplementedError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Feature not implemented"))}return a(t,u),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2Float=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.value=0}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Frustum=void 0;var n=function(){function e(e,t){for(var r=0;r=a.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.vec4.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.vec4.copy(r,a.value);case t.Extrapolation.GRADIENT:return i.vec4.scaleAndAdd(r,a.value,a.right,e-a.time);default:e%=a.time}else if(e<0||e=o.time||ethis.length){if(!this.cycle)return this.reversed?i.vec4.copy(t,this.startValue):i.vec4.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec4.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a[2]=o[2]+(s[2]-o[2])*(e/l),a[3]=o[3]+(s[3]-o[3])*(e/l),a;default:return a}}}]),t}();c.inputDimension=4,c.outputDimension=4,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2EventCurve=t.Tw2EventKey=void 0;var n=function(){function e(e,t){for(var r=0;r=this.keys[this._currentKey].time;)this.value=this.keys[this._currentKey].value,++this._currentKey}}]),t}();l.dimension=1,l.outputDimension=1,l.valueProperty="value",l.curveType=i.Tw2Curve.Type.CURVE,l.Key=u,l.Extrapolation={NONE:0,CYCLE:3}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PerlinCurve=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?(t[0]=this.startValue[0],t[1]=this.startValue[1],t[2]=this.startValue[2],t):(t[0]=this.endValue[0],t[1]=this.endValue[1],t[2]=this.endValue[2],t);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var i=0;i+1e));++i);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){a[0]=this.startValue[0],a[1]=this.startValue[1],a[2]=this.startValue[2];var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.SPHERICAL_LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),i.quat.slerp(a,o,s,e/l),a;default:return a}}}]),t}();c.inputDimension=4,c.outputDimension=4,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,SPHERICAL_LINEAR:4}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2RandomConstantCurve=void 0;var n=function(){function e(e,t){for(var r=0;r=this.states[this.states.length-1].time)r=this.states.length-1;else for(;r+1=this.states[r].time&&e=s.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.quat.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.quat.copy(r,s.value);default:e%=s.time}else if(e<0||e=u.time||e0;p--){var d=i.num.biCumulative(c,p);d>1&&i.quat.multiply(r,f,h[p]),r[0]=-h[p-1][0],r[1]=-h[p-1][1],r[2]=-h[p-1][2],r[3]=h[p-1][3],i.quat.multiply(r,r,h[p]),i.quat.pow(r,r,d),i.quat.multiply(f,f,r)}return i.quat.multiply(r,f,l.value);case t.Interpolation.SLERP:return i.quat.slerp(r,l.value,u.value,c);default:return i.quat.sqlerp(r,l.value,l.right,u.left,u.value,c)}}}]),t}();c.outputDimention=4,c.inputDimension=4,c.valueProperty="value",c.curveType=a.Tw2Curve.Type.CURVE,c.Child=l,c.Extrapolation={NONE:0,CONSTANT:1,GRADIENT:2,CYCLE:3},c.Interpolation={NONE:0,CONSTANT:1,LINEAR:2,HERMITE:3,SLERP:5,SQUAD:6}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2ScalarCurve=t.Tw2ScalarKey=void 0;var n=function(){function e(e,t){for(var r=0;r=n.time)switch(this.extrapolation){case t.Extrapolation.NONE:return this.value;case t.Extrapolation.CONSTANT:return n.value;case t.Extrapolation.GRADIENT:return n.value+(e-n.time)*n.right;default:e%=n.time}else if(e<0||e=i.time||ethis.length){if(!this.cycle)return this.reversed?this.startValue:this.endValue;e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null);var t=this.keys[0],r=this.keys[this.keys.length-1];if(e<=t.time)return this.Interpolate(e,null,t);if(e>=r.time)return this.Interpolate(e,r,null);for(var n=0;n+1e));++n);return this.Interpolate(e,t,r)}},{key:"Interpolate",value:function(e,r,n){var i=this.startValue,a=this.endValue,o=this.interpolation,s=this.length;switch(null!==r&&(o=r.interpolation,e-=r.time),o){case t.Interpolation.LINEAR:return r&&n?(i=r.value,a=n.value,s=n.time-r.time):n?(a=n.value,s=n.time):r&&(i=r.value,s=this.length-r.time),i+e/s*(a-i);case t.Interpolation.HERMITE:var u=this.startTangent,l=this.endTangent;r&&n?(i=r.value,u=r.rightTangent,a=n.value,l=n.leftTangent,s=n.time-r.time):n?(a=n.value,l=n.leftTangent,s=n.time):r&&(i=r.value,u=r.rightTangent,s=this.length-r.time);var c=e/s,f=c*c,h=f*c,p=-2*h+3*f,d=h-f;return i*(1-p)+a*p+u*(c+d-f)+l*d;default:return this.startValue}}}]),t}();l.inputDimension=1,l.outputDimension=1,l.valueProperty="currentValue",l.curveType=i.Tw2Curve.Type.CURVE2,l.Key=u,l.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SineCurve=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?i.vec2.copy(t,this.startValue):i.vec2.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec2.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a;case t.Interpolation.HERMITE:var c=this.startTangent,f=this.endTangent;r&&n?(o=r.value,c=r.rightTangent,s=n.value,f=n.leftTangent,l=n.time-r.time):n?(s=n.value,f=n.leftTangent,l=n.time):r&&(o=r.value,c=r.rightTangent,l=this.length-r.time);var h=e/l,p=h*h,d=p*h,v=-2*d+3*p,m=1-v,y=d-p,b=h+y-p;return a[0]=o[0]*m+s[0]*v+c[0]*b+f[0]*y,a[1]=o[1]*m+s[1]*v+c[1]*b+f[1]*y,a;default:return a}}}]),t}();c.inputDimension=2,c.outputDimension=2,c.valueProperty="value",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector3Curve=t.Tw2Vector3Key=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?i.vec3.copy(t,this.startValue):i.vec3.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec3.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a[2]=o[2]+(s[2]-o[2])*(e/l),a;case t.Interpolation.HERMITE:var c=this.startTangent,f=this.endTangent;r&&n?(o=r.value,c=r.rightTangent,s=n.value,f=n.leftTangent,l=n.time-r.time):n?(s=n.value,f=n.leftTangent,l=n.time):r&&(o=r.value,c=r.rightTangent,l=this.length-r.time);var h=e/l,p=h*h,d=p*h,v=-2*d+3*p,m=1-v,y=d-p,b=h+y-p;return a[0]=o[0]*m+s[0]*v+c[0]*b+f[0]*y,a[1]=o[1]*m+s[1]*v+c[1]*b+f[1]*y,a[2]=o[2]*m+s[2]*v+c[2]*b+f[2]*y,a;default:return a}}}]),t}();c.inputDimension=3,c.outputDimension=3,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VectorCurve=t.Tw2VectorKey=void 0;var n=function(){function e(e,t){for(var r=0;r=a.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.vec3.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.vec3.copy(r,a.value);case t.Extrapolation.GRADIENT:return i.vec3.scaleAndAdd(r,a.value,a.right,e-a.time);default:e%=a.time}else if(e<0||e=o.time||e=0&&this._UpdateValue(e))}}function a(){this._id=n.util.generateID(),this.translation=n.vec3.create(),this.rotation=n.quat.create(),this.rotation[3]=1,this.scale=n.vec3.create();var e=null,t=null,r=null,i=n.mat4.create();this._TracksReady=function(){return e||t||r},this._ApplyTracks=function(n,i){for(var a=0;athis.duration||e<0||(i.curve.evaluate(this.positionCurve,e,this.translation,this.cycle,this.duration),i.curve.evaluate(this.orientationCurve,e,this.rotation,this.cycle,this.duration),i.quat.normalize(this.rotation,this.rotation),i.curve.evaluate(this.scaleCurve,e,this.scaleShear,this.cycle,this.duration),i.mat4.getScaling(this.scale,this.scaleCurve))))}},{key:"FindTracks",value:function(){for(var e=null,t=0;t=0&&(this.length=this.animationEngine.GetLength(this.xIndex)),this.yIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.yIndex))),this.zIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.zIndex))))}}]),t}();o.outputDimension=3,o.valueProperty="eulerValue",o.curveType=a.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaScalarCurve=void 0;var n=function(){function e(e,t){for(var r=0;r=0&&(this.length=this.animationEngine.GetLength(this.index))}}]),t}();a.outputDimension=1,a.valueProperty="value",a.curveType=i.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaVector3Curve=void 0;var n=function(){function e(e,t){for(var r=0;r=0&&(this.length=this.animationEngine.GetLength(this.xIndex)),this.yIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.yIndex))),this.zIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.zIndex))))}}]),t}();o.outputDimension=3,o.valueProperty="value",o.curveType=a.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaAnimationEngine=void 0;var n=function(){function e(e,t){for(var r=0;ri[e.AnimCurveFields.END_TIME]?i[e.AnimCurveFields.POST_INFINITY]===e.INFINITY?i[e.AnimCurveFields.END_VALUE]:this._EvaluateInfinities(i,o,a,r,!1):this._EvaluateImpl(i,o,a,r)}},{key:"_EvaluateImpl",value:function(t,r,n,i){var a=!1,o=null,s=null,u=void 0;if(this._evalCache[this._currentCurveIndex]>=0)if(s=n+this._evalCache[this._currentCurveIndex],this._evalCache[this._currentCurveIndex]r[s][e.AnimSegment.TIME]){if(i===r[o=n+this._evalCache[this._currentCurveIndex]+1][e.AnimSegment.TIME])return this._evalCache[this._currentCurveIndex]++,r[o][e.AnimSegment.VALUE];i0&&ir[l][e.AnimSegment.TIME])u=this._evalCache[this._currentCurveIndex],a=!0;else if(i===r[l][e.AnimSegment.TIME])return this._evalCache[this._currentCurveIndex]--,r[l][e.AnimSegment.VALUE]}if(!a){var c=this._Find(t,i,r,n);if(u=c[1],c[0]||0===u)return u===t[e.AnimCurveFields.NUM_SEGMENTS]?(u--,this._evalCache[this._currentCurveIndex]=u,t[e.AnimCurveFields.END_VALUE]):(this._evalCache[this._currentCurveIndex]=u,r[n+u][e.AnimSegment.VALUE]);if(u===t[e.AnimCurveFields.NUM_SEGMENTS]+1)return this._evalCache[this._currentCurveIndex]=0,t[e.AnimCurveFields.END_VALUE]}if(this._evalCache[this._currentCurveIndex]!==u-1&&(this._evalCache[this._currentCurveIndex]=u-1,s=n+this._evalCache[this._currentCurveIndex],null===o&&(o=n+u)),t[e.AnimCurveFields.IS_WEIGHTED]){var f=r[s];if(f[e.BezierSegment.IS_STEP])return f[e.BezierSegment.VALUE];if(f[e.BezierSegment.IS_STEP_NEXT])return null===o?t[e.AnimCurveFields.END_VALUE]:r[o][e.BezierSegment.VALUE];var h=t[e.AnimCurveFields.END_TIME];return this._evalCache[this._currentCurveIndex]+10){s=0,u=a-1;do{if(r<(c=(o=s+u>>1)c))return[!0,l=o];s=o+1}}while(s<=u);l=s}return[!1,l]}},{key:"GetNumberOfCurves",value:function(){return this.curves.length}},{key:"GetLength",value:function(t){if(t<0||t>=this.curves.length)return 0;var r=this.curves[t],n=void 0;return n=r[e.AnimCurveFields.IS_WEIGHTED]?this.bezierSegments[r[e.AnimCurveFields.SEGMENT_OFFSET]]:this.hermiteSegments[r[e.AnimCurveFields.SEGMENT_OFFSET]],r[e.AnimCurveFields.END_TIME]-n[e.AnimSegment.TIME]}}]),e}();a.AnimCurveFields={NUM_SEGMENTS:0,SEGMENT_OFFSET:1,END_TIME:2,END_VALUE:3,IN_TANGENT:4,OUT_TANGENT:5,PRE_INFINITY:6,POST_INFINITY:7,IS_WEIGHTED:8},a.AnimSegment={TIME:0,VALUE:1},a.HermiteSegment={TIME:0,VALUE:1,COEFF:2,IS_STEP:3,IS_STEP_NEXT:4},a.BezierSegment={TIME:0,VALUE:1,COEFF:2,POLYY:3,IS_STEP:4,IS_STEP_NEXT:5,IS_LINEAR:6},a.INFINITY=0},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(59);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(164);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(61);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(64);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(182);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(183);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveChildBillboard=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t0&&void 0!==arguments[0]?arguments[0]:[];this.mesh&&this.mesh.GetResources(e);for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return a.util.perArrayChild(this.opaqueEffects,"GetResources",e),a.util.perArrayChild(this.decalEffects,"GetResources",e),a.util.perArrayChild(this.transparentEffects,"GetResources",e),a.util.perArrayChild(this.additiveEffects,"GetResources",e),a.util.perArrayChild(this.distortionEffects,"GetResources",e),e}},{key:"Update",value:function(e){this.update&&this.curveSet&&this.curveSet.Update(e)}},{key:"GetBatches",value:function(e,t,r,n){if(this.display&&n&&n.IsGood())for(var a=this.GetEffects(e),o=0;o0&&void 0!==arguments[0]?arguments[0]:[];return this.source&&this.source.GetResources&&this.source.GetResources(e),this.dest&&this.dest.GetResources&&this.dest.GetResources(e),this.sourceObject&&this.sourceObject.GetResources&&this.sourceObject.GetResources(e),this.destObject&&this.destObject.GetResources&&this.destObject.GetResources(e),this.stretchObject&&this.stretchObject.GetResources&&this.stretchObject.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(){if(this.display){var t=e.global,r=i.vec3.subtract(t.vec3_0,this._destinationPosition,this._sourcePosition),n=i.mat4.identity(t.mat4_0),a=i.vec3.set(t.vec3_1,0,0,0),o=i.vec3.set(t.vec3_2,0,0,0),s=i.mat4.identity(t.mat4_1),u=i.vec3.length(r);i.vec3.normalize(r,r),this._useTransformsForStretch?(i.mat4.rotateX(n,n,-Math.PI/2),i.mat4.multiply(n,this._sourceTransform,n)):(Math.abs(r[1])>.9?o[2]=1:o[1]=1,i.vec3.cross(a,o,r),i.vec3.normalize(a,a),i.vec3.cross(o,r,a),n[0]=a[0],n[1]=a[1],n[2]=a[2],n[4]=-r[0],n[5]=-r[1],n[6]=-r[2],n[8]=o[0],n[9]=o[1],n[10]=o[2]),this.destObject&&this._displayDestObject&&(i.mat4.setTranslation(n,this._destinationPosition),this.destObject.UpdateViewDependentData(n)),this.sourceObject&&this._displaySourceObject&&(this._useTransformsForStretch?(i.mat4.identity(n),i.mat4.rotateX(n,n,-Math.PI/2),i.mat4.multiply(n,this._sourceTransform,n)):i.mat4.setTranslation(n,this._sourcePosition),this.sourceObject.UpdateViewDependentData(n)),this.stretchObject&&(this._useTransformsForStretch?(i.mat4.identity(n),i.mat4.scale(n,n,[1,1,u]),i.mat4.multiply(n,this._sourceTransform,n)):(n[0]=a[0],n[1]=a[1],n[2]=a[2],n[4]=o[0],n[5]=o[1],n[6]=o[2],n[8]=-r[0],n[9]=-r[1],n[10]=-r[2],this._isNegZForward&&(u=-u),i.mat4.scale(s,s,[1,1,u]),i.mat4.multiply(n,n,s)),this.stretchObject.UpdateViewDependentData(n))}}},{key:"Update",value:function(t){for(var r=0;r0&&(this._perMuzzleData[0].constantDelay=this.firingDelay1),this._perMuzzleData.length>1&&(this._perMuzzleData[1].constantDelay=this.firingDelay2),this._perMuzzleData.length>2&&(this._perMuzzleData[2].constantDelay=this.firingDelay3),this._perMuzzleData.length>3&&(this._perMuzzleData[3].constantDelay=this.firingDelay4),this._perMuzzleData.length>4&&(this._perMuzzleData[4].constantDelay=this.firingDelay5),this._perMuzzleData.length>5&&(this._perMuzzleData[5].constantDelay=this.firingDelay6),this._perMuzzleData.length>6&&(this._perMuzzleData[6].constantDelay=this.firingDelay7),this._perMuzzleData.length>7&&(this._perMuzzleData[7].constantDelay=this.firingDelay8)}},{key:"GetCurveDuration",value:function(){for(var e=0,t=0;t1&&void 0!==arguments[1]?arguments[1]:-1,r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t=this._perMuzzleData[n].elapsedTime||this.isLoopFiring)&&this.stretch[n].GetBatches(e,t,r)}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveStarField=void 0;var n=r(0);t.EveStarField=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._id=n.util.generateID(),this.name="",this.display=!0,this.effect=null,this.maxDist=0,this.maxFlashRate=0,this.minFlashIntensity=0,this.minFlashRate=0,this.seed=20}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveEffectRoot=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t0&&void 0!==arguments[0]?arguments[0]:[];this.mesh&&this.mesh.GetResources(e),this.spriteSet&&this.spriteSet.GetResources(e)}},{key:"UpdateViewDependentData",value:function(){this.display&&this.state!==t.State.DEAD&&(i.mat4.transpose(this._perObjectData.perObjectVSData.Get("WorldMat"),this.transform),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("WorldMatLast"),this.transform))}},{key:"Update",value:function(e,r,n){if(this.state===t.State.IN_FLIGHT){var a=t.global,o=i.mat4.getTranslation(a.vec3_0,this.transform),s=a.vec3_1,u=a.vec3_2,l=a.vec3_3;this.time+=e,this.time>this.durationEjectPhase?(i.vec3.subtract(o,this.velocity,r),i.vec3.lerp(o,o,r,1-Math.exp(.9999*-e)),i.mat4.setTranslation(this.transform,o),i.vec3.subtract(s,n,o),i.vec3.length(s)t.length)this.warheads.splice(t.length);else for(;this.warheads.length0&&void 0!==arguments[0]?arguments[0]:[],t=0;t.1&&(i.vec3.normalize(t,t),i.vec3.scale(t,t,Math.min(e*this.speed,r)),i.vec3.add(this.position,this.position,t));for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:[];return this.highDetail&&this.highDetail.GetResources(e),this.effectHeight&&this.effectHeight.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(e){this.highDetail.UpdateViewDependentData(e),this.zOnlyModel&&(this.zOnlyModel.translation=this.highDetail.translation,this.zOnlyModel.scaling=this.highDetail.scaling,this.zOnlyModel.UpdateViewDependentData(e))}},{key:"Update",value:function(e){this.highDetail.Update(e)}},{key:"GetBatches",value:function(e,t){if(this.display&&this.heightDirty&&this.watchedResources.length&&""!==this.heightMapResPath1){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],r=arguments[1];i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"GetResources",this).call(this,e,r);for(var n=0;n1)for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t.visible,e.visible,["glow","symHalo","halo","trail"]),i.util.assignIfExists(t,e,["name","display","seed","wavePhase","transform","locatorName","updateFromLocator","atlas0","atlas1"]),t}}]),t}(),h=t.EveBoosterSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.visible={},e.visible.glows=!0,e.visible.symHalos=!0,e.visible.halos=!0,e.visible.trails=!0,e.effect=null,e.glows=null,e.alwaysOn=!0,e.maxVel=250,e.glowDistance=2.5,e.glowScale=1,e.glowColor=i.vec4.create(),e.warpGlowColor=i.vec4.create(),e.haloDistance=3.01,e.haloScaleX=1,e.haloScaleY=1,e.haloColor=i.vec4.create(),e.warpHaloColor=i.vec4.create(),e.symHaloDistance=3,e.symHaloScale=1,e.trailColor=i.vec4.create(),e.trailSize=i.vec4.create(),e._parentTransform=i.mat4.create(),e._positions=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,i.device.gl.FLOAT,3,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,2,12)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,20)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,4,36)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,i.device.gl.FLOAT,4,52)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,i.device.gl.FLOAT,4,68)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,i.device.gl.FLOAT,4,84)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,6,i.device.gl.FLOAT,1,100)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,7,i.device.gl.FLOAT,2,104)),e._decl.RebuildHash(),e._perObjectData=new a.Tw2PerObjectData,e._perObjectData.perObjectVSData=new a.Tw2RawData,e._perObjectData.perObjectVSData.Declare("WorldMat",16),e._perObjectData.perObjectVSData.Declare("Shipdata",4),e._perObjectData.perObjectVSData.Create(),e._locatorRebuildPending=!0,e}return l(t,o.EveObjectSet),n(t,[{key:"FindItemByLocatorName",value:function(e){for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),this.glows&&this.glows.effect.GetResources(e),e}},{key:"Update",value:function(e,t){i.mat4.copy(this._parentTransform,t),this._rebuildPending&&this.Rebuild(),this.glows&&this.glows.Update(e)}},{key:"Unload",value:function(){this._positions&&(i.device.gl.deleteBuffer(this._positions),this._positions=null),this.glows&&this.glows.Unload()}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this);var e=this._visibleItems.length;if(this._rebuildPending=!1,e){for(var r=i.device,n=t._box,a=new Float32Array(e*n.length*6*28),o=[0,3,1,3,2,1],s=0,u=0;u0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","type","position1","color1","position2","color2","intermediatePosition","width","multiColor","multiColorBorder","overlayColor","animationSpeed","animationScale","numOfSegments"]),t}}]),t}();c.Type={INVALID:0,STRAIGHT:1,SPHERED:2,CURVED:3},c.DEFAULT_CURVED_SEGMENTS=20,c.DEFAULT_SPHERED_SEGEMENTS=20;var f=t.EveCurveLineSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.lineEffect=a.Tw2Effect.create({effectFilePath:"res:/Graphics/Effect/Managed/Space/SpecialFX/Lines3D.fx",textures:{TexMap:"res:/texture/global/white.dds.0.png",OverlayTexMap:"res:/texture/global/white.dds.0.png"}}),e.pickEffect=null,e.lineWidthFactor=1,e.additive=!1,e.pickable=!0,e.depthOffset=0,e.translation=i.vec3.create(),e.rotation=i.quat.create(),e.scaling=i.vec3.fromValues(1,1,1),e.transform=i.mat4.create(),e.parentTransform=i.mat4.create(),e._vertexSize=26,e._vbSize=0,e._vb=null,e._perObjectData=new a.Tw2PerObjectData,e._perObjectData.perObjectVSData=new a.Tw2RawData,e._perObjectData.perObjectVSData.Declare("WorldMat",16),e._perObjectData.perObjectVSData.Create(),e._perObjectData.perObjectPSData=new a.Tw2RawData,e._perObjectData.perObjectPSData.Declare("WorldMat",16),e._perObjectData.perObjectPSData.Create(),e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,i.device.gl.FLOAT,3,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,4,12)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,28)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,3,44)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,4,56)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,1,i.device.gl.FLOAT,4,72)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,2,i.device.gl.FLOAT,4,88)),e._decl.stride=4*e._vertexSize,e._decl.RebuildHash(),t.init(),e}return l(t,o.EveObjectSet),n(t,[{key:"Initialize",value:function(){this.OnValueChanged(),this.Rebuild()}},{key:"AddStraightLine",value:function(e,t,r,n,i){return this.CreateItem({type:c.Type.STRAIGHT,position1:e,position2:t,color1:n,color2:i,width:r})}},{key:"AddCurvedLineCrt",value:function(e,t,r,n,i,a){return this.CreateItem({type:c.Type.CURVED,position1:e,position2:t,intermediatePosition:r,color1:i,color2:a,width:n,numOfSegments:c.DEFAULT_CURVED_SEGMENTS})}},{key:"AddCurvedLineSph",value:function(e,r,n,a,o,s,u){var l=t.global;return this.CreateItem({type:c.Type.CURVED,position1:i.vec3.fromSpherical(l.vec3_0,e,n),position2:i.vec3.fromSpherical(l.vec3_1,r,n),intermediatePosition:i.vec3.fromSpherical(l.vec3_2,a,n),color1:s,color2:u,width:o,numOfSegments:c.DEFAULT_CURVED_SEGMENTS})}},{key:"AddSpheredLineCrt",value:function(e,t,r,n,i,a){return this.CreateItem({type:c.Type.SPHERED,position1:e,position2:t,intermediatePosition:r,color1:i,color2:a,width:n,numOfSegments:c.DEFAULT_SPHERED_SEGEMENTS})}},{key:"AddSpheredLineSph",value:function(e,r,n,a,o,s,u){var l=t.global;return this.CreateItem({type:c.Type.SPHERED,position1:i.vec3.fromSpherical(l.vec3_0,e,n),position2:i.vec3.fromSpherical(l.vec3_1,r,n),intermediatePosition:i.vec3.fromSpherical(l.vec3_2,a,n),color1:s,color2:u,width:o,numOfSegments:c.DEFAULT_SPHERED_SEGEMENTS})}},{key:"OnValueChanged",value:function(){i.mat4.fromRotationTranslationScale(this.transform,this.rotation,this.translation,this.scaling),this._rebuildPending=!0}},{key:"UpdateViewDependentData",value:function(e){i.mat4.copy(this.parentTransform,e)}},{key:"Update",value:function(){this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){this._vb&&(i.device.gl.deleteBuffer(this._vb),this._vb=null)}},{key:"Rebuild",value:function(){t.RebuildItems(this),this._vb=null,this._vbSize=this.lineCount,this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=t.global,n=new Float32Array(6*this._vbSize*this._vertexSize),a=r.vec3_0,o=r.vec3_1,s=r.vec3_2,u=r.vec3_3,l=r.vec3_4,f=r.vec3_5,h=r.vec3_6,p=r.mat4_0,d=r.vec3_7,v=r.vec3_8,m=r.vec3_9,y=r.vec3_10,b=r.vec4_0,_=r.vec4_1,g=0,E=void 0,T=0;T0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","boneIndex","groupIndex","maskAtlasID","position","scaling","rotation","transform","color","layer1Transform","layer2Transform","layer1Scroll","layer2Scroll"]),t}}]),t}();(t.EvePlaneSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.effect=null,e.hideOnLowQuality=!1,e._time=0,e._vertexBuffer=null,e._indexBuffer=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,4,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,16)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,4,32)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,4,48)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,i.device.gl.FLOAT,4,64)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,i.device.gl.FLOAT,4,80)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,i.device.gl.FLOAT,4,96)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,6,i.device.gl.FLOAT,4,112)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,7,i.device.gl.FLOAT,3,128)),e._decl.RebuildHash(),e}return l(t,o.EveObjectSet),n(t,[{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),e}},{key:"Update",value:function(e){this._time+=e,this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){this._vertexBuffer&&(i.device.gl.deleteBuffer(this._vertexBuffer),this._vertexBuffer=null),this._indexBuffer&&(i.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"Rebuild",value:function(){this.Unload(),t.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=t.global.mat4_0,n=new Float32Array(4*e*35),a=0;a0&&void 0!==arguments[0]?arguments[0]:[];return this.parentGeometry&&!e.includes(this.parentGeometry)&&e.push(this.parentGeometry),this.decalEffect&&this.decalEffect.GetResources(e),this.pickEffect&&this.pickEffect.GetResources(e),e}},{key:"Unload",value:function(){this._indexBuffer&&(i.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"GetBatches",value:function(e,t,r,n){var o=void 0;switch(e){case i.device.RM_DECAL:o=this.decalEffect;break;case i.device.RM_PICKABLE:o=this.pickable?this.pickEffect:null}if(this.display&&o&&o.IsGood()&&this.indexBuffer.length&&this.parentGeometry&&this.parentGeometry.IsGood()){var s=new a.Tw2ForwardingRenderBatch;if(this._perObjectData.perObjectVSData.Set("worldMatrix",r.perObjectVSData.Get("WorldMat")),this.parentBoneIndex>=0){var u=r.perObjectVSData.Get("JointMat"),l=12*this.parentBoneIndex;if(u[l]||u[l+4]||u[l+8]){var c=this._perObjectData.perObjectVSData.Get("parentBoneMatrix");c[0]=u[l],c[1]=u[l+4],c[2]=u[l+8],c[3]=0,c[4]=u[l+1],c[5]=u[l+5],c[6]=u[l+9],c[7]=0,c[8]=u[l+2],c[9]=u[l+6],c[10]=u[l+10],c[11]=0,c[12]=u[l+3],c[13]=u[l+7],c[14]=u[l+11],c[15]=1,i.mat4.transpose(c,c)}}i.mat4.invert(this._perObjectData.perObjectVSData.Get("invWorldMatrix"),this._perObjectData.perObjectVSData.Get("worldMatrix")),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("decalMatrix"),this.decalMatrix),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("invDecalMatrix"),this.invDecalMatrix),this._perObjectData.perObjectPSData.Get("displayData")[0]=n||0,this._perObjectData.perObjectPSData.Set("shipData",r.perObjectPSData.data),s.perObjectData=this._perObjectData,s.geometryProvider=this,s.renderMode=e,s.effect=o,t.Commit(s)}}},{key:"Render",value:function(e,t){var r=this.parentGeometry.meshes[0].indexes,n=this.parentGeometry.meshes[0].areas[0].start,a=this.parentGeometry.meshes[0].areas[0].count,o=this.parentGeometry.meshes[0].indexType;i.store.SetVariableValue("u_DecalMatrix",this.decalMatrix),i.store.SetVariableValue("u_InvDecalMatrix",this.invDecalMatrix),this.parentGeometry.meshes[0].indexes=this._indexBuffer,this.parentGeometry.meshes[0].areas[0].start=0,this.parentGeometry.meshes[0].areas[0].count=this.indexBuffer.length,this.parentGeometry.meshes[0].indexType=i.device.gl.UNSIGNED_SHORT,this.parentGeometry.RenderAreas(0,0,1,e.effect,t),this.parentGeometry.meshes[0].indexes=r,this.parentGeometry.meshes[0].areas[0].start=n,this.parentGeometry.meshes[0].areas[0].count=a,this.parentGeometry.meshes[0].indexType=o}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveSpotlightSet=t.EveSpotlightSetItem=t.EveSpotlightSetBatch=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","boosterGainInfluence","boneIndex","groupIndex","coneIntensity","spriteIntensity","flareIntensity","transform","coneColor","spriteColor","flareColor","spriteScale"]),t}}]),t}();(t.EveSpotlightSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.coneEffect=null,e.glowEffect=null,e._coneVertexBuffer=null,e._spriteVertexBuffer=null,e._indexBuffer=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,4,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,4,16)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,32)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,4,48)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,i.device.gl.FLOAT,3,64)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,i.device.gl.FLOAT,3,76)),e._decl.RebuildHash(),e}return l(t,o.EveObjectSet),n(t,[{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.coneEffect&&this.coneEffect.GetResources(e),this.glowEffect&&this.glowEffect.GetResources(e),e}},{key:"Unload",value:function(){this._coneVertexBuffer&&(i.device.gl.deleteBuffer(this._coneVertexBuffer),this._coneVertexBuffer=null),this._spriteVertexBuffer&&(i.device.gl.deleteBuffer(this._spriteVertexBuffer),this._spriteVertexBuffer=null),this._indexBuffer&&(i.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"Rebuild",value:function(){this.Unload(),t.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=i.device,n=[1,0,2,3],a=new Float32Array(22*(4*e*4)),o=0;o0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","blinkRate","blinkPhase","minScale","maxScale","falloff","boneIndex","groupIndex","position","color","warpColor"]),t}}]),t}();(t.EveSpriteSet=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];s(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.effect=null,n.useQuads=null,n.isSkinned=null,n._time=0,n._vertexBuffer=null,n._indexBuffer=null,n._instanceBuffer=null,n._decl=n._decl=new a.Tw2VertexDeclaration,n._vdecl=new a.Tw2VertexDeclaration,n._vdecl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,i.device.gl.FLOAT,1,0)),n._vdecl.RebuildHash(),n.UseQuads(e,r),n}return l(t,o.EveObjectSet),n(t,[{key:"UseQuads",value:function(e,t){if(this.useQuads!==e){this.useQuads=e,this.isSkinned=t;var r=i.device.gl;this._decl.elements.splice(0,this._decl.elements.length),e?(this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,r.FLOAT,3,0)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,r.FLOAT,4,12)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,r.FLOAT,2,28)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,r.FLOAT,4,36)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,1,r.FLOAT,4,52))):(this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,r.FLOAT,2,0)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,r.FLOAT,3,8)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,r.FLOAT,3,20)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,r.FLOAT,1,32)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,r.FLOAT,1,36)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,r.FLOAT,1,40)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,r.FLOAT,1,44)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,r.FLOAT,1,48))),this._decl.RebuildHash(),this._rebuildPending=!0}}},{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),e}},{key:"Update",value:function(e){this._time+=e,this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){var e=i.device.gl;this._vertexBuffer&&(e.deleteBuffer(this._vertexBuffer),this._vertexBuffer=null),this._indexBuffer&&(e.deleteBuffer(this._indexBuffer),this._indexBuffer=null),this._instanceBuffer&&(e.deleteBuffer(this._instanceBuffer),this._instanceBuffer=null)}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){var t=i.device.gl;if(this.useQuads)return this._vertexBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._vertexBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,1,2,2,3,0]),t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),void(this._instanceBuffer=t.createBuffer());for(var r=new Float32Array(4*e*13),n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","locatorName","updateFromLocator","position","rotation","bone","canFireWhenHidden"]),t.UpdateTransforms(),t}}]),t}(),f=t.EveTurretSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.visible={},e.visible.turrets=!0,e.visible.firingEffects=!0,e.activeAnimation=new a.Tw2AnimationController,e.inactiveAnimation=new a.Tw2AnimationController,e.geometryResPath="",e.geometryResource=null,e.turretEffect=null,e.firingEffectResPath="",e.firingEffect=null,e.fireCallback=null,e.fireCallbackPending=!1,e.state=t.State.IDLE,e.bottomClipHeight=0,e.locatorName="",e.sysBoneHeight=0,e.hasCyclingFiringPos=!1,e.targetPosition=i.vec3.create(),e.parentMatrix=i.mat4.create(),e.boundingSphere=i.quat.create(),e._activeTurret=-1,e._recheckTimeLeft=0,e._currentCyclingFiresPos=0,e._perObjectDataActive=new a.Tw2PerObjectData,e._perObjectDataActive.perObjectVSData=new a.Tw2RawData,e._perObjectDataActive.perObjectVSData.Declare("baseCutoffData",4),e._perObjectDataActive.perObjectVSData.Declare("turretSetData",4),e._perObjectDataActive.perObjectVSData.Declare("shipMatrix",16),e._perObjectDataActive.perObjectVSData.Declare("turretTranslation",96),e._perObjectDataActive.perObjectVSData.Declare("turretRotation",96),e._perObjectDataActive.perObjectVSData.Declare("turretPoseTransAndRot",576),e._perObjectDataActive.perObjectVSData.Create(),e._perObjectDataInactive=new a.Tw2PerObjectData,e._perObjectDataInactive.perObjectVSData=new a.Tw2RawData,e._perObjectDataInactive.perObjectVSData.Declare("baseCutoffData",4),e._perObjectDataInactive.perObjectVSData.Declare("turretSetData",4),e._perObjectDataInactive.perObjectVSData.Declare("shipMatrix",16),e._perObjectDataInactive.perObjectVSData.Declare("turretTranslation",96),e._perObjectDataInactive.perObjectVSData.Declare("turretRotation",96),e._perObjectDataInactive.perObjectVSData.Declare("turretPoseTransAndRot",576),e._perObjectDataInactive.perObjectVSData.Create(),e._locatorRebuildPending=!0,e}return l(t,o.EveObjectSet),n(t,[{key:"Initialize",value:function(){var e=this;this.turretEffect&&""!==this.geometryResPath&&(this.geometryResource=i.resMan.GetResource(this.geometryResPath),this.activeAnimation.SetGeometryResource(this.geometryResource),this.inactiveAnimation.SetGeometryResource(this.geometryResource),this.geometryResource&&this.geometryResource.RegisterNotification(this)),""!==this.firingEffectResPath&&i.resMan.GetObject(this.firingEffectResPath,function(t){return e.firingEffect=t}),this.Rebuild()}},{key:"InitializeFiringEffect",value:function(){if(this.firingEffect&&this.geometryResource&&this.geometryResource.models.length)for(var e=this.geometryResource.models[0],r=0;rr&&(e=this.items.indexOf(l),r=c)}}return e}},{key:"EnterStateDeactive",value:function(){var e=this;this.state!==t.State.INACTIVE&&this.state!==t.State.PACKING&&(this.turretEffect?(this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.activeAnimation.PlayAnimation("Pack",!1,function(){e.state=t.State.INACTIVE,e.activeAnimation.PlayAnimation("Inactive",!0)}),this.inactiveAnimation.PlayAnimation("Pack",!1,function(){e.state=t.State.INACTIVE,e.inactiveAnimation.PlayAnimation("Inactive",!0)}),this.state=t.State.PACKING):this.state=t.State.INACTIVE,this._activeTurret=-1,this.firingEffect&&this.firingEffect.StopFiring())}},{key:"EnterStateIdle",value:function(){var e=this;this.state!==t.State.IDLE&&this.state!==t.State.UNPACKING&&(this.turretEffect?(this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.state===t.State.FIRING?(this.activeAnimation.PlayAnimation("Active",!0),this.inactiveAnimation.PlayAnimation("Active",!0)):(this.activeAnimation.PlayAnimation("Deploy",!1,function(){e.state=t.State.IDLE,e.activeAnimation.PlayAnimation("Active",!0)}),this.inactiveAnimation.PlayAnimation("Deploy",!1,function(){e.state=t.State.IDLE,e.inactiveAnimation.PlayAnimation("Active",!0)})),this.state=t.State.UNPACKING):this.state=t.State.IDLE,this._activeTurret=-1,this.firingEffect&&this.firingEffect.StopFiring())}},{key:"EnterStateFiring",value:function(){var e=this;if(!this.turretEffect||this.state===t.State.FIRING)return t.DoStartFiring(this),void(this.turretEffect&&this.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)}));this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.state===t.State.INACTIVE?(this.activeAnimation.PlayAnimation("Deploy",!1,function(){t.DoStartFiring(e),e.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)})}),this.inactiveAnimation.PlayAnimation("Deploy",!1,function(){e.inactiveAnimation.PlayAnimation("Active",!0)}),this.state=t.State.UNPACKING):(t.DoStartFiring(this),this.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)}),this.inactiveAnimation.PlayAnimation("Active",!0))}},{key:"RebuildCachedData",value:function(){for(var e=new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,2),r=this.geometryResource.meshes,n=this.activeAnimation,o=this.inactiveAnimation,s=0;s0&&void 0!==arguments[0]?arguments[0]:[];return this.geometryResource&&!e.includes(this.geometryResource)&&e.push(this.geometryResource),this.turretEffect&&this.turretEffect.GetResources(e),this.firingEffect&&this.firingEffect.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(){this.firingEffect&&this.firingEffect.UpdateViewDependentData()}},{key:"Update",value:function(e,r){if(this._rebuildPending&&this.Rebuild(),this.turretEffect&&(this.activeAnimation.Update(e),this.inactiveAnimation.Update(e)),i.mat4.copy(this.parentMatrix,r),this.firingEffect&&this._visibleItems.length){if(-1!==this._activeTurret){this.firingEffect.isLoopFiring&&this.state===t.State.FIRING&&(this._recheckTimeLeft-=e,this._recheckTimeLeft<=0&&t.DoStartFiring(this));var n=this.items[this._activeTurret];if(this.activeAnimation.models.length)for(var a=this.activeAnimation.models[0].bonesByName,o=0;o0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1],r=0;r2&&void 0!==arguments[2]?arguments[2]:this._batches,n=0;n=0&&(u=e.substr(0,s+1)+o+"/"+e.substr(s+1)),(s=u.lastIndexOf("_"))>=0){u=u.substr(0,s)+"_"+o+u.substr(s);var l=r(n,"textureOverrides",{});if(t in l&&i.name in l[t])return u}}return e}function f(e,t){var r=l(t),n=(e="/"+e).lastIndexOf("/");return e.substr(0,n+1)+r+e.substr(n+1)}function h(e,t){for(var r=0;r=0&&s=0?r||T:t||(r||T);case"not_overridable":case"half_overridable_2":return r||T}return T}function w(t,r,a){var o=e.faction[r],s=e.faction[a],u=null;o&&o.areas&&"hull"in o.areas&&(u=o.areas.hull);var l=null;if(s&&s.areas&&"hull"in s.areas&&(l=s.areas.hull),(u||l)&&t.turretEffect){var c=t.turretEffect.parameters;for(var f in c)if(c.hasOwnProperty(f)){if(c[f].constructor.prototype!==i.Tw2Vector4Parameter.prototype)continue;var h=null,p=null;u&&(h=E(f,o,u)),l&&(p=E(f,o,u)),n.vec4.copy(c[f].value,O(f,h,p,t.turretEffect.name))}t.turretEffect.BindParameters()}}function S(t){if("all"!==t){var r={};for(var n in e[t])e[t].hasOwnProperty(n)&&(r[n]=e[t][n].description||"");return r}return e}this.SetupTurretMaterial=function(t,r,n,i){null===e?this.LoadData(function(){w(t,r,n),i&&i()}):(w(t,r,n),i&&i())},this.GetHullNames=function(e){this.LoadData(function(){e(S("hull"))})},this.GetFactionNames=function(e){this.LoadData(function(){e(S("faction"))})},this.GetRaceNames=function(e){this.LoadData(function(){e(S("race"))})},this.GetSofData=function(e){this.LoadData(function(){e(S("all"))})}};var n=r(0),i=r(1),a=r(58),o=r(64),s=r(59),u=r(61)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(185);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(189);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(196);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(200);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(201);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(14);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(186);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(187);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(188);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2StaticEmitter=void 0;var n=function(){function e(e,t){for(var r=0;rthis.geometryIndex&&this.geometryResource.meshes[this.geometryIndex].bufferData){this._spawned=!0;for(var e=this.geometryResource.meshes[this.geometryIndex],t=this.particleSystem.elements,r=new Array(t.length),n=0;n=this.maxParticleCount?null:this.aliveCount++}},{key:"EndSpawnParticle",value:function(){this.bufferDirty=!0}},{key:"Update",value:function(t){if(t=Math.min(t,.1),this.applyAging&&this.HasElement(o.Tw2ParticleElementDeclaration.Type.LIFETIME)){for(var r=this.GetElement(o.Tw2ParticleElementDeclaration.Type.LIFETIME),n=this.emitParticleOnDeathEmitter?this.GetElement(o.Tw2ParticleElementDeclaration.Type.POSITION):null,a=this.emitParticleOnDeathEmitter?this.GetElement(o.Tw2ParticleElementDeclaration.Type.VELOCITY):null,s=0;s1){if(this.emitParticleOnDeathEmitter&&this.emitParticleOnDeathEmitter.SpawnParticles(n,a,1),this.aliveCount--,s=n&&t>=n)return et?1:0;if(e>=n)return 1;if(t>=n)return-1;var r=a[e],i=a[t];return ri?-1:0})}},{key:"GetInstanceBuffer",value:function(){if(0!==this.aliveCount){var e=i.device.gl;if(this.requiresSorting&&this.HasElement(o.Tw2ParticleElementDeclaration.Type.POSITION)&&this.buffers){this._Sort();for(var t=this.instanceStride[0],r=this.buffers[0],n=0;nt.time?1:0}},{key:"Sort",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.keys;r&&r.length&&(r.sort(e.Compare),t.length=r[r.length-1].time)}},{key:"Sort2",value:function(t){if(t.keys&&t.keys.length){t.keys.sort(e.Compare);var r=t.keys[t.keys.length-1];if(r.time>t.length){var n=t.length,i=t.endValue,a=t.endTangent;t.length=r.time,t.endValue=r.value,t.endTangent=r.leftTangent,n>0&&(r.time=n,r.value=i,r.leftTangent=a)}}}}]),e}();o.inputDimension=null,o.outputDimension=null,o.valueProperty=null,o.curveType=null,o.Key=null,o.Interpolation=null,o.Extrapolation=null,o.Type={CURVE:1,CURVE2:2,CURVE_MAYA:3,CURVE_NO_KEYS:4,SEQUENCER:100,SEQUENCER2:101},o.global={vec3_0:i.vec3.create(),vec4_0:i.vec4.create(),quat_0:i.quat.create(),quat_1:i.quat.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r.d(t,"ARRAY_TYPE",function(){return i}),t.setMatrixArrayType=function(e){i=e},t.toRadian=function(e){return e*o},t.equals=function(e,t){return Math.abs(e-t)<=n*Math.max(1,Math.abs(e),Math.abs(t))};const n=1e-6;t.EPSILON=n;let i="undefined"!=typeof Float32Array?Float32Array:Array;const a=Math.random;t.RANDOM=a;const o=Math.PI/180},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VectorParameter=t.Tw2Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";a(this,e),this._id=i.util.generateID(),this.name=t,this._onModified=[]}return n(e,[{key:"OnValueChanged",value:function(e,t){for(var r=0;r=this.size&&(this.constantBuffer=e,this.offset=t,this.Apply(e,t,r),!0)}},{key:"Unbind",value:function(){this.constantBuffer=null}},{key:"Apply",value:function(e,t,r){e.set(this.value,t)}},{key:"EqualsValue",value:function(e){for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:{},t=this.constructor.Item;if(t&&"create"in t){var r=t.create(e);return this.AddItem(r),r}return null}},{key:"AddItem",value:function(e){this.items.includes(e)||(e._onModified=this._onChildModified,this.items.push(e),this.OnValueChanged())}},{key:"RemoveItem",value:function(e){var t=this.items.indexOf(e);-1!==t&&(e._onModified=null,this.items.splice(t,1),this.OnValueChanged())}},{key:"ClearItems",value:function(){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:null;if(null!==e)for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e){this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this),this._rebuildPending=!1}},{key:"GetBatches",value:function(e,t,r){}},{key:"Render",value:function(){}}],[{key:"RebuildItems",value:function(e){e._visibleItems=[];for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e,t){this.useSRT&&(i.quat.normalize(this.rotation,this.rotation),i.mat4.fromRotationTranslationScale(this.localTransform,this.rotation,this.translation,this.scaling)),i.mat4.copy(this.worldTransformLast,this.worldTransform),i.mat4.multiply(this.worldTransform,t,this.localTransform)}},{key:"GetBatches",value:function(e,t){}}]),e}()).global={mat4_0:i.mat4.create(),vec3_0:i.vec3.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveObject=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[]}},{key:"Update",value:function(e){}},{key:"GetBatches",value:function(e,t){}}]),e}()).global={vec3_0:i.vec3.create(),vec3_1:i.vec3.create(),vec3_2:i.vec3.create(),vec3_3:i.vec3.create(),vec3_4:i.vec3.create(),vec3_5:i.vec3.create(),vec3_6:i.vec3.create(),vec3_7:i.vec3.create(),mat4_0:i.mat4.create(),mat4_1:i.mat4.create(),mat4_2:i.mat4.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2ParticleForce=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r.name=e,r.display=!0,r.visible={},r.visible.log=!0,r.visible.info=!0,r.visible.debug=!0,r.visible.warn=!0,r.visible.error=!0,r.maxLogs=100,r._logs=[],r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.Tw2EventEmitter),n(t,[{key:"log",value:function(e,r){if(r.logged)return r;if(r.log=t.Type[r.log?r.log.toUpperCase():"LOG"]||"log",!r.hide&&this.display&&this.visible[r.log]){var n=this.name+": {"+e+"}",i=r.msg||"";r.path&&(i+=" '"+r.path+"'","time"in r&&(i+=" in "+r.time.toFixed(3)+" secs")),(void 0!==r.value||r.type)&&(i+=" (",r.type&&(i+=r.type),r.type&&void 0!==r.value&&(i+=":"),void 0!==r.value&&(i+=r.value),i+=")"),"data"in r||"err"in r?(console.group(n),console[r.log](i),r.data&&console.debug(r.data),r.err&&console.debug(r.err.stack||r.err.toString()),console.groupEnd()):console[r.log](n,i)}return this.maxLogs?(this._logs.length>=this.maxLogs&&this._logs.splice(this.maxLogs,this._logs.length-1),this._logs.unshift(r)):this._logs=[],this.emit("log",r),r.logged=!0,r}},{key:"GetLogs",value:function(e){return Object.assign([],void 0===e?this._logs:this._logs.splice(0,e))}},{key:"Set",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,a.assignIfExists)(this,e,["name","maxLogs","display"]),(0,a.assignIfExists)(this.visible,e.visible,["log","info","debug","warn","error"])}}]),t}();o.Type={THROW:"error",ERROR:"error",WARNING:"warn",WARN:"warn",INFO:"info",LOG:"log",DEBUG:"debug"};var s=t.logger=new o("CCPWGL");i.Tw2EventEmitter.logger=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(29);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(67);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(33);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(34);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(73);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(74);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(75);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(76);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(77);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.store=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};"uuid"in e&&(0,i.enableUUID)(e.uuid),this.RegisterPaths(e.paths),this.RegisterDynamicPaths(e.dynamicPaths),this.RegisterTypes(e.types),this.RegisterConstructors(e.constructors),this.RegisterExtensions(e.extensions),this.RegisterVariables(e.variables),this.RegisterSchemas(e.schemas)}}],[{key:"GetStoreItem",value:function(e,t,r){var n=e["_"+t];if(n&&(0,i.isString)(r)){if(r in n)return n[r];e._missing[t]||(e._missing[t]=[]),e._missing[t].includes(r)||(e._missing[t].push(r),a.logger.log("store.warning",{log:"warning",msg:"Missing "+t+": '"+r+"'"}))}return null}},{key:"SetStoreItem",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=arguments[3],o=arguments[4];if(o&&!o(n))return a.logger.log("store.error",{log:"error",msg:"Invalid value "+t+": '"+r+"'"}),!1;var s=e["_"+t];if(s&&(0,i.isString)(r)&&!(0,i.isUndefined)(n)){var u=s[r];return s[r]=n,u?a.logger.log("store.registered",{log:"debug",msg:"Re-registered "+t+": '"+r+"'",data:{old_value:u,new_value:n}}):a.logger.log("store.registered",{log:"debug",msg:"Registered "+t+": '"+r+"'",hide:!0}),!0}return!1}},{key:"RegisterFromObject",value:function(e,t,r){if(r&&t in e){r=(0,i.toArray)(r);for(var n=0;nr.size?t.subarray(0,r.size):t,r.offset)}},{key:"Get",value:function(e){return this.elements[e].array}},{key:"GetData",value:function(e){return this.data.subarray(this.elements[e].offset,this.elements[e].offset+this.elements[e].array.length)}},{key:"Create",value:function(){for(var e in this.data=new Float32Array(this.nextOffset),this.elements)if(this.elements.hasOwnProperty(e)){var t=this.elements[e];if(t.array=this.data.subarray(t.offset,t.offset+t.size),null!==t.value){if(1===t.size)t.array[0]=t.value;else for(var r=0;r2&&void 0!==arguments[2]?arguments[2]:null;this.elements[e]={offset:this.nextOffset,size:t,array:null,value:r},this.nextOffset+=t}},{key:"DeclareFromObject",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in e)if(e.hasOwnProperty(t)){var r=e[t];if(a.util.isNumber(r))this.Declare(t,1,r);else{if(!a.util.isArrayLike(r))throw new Error("Invalid declaration type: "+(void 0===r?"undefined":n(r)));1===r.length&&this.Declare(t,r.length,r)}}this.Create()}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(118);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(120);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(38);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(8);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(52);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(121);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(40);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(39);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2ParticleEmitter=void 0;var n=function(){function e(e,t){for(var r=0;r1?0:i<-1?Math.PI:Math.acos(i)},t.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},t.equals=function(e,t){let r=e[0],i=e[1],a=e[2],o=t[0],s=t[1],u=t[2];return Math.abs(r-o)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-s)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(a-u)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(u))};var n=r(3);function i(){let e=new n.ARRAY_TYPE(3);return e[0]=0,e[1]=0,e[2]=0,e}function a(e){let t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function o(e,t,r){let i=new n.ARRAY_TYPE(3);return i[0]=e,i[1]=t,i[2]=r,i}function s(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function u(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function l(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function c(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(r*r+n*n+i*i)}function f(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return r*r+n*n+i*i}function h(e){let t=e[0],r=e[1],n=e[2];return t*t+r*r+n*n}function p(e,t){let r=t[0],n=t[1],i=t[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a),e}function d(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}const v=s;t.sub=v;const m=u;t.mul=m;const y=l;t.div=y;const b=c;t.dist=b;const _=f;t.sqrDist=_;const g=a;t.len=g;const E=h;t.sqrLen=E;const T=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=3),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s0&&(o=1/Math.sqrt(o),e[0]=r*o,e[1]=n*o,e[2]=i*o,e[3]=a*o),e}const d=a;t.sub=d;const v=o;t.mul=v;const m=s;t.div=m;const y=l;t.dist=y;const b=c;t.sqrDist=b;const _=f;t.len=_;const g=h;t.sqrLen=g;const E=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=4),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s1?r-1:0),i=1;i2?n-2:0),a=2;a1?r-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:{};if(i.has(this)){var r=i.get(this);e=e.toLowerCase(),t.log&&!t.log.logged&&(t.log=this.log(e,t.log)),e in r?r[e].forEach(function(n,i){i.call(n.context,t),n.once&&r[e].delete(i)}):(r[e]=new Set,this.emit("event_added",{eventName:e}))}return this}},{key:"on",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i.has(this)||i.set(this,{});var o=i.get(this);return o[e=e.toLowerCase()]||(o[e]=new Set,o[e].add(function(){return r.emit("event_added",{eventName:e})},{once:!0})),o[e].add(t,{context:n,once:a}),this}},{key:"once",value:function(e,t,r){return this.on(e,t,r,!0)}},{key:"off",value:function(e,t){if(i.has(this)){var r=i.get(this);(e=e.toLowerCase())in r&&r[e].delete(t)}return this}},{key:"del",value:function(e){if(i.has(this)){var t=i.get(this);(e=e.toLowerCase())in t&&(this.emit("event_removed",{eventName:e}),delete t[e])}return this}},{key:"clr",value:function(e){if(i.has(this)){var t=i.get(this);for(var r in t)t.hasOwnProperty(r)&&t[r].has(e)&&t[r].delete(e)}return this}},{key:"kill",value:function(){return i.has(this)&&(this.emit("event_kill"),i.set(this,{})),this}},{key:"log",value:function(e,t){return this.constructor.logger&&this.constructor.logger.log(e,t),t}}],[{key:"assign",value:function(t){Object.assign(t.prototype,e.prototype)}}]),e}()).logger=null},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resMan=t.Tw2ResMan=void 0;var n=function(){function e(e,t){for(var r=0;r1&&(this.activeFrame+=1,this._purgeTime-=Math.floor(this._purgeTime),this._purgeFrame+=1,this._purgeFrame>=5&&this.autoPurgeResources&&this.motherLode.PurgeInactive(this._purgeFrame,this._purgeFrameLimit,this.purgeTime,i.logger)),!0}},{key:"GetResource",value:function(t){var r=void 0;if(t=e.NormalizePath(t),r=this.motherLode.Find(t))return r.IsPurged()&&r.Reload(),r;var n=e.GetPathExt(t);if(null===n)return i.logger.log("res.error",{log:"error",src:["Tw2ResMan","ReloadResource"],msg:"Undefined extension",type:"extension.undefined",path:t}),null;var o=a.store.GetExtension(n);return o?((r=new o).path=t,e.LoadResource(this,r)):(i.logger.log("res.error",{log:"error",src:["Tw2ResMan","ReloadResource"],msg:"Unregistered extension",type:"extension.unregistered",path:t,value:n}),null)}},{key:"GetObject",value:function(t,r){var n={};t=e.NormalizePath(t);var i=this.motherLode.Find(t);i?i.AddObject(n,r):((i=new s.Tw2LoadingObject).path=t,i.AddObject(n,r),e.LoadResource(this,i))}},{key:"ReloadResource",value:function(t){var r=t.path,n=this.motherLode.Find(r);return n&&!n.IsPurged()?n:(i.logger.log("res.event",{msg:"Reloading ",path:r,type:"reload"}),e.LoadResource(this,t))}}],[{key:"BuildUrl",value:function(e){var t=e.indexOf(":/");if(-1===t)return i.logger.log("res.error",{log:"warn",src:["Tw2ResMan","BuildUrl"],msg:"Invalid path",type:"prefix.undefined",path:e}),e;var r=e.substr(0,t),n=a.store.GetPath(r);return n?n+e.substr(t+2):(i.logger.log("res.error",{log:"warn",src:["Tw2ResMan","BuildUrl"],msg:"Unregistered path",path:e,type:"prefix.unregistered",value:r}),e)}},{key:"NormalizePath",value:function(e){return"str:/"===e.substr(0,5)?e:((e=e.toLowerCase()).replace("\\","/"),e)}},{key:"GetPathExt",value:function(e){if("str:/"===e.substr(0,5)){var t=e.indexOf("/",5);return-1===t?null:e.substr(5,t-5)}var r=e.lastIndexOf(".");return-1===r?null:e.substr(r+1)}},{key:"LogPathString",value:function(e){return"str:/"===e.substr(0,5)&&e.length>64?e.substr(0,64)+"...":e}},{key:"LoadResource",value:function(t,r){var n=r.path,a=e.BuildUrl(n);if(r._isPurged=!1,t.motherLode.Add(n,r),r.DoCustomLoad&&r.DoCustomLoad(a))return r;var o=e.CreateHttpRequest(r.requestResponseType);if(o){i.logger.log("res.event",{msg:"Requesting",path:n,type:"request"}),o.onreadystatechange=e.DoLoadResource(t,r),o.open("GET",a),r.LoadStarted();try{o.send(),t._pendingLoads++}catch(e){i.logger.log("res.error",{log:"error",src:["Tw2ResMan","LoadResource"],msg:"Error sending object HTTP request",path:n,type:"http.request",err:e})}}return r}},{key:"DoLoadResource",value:function(e,t){return function(){var r=0;try{r=this.readyState}catch(n){return i.logger.log("res.error",{log:"error",src:["Tw2ResMan","_DoLoadResource"],msg:"Communication error loading",path:t.path,type:"http.readystate",value:r}),t.LoadFinished(!1),void e._pendingLoads--}if(4===r){if(200===this.status){var n=null,a=null;try{n=this.responseText,a=this.responseXML}catch(e){n=this.response}t.LoadFinished(!0),e._prepareQueue.push([t,n,a])}else i.logger.log("res.error",{log:"error",src:["Tw2ResMan","_DoLoadResource"],msg:"Communication error loading",path:t.path,type:"http.status",value:this.status}),t.LoadFinished(!1),t.PrepareFinished(!1);e._pendingLoads--}}}},{key:"CreateHttpRequest",value:function(e){var t=null;if(window.XMLHttpRequest)t=new XMLHttpRequest;else if(window.ActiveXObject)try{t=new window.ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{t=new window.ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}return t?e&&(t.responseType=e):i.logger.log("res.error",{log:"error",src:["Tw2LoadingObject","Prepare"],msg:"Could not create an XMLHTTP instance",type:"http.instance"}),t}}]),e}();t.resMan=new u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2LoadingObject=void 0;var n=function(){function e(e,t){for(var r=0;r127&&(e=e-255-1),e}},{key:"ReadUInt16",value:function(){return this.data[this.cursor++]+(this.data[this.cursor++]<<8)}},{key:"ReadInt16",value:function(){var e=this.data[this.cursor++]+(this.data[this.cursor++]<<8);return e>32767&&(e=e-65535-1),e}},{key:"ReadUInt32",value:function(){return this.data[this.cursor++]+(this.data[this.cursor++]<<8)+(this.data[this.cursor++]<<16)+(this.data[this.cursor++]<<24>>>0)}},{key:"ReadInt32",value:function(){var e=this.data[this.cursor++]+(this.data[this.cursor++]<<8)+(this.data[this.cursor++]<<16)+(this.data[this.cursor++]<<24>>>0);return e>2147483647&&(e=e-4294967295-1),e}},{key:"ReadFloat16",value:function(){var e=this.data[this.cursor++],t=this.data[this.cursor++],r=(t>>2&31)-15,n=(3&t)<<8|e;return 0===n&&-15===r?0:(1-2*(t>>7))*(1+n*Math.pow(2,-10))*Math.pow(2,r)}},{key:"ReadFloat32",value:function(){var e=this.data[this.cursor++],t=this.data[this.cursor++],r=this.data[this.cursor++],n=this.data[this.cursor++],i=(n<<1&255|r>>7)-127,a=(127&r)<<16|t<<8|e;return 0===a&&-127===i?0:(1-2*(n>>7))*(1+a*Math.pow(2,-23))*Math.pow(2,i)}},{key:"ReadString",value:function(){for(var e=this.data[this.cursor++],t="",r=0;r0&&void 0!==arguments[0]?arguments[0]:[];for(var t in this.effectRes&&!e.includes(this.effectRes)&&e.push(this.effectRes),this.parameters)this.parameters.hasOwnProperty(t)&&"GetResources"in this.parameters[t]&&this.parameters[t].GetResources(e);return e}},{key:"RebuildCachedData",value:function(e){this.shader=e.GetShader(this.options),this.BindParameters()}},{key:"UnBindParameters",value:function(){for(var e in this.techniques)if(this.techniques.hasOwnProperty(e))for(var t=this.techniques[e],r=0;r=this.techniques[e].length)){this.shader.ApplyPass(e,t);for(var r=this.techniques[e][t],n=this.shader.techniques[e].passes[t],a=i.device,o=a.gl,s=a.IsAlphaTestEnabled()&&n.shadowShaderProgram?n.shadowShaderProgram:n.shaderProgram,u=0;u<2;++u){for(var l=r.stages[u],c=0;c=this.techniques[e].length?null:i.device.IsAlphaTestEnabled()&&this.shader.techniques[e].passes[t].shadowShaderProgram?this.shader.techniques[e].passes[t].shadowShaderProgram.input:this.shader.techniques[e].passes[t].shaderProgram.input}},{key:"Render",value:function(e){for(var t=this.GetPassCount("Main"),r=0;r0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)if(this.parameters.hasOwnProperty(t)&&this.parameters[t]instanceof a.Tw2TextureParameter){var r=this.parameters[t].GetValue();r&&(e[t]=r)}return e}},{key:"SetTextures",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=e[r],i=this.parameters[r];a.Tw2TextureParameter.is(n)&&(i?i.EqualsValue(n)||(i.SetTexturePath(n),t=!0):(this.parameters[r]=new a.Tw2TextureParameter(r,n),t=!0))}return t}},{key:"GetParameters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)!this.parameters.hasOwnProperty(t)||this.parameters[t]instanceof a.Tw2TextureParameter||(e[t]=this.parameters[t].GetValue(!0));return e}},{key:"SetParameters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=e[r],a=this.parameters[r];if(a)a.constructor.is(n)&&!a.EqualsValue(n)&&(this.parameters[r].SetValue(n),t=!0);else{var o=i.store.CreateType(r,n);o&&(this.parameters[r]=o,t=!0)}}return t}},{key:"SetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!1;for(var r in e)if(e.hasOwnProperty(r)){var n=this.parameters[r];if(n&&n instanceof a.Tw2TextureParameter){var i=!1,o=e[r];for(var s in o)if(o.hasOwnProperty(s)&&a.Tw2TextureParameter.overrideProperties.includes(s)&&o[s]!==n[s]){i=!0;break}i&&(n.SetOverrides(e[r]),t=!0)}}return t}},{key:"GetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in this.parameters)if(this.parameters.hasOwnProperty(t)){var r=this.parameters[t];r&&r instanceof a.Tw2TextureParameter&&r.useAllOverrides&&(e[t]=this.parameters[t].GetOverrides())}return e}}],[{key:"ToEffectResPath",value:function(e){return(e=e?e.substr(0,e.lastIndexOf(".")).replace("/effect/",i.device.effectDir)+".sm_"+i.device.shaderModel:"").toLowerCase()}},{key:"FromEffectResPath",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"fx";return(e=e.substr(0,e.lastIndexOf(".")).replace(i.device.effectDir,"/effect/")+"."+t).toLowerCase()}},{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new this;if(i.util.assignIfExists(t,e,["name","effectFilePath","display","autoParameter"]),"parameters"in e&&t.SetParameters(e.parameters),"textures"in e&&t.SetTextures(e.textures),"overrides"in e&&t.SetOverrides(e.overrides),""===t.name&&""!==e.effectFilePath){var r=e.effectFilePath;t.name=r.substring(r.lastIndexOf("/")+1,r.length)}return t.Initialize(),t}}]),e}()).ConstantIgnore=["PerFrameVS","PerObjectVS","PerFramePS","PerObjectPS","PerObjectPSInt"]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TextureParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.resourcePath=r,n.useAllOverrides=!1,n.addressUMode=1,n.addressVMode=1,n.addressWMode=1,n.filterMode=2,n.mipFilterMode=2,n.maxAnisotropy=4,n.textureRes=null,n._sampler=null,r&&n.Initialize(),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,o.Tw2Parameter),n(t,[{key:"Initialize",value:function(){this.OnValueChanged()}},{key:"SetTexturePath",value:function(e){this.resourcePath=e,this.OnValueChanged()}},{key:"GetValue",value:function(){return this.isTextureAttached?null:this.resourcePath}},{key:"SetTextureRes",value:function(e){this.textureRes!==e&&(this.resourcePath="",this.textureRes=e),this.textureRes._isAttached=!0}},{key:"OnValueChanged",value:function(e,r){""!==this.resourcePath&&(this.resourcePath=this.resourcePath.toLowerCase(),this.textureRes=""!==this.resourcePath?i.resMan.GetResource(this.resourcePath):null),this.UpdateOverrides(),function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,r,n)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(n):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"OnValueChanged",this).call(this,e,r)}},{key:"Apply",value:function(e,t,r){this.textureRes&&(this.useAllOverrides&&(this._sampler.samplerType=t.samplerType,this._sampler.isVolume=t.isVolume,this._sampler.registerIndex=t.registerIndex,t=this._sampler),i.device.gl.activeTexture(i.device.gl.TEXTURE0+e),this.textureRes.Bind(t,r))}},{key:"SetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i.util.assignIfExists(this,e,t.overrideProperties),this.OnValueChanged()}},{key:"GetOverrides",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.util.assignIfExists(e,this,t.overrideProperties),e}},{key:"UpdateOverrides",value:function(){if(this.useAllOverrides){this._sampler=this._sampler||new a.Tw2SamplerState;var e=i.device.wrapModes,t=i.device.gl,r=this._sampler;if(1===this.filterMode){switch(this.mipFilterMode){case 0:r.minFilter=t.NEAREST;break;case 1:r.minFilter=t.NEAREST_MIPMAP_NEAREST;break;default:r.minFilter=t.NEAREST_MIPMAP_LINEAR}r.minFilterNoMips=t.NEAREST,r.magFilter=t.NEAREST}else{switch(this.mipFilterMode){case 0:r.minFilter=t.LINEAR;break;case 1:r.minFilter=t.LINEAR_MIPMAP_NEAREST;break;default:r.minFilter=t.LINEAR_MIPMAP_LINEAR}r.minFilterNoMips=t.LINEAR,r.magFilter=t.LINEAR}r.addressU=e[this.addressUMode],r.addressV=e[this.addressVMode],r.addressW=e[this.addressWMode],r.anisotropy=this.maxAnisotropy,r.ComputeHash()}else this._sampler&&(this._sampler=null)}},{key:"EqualsValue",value:function(e){return e.toLowerCase()===this.GetValue()}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.resourcePath=e.resourcePath,this.SetOverrides(e.GetOverrides)}},{key:"Clone",value:function(){var e=new t;return e.Copy(this,!0),e}},{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.textureRes&&!e.includes(this.textureRes)&&e.push(this.textureRes),e}},{key:"isTextureAttached",get:function(){return this.textureRes&&this.textureRes._isAttached}}],[{key:"isValue",value:function(e){return i.util.isString(e)}}]),t}();s.prototype.SetValue=s.prototype.SetTexturePath,s.overrideProperties=["useAllOverrides","addressUMode","addressVMode","addressWMode","filterMode","mipFilterMode","maxAnisotropy"]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SamplerState=void 0;var n=function(){function e(e,t){for(var r=0;r4&&void 0!==arguments[4]?arguments[4]:0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.usage=t,this.usageIndex=r,this.type=n,this.elements=i,this.offset=a,this.location=null,this.customSetter=null}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(94);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(95);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(96);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(97);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(98);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(99);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(100);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(42);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PerObjectData=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};e.VSData&&(this.perObjectVSData=new a.Tw2RawData(e.VSData)),e.PSData&&(this.perObjectPSData=new a.Tw2RawData(e.PSData))}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(103);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(104);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(105);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(106);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(107);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(108);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var l=r(109);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var c=r(110);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var f=r(111);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})});var h=r(112);Object.keys(h).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return h[e]}})});var p=r(113);Object.keys(p).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return p[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(41);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(114);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(49);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(50);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(115);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Mesh=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[];return e.includes(this.geometryResource)||e.push(this.geometryResource),i.util.perArrayChild(this.opaqueAreas,"GetResources",e),i.util.perArrayChild(this.transparentAreas,"GetResources",e),i.util.perArrayChild(this.additiveAreas,"GetResources",e),i.util.perArrayChild(this.pickableAreas,"GetResources",e),i.util.perArrayChild(this.decalAreas,"GetResources",e),i.util.perArrayChild(this.depthAreas,"GetResources",e),e}},{key:"GetBatches",value:function(e,t,r){if(!this.IsGood()||!this.display)return!1;var n=this.constructor.GetAreaBatches;switch(e){case i.device.RM_OPAQUE:return void(this.visible.opaqueAreas&&n(this,this.opaqueAreas,e,t,r));case i.device.RM_DECAL:return void(this.visible.decalAreas&&n(this,this.opaqueAreas,e,t,r));case i.device.RM_TRANSPARENT:return void(this.visible.transparentAreas&&n(this,this.transparentAreas,e,t,r));case i.device.RM_ADDITIVE:return void(this.visible.transparentAreas&&n(this,this.additiveAreas,e,t,r));case i.device.RM_PICKABLE:return void(this.visible.pickableAreas&&n(this,this.pickableAreas,e,t,r))}}}],[{key:"GetAreaBatches",value:function(e,t,r,n,i){for(var a=0;a=this.animationRes.duration}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TextureRes=void 0;var n=function(){function e(e,t){for(var r=0;r0?"."+t.mipLevelSkipCount.toString():"";if(t.mipLevelSkipCount>0){var n=e.lastIndexOf(".");n>=0&&(e=e.substr(0,n-2)+r+e.substr(n))}return e}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Bone=void 0;var n=r(0);t.Tw2Bone=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.boneRes=null,this.localTransform=n.mat4.create(),this.worldTransform=n.mat4.create(),this.offsetTransform=n.mat4.create()}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2Model=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.modelRes=null,this.bones=[],this.bonesByName={}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2Track=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.trackRes=null,this.bone=null}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2TrackGroup=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.trackGroupRes=null,this.model=null,this.transformTracks=[]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2RenderTarget=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];if(this.mesh&&this.mesh.GetResources(e),!t)for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];return this.mesh&&this.mesh.GetResources(e),this.animation&&this.animation.GetResources(e),i.util.perArrayChild(this.spriteSets,"GetResources",e),i.util.perArrayChild(this.turretSets,"GetResources",e),i.util.perArrayChild(this.decals,"GetResources",e),i.util.perArrayChild(this.spotlightSets,"GetResources",e),i.util.perArrayChild(this.planeSets,"GetResources",e),i.util.perArrayChild(this.lineSets,"GetResources",e),i.util.perArrayChild(this.overlayEffects,"GetResources",e),i.util.perArrayChild(this.effectChildren,"GetResources",e),t||i.util.perArrayChild(this.children,"GetResources",e),e}},{key:"UpdateViewDependentData",value:function(){for(var e=0;e0?(t[0]=this.shapeEllipsoidCenter[0],t[1]=this.shapeEllipsoidCenter[1],t[2]=this.shapeEllipsoidCenter[2],r[0]=this.shapeEllipsoidRadius[0],r[1]=this.shapeEllipsoidRadius[1],r[2]=this.shapeEllipsoidRadius[2]):this.mesh&&this.mesh.IsGood()&&(i.vec3.subtract(t,this.mesh.geometryResource.maxBounds,this.mesh.geometryResource.minBounds),i.vec3.scale(t,t,.8660254035),i.vec3.add(r,this.mesh.geometryResource.maxBounds,this.mesh.geometryResource.minBounds),i.vec3.scale(r,r,.5));for(var n=0;n0){for(var t=0;t0&&this.mesh.GetBatches(e,t,this._perObjectData),this.lod>1){if(r.spriteSets)for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:null;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.batches=[],this._sortMethod=t}return n(e,[{key:"Commit",value:function(e){this.batches.push(e)}},{key:"Clear",value:function(){this.batches=[]}},{key:"Render",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Main";this._sortMethod&&this.batches.sort(this._sortMethod);for(var r=0;r0?(n=2*Math.sqrt(r+1),e[3]=.25*n,e[0]=(t[6]-t[9])/n,e[1]=(t[8]-t[2])/n,e[2]=(t[1]-t[4])/n):t[0]>t[5]&t[0]>t[10]?(n=2*Math.sqrt(1+t[0]-t[5]-t[10]),e[3]=(t[6]-t[9])/n,e[0]=.25*n,e[1]=(t[1]+t[4])/n,e[2]=(t[8]+t[2])/n):t[5]>t[10]?(n=2*Math.sqrt(1+t[5]-t[0]-t[10]),e[3]=(t[8]-t[2])/n,e[0]=(t[1]+t[4])/n,e[1]=.25*n,e[2]=(t[6]+t[9])/n):(n=2*Math.sqrt(1+t[10]-t[0]-t[5]),e[3]=(t[1]-t[4])/n,e[0]=(t[8]+t[2])/n,e[1]=(t[6]+t[9])/n,e[2]=.25*n);return e},t.fromRotationTranslationScale=function(e,t,r,n){let i=t[0],a=t[1],o=t[2],s=t[3],u=i+i,l=a+a,c=o+o,f=i*u,h=i*l,p=i*c,d=a*l,v=a*c,m=o*c,y=s*u,b=s*l,_=s*c,g=n[0],E=n[1],T=n[2];return e[0]=(1-(d+m))*g,e[1]=(h+_)*g,e[2]=(p-b)*g,e[3]=0,e[4]=(h-_)*E,e[5]=(1-(f+m))*E,e[6]=(v+y)*E,e[7]=0,e[8]=(p+b)*T,e[9]=(v-y)*T,e[10]=(1-(f+d))*T,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e},t.fromRotationTranslationScaleOrigin=function(e,t,r,n,i){let a=t[0],o=t[1],s=t[2],u=t[3],l=a+a,c=o+o,f=s+s,h=a*l,p=a*c,d=a*f,v=o*c,m=o*f,y=s*f,b=u*l,_=u*c,g=u*f,E=n[0],T=n[1],O=n[2],w=i[0],S=i[1],R=i[2];return e[0]=(1-(v+y))*E,e[1]=(p+g)*E,e[2]=(d-_)*E,e[3]=0,e[4]=(p-g)*T,e[5]=(1-(h+y))*T,e[6]=(m+b)*T,e[7]=0,e[8]=(d+_)*O,e[9]=(m-b)*O,e[10]=(1-(h+v))*O,e[11]=0,e[12]=r[0]+w-(e[0]*w+e[4]*S+e[8]*R),e[13]=r[1]+S-(e[1]*w+e[5]*S+e[9]*R),e[14]=r[2]+R-(e[2]*w+e[6]*S+e[10]*R),e[15]=1,e},t.fromQuat=function(e,t){let r=t[0],n=t[1],i=t[2],a=t[3],o=r+r,s=n+n,u=i+i,l=r*o,c=n*o,f=n*s,h=i*o,p=i*s,d=i*u,v=a*o,m=a*s,y=a*u;return e[0]=1-f-d,e[1]=c+y,e[2]=h-m,e[3]=0,e[4]=c-y,e[5]=1-l-d,e[6]=p+v,e[7]=0,e[8]=h+m,e[9]=p-v,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},t.frustum=function(e,t,r,n,i,a,o){let s=1/(r-t),u=1/(i-n),l=1/(a-o);return e[0]=2*a*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*u,e[6]=0,e[7]=0,e[8]=(r+t)*s,e[9]=(i+n)*u,e[10]=(o+a)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*l,e[15]=0,e},t.perspective=function(e,t,r,n,i){let a=1/Math.tan(t/2),o=1/(n-i);return e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(i+n)*o,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*i*n*o,e[15]=0,e},t.perspectiveFromFieldOfView=function(e,t,r,n){let i=Math.tan(t.upDegrees*Math.PI/180),a=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),s=Math.tan(t.rightDegrees*Math.PI/180),u=2/(o+s),l=2/(i+a);return e[0]=u,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-(o-s)*u*.5,e[9]=(i-a)*l*.5,e[10]=n/(r-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*r/(r-n),e[15]=0,e},t.ortho=function(e,t,r,n,i,a,o){let s=1/(t-r),u=1/(n-i),l=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*s,e[13]=(i+n)*u,e[14]=(o+a)*l,e[15]=1,e},t.lookAt=function(e,t,r,i){let a,o,s,u,l,c,f,h,p,d,v=t[0],m=t[1],y=t[2],b=i[0],_=i[1],g=i[2],E=r[0],T=r[1],O=r[2];if(Math.abs(v-E)0&&(p=1/Math.sqrt(p),c*=p,f*=p,h*=p);let d=u*h-l*f,v=l*c-s*h,m=s*f-u*c;return e[0]=d,e[1]=v,e[2]=m,e[3]=0,e[4]=f*m-h*v,e[5]=h*d-c*m,e[6]=c*v-f*d,e[7]=0,e[8]=c,e[9]=f,e[10]=h,e[11]=0,e[12]=i,e[13]=a,e[14]=o,e[15]=1,e},t.str=function(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},t.frob=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2)+Math.pow(e[9],2)+Math.pow(e[10],2)+Math.pow(e[11],2)+Math.pow(e[12],2)+Math.pow(e[13],2)+Math.pow(e[14],2)+Math.pow(e[15],2))},t.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e},t.subtract=a,t.multiplyScalar=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e},t.multiplyScalarAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e[9]=t[9]+r[9]*n,e[10]=t[10]+r[10]*n,e[11]=t[11]+r[11]*n,e[12]=t[12]+r[12]*n,e[13]=t[13]+r[13]*n,e[14]=t[14]+r[14]*n,e[15]=t[15]+r[15]*n,e},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},t.equals=function(e,t){let r=e[0],i=e[1],a=e[2],o=e[3],s=e[4],u=e[5],l=e[6],c=e[7],f=e[8],h=e[9],p=e[10],d=e[11],v=e[12],m=e[13],y=e[14],b=e[15],_=t[0],g=t[1],E=t[2],T=t[3],O=t[4],w=t[5],S=t[6],R=t[7],P=t[8],A=t[9],M=t[10],j=t[11],D=t[12],C=t[13],I=t[14],k=t[15];return Math.abs(r-_)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(_))&&Math.abs(i-g)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(g))&&Math.abs(a-E)<=n.EPSILON*Math.max(1,Math.abs(a),Math.abs(E))&&Math.abs(o-T)<=n.EPSILON*Math.max(1,Math.abs(o),Math.abs(T))&&Math.abs(s-O)<=n.EPSILON*Math.max(1,Math.abs(s),Math.abs(O))&&Math.abs(u-w)<=n.EPSILON*Math.max(1,Math.abs(u),Math.abs(w))&&Math.abs(l-S)<=n.EPSILON*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(c-R)<=n.EPSILON*Math.max(1,Math.abs(c),Math.abs(R))&&Math.abs(f-P)<=n.EPSILON*Math.max(1,Math.abs(f),Math.abs(P))&&Math.abs(h-A)<=n.EPSILON*Math.max(1,Math.abs(h),Math.abs(A))&&Math.abs(p-M)<=n.EPSILON*Math.max(1,Math.abs(p),Math.abs(M))&&Math.abs(d-j)<=n.EPSILON*Math.max(1,Math.abs(d),Math.abs(j))&&Math.abs(v-D)<=n.EPSILON*Math.max(1,Math.abs(v),Math.abs(D))&&Math.abs(m-C)<=n.EPSILON*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(y-I)<=n.EPSILON*Math.max(1,Math.abs(y),Math.abs(I))&&Math.abs(b-k)<=n.EPSILON*Math.max(1,Math.abs(b),Math.abs(k))};var n=r(3);function i(e,t,r){let n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],l=t[6],c=t[7],f=t[8],h=t[9],p=t[10],d=t[11],v=t[12],m=t[13],y=t[14],b=t[15],_=r[0],g=r[1],E=r[2],T=r[3];return e[0]=_*n+g*s+E*f+T*v,e[1]=_*i+g*u+E*h+T*m,e[2]=_*a+g*l+E*p+T*y,e[3]=_*o+g*c+E*d+T*b,_=r[4],g=r[5],E=r[6],T=r[7],e[4]=_*n+g*s+E*f+T*v,e[5]=_*i+g*u+E*h+T*m,e[6]=_*a+g*l+E*p+T*y,e[7]=_*o+g*c+E*d+T*b,_=r[8],g=r[9],E=r[10],T=r[11],e[8]=_*n+g*s+E*f+T*v,e[9]=_*i+g*u+E*h+T*m,e[10]=_*a+g*l+E*p+T*y,e[11]=_*o+g*c+E*d+T*b,_=r[12],g=r[13],E=r[14],T=r[15],e[12]=_*n+g*s+E*f+T*v,e[13]=_*i+g*u+E*h+T*m,e[14]=_*a+g*l+E*p+T*y,e[15]=_*o+g*c+E*d+T*b,e}function a(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}const o=i;t.mul=o;const s=a;t.sub=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=s,t.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},t.setAxisAngle=u,t.getAxisAngle=function(e,t){let r=2*Math.acos(t[3]),n=Math.sin(r/2);0!=n?(e[0]=t[0]/n,e[1]=t[1]/n,e[2]=t[2]/n):(e[0]=1,e[1]=0,e[2]=0);return r},t.multiply=l,t.rotateX=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u+o*s,e[1]=i*u+a*s,e[2]=a*u-i*s,e[3]=o*u-n*s,e},t.rotateY=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u-a*s,e[1]=i*u+o*s,e[2]=a*u+n*s,e[3]=o*u-i*s,e},t.rotateZ=function(e,t,r){r*=.5;let n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u+i*s,e[1]=i*u-n*s,e[2]=a*u+o*s,e[3]=o*u-a*s,e},t.calculateW=function(e,t){let r=t[0],n=t[1],i=t[2];return e[0]=r,e[1]=n,e[2]=i,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),e},t.slerp=c,t.invert=function(e,t){let r=t[0],n=t[1],i=t[2],a=t[3],o=r*r+n*n+i*i+a*a,s=o?1/o:0;return e[0]=-r*s,e[1]=-n*s,e[2]=-i*s,e[3]=a*s,e},t.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},t.fromMat3=f,t.fromEuler=function(e,t,r,n){let i=.5*Math.PI/180;t*=i,r*=i,n*=i;let a=Math.sin(t),o=Math.cos(t),s=Math.sin(r),u=Math.cos(r),l=Math.sin(n),c=Math.cos(n);return e[0]=a*u*c-o*s*l,e[1]=o*s*c+a*u*l,e[2]=o*u*l-a*s*c,e[3]=o*u*c+a*s*l,e},t.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"};var n=r(3),i=r(30),a=r(31),o=r(32);function s(){let e=new n.ARRAY_TYPE(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function u(e,t,r){r*=.5;let n=Math.sin(r);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r),e}function l(e,t,r){let n=t[0],i=t[1],a=t[2],o=t[3],s=r[0],u=r[1],l=r[2],c=r[3];return e[0]=n*c+o*s+i*l-a*u,e[1]=i*c+o*u+a*s-n*l,e[2]=a*c+o*l+n*u-i*s,e[3]=o*c-n*s-i*u-a*l,e}function c(e,t,r,n){let i,a,o,s,u,l=t[0],c=t[1],f=t[2],h=t[3],p=r[0],d=r[1],v=r[2],m=r[3];return(a=l*p+c*d+f*v+h*m)<0&&(a=-a,p=-p,d=-d,v=-v,m=-m),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,u=Math.sin(n*i)/o):(s=1-n,u=n),e[0]=s*l+u*p,e[1]=s*c+u*d,e[2]=s*f+u*v,e[3]=s*h+u*m,e}function f(e,t){let r,n=t[0]+t[4]+t[8];if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{let n=0;t[4]>t[0]&&(n=1),t[8]>t[3*n+n]&&(n=2);let i=(n+1)%3,a=(n+2)%3;r=Math.sqrt(t[3*n+n]-t[3*i+i]-t[3*a+a]+1),e[n]=.5*r,r=.5/r,e[3]=(t[3*i+a]-t[3*a+i])*r,e[i]=(t[3*i+n]+t[3*n+i])*r,e[a]=(t[3*a+n]+t[3*n+a])*r}return e}const h=o.clone;t.clone=h;const p=o.fromValues;t.fromValues=p;const d=o.copy;t.copy=d;const v=o.set;t.set=v;const m=o.add;t.add=m;const y=l;t.mul=y;const b=o.scale;t.scale=b;const _=o.dot;t.dot=_;const g=o.lerp;t.lerp=g;const E=o.length;t.length=E;const T=E;t.len=T;const O=o.squaredLength;t.squaredLength=O;const w=O;t.sqrLen=w;const S=o.normalize;t.normalize=S;const R=o.exactEquals;t.exactEquals=R;const P=o.equals;t.equals=P;const A=function(){let e=a.create(),t=a.fromValues(1,0,0),r=a.fromValues(0,1,0);return function(n,i,o){let s=a.dot(i,o);return s<-.999999?(a.cross(e,t,i),a.len(e)<1e-6&&a.cross(e,r,i),a.normalize(e,e),u(n,e,Math.PI),n):s>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(a.cross(e,i,o),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+s,S(n,n))}}();t.rotationTo=A;const M=function(){let e=s(),t=s();return function(r,n,i,a,o,s){return c(e,n,o,s),c(t,i,a,s),c(r,e,t,2*s*(1-s)),r}}();t.sqlerp=M;const j=function(){let e=i.create();return function(t,r,n,i){return e[0]=n[0],e[3]=n[1],e[6]=n[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-r[0],e[5]=-r[1],e[8]=-r[2],S(t,f(t,e))}}();t.setAxes=j},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=i,t.clone=function(e){let t=new n.ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t},t.fromValues=function(e,t){let r=new n.ARRAY_TYPE(2);return r[0]=e,r[1]=t,r},t.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},t.set=function(e,t,r){return e[0]=t,e[1]=r,e},t.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e},t.subtract=a,t.multiply=o,t.divide=s,t.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},t.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},t.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e},t.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e},t.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},t.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e},t.scaleAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e},t.distance=u,t.squaredDistance=l,t.length=c,t.squaredLength=f,t.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},t.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},t.normalize=function(e,t){var r=t[0],n=t[1],i=r*r+n*n;i>0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i);return e},t.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},t.cross=function(e,t,r){var n=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=n,e},t.lerp=function(e,t,r,n){var i=t[0],a=t[1];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e},t.random=function(e,t){t=t||1;var r=2*n.RANDOM()*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e},t.transformMat2=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e},t.transformMat2d=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i+r[4],e[1]=r[1]*n+r[3]*i+r[5],e},t.transformMat3=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[3]*i+r[6],e[1]=r[1]*n+r[4]*i+r[7],e},t.transformMat4=function(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[4]*i+r[12],e[1]=r[1]*n+r[5]*i+r[13],e},t.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},t.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]},t.equals=function(e,t){let r=e[0],i=e[1],a=t[0],o=t[1];return Math.abs(r-a)<=n.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-o)<=n.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))};var n=r(3);function i(){let e=new n.ARRAY_TYPE(2);return e[0]=0,e[1]=0,e}function a(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function o(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function s(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function u(e,t){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function l(e,t){var r=t[0]-e[0],n=t[1]-e[1];return r*r+n*n}function c(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function f(e){var t=e[0],r=e[1];return t*t+r*r}const h=c;t.len=h;const p=a;t.sub=p;const d=o;t.mul=d;const v=s;t.div=v;const m=u;t.dist=m;const y=l;t.sqrDist=y;const b=f;t.sqrLen=b;const _=function(){let e=i();return function(t,r,n,i,a,o){let s,u;for(r||(r=2),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s1.0001||r<.99999)e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=0;else if(r=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])){var i=Math.atan2(r,t[3])/r;e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=0}else e[0]=0,e[1]=0,e[2]=0,e[3]=0;return e},n.quat.pow=function(e,t,r){return 1===r?n.quat.copy(e,t):(n.quat.ln(e,t),e[0]*=r,e[1]*=r,e[2]*=r,e[3]*=r,n.quat.exp(e,e),e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mat3=void 0;var n=r(7);t.mat3=n.mat3},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mat4=void 0;var n=r(7);t.mat4=n.mat4,n.mat4.arcFromForward=function(){var e=void 0;return function(t,r){e||(e=n.vec3.create());var i=n.vec3.normalize(e,r);if(n.mat4.identity(t),i[2]<-.99999)return t;if(i[2]>.99999)return t[5]=-1,t[10]=-1,t;var a=(1+i[2])/(i[0]*i[0]+i[1]*i[1]);return t[0]=a*i[1]*i[1]-i[2],t[1]=-a*i[0]*i[1],t[2]=i[0],t[4]=t[1],t[5]=a*i[0]*i[0]-i[2],t[6]=i[1],t[8]=-i[0],t[9]=-i[1],t[10]=-i[2],t}}(),n.mat4.copyTranslation=function(e,t){return e[12]=t[12],e[13]=t[13],e[14]=t[14],e},n.mat4.fromMat3=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[4]=t[3],e[5]=t[4],e[6]=t[5],e[8]=t[6],e[9]=t[7],e[10]=t[8],e[3]=e[7]=e[11]=e[12]=e[13]=e[14]=0,e[15]=1,e},n.mat4.lookAtGL=function(){var e=void 0,t=void 0,r=void 0;return function(i,a,o,s){return e||(e=n.vec3.create(),t=n.vec3.create(),r=n.vec3.create()),n.vec3.subtract(r,a,o),0===n.vec3.squaredLength(r)&&(r[2]=1),n.vec3.normalize(r,r),n.vec3.cross(e,s,r),0===n.vec3.squaredLength(e)&&(r[2]+=1e-4,n.vec3.cross(e,s,r)),n.vec3.normalize(e,e),n.vec3.cross(t,r,e),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[4]=t[0],i[5]=t[1],i[6]=t[2],i[8]=r[0],i[9]=r[1],i[10]=r[2],i}}(),n.mat4.perspectiveGL=function(e,t,r,i,a){var o=Math.tan(t/360*Math.PI)*i,s=o*r;return n.mat4.frustum(e,-s,s,-o,o,i,a),e},n.mat4.setTranslation=function(e,t){return e[12]=t[0],e[13]=t[1],e[14]=t[2],e},n.mat4.setTranslationFromValues=function(e,t,r,n){return e[12]=t,e[13]=r,e[14]=n,e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.noise=void 0;var n=r(33),i=r(34),a=t.noise={};a.turbulence=function(){var e=[],t=[],r=[],a=!1;return function(o,s,u,l,c,f){a||function(){for(var o=0;o<256;o++)e[o]=i.vec4.fromValues(Math.random()-.5,Math.random()-.5,Math.random()-.5,Math.random()-.5),t[o]=o;for(var s=256;--s;){var u=t[s],l=Math.floor(256*Math.random());t[s]=t[l],t[l]=u}for(var c=0;c<256;c++)t[256+c]=t[c],e[256+c]=e[c],e[512+c]=e[c];for(var f=0;f<15;++f)r[f]=n.vec3.create();a=!0}(),s+=4096,u+=4096,l+=4096,c+=4096;var h=Math.floor(s),p=Math.floor(u),d=Math.floor(l),v=Math.floor(c),m=s-h,y=u-p,b=l-d,_=c-v,g=(h&=255)+1,E=(p&=255)+1,T=(d&=255)+1,O=(v&=255)+1,w=t[h],S=t[g],R=t[w+p],P=t[S+p],A=t[w+E],M=t[S+E],j=n.vec3.lerp(r[0],e[R+d+v],e[P+d+v],m),D=n.vec3.lerp(r[1],e[A+d+v],e[M+d+v],m),C=n.vec3.lerp(r[2],e[R+T+v],e[P+T+v],m),I=n.vec3.lerp(r[3],e[R+T+v],e[P+T+v],m),k=n.vec3.lerp(r[4],j,D,y),x=n.vec3.lerp(r[5],C,I,y),L=n.vec3.lerp(r[6],k,x,b);j=n.vec3.lerp(r[7],e[R+d+O],e[P+d+O],m),D=n.vec3.lerp(r[8],e[A+d+O],e[M+d+O],m),C=n.vec3.lerp(r[9],e[R+T+O],e[P+T+O],m),I=n.vec3.lerp(r[10],e[R+T+O],e[P+T+O],m),k=n.vec3.lerp(r[11],j,D,y),x=n.vec3.lerp(r[12],C,I,y);var B=n.vec3.lerp(r[13],k,x,b),F=n.vec3.lerp(r[14],L,B,_);return o[0]+=F[0]*f,o[1]+=F[1]*f,o[2]+=F[2]*f,o}}(),a.perlin1=function(){var e=!1,t=256,r=null,n=null;return function(i){e||function(){r=new Array(t+t+2),n=new Array(t+t+2);var i=0,a=0,o=0;for(i=0;it){o=u;break}if(0===e.degree)for(var l=0;l0&&(s=(t-e.knots[e.knots.length-1])/f);for(var h=0;hg&&(g+=i,E+=i,t+=i),_>g&&(g+=i,E+=i,t+=i),E=0;)n=r*n+e[t];return n},n.ag_zeroin2=function(e,t,r,i,a,o){var s=void 0,u=void 0,l=void 0,c=void 0,f=void 0,h=void 0,p=void 0,d=void 0,v=void 0,m=void 0;for(var y=!0;y&&(s=e,c=r,l=u=t-e),Math.abs(c)f&&0!==i;)Math.abs(l)0?d=-d:p=-p,m=l,l=u,2*p<3*h*d-Math.abs(f*d)&&pf?t+=u:h>0?t+=f:t-=f,(i=n.ag_horner1(o.p,o.deg,t))*(c/Math.abs(c))>0&&(y=!0);return t},n.ag_zeroin=function(e,t,r,i){var a,o;return a=n.ag_horner1(i.p,i.deg,e),Math.abs(a)<1.192092896e-7?e:(o=n.ag_horner1(i.p,i.deg,t),Math.abs(o)<1.192092896e-7?t:n.ag_zeroin2(e,t,a,o,r,i))},n.polyZeroes=function(e,t,r,i,a,o,s){var u,l,c=void 0,f=void 0,h=void 0,p=void 0,d=void 0,v=void 0,m=void 0,y=void 0,b=void 0,_=void 0,g=void 0,E=void 0,T=new Array(22),O=void 0,w=new Array(22),S=new Array(22),R={p:[],deg:0};for(m=_=0,y=0,c=0;cs[0]-u:a>s[0]+u,(p=f&&h?1:0)&&(i&&s[0]a&&(s[0]=a)),p;for(R.p=E,R.deg=t,c=1;c<=t;c++)O[c-1]=c*E[c];if(0===(d=n.polyZeroes(O,t-1,r,0,a,0,l)).length)return 0;for(c=v=0;c<=d;c++){if(p>t)return p;0===c?(b=r,g=n.ag_horner1(E,t,b),Math.abs(g)<=u&&i&&(s[p++]=r)):(b=m,g=_),c===d?(m=a,v=0):m=l[c],_=n.ag_horner1(E,t,m),v?v=0:Math.abs(_)0||g>0&&_<0)&&(s[p++]=n.ag_zeroin(b,m,0,R),p>1&&s[p-2]>=s[p-1]-u&&(s[p-2]=.5*(s[p-2]+s[p-1]),p--))}return p}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(79);Object.defineProperty(t,"device",{enumerable:!0,get:function(){return n.device}});var i=r(37);Object.defineProperty(t,"resMan",{enumerable:!0,get:function(){return i.resMan}});var a=r(19);Object.defineProperty(t,"store",{enumerable:!0,get:function(){return a.store}});var o=r(17);Object.defineProperty(t,"logger",{enumerable:!0,get:function(){return o.logger}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.device=t.Tw2Device=void 0;var n=function(){function e(e,t){for(var r=0;r1,this.canvas=t,this.Resize();return this._quadBuffer=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,this._quadBuffer),n.bufferData(n.ARRAY_BUFFER,new Float32Array([1,1,0,1,1,1,-1,1,0,1,0,1,1,-1,0,1,1,0,-1,-1,0,1,0,0]),n.STATIC_DRAW),this._cameraQuadBuffer=n.createBuffer(),this._quadDecl=new l.Tw2VertexDeclaration,this._quadDecl.elements.push(new l.Tw2VertexElement(l.Tw2VertexDeclaration.Type.POSITION,0,n.FLOAT,4,0)),this._quadDecl.elements.push(new l.Tw2VertexElement(l.Tw2VertexDeclaration.Type.TEXCOORD,0,n.FLOAT,2,16)),this._quadDecl.RebuildHash(),this._alphaTestState={},this._alphaTestState.states={},this._alphaTestState.states[this.RS_ALPHATESTENABLE]=0,this._alphaTestState.states[this.RS_ALPHAREF]=-1,this._alphaTestState.states[this.RS_ALPHAFUNC]=this.CMP_GREATER,this._alphaTestState.states[this.RS_CLIPPING]=0,this._alphaTestState.states[this.RS_CLIPPLANEENABLE]=0,this._alphaTestState.dirty=!1,this._alphaBlendState={},this._alphaBlendState.states={},this._alphaBlendState.states[this.RS_SRCBLEND]=this.BLEND_SRCALPHA,this._alphaBlendState.states[this.RS_DESTBLEND]=this.BLEND_INVSRCALPHA,this._alphaBlendState.states[this.RS_BLENDOP]=this.BLENDOP_ADD,this._alphaBlendState.states[this.RS_SEPARATEALPHABLENDENABLE]=0,this._alphaBlendState.states[this.RS_BLENDOPALPHA]=this.BLENDOP_ADD,this._alphaBlendState.states[this.RS_SRCBLENDALPHA]=this.BLEND_SRCALPHA,this._alphaBlendState.states[this.RS_DESTBLENDALPHA]=this.BLEND_INVSRCALPHA,this._alphaBlendState.dirty=!1,this._depthOffsetState={},this._depthOffsetState.states={},this._depthOffsetState.states[this.RS_SLOPESCALEDEPTHBIAS]=0,this._depthOffsetState.states[this.RS_DEPTHBIAS]=0,this._depthOffsetState.dirty=!1,this.wrapModes=[],this.wrapModes[0]=0,this.wrapModes[1]=n.REPEAT,this.wrapModes[2]=n.MIRRORED_REPEAT,this.wrapModes[3]=n.CLAMP_TO_EDGE,this.wrapModes[4]=n.CLAMP_TO_EDGE,this.wrapModes[5]=n.CLAMP_TO_EDGE,this._shadowStateBuffer=new Float32Array(24),this._blendTable=[-1,n.ZERO,n.ONE,n.SRC_COLOR,n.ONE_MINUS_SRC_COLOR,n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.DST_ALPHA,n.ONE_MINUS_DST_ALPHA,n.DST_COLOR,n.ONE_MINUS_DST_COLOR,n.SRC_ALPHA_SATURATE,-1,-1,n.CONSTANT_COLOR,n.ONE_MINUS_CONSTANT_COLOR],this.glVersion}},{key:"Schedule",value:function(e){this._scheduled.includes(e)||this._scheduled.push(e)}},{key:"OnResize",value:function(e){this._onResize=e}},{key:"Resize",value:function(){if(this.vrDisplay&&this.vrDisplay.isPresenting){var e=this.vrDisplay.getEyeParameters("left"),t=this.vrDisplay.getEyeParameters("right");this.canvas.width=2*Math.max(e.renderWidth,t.renderWidth),this.canvas.height=Math.max(t.renderHeight,t.renderHeight)}else this.canvas.width=this.canvas.offsetWidth*this.viewportPixelRatio,this.canvas.height=this.canvas.offsetHeight*this.viewportPixelRatio;this.viewportWidth=this.canvas.clientWidth,this.viewportHeight=this.canvas.clientHeight,this.viewportAspect=this.viewportWidth/this.viewportHeight,this._onResize&&this._onResize(this.viewportWidth,this.viewportHeight),a.store.SetVariableValue("ViewportSize",[this.viewportWidth,this.viewportHeight,this.viewportWidth,this.viewportHeight])}},{key:"Tick",value:function(){this.canvas.clientWidth===this.viewportWidth&&this.canvas.clientHeight===this.viewportHeight||this.Resize();var e=null===this.previousTime?0:this.previousTime,t=this.Now();this.currentTime=.001*(t-this.startTime),this.dt=null===this.previousTime?0:.001*(t-this.previousTime),this.previousTime=t,a.store.SetVariableValue("Time",[this.currentTime,this.currentTime-Math.floor(this.currentTime),this.frameCounter,e]),s.resMan.PrepareLoop(this.dt);for(var r=0;r1.6&&(r=t/1.6);var n=2*Math.atan(r/this.projection[5]);return e[0]=this.viewportWidth,e[1]=this.viewportHeight,e[2]=n,e[3]=n*t,e}},{key:"GetEyePosition",value:function(e){return i.vec3.copy(e,this.eyePosition)}},{key:"IsAlphaTestEnabled",value:function(){return this._alphaTestState.states[this.RS_ALPHATESTENABLE]}},{key:"IsFrameBufferComplete",value:function(e){return this.gl.checkFramebufferStatus(e)===this.gl.FRAMEBUFFER_COMPLETE}},{key:"GetExtension",value:function(t){for(var r in e.WebglVendorPrefixes)if(e.WebglVendorPrefixes.hasOwnProperty(r)){var n=this.gl.getExtension(e.WebglVendorPrefixes[r]+t);if(n)return n}return null}},{key:"GetFallbackTexture",value:function(){return this._fallbackTexture||(this._fallbackTexture=this.CreateSolidTexture()),this._fallbackTexture}},{key:"GetFallbackCubeMap",value:function(){return this._fallbackCube||(this._fallbackCube=this.CreateSolidCube()),this._fallbackCube}},{key:"CreateSolidTexture",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],t=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,1,1,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(e)),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.bindTexture(this.gl.TEXTURE_2D,null),t}},{key:"CreateSolidCube",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],t=this.gl.createTexture();this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP,t);for(var r=0;r<6;++r)this.gl.texImage2D(this.gl.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,this.gl.RGBA,1,1,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,new Uint8Array(e));return this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP,null),t}},{key:"RenderFullScreenQuad",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Main";if(!e||!e.IsGood())return!1;this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._quadBuffer);for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:"Main";if(!e||!e.IsGood())return!1;for(var r=new Float32Array([1,1,0,1,1,1,-1,1,0,1,0,1,1,-1,0,1,1,0,-1,-1,0,1,0,0]),n=this.projectionInverse,a=0;a<4;++a){var o=r.subarray(6*a,6*a+4);i.vec4.transformMat4(o,o,n),i.vec3.scale(o,o,1/o[3]),o[3]=1}this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._cameraQuadBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,r,this.gl.STATIC_DRAW);for(var s=0;s>16,r=(4278190080&e)>>24,n=(r<<1&255|t>>7)-127,i=(127&t)<<16|(65280&e)>>8<<8|255&e;return 0===i&&-127===n?0:(1-2*(r>>7))*(1+i*Math.pow(2,-23))*Math.pow(2,n)}},{key:"CreateContext",value:function(e,t,r){r=Array.isArray(r)?r:[r];for(var n=0;n>8&255]+a[e>>16&255]+a[e>>24&255]+"-"+a[255&t]+a[t>>8&255]+"-"+a[t>>16&15|64]+a[t>>24&255]+"-"+a[63&r|128]+a[r>>8&255]+"-"+a[r>>16&255]+a[r>>24&255]+a[255&n]+a[n>>8&255]+a[n>>16&255]+a[n>>24&255]}():i++};var n=null,i=0,a=null},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getURL=function(){return Object.assign({},n)},t.getURLString=function(e,t){return(e=e.toLowerCase())in n?n[e]:t},t.getURLInteger=function(e,t){return(e=e.toLowerCase())in n?parseInt(n[e],10):t},t.getURLFloat=function(e,t){return(e=e.toLowerCase())in n?parseFloat(n[e]):t},t.getURLBoolean=function(e,t){return(e=e.toLowerCase())in n?n[e]:t};for(var n={},i=window.location.search.substring(1).split("&"),a=0;a=r&&a.Unload()&&(n.log("res.event",{msg:"Unloaded ",path:a.path,type:"unused"}),delete this._loadedObjects[i]))}}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SamplerOverride=void 0;var n=r(0),i=r(43);t.Tw2SamplerOverride=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="",this.addressU=0,this.addressV=0,this.addressW=0,this.filter=0,this.mipFilter=0,this.lodBias=0,this.maxMipLevel=0,this.maxAnisotropy=0;var t=null;this.GetSampler=function(e){if(!t){(t=new i.Tw2SamplerState).registerIndex=e.registerIndex,t.name=e.name;var r=n.device.wrapModes,a=n.device.gl;if(1===this.filter){switch(this.mipFilter){case 0:t.minFilter=a.NEAREST;break;case 1:t.minFilter=a.NEAREST_MIPMAP_NEAREST;break;default:t.minFilter=a.NEAREST_MIPMAP_LINEAR}t.minFilterNoMips=a.NEAREST}else{switch(this.mipFilter){case 0:t.minFilter=a.LINEAR;break;case 1:t.minFilter=a.LINEAR_MIPMAP_NEAREST;break;default:t.minFilter=a.LINEAR_MIPMAP_LINEAR}t.minFilterNoMips=a.LINEAR}3!==this.filter&&3!==this.mipFilter||(t.anisotropy=Math.max(this.maxAnisotropy,1)),t.magFilter=1===this.filter?a.NEAREST:a.LINEAR,t.addressU=r[this.addressU],t.addressV=r[this.addressV],t.addressW=r[this.addressW],t.samplerType=e.samplerType,t.isVolume=e.isVolume,t.ComputeHash()}return t}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VertexDeclaration=void 0;var n=function(){function e(e,t){for(var r=0;rt)return null}if(n.usage>e)return null}return null}},{key:"SetDeclaration",value:function(t,r){for(var n=i.device.gl,a=0,o=0;o=this._elementsSorted.length){n.disableVertexAttribArray(s.location),n.vertexAttrib4f(s.location,0,0,0,0);break}var u=this._elementsSorted[a],l=e.CompareDeclarationElements(u,s);if(l>0){n.disableVertexAttribArray(s.location),n.vertexAttrib4f(s.location,0,0,0,0);break}if(0===l){u.customSetter?u.customSetter(s):(n.enableVertexAttribArray(s.location),n.vertexAttribPointer(s.location,u.elements,u.type,!1,r,u.offset));break}a++}}return!0}},{key:"SetPartialDeclaration",value:function(t,r){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=i.device.ext,s=i.device.gl,u=[],l=0,c=0;c0){a||(s.disableVertexAttribArray(f.location),s.vertexAttrib4f(f.location,0,0,0,0));break}if(++l>=this._elementsSorted.length)return a||(s.disableVertexAttribArray(f.location),s.vertexAttrib4f(f.location,0,0,0,0)),u}}return u}},{key:"ResetInstanceDivisors",value:function(e){if(e)for(var t=0;t2&&void 0!==arguments[2]?arguments[2]:0;return e.usaget.usage?1:e.usageIndex+rt.usageIndex?1:0}}]),e}()).Type={POSITION:0,COLOR:1,NORMAL:2,TANGENT:3,BINORMAL:4,TEXCOORD:5,BLENDWEIGHT:6,BLENDINDICES:7}},function(e,t,r){(function(t){WebGLDebugUtils=function(){var e;void 0===e&&(e=t);var r=function(t){e.console&&e.console.error?e.console.error(t):function(t){e.console&&e.console.log&&e.console.log(t)}(t)},n={enable:{1:{0:!0}},disable:{1:{0:!0}},getParameter:{1:{0:!0}},drawArrays:{3:{0:!0}},drawElements:{4:{0:!0,2:!0}},createShader:{1:{0:!0}},getShaderParameter:{2:{1:!0}},getProgramParameter:{2:{1:!0}},getShaderPrecisionFormat:{2:{0:!0,1:!0}},getVertexAttrib:{2:{1:!0}},vertexAttribPointer:{6:{2:!0}},bindTexture:{2:{0:!0}},activeTexture:{1:{0:!0}},getTexParameter:{2:{0:!0,1:!0}},texParameterf:{3:{0:!0,1:!0}},texParameteri:{3:{0:!0,1:!0,2:!0}},copyTexImage2D:{8:{0:!0,2:!0}},copyTexSubImage2D:{8:{0:!0}},generateMipmap:{1:{0:!0}},bindBuffer:{2:{0:!0}},getBufferParameter:{2:{0:!0,1:!0}},pixelStorei:{2:{0:!0,1:!0}},bindRenderbuffer:{2:{0:!0}},bindFramebuffer:{2:{0:!0}},checkFramebufferStatus:{1:{0:!0}},framebufferRenderbuffer:{4:{0:!0,1:!0,2:!0}},framebufferTexture2D:{5:{0:!0,1:!0,2:!0}},getFramebufferAttachmentParameter:{3:{0:!0,1:!0,2:!0}},getRenderbufferParameter:{2:{0:!0,1:!0}},renderbufferStorage:{4:{0:!0,1:!0}},clear:{1:{0:{enumBitwiseOr:["COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT"]}}},depthFunc:{1:{0:!0}},blendFunc:{2:{0:!0,1:!0}},blendFuncSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},blendEquation:{1:{0:!0}},blendEquationSeparate:{2:{0:!0,1:!0}},stencilFunc:{3:{0:!0}},stencilFuncSeparate:{4:{0:!0,1:!0}},stencilMaskSeparate:{2:{0:!0}},stencilOp:{3:{0:!0,1:!0,2:!0}},stencilOpSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},cullFace:{1:{0:!0}},frontFace:{1:{0:!0}},drawArraysInstancedANGLE:{4:{0:!0}},drawElementsInstancedANGLE:{5:{0:!0,2:!0}},blendEquationEXT:{1:{0:!0}},bufferData:{3:{0:!0,2:!0},4:{0:!0,2:!0},5:{0:!0,2:!0}},bufferSubData:{3:{0:!0},4:{0:!0},5:{0:!0}},copyBufferSubData:{5:{0:!0,1:!0}},getBufferSubData:{3:{0:!0},4:{0:!0},5:{0:!0}},blitFramebuffer:{10:{8:{enumBitwiseOr:["COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT"]},9:!0}},framebufferTextureLayer:{5:{0:!0,1:!0}},invalidateFramebuffer:{2:{0:!0}},invalidateSubFramebuffer:{6:{0:!0}},readBuffer:{1:{0:!0}},getInternalformatParameter:{3:{0:!0,1:!0,2:!0}},renderbufferStorageMultisample:{5:{0:!0,2:!0}},texStorage2D:{5:{0:!0,2:!0}},texStorage3D:{6:{0:!0,2:!0}},texImage2D:{9:{0:!0,2:!0,6:!0,7:!0},6:{0:!0,2:!0,3:!0,4:!0},10:{0:!0,2:!0,6:!0,7:!0}},texImage3D:{10:{0:!0,2:!0,7:!0,8:!0},11:{0:!0,2:!0,7:!0,8:!0}},texSubImage2D:{9:{0:!0,6:!0,7:!0},7:{0:!0,4:!0,5:!0},10:{0:!0,6:!0,7:!0}},texSubImage3D:{11:{0:!0,8:!0,9:!0},12:{0:!0,8:!0,9:!0}},copyTexSubImage3D:{9:{0:!0}},compressedTexImage2D:{7:{0:!0,2:!0},8:{0:!0,2:!0},9:{0:!0,2:!0}},compressedTexImage3D:{8:{0:!0,2:!0},9:{0:!0,2:!0},10:{0:!0,2:!0}},compressedTexSubImage2D:{8:{0:!0,6:!0},9:{0:!0,6:!0},10:{0:!0,6:!0}},compressedTexSubImage3D:{10:{0:!0,8:!0},11:{0:!0,8:!0},12:{0:!0,8:!0}},vertexAttribIPointer:{5:{2:!0}},drawArraysInstanced:{4:{0:!0}},drawElementsInstanced:{5:{0:!0,2:!0}},drawRangeElements:{6:{0:!0,4:!0}},readPixels:{7:{4:!0,5:!0},8:{4:!0,5:!0}},clearBufferfv:{3:{0:!0},4:{0:!0}},clearBufferiv:{3:{0:!0},4:{0:!0}},clearBufferuiv:{3:{0:!0},4:{0:!0}},clearBufferfi:{4:{0:!0}},beginQuery:{2:{0:!0}},endQuery:{1:{0:!0}},getQuery:{2:{0:!0,1:!0}},getQueryParameter:{2:{1:!0}},samplerParameteri:{3:{1:!0,2:!0}},samplerParameterf:{3:{1:!0}},getSamplerParameter:{2:{1:!0}},fenceSync:{2:{0:!0,1:{enumBitwiseOr:[]}}},clientWaitSync:{3:{1:{enumBitwiseOr:["SYNC_FLUSH_COMMANDS_BIT"]}}},waitSync:{3:{1:{enumBitwiseOr:[]}}},getSyncParameter:{2:{1:!0}},bindTransformFeedback:{2:{0:!0}},beginTransformFeedback:{1:{0:!0}},transformFeedbackVaryings:{3:{2:!0}},bindBufferBase:{3:{0:!0}},bindBufferRange:{5:{0:!0}},getIndexedParameter:{2:{0:!0}},getActiveUniforms:{3:{2:!0}},getActiveUniformBlockParameter:{3:{2:!0}}},i=null,a=null;function o(e){if(null==i)for(var t in i={},a={},e)"number"==typeof e[t]&&(i[e[t]]=t,a[t]=e[t])}function s(){if(null==i)throw"WebGLDebugUtils.init(ctx) not called"}function u(e){s();var t=i[e];return void 0!==t?"gl."+t:"/*UNKNOWN WebGL ENUM*/ 0x"+e.toString(16)}function l(e,t,r,i){var o;if(void 0!==(o=n[e])&&(void 0!==(o=o[t])&&o[r])){if("object"==typeof o[r]&&void 0!==o[r].enumBitwiseOr){for(var s=o[r].enumBitwiseOr,l=0,c=[],f=0;f=0&&setTimeout(function(){t.restoreContext()},v)},0)}},t.restoreContext=function(){u&&a.length&&setTimeout(function(){if(!d)throw"can not restore. webglcontestlost listener did not call event.preventDefault";!function(){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:0;this.isPlaying=!0,this.scaledTime=e}},{key:"Stop",value:function(){this.isPlaying=!1}},{key:"Update",value:function(e){if(this.isPlaying){this.scaledTime+=e*this.scale;for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:this;this._copyFunc&&(this._copyFunc.call(this),"OnValueChanged"in this.destinationObject&&this.destinationObject.OnValueChanged(e,[this.destinationAttribute]))}}],[{key:"CopyValueToValue",value:function(){this.destinationObject[this.destinationAttribute]=this.sourceObject[this.sourceAttribute]*this.scale+this.offset[0]}},{key:"CopyArray",value:function(){for(var e=Math.min(this.destinationObject[this.destinationAttribute].length,this.sourceObject[this.sourceAttribute].length),t=0;t0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.value=a.util.isArrayLike(r)?r[0]:r,n.constantBuffer=null,n.offset=null,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.Tw2Parameter),n(t,[{key:"SetValue",value:function(e){this.value=e,this.OnValueChanged()}},{key:"GetValue",value:function(){return this.value}},{key:"Apply",value:function(e,t){e[t]=this.value}},{key:"EqualsValue",value:function(e){return this.value===e}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.SetValue(e.GetValue())}}],[{key:"isValue",value:function(e){return a.util.isNumber(e)}}]),t}()).constantBufferSize=1},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MatrixParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.mat4.create();return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"Compose",value:function(e,t,r){"value"in e&&(e=e.value),"value"in t&&(t=t.value),"value"in r&&(r=r.value),i.mat4.fromRotationTranslationScale(this.value,e,t,r),this.OnValueChanged()}},{key:"Decompose",value:function(e,t,r){i.mat4.getRotation("value"in e?e.value:e,this.value),i.mat4.getTranslation("value"in t?t.value:t,this.value),i.mat4.getScaling("value"in r?r.value:r,this.value),"OnValueChanged"in e&&e.OnValueChanged(),"OnValueChanged"in t&&t.OnValueChanged(),"OnValueChanged"in r&&r.OnValueChanged()}},{key:"x",get:function(){return this.GetIndexValue(12)},set:function(e){this.SetIndexValue(12,e)}},{key:"y",get:function(){return this.GetIndexValue(13)},set:function(e){this.SetIndexValue(13,e)}},{key:"z",get:function(){return this.GetIndexValue(14)},set:function(e){this.SetIndexValue(14,e)}}]),t}()).constantBufferSize=16},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2TransformParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.scaling=i.vec3.fromValues(1,1,1),r.rotationCenter=i.vec3.create(),r.rotation=i.quat.create(),r.translation=i.vec3.create(),r.transform=i.mat4.create(),r.worldTransform=i.mat4.create(),r.constantBuffer=null,r.offset=null,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2Parameter),n(t,[{key:"Initialize",value:function(){this.OnValueChanged()}},{key:"GetValue",value:function(e){return e?Array.from(this.transform):new Float32Array(this.transform)}},{key:"OnValueChanged",value:function(e,r){i.mat4.fromRotationTranslationScaleOrigin(this.transform,this.rotation,this.translation,this.scaling,this.rotationCenter),i.mat4.transpose(this.worldTransform,this.transform),function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,r,n)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(n):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"OnValueChanged",this).call(this,e,r)}},{key:"Bind",value:function(e,t,r){return!this.constantBuffer&&r>=this.size&&(this.constantBuffer=e,this.offset=t,this.Apply(e,t,r),!0)}},{key:"Apply",value:function(e,t,r){r>=this.constructor.constantBufferSize?e.set(this.worldTransform,t):e.set(this.worldTransform.subarray(0,r),t)}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),i.quat.copy(this.rotation,e.rotation),i.vec3.copy(this.translation,e.translation),i.vec3.copy(this.scaling,e.scaling),i.vec3.copy(this.rotationCenter,e.rotationCenter),this.OnValueChanged()}}]),t}()).constantBufferSize=16},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VariableParameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.variableName=r,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2Parameter),n(t,[{key:"GetValue",value:function(e){return i.store.GetVariableValue(this.variableName,e)}},{key:"Apply",value:function(e,t,r){this.variable&&this.variable.Apply(e,t,r)}},{key:"AddCallback",value:function(){return!1}},{key:"Copy",value:function(e,t){t&&(this.name=e.name),this.variableName=e.variableName}},{key:"variable",get:function(){return i.store.GetVariable(this.variableName)}},{key:"size",get:function(){return this.variable?this.variable.size:0}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector2Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec2.fromValues(1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}}]),t}()).constantBufferSize=2},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector3Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec3.fromValues(1,1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}},{key:"z",get:function(){return this.GetIndexValue(2)},set:function(e){this.SetIndexValue(2,e)}}]),t}()).constantBufferSize=3},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector4Parameter=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.vec4.fromValues(1,1,1,1);return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Tw2VectorParameter),n(t,[{key:"x",get:function(){return this.GetIndexValue(0)},set:function(e){this.SetIndexValue(0,e)}},{key:"y",get:function(){return this.GetIndexValue(1)},set:function(e){this.SetIndexValue(1,e)}},{key:"z",get:function(){return this.GetIndexValue(2)},set:function(e){this.SetIndexValue(2,e)}},{key:"w",get:function(){return this.GetIndexValue(3)},set:function(e){this.SetIndexValue(3,e)}}]),t}()).constantBufferSize=4},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(102);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(46);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(24);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveBasicPerObjectData=t.Tw2BasicPerObjectData=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"DeclareFromObject",this).call(this,e),e.FFEData&&(this.perObjectFFEData=new s.Tw2RawData(e.FFEData))}}]),t}();t.EveBasicPerObjectData=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2BlendShapeData=void 0;var n=r(9);t.Tw2BlendShapeData=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="",this.declaration=new n.Tw2VertexDeclaration,this.buffers=[],this.indexes=null,this.weightProxy=null}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2GeometryAnimation=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="",this.duration=0,this.trackGroups=[]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2GeometryBone=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[];return i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"GetResources",this).call(this,e),this.instanceGeometryResource&&"GetResources"in this.instanceGeometryResource&&this.instanceGeometryResource.GetResources(e),e}},{key:"RenderAreas",value:function(e,t,r,n,i){if(this.IsGood()){var a=this.instanceGeometryResource.GetInstanceBuffer(this.instanceMeshIndex);a&&this.geometryResource.RenderAreasInstanced(e,t,r,n,i,a,this.instanceGeometryResource.GetInstanceDeclaration(this.instanceMeshIndex),this.instanceGeometryResource.GetInstanceStride(this.instanceMeshIndex),this.instanceGeometryResource.GetInstanceCount(this.instanceMeshIndex))}}}],[{key:"GetAreaBatches",value:function(e,t,r,n,i){for(var a=0;a0&&void 0!==arguments[0]?arguments[0]:[],t=0;tf.duration&&(c.callback&&c.callback(this,c),c.cycle?c.time=c.time%f.duration:(c.isPlaying=!1,c.time=f.duration));for(var h=0;h=0){var i=this.models[t].bones[n.boneRes.parentIndex];e.AddLine([n.worldTransform[12],n.worldTransform[13],n.worldTransform[14]],[i.worldTransform[12],i.worldTransform[13],i.worldTransform[14]])}}}}],[{key:"AddModel",value:function(e,t){for(var r=0;r7)return i.logger.log("res.error",{log:"error",src:["Tw2EffectRes","CreateProgram"],msg:"Invalid version of effect file",type:"shader.effectversion",path:this.path,value:o}),void this.PrepareFinished(!1);var s=void 0,u=void 0;if(o<5){if(0===(s=t.ReadUInt32()))return i.logger.log("res.error",{log:"error",src:["Tw2EffectRes","CreateProgram"],msg:"File contains no compiled effects",path:this.path,type:"shader.effectheadersize",value:0}),void this.PrepareFinished(!1);t.ReadUInt32();var l=t.ReadUInt32();t.cursor=8+3*s*4,u=t.ReadUInt32(),this.stringTableOffset=t.cursor,r=String.fromCharCode.apply(null,t.data.subarray(t.cursor,t.cursor+u)),t.cursor=l}else{u=t.ReadUInt32(),this.stringTableOffset=t.cursor,r=String.fromCharCode.apply(null,t.data.subarray(t.cursor,t.cursor+u)),t.cursor+=u;for(var c=t.ReadUInt8(),f=0;f6&&(h=t.ReadUInt8());for(var p=0;p6&&(d.name=l()),this.techniques[d.name]=d;for(var v=t.ReadUInt8(),m=0;m=3&&(t.ReadUInt32(),t.ReadUInt32(),t.ReadUInt32()),E.constantSize=0;for(var C=t.ReadUInt32(),I=0;IE.constantSize&&(E.constantSize=x)}}var L=t.ReadUInt32()/4;if(E.constantValues=new Float32Array(L),r<5)for(var B=0;B=4?l():"";t.ReadUInt8();var X=t.ReadUInt8(),K=t.ReadUInt8(),Q=t.ReadUInt8(),Z=t.ReadUInt8(),J=t.ReadUInt8(),$=t.ReadUInt8();t.ReadFloat32();var ee=t.ReadUInt8();t.ReadUInt8();var te=i.quat.create();te[0]=t.ReadFloat32(),te[1]=t.ReadFloat32(),te[2]=t.ReadFloat32(),te[3]=t.ReadFloat32(),t.ReadFloat32(),t.ReadFloat32(),r<4&&t.ReadUInt8();var re=new o.Tw2SamplerState;if(re.registerIndex=Y,re.name=W,1===X){switch(Q){case 0:re.minFilter=f.NEAREST;break;case 1:re.minFilter=f.NEAREST_MIPMAP_NEAREST;break;default:re.minFilter=f.NEAREST_MIPMAP_LINEAR}re.minFilterNoMips=f.NEAREST}else{switch(Q){case 0:re.minFilter=f.LINEAR;break;case 1:re.minFilter=f.LINEAR_MIPMAP_NEAREST;break;default:re.minFilter=f.LINEAR_MIPMAP_LINEAR}re.minFilterNoMips=f.LINEAR}re.magFilter=1===K?f.NEAREST:f.LINEAR,re.addressU=c[Z],re.addressV=c[J],re.addressW=c[$],3!==X&&3!==K&&3!==Q||(re.anisotropy=Math.max(ee,1));for(var ne=0;ne=3&&t.ReadUInt8(),y.stages[T]=E}y.states=[];for(var ie=t.ReadUInt8(),ae=0;ae=0){var p=new a.Tw2VertexElement(r.stages[0].inputDefinition.elements[f].usage,r.stages[0].inputDefinition.elements[f].usageIndex);p.location=h,s.input.elements.push(p)}}s.input.RebuildHash(),s.shadowStateInt=o.getUniformLocation(s.program,"ssi"),s.shadowStateFloat=o.getUniformLocation(s.program,"ssf"),s.shadowStateYFlip=o.getUniformLocation(s.program,"ssyf"),o.uniform3f(s.shadowStateYFlip,0,0,1),s.volumeSlices=[];for(var d=0;d=this.meshes.length)return!1;var c=i.device,f=c.ext,h=c.gl,p=this.meshes[e],d=n.GetPassCount(a);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,p.indexes);for(var v=0;v=this.meshes.length)return!1;var o=i.device,s=o.gl,u=this.meshes[e]||this.meshes[0],l=n.GetPassCount(a);s.bindBuffer(s.ARRAY_BUFFER,u.buffer),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,u.indexes);for(var c=0;c=this.meshes.length)return!1;var o=i.device,s=o.gl,u=this.meshes[e],l=n.GetPassCount(a);s.bindBuffer(s.ARRAY_BUFFER,u.buffer),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,u.indexes);for(var c=0;c=0){var i=this.models[t].skeleton.bones[n.parentIndex];e.AddLine([n.worldTransform[12],n.worldTransform[13],n.worldTransform[14]],[i.worldTransform[12],i.worldTransform[13],i.worldTransform[14]],[0,.7,0,1],[0,.7,0,1])}}}},{key:"Unload",value:function(){for(var e=0;e>5),s.offset=4*n,t.elements[a]=s,n+=s.elements}t.RebuildHash(),t.stride=4*n;var u=e.ReadUInt32();if(0===u)return null;for(var l=new Float32Array(n*u),c=0,f=0;f0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.cycle=e,this._onEnded=t,this.video&&this._playable?(this.video.loop=this.cycle,this.video.play()):this.playOnLoad=!0}},{key:"Pause",value:function(){this.video?this.video.pause():this.playOnLoad=!1}},{key:"Prepare",value:function(e){var t=i.device.gl;switch(e){case"mp4":case"webm":case"ogg":this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this.video),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.bindTexture(t.TEXTURE_2D,null),this.width=this.video.width,this.height=this.video.height,this.video.loop=this.cycle,this.playOnLoad&&this.video.play(),this.PrepareFinished(!0)}}},{key:"DoCustomLoad",value:function(e){var t=this,r=i.resMan.constructor.GetPathExt(e);return this.LoadStarted(),i.resMan._pendingLoads++,this.video=document.createElement("video"),this.video.crossOrigin="anonymous",this.video.muted=!0,this.video.onerror=function(){i.resMan._pendingLoads--,i.logger.log("res.error",{log:"error",src:["Tw2TextureRes","DoCustomLoad"],msg:"Error loading resource",type:"http.error",path:e}),t.LoadFinished(!1),t.PrepareFinished(!1),t.video=null},this.video.oncanplay=function(){t._playable=!0,t.video.oncanplay=null,i.resMan._pendingLoads--,i.resMan._prepareQueue.push([t,r,null]),t.LoadFinished(!0)},this.video.onended=function(){t._isPlaying=!1,t._onEnded&&t._onEnded(t)},this.video.onpause=function(){t._isPlaying=!1,t._onPause&&t._onPause(t)},this.video.onplaying=function(){t._isPlaying=!0,t._onPlaying&&t._onPlaying(t)},this.video.src=e,!0}},{key:"Unload",value:function(){return this.texture&&(i.device.gl.deleteTexture(this.texture),this.texture=null),this._isPlaying=!1,this._playable=!1,this.playOnLoad=!0,this.video=null,!0}},{key:"Bind",value:function(e){var t=i.device,r=t.gl;this.KeepAlive();var n=e.samplerType;n===r.TEXTURE_2D&&(this.texture?(this._currentTime=this.video.currentTime,r.bindTexture(r.TEXTURE_2D,this.texture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,this.video),r.bindTexture(r.TEXTURE_2D,null),r.bindTexture(n,this.texture),e.hash!==this._currentSampler&&(e.Apply(!1),this._currentSampler=e.hash)):r.bindTexture(r.TEXTURE_2D,t.GetFallbackTexture()))}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(123);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PostProcess=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Undefined error";n(this,t);var a=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return"string"==typeof e?e={message:e}:e.message=e.message||r,a.message=e.message,a.name=a.constructor.name,a.data=e,s?Error.captureStackTrace(a,t):a.stack=new Error(e.message).stack,a}return a(t,o(Error)),t}();u.isError=!0;t.HTTPRequestError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Communication error while requesting resource"))}return a(t,u),t}(),t.HTTPRequestSendError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Communication send error while requesting resource"))}return a(t,u),t}(),t.HTTPInstanceError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Could not create an XML HTTP instance"))}return a(t,u),t}(),t.HTTPStatusError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Communication status error while loading resource"))}return a(t,u),t}(),t.HTTPReadyStateError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Communication ready state error while loading resource"))}return a(t,u),t}(),t.Tw2XMLBinaryError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Invalid binary"))}return a(t,u),t}(),t.Tw2XMLObjectTypeUndefinedError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"XML Object with undefined type"))}return a(t,u),t}(),t.Tw2GeometryMeshParticleElementError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Input geometry mesh lacks element required by particle system"))}return a(t,u),t}(),t.Tw2GeometryMeshElementComponentError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Input geometry mesh elements do not have the required number of components"))}return a(t,u),t}(),t.Tw2GeometryMeshInvalidBoneError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Geometry mesh has invalid bone name for model"))}return a(t,u),t}(),t.Tw2GeometryMeshEffectBindError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Error binding geometry mesh to effect"))}return a(t,u),t}(),t.Tw2GeometryFileTypeError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Invalid geometry file type"))}return a(t,u),t}(),t.Tw2ResourcePrefixUnregisteredError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Unregistered resource prefix"))}return a(t,u),t}(),t.Tw2ResourcePrefixUndefinedError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Undefined resource prefix"))}return a(t,u),t}(),t.Tw2ResourceExtensionUnregisteredError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Unregistered resource extension"))}return a(t,u),t}(),t.Tw2ResourceExtensionUndefinedError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Undefined resource extension"))}return a(t,u),t}(),t.Tw2ShaderVersionError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Invalid version of effect file"))}return a(t,u),t}(),t.Tw2ShaderHeaderSizeError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Effect file contains no compiled effects"))}return a(t,u),t}(),t.Tw2ShaderPermutationValueError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Invalid shader permutation value"))}return a(t,u),t}(),t.Tw2ShaderCompileError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Error compiling shader"))}return a(t,u),t}(),t.Tw2ShaderLinkError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Error linking shaders"))}return a(t,u),t}(),t.Tw2DeclarationValueTypeError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Invalid declaration value type"))}return a(t,u),t}(),t.Tw2SingleInstantiationError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Multiple class instantiations not yet supported"))}return a(t,u),t}(),t.Tw2AbstractClassMethodError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Abstract class method not implemented directly on child class"))}return a(t,u),t}(),t.Tw2FeatureNotImplementedError=function(e){function t(e){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Feature not implemented"))}return a(t,u),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Tw2Float=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.value=0}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Frustum=void 0;var n=function(){function e(e,t){for(var r=0;r=a.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.vec4.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.vec4.copy(r,a.value);case t.Extrapolation.GRADIENT:return i.vec4.scaleAndAdd(r,a.value,a.right,e-a.time);default:e%=a.time}else if(e<0||e=o.time||ethis.length){if(!this.cycle)return this.reversed?i.vec4.copy(t,this.startValue):i.vec4.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec4.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a[2]=o[2]+(s[2]-o[2])*(e/l),a[3]=o[3]+(s[3]-o[3])*(e/l),a;default:return a}}}]),t}();c.inputDimension=4,c.outputDimension=4,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2EventCurve=t.Tw2EventKey=void 0;var n=function(){function e(e,t){for(var r=0;r=this.keys[this._currentKey].time;)this.value=this.keys[this._currentKey].value,++this._currentKey}}]),t}();l.dimension=1,l.outputDimension=1,l.valueProperty="value",l.curveType=i.Tw2Curve.Type.CURVE,l.Key=u,l.Extrapolation={NONE:0,CYCLE:3}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2PerlinCurve=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?(t[0]=this.startValue[0],t[1]=this.startValue[1],t[2]=this.startValue[2],t):(t[0]=this.endValue[0],t[1]=this.endValue[1],t[2]=this.endValue[2],t);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var i=0;i+1e));++i);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){a[0]=this.startValue[0],a[1]=this.startValue[1],a[2]=this.startValue[2];var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.SPHERICAL_LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),i.quat.slerp(a,o,s,e/l),a;default:return a}}}]),t}();c.inputDimension=4,c.outputDimension=4,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,SPHERICAL_LINEAR:4}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2RandomConstantCurve=void 0;var n=function(){function e(e,t){for(var r=0;r=this.states[this.states.length-1].time)r=this.states.length-1;else for(;r+1=this.states[r].time&&e=s.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.quat.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.quat.copy(r,s.value);default:e%=s.time}else if(e<0||e=u.time||e0;p--){var d=i.num.biCumulative(c,p);d>1&&i.quat.multiply(r,f,h[p]),r[0]=-h[p-1][0],r[1]=-h[p-1][1],r[2]=-h[p-1][2],r[3]=h[p-1][3],i.quat.multiply(r,r,h[p]),i.quat.pow(r,r,d),i.quat.multiply(f,f,r)}return i.quat.multiply(r,f,l.value);case t.Interpolation.SLERP:return i.quat.slerp(r,l.value,u.value,c);default:return i.quat.sqlerp(r,l.value,l.right,u.left,u.value,c)}}}]),t}();c.outputDimention=4,c.inputDimension=4,c.valueProperty="value",c.curveType=a.Tw2Curve.Type.CURVE,c.Child=l,c.Extrapolation={NONE:0,CONSTANT:1,GRADIENT:2,CYCLE:3},c.Interpolation={NONE:0,CONSTANT:1,LINEAR:2,HERMITE:3,SLERP:5,SQUAD:6}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2ScalarCurve=t.Tw2ScalarKey=void 0;var n=function(){function e(e,t){for(var r=0;r=n.time)switch(this.extrapolation){case t.Extrapolation.NONE:return this.value;case t.Extrapolation.CONSTANT:return n.value;case t.Extrapolation.GRADIENT:return n.value+(e-n.time)*n.right;default:e%=n.time}else if(e<0||e=i.time||ethis.length){if(!this.cycle)return this.reversed?this.startValue:this.endValue;e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null);var t=this.keys[0],r=this.keys[this.keys.length-1];if(e<=t.time)return this.Interpolate(e,null,t);if(e>=r.time)return this.Interpolate(e,r,null);for(var n=0;n+1e));++n);return this.Interpolate(e,t,r)}},{key:"Interpolate",value:function(e,r,n){var i=this.startValue,a=this.endValue,o=this.interpolation,s=this.length;switch(null!==r&&(o=r.interpolation,e-=r.time),o){case t.Interpolation.LINEAR:return r&&n?(i=r.value,a=n.value,s=n.time-r.time):n?(a=n.value,s=n.time):r&&(i=r.value,s=this.length-r.time),i+e/s*(a-i);case t.Interpolation.HERMITE:var u=this.startTangent,l=this.endTangent;r&&n?(i=r.value,u=r.rightTangent,a=n.value,l=n.leftTangent,s=n.time-r.time):n?(a=n.value,l=n.leftTangent,s=n.time):r&&(i=r.value,u=r.rightTangent,s=this.length-r.time);var c=e/s,f=c*c,h=f*c,p=-2*h+3*f,d=h-f;return i*(1-p)+a*p+u*(c+d-f)+l*d;default:return this.startValue}}}]),t}();l.inputDimension=1,l.outputDimension=1,l.valueProperty="currentValue",l.curveType=i.Tw2Curve.Type.CURVE2,l.Key=u,l.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2SineCurve=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?i.vec2.copy(t,this.startValue):i.vec2.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec2.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a;case t.Interpolation.HERMITE:var c=this.startTangent,f=this.endTangent;r&&n?(o=r.value,c=r.rightTangent,s=n.value,f=n.leftTangent,l=n.time-r.time):n?(s=n.value,f=n.leftTangent,l=n.time):r&&(o=r.value,c=r.rightTangent,l=this.length-r.time);var h=e/l,p=h*h,d=p*h,v=-2*d+3*p,m=1-v,y=d-p,b=h+y-p;return a[0]=o[0]*m+s[0]*v+c[0]*b+f[0]*y,a[1]=o[1]*m+s[1]*v+c[1]*b+f[1]*y,a;default:return a}}}]),t}();c.inputDimension=2,c.outputDimension=2,c.valueProperty="value",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2Vector3Curve=t.Tw2Vector3Key=void 0;var n=function(){function e(e,t){for(var r=0;rthis.length){if(!this.cycle)return this.reversed?i.vec3.copy(t,this.startValue):i.vec3.copy(t,this.endValue);e%=this.length}if(this.reversed&&(e=this.length-e),0===this.keys.length)return this.Interpolate(e,null,null,t);var r=this.keys[0],n=this.keys[this.keys.length-1];if(e<=r.time)return this.Interpolate(e,null,r,t);if(e>=n.time)return this.Interpolate(e,n,null,t);for(var a=0;a+1e));++a);return this.Interpolate(e,r,n,t)}},{key:"Interpolate",value:function(e,r,n,a){i.vec3.copy(a,this.startValue);var o=this.startValue,s=this.endValue,u=this.interpolation,l=this.length;switch(null!==r&&(u=r.interpolation,e-=r.time),u){case t.Interpolation.LINEAR:return r&&n?(o=r.value,s=n.value,l=n.time-r.time):n?(s=n.value,l=n.time):r&&(o=r.value,l=this.length-r.time),a[0]=o[0]+(s[0]-o[0])*(e/l),a[1]=o[1]+(s[1]-o[1])*(e/l),a[2]=o[2]+(s[2]-o[2])*(e/l),a;case t.Interpolation.HERMITE:var c=this.startTangent,f=this.endTangent;r&&n?(o=r.value,c=r.rightTangent,s=n.value,f=n.leftTangent,l=n.time-r.time):n?(s=n.value,f=n.leftTangent,l=n.time):r&&(o=r.value,c=r.rightTangent,l=this.length-r.time);var h=e/l,p=h*h,d=p*h,v=-2*d+3*p,m=1-v,y=d-p,b=h+y-p;return a[0]=o[0]*m+s[0]*v+c[0]*b+f[0]*y,a[1]=o[1]*m+s[1]*v+c[1]*b+f[1]*y,a[2]=o[2]*m+s[2]*v+c[2]*b+f[2]*y,a;default:return a}}}]),t}();c.inputDimension=3,c.outputDimension=3,c.valueProperty="currentValue",c.curveType=a.Tw2Curve.Type.CURVE2,c.Key=l,c.Interpolation={CONSTANT:0,LINEAR:1,HERMITE:2}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2VectorCurve=t.Tw2VectorKey=void 0;var n=function(){function e(e,t){for(var r=0;r=a.time)switch(this.extrapolation){case t.Extrapolation.NONE:return i.vec3.copy(r,this.value);case t.Extrapolation.CONSTANT:return i.vec3.copy(r,a.value);case t.Extrapolation.GRADIENT:return i.vec3.scaleAndAdd(r,a.value,a.right,e-a.time);default:e%=a.time}else if(e<0||e=o.time||e=0&&this._UpdateValue(e))}}function a(){this._id=n.util.generateID(),this.translation=n.vec3.create(),this.rotation=n.quat.create(),this.rotation[3]=1,this.scale=n.vec3.create();var e=null,t=null,r=null,i=n.mat4.create();this._TracksReady=function(){return e||t||r},this._ApplyTracks=function(n,i){for(var a=0;athis.duration||e<0||(i.curve.evaluate(this.positionCurve,e,this.translation,this.cycle,this.duration),i.curve.evaluate(this.orientationCurve,e,this.rotation,this.cycle,this.duration),i.quat.normalize(this.rotation,this.rotation),i.curve.evaluate(this.scaleCurve,e,this.scaleShear,this.cycle,this.duration),i.mat4.getScaling(this.scale,this.scaleCurve))))}},{key:"FindTracks",value:function(){for(var e=null,t=0;t=0&&(this.length=this.animationEngine.GetLength(this.xIndex)),this.yIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.yIndex))),this.zIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.zIndex))))}}]),t}();o.outputDimension=3,o.valueProperty="eulerValue",o.curveType=a.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaScalarCurve=void 0;var n=function(){function e(e,t){for(var r=0;r=0&&(this.length=this.animationEngine.GetLength(this.index))}}]),t}();a.outputDimension=1,a.valueProperty="value",a.curveType=i.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaVector3Curve=void 0;var n=function(){function e(e,t){for(var r=0;r=0&&(this.length=this.animationEngine.GetLength(this.xIndex)),this.yIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.yIndex))),this.zIndex>=0&&(this.length=Math.max(this.length,this.animationEngine.GetLength(this.zIndex))))}}]),t}();o.outputDimension=3,o.valueProperty="value",o.curveType=a.Tw2Curve.Type.CURVE_MAYA},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2MayaAnimationEngine=void 0;var n=function(){function e(e,t){for(var r=0;ri[e.AnimCurveFields.END_TIME]?i[e.AnimCurveFields.POST_INFINITY]===e.INFINITY?i[e.AnimCurveFields.END_VALUE]:this._EvaluateInfinities(i,o,a,r,!1):this._EvaluateImpl(i,o,a,r)}},{key:"_EvaluateImpl",value:function(t,r,n,i){var a=!1,o=null,s=null,u=void 0;if(this._evalCache[this._currentCurveIndex]>=0)if(s=n+this._evalCache[this._currentCurveIndex],this._evalCache[this._currentCurveIndex]r[s][e.AnimSegment.TIME]){if(i===r[o=n+this._evalCache[this._currentCurveIndex]+1][e.AnimSegment.TIME])return this._evalCache[this._currentCurveIndex]++,r[o][e.AnimSegment.VALUE];i0&&ir[l][e.AnimSegment.TIME])u=this._evalCache[this._currentCurveIndex],a=!0;else if(i===r[l][e.AnimSegment.TIME])return this._evalCache[this._currentCurveIndex]--,r[l][e.AnimSegment.VALUE]}if(!a){var c=this._Find(t,i,r,n);if(u=c[1],c[0]||0===u)return u===t[e.AnimCurveFields.NUM_SEGMENTS]?(u--,this._evalCache[this._currentCurveIndex]=u,t[e.AnimCurveFields.END_VALUE]):(this._evalCache[this._currentCurveIndex]=u,r[n+u][e.AnimSegment.VALUE]);if(u===t[e.AnimCurveFields.NUM_SEGMENTS]+1)return this._evalCache[this._currentCurveIndex]=0,t[e.AnimCurveFields.END_VALUE]}if(this._evalCache[this._currentCurveIndex]!==u-1&&(this._evalCache[this._currentCurveIndex]=u-1,s=n+this._evalCache[this._currentCurveIndex],null===o&&(o=n+u)),t[e.AnimCurveFields.IS_WEIGHTED]){var f=r[s];if(f[e.BezierSegment.IS_STEP])return f[e.BezierSegment.VALUE];if(f[e.BezierSegment.IS_STEP_NEXT])return null===o?t[e.AnimCurveFields.END_VALUE]:r[o][e.BezierSegment.VALUE];var h=t[e.AnimCurveFields.END_TIME];return this._evalCache[this._currentCurveIndex]+10){s=0,u=a-1;do{if(r<(c=(o=s+u>>1)c))return[!0,l=o];s=o+1}}while(s<=u);l=s}return[!1,l]}},{key:"GetNumberOfCurves",value:function(){return this.curves.length}},{key:"GetLength",value:function(t){if(t<0||t>=this.curves.length)return 0;var r=this.curves[t],n=void 0;return n=r[e.AnimCurveFields.IS_WEIGHTED]?this.bezierSegments[r[e.AnimCurveFields.SEGMENT_OFFSET]]:this.hermiteSegments[r[e.AnimCurveFields.SEGMENT_OFFSET]],r[e.AnimCurveFields.END_TIME]-n[e.AnimSegment.TIME]}}]),e}();a.AnimCurveFields={NUM_SEGMENTS:0,SEGMENT_OFFSET:1,END_TIME:2,END_VALUE:3,IN_TANGENT:4,OUT_TANGENT:5,PRE_INFINITY:6,POST_INFINITY:7,IS_WEIGHTED:8},a.AnimSegment={TIME:0,VALUE:1},a.HermiteSegment={TIME:0,VALUE:1,COEFF:2,IS_STEP:3,IS_STEP_NEXT:4},a.BezierSegment={TIME:0,VALUE:1,COEFF:2,POLYY:3,IS_STEP:4,IS_STEP_NEXT:5,IS_LINEAR:6},a.INFINITY=0},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(59);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(164);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(61);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(64);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(182);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(183);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveChildBillboard=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t0&&void 0!==arguments[0]?arguments[0]:[];this.mesh&&this.mesh.GetResources(e);for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return a.util.perArrayChild(this.opaqueEffects,"GetResources",e),a.util.perArrayChild(this.decalEffects,"GetResources",e),a.util.perArrayChild(this.transparentEffects,"GetResources",e),a.util.perArrayChild(this.additiveEffects,"GetResources",e),a.util.perArrayChild(this.distortionEffects,"GetResources",e),e}},{key:"Update",value:function(e){this.update&&this.curveSet&&this.curveSet.Update(e)}},{key:"GetBatches",value:function(e,t,r,n){if(this.display&&n&&n.IsGood())for(var a=this.GetEffects(e),o=0;o0&&void 0!==arguments[0]?arguments[0]:[];return this.source&&this.source.GetResources&&this.source.GetResources(e),this.dest&&this.dest.GetResources&&this.dest.GetResources(e),this.sourceObject&&this.sourceObject.GetResources&&this.sourceObject.GetResources(e),this.destObject&&this.destObject.GetResources&&this.destObject.GetResources(e),this.stretchObject&&this.stretchObject.GetResources&&this.stretchObject.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(){if(this.display){var t=e.global,r=i.vec3.subtract(t.vec3_0,this._destinationPosition,this._sourcePosition),n=i.mat4.identity(t.mat4_0),a=i.vec3.set(t.vec3_1,0,0,0),o=i.vec3.set(t.vec3_2,0,0,0),s=i.mat4.identity(t.mat4_1),u=i.vec3.length(r);i.vec3.normalize(r,r),this._useTransformsForStretch?(i.mat4.rotateX(n,n,-Math.PI/2),i.mat4.multiply(n,this._sourceTransform,n)):(Math.abs(r[1])>.9?o[2]=1:o[1]=1,i.vec3.cross(a,o,r),i.vec3.normalize(a,a),i.vec3.cross(o,r,a),n[0]=a[0],n[1]=a[1],n[2]=a[2],n[4]=-r[0],n[5]=-r[1],n[6]=-r[2],n[8]=o[0],n[9]=o[1],n[10]=o[2]),this.destObject&&this._displayDestObject&&(i.mat4.setTranslation(n,this._destinationPosition),this.destObject.UpdateViewDependentData(n)),this.sourceObject&&this._displaySourceObject&&(this._useTransformsForStretch?(i.mat4.identity(n),i.mat4.rotateX(n,n,-Math.PI/2),i.mat4.multiply(n,this._sourceTransform,n)):i.mat4.setTranslation(n,this._sourcePosition),this.sourceObject.UpdateViewDependentData(n)),this.stretchObject&&(this._useTransformsForStretch?(i.mat4.identity(n),i.mat4.scale(n,n,[1,1,u]),i.mat4.multiply(n,this._sourceTransform,n)):(n[0]=a[0],n[1]=a[1],n[2]=a[2],n[4]=o[0],n[5]=o[1],n[6]=o[2],n[8]=-r[0],n[9]=-r[1],n[10]=-r[2],this._isNegZForward&&(u=-u),i.mat4.scale(s,s,[1,1,u]),i.mat4.multiply(n,n,s)),this.stretchObject.UpdateViewDependentData(n))}}},{key:"Update",value:function(t){for(var r=0;r0&&(this._perMuzzleData[0].constantDelay=this.firingDelay1),this._perMuzzleData.length>1&&(this._perMuzzleData[1].constantDelay=this.firingDelay2),this._perMuzzleData.length>2&&(this._perMuzzleData[2].constantDelay=this.firingDelay3),this._perMuzzleData.length>3&&(this._perMuzzleData[3].constantDelay=this.firingDelay4),this._perMuzzleData.length>4&&(this._perMuzzleData[4].constantDelay=this.firingDelay5),this._perMuzzleData.length>5&&(this._perMuzzleData[5].constantDelay=this.firingDelay6),this._perMuzzleData.length>6&&(this._perMuzzleData[6].constantDelay=this.firingDelay7),this._perMuzzleData.length>7&&(this._perMuzzleData[7].constantDelay=this.firingDelay8)}},{key:"GetCurveDuration",value:function(){for(var e=0,t=0;t1&&void 0!==arguments[1]?arguments[1]:-1,r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t=this._perMuzzleData[n].elapsedTime||this.isLoopFiring)&&this.stretch[n].GetBatches(e,t,r)}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveStarField=void 0;var n=r(0);t.EveStarField=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._id=n.util.generateID(),this.name="",this.display=!0,this.effect=null,this.maxDist=0,this.maxFlashRate=0,this.minFlashIntensity=0,this.minFlashRate=0,this.seed=20}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveEffectRoot=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=0;t0&&void 0!==arguments[0]?arguments[0]:[];this.mesh&&this.mesh.GetResources(e),this.spriteSet&&this.spriteSet.GetResources(e)}},{key:"UpdateViewDependentData",value:function(){this.display&&this.state!==t.State.DEAD&&(i.mat4.transpose(this._perObjectData.perObjectVSData.Get("WorldMat"),this.transform),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("WorldMatLast"),this.transform))}},{key:"Update",value:function(e,r,n){if(this.state===t.State.IN_FLIGHT){var a=t.global,o=i.mat4.getTranslation(a.vec3_0,this.transform),s=a.vec3_1,u=a.vec3_2,l=a.vec3_3;this.time+=e,this.time>this.durationEjectPhase?(i.vec3.subtract(o,this.velocity,r),i.vec3.lerp(o,o,r,1-Math.exp(.9999*-e)),i.mat4.setTranslation(this.transform,o),i.vec3.subtract(s,n,o),i.vec3.length(s)t.length)this.warheads.splice(t.length);else for(;this.warheads.length0&&void 0!==arguments[0]?arguments[0]:[],t=0;t.1&&(i.vec3.normalize(t,t),i.vec3.scale(t,t,Math.min(e*this.speed,r)),i.vec3.add(this.position,this.position,t));for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1],a=r.itemID,o=void 0===a?0:a,s=r.planetPath,u=r.atmospherePath,l=r.heightMap1,c=r.heightMap2;this.itemID=o,this.heightMapResPath1=l,this.heightMapResPath2=c,this.highDetail.children=[],this.heightDirty=!0;var f=1;function h(){--f<1&&n&&n()}s&&f++,u&&f++,s&&i.resMan.GetObject(s,function(r){t.MeshLoaded(e,r),h()}),u&&i.resMan.GetObject(u,function(t){e.highDetail.children.push(t),h()}),i.resMan.GetObject("res:/dx9/model/worldobject/planet/planetzonly.red",function(t){e.zOnlyModel=t,h()})}},{key:"GetPlanetResources",value:function(e,t,r){if(!t.includes(e))if(t.push(e),!e||i.util.isUndefined(e.doNotPurge))for(var n in e)e.hasOwnProperty(n)&&i.util.isObjectLike(e[n])&&this.GetPlanetResources(e[n],t,r);else r.push(e)}},{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.highDetail&&this.highDetail.GetResources(e),this.effectHeight&&this.effectHeight.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(e){this.highDetail.UpdateViewDependentData(e),this.zOnlyModel&&(this.zOnlyModel.translation=this.highDetail.translation,this.zOnlyModel.scaling=this.highDetail.scaling,this.zOnlyModel.UpdateViewDependentData(e))}},{key:"Update",value:function(e){this.highDetail.Update(e)}},{key:"GetBatches",value:function(e,t){if(this.display&&this.heightDirty&&this.watchedResources.length&&""!==this.heightMapResPath1){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],r=arguments[1];i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"GetResources",this).call(this,e,r);for(var n=0;n1)for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t.visible,e.visible,["glow","symHalo","halo","trail"]),i.util.assignIfExists(t,e,["name","display","seed","wavePhase","transform","locatorName","updateFromLocator","atlas0","atlas1"]),t}}]),t}(),h=t.EveBoosterSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.visible={},e.visible.glows=!0,e.visible.symHalos=!0,e.visible.halos=!0,e.visible.trails=!0,e.effect=null,e.glows=null,e.alwaysOn=!0,e.maxVel=250,e.glowDistance=2.5,e.glowScale=1,e.glowColor=i.vec4.create(),e.warpGlowColor=i.vec4.create(),e.haloDistance=3.01,e.haloScaleX=1,e.haloScaleY=1,e.haloColor=i.vec4.create(),e.warpHaloColor=i.vec4.create(),e.symHaloDistance=3,e.symHaloScale=1,e.trailColor=i.vec4.create(),e.trailSize=i.vec4.create(),e._parentTransform=i.mat4.create(),e._positions=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,i.device.gl.FLOAT,3,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,2,12)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,20)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,4,36)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,i.device.gl.FLOAT,4,52)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,i.device.gl.FLOAT,4,68)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,i.device.gl.FLOAT,4,84)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,6,i.device.gl.FLOAT,1,100)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,7,i.device.gl.FLOAT,2,104)),e._decl.RebuildHash(),e._perObjectData=new a.Tw2PerObjectData,e._perObjectData.perObjectVSData=new a.Tw2RawData,e._perObjectData.perObjectVSData.Declare("WorldMat",16),e._perObjectData.perObjectVSData.Declare("Shipdata",4),e._perObjectData.perObjectVSData.Create(),e._locatorRebuildPending=!0,e}return l(t,o.EveObjectSet),n(t,[{key:"FindItemByLocatorName",value:function(e){for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),this.glows&&this.glows.effect.GetResources(e),e}},{key:"Update",value:function(e,t){i.mat4.copy(this._parentTransform,t),this._rebuildPending&&this.Rebuild(),this.glows&&this.glows.Update(e)}},{key:"Unload",value:function(){this._positions&&(i.device.gl.deleteBuffer(this._positions),this._positions=null),this.glows&&this.glows.Unload()}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this);var e=this._visibleItems.length;if(this._rebuildPending=!1,e){for(var r=i.device,n=t._box,a=new Float32Array(e*n.length*6*28),o=[0,3,1,3,2,1],s=0,u=0;u0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","type","position1","color1","position2","color2","intermediatePosition","width","multiColor","multiColorBorder","overlayColor","animationSpeed","animationScale","numOfSegments"]),t}}]),t}();c.Type={INVALID:0,STRAIGHT:1,SPHERED:2,CURVED:3},c.DEFAULT_CURVED_SEGMENTS=20,c.DEFAULT_SPHERED_SEGEMENTS=20;var f=t.EveCurveLineSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.lineEffect=a.Tw2Effect.create({effectFilePath:"res:/Graphics/Effect/Managed/Space/SpecialFX/Lines3D.fx",textures:{TexMap:"res:/texture/global/white.dds.0.png",OverlayTexMap:"res:/texture/global/white.dds.0.png"}}),e.pickEffect=null,e.lineWidthFactor=1,e.additive=!1,e.pickable=!0,e.depthOffset=0,e.translation=i.vec3.create(),e.rotation=i.quat.create(),e.scaling=i.vec3.fromValues(1,1,1),e.transform=i.mat4.create(),e.parentTransform=i.mat4.create(),e._vertexSize=26,e._vbSize=0,e._vb=null,e._perObjectData=new a.Tw2PerObjectData,e._perObjectData.perObjectVSData=new a.Tw2RawData,e._perObjectData.perObjectVSData.Declare("WorldMat",16),e._perObjectData.perObjectVSData.Create(),e._perObjectData.perObjectPSData=new a.Tw2RawData,e._perObjectData.perObjectPSData.Declare("WorldMat",16),e._perObjectData.perObjectPSData.Create(),e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,i.device.gl.FLOAT,3,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,4,12)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,28)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,3,44)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,4,56)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,1,i.device.gl.FLOAT,4,72)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,2,i.device.gl.FLOAT,4,88)),e._decl.stride=4*e._vertexSize,e._decl.RebuildHash(),t.init(),e}return l(t,o.EveObjectSet),n(t,[{key:"Initialize",value:function(){this.OnValueChanged(),this.Rebuild()}},{key:"AddStraightLine",value:function(e,t,r,n,i){return this.CreateItem({type:c.Type.STRAIGHT,position1:e,position2:t,color1:n,color2:i,width:r})}},{key:"AddCurvedLineCrt",value:function(e,t,r,n,i,a){return this.CreateItem({type:c.Type.CURVED,position1:e,position2:t,intermediatePosition:r,color1:i,color2:a,width:n,numOfSegments:c.DEFAULT_CURVED_SEGMENTS})}},{key:"AddCurvedLineSph",value:function(e,r,n,a,o,s,u){var l=t.global;return this.CreateItem({type:c.Type.CURVED,position1:i.vec3.fromSpherical(l.vec3_0,e,n),position2:i.vec3.fromSpherical(l.vec3_1,r,n),intermediatePosition:i.vec3.fromSpherical(l.vec3_2,a,n),color1:s,color2:u,width:o,numOfSegments:c.DEFAULT_CURVED_SEGMENTS})}},{key:"AddSpheredLineCrt",value:function(e,t,r,n,i,a){return this.CreateItem({type:c.Type.SPHERED,position1:e,position2:t,intermediatePosition:r,color1:i,color2:a,width:n,numOfSegments:c.DEFAULT_SPHERED_SEGEMENTS})}},{key:"AddSpheredLineSph",value:function(e,r,n,a,o,s,u){var l=t.global;return this.CreateItem({type:c.Type.SPHERED,position1:i.vec3.fromSpherical(l.vec3_0,e,n),position2:i.vec3.fromSpherical(l.vec3_1,r,n),intermediatePosition:i.vec3.fromSpherical(l.vec3_2,a,n),color1:s,color2:u,width:o,numOfSegments:c.DEFAULT_SPHERED_SEGEMENTS})}},{key:"OnValueChanged",value:function(){i.mat4.fromRotationTranslationScale(this.transform,this.rotation,this.translation,this.scaling),this._rebuildPending=!0}},{key:"UpdateViewDependentData",value:function(e){i.mat4.copy(this.parentTransform,e)}},{key:"Update",value:function(){this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){this._vb&&(i.device.gl.deleteBuffer(this._vb),this._vb=null)}},{key:"Rebuild",value:function(){t.RebuildItems(this),this._vb=null,this._vbSize=this.lineCount,this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=t.global,n=new Float32Array(6*this._vbSize*this._vertexSize),a=r.vec3_0,o=r.vec3_1,s=r.vec3_2,u=r.vec3_3,l=r.vec3_4,f=r.vec3_5,h=r.vec3_6,p=r.mat4_0,d=r.vec3_7,v=r.vec3_8,m=r.vec3_9,y=r.vec3_10,b=r.vec4_0,_=r.vec4_1,g=0,E=void 0,T=0;T0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","boneIndex","groupIndex","maskAtlasID","position","scaling","rotation","transform","color","layer1Transform","layer2Transform","layer1Scroll","layer2Scroll"]),t}}]),t}();(t.EvePlaneSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.effect=null,e.hideOnLowQuality=!1,e._time=0,e._vertexBuffer=null,e._indexBuffer=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,4,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,16)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,4,32)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,4,48)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,i.device.gl.FLOAT,4,64)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,i.device.gl.FLOAT,4,80)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,i.device.gl.FLOAT,4,96)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,6,i.device.gl.FLOAT,4,112)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,7,i.device.gl.FLOAT,3,128)),e._decl.RebuildHash(),e}return l(t,o.EveObjectSet),n(t,[{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),e}},{key:"Update",value:function(e){this._time+=e,this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){this._vertexBuffer&&(i.device.gl.deleteBuffer(this._vertexBuffer),this._vertexBuffer=null),this._indexBuffer&&(i.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"Rebuild",value:function(){this.Unload(),t.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=t.global.mat4_0,n=new Float32Array(4*e*35),a=0;a0&&void 0!==arguments[0]?arguments[0]:[];return this.parentGeometry&&!e.includes(this.parentGeometry)&&e.push(this.parentGeometry),this.decalEffect&&this.decalEffect.GetResources(e),this.pickEffect&&this.pickEffect.GetResources(e),e}},{key:"Unload",value:function(){this._indexBuffer&&(i.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"GetBatches",value:function(e,t,r,n){var o=void 0;switch(e){case i.device.RM_DECAL:o=this.decalEffect;break;case i.device.RM_PICKABLE:o=this.pickable?this.pickEffect:null}if(this.display&&o&&o.IsGood()&&this.indexBuffer.length&&this.parentGeometry&&this.parentGeometry.IsGood()){var s=new a.Tw2ForwardingRenderBatch;if(this._perObjectData.perObjectVSData.Set("worldMatrix",r.perObjectVSData.Get("WorldMat")),this.parentBoneIndex>=0){var u=r.perObjectVSData.Get("JointMat"),l=12*this.parentBoneIndex;if(u[l]||u[l+4]||u[l+8]){var c=this._perObjectData.perObjectVSData.Get("parentBoneMatrix");c[0]=u[l],c[1]=u[l+4],c[2]=u[l+8],c[3]=0,c[4]=u[l+1],c[5]=u[l+5],c[6]=u[l+9],c[7]=0,c[8]=u[l+2],c[9]=u[l+6],c[10]=u[l+10],c[11]=0,c[12]=u[l+3],c[13]=u[l+7],c[14]=u[l+11],c[15]=1,i.mat4.transpose(c,c)}}i.mat4.invert(this._perObjectData.perObjectVSData.Get("invWorldMatrix"),this._perObjectData.perObjectVSData.Get("worldMatrix")),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("decalMatrix"),this.decalMatrix),i.mat4.transpose(this._perObjectData.perObjectVSData.Get("invDecalMatrix"),this.invDecalMatrix),this._perObjectData.perObjectPSData.Get("displayData")[0]=n||0,this._perObjectData.perObjectPSData.Set("shipData",r.perObjectPSData.data),s.perObjectData=this._perObjectData,s.geometryProvider=this,s.renderMode=e,s.effect=o,t.Commit(s)}}},{key:"Render",value:function(e,t){var r=this.parentGeometry.meshes[0].indexes,n=this.parentGeometry.meshes[0].areas[0].start,a=this.parentGeometry.meshes[0].areas[0].count,o=this.parentGeometry.meshes[0].indexType;i.store.SetVariableValue("u_DecalMatrix",this.decalMatrix),i.store.SetVariableValue("u_InvDecalMatrix",this.invDecalMatrix),this.parentGeometry.meshes[0].indexes=this._indexBuffer,this.parentGeometry.meshes[0].areas[0].start=0,this.parentGeometry.meshes[0].areas[0].count=this.indexBuffer.length,this.parentGeometry.meshes[0].indexType=i.device.gl.UNSIGNED_SHORT,this.parentGeometry.RenderAreas(0,0,1,e.effect,t),this.parentGeometry.meshes[0].indexes=r,this.parentGeometry.meshes[0].areas[0].start=n,this.parentGeometry.meshes[0].areas[0].count=a,this.parentGeometry.meshes[0].indexType=o}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EveSpotlightSet=t.EveSpotlightSetItem=t.EveSpotlightSetBatch=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","boosterGainInfluence","boneIndex","groupIndex","coneIntensity","spriteIntensity","flareIntensity","transform","coneColor","spriteColor","flareColor","spriteScale"]),t}}]),t}();(t.EveSpotlightSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.coneEffect=null,e.glowEffect=null,e._coneVertexBuffer=null,e._spriteVertexBuffer=null,e._indexBuffer=null,e._decl=new a.Tw2VertexDeclaration,e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,i.device.gl.FLOAT,4,0)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,i.device.gl.FLOAT,4,16)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,4,32)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,i.device.gl.FLOAT,4,48)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,i.device.gl.FLOAT,3,64)),e._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,i.device.gl.FLOAT,3,76)),e._decl.RebuildHash(),e}return l(t,o.EveObjectSet),n(t,[{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.coneEffect&&this.coneEffect.GetResources(e),this.glowEffect&&this.glowEffect.GetResources(e),e}},{key:"Unload",value:function(){this._coneVertexBuffer&&(i.device.gl.deleteBuffer(this._coneVertexBuffer),this._coneVertexBuffer=null),this._spriteVertexBuffer&&(i.device.gl.deleteBuffer(this._spriteVertexBuffer),this._spriteVertexBuffer=null),this._indexBuffer&&(i.device.gl.deleteBuffer(this._indexBuffer),this._indexBuffer=null)}},{key:"Rebuild",value:function(){this.Unload(),t.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){for(var r=i.device,n=[1,0,2,3],a=new Float32Array(22*(4*e*4)),o=0;o0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","blinkRate","blinkPhase","minScale","maxScale","falloff","boneIndex","groupIndex","position","color","warpColor"]),t}}]),t}();(t.EveSpriteSet=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];s(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.effect=null,n.useQuads=null,n.isSkinned=null,n._time=0,n._vertexBuffer=null,n._indexBuffer=null,n._instanceBuffer=null,n._decl=n._decl=new a.Tw2VertexDeclaration,n._vdecl=new a.Tw2VertexDeclaration,n._vdecl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,i.device.gl.FLOAT,1,0)),n._vdecl.RebuildHash(),n.UseQuads(e,r),n}return l(t,o.EveObjectSet),n(t,[{key:"UseQuads",value:function(e,t){if(this.useQuads!==e){this.useQuads=e,this.isSkinned=t;var r=i.device.gl;this._decl.elements.splice(0,this._decl.elements.length),e?(this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,r.FLOAT,3,0)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,r.FLOAT,4,12)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,r.FLOAT,2,28)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,r.FLOAT,4,36)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,1,r.FLOAT,4,52))):(this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,5,r.FLOAT,2,0)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.POSITION,0,r.FLOAT,3,8)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.COLOR,0,r.FLOAT,3,20)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,0,r.FLOAT,1,32)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,r.FLOAT,1,36)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,2,r.FLOAT,1,40)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,3,r.FLOAT,1,44)),this._decl.elements.push(new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,4,r.FLOAT,1,48))),this._decl.RebuildHash(),this._rebuildPending=!0}}},{key:"GetResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.effect&&this.effect.GetResources(e),e}},{key:"Update",value:function(e){this._time+=e,this._rebuildPending&&this.Rebuild()}},{key:"Unload",value:function(){var e=i.device.gl;this._vertexBuffer&&(e.deleteBuffer(this._vertexBuffer),this._vertexBuffer=null),this._indexBuffer&&(e.deleteBuffer(this._indexBuffer),this._indexBuffer=null),this._instanceBuffer&&(e.deleteBuffer(this._instanceBuffer),this._instanceBuffer=null)}},{key:"Rebuild",value:function(){this.constructor.RebuildItems(this),this._rebuildPending=!1;var e=this._visibleItems.length;if(e){var t=i.device.gl;if(this.useQuads)return this._vertexBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._vertexBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,1,2,2,3,0]),t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),void(this._instanceBuffer=t.createBuffer());for(var r=new Float32Array(4*e*13),n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=new this;return i.util.assignIfExists(t,e,["name","display","locatorName","updateFromLocator","position","rotation","bone","canFireWhenHidden"]),t.UpdateTransforms(),t}}]),t}(),f=t.EveTurretSet=function(e){function t(){s(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.visible={},e.visible.turrets=!0,e.visible.firingEffects=!0,e.activeAnimation=new a.Tw2AnimationController,e.inactiveAnimation=new a.Tw2AnimationController,e.geometryResPath="",e.geometryResource=null,e.turretEffect=null,e.firingEffectResPath="",e.firingEffect=null,e.fireCallback=null,e.fireCallbackPending=!1,e.state=t.State.IDLE,e.bottomClipHeight=0,e.locatorName="",e.sysBoneHeight=0,e.hasCyclingFiringPos=!1,e.targetPosition=i.vec3.create(),e.parentMatrix=i.mat4.create(),e.boundingSphere=i.quat.create(),e._activeTurret=-1,e._recheckTimeLeft=0,e._currentCyclingFiresPos=0,e._perObjectDataActive=new a.Tw2PerObjectData,e._perObjectDataActive.perObjectVSData=new a.Tw2RawData,e._perObjectDataActive.perObjectVSData.Declare("baseCutoffData",4),e._perObjectDataActive.perObjectVSData.Declare("turretSetData",4),e._perObjectDataActive.perObjectVSData.Declare("shipMatrix",16),e._perObjectDataActive.perObjectVSData.Declare("turretTranslation",96),e._perObjectDataActive.perObjectVSData.Declare("turretRotation",96),e._perObjectDataActive.perObjectVSData.Declare("turretPoseTransAndRot",576),e._perObjectDataActive.perObjectVSData.Create(),e._perObjectDataInactive=new a.Tw2PerObjectData,e._perObjectDataInactive.perObjectVSData=new a.Tw2RawData,e._perObjectDataInactive.perObjectVSData.Declare("baseCutoffData",4),e._perObjectDataInactive.perObjectVSData.Declare("turretSetData",4),e._perObjectDataInactive.perObjectVSData.Declare("shipMatrix",16),e._perObjectDataInactive.perObjectVSData.Declare("turretTranslation",96),e._perObjectDataInactive.perObjectVSData.Declare("turretRotation",96),e._perObjectDataInactive.perObjectVSData.Declare("turretPoseTransAndRot",576),e._perObjectDataInactive.perObjectVSData.Create(),e._locatorRebuildPending=!0,e}return l(t,o.EveObjectSet),n(t,[{key:"Initialize",value:function(){var e=this;this.turretEffect&&""!==this.geometryResPath&&(this.geometryResource=i.resMan.GetResource(this.geometryResPath),this.activeAnimation.SetGeometryResource(this.geometryResource),this.inactiveAnimation.SetGeometryResource(this.geometryResource),this.geometryResource&&this.geometryResource.RegisterNotification(this)),""!==this.firingEffectResPath&&i.resMan.GetObject(this.firingEffectResPath,function(t){return e.firingEffect=t}),this.Rebuild()}},{key:"InitializeFiringEffect",value:function(){if(this.firingEffect&&this.geometryResource&&this.geometryResource.models.length)for(var e=this.geometryResource.models[0],r=0;rr&&(e=this.items.indexOf(l),r=c)}}return e}},{key:"EnterStateDeactive",value:function(){var e=this;this.state!==t.State.INACTIVE&&this.state!==t.State.PACKING&&(this.turretEffect?(this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.activeAnimation.PlayAnimation("Pack",!1,function(){e.state=t.State.INACTIVE,e.activeAnimation.PlayAnimation("Inactive",!0)}),this.inactiveAnimation.PlayAnimation("Pack",!1,function(){e.state=t.State.INACTIVE,e.inactiveAnimation.PlayAnimation("Inactive",!0)}),this.state=t.State.PACKING):this.state=t.State.INACTIVE,this._activeTurret=-1,this.firingEffect&&this.firingEffect.StopFiring())}},{key:"EnterStateIdle",value:function(){var e=this;this.state!==t.State.IDLE&&this.state!==t.State.UNPACKING&&(this.turretEffect?(this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.state===t.State.FIRING?(this.activeAnimation.PlayAnimation("Active",!0),this.inactiveAnimation.PlayAnimation("Active",!0)):(this.activeAnimation.PlayAnimation("Deploy",!1,function(){e.state=t.State.IDLE,e.activeAnimation.PlayAnimation("Active",!0)}),this.inactiveAnimation.PlayAnimation("Deploy",!1,function(){e.state=t.State.IDLE,e.inactiveAnimation.PlayAnimation("Active",!0)})),this.state=t.State.UNPACKING):this.state=t.State.IDLE,this._activeTurret=-1,this.firingEffect&&this.firingEffect.StopFiring())}},{key:"EnterStateFiring",value:function(){var e=this;if(!this.turretEffect||this.state===t.State.FIRING)return t.DoStartFiring(this),void(this.turretEffect&&this.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)}));this.activeAnimation.StopAllAnimations(),this.inactiveAnimation.StopAllAnimations(),this.state===t.State.INACTIVE?(this.activeAnimation.PlayAnimation("Deploy",!1,function(){t.DoStartFiring(e),e.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)})}),this.inactiveAnimation.PlayAnimation("Deploy",!1,function(){e.inactiveAnimation.PlayAnimation("Active",!0)}),this.state=t.State.UNPACKING):(t.DoStartFiring(this),this.activeAnimation.PlayAnimation("Fire",!1,function(){e.activeAnimation.PlayAnimation("Active",!0)}),this.inactiveAnimation.PlayAnimation("Active",!0))}},{key:"RebuildCachedData",value:function(){for(var e=new a.Tw2VertexElement(a.Tw2VertexDeclaration.Type.TEXCOORD,1,i.device.gl.FLOAT,2),r=this.geometryResource.meshes,n=this.activeAnimation,o=this.inactiveAnimation,s=0;s0&&void 0!==arguments[0]?arguments[0]:[];return this.geometryResource&&!e.includes(this.geometryResource)&&e.push(this.geometryResource),this.turretEffect&&this.turretEffect.GetResources(e),this.firingEffect&&this.firingEffect.GetResources(e),e}},{key:"UpdateViewDependentData",value:function(){this.firingEffect&&this.firingEffect.UpdateViewDependentData()}},{key:"Update",value:function(e,r){if(this._rebuildPending&&this.Rebuild(),this.turretEffect&&(this.activeAnimation.Update(e),this.inactiveAnimation.Update(e)),i.mat4.copy(this.parentMatrix,r),this.firingEffect&&this._visibleItems.length){if(-1!==this._activeTurret){this.firingEffect.isLoopFiring&&this.state===t.State.FIRING&&(this._recheckTimeLeft-=e,this._recheckTimeLeft<=0&&t.DoStartFiring(this));var n=this.items[this._activeTurret];if(this.activeAnimation.models.length)for(var a=this.activeAnimation.models[0].bonesByName,o=0;o0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1],r=0;r2&&void 0!==arguments[2]?arguments[2]:this._batches,n=0;n=0&&(u=e.substr(0,s+1)+o+"/"+e.substr(s+1)),(s=u.lastIndexOf("_"))>=0){u=u.substr(0,s)+"_"+o+u.substr(s);var l=r(n,"textureOverrides",{});if(t in l&&i.name in l[t])return u}}return e}function f(e,t){var r=l(t),n=(e="/"+e).lastIndexOf("/");return e.substr(0,n+1)+r+e.substr(n+1)}function h(e,t){for(var r=0;r=0&&s=0?r||T:t||(r||T);case"not_overridable":case"half_overridable_2":return r||T}return T}function w(t,r,a){var o=e.faction[r],s=e.faction[a],u=null;o&&o.areas&&"hull"in o.areas&&(u=o.areas.hull);var l=null;if(s&&s.areas&&"hull"in s.areas&&(l=s.areas.hull),(u||l)&&t.turretEffect){var c=t.turretEffect.parameters;for(var f in c)if(c.hasOwnProperty(f)){if(c[f].constructor.prototype!==i.Tw2Vector4Parameter.prototype)continue;var h=null,p=null;u&&(h=E(f,o,u)),l&&(p=E(f,o,u)),n.vec4.copy(c[f].value,O(f,h,p,t.turretEffect.name))}t.turretEffect.BindParameters()}}function S(t){if("all"!==t){var r={};for(var n in e[t])e[t].hasOwnProperty(n)&&(r[n]=e[t][n].description||"");return r}return e}this.SetupTurretMaterial=function(t,r,n,i){null===e?this.LoadData(function(){w(t,r,n),i&&i()}):(w(t,r,n),i&&i())},this.GetHullNames=function(e){this.LoadData(function(){e(S("hull"))})},this.GetFactionNames=function(e){this.LoadData(function(){e(S("faction"))})},this.GetRaceNames=function(e){this.LoadData(function(){e(S("race"))})},this.GetSofData=function(e){this.LoadData(function(){e(S("all"))})}};var n=r(0),i=r(1),a=r(58),o=r(64),s=r(59),u=r(61)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(185);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(189);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(196);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var o=r(200);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var s=r(201);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var u=r(14);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(186);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var i=r(187);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(188);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Tw2StaticEmitter=void 0;var n=function(){function e(e,t){for(var r=0;rthis.geometryIndex&&this.geometryResource.meshes[this.geometryIndex].bufferData){this._spawned=!0;for(var e=this.geometryResource.meshes[this.geometryIndex],t=this.particleSystem.elements,r=new Array(t.length),n=0;n=this.maxParticleCount?null:this.aliveCount++}},{key:"EndSpawnParticle",value:function(){this.bufferDirty=!0}},{key:"Update",value:function(t){if(t=Math.min(t,.1),this.applyAging&&this.HasElement(o.Tw2ParticleElementDeclaration.Type.LIFETIME)){for(var r=this.GetElement(o.Tw2ParticleElementDeclaration.Type.LIFETIME),n=this.emitParticleOnDeathEmitter?this.GetElement(o.Tw2ParticleElementDeclaration.Type.POSITION):null,a=this.emitParticleOnDeathEmitter?this.GetElement(o.Tw2ParticleElementDeclaration.Type.VELOCITY):null,s=0;s1){if(this.emitParticleOnDeathEmitter&&this.emitParticleOnDeathEmitter.SpawnParticles(n,a,1),this.aliveCount--,s=n&&t>=n)return et?1:0;if(e>=n)return 1;if(t>=n)return-1;var r=a[e],i=a[t];return ri?-1:0})}},{key:"GetInstanceBuffer",value:function(){if(0!==this.aliveCount){var e=i.device.gl;if(this.requiresSorting&&this.HasElement(o.Tw2ParticleElementDeclaration.Type.POSITION)&&this.buffers){this._Sort();for(var t=this.instanceStride[0],r=this.buffers[0],n=0;n} watchedResources + * @property {Array.} watchedResources * @class */ export class EvePlanet extends EveObject @@ -38,28 +38,64 @@ export class EvePlanet extends EveObject } /** - * Creates the planet - * @param {number} itemID - the item id is used for randomization - * @param {string} planetPath - .red file for a planet, or planet template - * @param {string} [atmospherePath] - optional .red file for a planet's atmosphere - * @param {string} heightMap1 - * @param {string} heightMap2 + * Creates the planet from an options object + * @param {{}} options={} - an object containing the planet's options + * @param {number} options.itemID - the item id is used for randomization + * @param {string} options.planetPath - .red file for a planet, or planet template + * @param {string} [options.atmospherePath] - optional .red file for a planet's atmosphere + * @param {string} options.heightMap1 - the planet's first height map + * @param {string} options.heightMap2 - the planet's second height map + * @param {function} [onLoaded] - an optional callback which is fired when the planet has loaded */ - Create(itemID, planetPath, atmospherePath, heightMap1, heightMap2) + Create(options={}, onLoaded) { + const {itemID=0, planetPath, atmospherePath, heightMap1, heightMap2} = options; + this.itemID = itemID; this.heightMapResPath1 = heightMap1; this.heightMapResPath2 = heightMap2; this.highDetail.children = []; this.heightDirty = true; - resMan.GetObject(planetPath, obj => EvePlanet.MeshLoaded(this, obj)); - resMan.GetObject('res:/dx9/model/worldobject/planet/planetzonly.red', obj => this.zOnlyModel = obj); + let loadingParts = 1; + if (planetPath) loadingParts++; + if (atmospherePath) loadingParts++; + + /** + * Handles the optional onLoaded callback which is fired when all parts have loaded + */ + function onPartLoaded() + { + loadingParts--; + if (loadingParts < 1 && onLoaded) + { + onLoaded(); + } + } + + if (planetPath) + { + resMan.GetObject(planetPath, obj => + { + EvePlanet.MeshLoaded(this, obj); + onPartLoaded(); + }); + } if (atmospherePath) { - resMan.GetObject(atmospherePath, obj => this.highDetail.children.push(obj)); + resMan.GetObject(atmospherePath, obj => + { + this.highDetail.children.push(obj); + onPartLoaded(); + }); } + + resMan.GetObject('res:/dx9/model/worldobject/planet/planetzonly.red', obj => + { + this.zOnlyModel = obj; + onPartLoaded(); + }); } /** diff --git a/src/global/util/type.js b/src/global/util/type.js index 48ee782..7123253 100644 --- a/src/global/util/type.js +++ b/src/global/util/type.js @@ -27,6 +27,16 @@ export function isBoolean(a) return isTag(a, '[object Boolean]'); } +/** + * Checks if a value is an html canvas element + * @param {*} a + * @returns {boolean} + */ +export function isCanvas(a) +{ + return !!(a && a instanceof HTMLCanvasElement); +} + /** * Checks if a value is a descriptor * @author jay phelps From 78aa81b2bfaf309c459ac86ff3229aace1ce0ca8 Mon Sep 17 00:00:00 2001 From: cppctamber Date: Sun, 19 Aug 2018 20:11:41 +1200 Subject: [PATCH 04/25] Updated ccpwgl.setResourcePath to reflect past changes --- dist/ccpwgl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/ccpwgl.js b/dist/ccpwgl.js index 4a5353e..933c525 100644 --- a/dist/ccpwgl.js +++ b/dist/ccpwgl.js @@ -303,7 +303,7 @@ var ccpwgl = (function(ccpwgl_int) */ ccpwgl.setResourcePath = function(namespace, path) { - ccpwgl_int.resMan.resourcePaths[namespace] = path; + ccpwgl_int.store.RegisterPath(namespace, path); }; /** From 0df8a0481b49e822ee0c915733011cacbda85b4b Mon Sep 17 00:00:00 2001 From: cppctamber Date: Sun, 9 Sep 2018 14:15:09 +1200 Subject: [PATCH 05/25] Updated Resources and Resource manager, and minor fixes Demos === - Added Vanilla Toasts https://github.com/AlexKvazos/Toasts - Added toasts for error and warning messages so users can see them without using the console - Fixed `camera.focus` so that it actually works (`ccpwgl.js`, `sof.html`, `typeids.html`) - Stopped camera focus from changing the camera's distance when you haven't changed hulls - Added `autoPlane` to `camera.focus` to fix visual issues where the target object is too big - Beautified code Tw2Device === - `Tw2Device` is now an event emitter so you can listen to events - Added `resize` event which is fired when the canvas is resized - Added `context` event which is fired when context is created - Added `tick` event which is fired per tick Tw2ResMan === - `Tw2ResMan` is now an event emitter so you can listen to events - Added `OnResError` which is fired on resource errors - Added `OnResEvent` which is fired on resource events - Replaced logs with errors in preparation for Promises - Added `Try/Catch` blocks in preparation for Promises - Added `onRejected` callback to `GetObject` so you can catch errors - Errors are now handled correctly in the resMan per frame update - Simplified per frame updates Tw2MotherLode === - Added `HasErrors` function which checks a path for errors - Updated `PurgeInactive` function so that it uses new resource methods - Updated `Tw2MotherLode` to normalize error data Tw2Resource === - Replaced logs with errors in preparation for Promises - Added `GetErrors` function which returns any resource errors - Added `HasErrors` function which checks if a resource has errors - Added `OnError` which is fired on errors - Added `OnResError` for notifications error handling - Added `OnUnloaded` which is fired when resources are purged or unloaded - Replaced `LoadStarted` with `OnRequested` - Replaced `LoadFinished` with `OnError` and `OnLoaded` - Replaced `PrepareFinished` with `OnError` and `OnPrepared` - Added `onRejected` callback to `Tw2LoadingObject` so you can catch errors Tw2Store === - `Tw2Store` is now an event emitter so you can listen to events - Replaced logs with events Tw2Logger === - Simplified `Tw2Logger` - Removed most direct references in preparation for user defined loggers EveSOF === - Updated `EveSOF` so it doesn't throw errors when trying to bind unsupported elements - Updated `EveSOF` to log a warning when an unsupported element cannot be bound Tw2ObjectReader === - Replaced logs with errors - Fixed `Tw2ObjectReader.DEBUG_ENABLED` mode so it actually works Misc === - Added `template` to utils and `Tw2Error` - Added `isError` to utils - Fixed error in `Tw2ParticleElement` - Fixed error in `EveMissile` - Beautified code --- .eslintrc | 2 +- demos/cubeofdeath.html | 6 +- demos/demos.css | 137 +- demos/demos.js | 342 +- demos/explosions.html | 4 +- demos/firing.html | 10 +- demos/fitting.html | 16 +- demos/index.html | 120 +- demos/sof.html | 27 +- demos/sun.html | 4 +- demos/tech3.html | 8 +- demos/typeids.html | 54 +- dist/ccpwgl.js | 93 +- dist/ccpwgl_int.js | 4559 +++++++++++---------- dist/ccpwgl_int.min.js | 2 +- src/core/Tw2Error.js | 32 +- src/core/Tw2EventEmitter.js | 21 +- src/core/data/Tw2RawData.js | 3 +- src/core/reader/Tw2ObjectReader.js | 79 +- src/core/resource/Tw2EffectRes.js | 55 +- src/core/resource/Tw2GeometryRes.js | 71 +- src/core/resource/Tw2LoadingObject.js | 96 +- src/core/resource/Tw2Resource.js | 133 +- src/core/resource/Tw2Shader.js | 106 +- src/core/resource/Tw2TextureRes.js | 53 +- src/core/resource/Tw2VideoRes.js | 47 +- src/curve/maya/Tw2MayaAnimationEngine.js | 3 +- src/eve/EveSOF.js | 33 +- src/eve/object/EveMissile.js | 2 - src/eve/object/EvePlanet.js | 4 +- src/global/engine/Tw2Device.js | 34 +- src/global/engine/Tw2Logger.js | 68 +- src/global/engine/Tw2MotherLode.js | 40 +- src/global/engine/Tw2ResMan.js | 343 +- src/global/engine/Tw2Store.js | 62 +- src/global/util/obj.js | 35 + src/global/util/type.js | 10 + src/particle/Tw2ParticleElement.js | 2 +- src/particle/emitters/Tw2StaticEmitter.js | 52 +- webpack.config.js | 2 +- 40 files changed, 3620 insertions(+), 3150 deletions(-) diff --git a/.eslintrc b/.eslintrc index beec9b8..cd8b8ae 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,5 +1,5 @@ { - "parser" : "babel-eslint", + "parser": "babel-eslint", "parserOptions": { "sourceType": "module" }, diff --git a/demos/cubeofdeath.html b/demos/cubeofdeath.html index c5c27e1..578d750 100644 --- a/demos/cubeofdeath.html +++ b/demos/cubeofdeath.html @@ -27,7 +27,7 @@ function sofDataReceived(member) { - return function (data) + return function(data) { sofData[member] = []; for (var i in data) @@ -44,7 +44,7 @@ var y = 0; var z = 0; var cubeDimension = Math.ceil(Math.pow(shipCount, 1 / 3)); - var radius = ( cubeDimension - 1 ) / 2 * spacing; + var radius = (cubeDimension - 1) / 2 * spacing; for (i = 0; i < shipCount; ++i) { @@ -82,7 +82,7 @@ if (demos.options.postprocess) ccpwgl.enablePostprocessing(true); - ccpwgl.onPreRender = function () + ccpwgl.onPreRender = function() { document.getElementById('loading').style.display = ccpwgl.isLoading() ? 'block' : 'none'; }; diff --git a/demos/demos.css b/demos/demos.css index a54b34a..87958e6 100644 --- a/demos/demos.css +++ b/demos/demos.css @@ -5,37 +5,40 @@ html { } body { - background-color:black; - margin:0; + background-color: black; + margin: 0; } * { box-sizing: border-box; } + #toolbox { position: fixed; right: 0; top: 0; bottom: 0; width: 44px; - color:#ffffff; + color: #ffffff; background: #222; padding: 2px; border-left: solid 1px #3c3c3c; } -#toolbox>div { +#toolbox > div { transform: rotate(90deg); transform-origin: top left; display: inline-block; margin-left: 100%; margin-bottom: 10px; } -#toolbox>div:after { + +#toolbox > div:after { content: ""; float: left; margin-top: 100%; } + #toolbox button { height: 40px; border-top: none; @@ -49,6 +52,7 @@ button, input, select { border: 1px solid; font-size: 1em; } + button.default { font-weight: bold; } @@ -60,14 +64,13 @@ button.default { top: 0; bottom: 0; width: 40%; - color:#ffffff; + color: #ffffff; background: linear-gradient(to right, rgba(60, 60, 60, 0.5) 0, rgba(34, 34, 34, 1) 100%); margin: 0; flex-direction: column; border: solid 1px #3c3c3c; } - @media (max-width: 1000px) { .pane { width: auto; @@ -75,7 +78,6 @@ button.default { } } - .pane.visible { display: flex; } @@ -87,16 +89,15 @@ button.default { font-weight: bold; } -.pane>* { +.pane > * { padding: 7px; } - #mainCanvas { border: none; - position:fixed; - width:100%; - height:100% + position: fixed; + width: 100%; + height: 100% } .flex-vertical { @@ -114,15 +115,16 @@ button.default { } #loading { - display:block; - position:fixed; - left:0; - bottom:0; + display: block; + position: fixed; + left: 0; + bottom: 0; } .sof-tree { padding-left: 0; } + .sof-tree ul { padding-left: 12px; } @@ -157,9 +159,11 @@ button.default { .sof-tree li { list-style: none; } + .sof-tree ul { display: none; } + .sof-tree .node.expanded > ul { display: block; } @@ -188,3 +192,102 @@ button.default { .sof-tree li.leaf a { text-decoration: underline; } + +#toasts-container { + position: fixed; + top: 0; + left: 0; + width: 650px; +} + +.toasts-toast { + position: relative; + padding: 25px 35px; + margin: 5px; + border-radius: 1px; + background: #000; + cursor: pointer; + box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1); + animation-duration: .3s; + animation-name: Toasts; + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); +} + +.toasts-fadeOut { + animation-name: ToastsFadeOut; + animation-duration: .3s; + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-fill-mode: forwards; +} + +#toasts-container p, +#toasts-container h4 { + margin: 3px 0 !important; +} + +.toasts-title { + font-weight: 900; + font-size: 16px; + margin-bottom: 10px; + color: #FFF; +} + +.toasts-text { + font-size: 11px; + color: #aaa; +} + +.toasts-icon { + position: absolute; + top: 5px; + left: -40px; + width: 50px; + height: 50px; + border-radius: 100%; + box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1); + background: #FFF; +} + +.toasts-toast a, .toasts-toast a:hover { + color: #549EDB !important; + text-decoration: none !important; +} + +/** toast types */ +.toasts-success { + border-bottom: 2px solid #51C625; +} + +.toasts-warning { + border-bottom: 2px solid #DB9215; +} + +.toasts-error { + border-bottom: 2px solid #DB2B1D; +} + +.toasts-info { + border-bottom: 2px solid #27ABDB; +} + +@keyframes Toasts { + from { + transform: translate3d(400px, 0, 0);; + opacity: 0; + } + to { + transform: translate3d(0, 0, 0); + opacity: 1; + } +} + +@keyframes ToastsFadeOut { + from { + transform: translate3d(0, 0, 0); + opacity: 1; + } + to { + transform: translate3d(400px, 0, 0); + opacity: 0; + } +} \ No newline at end of file diff --git a/demos/demos.js b/demos/demos.js index b2f6dd6..891d711 100644 --- a/demos/demos.js +++ b/demos/demos.js @@ -1,66 +1,101 @@ - -var demos = new function () { +var demos = new function() +{ var self = this; this.options = {}; - try { + try + { this.options = JSON.parse(localStorage.ccpwgloptions); } - catch (e) { + catch (e) + { } - function decodeUrlOptions() { + function decodeUrlOptions() + { var match, - pl = /\+/g, // Regex for replacing addition symbol with a space + pl = /\+/g, // Regex for replacing addition symbol with a space search = /([^&=]+)=?([^&]*)/g, - decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); }, - query = window.location.search.substring(1); + decode = function(s) { return decodeURIComponent(s.replace(pl, " ")); }, + query = window.location.search.substring(1); self.options = {}; - while (match = search.exec(query)) { + while (match = search.exec(query)) + { self.options[decode(match[1])] = decode(match[2]); } } - function saveOptions() { + function saveOptions() + { localStorage.ccpwgloptions = JSON.stringify(self.options); } - function onPopState(state) { - if (state) { + function onPopState(state) + { + if (state) + { self.options = state.options || {}; } decodeUrlOptions(); saveOptions(); } - $(window).bind('popstate', function (event) { + $(window).bind('popstate', function(event) + { onPopState(event.originalEvent.state); }); onPopState(history.state); - if ('resUrl' in this.options) { + if ('resUrl' in this.options) + { ccpwgl.setResourcePath('res', this.options.resUrl); //this.options.resUrl = 'http://developers.eveonline.com/ccpwgl/assetpath/860161/';// window.location.protocol + '//' + window.location.host + ':8880/'; } - window.addEventListener('load', function () { + window.addEventListener('load', function() + { var settings = [ - {label: 'Shader Quality', member: 'shaderQuality', options: [{label: 'High', value: ccpwgl.ShaderQuality.HIGH}, {label: 'Low', value: ccpwgl.ShaderQuality.LOW}]}, - {label: 'Texture Quality', member: 'textureQuality', options: [{label: 'High', value: ccpwgl.TextureQuality.HIGH}, {label: 'Medium', value: ccpwgl.TextureQuality.MEDIUM}, {label: 'Low', value: ccpwgl.TextureQuality.LOW}]}, - {label: 'Texture Filtering', member: 'anisotropicFilter', options: [{label: 'Anisotropic', value: '1'}, {label: 'Linear', value: ''}]}, - {label: 'Post-processing', member: 'postprocess', options: [{label: 'On', value: '1'}, {label: 'Off', value: ''}]} + { + label: 'Shader Quality', + member: 'shaderQuality', + options: [{label: 'High', value: ccpwgl.ShaderQuality.HIGH}, { + label: 'Low', + value: ccpwgl.ShaderQuality.LOW + }] + }, + { + label: 'Texture Quality', + member: 'textureQuality', + options: [{label: 'High', value: ccpwgl.TextureQuality.HIGH}, { + label: 'Medium', + value: ccpwgl.TextureQuality.MEDIUM + }, {label: 'Low', value: ccpwgl.TextureQuality.LOW}] + }, + { + label: 'Texture Filtering', + member: 'anisotropicFilter', + options: [{label: 'Anisotropic', value: '1'}, {label: 'Linear', value: ''}] + }, + { + label: 'Post-processing', + member: 'postprocess', + options: [{label: 'On', value: '1'}, {label: 'Off', value: ''}] + } ]; var $toolbox = $('#toolbox'); - if (!$toolbox.length) { + if (!$toolbox.length) + { $toolbox = $('
').appendTo($(document.body)); } $toolbox.append($('
')); var $pane = $('
Settings
'); - for (var i = 0; i < settings.length; ++i) { + for (var i = 0; i < settings.length; ++i) + { var $select = $('