es6.js 111 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429
  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. import * as targetCamera from 'babylonjs/targetCamera/es6';
  18. var BABYLON;
  19. (function (BABYLON) {
  20. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  21. function ArcRotateCameraKeyboardMoveInput() {
  22. this._keys = new Array();
  23. this.keysUp = [38];
  24. this.keysDown = [40];
  25. this.keysLeft = [37];
  26. this.keysRight = [39];
  27. this.keysReset = [220];
  28. this.panningSensibility = 50.0;
  29. this.zoomingSensibility = 25.0;
  30. this.useAltToZoom = true;
  31. }
  32. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  33. var _this = this;
  34. if (this._onCanvasBlurObserver) {
  35. return;
  36. }
  37. this._scene = this.camera.getScene();
  38. this._engine = this._scene.getEngine();
  39. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  40. _this._keys = [];
  41. });
  42. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  43. var evt = info.event;
  44. if (info.type === BABYLON.KeyboardEventTypes.KEYDOWN) {
  45. _this._ctrlPressed = evt.ctrlKey;
  46. _this._altPressed = evt.altKey;
  47. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  48. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  49. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  50. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  51. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  52. var index = _this._keys.indexOf(evt.keyCode);
  53. if (index === -1) {
  54. _this._keys.push(evt.keyCode);
  55. }
  56. if (evt.preventDefault) {
  57. if (!noPreventDefault) {
  58. evt.preventDefault();
  59. }
  60. }
  61. }
  62. }
  63. else {
  64. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  65. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  66. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  67. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  68. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  69. var index = _this._keys.indexOf(evt.keyCode);
  70. if (index >= 0) {
  71. _this._keys.splice(index, 1);
  72. }
  73. if (evt.preventDefault) {
  74. if (!noPreventDefault) {
  75. evt.preventDefault();
  76. }
  77. }
  78. }
  79. }
  80. });
  81. };
  82. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  83. if (this._scene) {
  84. if (this._onKeyboardObserver) {
  85. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  86. }
  87. if (this._onCanvasBlurObserver) {
  88. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  89. }
  90. this._onKeyboardObserver = null;
  91. this._onCanvasBlurObserver = null;
  92. }
  93. this._keys = [];
  94. };
  95. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  96. if (this._onKeyboardObserver) {
  97. var camera = this.camera;
  98. for (var index = 0; index < this._keys.length; index++) {
  99. var keyCode = this._keys[index];
  100. if (this.keysLeft.indexOf(keyCode) !== -1) {
  101. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  102. camera.inertialPanningX -= 1 / this.panningSensibility;
  103. }
  104. else {
  105. camera.inertialAlphaOffset -= 0.01;
  106. }
  107. }
  108. else if (this.keysUp.indexOf(keyCode) !== -1) {
  109. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  110. camera.inertialPanningY += 1 / this.panningSensibility;
  111. }
  112. else if (this._altPressed && this.useAltToZoom) {
  113. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  114. }
  115. else {
  116. camera.inertialBetaOffset -= 0.01;
  117. }
  118. }
  119. else if (this.keysRight.indexOf(keyCode) !== -1) {
  120. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  121. camera.inertialPanningX += 1 / this.panningSensibility;
  122. }
  123. else {
  124. camera.inertialAlphaOffset += 0.01;
  125. }
  126. }
  127. else if (this.keysDown.indexOf(keyCode) !== -1) {
  128. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  129. camera.inertialPanningY -= 1 / this.panningSensibility;
  130. }
  131. else if (this._altPressed && this.useAltToZoom) {
  132. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  133. }
  134. else {
  135. camera.inertialBetaOffset += 0.01;
  136. }
  137. }
  138. else if (this.keysReset.indexOf(keyCode) !== -1) {
  139. camera.restoreState();
  140. }
  141. }
  142. }
  143. };
  144. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  145. return "ArcRotateCameraKeyboardMoveInput";
  146. };
  147. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  148. return "keyboard";
  149. };
  150. __decorate([
  151. BABYLON.serialize()
  152. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  153. __decorate([
  154. BABYLON.serialize()
  155. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  156. __decorate([
  157. BABYLON.serialize()
  158. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  159. __decorate([
  160. BABYLON.serialize()
  161. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  162. __decorate([
  163. BABYLON.serialize()
  164. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  165. __decorate([
  166. BABYLON.serialize()
  167. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  168. __decorate([
  169. BABYLON.serialize()
  170. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  171. __decorate([
  172. BABYLON.serialize()
  173. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  174. return ArcRotateCameraKeyboardMoveInput;
  175. }());
  176. BABYLON.ArcRotateCameraKeyboardMoveInput = ArcRotateCameraKeyboardMoveInput;
  177. BABYLON.CameraInputTypes["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  178. })(BABYLON || (BABYLON = {}));
  179. //# sourceMappingURL=babylon.arcRotateCameraKeyboardMoveInput.js.map
  180. var BABYLON;
  181. (function (BABYLON) {
  182. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  183. function ArcRotateCameraMouseWheelInput() {
  184. this.wheelPrecision = 3.0;
  185. /**
  186. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  187. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  188. */
  189. this.wheelDeltaPercentage = 0;
  190. }
  191. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  192. var _this = this;
  193. this._wheel = function (p, s) {
  194. //sanity check - this should be a PointerWheel event.
  195. if (p.type !== BABYLON.PointerEventTypes.POINTERWHEEL)
  196. return;
  197. var event = p.event;
  198. var delta = 0;
  199. if (event.wheelDelta) {
  200. delta = _this.wheelDeltaPercentage ? (event.wheelDelta * 0.01) * _this.camera.radius * _this.wheelDeltaPercentage : event.wheelDelta / (_this.wheelPrecision * 40);
  201. }
  202. else if (event.detail) {
  203. delta = -event.detail / _this.wheelPrecision;
  204. }
  205. if (delta)
  206. _this.camera.inertialRadiusOffset += delta;
  207. if (event.preventDefault) {
  208. if (!noPreventDefault) {
  209. event.preventDefault();
  210. }
  211. }
  212. };
  213. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, BABYLON.PointerEventTypes.POINTERWHEEL);
  214. };
  215. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  216. if (this._observer && element) {
  217. this.camera.getScene().onPointerObservable.remove(this._observer);
  218. this._observer = null;
  219. this._wheel = null;
  220. }
  221. };
  222. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  223. return "ArcRotateCameraMouseWheelInput";
  224. };
  225. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  226. return "mousewheel";
  227. };
  228. __decorate([
  229. BABYLON.serialize()
  230. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  231. __decorate([
  232. BABYLON.serialize()
  233. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  234. return ArcRotateCameraMouseWheelInput;
  235. }());
  236. BABYLON.ArcRotateCameraMouseWheelInput = ArcRotateCameraMouseWheelInput;
  237. BABYLON.CameraInputTypes["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  238. })(BABYLON || (BABYLON = {}));
  239. //# sourceMappingURL=babylon.arcRotateCameraMouseWheelInput.js.map
  240. 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}";
  241. 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}";
  242. var BABYLON;
  243. (function (BABYLON) {
  244. var ArcRotateCameraPointersInput = /** @class */ (function () {
  245. function ArcRotateCameraPointersInput() {
  246. this.buttons = [0, 1, 2];
  247. this.angularSensibilityX = 1000.0;
  248. this.angularSensibilityY = 1000.0;
  249. this.pinchPrecision = 12.0;
  250. /**
  251. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  252. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  253. */
  254. this.pinchDeltaPercentage = 0;
  255. this.panningSensibility = 1000.0;
  256. this.multiTouchPanning = true;
  257. this.multiTouchPanAndZoom = true;
  258. this._isPanClick = false;
  259. this.pinchInwards = true;
  260. }
  261. ArcRotateCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  262. var _this = this;
  263. var engine = this.camera.getEngine();
  264. var cacheSoloPointer; // cache pointer object for better perf on camera rotation
  265. var pointA = null;
  266. var pointB = null;
  267. var previousPinchSquaredDistance = 0;
  268. var initialDistance = 0;
  269. var twoFingerActivityCount = 0;
  270. var previousMultiTouchPanPosition = { x: 0, y: 0, isPaning: false, isPinching: false };
  271. this._pointerInput = function (p, s) {
  272. var evt = p.event;
  273. var isTouch = p.event.pointerType === "touch";
  274. if (engine.isInVRExclusivePointerMode) {
  275. return;
  276. }
  277. if (p.type !== BABYLON.PointerEventTypes.POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  278. return;
  279. }
  280. var srcElement = (evt.srcElement || evt.target);
  281. if (p.type === BABYLON.PointerEventTypes.POINTERDOWN && srcElement) {
  282. try {
  283. srcElement.setPointerCapture(evt.pointerId);
  284. }
  285. catch (e) {
  286. //Nothing to do with the error. Execution will continue.
  287. }
  288. // Manage panning with pan button click
  289. _this._isPanClick = evt.button === _this.camera._panningMouseButton;
  290. // manage pointers
  291. cacheSoloPointer = { x: evt.clientX, y: evt.clientY, pointerId: evt.pointerId, type: evt.pointerType };
  292. if (pointA === null) {
  293. pointA = cacheSoloPointer;
  294. }
  295. else if (pointB === null) {
  296. pointB = cacheSoloPointer;
  297. }
  298. if (!noPreventDefault) {
  299. evt.preventDefault();
  300. element.focus();
  301. }
  302. }
  303. else if (p.type === BABYLON.PointerEventTypes.POINTERDOUBLETAP) {
  304. _this.camera.restoreState();
  305. }
  306. else if (p.type === BABYLON.PointerEventTypes.POINTERUP && srcElement) {
  307. try {
  308. srcElement.releasePointerCapture(evt.pointerId);
  309. }
  310. catch (e) {
  311. //Nothing to do with the error.
  312. }
  313. cacheSoloPointer = null;
  314. previousPinchSquaredDistance = 0;
  315. previousMultiTouchPanPosition.isPaning = false;
  316. previousMultiTouchPanPosition.isPinching = false;
  317. twoFingerActivityCount = 0;
  318. initialDistance = 0;
  319. if (!isTouch) {
  320. pointB = null; // Mouse and pen are mono pointer
  321. }
  322. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  323. //but emptying completly pointers collection is required to fix a bug on iPhone :
  324. //when changing orientation while pinching camera, one pointer stay pressed forever if we don't release all pointers
  325. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  326. if (engine.badOS) {
  327. pointA = pointB = null;
  328. }
  329. else {
  330. //only remove the impacted pointer in case of multitouch allowing on most
  331. //platforms switching from rotate to zoom and pan seamlessly.
  332. if (pointB && pointA && pointA.pointerId == evt.pointerId) {
  333. pointA = pointB;
  334. pointB = null;
  335. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  336. }
  337. else if (pointA && pointB && pointB.pointerId == evt.pointerId) {
  338. pointB = null;
  339. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  340. }
  341. else {
  342. pointA = pointB = null;
  343. }
  344. }
  345. if (!noPreventDefault) {
  346. evt.preventDefault();
  347. }
  348. }
  349. else if (p.type === BABYLON.PointerEventTypes.POINTERMOVE) {
  350. if (!noPreventDefault) {
  351. evt.preventDefault();
  352. }
  353. // One button down
  354. if (pointA && pointB === null && cacheSoloPointer) {
  355. if (_this.panningSensibility !== 0 &&
  356. ((evt.ctrlKey && _this.camera._useCtrlForPanning) || _this._isPanClick)) {
  357. _this.camera.inertialPanningX += -(evt.clientX - cacheSoloPointer.x) / _this.panningSensibility;
  358. _this.camera.inertialPanningY += (evt.clientY - cacheSoloPointer.y) / _this.panningSensibility;
  359. }
  360. else {
  361. var offsetX = evt.clientX - cacheSoloPointer.x;
  362. var offsetY = evt.clientY - cacheSoloPointer.y;
  363. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  364. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  365. }
  366. cacheSoloPointer.x = evt.clientX;
  367. cacheSoloPointer.y = evt.clientY;
  368. }
  369. else if (pointA && pointB) {
  370. //if (noPreventDefault) { evt.preventDefault(); } //if pinch gesture, could be useful to force preventDefault to avoid html page scroll/zoom in some mobile browsers
  371. var ed = (pointA.pointerId === evt.pointerId) ? pointA : pointB;
  372. ed.x = evt.clientX;
  373. ed.y = evt.clientY;
  374. var direction = _this.pinchInwards ? 1 : -1;
  375. var distX = pointA.x - pointB.x;
  376. var distY = pointA.y - pointB.y;
  377. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  378. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  379. if (previousPinchSquaredDistance === 0) {
  380. initialDistance = pinchDistance;
  381. previousPinchSquaredDistance = pinchSquaredDistance;
  382. previousMultiTouchPanPosition.x = (pointA.x + pointB.x) / 2;
  383. previousMultiTouchPanPosition.y = (pointA.y + pointB.y) / 2;
  384. return;
  385. }
  386. if (_this.multiTouchPanAndZoom) {
  387. if (_this.pinchDeltaPercentage) {
  388. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  389. }
  390. else {
  391. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  392. (_this.pinchPrecision *
  393. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  394. direction);
  395. }
  396. if (_this.panningSensibility !== 0) {
  397. var pointersCenterX = (pointA.x + pointB.x) / 2;
  398. var pointersCenterY = (pointA.y + pointB.y) / 2;
  399. var pointersCenterDistX = pointersCenterX - previousMultiTouchPanPosition.x;
  400. var pointersCenterDistY = pointersCenterY - previousMultiTouchPanPosition.y;
  401. previousMultiTouchPanPosition.x = pointersCenterX;
  402. previousMultiTouchPanPosition.y = pointersCenterY;
  403. _this.camera.inertialPanningX += -(pointersCenterDistX) / (_this.panningSensibility);
  404. _this.camera.inertialPanningY += (pointersCenterDistY) / (_this.panningSensibility);
  405. }
  406. }
  407. else {
  408. twoFingerActivityCount++;
  409. if (previousMultiTouchPanPosition.isPinching || (twoFingerActivityCount < 20 && Math.abs(pinchDistance - initialDistance) > _this.camera.pinchToPanMaxDistance)) {
  410. if (_this.pinchDeltaPercentage) {
  411. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  412. }
  413. else {
  414. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  415. (_this.pinchPrecision *
  416. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  417. direction);
  418. }
  419. previousMultiTouchPanPosition.isPaning = false;
  420. previousMultiTouchPanPosition.isPinching = true;
  421. }
  422. else {
  423. if (cacheSoloPointer && cacheSoloPointer.pointerId === ed.pointerId && _this.panningSensibility !== 0 && _this.multiTouchPanning) {
  424. if (!previousMultiTouchPanPosition.isPaning) {
  425. previousMultiTouchPanPosition.isPaning = true;
  426. previousMultiTouchPanPosition.isPinching = false;
  427. previousMultiTouchPanPosition.x = ed.x;
  428. previousMultiTouchPanPosition.y = ed.y;
  429. return;
  430. }
  431. _this.camera.inertialPanningX += -(ed.x - previousMultiTouchPanPosition.x) / (_this.panningSensibility);
  432. _this.camera.inertialPanningY += (ed.y - previousMultiTouchPanPosition.y) / (_this.panningSensibility);
  433. }
  434. }
  435. if (cacheSoloPointer && cacheSoloPointer.pointerId === evt.pointerId) {
  436. previousMultiTouchPanPosition.x = ed.x;
  437. previousMultiTouchPanPosition.y = ed.y;
  438. }
  439. }
  440. previousPinchSquaredDistance = pinchSquaredDistance;
  441. }
  442. }
  443. };
  444. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, BABYLON.PointerEventTypes.POINTERDOWN | BABYLON.PointerEventTypes.POINTERUP | BABYLON.PointerEventTypes.POINTERMOVE | BABYLON.PointerEventTypes._POINTERDOUBLETAP);
  445. this._onContextMenu = function (evt) {
  446. evt.preventDefault();
  447. };
  448. if (!this.camera._useCtrlForPanning) {
  449. element.addEventListener("contextmenu", this._onContextMenu, false);
  450. }
  451. this._onLostFocus = function () {
  452. //this._keys = [];
  453. pointA = pointB = null;
  454. previousPinchSquaredDistance = 0;
  455. previousMultiTouchPanPosition.isPaning = false;
  456. previousMultiTouchPanPosition.isPinching = false;
  457. twoFingerActivityCount = 0;
  458. cacheSoloPointer = null;
  459. initialDistance = 0;
  460. };
  461. this._onMouseMove = function (evt) {
  462. if (!engine.isPointerLock) {
  463. return;
  464. }
  465. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  466. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  467. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  468. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  469. if (!noPreventDefault) {
  470. evt.preventDefault();
  471. }
  472. };
  473. this._onGestureStart = function (e) {
  474. if (window.MSGesture === undefined) {
  475. return;
  476. }
  477. if (!_this._MSGestureHandler) {
  478. _this._MSGestureHandler = new MSGesture();
  479. _this._MSGestureHandler.target = element;
  480. }
  481. _this._MSGestureHandler.addPointer(e.pointerId);
  482. };
  483. this._onGesture = function (e) {
  484. _this.camera.radius *= e.scale;
  485. if (e.preventDefault) {
  486. if (!noPreventDefault) {
  487. e.stopPropagation();
  488. e.preventDefault();
  489. }
  490. }
  491. };
  492. element.addEventListener("mousemove", this._onMouseMove, false);
  493. element.addEventListener("MSPointerDown", this._onGestureStart, false);
  494. element.addEventListener("MSGestureChange", this._onGesture, false);
  495. BABYLON.Tools.RegisterTopRootEvents([
  496. { name: "blur", handler: this._onLostFocus }
  497. ]);
  498. };
  499. ArcRotateCameraPointersInput.prototype.detachControl = function (element) {
  500. if (this._onLostFocus) {
  501. BABYLON.Tools.UnregisterTopRootEvents([
  502. { name: "blur", handler: this._onLostFocus }
  503. ]);
  504. }
  505. if (element && this._observer) {
  506. this.camera.getScene().onPointerObservable.remove(this._observer);
  507. this._observer = null;
  508. if (this._onContextMenu) {
  509. element.removeEventListener("contextmenu", this._onContextMenu);
  510. }
  511. if (this._onMouseMove) {
  512. element.removeEventListener("mousemove", this._onMouseMove);
  513. }
  514. if (this._onGestureStart) {
  515. element.removeEventListener("MSPointerDown", this._onGestureStart);
  516. }
  517. if (this._onGesture) {
  518. element.removeEventListener("MSGestureChange", this._onGesture);
  519. }
  520. this._isPanClick = false;
  521. this.pinchInwards = true;
  522. this._onMouseMove = null;
  523. this._onGestureStart = null;
  524. this._onGesture = null;
  525. this._MSGestureHandler = null;
  526. this._onLostFocus = null;
  527. this._onContextMenu = null;
  528. }
  529. };
  530. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  531. return "ArcRotateCameraPointersInput";
  532. };
  533. ArcRotateCameraPointersInput.prototype.getSimpleName = function () {
  534. return "pointers";
  535. };
  536. __decorate([
  537. BABYLON.serialize()
  538. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  539. __decorate([
  540. BABYLON.serialize()
  541. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  542. __decorate([
  543. BABYLON.serialize()
  544. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  545. __decorate([
  546. BABYLON.serialize()
  547. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  548. __decorate([
  549. BABYLON.serialize()
  550. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  551. __decorate([
  552. BABYLON.serialize()
  553. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  554. __decorate([
  555. BABYLON.serialize()
  556. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  557. __decorate([
  558. BABYLON.serialize()
  559. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  560. return ArcRotateCameraPointersInput;
  561. }());
  562. BABYLON.ArcRotateCameraPointersInput = ArcRotateCameraPointersInput;
  563. BABYLON.CameraInputTypes["ArcRotateCameraPointersInput"] = ArcRotateCameraPointersInput;
  564. })(BABYLON || (BABYLON = {}));
  565. //# sourceMappingURL=babylon.arcRotateCameraPointersInput.js.map
  566. var BABYLON;
  567. (function (BABYLON) {
  568. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  569. __extends(ArcRotateCameraInputsManager, _super);
  570. function ArcRotateCameraInputsManager(camera) {
  571. return _super.call(this, camera) || this;
  572. }
  573. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  574. this.add(new BABYLON.ArcRotateCameraMouseWheelInput());
  575. return this;
  576. };
  577. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  578. this.add(new BABYLON.ArcRotateCameraPointersInput());
  579. return this;
  580. };
  581. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  582. this.add(new BABYLON.ArcRotateCameraKeyboardMoveInput());
  583. return this;
  584. };
  585. ArcRotateCameraInputsManager.prototype.addGamepad = function () {
  586. this.add(new BABYLON.ArcRotateCameraGamepadInput());
  587. return this;
  588. };
  589. ArcRotateCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  590. this.add(new BABYLON.ArcRotateCameraVRDeviceOrientationInput());
  591. return this;
  592. };
  593. return ArcRotateCameraInputsManager;
  594. }(BABYLON.CameraInputsManager));
  595. BABYLON.ArcRotateCameraInputsManager = ArcRotateCameraInputsManager;
  596. })(BABYLON || (BABYLON = {}));
  597. //# sourceMappingURL=babylon.arcRotateCameraInputsManager.js.map
  598. var BABYLON;
  599. (function (BABYLON) {
  600. var ArcRotateCamera = /** @class */ (function (_super) {
  601. __extends(ArcRotateCamera, _super);
  602. function ArcRotateCamera(name, alpha, beta, radius, target, scene) {
  603. var _this = _super.call(this, name, BABYLON.Vector3.Zero(), scene) || this;
  604. _this.inertialAlphaOffset = 0;
  605. _this.inertialBetaOffset = 0;
  606. _this.inertialRadiusOffset = 0;
  607. _this.lowerAlphaLimit = null;
  608. _this.upperAlphaLimit = null;
  609. _this.lowerBetaLimit = 0.01;
  610. _this.upperBetaLimit = Math.PI;
  611. _this.lowerRadiusLimit = null;
  612. _this.upperRadiusLimit = null;
  613. _this.inertialPanningX = 0;
  614. _this.inertialPanningY = 0;
  615. _this.pinchToPanMaxDistance = 20;
  616. _this.panningDistanceLimit = null;
  617. _this.panningOriginTarget = BABYLON.Vector3.Zero();
  618. _this.panningInertia = 0.9;
  619. //-- end properties for backward compatibility for inputs
  620. _this.zoomOnFactor = 1;
  621. _this.targetScreenOffset = BABYLON.Vector2.Zero();
  622. _this.allowUpsideDown = true;
  623. _this._viewMatrix = new BABYLON.Matrix();
  624. // Panning
  625. _this.panningAxis = new BABYLON.Vector3(1, 1, 0);
  626. _this.onMeshTargetChangedObservable = new BABYLON.Observable();
  627. _this.checkCollisions = false;
  628. _this.collisionRadius = new BABYLON.Vector3(0.5, 0.5, 0.5);
  629. _this._previousPosition = BABYLON.Vector3.Zero();
  630. _this._collisionVelocity = BABYLON.Vector3.Zero();
  631. _this._newPosition = BABYLON.Vector3.Zero();
  632. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  633. if (collidedMesh === void 0) { collidedMesh = null; }
  634. if (_this.getScene().workerCollisions && _this.checkCollisions) {
  635. newPosition.multiplyInPlace(_this._collider._radius);
  636. }
  637. if (!collidedMesh) {
  638. _this._previousPosition.copyFrom(_this.position);
  639. }
  640. else {
  641. _this.setPosition(newPosition);
  642. if (_this.onCollide) {
  643. _this.onCollide(collidedMesh);
  644. }
  645. }
  646. // Recompute because of constraints
  647. var cosa = Math.cos(_this.alpha);
  648. var sina = Math.sin(_this.alpha);
  649. var cosb = Math.cos(_this.beta);
  650. var sinb = Math.sin(_this.beta);
  651. if (sinb === 0) {
  652. sinb = 0.0001;
  653. }
  654. var target = _this._getTargetPosition();
  655. target.addToRef(new BABYLON.Vector3(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb), _this._newPosition);
  656. _this.position.copyFrom(_this._newPosition);
  657. var up = _this.upVector;
  658. if (_this.allowUpsideDown && _this.beta < 0) {
  659. up = up.clone();
  660. up = up.negate();
  661. }
  662. BABYLON.Matrix.LookAtLHToRef(_this.position, target, up, _this._viewMatrix);
  663. _this._viewMatrix.m[12] += _this.targetScreenOffset.x;
  664. _this._viewMatrix.m[13] += _this.targetScreenOffset.y;
  665. _this._collisionTriggered = false;
  666. };
  667. _this._target = BABYLON.Vector3.Zero();
  668. if (target) {
  669. _this.setTarget(target);
  670. }
  671. _this.alpha = alpha;
  672. _this.beta = beta;
  673. _this.radius = radius;
  674. _this.getViewMatrix();
  675. _this.inputs = new BABYLON.ArcRotateCameraInputsManager(_this);
  676. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  677. return _this;
  678. }
  679. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  680. get: function () {
  681. return this._target;
  682. },
  683. set: function (value) {
  684. this.setTarget(value);
  685. },
  686. enumerable: true,
  687. configurable: true
  688. });
  689. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  690. //-- begin properties for backward compatibility for inputs
  691. get: function () {
  692. var pointers = this.inputs.attached["pointers"];
  693. if (pointers)
  694. return pointers.angularSensibilityX;
  695. return 0;
  696. },
  697. set: function (value) {
  698. var pointers = this.inputs.attached["pointers"];
  699. if (pointers) {
  700. pointers.angularSensibilityX = value;
  701. }
  702. },
  703. enumerable: true,
  704. configurable: true
  705. });
  706. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  707. get: function () {
  708. var pointers = this.inputs.attached["pointers"];
  709. if (pointers)
  710. return pointers.angularSensibilityY;
  711. return 0;
  712. },
  713. set: function (value) {
  714. var pointers = this.inputs.attached["pointers"];
  715. if (pointers) {
  716. pointers.angularSensibilityY = value;
  717. }
  718. },
  719. enumerable: true,
  720. configurable: true
  721. });
  722. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  723. get: function () {
  724. var pointers = this.inputs.attached["pointers"];
  725. if (pointers)
  726. return pointers.pinchPrecision;
  727. return 0;
  728. },
  729. set: function (value) {
  730. var pointers = this.inputs.attached["pointers"];
  731. if (pointers) {
  732. pointers.pinchPrecision = value;
  733. }
  734. },
  735. enumerable: true,
  736. configurable: true
  737. });
  738. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  739. get: function () {
  740. var pointers = this.inputs.attached["pointers"];
  741. if (pointers)
  742. return pointers.pinchDeltaPercentage;
  743. return 0;
  744. },
  745. set: function (value) {
  746. var pointers = this.inputs.attached["pointers"];
  747. if (pointers) {
  748. pointers.pinchDeltaPercentage = value;
  749. }
  750. },
  751. enumerable: true,
  752. configurable: true
  753. });
  754. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  755. get: function () {
  756. var pointers = this.inputs.attached["pointers"];
  757. if (pointers)
  758. return pointers.panningSensibility;
  759. return 0;
  760. },
  761. set: function (value) {
  762. var pointers = this.inputs.attached["pointers"];
  763. if (pointers) {
  764. pointers.panningSensibility = value;
  765. }
  766. },
  767. enumerable: true,
  768. configurable: true
  769. });
  770. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  771. get: function () {
  772. var keyboard = this.inputs.attached["keyboard"];
  773. if (keyboard)
  774. return keyboard.keysUp;
  775. return [];
  776. },
  777. set: function (value) {
  778. var keyboard = this.inputs.attached["keyboard"];
  779. if (keyboard)
  780. keyboard.keysUp = value;
  781. },
  782. enumerable: true,
  783. configurable: true
  784. });
  785. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  786. get: function () {
  787. var keyboard = this.inputs.attached["keyboard"];
  788. if (keyboard)
  789. return keyboard.keysDown;
  790. return [];
  791. },
  792. set: function (value) {
  793. var keyboard = this.inputs.attached["keyboard"];
  794. if (keyboard)
  795. keyboard.keysDown = value;
  796. },
  797. enumerable: true,
  798. configurable: true
  799. });
  800. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  801. get: function () {
  802. var keyboard = this.inputs.attached["keyboard"];
  803. if (keyboard)
  804. return keyboard.keysLeft;
  805. return [];
  806. },
  807. set: function (value) {
  808. var keyboard = this.inputs.attached["keyboard"];
  809. if (keyboard)
  810. keyboard.keysLeft = value;
  811. },
  812. enumerable: true,
  813. configurable: true
  814. });
  815. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  816. get: function () {
  817. var keyboard = this.inputs.attached["keyboard"];
  818. if (keyboard)
  819. return keyboard.keysRight;
  820. return [];
  821. },
  822. set: function (value) {
  823. var keyboard = this.inputs.attached["keyboard"];
  824. if (keyboard)
  825. keyboard.keysRight = value;
  826. },
  827. enumerable: true,
  828. configurable: true
  829. });
  830. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  831. get: function () {
  832. var mousewheel = this.inputs.attached["mousewheel"];
  833. if (mousewheel)
  834. return mousewheel.wheelPrecision;
  835. return 0;
  836. },
  837. set: function (value) {
  838. var mousewheel = this.inputs.attached["mousewheel"];
  839. if (mousewheel)
  840. mousewheel.wheelPrecision = value;
  841. },
  842. enumerable: true,
  843. configurable: true
  844. });
  845. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  846. get: function () {
  847. var mousewheel = this.inputs.attached["mousewheel"];
  848. if (mousewheel)
  849. return mousewheel.wheelDeltaPercentage;
  850. return 0;
  851. },
  852. set: function (value) {
  853. var mousewheel = this.inputs.attached["mousewheel"];
  854. if (mousewheel)
  855. mousewheel.wheelDeltaPercentage = value;
  856. },
  857. enumerable: true,
  858. configurable: true
  859. });
  860. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  861. get: function () {
  862. return this._bouncingBehavior;
  863. },
  864. enumerable: true,
  865. configurable: true
  866. });
  867. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  868. get: function () {
  869. return this._bouncingBehavior != null;
  870. },
  871. set: function (value) {
  872. if (value === this.useBouncingBehavior) {
  873. return;
  874. }
  875. if (value) {
  876. this._bouncingBehavior = new BABYLON.BouncingBehavior();
  877. this.addBehavior(this._bouncingBehavior);
  878. }
  879. else if (this._bouncingBehavior) {
  880. this.removeBehavior(this._bouncingBehavior);
  881. this._bouncingBehavior = null;
  882. }
  883. },
  884. enumerable: true,
  885. configurable: true
  886. });
  887. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  888. get: function () {
  889. return this._framingBehavior;
  890. },
  891. enumerable: true,
  892. configurable: true
  893. });
  894. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  895. get: function () {
  896. return this._framingBehavior != null;
  897. },
  898. set: function (value) {
  899. if (value === this.useFramingBehavior) {
  900. return;
  901. }
  902. if (value) {
  903. this._framingBehavior = new BABYLON.FramingBehavior();
  904. this.addBehavior(this._framingBehavior);
  905. }
  906. else if (this._framingBehavior) {
  907. this.removeBehavior(this._framingBehavior);
  908. this._framingBehavior = null;
  909. }
  910. },
  911. enumerable: true,
  912. configurable: true
  913. });
  914. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  915. get: function () {
  916. return this._autoRotationBehavior;
  917. },
  918. enumerable: true,
  919. configurable: true
  920. });
  921. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  922. get: function () {
  923. return this._autoRotationBehavior != null;
  924. },
  925. set: function (value) {
  926. if (value === this.useAutoRotationBehavior) {
  927. return;
  928. }
  929. if (value) {
  930. this._autoRotationBehavior = new BABYLON.AutoRotationBehavior();
  931. this.addBehavior(this._autoRotationBehavior);
  932. }
  933. else if (this._autoRotationBehavior) {
  934. this.removeBehavior(this._autoRotationBehavior);
  935. this._autoRotationBehavior = null;
  936. }
  937. },
  938. enumerable: true,
  939. configurable: true
  940. });
  941. // Cache
  942. ArcRotateCamera.prototype._initCache = function () {
  943. _super.prototype._initCache.call(this);
  944. this._cache._target = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  945. this._cache.alpha = undefined;
  946. this._cache.beta = undefined;
  947. this._cache.radius = undefined;
  948. this._cache.targetScreenOffset = BABYLON.Vector2.Zero();
  949. };
  950. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  951. if (!ignoreParentClass) {
  952. _super.prototype._updateCache.call(this);
  953. }
  954. this._cache._target.copyFrom(this._getTargetPosition());
  955. this._cache.alpha = this.alpha;
  956. this._cache.beta = this.beta;
  957. this._cache.radius = this.radius;
  958. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  959. };
  960. ArcRotateCamera.prototype._getTargetPosition = function () {
  961. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  962. var pos = this._targetHost.getAbsolutePosition();
  963. if (this._targetBoundingCenter) {
  964. pos.addToRef(this._targetBoundingCenter, this._target);
  965. }
  966. else {
  967. this._target.copyFrom(pos);
  968. }
  969. }
  970. var lockedTargetPosition = this._getLockedTargetPosition();
  971. if (lockedTargetPosition) {
  972. return lockedTargetPosition;
  973. }
  974. return this._target;
  975. };
  976. ArcRotateCamera.prototype.storeState = function () {
  977. this._storedAlpha = this.alpha;
  978. this._storedBeta = this.beta;
  979. this._storedRadius = this.radius;
  980. this._storedTarget = this._getTargetPosition().clone();
  981. return _super.prototype.storeState.call(this);
  982. };
  983. /**
  984. * Restored camera state. You must call storeState() first
  985. */
  986. ArcRotateCamera.prototype._restoreStateValues = function () {
  987. if (!_super.prototype._restoreStateValues.call(this)) {
  988. return false;
  989. }
  990. this.alpha = this._storedAlpha;
  991. this.beta = this._storedBeta;
  992. this.radius = this._storedRadius;
  993. this.setTarget(this._storedTarget.clone());
  994. this.inertialAlphaOffset = 0;
  995. this.inertialBetaOffset = 0;
  996. this.inertialRadiusOffset = 0;
  997. this.inertialPanningX = 0;
  998. this.inertialPanningY = 0;
  999. return true;
  1000. };
  1001. // Synchronized
  1002. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  1003. if (!_super.prototype._isSynchronizedViewMatrix.call(this))
  1004. return false;
  1005. return this._cache._target.equals(this._getTargetPosition())
  1006. && this._cache.alpha === this.alpha
  1007. && this._cache.beta === this.beta
  1008. && this._cache.radius === this.radius
  1009. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  1010. };
  1011. // Methods
  1012. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  1013. var _this = this;
  1014. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  1015. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  1016. this._useCtrlForPanning = useCtrlForPanning;
  1017. this._panningMouseButton = panningMouseButton;
  1018. this.inputs.attachElement(element, noPreventDefault);
  1019. this._reset = function () {
  1020. _this.inertialAlphaOffset = 0;
  1021. _this.inertialBetaOffset = 0;
  1022. _this.inertialRadiusOffset = 0;
  1023. _this.inertialPanningX = 0;
  1024. _this.inertialPanningY = 0;
  1025. };
  1026. };
  1027. ArcRotateCamera.prototype.detachControl = function (element) {
  1028. this.inputs.detachElement(element);
  1029. if (this._reset) {
  1030. this._reset();
  1031. }
  1032. };
  1033. ArcRotateCamera.prototype._checkInputs = function () {
  1034. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  1035. if (this._collisionTriggered) {
  1036. return;
  1037. }
  1038. this.inputs.checkInputs();
  1039. // Inertia
  1040. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  1041. if (this.getScene().useRightHandedSystem) {
  1042. this.alpha -= this.beta <= 0 ? -this.inertialAlphaOffset : this.inertialAlphaOffset;
  1043. }
  1044. else {
  1045. this.alpha += this.beta <= 0 ? -this.inertialAlphaOffset : this.inertialAlphaOffset;
  1046. }
  1047. this.beta += this.inertialBetaOffset;
  1048. this.radius -= this.inertialRadiusOffset;
  1049. this.inertialAlphaOffset *= this.inertia;
  1050. this.inertialBetaOffset *= this.inertia;
  1051. this.inertialRadiusOffset *= this.inertia;
  1052. if (Math.abs(this.inertialAlphaOffset) < BABYLON.Epsilon)
  1053. this.inertialAlphaOffset = 0;
  1054. if (Math.abs(this.inertialBetaOffset) < BABYLON.Epsilon)
  1055. this.inertialBetaOffset = 0;
  1056. if (Math.abs(this.inertialRadiusOffset) < this.speed * BABYLON.Epsilon)
  1057. this.inertialRadiusOffset = 0;
  1058. }
  1059. // Panning inertia
  1060. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  1061. if (!this._localDirection) {
  1062. this._localDirection = BABYLON.Vector3.Zero();
  1063. this._transformedDirection = BABYLON.Vector3.Zero();
  1064. }
  1065. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  1066. this._localDirection.multiplyInPlace(this.panningAxis);
  1067. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  1068. BABYLON.Vector3.TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  1069. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  1070. if (!this.panningAxis.y) {
  1071. this._transformedDirection.y = 0;
  1072. }
  1073. if (!this._targetHost) {
  1074. if (this.panningDistanceLimit) {
  1075. this._transformedDirection.addInPlace(this._target);
  1076. var distanceSquared = BABYLON.Vector3.DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  1077. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  1078. this._target.copyFrom(this._transformedDirection);
  1079. }
  1080. }
  1081. else {
  1082. this._target.addInPlace(this._transformedDirection);
  1083. }
  1084. }
  1085. this.inertialPanningX *= this.panningInertia;
  1086. this.inertialPanningY *= this.panningInertia;
  1087. if (Math.abs(this.inertialPanningX) < this.speed * BABYLON.Epsilon)
  1088. this.inertialPanningX = 0;
  1089. if (Math.abs(this.inertialPanningY) < this.speed * BABYLON.Epsilon)
  1090. this.inertialPanningY = 0;
  1091. }
  1092. // Limits
  1093. this._checkLimits();
  1094. _super.prototype._checkInputs.call(this);
  1095. };
  1096. ArcRotateCamera.prototype._checkLimits = function () {
  1097. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  1098. if (this.allowUpsideDown && this.beta > Math.PI) {
  1099. this.beta = this.beta - (2 * Math.PI);
  1100. }
  1101. }
  1102. else {
  1103. if (this.beta < this.lowerBetaLimit) {
  1104. this.beta = this.lowerBetaLimit;
  1105. }
  1106. }
  1107. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  1108. if (this.allowUpsideDown && this.beta < -Math.PI) {
  1109. this.beta = this.beta + (2 * Math.PI);
  1110. }
  1111. }
  1112. else {
  1113. if (this.beta > this.upperBetaLimit) {
  1114. this.beta = this.upperBetaLimit;
  1115. }
  1116. }
  1117. if (this.lowerAlphaLimit && this.alpha < this.lowerAlphaLimit) {
  1118. this.alpha = this.lowerAlphaLimit;
  1119. }
  1120. if (this.upperAlphaLimit && this.alpha > this.upperAlphaLimit) {
  1121. this.alpha = this.upperAlphaLimit;
  1122. }
  1123. if (this.lowerRadiusLimit && this.radius < this.lowerRadiusLimit) {
  1124. this.radius = this.lowerRadiusLimit;
  1125. }
  1126. if (this.upperRadiusLimit && this.radius > this.upperRadiusLimit) {
  1127. this.radius = this.upperRadiusLimit;
  1128. }
  1129. };
  1130. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
  1131. var radiusv3 = this.position.subtract(this._getTargetPosition());
  1132. this.radius = radiusv3.length();
  1133. if (this.radius === 0) {
  1134. this.radius = 0.0001; // Just to avoid division by zero
  1135. }
  1136. // Alpha
  1137. this.alpha = Math.acos(radiusv3.x / Math.sqrt(Math.pow(radiusv3.x, 2) + Math.pow(radiusv3.z, 2)));
  1138. if (radiusv3.z < 0) {
  1139. this.alpha = 2 * Math.PI - this.alpha;
  1140. }
  1141. // Beta
  1142. this.beta = Math.acos(radiusv3.y / this.radius);
  1143. this._checkLimits();
  1144. };
  1145. ArcRotateCamera.prototype.setPosition = function (position) {
  1146. if (this.position.equals(position)) {
  1147. return;
  1148. }
  1149. this.position.copyFrom(position);
  1150. this.rebuildAnglesAndRadius();
  1151. };
  1152. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  1153. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  1154. if (allowSamePosition === void 0) { allowSamePosition = false; }
  1155. if (target.getBoundingInfo) {
  1156. if (toBoundingCenter) {
  1157. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  1158. }
  1159. else {
  1160. this._targetBoundingCenter = null;
  1161. }
  1162. this._targetHost = target;
  1163. this._target = this._getTargetPosition();
  1164. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  1165. }
  1166. else {
  1167. var newTarget = target;
  1168. var currentTarget = this._getTargetPosition();
  1169. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  1170. return;
  1171. }
  1172. this._targetHost = null;
  1173. this._target = newTarget;
  1174. this._targetBoundingCenter = null;
  1175. this.onMeshTargetChangedObservable.notifyObservers(null);
  1176. }
  1177. this.rebuildAnglesAndRadius();
  1178. };
  1179. ArcRotateCamera.prototype._getViewMatrix = function () {
  1180. // Compute
  1181. var cosa = Math.cos(this.alpha);
  1182. var sina = Math.sin(this.alpha);
  1183. var cosb = Math.cos(this.beta);
  1184. var sinb = Math.sin(this.beta);
  1185. if (sinb === 0) {
  1186. sinb = 0.0001;
  1187. }
  1188. var target = this._getTargetPosition();
  1189. target.addToRef(new BABYLON.Vector3(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb), this._newPosition);
  1190. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  1191. if (!this._collider) {
  1192. this._collider = new BABYLON.Collider();
  1193. }
  1194. this._collider._radius = this.collisionRadius;
  1195. this._newPosition.subtractToRef(this.position, this._collisionVelocity);
  1196. this._collisionTriggered = true;
  1197. this.getScene().collisionCoordinator.getNewPosition(this.position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  1198. }
  1199. else {
  1200. this.position.copyFrom(this._newPosition);
  1201. var up = this.upVector;
  1202. if (this.allowUpsideDown && sinb < 0) {
  1203. up = up.clone();
  1204. up = up.negate();
  1205. }
  1206. if (this.getScene().useRightHandedSystem) {
  1207. BABYLON.Matrix.LookAtRHToRef(this.position, target, up, this._viewMatrix);
  1208. }
  1209. else {
  1210. BABYLON.Matrix.LookAtLHToRef(this.position, target, up, this._viewMatrix);
  1211. }
  1212. this._viewMatrix.m[12] += this.targetScreenOffset.x;
  1213. this._viewMatrix.m[13] += this.targetScreenOffset.y;
  1214. }
  1215. this._currentTarget = target;
  1216. return this._viewMatrix;
  1217. };
  1218. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  1219. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  1220. meshes = meshes || this.getScene().meshes;
  1221. var minMaxVector = BABYLON.Mesh.MinMax(meshes);
  1222. var distance = BABYLON.Vector3.Distance(minMaxVector.min, minMaxVector.max);
  1223. this.radius = distance * this.zoomOnFactor;
  1224. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  1225. };
  1226. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  1227. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  1228. var meshesOrMinMaxVector;
  1229. var distance;
  1230. if (meshesOrMinMaxVectorAndDistance.min === undefined) {
  1231. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  1232. meshesOrMinMaxVector = BABYLON.Mesh.MinMax(meshes);
  1233. distance = BABYLON.Vector3.Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  1234. }
  1235. else {
  1236. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  1237. meshesOrMinMaxVector = minMaxVectorAndDistance;
  1238. distance = minMaxVectorAndDistance.distance;
  1239. }
  1240. this._target = BABYLON.Mesh.Center(meshesOrMinMaxVector);
  1241. if (!doNotUpdateMaxZ) {
  1242. this.maxZ = distance * 2;
  1243. }
  1244. };
  1245. /**
  1246. * @override
  1247. * Override Camera.createRigCamera
  1248. */
  1249. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  1250. var alphaShift = 0;
  1251. switch (this.cameraRigMode) {
  1252. case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  1253. case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  1254. case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  1255. case BABYLON.Camera.RIG_MODE_VR:
  1256. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  1257. break;
  1258. case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  1259. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  1260. break;
  1261. }
  1262. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  1263. rigCam._cameraRigParams = {};
  1264. return rigCam;
  1265. };
  1266. /**
  1267. * @override
  1268. * Override Camera._updateRigCameras
  1269. */
  1270. ArcRotateCamera.prototype._updateRigCameras = function () {
  1271. var camLeft = this._rigCameras[0];
  1272. var camRight = this._rigCameras[1];
  1273. camLeft.beta = camRight.beta = this.beta;
  1274. camLeft.radius = camRight.radius = this.radius;
  1275. switch (this.cameraRigMode) {
  1276. case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  1277. case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  1278. case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  1279. case BABYLON.Camera.RIG_MODE_VR:
  1280. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  1281. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  1282. break;
  1283. case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  1284. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  1285. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  1286. break;
  1287. }
  1288. _super.prototype._updateRigCameras.call(this);
  1289. };
  1290. ArcRotateCamera.prototype.dispose = function () {
  1291. this.inputs.clear();
  1292. _super.prototype.dispose.call(this);
  1293. };
  1294. ArcRotateCamera.prototype.getClassName = function () {
  1295. return "ArcRotateCamera";
  1296. };
  1297. __decorate([
  1298. BABYLON.serialize()
  1299. ], ArcRotateCamera.prototype, "alpha", void 0);
  1300. __decorate([
  1301. BABYLON.serialize()
  1302. ], ArcRotateCamera.prototype, "beta", void 0);
  1303. __decorate([
  1304. BABYLON.serialize()
  1305. ], ArcRotateCamera.prototype, "radius", void 0);
  1306. __decorate([
  1307. BABYLON.serializeAsVector3("target")
  1308. ], ArcRotateCamera.prototype, "_target", void 0);
  1309. __decorate([
  1310. BABYLON.serialize()
  1311. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  1312. __decorate([
  1313. BABYLON.serialize()
  1314. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  1315. __decorate([
  1316. BABYLON.serialize()
  1317. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  1318. __decorate([
  1319. BABYLON.serialize()
  1320. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  1321. __decorate([
  1322. BABYLON.serialize()
  1323. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  1324. __decorate([
  1325. BABYLON.serialize()
  1326. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  1327. __decorate([
  1328. BABYLON.serialize()
  1329. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  1330. __decorate([
  1331. BABYLON.serialize()
  1332. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  1333. __decorate([
  1334. BABYLON.serialize()
  1335. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  1336. __decorate([
  1337. BABYLON.serialize()
  1338. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  1339. __decorate([
  1340. BABYLON.serialize()
  1341. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  1342. __decorate([
  1343. BABYLON.serialize()
  1344. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  1345. __decorate([
  1346. BABYLON.serialize()
  1347. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  1348. __decorate([
  1349. BABYLON.serializeAsVector3()
  1350. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  1351. __decorate([
  1352. BABYLON.serialize()
  1353. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  1354. __decorate([
  1355. BABYLON.serialize()
  1356. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  1357. __decorate([
  1358. BABYLON.serialize()
  1359. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  1360. return ArcRotateCamera;
  1361. }(BABYLON.TargetCamera));
  1362. BABYLON.ArcRotateCamera = ArcRotateCamera;
  1363. })(BABYLON || (BABYLON = {}));
  1364. //# sourceMappingURL=babylon.arcRotateCamera.js.map
  1365. BABYLON.Effect.IncludesShadersStore['depthPrePass'] = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  1366. 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";
  1367. 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";
  1368. BABYLON.Effect.IncludesShadersStore['pointCloudVertexDeclaration'] = "#ifdef POINTSIZE\nuniform float pointSize;\n#endif";
  1369. BABYLON.Effect.IncludesShadersStore['bumpVertexDeclaration'] = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#endif\n";
  1370. BABYLON.Effect.IncludesShadersStore['clipPlaneVertexDeclaration'] = "#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nvarying float fClipDistance;\n#endif";
  1371. BABYLON.Effect.IncludesShadersStore['fogVertexDeclaration'] = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  1372. BABYLON.Effect.IncludesShadersStore['morphTargetsVertexGlobalDeclaration'] = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  1373. 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";
  1374. BABYLON.Effect.IncludesShadersStore['logDepthDeclaration'] = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  1375. 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";
  1376. BABYLON.Effect.IncludesShadersStore['instancesVertex'] = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  1377. 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";
  1378. 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";
  1379. BABYLON.Effect.IncludesShadersStore['clipPlaneVertex'] = "#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif";
  1380. BABYLON.Effect.IncludesShadersStore['fogVertex'] = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  1381. 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";
  1382. BABYLON.Effect.IncludesShadersStore['pointCloudVertex'] = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  1383. BABYLON.Effect.IncludesShadersStore['logDepthVertex'] = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  1384. 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}";
  1385. 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";
  1386. 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";
  1387. 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";
  1388. 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";
  1389. 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";
  1390. 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};";
  1391. 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";
  1392. 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";
  1393. 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}";
  1394. 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";
  1395. 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}";
  1396. 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";
  1397. BABYLON.Effect.IncludesShadersStore['clipPlaneFragmentDeclaration'] = "#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif";
  1398. 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";
  1399. BABYLON.Effect.IncludesShadersStore['clipPlaneFragment'] = "#ifdef CLIPPLANE\nif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif";
  1400. 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";
  1401. 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";
  1402. BABYLON.Effect.IncludesShadersStore['logDepthFragment'] = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  1403. BABYLON.Effect.IncludesShadersStore['fogFragment'] = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  1404. var ArcRotateCameraKeyboardMoveInput = BABYLON.ArcRotateCameraKeyboardMoveInput;
  1405. var ArcRotateCameraMouseWheelInput = BABYLON.ArcRotateCameraMouseWheelInput;
  1406. var ArcRotateCameraPointersInput = BABYLON.ArcRotateCameraPointersInput;
  1407. var ArcRotateCameraInputsManager = BABYLON.ArcRotateCameraInputsManager;
  1408. var ArcRotateCamera = BABYLON.ArcRotateCamera;
  1409. export { ArcRotateCameraKeyboardMoveInput,ArcRotateCameraMouseWheelInput,ArcRotateCameraPointersInput,ArcRotateCameraInputsManager,ArcRotateCamera };