Jelajahi Sumber

Adding submeshId to PickingInfo

David Catuhe 10 tahun lalu
induk
melakukan
746e53320d

+ 2 - 0
Babylon/Collisions/babylon.pickingInfo.js

@@ -6,6 +6,7 @@ var BABYLON;
             this.bv = bv;
             this.distance = distance;
             this.faceId = 0;
+            this.subMeshId = 0;
         }
         return IntersectionInfo;
     })();
@@ -19,6 +20,7 @@ var BABYLON;
             this.bu = 0;
             this.bv = 0;
             this.faceId = -1;
+            this.subMeshId = 0;
         }
         // Methods
         PickingInfo.prototype.getNormal = function () {

+ 14 - 12
Babylon/Collisions/babylon.pickingInfo.ts

@@ -1,6 +1,7 @@
 module BABYLON {
     export class IntersectionInfo {
         public faceId = 0;
+        public subMeshId = 0;
 
         constructor(public bu: number, public bv: number, public distance: number) {
         }
@@ -14,44 +15,45 @@
         public bu = 0;
         public bv = 0;
         public faceId = -1;
+        public subMeshId = 0;
 
         // Methods
         public getNormal(): Vector3 {
-            if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(BABYLON.VertexBuffer.NormalKind)) {
+            if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(VertexBuffer.NormalKind)) {
                 return null;
             }
 
             var indices = this.pickedMesh.getIndices();
-            var normals = this.pickedMesh.getVerticesData(BABYLON.VertexBuffer.NormalKind);
+            var normals = this.pickedMesh.getVerticesData(VertexBuffer.NormalKind);
 
-            var normal0 = BABYLON.Vector3.FromArray(normals, indices[this.faceId * 3] * 3);
-            var normal1 = BABYLON.Vector3.FromArray(normals, indices[this.faceId * 3 + 1] * 3);
-            var normal2 = BABYLON.Vector3.FromArray(normals, indices[this.faceId * 3 + 2] * 3);
+            var normal0 = Vector3.FromArray(normals, indices[this.faceId * 3] * 3);
+            var normal1 = Vector3.FromArray(normals, indices[this.faceId * 3 + 1] * 3);
+            var normal2 = Vector3.FromArray(normals, indices[this.faceId * 3 + 2] * 3);
 
             normal0 = normal0.scale(this.bu);
             normal1 = normal1.scale(this.bv);
             normal2 = normal2.scale(1.0 - this.bu - this.bv);
 
-            return new BABYLON.Vector3(normal0.x + normal1.x + normal2.x, normal0.y + normal1.y + normal2.y, normal0.z + normal1.z + normal2.z);
+            return new Vector3(normal0.x + normal1.x + normal2.x, normal0.y + normal1.y + normal2.y, normal0.z + normal1.z + normal2.z);
         }
 
         public getTextureCoordinates(): Vector2 {
-            if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
+            if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(VertexBuffer.UVKind)) {
                 return null;
             }
 
             var indices = this.pickedMesh.getIndices();
-            var uvs = this.pickedMesh.getVerticesData(BABYLON.VertexBuffer.UVKind);
+            var uvs = this.pickedMesh.getVerticesData(VertexBuffer.UVKind);
 
-            var uv0 = BABYLON.Vector2.FromArray(uvs, indices[this.faceId * 3] * 2);
-            var uv1 = BABYLON.Vector2.FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
-            var uv2 = BABYLON.Vector2.FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
+            var uv0 = Vector2.FromArray(uvs, indices[this.faceId * 3] * 2);
+            var uv1 = Vector2.FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
+            var uv2 = Vector2.FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
 
             uv0 = uv0.scale(this.bu);
             uv1 = uv1.scale(this.bv);
             uv2 = uv2.scale(1.0 - this.bu - this.bv);
 
-            return new BABYLON.Vector2(uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
+            return new Vector2(uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
         }
     }
 } 

+ 2 - 2
Babylon/Math/babylon.math.js

@@ -1226,7 +1226,7 @@ var BABYLON;
             return result;
         };
         Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
-            //produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
+            // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
             var halfRoll = roll * 0.5;
             var halfPitch = pitch * 0.5;
             var halfYaw = yaw * 0.5;
