!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs"),require("babylonjs-loaders")):"function"==typeof define&&define.amd?define("babylonjs-sandbox",["babylonjs","babylonjs-loaders"],t):"object"==typeof exports?exports["babylonjs-sandbox"]=t(require("babylonjs"),require("babylonjs-loaders")):e.SANDBOX=t(e.BABYLON,e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(e,t){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=8)}([function(e,t,n){"use strict";e.exports=n(10)},function(t,n){t.exports=e},function(e,t,n){"use strict";var r,o=function(){return void 0===r&&(r=Boolean(window&&document&&document.all&&!window.atob)),r},i=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}(),l=[];function a(e){for(var t=-1,n=0;n0&&this.props.globalState.onError.notifyObservers({scene:this._scene,message:"Scene loaded but several errors were found"});var e=this._scene.activeCamera;e.keysUp&&(e.keysUp.push(90),e.keysUp.push(87),e.keysDown.push(83),e.keysLeft.push(65),e.keysLeft.push(81),e.keysRight.push(69),e.keysRight.push(68))}},t.prototype.prepareLighting=function(){if("gltf"===this._currentPluginName)this._scene.environmentTexture||(this._scene.environmentTexture=f.LoadSkyboxPathTexture(this._scene)),this._scene.environmentTexture&&this._scene.createDefaultSkybox(this._scene.environmentTexture,!0,(this._scene.activeCamera.maxZ-this._scene.activeCamera.minZ)/2,.3,!1);else{for(var e=!1,t=0;t0&&e.props.globalState.showDebugLayer()}))})),this.initEngine())},t.prototype.shouldComponentUpdate=function(e){var t=this;return e.expanded!==this.props.expanded&&(setTimeout((function(){return t._engine.resize()})),!0)},t.prototype.render=function(){return i.createElement("div",{id:"canvasZone",className:this.props.expanded?"expanded":""},i.createElement("canvas",{id:"renderCanvas","touch-action":"none",onContextMenu:function(e){return e.preventDefault()}}))},t}(i.Component),p=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.render=function(){var e=this;return this.props.enabled?i.createElement("div",{className:"button",onClick:function(){return e.props.onClick()}},i.createElement("img",{src:this.props.icon,alt:this.props.label,title:this.props.label})):null},t}(i.Component),h=n(16),m=n(17),g=function(e){function t(t){var n=e.call(this,t)||this;return n.state={isOpen:!1},n._onClickInterceptorClickedObserver=t.globalState.onClickInterceptorClicked.add((function(){n.setState({isOpen:!1})})),n}return o(t,e),t.prototype.componentWillUnmount=function(){this.props.globalState.onClickInterceptorClicked.remove(this._onClickInterceptorClickedObserver)},t.prototype.switchDropUp=function(){this.props.globalState.onRequestClickInterceptor.notifyObservers(),this.setState({isOpen:!this.state.isOpen})},t.prototype.clickOption=function(e){this.switchDropUp(),this.props.onOptionPicked(e)},t.prototype.render=function(){var e=this;return this.props.enabled?i.createElement("div",{className:"dropup"},this.props.icon&&i.createElement("div",{className:"button"+(this.state.isOpen?" active":""),onClick:function(){return e.switchDropUp()}},i.createElement("img",{src:this.props.icon,alt:this.props.label,title:this.props.label})),this.props.selectedOption&&i.createElement("div",{className:"button long"+(this.state.isOpen?" active":""),onClick:function(){return e.switchDropUp()}},this.state.isOpen&&i.createElement("img",{className:"button-icon",src:m,alt:"Close the list",title:"Close the list"}),!this.state.isOpen&&i.createElement("img",{className:"button-icon",src:h,alt:"Open the list",title:"Open the list"}),i.createElement("div",{className:"button-text",title:this.props.selectedOption},this.props.selectedOption)),this.state.isOpen&&i.createElement("div",{className:"dropup-content"+(this.props.selectedOption?" long-mode":"")},this.props.options.map((function(t){return i.createElement("div",{key:t,onClick:function(){return e.clickOption(t)}},t)})))):null},t}(i.Component),v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.onFilePicked=function(e){this.props.onFilesPicked(e.nativeEvent,e.target.files)},t.prototype.render=function(){var e=this;return this.props.enabled?i.createElement("div",{className:"custom-upload",title:this.props.label},i.createElement("img",{src:this.props.icon}),i.createElement("input",{type:"file",id:"files",multiple:!0,onChange:function(t){return e.onFilePicked(t)}})):null},t}(i.Component),y=n(18),b=n(19);n(20);var w=function(e){function t(t){var n=e.call(this,t)||this;return n._sliderRef=i.createRef(),n.state={groupIndex:0},t.globalState.onSceneLoaded.add((function(e){n.registerBeforeRender(e.scene)})),n.props.globalState.currentScene&&n.registerBeforeRender(n.props.globalState.currentScene),n}return o(t,e),t.prototype.getCurrentPosition=function(){if(!this._currentGroup)return"0";if(this._currentGroup.targetedAnimations.length>0){var e=this._currentGroup.targetedAnimations[0].animation.runtimeAnimations;if(e.length>0)return e[0].currentFrame.toString()}return"0"},t.prototype.registerBeforeRender=function(e){var t=this;this._currentScene&&this._currentScene.onBeforeRenderObservable.remove(this._sliderSyncObserver),this._currentScene=e,this._sliderSyncObserver=this._currentScene.onBeforeRenderObservable.add((function(){t._currentGroup&&t._sliderRef.current&&(t._sliderRef.current.value=t.getCurrentPosition(),t._currentPlayingState!==t._currentGroup.isPlaying&&t.forceUpdate())}))},t.prototype.pause=function(){this._currentGroup&&(this._currentGroup.pause(),this.forceUpdate())},t.prototype.play=function(){this._currentGroup&&(this._currentGroup.play(),this.forceUpdate())},t.prototype.sliderInput=function(e){if(this._currentGroup){var t=parseFloat(e.target.value);this._currentGroup.isPlaying?this._currentGroup.goToFrame(t):(this._currentGroup.play(!0),this._currentGroup.goToFrame(t),this._currentGroup.pause())}},t.prototype.render=function(){var e=this;if(!this.props.enabled)return this._currentGroup=null,null;var t=this.props.globalState.currentScene;if(0===t.animationGroups.length)return this._currentGroup=null,null;var n=t.animationGroups.map((function(e){return e.name}));return this._currentGroup=t.animationGroups[this.state.groupIndex],this._currentPlayingState=this._currentGroup.isPlaying,i.createElement("div",{className:"animationBar"},i.createElement("div",{className:"row"},i.createElement("button",{id:"playBtn"},this._currentGroup.isPlaying&&i.createElement("img",{id:"pauseImg",src:b,onClick:function(){return e.pause()}}),!this._currentGroup.isPlaying&&i.createElement("img",{id:"playImg",src:y,onClick:function(){return e.play()}})),i.createElement("input",{ref:this._sliderRef,className:"slider",type:"range",onInput:function(t){return e.sliderInput(t)},min:this._currentGroup.from,max:this._currentGroup.to,onChange:function(){},value:this.getCurrentPosition(),step:"any"})),i.createElement(g,{globalState:this.props.globalState,label:"Active animation group",options:n,selectedOption:this._currentGroup.name,onOptionPicked:function(r){e._currentGroup.stop();var o=n.indexOf(r);e.setState({groupIndex:o}),t.animationGroups[o].play(!0)},enabled:!0}))},t}(i.Component);n(22);var E=n(24),x=n(25),k=n(26),C=n(27),S=function(e){function t(t){var n=e.call(this,t)||this;return t.globalState.onSceneLoaded.add((function(e){n.forceUpdate()})),n}return o(t,e),t.prototype.showInspector=function(){this.props.globalState.currentScene&&(this.props.globalState.currentScene.debugLayer.isVisible()?this.props.globalState.hideDebugLayer():this.props.globalState.showDebugLayer())},t.prototype.render=function(){var e=this;return i.createElement("div",{id:"footer",className:"footer"},i.createElement("div",{className:"footerLeft"},i.createElement("img",{id:"logoImg",src:E})),i.createElement(w,{globalState:this.props.globalState,enabled:!!this.props.globalState.currentScene}),i.createElement("div",{className:"footerRight"},i.createElement(v,{globalState:this.props.globalState,enabled:!0,icon:k,onFilesPicked:function(t,n){e.props.globalState.filesInput.loadFiles(t)},label:"Open your scene from your hard drive (.babylon, .gltf, .glb, .obj)"}),i.createElement(g,{globalState:this.props.globalState,icon:C,label:"Select environment",options:f.SkyboxesNames,onOptionPicked:function(t){return e.props.globalState.onEnvironmentChanged.notifyObservers(t)},enabled:!!this.props.globalState.currentScene}),i.createElement(p,{globalState:this.props.globalState,icon:x,label:"Display inspector",onClick:function(){return e.showInspector()},enabled:!!this.props.globalState.currentScene})))},t}(i.Component);n(28);var T=n(30),_=function(e){function t(t){var n=e.call(this,t)||this;return n._globalState=new u,n._logoRef=i.createRef(),n._dropTextRef=i.createRef(),n._clickInterceptorRef=i.createRef(),n.state={isFooterVisible:!0,errorMessage:""},n.checkUrl(),f.HookWithEnvironmentChange(n._globalState),n._globalState.onSceneLoaded.add((function(e){document.title="Babylon.js - "+e.filename,n._globalState.currentScene=e.scene,0===n._globalState.currentScene.meshes.length&&1===n._globalState.currentScene.clearColor.r&&0===n._globalState.currentScene.clearColor.g&&0===n._globalState.currentScene.clearColor.b?n._logoRef.current.className="":(n._logoRef.current.className="hidden",n._dropTextRef.current.className="hidden")})),n._globalState.onError.add((function(e){e.scene&&n._globalState.showDebugLayer(),e.message&&n.setState({errorMessage:e.message})})),n._globalState.onRequestClickInterceptor.add((function(){var e=n._clickInterceptorRef.current;e.classList.contains("hidden")?e.classList.remove("hidden"):e.classList.add("hidden")})),window.addEventListener("keydown",(function(e){32===e.keyCode&&e.target&&"INPUT"!==e.target.nodeName&&n.setState({isFooterVisible:!n.state.isFooterVisible})})),n}return o(t,e),t.prototype.checkUrl=function(){var e=location.href.indexOf("?");if(-1!==e)for(var t=location.href.substr(e+1).split("&"),n=0;nO.length&&O.push(e)}function R(e,t,n){return null==e?0:function e(t,n,r,o){var a=typeof t;"undefined"!==a&&"boolean"!==a||(t=null);var u=!1;if(null===t)u=!0;else switch(a){case"string":case"number":u=!0;break;case"object":switch(t.$$typeof){case i:case l:u=!0}}if(u)return r(o,t,""===n?"."+I(t,0):n),1;if(u=0,n=""===n?".":n+":",Array.isArray(t))for(var s=0;s