index.js 112 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = Object.setPrototypeOf ||
  3. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5. return function (d, b) {
  6. extendStatics(d, b);
  7. function __() { this.constructor = d; }
  8. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9. };
  10. })();
  11. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  12. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  13. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  14. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  15. return c > 3 && r && Object.defineProperty(target, key, r), r;
  16. };
  17. if(typeof require !== 'undefined'){
  18. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : this);
  19. var BABYLON = globalObject["BABYLON"] || {};
  20. var BABYLON0 = require('babylonjs/targetCamera');
  21. if(BABYLON !== BABYLON0) __extends(BABYLON, BABYLON0);
  22. var BABYLON;
  23. (function (BABYLON) {
  24. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  25. function ArcRotateCameraKeyboardMoveInput() {
  26. this._keys = new Array();
  27. this.keysUp = [38];
  28. this.keysDown = [40];
  29. this.keysLeft = [37];
  30. this.keysRight = [39];
  31. this.keysReset = [220];
  32. this.panningSensibility = 50.0;
  33. this.zoomingSensibility = 25.0;
  34. this.useAltToZoom = true;
  35. }
  36. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  37. var _this = this;
  38. if (this._onCanvasBlurObserver) {
  39. return;
  40. }
  41. this._scene = this.camera.getScene();
  42. this._engine = this._scene.getEngine();
  43. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  44. _this._keys = [];
  45. });
  46. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  47. var evt = info.event;
  48. if (info.type === BABYLON.KeyboardEventTypes.KEYDOWN) {
  49. _this._ctrlPressed = evt.ctrlKey;
  50. _this._altPressed = evt.altKey;
  51. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  52. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  53. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  54. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  55. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  56. var index = _this._keys.indexOf(evt.keyCode);
  57. if (index === -1) {
  58. _this._keys.push(evt.keyCode);
  59. }
  60. if (evt.preventDefault) {
  61. if (!noPreventDefault) {
  62. evt.preventDefault();
  63. }
  64. }
  65. }
  66. }
  67. else {
  68. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  69. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  70. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  71. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  72. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  73. var index = _this._keys.indexOf(evt.keyCode);
  74. if (index >= 0) {
  75. _this._keys.splice(index, 1);
  76. }
  77. if (evt.preventDefault) {
  78. if (!noPreventDefault) {
  79. evt.preventDefault();
  80. }
  81. }
  82. }
  83. }
  84. });
  85. };
  86. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  87. if (this._scene) {
  88. if (this._onKeyboardObserver) {
  89. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  90. }
  91. if (this._onCanvasBlurObserver) {
  92. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  93. }
  94. this._onKeyboardObserver = null;
  95. this._onCanvasBlurObserver = null;
  96. }
  97. this._keys = [];
  98. };
  99. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  100. if (this._onKeyboardObserver) {
  101. var camera = this.camera;
  102. for (var index = 0; index < this._keys.length; index++) {
  103. var keyCode = this._keys[index];
  104. if (this.keysLeft.indexOf(keyCode) !== -1) {
  105. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  106. camera.inertialPanningX -= 1 / this.panningSensibility;
  107. }
  108. else {
  109. camera.inertialAlphaOffset -= 0.01;
  110. }
  111. }
  112. else if (this.keysUp.indexOf(keyCode) !== -1) {
  113. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  114. camera.inertialPanningY += 1 / this.panningSensibility;
  115. }
  116. else if (this._altPressed && this.useAltToZoom) {
  117. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  118. }
  119. else {
  120. camera.inertialBetaOffset -= 0.01;
  121. }
  122. }
  123. else if (this.keysRight.indexOf(keyCode) !== -1) {
  124. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  125. camera.inertialPanningX += 1 / this.panningSensibility;
  126. }
  127. else {
  128. camera.inertialAlphaOffset += 0.01;
  129. }
  130. }
  131. else if (this.keysDown.indexOf(keyCode) !== -1) {
  132. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  133. camera.inertialPanningY -= 1 / this.panningSensibility;
  134. }
  135. else if (this._altPressed && this.useAltToZoom) {
  136. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  137. }
  138. else {
  139. camera.inertialBetaOffset += 0.01;
  140. }
  141. }
  142. else if (this.keysReset.indexOf(keyCode) !== -1) {
  143. camera.restoreState();
  144. }
  145. }
  146. }
  147. };
  148. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  149. return "ArcRotateCameraKeyboardMoveInput";
  150. };
  151. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  152. return "keyboard";
  153. };
  154. __decorate([
  155. BABYLON.serialize()
  156. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  157. __decorate([
  158. BABYLON.serialize()
  159. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  160. __decorate([
  161. BABYLON.serialize()
  162. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  163. __decorate([
  164. BABYLON.serialize()
  165. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  166. __decorate([
  167. BABYLON.serialize()
  168. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  169. __decorate([
  170. BABYLON.serialize()
  171. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  172. __decorate([
  173. BABYLON.serialize()
  174. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  175. __decorate([
  176. BABYLON.serialize()
  177. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  178. return ArcRotateCameraKeyboardMoveInput;
  179. }());
  180. BABYLON.ArcRotateCameraKeyboardMoveInput = ArcRotateCameraKeyboardMoveInput;
  181. BABYLON.CameraInputTypes["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  182. })(BABYLON || (BABYLON = {}));
  183. //# sourceMappingURL=babylon.arcRotateCameraKeyboardMoveInput.js.map
  184. var BABYLON;
  185. (function (BABYLON) {
  186. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  187. function ArcRotateCameraMouseWheelInput() {
  188. this.wheelPrecision = 3.0;
  189. /**
  190. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  191. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  192. */
  193. this.wheelDeltaPercentage = 0;
  194. }
  195. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  196. var _this = this;
  197. this._wheel = function (p, s) {
  198. //sanity check - this should be a PointerWheel event.
  199. if (p.type !== BABYLON.PointerEventTypes.POINTERWHEEL)
  200. return;
  201. var event = p.event;
  202. var delta = 0;
  203. if (event.wheelDelta) {
  204. delta = _this.wheelDeltaPercentage ? (event.wheelDelta * 0.01) * _this.camera.radius * _this.wheelDeltaPercentage : event.wheelDelta / (_this.wheelPrecision * 40);
  205. }
  206. else if (event.detail) {
  207. delta = -event.detail / _this.wheelPrecision;
  208. }
  209. if (delta)
  210. _this.camera.inertialRadiusOffset += delta;
  211. if (event.preventDefault) {
  212. if (!noPreventDefault) {
  213. event.preventDefault();
  214. }
  215. }
  216. };
  217. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, BABYLON.PointerEventTypes.POINTERWHEEL);
  218. };
  219. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  220. if (this._observer && element) {
  221. this.camera.getScene().onPointerObservable.remove(this._observer);
  222. this._observer = null;
  223. this._wheel = null;
  224. }
  225. };
  226. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  227. return "ArcRotateCameraMouseWheelInput";
  228. };
  229. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  230. return "mousewheel";
  231. };
  232. __decorate([
  233. BABYLON.serialize()
  234. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  235. __decorate([
  236. BABYLON.serialize()
  237. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  238. return ArcRotateCameraMouseWheelInput;
  239. }());
  240. BABYLON.ArcRotateCameraMouseWheelInput = ArcRotateCameraMouseWheelInput;
  241. BABYLON.CameraInputTypes["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  242. })(BABYLON || (BABYLON = {}));
  243. //# sourceMappingURL=babylon.arcRotateCameraMouseWheelInput.js.map
  244. BABYLON.Effect.ShadersStore['defaultVertexShader'] = "#include<__decl__defaultVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nvarying vec2 vSpecularUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL \nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif \n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n}";
  245. BABYLON.Effect.ShadersStore['defaultPixelShader'] = "#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY \n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n\n#include<fresnelFunction>\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0)\n{\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb*vRefractionInfos.x;\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords).rgb*vRefractionInfos.x;\n#endif\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb*vReflectionInfos.x;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb*vReflectionInfos.x;\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb*vReflectionInfos.x;\n#endif\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#include<logDepthFragment>\n#include<fogFragment>\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\ngl_FragColor=color;\n}";
  246. var BABYLON;
  247. (function (BABYLON) {
  248. var ArcRotateCameraPointersInput = /** @class */ (function () {
  249. function ArcRotateCameraPointersInput() {
  250. this.buttons = [0, 1, 2];
  251. this.angularSensibilityX = 1000.0;
  252. this.angularSensibilityY = 1000.0;
  253. this.pinchPrecision = 12.0;
  254. /**
  255. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  256. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  257. */
  258. this.pinchDeltaPercentage = 0;
  259. this.panningSensibility = 1000.0;
  260. this.multiTouchPanning = true;
  261. this.multiTouchPanAndZoom = true;
  262. this._isPanClick = false;
  263. this.pinchInwards = true;
  264. }
  265. ArcRotateCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  266. var _this = this;
  267. var engine = this.camera.getEngine();
  268. var cacheSoloPointer; // cache pointer object for better perf on camera rotation
  269. var pointA = null;
  270. var pointB = null;
  271. var previousPinchSquaredDistance = 0;
  272. var initialDistance = 0;
  273. var twoFingerActivityCount = 0;
  274. var previousMultiTouchPanPosition = { x: 0, y: 0, isPaning: false, isPinching: false };
  275. this._pointerInput = function (p, s) {
  276. var evt = p.event;
  277. var isTouch = p.event.pointerType === "touch";
  278. if (engine.isInVRExclusivePointerMode) {
  279. return;
  280. }
  281. if (p.type !== BABYLON.PointerEventTypes.POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  282. return;
  283. }
  284. var srcElement = (evt.srcElement || evt.target);
  285. if (p.type === BABYLON.PointerEventTypes.POINTERDOWN && srcElement) {
  286. try {
  287. srcElement.setPointerCapture(evt.pointerId);
  288. }
  289. catch (e) {
  290. //Nothing to do with the error. Execution will continue.
  291. }
  292. // Manage panning with pan button click
  293. _this._isPanClick = evt.button === _this.camera._panningMouseButton;
  294. // manage pointers
  295. cacheSoloPointer = { x: evt.clientX, y: evt.clientY, pointerId: evt.pointerId, type: evt.pointerType };
  296. if (pointA === null) {
  297. pointA = cacheSoloPointer;
  298. }
  299. else if (pointB === null) {
  300. pointB = cacheSoloPointer;
  301. }
  302. if (!noPreventDefault) {
  303. evt.preventDefault();
  304. element.focus();
  305. }
  306. }
  307. else if (p.type === BABYLON.PointerEventTypes.POINTERDOUBLETAP) {
  308. _this.camera.restoreState();
  309. }
  310. else if (p.type === BABYLON.PointerEventTypes.POINTERUP && srcElement) {
  311. try {
  312. srcElement.releasePointerCapture(evt.pointerId);
  313. }
  314. catch (e) {
  315. //Nothing to do with the error.
  316. }
  317. cacheSoloPointer = null;
  318. previousPinchSquaredDistance = 0;
  319. previousMultiTouchPanPosition.isPaning = false;
  320. previousMultiTouchPanPosition.isPinching = false;
  321. twoFingerActivityCount = 0;
  322. initialDistance = 0;
  323. if (!isTouch) {
  324. pointB = null; // Mouse and pen are mono pointer
  325. }
  326. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  327. //but emptying completly pointers collection is required to fix a bug on iPhone :
  328. //when changing orientation while pinching camera, one pointer stay pressed forever if we don't release all pointers
  329. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  330. if (engine.badOS) {
  331. pointA = pointB = null;
  332. }
  333. else {
  334. //only remove the impacted pointer in case of multitouch allowing on most
  335. //platforms switching from rotate to zoom and pan seamlessly.
  336. if (pointB && pointA && pointA.pointerId == evt.pointerId) {
  337. pointA = pointB;
  338. pointB = null;
  339. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  340. }
  341. else if (pointA && pointB && pointB.pointerId == evt.pointerId) {
  342. pointB = null;
  343. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  344. }
  345. else {
  346. pointA = pointB = null;
  347. }
  348. }
  349. if (!noPreventDefault) {
  350. evt.preventDefault();
  351. }
  352. }
  353. else if (p.type === BABYLON.PointerEventTypes.POINTERMOVE) {
  354. if (!noPreventDefault) {
  355. evt.preventDefault();
  356. }
  357. // One button down
  358. if (pointA && pointB === null && cacheSoloPointer) {
  359. if (_this.panningSensibility !== 0 &&
  360. ((evt.ctrlKey && _this.camera._useCtrlForPanning) || _this._isPanClick)) {
  361. _this.camera.inertialPanningX += -(evt.clientX - cacheSoloPointer.x) / _this.panningSensibility;
  362. _this.camera.inertialPanningY += (evt.clientY - cacheSoloPointer.y) / _this.panningSensibility;
  363. }
  364. else {
  365. var offsetX = evt.clientX - cacheSoloPointer.x;
  366. var offsetY = evt.clientY - cacheSoloPointer.y;
  367. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  368. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  369. }
  370. cacheSoloPointer.x = evt.clientX;
  371. cacheSoloPointer.y = evt.clientY;
  372. }
  373. else if (pointA && pointB) {
  374. //if (noPreventDefault) { evt.preventDefault(); } //if pinch gesture, could be useful to force preventDefault to avoid html page scroll/zoom in some mobile browsers
  375. var ed = (pointA.pointerId === evt.pointerId) ? pointA : pointB;
  376. ed.x = evt.clientX;
  377. ed.y = evt.clientY;
  378. var direction = _this.pinchInwards ? 1 : -1;
  379. var distX = pointA.x - pointB.x;
  380. var distY = pointA.y - pointB.y;
  381. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  382. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  383. if (previousPinchSquaredDistance === 0) {
  384. initialDistance = pinchDistance;
  385. previousPinchSquaredDistance = pinchSquaredDistance;
  386. previousMultiTouchPanPosition.x = (pointA.x + pointB.x) / 2;
  387. previousMultiTouchPanPosition.y = (pointA.y + pointB.y) / 2;
  388. return;
  389. }
  390. if (_this.multiTouchPanAndZoom) {
  391. if (_this.pinchDeltaPercentage) {
  392. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  393. }
  394. else {
  395. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  396. (_this.pinchPrecision *
  397. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  398. direction);
  399. }
  400. if (_this.panningSensibility !== 0) {
  401. var pointersCenterX = (pointA.x + pointB.x) / 2;
  402. var pointersCenterY = (pointA.y + pointB.y) / 2;
  403. var pointersCenterDistX = pointersCenterX - previousMultiTouchPanPosition.x;
  404. var pointersCenterDistY = pointersCenterY - previousMultiTouchPanPosition.y;
  405. previousMultiTouchPanPosition.x = pointersCenterX;
  406. previousMultiTouchPanPosition.y = pointersCenterY;
  407. _this.camera.inertialPanningX += -(pointersCenterDistX) / (_this.panningSensibility);
  408. _this.camera.inertialPanningY += (pointersCenterDistY) / (_this.panningSensibility);
  409. }
  410. }
  411. else {
  412. twoFingerActivityCount++;
  413. if (previousMultiTouchPanPosition.isPinching || (twoFingerActivityCount < 20 && Math.abs(pinchDistance - initialDistance) > _this.camera.pinchToPanMaxDistance)) {
  414. if (_this.pinchDeltaPercentage) {
  415. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  416. }
  417. else {
  418. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  419. (_this.pinchPrecision *
  420. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  421. direction);
  422. }
  423. previousMultiTouchPanPosition.isPaning = false;
  424. previousMultiTouchPanPosition.isPinching = true;
  425. }
  426. else {
  427. if (cacheSoloPointer && cacheSoloPointer.pointerId === ed.pointerId && _this.panningSensibility !== 0 && _this.multiTouchPanning) {
  428. if (!previousMultiTouchPanPosition.isPaning) {
  429. previousMultiTouchPanPosition.isPaning = true;
  430. previousMultiTouchPanPosition.isPinching = false;
  431. previousMultiTouchPanPosition.x = ed.x;
  432. previousMultiTouchPanPosition.y = ed.y;
  433. return;
  434. }
  435. _this.camera.inertialPanningX += -(ed.x - previousMultiTouchPanPosition.x) / (_this.panningSensibility);
  436. _this.camera.inertialPanningY += (ed.y - previousMultiTouchPanPosition.y) / (_this.panningSensibility);
  437. }
  438. }
  439. if (cacheSoloPointer && cacheSoloPointer.pointerId === evt.pointerId) {
  440. previousMultiTouchPanPosition.x = ed.x;
  441. previousMultiTouchPanPosition.y = ed.y;
  442. }
  443. }
  444. previousPinchSquaredDistance = pinchSquaredDistance;
  445. }
  446. }
  447. };
  448. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, BABYLON.PointerEventTypes.POINTERDOWN | BABYLON.PointerEventTypes.POINTERUP | BABYLON.PointerEventTypes.POINTERMOVE | BABYLON.PointerEventTypes._POINTERDOUBLETAP);
  449. this._onContextMenu = function (evt) {
  450. evt.preventDefault();
  451. };
  452. if (!this.camera._useCtrlForPanning) {
  453. element.addEventListener("contextmenu", this._onContextMenu, false);
  454. }
  455. this._onLostFocus = function () {
  456. //this._keys = [];
  457. pointA = pointB = null;
  458. previousPinchSquaredDistance = 0;
  459. previousMultiTouchPanPosition.isPaning = false;
  460. previousMultiTouchPanPosition.isPinching = false;
  461. twoFingerActivityCount = 0;
  462. cacheSoloPointer = null;
  463. initialDistance = 0;
  464. };
  465. this._onMouseMove = function (evt) {
  466. if (!engine.isPointerLock) {
  467. return;
  468. }
  469. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  470. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  471. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  472. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  473. if (!noPreventDefault) {
  474. evt.preventDefault();
  475. }
  476. };
  477. this._onGestureStart = function (e) {
  478. if (window.MSGesture === undefined) {
  479. return;
  480. }
  481. if (!_this._MSGestureHandler) {
  482. _this._MSGestureHandler = new MSGesture();
  483. _this._MSGestureHandler.target = element;
  484. }
  485. _this._MSGestureHandler.addPointer(e.pointerId);
  486. };
  487. this._onGesture = function (e) {
  488. _this.camera.radius *= e.scale;
  489. if (e.preventDefault) {
  490. if (!noPreventDefault) {
  491. e.stopPropagation();
  492. e.preventDefault();
  493. }
  494. }
  495. };
  496. element.addEventListener("mousemove", this._onMouseMove, false);
  497. element.addEventListener("MSPointerDown", this._onGestureStart, false);
  498. element.addEventListener("MSGestureChange", this._onGesture, false);
  499. BABYLON.Tools.RegisterTopRootEvents([
  500. { name: "blur", handler: this._onLostFocus }
  501. ]);
  502. };
  503. ArcRotateCameraPointersInput.prototype.detachControl = function (element) {
  504. if (this._onLostFocus) {
  505. BABYLON.Tools.UnregisterTopRootEvents([
  506. { name: "blur", handler: this._onLostFocus }
  507. ]);
  508. }
  509. if (element && this._observer) {
  510. this.camera.getScene().onPointerObservable.remove(this._observer);
  511. this._observer = null;
  512. if (this._onContextMenu) {
  513. element.removeEventListener("contextmenu", this._onContextMenu);
  514. }
  515. if (this._onMouseMove) {
  516. element.removeEventListener("mousemove", this._onMouseMove);
  517. }
  518. if (this._onGestureStart) {
  519. element.removeEventListener("MSPointerDown", this._onGestureStart);
  520. }
  521. if (this._onGesture) {
  522. element.removeEventListener("MSGestureChange", this._onGesture);
  523. }
  524. this._isPanClick = false;
  525. this.pinchInwards = true;
  526. this._onMouseMove = null;
  527. this._onGestureStart = null;
  528. this._onGesture = null;
  529. this._MSGestureHandler = null;
  530. this._onLostFocus = null;
  531. this._onContextMenu = null;
  532. }
  533. };
  534. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  535. return "ArcRotateCameraPointersInput";
  536. };
  537. ArcRotateCameraPointersInput.prototype.getSimpleName = function () {
  538. return "pointers";
  539. };
  540. __decorate([
  541. BABYLON.serialize()
  542. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  543. __decorate([
  544. BABYLON.serialize()
  545. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  546. __decorate([
  547. BABYLON.serialize()
  548. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  549. __decorate([
  550. BABYLON.serialize()
  551. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  552. __decorate([
  553. BABYLON.serialize()
  554. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  555. __decorate([
  556. BABYLON.serialize()
  557. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  558. __decorate([
  559. BABYLON.serialize()
  560. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  561. __decorate([
  562. BABYLON.serialize()
  563. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  564. return ArcRotateCameraPointersInput;
  565. }());
  566. BABYLON.ArcRotateCameraPointersInput = ArcRotateCameraPointersInput;
  567. BABYLON.CameraInputTypes["ArcRotateCameraPointersInput"] = ArcRotateCameraPointersInput;
  568. })(BABYLON || (BABYLON = {}));
  569. //# sourceMappingURL=babylon.arcRotateCameraPointersInput.js.map
  570. var BABYLON;
  571. (function (BABYLON) {
  572. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  573. __extends(ArcRotateCameraInputsManager, _super);
  574. function ArcRotateCameraInputsManager(camera) {
  575. return _super.call(this, camera) || this;
  576. }
  577. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  578. this.add(new BABYLON.ArcRotateCameraMouseWheelInput());
  579. return this;
  580. };
  581. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  582. this.add(new BABYLON.ArcRotateCameraPointersInput());
  583. return this;
  584. };
  585. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  586. this.add(new BABYLON.ArcRotateCameraKeyboardMoveInput());
  587. return this;
  588. };
  589. ArcRotateCameraInputsManager.prototype.addGamepad = function () {
  590. this.add(new BABYLON.ArcRotateCameraGamepadInput());
  591. return this;
  592. };
  593. ArcRotateCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  594. this.add(new BABYLON.ArcRotateCameraVRDeviceOrientationInput());
  595. return this;
  596. };
  597. return ArcRotateCameraInputsManager;
  598. }(BABYLON.CameraInputsManager));
  599. BABYLON.ArcRotateCameraInputsManager = ArcRotateCameraInputsManager;
  600. })(BABYLON || (BABYLON = {}));
  601. //# sourceMappingURL=babylon.arcRotateCameraInputsManager.js.map
  602. var BABYLON;
  603. (function (BABYLON) {
  604. var ArcRotateCamera = /** @class */ (function (_super) {
  605. __extends(ArcRotateCamera, _super);
  606. function ArcRotateCamera(name, alpha, beta, radius, target, scene) {
  607. var _this = _super.call(this, name, BABYLON.Vector3.Zero(), scene) || this;
  608. _this.inertialAlphaOffset = 0;
  609. _this.inertialBetaOffset = 0;
  610. _this.inertialRadiusOffset = 0;
  611. _this.lowerAlphaLimit = null;
  612. _this.upperAlphaLimit = null;
  613. _this.lowerBetaLimit = 0.01;
  614. _this.upperBetaLimit = Math.PI;
  615. _this.lowerRadiusLimit = null;
  616. _this.upperRadiusLimit = null;
  617. _this.inertialPanningX = 0;
  618. _this.inertialPanningY = 0;
  619. _this.pinchToPanMaxDistance = 20;
  620. _this.panningDistanceLimit = null;
  621. _this.panningOriginTarget = BABYLON.Vector3.Zero();
  622. _this.panningInertia = 0.9;
  623. //-- end properties for backward compatibility for inputs
  624. _this.zoomOnFactor = 1;
  625. _this.targetScreenOffset = BABYLON.Vector2.Zero();
  626. _this.allowUpsideDown = true;
  627. _this._viewMatrix = new BABYLON.Matrix();
  628. // Panning
  629. _this.panningAxis = new BABYLON.Vector3(1, 1, 0);
  630. _this.onMeshTargetChangedObservable = new BABYLON.Observable();
  631. _this.checkCollisions = false;
  632. _this.collisionRadius = new BABYLON.Vector3(0.5, 0.5, 0.5);
  633. _this._previousPosition = BABYLON.Vector3.Zero();
  634. _this._collisionVelocity = BABYLON.Vector3.Zero();
  635. _this._newPosition = BABYLON.Vector3.Zero();
  636. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  637. if (collidedMesh === void 0) { collidedMesh = null; }
  638. if (_this.getScene().workerCollisions && _this.checkCollisions) {
  639. newPosition.multiplyInPlace(_this._collider._radius);
  640. }
  641. if (!collidedMesh) {
  642. _this._previousPosition.copyFrom(_this.position);
  643. }
  644. else {
  645. _this.setPosition(newPosition);
  646. if (_this.onCollide) {
  647. _this.onCollide(collidedMesh);
  648. }
  649. }
  650. // Recompute because of constraints
  651. var cosa = Math.cos(_this.alpha);
  652. var sina = Math.sin(_this.alpha);
  653. var cosb = Math.cos(_this.beta);
  654. var sinb = Math.sin(_this.beta);
  655. if (sinb === 0) {
  656. sinb = 0.0001;
  657. }
  658. var target = _this._getTargetPosition();
  659. target.addToRef(new BABYLON.Vector3(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb), _this._newPosition);
  660. _this.position.copyFrom(_this._newPosition);
  661. var up = _this.upVector;
  662. if (_this.allowUpsideDown && _this.beta < 0) {
  663. up = up.clone();
  664. up = up.negate();
  665. }
  666. BABYLON.Matrix.LookAtLHToRef(_this.position, target, up, _this._viewMatrix);
  667. _this._viewMatrix.m[12] += _this.targetScreenOffset.x;
  668. _this._viewMatrix.m[13] += _this.targetScreenOffset.y;
  669. _this._collisionTriggered = false;
  670. };
  671. _this._target = BABYLON.Vector3.Zero();
  672. if (target) {
  673. _this.setTarget(target);
  674. }
  675. _this.alpha = alpha;
  676. _this.beta = beta;
  677. _this.radius = radius;
  678. _this.getViewMatrix();
  679. _this.inputs = new BABYLON.ArcRotateCameraInputsManager(_this);
  680. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  681. return _this;
  682. }
  683. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  684. get: function () {
  685. return this._target;
  686. },
  687. set: function (value) {
  688. this.setTarget(value);
  689. },
  690. enumerable: true,
  691. configurable: true
  692. });
  693. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  694. //-- begin properties for backward compatibility for inputs
  695. get: function () {
  696. var pointers = this.inputs.attached["pointers"];
  697. if (pointers)
  698. return pointers.angularSensibilityX;
  699. return 0;
  700. },
  701. set: function (value) {
  702. var pointers = this.inputs.attached["pointers"];
  703. if (pointers) {
  704. pointers.angularSensibilityX = value;
  705. }
  706. },
  707. enumerable: true,
  708. configurable: true
  709. });
  710. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  711. get: function () {
  712. var pointers = this.inputs.attached["pointers"];
  713. if (pointers)
  714. return pointers.angularSensibilityY;
  715. return 0;
  716. },
  717. set: function (value) {
  718. var pointers = this.inputs.attached["pointers"];
  719. if (pointers) {
  720. pointers.angularSensibilityY = value;
  721. }
  722. },
  723. enumerable: true,
  724. configurable: true
  725. });
  726. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  727. get: function () {
  728. var pointers = this.inputs.attached["pointers"];
  729. if (pointers)
  730. return pointers.pinchPrecision;
  731. return 0;
  732. },
  733. set: function (value) {
  734. var pointers = this.inputs.attached["pointers"];
  735. if (pointers) {
  736. pointers.pinchPrecision = value;
  737. }
  738. },
  739. enumerable: true,
  740. configurable: true
  741. });
  742. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  743. get: function () {
  744. var pointers = this.inputs.attached["pointers"];
  745. if (pointers)
  746. return pointers.pinchDeltaPercentage;
  747. return 0;
  748. },
  749. set: function (value) {
  750. var pointers = this.inputs.attached["pointers"];
  751. if (pointers) {
  752. pointers.pinchDeltaPercentage = value;
  753. }
  754. },
  755. enumerable: true,
  756. configurable: true
  757. });
  758. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  759. get: function () {
  760. var pointers = this.inputs.attached["pointers"];
  761. if (pointers)
  762. return pointers.panningSensibility;
  763. return 0;
  764. },
  765. set: function (value) {
  766. var pointers = this.inputs.attached["pointers"];
  767. if (pointers) {
  768. pointers.panningSensibility = value;
  769. }
  770. },
  771. enumerable: true,
  772. configurable: true
  773. });
  774. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  775. get: function () {
  776. var keyboard = this.inputs.attached["keyboard"];
  777. if (keyboard)
  778. return keyboard.keysUp;
  779. return [];
  780. },
  781. set: function (value) {
  782. var keyboard = this.inputs.attached["keyboard"];
  783. if (keyboard)
  784. keyboard.keysUp = value;
  785. },
  786. enumerable: true,
  787. configurable: true
  788. });
  789. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  790. get: function () {
  791. var keyboard = this.inputs.attached["keyboard"];
  792. if (keyboard)
  793. return keyboard.keysDown;
  794. return [];
  795. },
  796. set: function (value) {
  797. var keyboard = this.inputs.attached["keyboard"];
  798. if (keyboard)
  799. keyboard.keysDown = value;
  800. },
  801. enumerable: true,
  802. configurable: true
  803. });
  804. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  805. get: function () {
  806. var keyboard = this.inputs.attached["keyboard"];
  807. if (keyboard)
  808. return keyboard.keysLeft;
  809. return [];
  810. },
  811. set: function (value) {
  812. var keyboard = this.inputs.attached["keyboard"];
  813. if (keyboard)
  814. keyboard.keysLeft = value;
  815. },
  816. enumerable: true,
  817. configurable: true
  818. });
  819. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  820. get: function () {
  821. var keyboard = this.inputs.attached["keyboard"];
  822. if (keyboard)
  823. return keyboard.keysRight;
  824. return [];
  825. },
  826. set: function (value) {
  827. var keyboard = this.inputs.attached["keyboard"];
  828. if (keyboard)
  829. keyboard.keysRight = value;
  830. },
  831. enumerable: true,
  832. configurable: true
  833. });
  834. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  835. get: function () {
  836. var mousewheel = this.inputs.attached["mousewheel"];
  837. if (mousewheel)
  838. return mousewheel.wheelPrecision;
  839. return 0;
  840. },
  841. set: function (value) {
  842. var mousewheel = this.inputs.attached["mousewheel"];
  843. if (mousewheel)
  844. mousewheel.wheelPrecision = value;
  845. },
  846. enumerable: true,
  847. configurable: true
  848. });
  849. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  850. get: function () {
  851. var mousewheel = this.inputs.attached["mousewheel"];
  852. if (mousewheel)
  853. return mousewheel.wheelDeltaPercentage;
  854. return 0;
  855. },
  856. set: function (value) {
  857. var mousewheel = this.inputs.attached["mousewheel"];
  858. if (mousewheel)
  859. mousewheel.wheelDeltaPercentage = value;
  860. },
  861. enumerable: true,
  862. configurable: true
  863. });
  864. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  865. get: function () {
  866. return this._bouncingBehavior;
  867. },
  868. enumerable: true,
  869. configurable: true
  870. });
  871. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  872. get: function () {
  873. return this._bouncingBehavior != null;
  874. },
  875. set: function (value) {
  876. if (value === this.useBouncingBehavior) {
  877. return;
  878. }
  879. if (value) {
  880. this._bouncingBehavior = new BABYLON.BouncingBehavior();
  881. this.addBehavior(this._bouncingBehavior);
  882. }
  883. else if (this._bouncingBehavior) {
  884. this.removeBehavior(this._bouncingBehavior);
  885. this._bouncingBehavior = null;
  886. }
  887. },
  888. enumerable: true,
  889. configurable: true
  890. });
  891. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  892. get: function () {
  893. return this._framingBehavior;
  894. },
  895. enumerable: true,
  896. configurable: true
  897. });
  898. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  899. get: function () {
  900. return this._framingBehavior != null;
  901. },
  902. set: function (value) {
  903. if (value === this.useFramingBehavior) {
  904. return;
  905. }
  906. if (value) {
  907. this._framingBehavior = new BABYLON.FramingBehavior();
  908. this.addBehavior(this._framingBehavior);
  909. }
  910. else if (this._framingBehavior) {
  911. this.removeBehavior(this._framingBehavior);
  912. this._framingBehavior = null;
  913. }
  914. },
  915. enumerable: true,
  916. configurable: true
  917. });
  918. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  919. get: function () {
  920. return this._autoRotationBehavior;
  921. },
  922. enumerable: true,
  923. configurable: true
  924. });
  925. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  926. get: function () {
  927. return this._autoRotationBehavior != null;
  928. },
  929. set: function (value) {
  930. if (value === this.useAutoRotationBehavior) {
  931. return;
  932. }
  933. if (value) {
  934. this._autoRotationBehavior = new BABYLON.AutoRotationBehavior();
  935. this.addBehavior(this._autoRotationBehavior);
  936. }
  937. else if (this._autoRotationBehavior) {
  938. this.removeBehavior(this._autoRotationBehavior);
  939. this._autoRotationBehavior = null;
  940. }
  941. },
  942. enumerable: true,
  943. configurable: true
  944. });
  945. // Cache
  946. ArcRotateCamera.prototype._initCache = function () {
  947. _super.prototype._initCache.call(this);
  948. this._cache._target = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  949. this._cache.alpha = undefined;
  950. this._cache.beta = undefined;
  951. this._cache.radius = undefined;
  952. this._cache.targetScreenOffset = BABYLON.Vector2.Zero();
  953. };
  954. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  955. if (!ignoreParentClass) {
  956. _super.prototype._updateCache.call(this);
  957. }
  958. this._cache._target.copyFrom(this._getTargetPosition());
  959. this._cache.alpha = this.alpha;
  960. this._cache.beta = this.beta;
  961. this._cache.radius = this.radius;
  962. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  963. };
  964. ArcRotateCamera.prototype._getTargetPosition = function () {
  965. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  966. var pos = this._targetHost.getAbsolutePosition();
  967. if (this._targetBoundingCenter) {
  968. pos.addToRef(this._targetBoundingCenter, this._target);
  969. }
  970. else {
  971. this._target.copyFrom(pos);
  972. }
  973. }
  974. var lockedTargetPosition = this._getLockedTargetPosition();
  975. if (lockedTargetPosition) {
  976. return lockedTargetPosition;
  977. }
  978. return this._target;
  979. };
  980. ArcRotateCamera.prototype.storeState = function () {
  981. this._storedAlpha = this.alpha;
  982. this._storedBeta = this.beta;
  983. this._storedRadius = this.radius;
  984. this._storedTarget = this._getTargetPosition().clone();
  985. return _super.prototype.storeState.call(this);
  986. };
  987. /**
  988. * Restored camera state. You must call storeState() first
  989. */
  990. ArcRotateCamera.prototype._restoreStateValues = function () {
  991. if (!_super.prototype._restoreStateValues.call(this)) {
  992. return false;
  993. }
  994. this.alpha = this._storedAlpha;
  995. this.beta = this._storedBeta;
  996. this.radius = this._storedRadius;
  997. this.setTarget(this._storedTarget.clone());
  998. this.inertialAlphaOffset = 0;
  999. this.inertialBetaOffset = 0;
  1000. this.inertialRadiusOffset = 0;
  1001. this.inertialPanningX = 0;
  1002. this.inertialPanningY = 0;
  1003. return true;
  1004. };
  1005. // Synchronized
  1006. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  1007. if (!_super.prototype._isSynchronizedViewMatrix.call(this))
  1008. return false;
  1009. return this._cache._target.equals(this._getTargetPosition())
  1010. && this._cache.alpha === this.alpha
  1011. && this._cache.beta === this.beta
  1012. && this._cache.radius === this.radius
  1013. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  1014. };
  1015. // Methods
  1016. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  1017. var _this = this;
  1018. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  1019. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  1020. this._useCtrlForPanning = useCtrlForPanning;
  1021. this._panningMouseButton = panningMouseButton;
  1022. this.inputs.attachElement(element, noPreventDefault);
  1023. this._reset = function () {
  1024. _this.inertialAlphaOffset = 0;
  1025. _this.inertialBetaOffset = 0;
  1026. _this.inertialRadiusOffset = 0;
  1027. _this.inertialPanningX = 0;
  1028. _this.inertialPanningY = 0;
  1029. };
  1030. };
  1031. ArcRotateCamera.prototype.detachControl = function (element) {
  1032. this.inputs.detachElement(element);
  1033. if (this._reset) {
  1034. this._reset();
  1035. }
  1036. };
  1037. ArcRotateCamera.prototype._checkInputs = function () {
  1038. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  1039. if (this._collisionTriggered) {
  1040. return;
  1041. }
  1042. this.inputs.checkInputs();
  1043. // Inertia
  1044. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  1045. if (this.getScene().useRightHandedSystem) {
  1046. this.alpha -= this.beta <= 0 ? -this.inertialAlphaOffset : this.inertialAlphaOffset;
  1047. }
  1048. else {
  1049. this.alpha += this.beta <= 0 ? -this.inertialAlphaOffset : this.inertialAlphaOffset;
  1050. }
  1051. this.beta += this.inertialBetaOffset;
  1052. this.radius -= this.inertialRadiusOffset;
  1053. this.inertialAlphaOffset *= this.inertia;
  1054. this.inertialBetaOffset *= this.inertia;
  1055. this.inertialRadiusOffset *= this.inertia;
  1056. if (Math.abs(this.inertialAlphaOffset) < BABYLON.Epsilon)
  1057. this.inertialAlphaOffset = 0;
  1058. if (Math.abs(this.inertialBetaOffset) < BABYLON.Epsilon)
  1059. this.inertialBetaOffset = 0;
  1060. if (Math.abs(this.inertialRadiusOffset) < this.speed * BABYLON.Epsilon)
  1061. this.inertialRadiusOffset = 0;
  1062. }
  1063. // Panning inertia
  1064. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  1065. if (!this._localDirection) {
  1066. this._localDirection = BABYLON.Vector3.Zero();
  1067. this._transformedDirection = BABYLON.Vector3.Zero();
  1068. }
  1069. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  1070. this._localDirection.multiplyInPlace(this.panningAxis);
  1071. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  1072. BABYLON.Vector3.TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  1073. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  1074. if (!this.panningAxis.y) {
  1075. this._transformedDirection.y = 0;
  1076. }
  1077. if (!this._targetHost) {
  1078. if (this.panningDistanceLimit) {
  1079. this._transformedDirection.addInPlace(this._target);
  1080. var distanceSquared = BABYLON.Vector3.DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  1081. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  1082. this._target.copyFrom(this._transformedDirection);
  1083. }
  1084. }
  1085. else {
  1086. this._target.addInPlace(this._transformedDirection);
  1087. }
  1088. }
  1089. this.inertialPanningX *= this.panningInertia;
  1090. this.inertialPanningY *= this.panningInertia;
  1091. if (Math.abs(this.inertialPanningX) < this.speed * BABYLON.Epsilon)
  1092. this.inertialPanningX = 0;
  1093. if (Math.abs(this.inertialPanningY) < this.speed * BABYLON.Epsilon)
  1094. this.inertialPanningY = 0;
  1095. }
  1096. // Limits
  1097. this._checkLimits();
  1098. _super.prototype._checkInputs.call(this);
  1099. };
  1100. ArcRotateCamera.prototype._checkLimits = function () {
  1101. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  1102. if (this.allowUpsideDown && this.beta > Math.PI) {
  1103. this.beta = this.beta - (2 * Math.PI);
  1104. }
  1105. }
  1106. else {
  1107. if (this.beta < this.lowerBetaLimit) {
  1108. this.beta = this.lowerBetaLimit;
  1109. }
  1110. }
  1111. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  1112. if (this.allowUpsideDown && this.beta < -Math.PI) {
  1113. this.beta = this.beta + (2 * Math.PI);
  1114. }
  1115. }
  1116. else {
  1117. if (this.beta > this.upperBetaLimit) {
  1118. this.beta = this.upperBetaLimit;
  1119. }
  1120. }
  1121. if (this.lowerAlphaLimit && this.alpha < this.lowerAlphaLimit) {
  1122. this.alpha = this.lowerAlphaLimit;
  1123. }
  1124. if (this.upperAlphaLimit && this.alpha > this.upperAlphaLimit) {
  1125. this.alpha = this.upperAlphaLimit;
  1126. }
  1127. if (this.lowerRadiusLimit && this.radius < this.lowerRadiusLimit) {
  1128. this.radius = this.lowerRadiusLimit;
  1129. }
  1130. if (this.upperRadiusLimit && this.radius > this.upperRadiusLimit) {
  1131. this.radius = this.upperRadiusLimit;
  1132. }
  1133. };
  1134. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
  1135. var radiusv3 = this.position.subtract(this._getTargetPosition());
  1136. this.radius = radiusv3.length();
  1137. if (this.radius === 0) {
  1138. this.radius = 0.0001; // Just to avoid division by zero
  1139. }
  1140. // Alpha
  1141. this.alpha = Math.acos(radiusv3.x / Math.sqrt(Math.pow(radiusv3.x, 2) + Math.pow(radiusv3.z, 2)));
  1142. if (radiusv3.z < 0) {
  1143. this.alpha = 2 * Math.PI - this.alpha;
  1144. }
  1145. // Beta
  1146. this.beta = Math.acos(radiusv3.y / this.radius);
  1147. this._checkLimits();
  1148. };
  1149. ArcRotateCamera.prototype.setPosition = function (position) {
  1150. if (this.position.equals(position)) {
  1151. return;
  1152. }
  1153. this.position.copyFrom(position);
  1154. this.rebuildAnglesAndRadius();
  1155. };
  1156. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  1157. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  1158. if (allowSamePosition === void 0) { allowSamePosition = false; }
  1159. if (target.getBoundingInfo) {
  1160. if (toBoundingCenter) {
  1161. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  1162. }
  1163. else {
  1164. this._targetBoundingCenter = null;
  1165. }
  1166. this._targetHost = target;
  1167. this._target = this._getTargetPosition();
  1168. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  1169. }
  1170. else {
  1171. var newTarget = target;
  1172. var currentTarget = this._getTargetPosition();
  1173. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  1174. return;
  1175. }
  1176. this._targetHost = null;
  1177. this._target = newTarget;
  1178. this._targetBoundingCenter = null;
  1179. this.onMeshTargetChangedObservable.notifyObservers(null);
  1180. }
  1181. this.rebuildAnglesAndRadius();
  1182. };
  1183. ArcRotateCamera.prototype._getViewMatrix = function () {
  1184. // Compute
  1185. var cosa = Math.cos(this.alpha);
  1186. var sina = Math.sin(this.alpha);
  1187. var cosb = Math.cos(this.beta);
  1188. var sinb = Math.sin(this.beta);
  1189. if (sinb === 0) {
  1190. sinb = 0.0001;
  1191. }
  1192. var target = this._getTargetPosition();
  1193. target.addToRef(new BABYLON.Vector3(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb), this._newPosition);
  1194. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  1195. if (!this._collider) {
  1196. this._collider = new BABYLON.Collider();
  1197. }
  1198. this._collider._radius = this.collisionRadius;
  1199. this._newPosition.subtractToRef(this.position, this._collisionVelocity);
  1200. this._collisionTriggered = true;
  1201. this.getScene().collisionCoordinator.getNewPosition(this.position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  1202. }
  1203. else {
  1204. this.position.copyFrom(this._newPosition);
  1205. var up = this.upVector;
  1206. if (this.allowUpsideDown && sinb < 0) {
  1207. up = up.clone();
  1208. up = up.negate();
  1209. }
  1210. if (this.getScene().useRightHandedSystem) {
  1211. BABYLON.Matrix.LookAtRHToRef(this.position, target, up, this._viewMatrix);
  1212. }
  1213. else {
  1214. BABYLON.Matrix.LookAtLHToRef(this.position, target, up, this._viewMatrix);
  1215. }
  1216. this._viewMatrix.m[12] += this.targetScreenOffset.x;
  1217. this._viewMatrix.m[13] += this.targetScreenOffset.y;
  1218. }
  1219. this._currentTarget = target;
  1220. return this._viewMatrix;
  1221. };
  1222. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  1223. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  1224. meshes = meshes || this.getScene().meshes;
  1225. var minMaxVector = BABYLON.Mesh.MinMax(meshes);
  1226. var distance = BABYLON.Vector3.Distance(minMaxVector.min, minMaxVector.max);
  1227. this.radius = distance * this.zoomOnFactor;
  1228. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  1229. };
  1230. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  1231. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  1232. var meshesOrMinMaxVector;
  1233. var distance;
  1234. if (meshesOrMinMaxVectorAndDistance.min === undefined) {
  1235. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  1236. meshesOrMinMaxVector = BABYLON.Mesh.MinMax(meshes);
  1237. distance = BABYLON.Vector3.Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  1238. }
  1239. else {
  1240. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  1241. meshesOrMinMaxVector = minMaxVectorAndDistance;
  1242. distance = minMaxVectorAndDistance.distance;
  1243. }
  1244. this._target = BABYLON.Mesh.Center(meshesOrMinMaxVector);
  1245. if (!doNotUpdateMaxZ) {
  1246. this.maxZ = distance * 2;
  1247. }
  1248. };
  1249. /**
  1250. * @override
  1251. * Override Camera.createRigCamera
  1252. */
  1253. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  1254. var alphaShift = 0;
  1255. switch (this.cameraRigMode) {
  1256. case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  1257. case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  1258. case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  1259. case BABYLON.Camera.RIG_MODE_VR:
  1260. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  1261. break;
  1262. case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  1263. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  1264. break;
  1265. }
  1266. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  1267. rigCam._cameraRigParams = {};
  1268. return rigCam;
  1269. };
  1270. /**
  1271. * @override
  1272. * Override Camera._updateRigCameras
  1273. */
  1274. ArcRotateCamera.prototype._updateRigCameras = function () {
  1275. var camLeft = this._rigCameras[0];
  1276. var camRight = this._rigCameras[1];
  1277. camLeft.beta = camRight.beta = this.beta;
  1278. camLeft.radius = camRight.radius = this.radius;
  1279. switch (this.cameraRigMode) {
  1280. case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  1281. case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  1282. case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  1283. case BABYLON.Camera.RIG_MODE_VR:
  1284. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  1285. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  1286. break;
  1287. case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  1288. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  1289. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  1290. break;
  1291. }
  1292. _super.prototype._updateRigCameras.call(this);
  1293. };
  1294. ArcRotateCamera.prototype.dispose = function () {
  1295. this.inputs.clear();
  1296. _super.prototype.dispose.call(this);
  1297. };
  1298. ArcRotateCamera.prototype.getClassName = function () {
  1299. return "ArcRotateCamera";
  1300. };
  1301. __decorate([
  1302. BABYLON.serialize()
  1303. ], ArcRotateCamera.prototype, "alpha", void 0);
  1304. __decorate([
  1305. BABYLON.serialize()
  1306. ], ArcRotateCamera.prototype, "beta", void 0);
  1307. __decorate([
  1308. BABYLON.serialize()
  1309. ], ArcRotateCamera.prototype, "radius", void 0);
  1310. __decorate([
  1311. BABYLON.serializeAsVector3("target")
  1312. ], ArcRotateCamera.prototype, "_target", void 0);
  1313. __decorate([
  1314. BABYLON.serialize()
  1315. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  1316. __decorate([
  1317. BABYLON.serialize()
  1318. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  1319. __decorate([
  1320. BABYLON.serialize()
  1321. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  1322. __decorate([
  1323. BABYLON.serialize()
  1324. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  1325. __decorate([
  1326. BABYLON.serialize()
  1327. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  1328. __decorate([
  1329. BABYLON.serialize()
  1330. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  1331. __decorate([
  1332. BABYLON.serialize()
  1333. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  1334. __decorate([
  1335. BABYLON.serialize()
  1336. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  1337. __decorate([
  1338. BABYLON.serialize()
  1339. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  1340. __decorate([
  1341. BABYLON.serialize()
  1342. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  1343. __decorate([
  1344. BABYLON.serialize()
  1345. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  1346. __decorate([
  1347. BABYLON.serialize()
  1348. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  1349. __decorate([
  1350. BABYLON.serialize()
  1351. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  1352. __decorate([
  1353. BABYLON.serializeAsVector3()
  1354. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  1355. __decorate([
  1356. BABYLON.serialize()
  1357. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  1358. __decorate([
  1359. BABYLON.serialize()
  1360. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  1361. __decorate([
  1362. BABYLON.serialize()
  1363. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  1364. return ArcRotateCamera;
  1365. }(BABYLON.TargetCamera));
  1366. BABYLON.ArcRotateCamera = ArcRotateCamera;
  1367. })(BABYLON || (BABYLON = {}));
  1368. //# sourceMappingURL=babylon.arcRotateCamera.js.map
  1369. BABYLON.Effect.IncludesShadersStore['depthPrePass'] = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  1370. BABYLON.Effect.IncludesShadersStore['bonesDeclaration'] = "#if NUM_BONE_INFLUENCERS>0\nuniform mat4 mBones[BonesPerMesh];\nattribute vec4 matricesIndices;\nattribute vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nattribute vec4 matricesIndicesExtra;\nattribute vec4 matricesWeightsExtra;\n#endif\n#endif";
  1371. BABYLON.Effect.IncludesShadersStore['instancesDeclaration'] = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  1372. BABYLON.Effect.IncludesShadersStore['pointCloudVertexDeclaration'] = "#ifdef POINTSIZE\nuniform float pointSize;\n#endif";
  1373. BABYLON.Effect.IncludesShadersStore['bumpVertexDeclaration'] = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#endif\n";
  1374. BABYLON.Effect.IncludesShadersStore['clipPlaneVertexDeclaration'] = "#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nvarying float fClipDistance;\n#endif";
  1375. BABYLON.Effect.IncludesShadersStore['fogVertexDeclaration'] = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  1376. BABYLON.Effect.IncludesShadersStore['morphTargetsVertexGlobalDeclaration'] = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  1377. BABYLON.Effect.IncludesShadersStore['morphTargetsVertexDeclaration'] = "#ifdef MORPHTARGETS\nattribute vec3 position{X};\n#ifdef MORPHTARGETS_NORMAL\nattribute vec3 normal{X};\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute vec3 tangent{X};\n#endif\n#endif";
  1378. BABYLON.Effect.IncludesShadersStore['logDepthDeclaration'] = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  1379. BABYLON.Effect.IncludesShadersStore['morphTargetsVertex'] = "#ifdef MORPHTARGETS\npositionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];\n#endif\n#endif";
  1380. BABYLON.Effect.IncludesShadersStore['instancesVertex'] = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  1381. BABYLON.Effect.IncludesShadersStore['bonesVertex'] = "#if NUM_BONE_INFLUENCERS>0\nmat4 influence;\ninfluence=mBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=mBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\ninfluence+=mBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\ninfluence+=mBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif \n#if NUM_BONE_INFLUENCERS>4\ninfluence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\ninfluence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\ninfluence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\ninfluence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif \nfinalWorld=finalWorld*influence;\n#endif";
  1382. BABYLON.Effect.IncludesShadersStore['bumpVertex'] = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 tbnNormal=normalize(normalUpdated);\nvec3 tbnTangent=normalize(tangentUpdated.xyz);\nvec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;\nvTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\n#endif\n#endif";
  1383. BABYLON.Effect.IncludesShadersStore['clipPlaneVertex'] = "#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif";
  1384. BABYLON.Effect.IncludesShadersStore['fogVertex'] = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  1385. BABYLON.Effect.IncludesShadersStore['shadowsVertex'] = "#ifdef SHADOWS\n#if defined(SHADOW{X}) && !defined(SHADOWCUBE{X})\nvPositionFromLight{X}=lightMatrix{X}*worldPos;\nvDepthMetric{X}=((vPositionFromLight{X}.z+light{X}.depthValues.x)/(light{X}.depthValues.y));\n#endif\n#endif";
  1386. BABYLON.Effect.IncludesShadersStore['pointCloudVertex'] = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  1387. BABYLON.Effect.IncludesShadersStore['logDepthVertex'] = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  1388. BABYLON.Effect.IncludesShadersStore['helperFunctions'] = "const float PI=3.1415926535897932384626433832795;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\n\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.0,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\nvec3 applyEaseInOut(vec3 x){\nreturn x*x*(3.0-2.0*x);\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\n\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nvec3 dither(vec2 seed,vec3 color) {\nfloat rand=getRand(seed);\ncolor+=mix(-0.5/255.0,0.5/255.0,rand);\ncolor=max(color,0.0);\nreturn color;\n}";
  1389. BABYLON.Effect.IncludesShadersStore['lightFragmentDeclaration'] = "#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec3 vLightSpecular{X};\n#else\nvec3 vLightSpecular{X}=vec3(0.);\n#endif\n#ifdef SHADOW{X}\n#if defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\nuniform sampler2D shadowSampler{X};\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};\nuniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\n#endif\n#ifdef HEMILIGHT{X}\nuniform vec3 vLightGround{X};\n#endif\n#endif";
  1390. BABYLON.Effect.IncludesShadersStore['lightsFragmentFunctions'] = "\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\n#endif\n};\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 lightVectorW;\nfloat attenuation=1.0;\nif (lightData.w == 0.)\n{\nvec3 direction=lightData.xyz-vPositionW;\nattenuation=max(0.,1.0-length(direction)/range);\nlightVectorW=normalize(direction);\n}\nelse\n{\nlightVectorW=normalize(-lightData.xyz);\n}\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 direction=lightData.xyz-vPositionW;\nvec3 lightVectorW=normalize(direction);\nfloat attenuation=max(0.,1.0-length(direction)/range);\n\nfloat cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));\nif (cosAngle>=lightDirection.w)\n{\ncosAngle=max(0.,pow(cosAngle,lightData.w));\nattenuation*=cosAngle;\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {\nlightingInfo result;\n\nfloat ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor;\n#endif\nreturn result;\n}\n";
  1391. BABYLON.Effect.IncludesShadersStore['lightUboDeclaration'] = "#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec3 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;\n#endif\n#ifdef HEMILIGHT{X}\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;\nvec2 depthValues;\n} light{X};\n#ifdef SHADOW{X}\n#if defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\nuniform sampler2D shadowSampler{X};\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif";
  1392. BABYLON.Effect.IncludesShadersStore['defaultVertexDeclaration'] = "\nuniform mat4 viewProjection;\nuniform mat4 view;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\nuniform mat4 specularMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n";
  1393. BABYLON.Effect.IncludesShadersStore['defaultFragmentDeclaration'] = "uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY \nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REFLECTIONMAP_SKYBOX\n#else\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION)\nuniform mat4 reflectionMatrix;\n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif";
  1394. BABYLON.Effect.IncludesShadersStore['defaultUboDeclaration'] = "layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor; \nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix; \nvec4 vTangentSpaceParams;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nfloat pointSize; \n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  1395. BABYLON.Effect.IncludesShadersStore['shadowsFragmentFunctions'] = "#ifdef SHADOWS\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\nfloat computeShadowWithPCFCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\n#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\n#endif\nreturn min(1.0,visibility+darkness);\n}\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness); \nreturn esm;\n}\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn esm;\n}\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nif (shadowPixelDepth>shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\nfloat computeShadowWithPCF(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;\n#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;\n#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0); \n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n#endif\n";
  1396. BABYLON.Effect.IncludesShadersStore['fresnelFunction'] = "#ifdef FRESNEL\nfloat computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)\n{\nfloat fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);\nreturn clamp(fresnelTerm,0.,1.);\n}\n#endif";
  1397. BABYLON.Effect.IncludesShadersStore['reflectionFunction'] = "vec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)\n{\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvec3 direction=normalize(vDirectionW);\nfloat t=clamp(direction.y*-0.5+0.5,0.,1.0);\nfloat s=atan(direction.z,direction.x)*RECIPROCAL_PI2+0.5;\n#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED\nreturn vec3(1.0-s,t,0);\n#else\nreturn vec3(s,t,0);\n#endif\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR\nvec3 cameraToVertex=normalize(worldPos.xyz-vEyePosition.xyz);\nvec3 r=reflect(cameraToVertex,worldNormal);\nfloat t=clamp(r.y*-0.5+0.5,0.,1.0);\nfloat s=atan(r.z,r.x)*RECIPROCAL_PI2+0.5;\nreturn vec3(s,t,0);\n#endif\n#ifdef REFLECTIONMAP_SPHERICAL\nvec3 viewDir=normalize(vec3(view*worldPos));\nvec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));\nvec3 r=reflect(viewDir,viewNormal);\nr.z=r.z-1.0;\nfloat m=2.0*length(r);\nreturn vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);\n#endif\n#ifdef REFLECTIONMAP_PLANAR\nvec3 viewDir=worldPos.xyz-vEyePosition.xyz;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n#endif\n#ifdef REFLECTIONMAP_CUBIC\nvec3 viewDir=worldPos.xyz-vEyePosition.xyz;\nvec3 coords=reflect(viewDir,worldNormal);\n#ifdef INVERTCUBICMAP\ncoords.y=1.0-coords.y;\n#endif\nreturn vec3(reflectionMatrix*vec4(coords,0));\n#endif\n#ifdef REFLECTIONMAP_PROJECTION\nreturn vec3(reflectionMatrix*(view*worldPos));\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nreturn vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}";
  1398. BABYLON.Effect.IncludesShadersStore['imageProcessingDeclaration'] = "#ifdef EXPOSURE\nuniform float exposureLinear;\n#endif\n#ifdef CONTRAST\nuniform float contrast;\n#endif\n#ifdef VIGNETTE\nuniform vec2 vInverseScreenSize;\nuniform vec4 vignetteSettings1;\nuniform vec4 vignetteSettings2;\n#endif\n#ifdef COLORCURVES\nuniform vec4 vCameraColorCurveNegative;\nuniform vec4 vCameraColorCurveNeutral;\nuniform vec4 vCameraColorCurvePositive;\n#endif\n#ifdef COLORGRADING\n#ifdef COLORGRADING3D\nuniform highp sampler3D txColorTransform;\n#else\nuniform sampler2D txColorTransform;\n#endif\nuniform vec4 colorTransformSettings;\n#endif";
  1399. BABYLON.Effect.IncludesShadersStore['imageProcessingFunctions'] = "#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x; \n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\n\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\n\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=clamp(result.rgb,0.0,1.0);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=applyEaseInOut(result.rgb);\nif (contrast<1.0) {\n\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\n\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\n#ifdef COLORGRADING3D\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\n#else\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\n#endif\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\n\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}";
  1400. BABYLON.Effect.IncludesShadersStore['bumpFragmentFunctions'] = "#ifdef BUMP\n#if BUMPDIRECTUV == 1\n#define vBumpUV vMainUV1\n#elif BUMPDIRECTUV == 2\n#define vBumpUV vMainUV2\n#else\nvarying vec2 vBumpUV;\n#endif\nuniform sampler2D bumpSampler;\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\n\nuv=gl_FrontFacing ? uv : -uv;\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;\n\ntangent*=vTangentSpaceParams.x;\nbitangent*=vTangentSpaceParams.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nvec3 map=texture2D(bumpSampler,uv).xyz;\nmap=map*2.0-1.0;\n#ifdef NORMALXYSCALE\nmap=normalize(map*vec3(vBumpInfos.y,vBumpInfos.y,1.0));\n#endif\nreturn normalize(cotangentFrame*map);\n}\n#ifdef PARALLAX\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\n\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\n\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; i<iMaxSamples; i++)\n{\ncurrSampledHeight=texture2D(bumpSampler,vBumpUV+vCurrOffset).w;\n\nif (currSampledHeight>currRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\n\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif\n#endif";
  1401. BABYLON.Effect.IncludesShadersStore['clipPlaneFragmentDeclaration'] = "#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif";
  1402. BABYLON.Effect.IncludesShadersStore['fogFragmentDeclaration'] = "#ifdef FOG\n#define FOGMODE_NONE 0.\n#define FOGMODE_EXP 1.\n#define FOGMODE_EXP2 2.\n#define FOGMODE_LINEAR 3.\n#define E 2.71828\nuniform vec4 vFogInfos;\nuniform vec3 vFogColor;\nvarying vec3 vFogDistance;\nfloat CalcFogFactor()\n{\nfloat fogCoeff=1.0;\nfloat fogStart=vFogInfos.y;\nfloat fogEnd=vFogInfos.z;\nfloat fogDensity=vFogInfos.w;\nfloat fogDistance=length(vFogDistance);\nif (FOGMODE_LINEAR == vFogInfos.x)\n{\nfogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);\n}\nelse if (FOGMODE_EXP == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDensity);\n}\nelse if (FOGMODE_EXP2 == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);\n}\nreturn clamp(fogCoeff,0.0,1.0);\n}\n#endif";
  1403. BABYLON.Effect.IncludesShadersStore['clipPlaneFragment'] = "#ifdef CLIPPLANE\nif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif";
  1404. BABYLON.Effect.IncludesShadersStore['bumpFragment'] = "vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#else \nfloat normalScale=vBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);\n#endif\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef BUMP\nnormalW=perturbNormal(TBN,vBumpUV+uvOffset);\n#endif";
  1405. BABYLON.Effect.IncludesShadersStore['lightFragment'] = "#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,NdotL);\n#endif\n#ifdef HEMILIGHT{X}\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,NdotL);\n#endif\n#if defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,NdotL);\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#ifdef HEMILIGHT{X}\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,glossiness);\n#endif\n#if defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCLOSEESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#else\n#ifdef SHADOWESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#else \n#ifdef SHADOWPCF{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPCFCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPCF(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#endif\n#endif\n#endif";
  1406. BABYLON.Effect.IncludesShadersStore['logDepthFragment'] = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  1407. BABYLON.Effect.IncludesShadersStore['fogFragment'] = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  1408. (function() {
  1409. var EXPORTS = {};EXPORTS['ArcRotateCameraKeyboardMoveInput'] = BABYLON['ArcRotateCameraKeyboardMoveInput'];EXPORTS['ArcRotateCameraMouseWheelInput'] = BABYLON['ArcRotateCameraMouseWheelInput'];EXPORTS['ArcRotateCameraPointersInput'] = BABYLON['ArcRotateCameraPointersInput'];EXPORTS['ArcRotateCameraInputsManager'] = BABYLON['ArcRotateCameraInputsManager'];EXPORTS['ArcRotateCamera'] = BABYLON['ArcRotateCamera'];
  1410. globalObject["BABYLON"] = globalObject["BABYLON"] || BABYLON;
  1411. module.exports = EXPORTS;
  1412. })();
  1413. }