@@ -1247,7 +1247,7 @@ var BABYLON;
             return result;
         };
         Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
-            //produces a quaternion from Euler angles in the z-x-z orientation
+            // Produces a quaternion from Euler angles in the z-x-z orientation
             var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
             var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
             var halfBeta = beta * 0.5;

+ 2 - 2
Babylon/Math/babylon.math.ts

@@ -1521,7 +1521,7 @@
         }
 
         public static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void {
-            //produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
+            // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
             var halfRoll = roll * 0.5;
             var halfPitch = pitch * 0.5;
             var halfYaw = yaw * 0.5;
@@ -1546,7 +1546,7 @@
         }
 
         public static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void {
-            //produces a quaternion from Euler angles in the z-x-z orientation
+            // Produces a quaternion from Euler angles in the z-x-z orientation
             var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
             var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
             var halfBeta = beta * 0.5;

+ 2 - 0
Babylon/Mesh/babylon.abstractMesh.js

@@ -697,6 +697,7 @@ var BABYLON;
                 if (currentIntersectInfo) {
                     if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
                         intersectInfo = currentIntersectInfo;
+                        intersectInfo.subMeshId = index;
                         if (fastCheck) {
                             break;
                         }
@@ -719,6 +720,7 @@ var BABYLON;
                 pickingInfo.bu = intersectInfo.bu;
                 pickingInfo.bv = intersectInfo.bv;
                 pickingInfo.faceId = intersectInfo.faceId;
+                pickingInfo.subMeshId = intersectInfo.subMeshId;
                 return pickingInfo;
             }
             return pickingInfo;

+ 5 - 3
Babylon/Mesh/babylon.abstractMesh.ts

@@ -827,6 +827,7 @@
                 if (currentIntersectInfo) {
                     if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
                         intersectInfo = currentIntersectInfo;
+                        intersectInfo.subMeshId = index;
 
                         if (fastCheck) {
                             break;
@@ -838,21 +839,22 @@
             if (intersectInfo) {
                 // Get picked point
                 var world = this.getWorldMatrix();
-                var worldOrigin = BABYLON.Vector3.TransformCoordinates(ray.origin, world);
+                var worldOrigin = Vector3.TransformCoordinates(ray.origin, world);
                 var direction = ray.direction.clone();
                 direction = direction.scale(intersectInfo.distance);
-                var worldDirection = BABYLON.Vector3.TransformNormal(direction, world);
+                var worldDirection = Vector3.TransformNormal(direction, world);
 
                 var pickedPoint = worldOrigin.add(worldDirection);
 
                 // Return result
                 pickingInfo.hit = true;
-                pickingInfo.distance = BABYLON.Vector3.Distance(worldOrigin, pickedPoint);
+                pickingInfo.distance = Vector3.Distance(worldOrigin, pickedPoint);
                 pickingInfo.pickedPoint = pickedPoint;
                 pickingInfo.pickedMesh = this;
                 pickingInfo.bu = intersectInfo.bu;
                 pickingInfo.bv = intersectInfo.bv;
                 pickingInfo.faceId = intersectInfo.faceId;
+                pickingInfo.subMeshId = intersectInfo.subMeshId;
                 return pickingInfo;
             }
 

+ 10 - 9
Babylon/PostProcess/babylon.ssaoRenderingPipeline.js

@@ -12,12 +12,11 @@ var BABYLON;
          * @constructor
          * @param {string} name - The rendering pipeline name
          * @param {BABYLON.Scene} scene - The scene linked to this pipeline
-         * @param {number} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
+         * @param {any} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
          * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
          */
         function SSAORenderingPipeline(name, scene, ratio, cameras) {
             var _this = this;
-            if (ratio === void 0) { ratio = 1.0; }
             _super.call(this, scene.getEngine(), name);
             // Members
             /**
@@ -50,11 +49,13 @@ var BABYLON;
             // Set up assets
             this._createRandomTexture();
             this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
-            this._originalColorPostProcess = new BABYLON.PassPostProcess("SSAOOriginalSceneColor", 1.0, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
-            this._createSSAOPostProcess(ratio);
-            this._blurHPostProcess = new BABYLON.BlurPostProcess("SSAOBlurH", new BABYLON.Vector2(2.0, 0.0), 1.3, ratio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
-            this._blurVPostProcess = new BABYLON.BlurPostProcess("SSAOBlurV", new BABYLON.Vector2(0.0, 2.0), 1.3, ratio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
-            this._createSSAOCombinePostProcess();
+            var ssaoRatio = ratio.ssaoRatio || ratio;
+            var combineRatio = ratio.combineRatio || ratio;
+            this._originalColorPostProcess = new BABYLON.PassPostProcess("SSAOOriginalSceneColor", combineRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
+            this._createSSAOPostProcess(ssaoRatio);
+            this._blurHPostProcess = new BABYLON.BlurPostProcess("SSAOBlurH", new BABYLON.Vector2(2.0, 0.0), 1.3, ssaoRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
+            this._blurVPostProcess = new BABYLON.BlurPostProcess("SSAOBlurV", new BABYLON.Vector2(0.0, 2.0), 1.3, ssaoRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
+            this._createSSAOCombinePostProcess(combineRatio);
             // Set up pipeline
             this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.SSAOOriginalSceneColorEffect, function () {
                 return _this._originalColorPostProcess;
@@ -172,9 +173,9 @@ var BABYLON;
                 effect.setTexture("randomSampler", _this._randomTexture);
             };
         };
-        SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function () {
+        SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
             var _this = this;
-            this._ssaoCombinePostProcess = new BABYLON.PostProcess("ssaoCombine", "ssaoCombine", [], ["originalColor"], 1.0, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
+            this._ssaoCombinePostProcess = new BABYLON.PostProcess("ssaoCombine", "ssaoCombine", [], ["originalColor"], ratio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
             this._ssaoCombinePostProcess.onApply = function (effect) {
                 effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
             };

+ 12 - 9
Babylon/PostProcess/babylon.ssaoRenderingPipeline.ts

@@ -44,10 +44,10 @@
          * @constructor
          * @param {string} name - The rendering pipeline name
          * @param {BABYLON.Scene} scene - The scene linked to this pipeline
-         * @param {number} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
+         * @param {any} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
          * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
          */
-        constructor(name: string, scene: Scene, ratio: number = 1.0, cameras?: Camera[]) {
+        constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]) {
             super(scene.getEngine(), name);
 
             this._scene = scene;
@@ -56,11 +56,14 @@
             this._createRandomTexture();
             this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
 
-            this._originalColorPostProcess = new PassPostProcess("SSAOOriginalSceneColor", 1.0, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
-            this._createSSAOPostProcess(ratio);
-            this._blurHPostProcess = new BlurPostProcess("SSAOBlurH", new Vector2(2.0, 0.0), 1.3, ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
-            this._blurVPostProcess = new BlurPostProcess("SSAOBlurV", new Vector2(0.0, 2.0), 1.3, ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
-            this._createSSAOCombinePostProcess();
+            var ssaoRatio = ratio.ssaoRatio || ratio;
+            var combineRatio = ratio.combineRatio || ratio;
+
+            this._originalColorPostProcess = new PassPostProcess("SSAOOriginalSceneColor", combineRatio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
+            this._createSSAOPostProcess(ssaoRatio);
+            this._blurHPostProcess = new BlurPostProcess("SSAOBlurH", new Vector2(2.0, 0.0), 1.3, ssaoRatio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
+            this._blurVPostProcess = new BlurPostProcess("SSAOBlurV", new Vector2(0.0, 2.0), 1.3, ssaoRatio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
+            this._createSSAOCombinePostProcess(combineRatio);
 
             // Set up pipeline
             this.addEffect(new PostProcessRenderEffect(scene.getEngine(), this.SSAOOriginalSceneColorEffect, () => { return this._originalColorPostProcess; }, true));
@@ -150,9 +153,9 @@
             };
         }
 
-        private _createSSAOCombinePostProcess(): void {
+        private _createSSAOCombinePostProcess(ratio: number): void {
             this._ssaoCombinePostProcess = new PostProcess("ssaoCombine", "ssaoCombine", [], ["originalColor"],
-                                                           1.0, null, Texture.BILINEAR_SAMPLINGMODE,
+                                                           ratio, null, Texture.BILINEAR_SAMPLINGMODE,
                                                            this._scene.getEngine(), false);
 
             this._ssaoCombinePostProcess.onApply = (effect: Effect) => {

+ 4 - 3
Babylon/PostProcess/babylon.volumetricLightScatteringPostProcess.js

@@ -12,9 +12,10 @@ var BABYLON;
         /**
          * @constructor
          * @param {string} name - The post-process name
-         * @param {number} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
+         * @param {any} ratio - The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
          * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
          * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
+         * @param {number} samples - The post-process quality, default 100
          * @param {number} samplingMode - The post-process filtering mode
          * @param {BABYLON.Engine} engine - The babylon engine
          * @param {boolean} reusable - If the post-process is reusable
@@ -23,7 +24,7 @@ var BABYLON;
             var _this = this;
             if (samples === void 0) { samples = 100; }
             if (samplingMode === void 0) { samplingMode = BABYLON.Texture.BILINEAR_SAMPLINGMODE; }
-            _super.call(this, name, "volumetricLightScattering", ["decay", "exposure", "weight", "meshPositionOnScreen", "density"], ["lightScatteringSampler"], ratio, camera, samplingMode, engine, reusable, "#define NUM_SAMPLES " + samples);
+            _super.call(this, name, "volumetricLightScattering", ["decay", "exposure", "weight", "meshPositionOnScreen", "density"], ["lightScatteringSampler"], ratio.postProcessRatio || ratio, camera, samplingMode, engine, reusable, "#define NUM_SAMPLES " + samples);
             this._screenCoordinates = BABYLON.Vector2.Zero();
             /**
             * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
@@ -48,7 +49,7 @@ var BABYLON;
             // Configure mesh
             this.mesh = (mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene);
             // Configure
-            this._createPass(scene, 0.5);
+            this._createPass(scene, ratio.passRatio || ratio);
             this.onApply = function (effect) {
                 _this._updateMeshScreenCoordinates(scene);
                 effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);

+ 5 - 4
Babylon/PostProcess/babylon.volumetricLightScatteringPostProcess.ts

@@ -38,15 +38,16 @@
         /**
          * @constructor
          * @param {string} name - The post-process name
-         * @param {number} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
+         * @param {any} ratio - The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
          * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
          * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
+         * @param {number} samples - The post-process quality, default 100
          * @param {number} samplingMode - The post-process filtering mode
          * @param {BABYLON.Engine} engine - The babylon engine
          * @param {boolean} reusable - If the post-process is reusable
          */
-        constructor(name: string, ratio: number, camera: Camera, mesh?: Mesh, samples: number = 100, samplingMode: number = Texture.BILINEAR_SAMPLINGMODE, engine?: Engine, reusable?: boolean) {
-            super(name, "volumetricLightScattering", ["decay", "exposure", "weight", "meshPositionOnScreen", "density"], ["lightScatteringSampler"], ratio, camera, samplingMode, engine, reusable, "#define NUM_SAMPLES " + samples);
+        constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples: number = 100, samplingMode: number = Texture.BILINEAR_SAMPLINGMODE, engine?: Engine, reusable?: boolean) {
+            super(name, "volumetricLightScattering", ["decay", "exposure", "weight", "meshPositionOnScreen", "density"], ["lightScatteringSampler"], ratio.postProcessRatio || ratio, camera, samplingMode, engine, reusable, "#define NUM_SAMPLES " + samples);
             var scene = camera.getScene();
 
             this._viewPort = new Viewport(0, 0, 1, 1).toGlobal(scene.getEngine());
@@ -55,7 +56,7 @@
             this.mesh = (mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene);
 
             // Configure
-            this._createPass(scene, 0.5);
+            this._createPass(scene, ratio.passRatio || ratio);
 
             this.onApply = (effect: Effect) => {
                 this._updateMeshScreenCoordinates(scene);

+ 8 - 8
Babylon/Tools/babylon.database.ts

@@ -15,7 +15,7 @@ module BABYLON {
 
         static isUASupportingBlobStorage: boolean = true;
 
-        constructor(urlToScene: string, callbackManifestChecked: (boolean) => any) {          
+        constructor(urlToScene: string, callbackManifestChecked: (boolean) => any) {
             this.callbackManifestChecked = callbackManifestChecked;
             this.currentSceneUrl = BABYLON.Database.ReturnFullUrlLocation(urlToScene);
             this.db = null;
@@ -30,8 +30,8 @@ module BABYLON {
         static parseURL = (url: string) => {
             var a = document.createElement('a');
             a.href = url;
-            var urlWithoutHash = url.substring(0, url.lastIndexOf("#")); 
-            var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length); 
+            var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
+            var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
             var absLocation = url.substring(0, url.indexOf(fileName, 0));
             return absLocation;
         }
@@ -61,7 +61,7 @@ module BABYLON {
             var manifestURLTimeStamped = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + (new Date()).getTime();
             xhr.open("GET", manifestURLTimeStamped, true);
 
-            xhr.addEventListener("load", () => {
+            xhr.addEventListener("load",() => {
                 if (xhr.status === 200 || BABYLON.Tools.ValidateXHRData(xhr, 1)) {
                     try {
                         var manifestFile = JSON.parse(xhr.response);
@@ -136,7 +136,7 @@ module BABYLON {
                     // Initialization of the DB. Creating Scenes & Textures stores
                     request.onupgradeneeded = (event: IDBVersionChangeEvent) => {
                         this.db = (<any>(event.target)).result;
-                        try {                            
+                        try {
                             var scenesStore = this.db.createObjectStore("scenes", { keyPath: "sceneUrl" });
                             var versionsStore = this.db.createObjectStore("versions", { keyPath: "sceneUrl" });
                             var texturesStore = this.db.createObjectStore("textures", { keyPath: "textureUrl" });
@@ -192,7 +192,7 @@ module BABYLON {
                     if (texture) {
                         var URL = window.URL || window.webkitURL;
                         blobTextureURL = URL.createObjectURL(texture.data, { oneTimeOnly: true });
-                       
+
                         image.onerror = () => {
                             BABYLON.Tools.Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
                             image.src = url;
@@ -247,7 +247,7 @@ module BABYLON {
                     xhr.open("GET", url, true);
                     xhr.responseType = "blob";
 
-                    xhr.addEventListener("load", () => {
+                    xhr.addEventListener("load",() => {
                         if (xhr.status === 200) {
                             // Blob as response (XHR2)
                             blob = xhr.response;
@@ -495,7 +495,7 @@ module BABYLON {
 
                 xhr.onprogress = progressCallback;
 
-                xhr.addEventListener("load", () => { 
+                xhr.addEventListener("load",() => {
                     if (xhr.status === 200 || BABYLON.Tools.ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6)) {
                         // Blob as response (XHR2)
                         //fileData = xhr.responseText;

+ 35 - 20
babylon.2.1-alpha.debug.js

@@ -1231,7 +1231,7 @@ var __extends = this.__extends || function (d, b) {
             return result;
         };
         Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
-            //produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
+            // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
             var halfRoll = roll * 0.5;
             var halfPitch = pitch * 0.5;
             var halfYaw = yaw * 0.5;
@@ -1252,7 +1252,7 @@ var __extends = this.__extends || function (d, b) {
             return result;
         };
         Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
-            //produces a quaternion from Euler angles in the z-x-z orientation
+            // Produces a quaternion from Euler angles in the z-x-z orientation
             var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
             var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
             var halfBeta = beta * 0.5;
@@ -2629,7 +2629,8 @@ var __extends = this.__extends || function (d, b) {
         Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
             var reader = new FileReader();
             reader.onload = function (e) {
-                callback(e.target.result);
+                //target doesn't have result from ts 1.3
+                callback(e.target['result']);
             };
             reader.onprogress = progressCallback;
             reader.readAsDataURL(fileToLoad);
@@ -2637,7 +2638,8 @@ var __extends = this.__extends || function (d, b) {
         Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
             var reader = new FileReader();
             reader.onload = function (e) {
-                callback(e.target.result);
+                //target doesn't have result from ts 1.3
+                callback(e.target['result']);
             };
             reader.onprogress = progressCallBack;
             if (!useArrayBuffer) {
@@ -2821,7 +2823,9 @@ var __extends = this.__extends || function (d, b) {
                 var context = screenshotCanvas.getContext('2d');
                 // Copy the pixels to a 2D canvas
                 var imageData = context.createImageData(width, height);
-                imageData.data.set(data);
+                //cast is due to ts error in lib.d.ts, see here - https://github.com/Microsoft/TypeScript/issues/949
+                var data = imageData.data;
+                data.set(data);
                 context.putImageData(imageData, 0, 0);
                 var base64Image = screenshotCanvas.toDataURL();
                 //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
@@ -9882,6 +9886,7 @@ var BABYLON;
                 if (currentIntersectInfo) {
                     if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
                         intersectInfo = currentIntersectInfo;
+                        intersectInfo.subMeshId = index;
                         if (fastCheck) {
                             break;
                         }
@@ -9904,6 +9909,7 @@ var BABYLON;
                 pickingInfo.bu = intersectInfo.bu;
                 pickingInfo.bv = intersectInfo.bv;
                 pickingInfo.faceId = intersectInfo.faceId;
+                pickingInfo.subMeshId = intersectInfo.subMeshId;
                 return pickingInfo;
             }
             return pickingInfo;
@@ -10692,6 +10698,7 @@ var BABYLON;
                 canvas.height = heightMapHeight;
                 context.drawImage(img, 0, 0);
                 // Create VertexData from map data
+                //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
                 var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
                 _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight);
                 //execute success callback, if set
@@ -10951,6 +10958,7 @@ var BABYLON;
                 canvas.height = heightMapHeight;
                 context.drawImage(img, 0, 0);
                 // Create VertexData from map data
+                //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949 
                 var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
                 var vertexData = BABYLON.VertexData.CreateGroundFromHeightMap(width, height, subdivisions, minHeight, maxHeight, buffer, heightMapWidth, heightMapHeight);
                 vertexData.applyToMesh(ground, updatable);
@@ -12990,6 +12998,7 @@ var BABYLON;
                 }
             });
             urls.forEach(function (url) {
+                //Backwards-compatibility for typescript 1. from 1.3 it should say "SOURCE". see here - https://github.com/Microsoft/TypeScript/issues/1850
                 var source = document.createElement("source");
                 source.src = url;
                 _this.video.appendChild(source);
@@ -14330,7 +14339,8 @@ var BABYLON;
                             // the transaction could abort because of a QuotaExceededError error
                             transaction.onabort = function (event) {
                                 try {
-                                    if (event.srcElement.error.name === "QuotaExceededError") {
+                                    //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
+                                    if (event.srcElement['error'] && event.srcElement['error'].name === "QuotaExceededError") {
                                         this.hasReachedQuota = true;
                                     }
                                 }
@@ -14439,7 +14449,7 @@ var BABYLON;
                     // the transaction could abort because of a QuotaExceededError error
                     transaction.onabort = function (event) {
                         try {
-                            if (event.srcElement.error.name === "QuotaExceededError") {
+                            if (event.srcElement['error'] && event.srcElement['error'].name === "QuotaExceededError") {
                                 _this.hasReachedQuota = true;
                             }
                         }
@@ -14553,7 +14563,8 @@ var BABYLON;
                             // the transaction could abort because of a QuotaExceededError error
                             transaction.onabort = function (event) {
                                 try {
-                                    if (event.srcElement.error.name === "QuotaExceededError") {
+                                    //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
+                                    if (event.srcElement['error'] && event.srcElement['error'].name === "QuotaExceededError") {
                                         this.hasReachedQuota = true;
                                     }
                                 }
@@ -16850,6 +16861,7 @@ var BABYLON;
             this.bv = bv;
             this.distance = distance;
             this.faceId = 0;
+            this.subMeshId = 0;
         }
         return IntersectionInfo;
     })();
@@ -16863,6 +16875,7 @@ var BABYLON;
             this.bu = 0;
             this.bv = 0;
             this.faceId = -1;
+            this.subMeshId = 0;
         }
         // Methods
         PickingInfo.prototype.getNormal = function () {
@@ -27582,12 +27595,11 @@ var BABYLON;
          * @constructor
          * @param {string} name - The rendering pipeline name
          * @param {BABYLON.Scene} scene - The scene linked to this pipeline
-         * @param {number} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
+         * @param {any} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
          * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
          */
         function SSAORenderingPipeline(name, scene, ratio, cameras) {
             var _this = this;
-            if (ratio === void 0) { ratio = 1.0; }
             _super.call(this, scene.getEngine(), name);
             // Members
             /**
@@ -27620,11 +27632,13 @@ var BABYLON;
             // Set up assets
             this._createRandomTexture();
             this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
-            this._originalColorPostProcess = new BABYLON.PassPostProcess("SSAOOriginalSceneColor", 1.0, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
-            this._createSSAOPostProcess(ratio);
-            this._blurHPostProcess = new BABYLON.BlurPostProcess("SSAOBlurH", new BABYLON.Vector2(2.0, 0.0), 1.3, ratio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
-            this._blurVPostProcess = new BABYLON.BlurPostProcess("SSAOBlurV", new BABYLON.Vector2(0.0, 2.0), 1.3, ratio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
-            this._createSSAOCombinePostProcess();
+            var ssaoRatio = ratio.ssaoRatio || ratio;
+            var combineRatio = ratio.combineRatio || ratio;
+            this._originalColorPostProcess = new BABYLON.PassPostProcess("SSAOOriginalSceneColor", combineRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
+            this._createSSAOPostProcess(ssaoRatio);
+            this._blurHPostProcess = new BABYLON.BlurPostProcess("SSAOBlurH", new BABYLON.Vector2(2.0, 0.0), 1.3, ssaoRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
+            this._blurVPostProcess = new BABYLON.BlurPostProcess("SSAOBlurV", new BABYLON.Vector2(0.0, 2.0), 1.3, ssaoRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
+            this._createSSAOCombinePostProcess(combineRatio);
             // Set up pipeline
             this.addEffect(new BABYLON.PostProcessRenderEffect(scene.getEngine(), this.SSAOOriginalSceneColorEffect, function () {
                 return _this._originalColorPostProcess;
@@ -27742,9 +27756,9 @@ var BABYLON;
                 effect.setTexture("randomSampler", _this._randomTexture);
             };
         };
-        SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function () {
+        SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
             var _this = this;
-            this._ssaoCombinePostProcess = new BABYLON.PostProcess("ssaoCombine", "ssaoCombine", [], ["originalColor"], 1.0, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
+            this._ssaoCombinePostProcess = new BABYLON.PostProcess("ssaoCombine", "ssaoCombine", [], ["originalColor"], ratio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
             this._ssaoCombinePostProcess.onApply = function (effect) {
                 effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
             };
@@ -27783,9 +27797,10 @@ var BABYLON;
         /**
          * @constructor
          * @param {string} name - The post-process name
-         * @param {number} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
+         * @param {any} ratio - The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
          * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
          * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
+         * @param {number} samples - The post-process quality, default 100
          * @param {number} samplingMode - The post-process filtering mode
          * @param {BABYLON.Engine} engine - The babylon engine
          * @param {boolean} reusable - If the post-process is reusable
@@ -27794,7 +27809,7 @@ var BABYLON;
             var _this = this;
             if (samples === void 0) { samples = 100; }
             if (samplingMode === void 0) { samplingMode = BABYLON.Texture.BILINEAR_SAMPLINGMODE; }
-            _super.call(this, name, "volumetricLightScattering", ["decay", "exposure", "weight", "meshPositionOnScreen", "density"], ["lightScatteringSampler"], ratio, camera, samplingMode, engine, reusable, "#define NUM_SAMPLES " + samples);
+            _super.call(this, name, "volumetricLightScattering", ["decay", "exposure", "weight", "meshPositionOnScreen", "density"], ["lightScatteringSampler"], ratio.postProcessRatio || ratio, camera, samplingMode, engine, reusable, "#define NUM_SAMPLES " + samples);
             this._screenCoordinates = BABYLON.Vector2.Zero();
             /**
             * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
@@ -27819,7 +27834,7 @@ var BABYLON;
             // Configure mesh
             this.mesh = (mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene);
             // Configure
-            this._createPass(scene, 0.5);
+            this._createPass(scene, ratio.passRatio || ratio);
             this.onApply = function (effect) {
                 _this._updateMeshScreenCoordinates(scene);
                 effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);

File diff ditekan karena terlalu besar
+ 7 - 7
babylon.2.1-alpha.js