diff --git a/Babylon/JSKompactor.exe b/Babylon/JSKompactor.exe index f03590f25b6..520b74a04ba 100644 Binary files a/Babylon/JSKompactor.exe and b/Babylon/JSKompactor.exe differ diff --git a/Babylon/Tools/babylon.sceneLoader.js b/Babylon/Tools/babylon.sceneLoader.js index 2486aee6947..a6af93744e7 100644 --- a/Babylon/Tools/babylon.sceneLoader.js +++ b/Babylon/Tools/babylon.sceneLoader.js @@ -368,6 +368,12 @@ var BABYLON = BABYLON || {}; mesh.checkCollisions = parsedMesh.checkCollisions; + // Parent + if (parsedMesh.parentId) { + mesh.parent = scene.getLastEntryByID(parsedMesh.parentId); + } + + // Geometry if (parsedMesh.delayLoadingFile) { mesh.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NOTLOADED; mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile; @@ -398,11 +404,6 @@ var BABYLON = BABYLON || {}; BABYLON.SceneLoader._ImportGeometry(parsedMesh, mesh); } - // Parent - if (parsedMesh.parentId) { - mesh.parent = scene.getLastEntryByID(parsedMesh.parentId); - } - // Material if (parsedMesh.materialId) { mesh.setMaterialByID(parsedMesh.materialId); diff --git a/Exporters/Blender/io_export_babylon.py b/Exporters/Blender/io_export_babylon.py index 470d1afe29b..89595696278 100644 --- a/Exporters/Blender/io_export_babylon.py +++ b/Exporters/Blender/io_export_babylon.py @@ -1,7 +1,7 @@ bl_info = { "name": "Babylon.js", "author": "David Catuhe", - "version": (1, 0), + "version": (1, 1), "blender": (2, 67, 0), "location": "File > Export > Babylon.js (.babylon)", "description": "Export Babylon.js scenes (.babylon)", @@ -675,6 +675,38 @@ def export_mesh(object, scene, file_handler, multiMaterials): # Closing file_handler.write("}") + + def export_node(object, scene, file_handler): + # Transform + loc = mathutils.Vector((0, 0, 0)) + rot = mathutils.Quaternion((0, 0, 0, 1)) + scale = mathutils.Vector((1, 1, 1)) + + world = object.matrix_world + if (object.parent): + world = object.parent.matrix_world.inverted() * object.matrix_world + + loc, rot, scale = world.decompose() + + # Writing node + file_handler.write("{") + + Export_babylon.write_string(file_handler, "name", object.name, True) + Export_babylon.write_string(file_handler, "id", object.name) + if object.parent != None: + Export_babylon.write_string(file_handler, "parentId", object.parent.name) + + Export_babylon.write_vector(file_handler, "position", loc) + Export_babylon.write_vectorScaled(file_handler, "rotation", rot.to_euler("XYZ"), -1) + Export_babylon.write_vector(file_handler, "scaling", scale) + Export_babylon.write_bool(file_handler, "isVisible", False) + Export_babylon.write_bool(file_handler, "isEnabled", True) + Export_babylon.write_bool(file_handler, "checkCollisions", False) + Export_babylon.write_int(file_handler, "billboardMode", 0) + Export_babylon.write_bool(file_handler, "receiveShadows", False) + + # Closing + file_handler.write("}") def export_shadowGenerator(lamp, scene, file_handler): file_handler.write("{") @@ -870,12 +902,16 @@ def save(operator, context, filepath="", multiMaterials = [] first = True for object in [object for object in scene.objects]: - if (object.type == 'MESH'): + if object.type == 'MESH' or object.type == 'EMPTY': if first != True: file_handler.write(",") first = False - data_string = Export_babylon.export_mesh(object, scene, file_handler, multiMaterials) + if object.type == 'MESH': + data_string = Export_babylon.export_mesh(object, scene, file_handler, multiMaterials) + else: + data_string = Export_babylon.export_node(object, scene, file_handler) + file_handler.write("]") # Multi-materials diff --git a/babylon.1.7.2.js b/babylon.1.7.3.js similarity index 99% rename from babylon.1.7.2.js rename to babylon.1.7.3.js index d6da7f01816..ea4ecbb6ed2 100644 --- a/babylon.1.7.2.js +++ b/babylon.1.7.3.js @@ -19,4 +19,4 @@ shadowMapPixelShader:"#ifdef GL_ES\nprecision mediump float;\n#endif\n\nvec4 pac shadowMapVertexShader:"#ifdef GL_ES\nprecision mediump float;\n#endif\n\n// Attribute\nattribute vec3 position;\n#ifdef BONES\nattribute vec4 matricesIndices;\nattribute vec4 matricesWeights;\n#endif\n\n// Uniform\n#ifdef BONES\nuniform mat4 world;\nuniform mat4 mBones[BonesPerMesh];\nuniform mat4 viewProjection;\n#else\nuniform mat4 worldViewProjection;\n#endif\n\nvoid main(void)\n{\n#ifdef BONES\n mat4 m0 = mBones[int(matricesIndices.x)] * matricesWeights.x;\n mat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;\n mat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;\n mat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;\n mat4 finalWorld = world * (m0 + m1 + m2 + m3);\n gl_Position = viewProjection * finalWorld * vec4(position, 1.0);\n#else\n gl_Position = worldViewProjection * vec4(position, 1.0);\n#endif\n}", spritesPixelShader:"#ifdef GL_ES\nprecision mediump float;\n#endif\n\nuniform bool alphaTest;\n\nvarying vec4 vColor;\n\n// Samplers\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n// Fog\n#ifdef FOG\n\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\n\nuniform vec4 vFogInfos;\nuniform vec3 vFogColor;\nvarying float fFogDistance;\n\nfloat CalcFogFactor()\n{\n float fogCoeff = 1.0;\n float fogStart = vFogInfos.y;\n float fogEnd = vFogInfos.z;\n float fogDensity = vFogInfos.w;\n\n if (FOGMODE_LINEAR == vFogInfos.x)\n {\n fogCoeff = (fogEnd - fFogDistance) / (fogEnd - fogStart);\n }\n else if (FOGMODE_EXP == vFogInfos.x)\n {\n fogCoeff = 1.0 / pow(E, fFogDistance * fogDensity);\n }\n else if (FOGMODE_EXP2 == vFogInfos.x)\n {\n fogCoeff = 1.0 / pow(E, fFogDistance * fFogDistance * fogDensity * fogDensity);\n }\n\n return min(1., max(0., fogCoeff));\n}\n#endif\n\n\nvoid main(void) {\n vec4 baseColor = texture2D(diffuseSampler, vUV);\n\n if (alphaTest) \n {\n if (baseColor.a < 0.95)\n discard;\n }\n\n baseColor *= vColor;\n\n#ifdef FOG\n float fog = CalcFogFactor();\n baseColor.rgb = fog * baseColor.rgb + (1.0 - fog) * vFogColor;\n#endif\n\n gl_FragColor = baseColor;\n}", spritesVertexShader:"#ifdef GL_ES\nprecision mediump float;\n#endif\n\n// Attributes\nattribute vec3 position;\nattribute vec4 options;\nattribute vec4 cellInfo;\nattribute vec4 color;\n\n// Uniforms\nuniform vec2 textureInfos;\nuniform mat4 view;\nuniform mat4 projection;\n\n// Output\nvarying vec2 vUV;\nvarying vec4 vColor;\n\n#ifdef FOG\nvarying float fFogDistance;\n#endif\n\nvoid main(void) { \n vec3 viewPos = (view * vec4(position, 1.0)).xyz; \n vec3 cornerPos;\n \n float angle = options.x;\n float size = options.y;\n vec2 offset = options.zw;\n vec2 uvScale = textureInfos.xy;\n\n cornerPos = vec3(offset.x - 0.5, offset.y - 0.5, 0.) * size;\n\n // Rotate\n vec3 rotatedCorner;\n rotatedCorner.x = cornerPos.x * cos(angle) - cornerPos.y * sin(angle);\n rotatedCorner.y = cornerPos.x * sin(angle) + cornerPos.y * cos(angle);\n rotatedCorner.z = 0.;\n\n // Position\n viewPos += rotatedCorner;\n gl_Position = projection * vec4(viewPos, 1.0); \n\n // Color\n vColor = color;\n \n // Texture\n vec2 uvOffset = vec2(abs(offset.x - cellInfo.x), 1.0 - abs(offset.y - cellInfo.y));\n\n vUV = (uvOffset + cellInfo.zw) * uvScale;\n\n // Fog\n#ifdef FOG\n fFogDistance = viewPos.z;\n#endif\n}", -};})();var BABYLON=BABYLON||{};(function(){BABYLON.Material=function(name,scene){this.name=name;this.id=name;this._scene=scene;scene.materials.push(this);};BABYLON.Material.prototype.checkReadyOnEveryCall=true;BABYLON.Material.prototype.checkReadyOnlyOnce=false;BABYLON.Material.prototype.alpha=1.0;BABYLON.Material.prototype.wireframe=false;BABYLON.Material.prototype.backFaceCulling=true;BABYLON.Material.prototype._effect=null;BABYLON.Material.prototype._wasPreviouslyReady=false;BABYLON.Material.prototype.onDispose=null;BABYLON.Material.prototype.isReady=function(mesh){return true;};BABYLON.Material.prototype.getEffect=function(){return this._effect;};BABYLON.Material.prototype.needAlphaBlending=function(){return(this.alpha<1.0);};BABYLON.Material.prototype.needAlphaTesting=function(){return false;};BABYLON.Material.prototype._preBind=function(){var engine=this._scene.getEngine();engine.enableEffect(this._effect);engine.setState(this.backFaceCulling);};BABYLON.Material.prototype.bind=function(world,mesh){};BABYLON.Material.prototype.unbind=function(){};BABYLON.Material.prototype.baseDispose=function(){var index=this._scene.materials.indexOf(this);this._scene.materials.splice(index,1);if(this.onDispose){this.onDispose();}};BABYLON.Material.prototype.dispose=function(){this.baseDispose();};})();var BABYLON=BABYLON||{};(function(){BABYLON.StandardMaterial=function(name,scene){BABYLON.Material.call(this,name,scene);this.diffuseTexture=null;this.ambientTexture=null;this.opacityTexture=null;this.reflectionTexture=null;this.emissiveTexture=null;this.specularTexture=null;this.bumpTexture=null;this.ambientColor=new BABYLON.Color3(0,0,0);this.diffuseColor=new BABYLON.Color3(1,1,1);this.specularColor=new BABYLON.Color3(1,1,1);this.specularPower=64;this.emissiveColor=new BABYLON.Color3(0,0,0);this._cachedDefines=null;this._renderTargets=new BABYLON.Tools.SmartArray(16);this._worldViewProjectionMatrix=BABYLON.Matrix.Zero();this._lightMatrix=BABYLON.Matrix.Zero();this._globalAmbientColor=new BABYLON.Color3(0,0,0);this._baseColor=new BABYLON.Color3();this._scaledDiffuse=new BABYLON.Color3();this._scaledSpecular=new BABYLON.Color3();};BABYLON.StandardMaterial.prototype=Object.create(BABYLON.Material.prototype);BABYLON.StandardMaterial.prototype.needAlphaBlending=function(){return(this.alpha<1.0)||(this.opacityTexture!=null);};BABYLON.StandardMaterial.prototype.needAlphaTesting=function(){return this.diffuseTexture!=null&&this.diffuseTexture.hasAlpha;};BABYLON.StandardMaterial.prototype.isReady=function(mesh){if(this.checkReadyOnlyOnce){if(this._wasPreviouslyReady){return true;}}if(!this.checkReadyOnEveryCall){if(this._renderId===this._scene.getRenderId()){return true;}}var engine=this._scene.getEngine();var defines=[];var optionalDefines=[];if(this._scene.texturesEnabled){if(this.diffuseTexture){if(!this.diffuseTexture.isReady()){return false;}else{defines.push("#define DIFFUSE");}}if(this.ambientTexture){if(!this.ambientTexture.isReady()){return false;}else{defines.push("#define AMBIENT");}}if(this.opacityTexture){if(!this.opacityTexture.isReady()){return false;}else{defines.push("#define OPACITY");}}if(this.reflectionTexture){if(!this.reflectionTexture.isReady()){return false;}else{defines.push("#define REFLECTION");}}if(this.emissiveTexture){if(!this.emissiveTexture.isReady()){return false;}else{defines.push("#define EMISSIVE");}}if(this.specularTexture){if(!this.specularTexture.isReady()){return false;}else{defines.push("#define SPECULAR");optionalDefines.push(defines[defines.length-1]);}}}if(this._scene.getEngine().getCaps().standardDerivatives&&this.bumpTexture){if(!this.bumpTexture.isReady()){return false;}else{defines.push("#define BUMP");optionalDefines.push(defines[defines.length-1]);}}if(BABYLON.clipPlane){defines.push("#define CLIPPLANE");}if(engine.getAlphaTesting()){defines.push("#define ALPHATEST");}if(this._scene.fogMode!==BABYLON.Scene.FOGMODE_NONE){defines.push("#define FOG");optionalDefines.push(defines[defines.length-1]);}var shadowsActivated=false;var lightIndex=0;if(this._scene.lightsEnabled){for(var index=0;index0){optionalDefines.push(defines[defines.length-1]);}var type;if(light instanceof BABYLON.SpotLight){type="#define SPOTLIGHT"+lightIndex;}else if(light instanceof BABYLON.HemisphericLight){type="#define HEMILIGHT"+lightIndex;}else{type="#define POINTDIRLIGHT"+lightIndex;}defines.push(type);if(lightIndex>0){optionalDefines.push(defines[defines.length-1]);}var shadowGenerator=light.getShadowGenerator();if(mesh&&mesh.receiveShadows&&shadowGenerator){defines.push("#define SHADOW"+lightIndex);if(lightIndex>0){optionalDefines.push(defines[defines.length-1]);}if(!shadowsActivated){defines.push("#define SHADOWS");shadowsActivated=true;}if(shadowGenerator.useVarianceShadowMap){defines.push("#define SHADOWVSM"+lightIndex);if(lightIndex>0){optionalDefines.push(defines[defines.length-1]);}}}lightIndex++;if(lightIndex==4)break;}}var attribs=[BABYLON.VertexBuffer.PositionKind,BABYLON.VertexBuffer.NormalKind];if(mesh){if(mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)){attribs.push(BABYLON.VertexBuffer.UVKind);defines.push("#define UV1");}if(mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UV2Kind)){attribs.push(BABYLON.VertexBuffer.UV2Kind);defines.push("#define UV2");}if(mesh.isVerticesDataPresent(BABYLON.VertexBuffer.ColorKind)){attribs.push(BABYLON.VertexBuffer.ColorKind);defines.push("#define VERTEXCOLOR");}if(mesh.skeleton&&mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesIndicesKind)&&mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesWeightsKind)){attribs.push(BABYLON.VertexBuffer.MatricesIndicesKind);attribs.push(BABYLON.VertexBuffer.MatricesWeightsKind);defines.push("#define BONES");defines.push("#define BonesPerMesh "+mesh.skeleton.bones.length);defines.push("#define BONES4");optionalDefines.push(defines[defines.length-1]);}}var join=defines.join("\n");if(this._cachedDefines!=join){this._cachedDefines=join;var shaderName="default";if(BABYLON.Tools.isIE()){shaderName="iedefault";}this._effect=this._scene.getEngine().createEffect(shaderName,attribs,["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","vLightData0","vLightDiffuse0","vLightSpecular0","vLightDirection0","vLightGround0","lightMatrix0","vLightData1","vLightDiffuse1","vLightSpecular1","vLightDirection1","vLightGround1","lightMatrix1","vLightData2","vLightDiffuse2","vLightSpecular2","vLightDirection2","vLightGround2","lightMatrix2","vLightData3","vLightDiffuse3","vLightSpecular3","vLightDirection3","vLightGround3","lightMatrix3","vFogInfos","vFogColor","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","mBones","vClipPlane","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix"],["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","shadowSampler0","shadowSampler1","shadowSampler2","shadowSampler3"],join,optionalDefines);}if(!this._effect.isReady()){return false;}this._renderId=this._scene.getRenderId();this._wasPreviouslyReady=true;return true;};BABYLON.StandardMaterial.prototype.getRenderTargetTextures=function(){this._renderTargets.reset();if(this.reflectionTexture&&this.reflectionTexture.isRenderTarget){this._renderTargets.push(this.reflectionTexture);}return this._renderTargets;};BABYLON.StandardMaterial.prototype.unbind=function(){if(this.reflectionTexture&&this.reflectionTexture.isRenderTarget){this._effect.setTexture("reflection2DSampler",null);}};BABYLON.StandardMaterial.prototype.bind=function(world,mesh){this._baseColor.copyFrom(this.diffuseColor);this._effect.setMatrix("world",world);this._effect.setMatrix("viewProjection",this._scene.getTransformMatrix());if(mesh.skeleton&&mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesIndicesKind)&&mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesWeightsKind)){this._effect.setMatrices("mBones",mesh.skeleton.getTransformMatrices());}if(this.diffuseTexture){this._effect.setTexture("diffuseSampler",this.diffuseTexture);this._effect.setFloat2("vDiffuseInfos",this.diffuseTexture.coordinatesIndex,this.diffuseTexture.level);this._effect.setMatrix("diffuseMatrix",this.diffuseTexture._computeTextureMatrix());this._baseColor.copyFromFloats(1,1,1);}if(this.ambientTexture){this._effect.setTexture("ambientSampler",this.ambientTexture);this._effect.setFloat2("vAmbientInfos",this.ambientTexture.coordinatesIndex,this.ambientTexture.level);this._effect.setMatrix("ambientMatrix",this.ambientTexture._computeTextureMatrix());}if(this.opacityTexture){this._effect.setTexture("opacitySampler",this.opacityTexture);this._effect.setFloat2("vOpacityInfos",this.opacityTexture.coordinatesIndex,this.opacityTexture.level);this._effect.setMatrix("opacityMatrix",this.opacityTexture._computeTextureMatrix());}if(this.reflectionTexture){if(this.reflectionTexture.isCube){this._effect.setTexture("reflectionCubeSampler",this.reflectionTexture);}else{this._effect.setTexture("reflection2DSampler",this.reflectionTexture);}this._effect.setMatrix("reflectionMatrix",this.reflectionTexture._computeReflectionTextureMatrix());this._effect.setFloat3("vReflectionInfos",this.reflectionTexture.coordinatesMode,this.reflectionTexture.level,this.reflectionTexture.isCube?1:0);}if(this.emissiveTexture){this._effect.setTexture("emissiveSampler",this.emissiveTexture);this._effect.setFloat2("vEmissiveInfos",this.emissiveTexture.coordinatesIndex,this.emissiveTexture.level);this._effect.setMatrix("emissiveMatrix",this.emissiveTexture._computeTextureMatrix());}if(this.specularTexture){this._effect.setTexture("specularSampler",this.specularTexture);this._effect.setFloat2("vSpecularInfos",this.specularTexture.coordinatesIndex,this.specularTexture.level);this._effect.setMatrix("specularMatrix",this.specularTexture._computeTextureMatrix());}if(this.bumpTexture&&this._scene.getEngine().getCaps().standardDerivatives){this._effect.setTexture("bumpSampler",this.bumpTexture);this._effect.setFloat2("vBumpInfos",this.bumpTexture.coordinatesIndex,this.bumpTexture.level);this._effect.setMatrix("bumpMatrix",this.bumpTexture._computeTextureMatrix());}this._scene.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor);this._effect.setVector3("vEyePosition",this._scene.activeCamera.position);this._effect.setColor3("vAmbientColor",this._globalAmbientColor);this._effect.setColor4("vDiffuseColor",this._baseColor,this.alpha*mesh.visibility);this._effect.setColor4("vSpecularColor",this.specularColor,this.specularPower);this._effect.setColor3("vEmissiveColor",this.emissiveColor);if(this._scene.lightsEnabled){var lightIndex=0;for(var index=0;index0){results.push(this.diffuseTexture);}if(this.ambientTexture&&this.ambientTexture.animations&&this.ambientTexture.animations.length>0){results.push(this.ambientTexture);}if(this.opacityTexture&&this.opacityTexture.animations&&this.opacityTexture.animations.length>0){results.push(this.opacityTexture);}if(this.reflectionTexture&&this.reflectionTexture.animations&&this.reflectionTexture.animations.length>0){results.push(this.reflectionTexture);}if(this.emissiveTexture&&this.emissiveTexture.animations&&this.emissiveTexture.animations.length>0){results.push(this.emissiveTexture);}if(this.specularTexture&&this.specularTexture.animations&&this.specularTexture.animations.length>0){results.push(this.specularTexture);}if(this.bumpTexture&&this.bumpTexture.animations&&this.bumpTexture.animations.length>0){results.push(this.bumpTexture);}return results;};BABYLON.StandardMaterial.prototype.dispose=function(){if(this.diffuseTexture){this.diffuseTexture.dispose();}if(this.ambientTexture){this.ambientTexture.dispose();}if(this.opacityTexture){this.opacityTexture.dispose();}if(this.reflectionTexture){this.reflectionTexture.dispose();}if(this.emissiveTexture){this.emissiveTexture.dispose();}if(this.specularTexture){this.specularTexture.dispose();}if(this.bumpTexture){this.bumpTexture.dispose();}this.baseDispose();};BABYLON.StandardMaterial.prototype.clone=function(name){var newStandardMaterial=new BABYLON.StandardMaterial(name,this._scene);newStandardMaterial.checkReadyOnEveryCall=this.checkReadyOnEveryCall;newStandardMaterial.alpha=this.alpha;newStandardMaterial.wireframe=this.wireframe;newStandardMaterial.backFaceCulling=this.backFaceCulling;if(this.diffuseTexture&&this.diffuseTexture.clone){newStandardMaterial.diffuseTexture=this.diffuseTexture.clone();}if(this.ambientTexture&&this.ambientTexture.clone){newStandardMaterial.ambientTexture=this.ambientTexture.clone();}if(this.opacityTexture&&this.opacityTexture.clone){newStandardMaterial.opacityTexture=this.opacityTexture.clone();}if(this.reflectionTexture&&this.reflectionTexture.clone){newStandardMaterial.reflectionTexture=this.reflectionTexture.clone();}if(this.emissiveTexture&&this.emissiveTexture.clone){newStandardMaterial.emissiveTexture=this.emissiveTexture.clone();}if(this.specularTexture&&this.specularTexture.clone){newStandardMaterial.specularTexture=this.specularTexture.clone();}if(this.bumpTexture&&this.bumpTexture.clone){newStandardMaterial.bumpTexture=this.bumpTexture.clone();}newStandardMaterial.ambientColor=this.ambientColor.clone();newStandardMaterial.diffuseColor=this.diffuseColor.clone();newStandardMaterial.specularColor=this.specularColor.clone();newStandardMaterial.specularPower=this.specularPower;newStandardMaterial.emissiveColor=this.emissiveColor.clone();return newStandardMaterial;};})();var BABYLON=BABYLON||{};(function(){BABYLON.MultiMaterial=function(name,scene){this.name=name;this.id=name;this._scene=scene;scene.multiMaterials.push(this);this.subMaterials=[];};BABYLON.MultiMaterial.prototype.getSubMaterial=function(index){if(index<0||index>=this.subMaterials.length){return this._scene.defaultMaterial;}return this.subMaterials[index];};BABYLON.MultiMaterial.prototype.isReady=function(mesh){var result=true;for(var index=0;indexversion.data){that.mustUpdateRessources=true;updateInDBCallback();}else{callback(version.data);}}else{that.mustUpdateRessources=true;updateInDBCallback();}};transaction.onabort=function(event){callback(-1);};var getRequest=transaction.objectStore("versions").get(url);getRequest.onsuccess=function(event){version=event.target.result;};getRequest.onerror=function(event){console.log("Error loading version for scene "+url+" from DB.");callback(-1);};}catch(ex){console.log("Error while accessing 'versions' object store (READ OP). Exception: "+ex.message);callback(-1);}}else{console.log("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");callback(-1);}};BABYLON.Database.prototype._saveVersionIntoDBAsync=function(url,callback){if(this.isSupported&&!this.hasReachedQuota){var that=this;try{var transaction=this.db.transaction(["versions"],"readwrite");transaction.onabort=function(event){try{if(event.srcElement.error.name==="QuotaExceededError"){that.hasReachedQuota=true;}}catch(ex){}callback(-1);};transaction.oncomplete=function(event){callback(that.manifestVersionFound);};var newVersion={};newVersion.sceneUrl=url;newVersion.data=this.manifestVersionFound;var addRequest=transaction.objectStore("versions").put(newVersion);addRequest.onsuccess=function(event){console.log("");};addRequest.onerror=function(event){console.log("Error in DB add version request in BABYLON.Database.");};}catch(ex){console.log("Error while accessing 'versions' object store (WRITE OP). Exception: "+ex.message);callback(-1);}}else{callback(-1);}};BABYLON.Database.prototype.loadSceneFromDB=function(url,sceneLoaded,progressCallBack,errorCallback){var that=this;var completeUrl=BABYLON.Database.ReturnFullUrlLocation(url);var saveAndLoadScene=function(event){that._saveSceneIntoDBAsync(completeUrl,sceneLoaded,progressCallBack);};this._checkVersionFromDB(completeUrl,function(version){if(version!==-1){if(!that.mustUpdateRessources){that._loadSceneFromDBAsync(completeUrl,sceneLoaded,saveAndLoadScene);}else{that._saveSceneIntoDBAsync(completeUrl,sceneLoaded,progressCallBack);}}else{errorCallback();}});};BABYLON.Database.prototype._loadSceneFromDBAsync=function(url,callback,notInDBCallback){if(this.isSupported){var scene;var transaction=this.db.transaction(["scenes"]);transaction.oncomplete=function(event){if(scene){callback(scene.data);}else{notInDBCallback();}};transaction.onabort=function(event){notInDBCallback();};var getRequest=transaction.objectStore("scenes").get(url);getRequest.onsuccess=function(event){scene=event.target.result;};getRequest.onerror=function(event){console.log("Error loading scene "+url+" from DB.");notInDBCallback();};}else{console.log("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");callback();}};BABYLON.Database.prototype._saveSceneIntoDBAsync=function(url,callback,progressCallback){if(this.isSupported){var xhr=new XMLHttpRequest(),sceneText;var that=this;xhr.open("GET",url,true);xhr.onprogress=progressCallback;xhr.addEventListener("load",function(){if(xhr.status===200){sceneText=xhr.responseText;if(!that.hasReachedQuota){var transaction=that.db.transaction(["scenes"],"readwrite");transaction.onabort=function(event){try{if(event.srcElement.error.name==="QuotaExceededError"){that.hasReachedQuota=true;}}catch(ex){}callback(sceneText);};transaction.oncomplete=function(event){callback(sceneText);};var newScene={};newScene.sceneUrl=url;newScene.data=sceneText;newScene.version=that.manifestVersionFound;try{var addRequest=transaction.objectStore("scenes").put(newScene);addRequest.onsuccess=function(event){console.log("");};addRequest.onerror=function(event){console.log("Error in DB add scene request in BABYLON.Database.");};}catch(ex){callback(sceneText);}}else{callback(sceneText);}}else{callback();}},false);xhr.addEventListener("error",function(event){console.log("error on XHR request.");callback();},false);xhr.send();}else{console.log("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");callback();}};})();var BABYLON=BABYLON||{};(function(){var loadCubeTexture=function(rootUrl,parsedTexture,scene){var texture=new BABYLON.CubeTexture(rootUrl+parsedTexture.name,scene);texture.name=parsedTexture.name;texture.hasAlpha=parsedTexture.hasAlpha;texture.level=parsedTexture.level;texture.coordinatesMode=parsedTexture.coordinatesMode;return texture;};var loadTexture=function(rootUrl,parsedTexture,scene){if(!parsedTexture.name&&!parsedTexture.isRenderTarget){return null;}if(parsedTexture.isCube){return loadCubeTexture(rootUrl,parsedTexture,scene);}var texture;if(parsedTexture.mirrorPlane){texture=new BABYLON.MirrorTexture(parsedTexture.name,parsedTexture.renderTargetSize,scene);texture._waitingRenderList=parsedTexture.renderList;texture.mirrorPlane=BABYLON.Plane.FromArray(parsedTexture.mirrorPlane);}else if(parsedTexture.isRenderTarget){texture=new BABYLON.RenderTargetTexture(parsedTexture.name,parsedTexture.renderTargetSize,scene);texture._waitingRenderList=parsedTexture.renderList;}else{texture=new BABYLON.Texture(rootUrl+parsedTexture.name,scene);}texture.name=parsedTexture.name;texture.hasAlpha=parsedTexture.hasAlpha;texture.level=parsedTexture.level;texture.coordinatesIndex=parsedTexture.coordinatesIndex;texture.coordinatesMode=parsedTexture.coordinatesMode;texture.uOffset=parsedTexture.uOffset;texture.vOffset=parsedTexture.vOffset;texture.uScale=parsedTexture.uScale;texture.vScale=parsedTexture.vScale;texture.uAng=parsedTexture.uAng;texture.vAng=parsedTexture.vAng;texture.wAng=parsedTexture.wAng;texture.wrapU=parsedTexture.wrapU;texture.wrapV=parsedTexture.wrapV;if(parsedTexture.animations){for(var animationIndex=0;animationIndex-1){parentBone=skeleton.bones[parsedBone.parentBoneIndex];}var bone=new BABYLON.Bone(parsedBone.name,skeleton,parentBone,BABYLON.Matrix.FromArray(parsedBone.matrix));if(parsedBone.animation){bone.animations.push(parseAnimation(parsedBone.animation));}}return skeleton;};var parseMaterial=function(parsedMaterial,scene,rootUrl){var material;material=new BABYLON.StandardMaterial(parsedMaterial.name,scene);material.ambientColor=BABYLON.Color3.FromArray(parsedMaterial.ambient);material.diffuseColor=BABYLON.Color3.FromArray(parsedMaterial.diffuse);material.specularColor=BABYLON.Color3.FromArray(parsedMaterial.specular);material.specularPower=parsedMaterial.specularPower;material.emissiveColor=BABYLON.Color3.FromArray(parsedMaterial.emissive);material.alpha=parsedMaterial.alpha;material.id=parsedMaterial.id;material.backFaceCulling=parsedMaterial.backFaceCulling;if(parsedMaterial.diffuseTexture){material.diffuseTexture=loadTexture(rootUrl,parsedMaterial.diffuseTexture,scene);}if(parsedMaterial.ambientTexture){material.ambientTexture=loadTexture(rootUrl,parsedMaterial.ambientTexture,scene);}if(parsedMaterial.opacityTexture){material.opacityTexture=loadTexture(rootUrl,parsedMaterial.opacityTexture,scene);}if(parsedMaterial.reflectionTexture){material.reflectionTexture=loadTexture(rootUrl,parsedMaterial.reflectionTexture,scene);}if(parsedMaterial.emissiveTexture){material.emissiveTexture=loadTexture(rootUrl,parsedMaterial.emissiveTexture,scene);}if(parsedMaterial.specularTexture){material.specularTexture=loadTexture(rootUrl,parsedMaterial.specularTexture,scene);}if(parsedMaterial.bumpTexture){material.bumpTexture=loadTexture(rootUrl,parsedMaterial.bumpTexture,scene);}return material;};var parseMaterialById=function(id,parsedData,scene,rootUrl){for(var index=0;index-1){mesh.skeleton=scene.getLastSkeletonByID(parsedMesh.skeletonId);}if(parsedMesh.animations){for(var animationIndex=0;animationIndex>8);floatIndices.push((matricesIndex&0x00FF0000)>>16);floatIndices.push(matricesIndex>>24);}mesh.setVerticesData(floatIndices,BABYLON.VertexBuffer.MatricesIndicesKind,false);}if(parsedGeometry.matricesWeights){mesh.setVerticesData(parsedGeometry.matricesWeights,BABYLON.VertexBuffer.MatricesWeightsKind,false);}mesh.setIndices(parsedGeometry.indices);}if(parsedGeometry.subMeshes){mesh.subMeshes=[];for(var subIndex=0;subIndex-1&&scene.skeletons){var skeletonAlreadyLoaded=(loadedSkeletonsIds.indexOf(parsedMesh.skeletonId)>-1);if(!skeletonAlreadyLoaded){for(var skeletonIndex=0;skeletonIndex>0;this._vertices[arrayOffset+9]=sprite.cellIndex-offset*rowSize;this._vertices[arrayOffset+10]=offset;this._vertices[arrayOffset+11]=sprite.color.r;this._vertices[arrayOffset+12]=sprite.color.g;this._vertices[arrayOffset+13]=sprite.color.b;this._vertices[arrayOffset+14]=sprite.color.a;};BABYLON.SpriteManager.prototype.render=function(){if(!this._effectBase.isReady()||!this._effectFog.isReady()||!this._spriteTexture||!this._spriteTexture.isReady())return 0;var engine=this._scene.getEngine();var baseSize=this._spriteTexture.getBaseSize();var deltaTime=BABYLON.Tools.GetDeltaTime();var max=Math.min(this._capacity,this.sprites.length);var rowSize=baseSize.width/this.cellSize;var offset=0;for(var index=0;indexthis._delay){this._time=this._time%this._delay;this.cellIndex+=this._direction;if(this.cellIndex==this._toIndex){if(this._loopAnimation){this.cellIndex=this._fromIndex;}else{this._animationStarted=false;if(this.disposeWhenFinishedAnimating){this.dispose();}}}}};BABYLON.Sprite.prototype.dispose=function(){for(var i=0;i0;for(var index=0;index=particle.lifeTime){this._stockParticles.push(this.particles.splice(index,1)[0]);index--;continue;}else{particle.colorStep.scaleToRef(this._scaledUpdateSpeed,this._scaledColorStep);particle.color.addInPlace(this._scaledColorStep);if(particle.color.a<0)particle.color.a=0;particle.direction.scaleToRef(this._scaledUpdateSpeed,this._scaledDirection);particle.position.addInPlace(this._scaledDirection);particle.angle+=particle.angularSpeed*this._scaledUpdateSpeed;this.gravity.scaleToRef(this._scaledUpdateSpeed,this._scaledGravity);particle.direction.addInPlace(this._scaledGravity);}}var worldMatrix;if(this.emitter.position){worldMatrix=this.emitter.getWorldMatrix();}else{worldMatrix=BABYLON.Matrix.Translation(this.emitter.x,this.emitter.y,this.emitter.z);}for(var index=0;index-1){emitCout=this.manualEmitCount;this.manualEmitCount=0;}else{emitCout=this.emitRate;}var newParticles=((emitCout*this._scaledUpdateSpeed)>>0);this._newPartsExcess+=emitCout*this._scaledUpdateSpeed-newParticles;if(this._newPartsExcess>1.0){newParticles+=this._newPartsExcess>>0;this._newPartsExcess-=this._newPartsExcess>>0;}this._alive=false;if(!this._stopped){this._actualFrame+=this._scaledUpdateSpeed;if(this.targetStopDuration&&this._actualFrame>=this.targetStopDuration)this.stop();}else{newParticles=0;}this._update(newParticles);if(this._stopped){if(!this._alive){this._started=false;if(this.disposeOnStop){this._scene._toBeDisposed.push(this);}}}var offset=0;for(var index=0;index0){return highLimitValue.clone?highLimitValue.clone():highLimitValue;}for(var key=0;key=currentFrame){var startValue=this._keys[key].value;var endValue=this._keys[key+1].value;var gradient=(currentFrame-this._keys[key].frame)/(this._keys[key+1].frame-this._keys[key].frame);switch(this.dataType){case BABYLON.Animation.ANIMATIONTYPE_FLOAT:switch(loopMode){case BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE:case BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT:return startValue+(endValue-startValue)*gradient;case BABYLON.Animation.ANIMATIONLOOPMODE_RELATIVE:return offsetValue*repeatCount+(startValue+(endValue-startValue)*gradient);}break;case BABYLON.Animation.ANIMATIONTYPE_QUATERNION:var quaternion=null;switch(loopMode){case BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE:case BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT:quaternion=BABYLON.Quaternion.Slerp(startValue,endValue,gradient);break;case BABYLON.Animation.ANIMATIONLOOPMODE_RELATIVE:quaternion=BABYLON.Quaternion.Slerp(startValue,endValue,gradient).add(offsetValue.scale(repeatCount));break;}return quaternion;case BABYLON.Animation.ANIMATIONTYPE_VECTOR3:switch(loopMode){case BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE:case BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT:return BABYLON.Vector3.Lerp(startValue,endValue,gradient);case BABYLON.Animation.ANIMATIONLOOPMODE_RELATIVE:return BABYLON.Vector3.Lerp(startValue,endValue,gradient).add(offsetValue.scale(repeatCount));}case BABYLON.Animation.ANIMATIONTYPE_MATRIX:switch(loopMode){case BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE:case BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT:case BABYLON.Animation.ANIMATIONLOOPMODE_RELATIVE:return startValue;}default:break;}break;}}return this._keys[this._keys.length-1].value;};BABYLON.Animation.prototype.animate=function(target,delay,from,to,loop,speedRatio){if(!this.targetPropertyPath||this.targetPropertyPath.length<1){return false;}var returnValue=true;if(this._keys[0].frame!=0){var newKey={frame:0,value:this._keys[0].value};this._keys.splice(0,0,newKey);}if(fromthis._keys[this._keys.length-1].frame){from=this._keys[0].frame;}if(tothis._keys[this._keys.length-1].frame){to=this._keys[this._keys.length-1].frame;}var range=to-from;var ratio=delay*(this.framePerSecond*speedRatio)/1000.0;if(ratio>range&&!loop){offsetValue=0;returnValue=false;}else{var offsetValue=0;var highLimitValue=0;if(this.loopMode!=BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE){var keyOffset=to.toString()+from.toString();if(!this._offsetsCache[keyOffset]){var fromValue=this._interpolate(from,0,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);var toValue=this._interpolate(to,0,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);switch(this.dataType){case BABYLON.Animation.ANIMATIONTYPE_FLOAT:this._offsetsCache[keyOffset]=toValue-fromValue;break;case BABYLON.Animation.ANIMATIONTYPE_QUATERNION:this._offsetsCache[keyOffset]=toValue.subtract(fromValue);break;case BABYLON.Animation.ANIMATIONTYPE_VECTOR3:this._offsetsCache[keyOffset]=toValue.subtract(fromValue);default:break;}this._highLimitsCache[keyOffset]=toValue;}highLimitValue=this._highLimitsCache[keyOffset];offsetValue=this._offsetsCache[keyOffset];}}var repeatCount=(ratio/range)>>0;var currentFrame=returnValue?from+ratio%range:to;var currentValue=this._interpolate(currentFrame,repeatCount,this.loopMode,offsetValue,highLimitValue);if(this.targetPropertyPath.length>1){var property=target[this.targetPropertyPath[0]];for(var index=1;indexthis._capacity){BABYLON.Octree._CreateBlocks(this._minPoint,this._maxPoint,this.meshes,this._capacity,this);}};BABYLON.OctreeBlock.prototype.addEntries=function(meshes){for(var index=0;index0){this._camera.postProcesses[0].width=-1;}};})();var BABYLON=BABYLON||{};(function(){BABYLON.PostProcessManager=function(scene){this._scene=scene;var vertices=[];vertices.push(1,1);vertices.push(-1,1);vertices.push(-1,-1);vertices.push(1,-1);this._vertexDeclaration=[2];this._vertexStrideSize=2*4;this._vertexBuffer=scene.getEngine().createVertexBuffer(vertices);var indices=[];indices.push(0);indices.push(1);indices.push(2);indices.push(0);indices.push(2);indices.push(3);this._indexBuffer=scene.getEngine().createIndexBuffer(indices);};BABYLON.PostProcessManager.prototype._prepareFrame=function(){var postProcesses=this._scene.activeCamera.postProcesses;if(postProcesses.length===0||!this._scene.postProcessesEnabled){return;}postProcesses[0].activate();};BABYLON.PostProcessManager.prototype._finalizeFrame=function(){var postProcesses=this._scene.activeCamera.postProcesses;if(postProcesses.length===0||!this._scene.postProcessesEnabled){return;}var engine=this._scene.getEngine();for(var index=0;index0){if((this._positionX>globalViewport.x)&&(this._positionXglobalViewport.y)&&(this._positionYdistance;};BABYLON.LensFlareSystem.prototype.render=function(){if(!this._effect.isReady())return false;var engine=this._scene.getEngine();var viewport=this._scene.activeCamera.viewport;var globalViewport=viewport.toGlobal(engine);if(!this.computeEffectivePosition(globalViewport)){return false;}if(!this._isVisible()){return false;}var awayX;var awayY;if(this._positionXglobalViewport.x+globalViewport.width-this.borderLimit){awayX=this._positionX-globalViewport.x-globalViewport.width+this.borderLimit;}else{awayX=0;}if(this._positionYglobalViewport.y+globalViewport.height-this.borderLimit){awayY=this._positionY-globalViewport.y-globalViewport.height+this.borderLimit;}else{awayY=0;}var away=(awayX>awayY)?awayX:awayY;if(away>this.borderLimit){away=this.borderLimit;}var intensity=1.0-(away/this.borderLimit);if(intensity<0){return false;}if(intensity>1.0){intensity=1.0;}var centerX=globalViewport.x+globalViewport.width/2;var centerY=globalViewport.y+globalViewport.height/2;var distX=centerX-this._positionX;var distY=centerY-this._positionY;engine.enableEffect(this._effect);engine.setState(false);engine.setDepthBuffer(false);engine.setAlphaMode(BABYLON.Engine.ALPHA_ADD);engine.bindBuffers(this._vertexBuffer,this._indexBuffer,this._vertexDeclaration,this._vertexStrideSize,this._effect);for(var index=0;index0){that.textureLoadingCallback(remaining);}}that.currentScene.render();}};function drag(e){e.stopPropagation();e.preventDefault();};function drop(eventDrop){eventDrop.stopPropagation();eventDrop.preventDefault();that.loadFiles(eventDrop);};BABYLON.FilesInput.prototype.loadFiles=function(event){if(that.startingProcessingFilesCallback)that.startingProcessingFilesCallback();var sceneFileToLoad;var filesToLoad;BABYLON.FilesTextures={};if(event&&event.dataTransfer&&event.dataTransfer.files){filesToLoad=event.dataTransfer.files;}if(event&&event.target&&event.target.files){filesToLoad=event.target.files;}if(filesToLoad&&filesToLoad.length>0){for(var i=0;i0){optionalDefines.push(defines[defines.length-1]);}var type;if(light instanceof BABYLON.SpotLight){type="#define SPOTLIGHT"+lightIndex;}else if(light instanceof BABYLON.HemisphericLight){type="#define HEMILIGHT"+lightIndex;}else{type="#define POINTDIRLIGHT"+lightIndex;}defines.push(type);if(lightIndex>0){optionalDefines.push(defines[defines.length-1]);}var shadowGenerator=light.getShadowGenerator();if(mesh&&mesh.receiveShadows&&shadowGenerator){defines.push("#define SHADOW"+lightIndex);if(lightIndex>0){optionalDefines.push(defines[defines.length-1]);}if(!shadowsActivated){defines.push("#define SHADOWS");shadowsActivated=true;}if(shadowGenerator.useVarianceShadowMap){defines.push("#define SHADOWVSM"+lightIndex);if(lightIndex>0){optionalDefines.push(defines[defines.length-1]);}}}lightIndex++;if(lightIndex==4)break;}}var attribs=[BABYLON.VertexBuffer.PositionKind,BABYLON.VertexBuffer.NormalKind];if(mesh){if(mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)){attribs.push(BABYLON.VertexBuffer.UVKind);defines.push("#define UV1");}if(mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UV2Kind)){attribs.push(BABYLON.VertexBuffer.UV2Kind);defines.push("#define UV2");}if(mesh.isVerticesDataPresent(BABYLON.VertexBuffer.ColorKind)){attribs.push(BABYLON.VertexBuffer.ColorKind);defines.push("#define VERTEXCOLOR");}if(mesh.skeleton&&mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesIndicesKind)&&mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesWeightsKind)){attribs.push(BABYLON.VertexBuffer.MatricesIndicesKind);attribs.push(BABYLON.VertexBuffer.MatricesWeightsKind);defines.push("#define BONES");defines.push("#define BonesPerMesh "+mesh.skeleton.bones.length);defines.push("#define BONES4");optionalDefines.push(defines[defines.length-1]);}}var join=defines.join("\n");if(this._cachedDefines!=join){this._cachedDefines=join;var shaderName="default";if(BABYLON.Tools.isIE()){shaderName="iedefault";}this._effect=this._scene.getEngine().createEffect(shaderName,attribs,["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","vLightData0","vLightDiffuse0","vLightSpecular0","vLightDirection0","vLightGround0","lightMatrix0","vLightData1","vLightDiffuse1","vLightSpecular1","vLightDirection1","vLightGround1","lightMatrix1","vLightData2","vLightDiffuse2","vLightSpecular2","vLightDirection2","vLightGround2","lightMatrix2","vLightData3","vLightDiffuse3","vLightSpecular3","vLightDirection3","vLightGround3","lightMatrix3","vFogInfos","vFogColor","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","mBones","vClipPlane","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix"],["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","shadowSampler0","shadowSampler1","shadowSampler2","shadowSampler3"],join,optionalDefines);}if(!this._effect.isReady()){return false;}this._renderId=this._scene.getRenderId();this._wasPreviouslyReady=true;return true;};BABYLON.StandardMaterial.prototype.getRenderTargetTextures=function(){this._renderTargets.reset();if(this.reflectionTexture&&this.reflectionTexture.isRenderTarget){this._renderTargets.push(this.reflectionTexture);}return this._renderTargets;};BABYLON.StandardMaterial.prototype.unbind=function(){if(this.reflectionTexture&&this.reflectionTexture.isRenderTarget){this._effect.setTexture("reflection2DSampler",null);}};BABYLON.StandardMaterial.prototype.bind=function(world,mesh){this._baseColor.copyFrom(this.diffuseColor);this._effect.setMatrix("world",world);this._effect.setMatrix("viewProjection",this._scene.getTransformMatrix());if(mesh.skeleton&&mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesIndicesKind)&&mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesWeightsKind)){this._effect.setMatrices("mBones",mesh.skeleton.getTransformMatrices());}if(this.diffuseTexture){this._effect.setTexture("diffuseSampler",this.diffuseTexture);this._effect.setFloat2("vDiffuseInfos",this.diffuseTexture.coordinatesIndex,this.diffuseTexture.level);this._effect.setMatrix("diffuseMatrix",this.diffuseTexture._computeTextureMatrix());this._baseColor.copyFromFloats(1,1,1);}if(this.ambientTexture){this._effect.setTexture("ambientSampler",this.ambientTexture);this._effect.setFloat2("vAmbientInfos",this.ambientTexture.coordinatesIndex,this.ambientTexture.level);this._effect.setMatrix("ambientMatrix",this.ambientTexture._computeTextureMatrix());}if(this.opacityTexture){this._effect.setTexture("opacitySampler",this.opacityTexture);this._effect.setFloat2("vOpacityInfos",this.opacityTexture.coordinatesIndex,this.opacityTexture.level);this._effect.setMatrix("opacityMatrix",this.opacityTexture._computeTextureMatrix());}if(this.reflectionTexture){if(this.reflectionTexture.isCube){this._effect.setTexture("reflectionCubeSampler",this.reflectionTexture);}else{this._effect.setTexture("reflection2DSampler",this.reflectionTexture);}this._effect.setMatrix("reflectionMatrix",this.reflectionTexture._computeReflectionTextureMatrix());this._effect.setFloat3("vReflectionInfos",this.reflectionTexture.coordinatesMode,this.reflectionTexture.level,this.reflectionTexture.isCube?1:0);}if(this.emissiveTexture){this._effect.setTexture("emissiveSampler",this.emissiveTexture);this._effect.setFloat2("vEmissiveInfos",this.emissiveTexture.coordinatesIndex,this.emissiveTexture.level);this._effect.setMatrix("emissiveMatrix",this.emissiveTexture._computeTextureMatrix());}if(this.specularTexture){this._effect.setTexture("specularSampler",this.specularTexture);this._effect.setFloat2("vSpecularInfos",this.specularTexture.coordinatesIndex,this.specularTexture.level);this._effect.setMatrix("specularMatrix",this.specularTexture._computeTextureMatrix());}if(this.bumpTexture&&this._scene.getEngine().getCaps().standardDerivatives){this._effect.setTexture("bumpSampler",this.bumpTexture);this._effect.setFloat2("vBumpInfos",this.bumpTexture.coordinatesIndex,this.bumpTexture.level);this._effect.setMatrix("bumpMatrix",this.bumpTexture._computeTextureMatrix());}this._scene.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor);this._effect.setVector3("vEyePosition",this._scene.activeCamera.position);this._effect.setColor3("vAmbientColor",this._globalAmbientColor);this._effect.setColor4("vDiffuseColor",this._baseColor,this.alpha*mesh.visibility);this._effect.setColor4("vSpecularColor",this.specularColor,this.specularPower);this._effect.setColor3("vEmissiveColor",this.emissiveColor);if(this._scene.lightsEnabled){var lightIndex=0;for(var index=0;index0){results.push(this.diffuseTexture);}if(this.ambientTexture&&this.ambientTexture.animations&&this.ambientTexture.animations.length>0){results.push(this.ambientTexture);}if(this.opacityTexture&&this.opacityTexture.animations&&this.opacityTexture.animations.length>0){results.push(this.opacityTexture);}if(this.reflectionTexture&&this.reflectionTexture.animations&&this.reflectionTexture.animations.length>0){results.push(this.reflectionTexture);}if(this.emissiveTexture&&this.emissiveTexture.animations&&this.emissiveTexture.animations.length>0){results.push(this.emissiveTexture);}if(this.specularTexture&&this.specularTexture.animations&&this.specularTexture.animations.length>0){results.push(this.specularTexture);}if(this.bumpTexture&&this.bumpTexture.animations&&this.bumpTexture.animations.length>0){results.push(this.bumpTexture);}return results;};BABYLON.StandardMaterial.prototype.dispose=function(){if(this.diffuseTexture){this.diffuseTexture.dispose();}if(this.ambientTexture){this.ambientTexture.dispose();}if(this.opacityTexture){this.opacityTexture.dispose();}if(this.reflectionTexture){this.reflectionTexture.dispose();}if(this.emissiveTexture){this.emissiveTexture.dispose();}if(this.specularTexture){this.specularTexture.dispose();}if(this.bumpTexture){this.bumpTexture.dispose();}this.baseDispose();};BABYLON.StandardMaterial.prototype.clone=function(name){var newStandardMaterial=new BABYLON.StandardMaterial(name,this._scene);newStandardMaterial.checkReadyOnEveryCall=this.checkReadyOnEveryCall;newStandardMaterial.alpha=this.alpha;newStandardMaterial.wireframe=this.wireframe;newStandardMaterial.backFaceCulling=this.backFaceCulling;if(this.diffuseTexture&&this.diffuseTexture.clone){newStandardMaterial.diffuseTexture=this.diffuseTexture.clone();}if(this.ambientTexture&&this.ambientTexture.clone){newStandardMaterial.ambientTexture=this.ambientTexture.clone();}if(this.opacityTexture&&this.opacityTexture.clone){newStandardMaterial.opacityTexture=this.opacityTexture.clone();}if(this.reflectionTexture&&this.reflectionTexture.clone){newStandardMaterial.reflectionTexture=this.reflectionTexture.clone();}if(this.emissiveTexture&&this.emissiveTexture.clone){newStandardMaterial.emissiveTexture=this.emissiveTexture.clone();}if(this.specularTexture&&this.specularTexture.clone){newStandardMaterial.specularTexture=this.specularTexture.clone();}if(this.bumpTexture&&this.bumpTexture.clone){newStandardMaterial.bumpTexture=this.bumpTexture.clone();}newStandardMaterial.ambientColor=this.ambientColor.clone();newStandardMaterial.diffuseColor=this.diffuseColor.clone();newStandardMaterial.specularColor=this.specularColor.clone();newStandardMaterial.specularPower=this.specularPower;newStandardMaterial.emissiveColor=this.emissiveColor.clone();return newStandardMaterial;};})();var BABYLON=BABYLON||{};(function(){BABYLON.MultiMaterial=function(name,scene){this.name=name;this.id=name;this._scene=scene;scene.multiMaterials.push(this);this.subMaterials=[];};BABYLON.MultiMaterial.prototype.getSubMaterial=function(index){if(index<0||index>=this.subMaterials.length){return this._scene.defaultMaterial;}return this.subMaterials[index];};BABYLON.MultiMaterial.prototype.isReady=function(mesh){var result=true;for(var index=0;indexversion.data){that.mustUpdateRessources=true;updateInDBCallback();}else{callback(version.data);}}else{that.mustUpdateRessources=true;updateInDBCallback();}};transaction.onabort=function(event){callback(-1);};var getRequest=transaction.objectStore("versions").get(url);getRequest.onsuccess=function(event){version=event.target.result;};getRequest.onerror=function(event){console.log("Error loading version for scene "+url+" from DB.");callback(-1);};}catch(ex){console.log("Error while accessing 'versions' object store (READ OP). Exception: "+ex.message);callback(-1);}}else{console.log("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");callback(-1);}};BABYLON.Database.prototype._saveVersionIntoDBAsync=function(url,callback){if(this.isSupported&&!this.hasReachedQuota){var that=this;try{var transaction=this.db.transaction(["versions"],"readwrite");transaction.onabort=function(event){try{if(event.srcElement.error.name==="QuotaExceededError"){that.hasReachedQuota=true;}}catch(ex){}callback(-1);};transaction.oncomplete=function(event){callback(that.manifestVersionFound);};var newVersion={};newVersion.sceneUrl=url;newVersion.data=this.manifestVersionFound;var addRequest=transaction.objectStore("versions").put(newVersion);addRequest.onsuccess=function(event){console.log("");};addRequest.onerror=function(event){console.log("Error in DB add version request in BABYLON.Database.");};}catch(ex){console.log("Error while accessing 'versions' object store (WRITE OP). Exception: "+ex.message);callback(-1);}}else{callback(-1);}};BABYLON.Database.prototype.loadSceneFromDB=function(url,sceneLoaded,progressCallBack,errorCallback){var that=this;var completeUrl=BABYLON.Database.ReturnFullUrlLocation(url);var saveAndLoadScene=function(event){that._saveSceneIntoDBAsync(completeUrl,sceneLoaded,progressCallBack);};this._checkVersionFromDB(completeUrl,function(version){if(version!==-1){if(!that.mustUpdateRessources){that._loadSceneFromDBAsync(completeUrl,sceneLoaded,saveAndLoadScene);}else{that._saveSceneIntoDBAsync(completeUrl,sceneLoaded,progressCallBack);}}else{errorCallback();}});};BABYLON.Database.prototype._loadSceneFromDBAsync=function(url,callback,notInDBCallback){if(this.isSupported){var scene;var transaction=this.db.transaction(["scenes"]);transaction.oncomplete=function(event){if(scene){callback(scene.data);}else{notInDBCallback();}};transaction.onabort=function(event){notInDBCallback();};var getRequest=transaction.objectStore("scenes").get(url);getRequest.onsuccess=function(event){scene=event.target.result;};getRequest.onerror=function(event){console.log("Error loading scene "+url+" from DB.");notInDBCallback();};}else{console.log("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");callback();}};BABYLON.Database.prototype._saveSceneIntoDBAsync=function(url,callback,progressCallback){if(this.isSupported){var xhr=new XMLHttpRequest(),sceneText;var that=this;xhr.open("GET",url,true);xhr.onprogress=progressCallback;xhr.addEventListener("load",function(){if(xhr.status===200){sceneText=xhr.responseText;if(!that.hasReachedQuota){var transaction=that.db.transaction(["scenes"],"readwrite");transaction.onabort=function(event){try{if(event.srcElement.error.name==="QuotaExceededError"){that.hasReachedQuota=true;}}catch(ex){}callback(sceneText);};transaction.oncomplete=function(event){callback(sceneText);};var newScene={};newScene.sceneUrl=url;newScene.data=sceneText;newScene.version=that.manifestVersionFound;try{var addRequest=transaction.objectStore("scenes").put(newScene);addRequest.onsuccess=function(event){console.log("");};addRequest.onerror=function(event){console.log("Error in DB add scene request in BABYLON.Database.");};}catch(ex){callback(sceneText);}}else{callback(sceneText);}}else{callback();}},false);xhr.addEventListener("error",function(event){console.log("error on XHR request.");callback();},false);xhr.send();}else{console.log("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");callback();}};})();var BABYLON=BABYLON||{};(function(){var loadCubeTexture=function(rootUrl,parsedTexture,scene){var texture=new BABYLON.CubeTexture(rootUrl+parsedTexture.name,scene);texture.name=parsedTexture.name;texture.hasAlpha=parsedTexture.hasAlpha;texture.level=parsedTexture.level;texture.coordinatesMode=parsedTexture.coordinatesMode;return texture;};var loadTexture=function(rootUrl,parsedTexture,scene){if(!parsedTexture.name&&!parsedTexture.isRenderTarget){return null;}if(parsedTexture.isCube){return loadCubeTexture(rootUrl,parsedTexture,scene);}var texture;if(parsedTexture.mirrorPlane){texture=new BABYLON.MirrorTexture(parsedTexture.name,parsedTexture.renderTargetSize,scene);texture._waitingRenderList=parsedTexture.renderList;texture.mirrorPlane=BABYLON.Plane.FromArray(parsedTexture.mirrorPlane);}else if(parsedTexture.isRenderTarget){texture=new BABYLON.RenderTargetTexture(parsedTexture.name,parsedTexture.renderTargetSize,scene);texture._waitingRenderList=parsedTexture.renderList;}else{texture=new BABYLON.Texture(rootUrl+parsedTexture.name,scene);}texture.name=parsedTexture.name;texture.hasAlpha=parsedTexture.hasAlpha;texture.level=parsedTexture.level;texture.coordinatesIndex=parsedTexture.coordinatesIndex;texture.coordinatesMode=parsedTexture.coordinatesMode;texture.uOffset=parsedTexture.uOffset;texture.vOffset=parsedTexture.vOffset;texture.uScale=parsedTexture.uScale;texture.vScale=parsedTexture.vScale;texture.uAng=parsedTexture.uAng;texture.vAng=parsedTexture.vAng;texture.wAng=parsedTexture.wAng;texture.wrapU=parsedTexture.wrapU;texture.wrapV=parsedTexture.wrapV;if(parsedTexture.animations){for(var animationIndex=0;animationIndex-1){parentBone=skeleton.bones[parsedBone.parentBoneIndex];}var bone=new BABYLON.Bone(parsedBone.name,skeleton,parentBone,BABYLON.Matrix.FromArray(parsedBone.matrix));if(parsedBone.animation){bone.animations.push(parseAnimation(parsedBone.animation));}}return skeleton;};var parseMaterial=function(parsedMaterial,scene,rootUrl){var material;material=new BABYLON.StandardMaterial(parsedMaterial.name,scene);material.ambientColor=BABYLON.Color3.FromArray(parsedMaterial.ambient);material.diffuseColor=BABYLON.Color3.FromArray(parsedMaterial.diffuse);material.specularColor=BABYLON.Color3.FromArray(parsedMaterial.specular);material.specularPower=parsedMaterial.specularPower;material.emissiveColor=BABYLON.Color3.FromArray(parsedMaterial.emissive);material.alpha=parsedMaterial.alpha;material.id=parsedMaterial.id;material.backFaceCulling=parsedMaterial.backFaceCulling;if(parsedMaterial.diffuseTexture){material.diffuseTexture=loadTexture(rootUrl,parsedMaterial.diffuseTexture,scene);}if(parsedMaterial.ambientTexture){material.ambientTexture=loadTexture(rootUrl,parsedMaterial.ambientTexture,scene);}if(parsedMaterial.opacityTexture){material.opacityTexture=loadTexture(rootUrl,parsedMaterial.opacityTexture,scene);}if(parsedMaterial.reflectionTexture){material.reflectionTexture=loadTexture(rootUrl,parsedMaterial.reflectionTexture,scene);}if(parsedMaterial.emissiveTexture){material.emissiveTexture=loadTexture(rootUrl,parsedMaterial.emissiveTexture,scene);}if(parsedMaterial.specularTexture){material.specularTexture=loadTexture(rootUrl,parsedMaterial.specularTexture,scene);}if(parsedMaterial.bumpTexture){material.bumpTexture=loadTexture(rootUrl,parsedMaterial.bumpTexture,scene);}return material;};var parseMaterialById=function(id,parsedData,scene,rootUrl){for(var index=0;index-1){mesh.skeleton=scene.getLastSkeletonByID(parsedMesh.skeletonId);}if(parsedMesh.animations){for(var animationIndex=0;animationIndex>8);floatIndices.push((matricesIndex&0x00FF0000)>>16);floatIndices.push(matricesIndex>>24);}mesh.setVerticesData(floatIndices,BABYLON.VertexBuffer.MatricesIndicesKind,false);}if(parsedGeometry.matricesWeights){mesh.setVerticesData(parsedGeometry.matricesWeights,BABYLON.VertexBuffer.MatricesWeightsKind,false);}mesh.setIndices(parsedGeometry.indices);}if(parsedGeometry.subMeshes){mesh.subMeshes=[];for(var subIndex=0;subIndex-1&&scene.skeletons){var skeletonAlreadyLoaded=(loadedSkeletonsIds.indexOf(parsedMesh.skeletonId)>-1);if(!skeletonAlreadyLoaded){for(var skeletonIndex=0;skeletonIndex>0;this._vertices[arrayOffset+9]=sprite.cellIndex-offset*rowSize;this._vertices[arrayOffset+10]=offset;this._vertices[arrayOffset+11]=sprite.color.r;this._vertices[arrayOffset+12]=sprite.color.g;this._vertices[arrayOffset+13]=sprite.color.b;this._vertices[arrayOffset+14]=sprite.color.a;};BABYLON.SpriteManager.prototype.render=function(){if(!this._effectBase.isReady()||!this._effectFog.isReady()||!this._spriteTexture||!this._spriteTexture.isReady())return 0;var engine=this._scene.getEngine();var baseSize=this._spriteTexture.getBaseSize();var deltaTime=BABYLON.Tools.GetDeltaTime();var max=Math.min(this._capacity,this.sprites.length);var rowSize=baseSize.width/this.cellSize;var offset=0;for(var index=0;indexthis._delay){this._time=this._time%this._delay;this.cellIndex+=this._direction;if(this.cellIndex==this._toIndex){if(this._loopAnimation){this.cellIndex=this._fromIndex;}else{this._animationStarted=false;if(this.disposeWhenFinishedAnimating){this.dispose();}}}}};BABYLON.Sprite.prototype.dispose=function(){for(var i=0;i0;for(var index=0;index=particle.lifeTime){this._stockParticles.push(this.particles.splice(index,1)[0]);index--;continue;}else{particle.colorStep.scaleToRef(this._scaledUpdateSpeed,this._scaledColorStep);particle.color.addInPlace(this._scaledColorStep);if(particle.color.a<0)particle.color.a=0;particle.direction.scaleToRef(this._scaledUpdateSpeed,this._scaledDirection);particle.position.addInPlace(this._scaledDirection);particle.angle+=particle.angularSpeed*this._scaledUpdateSpeed;this.gravity.scaleToRef(this._scaledUpdateSpeed,this._scaledGravity);particle.direction.addInPlace(this._scaledGravity);}}var worldMatrix;if(this.emitter.position){worldMatrix=this.emitter.getWorldMatrix();}else{worldMatrix=BABYLON.Matrix.Translation(this.emitter.x,this.emitter.y,this.emitter.z);}for(var index=0;index-1){emitCout=this.manualEmitCount;this.manualEmitCount=0;}else{emitCout=this.emitRate;}var newParticles=((emitCout*this._scaledUpdateSpeed)>>0);this._newPartsExcess+=emitCout*this._scaledUpdateSpeed-newParticles;if(this._newPartsExcess>1.0){newParticles+=this._newPartsExcess>>0;this._newPartsExcess-=this._newPartsExcess>>0;}this._alive=false;if(!this._stopped){this._actualFrame+=this._scaledUpdateSpeed;if(this.targetStopDuration&&this._actualFrame>=this.targetStopDuration)this.stop();}else{newParticles=0;}this._update(newParticles);if(this._stopped){if(!this._alive){this._started=false;if(this.disposeOnStop){this._scene._toBeDisposed.push(this);}}}var offset=0;for(var index=0;index0){return highLimitValue.clone?highLimitValue.clone():highLimitValue;}for(var key=0;key=currentFrame){var startValue=this._keys[key].value;var endValue=this._keys[key+1].value;var gradient=(currentFrame-this._keys[key].frame)/(this._keys[key+1].frame-this._keys[key].frame);switch(this.dataType){case BABYLON.Animation.ANIMATIONTYPE_FLOAT:switch(loopMode){case BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE:case BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT:return startValue+(endValue-startValue)*gradient;case BABYLON.Animation.ANIMATIONLOOPMODE_RELATIVE:return offsetValue*repeatCount+(startValue+(endValue-startValue)*gradient);}break;case BABYLON.Animation.ANIMATIONTYPE_QUATERNION:var quaternion=null;switch(loopMode){case BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE:case BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT:quaternion=BABYLON.Quaternion.Slerp(startValue,endValue,gradient);break;case BABYLON.Animation.ANIMATIONLOOPMODE_RELATIVE:quaternion=BABYLON.Quaternion.Slerp(startValue,endValue,gradient).add(offsetValue.scale(repeatCount));break;}return quaternion;case BABYLON.Animation.ANIMATIONTYPE_VECTOR3:switch(loopMode){case BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE:case BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT:return BABYLON.Vector3.Lerp(startValue,endValue,gradient);case BABYLON.Animation.ANIMATIONLOOPMODE_RELATIVE:return BABYLON.Vector3.Lerp(startValue,endValue,gradient).add(offsetValue.scale(repeatCount));}case BABYLON.Animation.ANIMATIONTYPE_MATRIX:switch(loopMode){case BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE:case BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT:case BABYLON.Animation.ANIMATIONLOOPMODE_RELATIVE:return startValue;}default:break;}break;}}return this._keys[this._keys.length-1].value;};BABYLON.Animation.prototype.animate=function(target,delay,from,to,loop,speedRatio){if(!this.targetPropertyPath||this.targetPropertyPath.length<1){return false;}var returnValue=true;if(this._keys[0].frame!=0){var newKey={frame:0,value:this._keys[0].value};this._keys.splice(0,0,newKey);}if(fromthis._keys[this._keys.length-1].frame){from=this._keys[0].frame;}if(tothis._keys[this._keys.length-1].frame){to=this._keys[this._keys.length-1].frame;}var range=to-from;var ratio=delay*(this.framePerSecond*speedRatio)/1000.0;if(ratio>range&&!loop){offsetValue=0;returnValue=false;}else{var offsetValue=0;var highLimitValue=0;if(this.loopMode!=BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE){var keyOffset=to.toString()+from.toString();if(!this._offsetsCache[keyOffset]){var fromValue=this._interpolate(from,0,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);var toValue=this._interpolate(to,0,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);switch(this.dataType){case BABYLON.Animation.ANIMATIONTYPE_FLOAT:this._offsetsCache[keyOffset]=toValue-fromValue;break;case BABYLON.Animation.ANIMATIONTYPE_QUATERNION:this._offsetsCache[keyOffset]=toValue.subtract(fromValue);break;case BABYLON.Animation.ANIMATIONTYPE_VECTOR3:this._offsetsCache[keyOffset]=toValue.subtract(fromValue);default:break;}this._highLimitsCache[keyOffset]=toValue;}highLimitValue=this._highLimitsCache[keyOffset];offsetValue=this._offsetsCache[keyOffset];}}var repeatCount=(ratio/range)>>0;var currentFrame=returnValue?from+ratio%range:to;var currentValue=this._interpolate(currentFrame,repeatCount,this.loopMode,offsetValue,highLimitValue);if(this.targetPropertyPath.length>1){var property=target[this.targetPropertyPath[0]];for(var index=1;indexthis._capacity){BABYLON.Octree._CreateBlocks(this._minPoint,this._maxPoint,this.meshes,this._capacity,this);}};BABYLON.OctreeBlock.prototype.addEntries=function(meshes){for(var index=0;index0){this._camera.postProcesses[0].width=-1;}};})();var BABYLON=BABYLON||{};(function(){BABYLON.PostProcessManager=function(scene){this._scene=scene;var vertices=[];vertices.push(1,1);vertices.push(-1,1);vertices.push(-1,-1);vertices.push(1,-1);this._vertexDeclaration=[2];this._vertexStrideSize=2*4;this._vertexBuffer=scene.getEngine().createVertexBuffer(vertices);var indices=[];indices.push(0);indices.push(1);indices.push(2);indices.push(0);indices.push(2);indices.push(3);this._indexBuffer=scene.getEngine().createIndexBuffer(indices);};BABYLON.PostProcessManager.prototype._prepareFrame=function(){var postProcesses=this._scene.activeCamera.postProcesses;if(postProcesses.length===0||!this._scene.postProcessesEnabled){return;}postProcesses[0].activate();};BABYLON.PostProcessManager.prototype._finalizeFrame=function(){var postProcesses=this._scene.activeCamera.postProcesses;if(postProcesses.length===0||!this._scene.postProcessesEnabled){return;}var engine=this._scene.getEngine();for(var index=0;index0){if((this._positionX>globalViewport.x)&&(this._positionXglobalViewport.y)&&(this._positionYdistance;};BABYLON.LensFlareSystem.prototype.render=function(){if(!this._effect.isReady())return false;var engine=this._scene.getEngine();var viewport=this._scene.activeCamera.viewport;var globalViewport=viewport.toGlobal(engine);if(!this.computeEffectivePosition(globalViewport)){return false;}if(!this._isVisible()){return false;}var awayX;var awayY;if(this._positionXglobalViewport.x+globalViewport.width-this.borderLimit){awayX=this._positionX-globalViewport.x-globalViewport.width+this.borderLimit;}else{awayX=0;}if(this._positionYglobalViewport.y+globalViewport.height-this.borderLimit){awayY=this._positionY-globalViewport.y-globalViewport.height+this.borderLimit;}else{awayY=0;}var away=(awayX>awayY)?awayX:awayY;if(away>this.borderLimit){away=this.borderLimit;}var intensity=1.0-(away/this.borderLimit);if(intensity<0){return false;}if(intensity>1.0){intensity=1.0;}var centerX=globalViewport.x+globalViewport.width/2;var centerY=globalViewport.y+globalViewport.height/2;var distX=centerX-this._positionX;var distY=centerY-this._positionY;engine.enableEffect(this._effect);engine.setState(false);engine.setDepthBuffer(false);engine.setAlphaMode(BABYLON.Engine.ALPHA_ADD);engine.bindBuffers(this._vertexBuffer,this._indexBuffer,this._vertexDeclaration,this._vertexStrideSize,this._effect);for(var index=0;index0){that.textureLoadingCallback(remaining);}}that.currentScene.render();}};function drag(e){e.stopPropagation();e.preventDefault();};function drop(eventDrop){eventDrop.stopPropagation();eventDrop.preventDefault();that.loadFiles(eventDrop);};BABYLON.FilesInput.prototype.loadFiles=function(event){if(that.startingProcessingFilesCallback)that.startingProcessingFilesCallback();var sceneFileToLoad;var filesToLoad;BABYLON.FilesTextures={};if(event&&event.dataTransfer&&event.dataTransfer.files){filesToLoad=event.dataTransfer.files;}if(event&&event.target&&event.target.files){filesToLoad=event.target.files;}if(filesToLoad&&filesToLoad.length>0){for(var i=0;i