Browse Source

Adding range for spotLights

David Catuhe 11 years ago
parent
commit
fa6f0668e5

+ 4 - 4
Babylon/Shaders/default.fragment.fx

@@ -450,7 +450,7 @@ void main(void) {
 
 #ifdef LIGHT0
 #ifdef SPOTLIGHT0
-	lightingInfo info = computeSpotLighting(viewDirectionW, normalW, vLightData0, vLightDirection0, vLightDiffuse0.rgb, vLightSpecular0);
+	lightingInfo info = computeSpotLighting(viewDirectionW, normalW, vLightData0, vLightDirection0, vLightDiffuse0.rgb, vLightSpecular0, vLightDiffuse0.a);
 #endif
 #ifdef HEMILIGHT0
 	lightingInfo info = computeHemisphericLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0.rgb, vLightSpecular0, vLightGround0);
@@ -473,7 +473,7 @@ void main(void) {
 
 #ifdef LIGHT1
 #ifdef SPOTLIGHT1
-	info = computeSpotLighting(viewDirectionW, normalW, vLightData1, vLightDirection1, vLightDiffuse1.rgb, vLightSpecular1);
+	info = computeSpotLighting(viewDirectionW, normalW, vLightData1, vLightDirection1, vLightDiffuse1.rgb, vLightSpecular1, vLightDiffuse1.a);
 #endif
 #ifdef HEMILIGHT1
 	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1.rgb, vLightSpecular1, vLightGround1);
@@ -496,7 +496,7 @@ void main(void) {
 
 #ifdef LIGHT2
 #ifdef SPOTLIGHT2
-	info = computeSpotLighting(viewDirectionW, normalW, vLightData2, vLightDirection2, vLightDiffuse2.rgb, vLightSpecular2);
+	info = computeSpotLighting(viewDirectionW, normalW, vLightData2, vLightDirection2, vLightDiffuse2.rgb, vLightSpecular2, vLightDiffuse2.a);
 #endif
 #ifdef HEMILIGHT2
 	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2.rgb, vLightSpecular2, vLightGround2);
@@ -519,7 +519,7 @@ void main(void) {
 
 #ifdef LIGHT3
 #ifdef SPOTLIGHT3
-	info = computeSpotLighting(viewDirectionW, normalW, vLightData3, vLightDirection3, vLightDiffuse3.rgb, vLightSpecular3);
+	info = computeSpotLighting(viewDirectionW, normalW, vLightData3, vLightDirection3, vLightDiffuse3.rgb, vLightSpecular3, vLightDiffuse3.a);
 #endif
 #ifdef HEMILIGHT3
 	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3.rgb, vLightSpecular3, vLightGround3);

+ 12 - 4
Babylon/Tools/babylon.tools.js

@@ -290,8 +290,12 @@
                 var event = events[index];
                 window.addEventListener(event.name, event.handler, false);
 
-                if (window.parent) {
-                    window.parent.addEventListener(event.name, event.handler, false);
+                try  {
+                    if (window.parent) {
+                        window.parent.addEventListener(event.name, event.handler, false);
+                    }
+                } catch (e) {
+                    // Silently fails...
                 }
             }
         };
@@ -301,8 +305,12 @@
                 var event = events[index];
                 window.removeEventListener(event.name, event.handler);
 
-                if (window.parent) {
-                    window.parent.removeEventListener(event.name, event.handler);
+                try  {
+                    if (window.parent) {
+                        window.parent.removeEventListener(event.name, event.handler);
+                    }
+                } catch (e) {
+                    // Silently fails...
                 }
             }
         };

+ 12 - 4
Babylon/Tools/babylon.tools.ts

@@ -310,8 +310,12 @@
                 var event = events[index];
                 window.addEventListener(event.name, event.handler, false);
 
-                if (window.parent) {
-                    window.parent.addEventListener(event.name, event.handler, false);
+                try {
+                    if (window.parent) {
+                        window.parent.addEventListener(event.name, event.handler, false);
+                    }
+                } catch (e) {
+                    // Silently fails...
                 }
             }
         }
@@ -321,8 +325,12 @@
                 var event = events[index];
                 window.removeEventListener(event.name, event.handler);
 
-                if (window.parent) {
-                    window.parent.removeEventListener(event.name, event.handler);
+                try {
+                    if (window.parent) {
+                        window.parent.removeEventListener(event.name, event.handler);
+                    }
+                } catch (e) {
+                    // Silently fails...
                 }
             }
         }

+ 0 - 2
Babylon/babylon.engine.js

@@ -489,8 +489,6 @@
 
         Engine.prototype.draw = function (useTriangles, indexStart, indexCount) {
             this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2);
-
-            this._gl.getError();
         };
 
         // Shaders

+ 0 - 2
Babylon/babylon.engine.ts

@@ -546,8 +546,6 @@
 
         public draw(useTriangles: boolean, indexStart: number, indexCount: number): void {
             this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2);
-
-            this._gl.getError();
         }
 
         // Shaders

+ 2 - 2
Babylon/babylon.scene.js

@@ -163,7 +163,7 @@
             var _this = this;
             this._onPointerMove = function (evt) {
                 var canvas = _this._engine.getRenderingCanvas();
-                var pickResult = _this.pick(evt.clientX, evt.clientY, function (mesh) {
+                var pickResult = _this.pick(evt.offsetX || evt.layerX, evt.offsetY || evt.layerY, function (mesh) {
                     return mesh.actionManager && mesh.isPickable;
                 });
 
@@ -177,7 +177,7 @@
             };
 
             this._onPointerDown = function (evt) {
-                var pickResult = _this.pick(evt.clientX, evt.clientY);
+                var pickResult = _this.pick(evt.offsetX || evt.layerX, evt.offsetY || evt.layerY);
 
                 if (pickResult.hit) {
                     if (pickResult.pickedMesh.actionManager) {

+ 2 - 2
Babylon/babylon.scene.ts

@@ -228,7 +228,7 @@
         public attachControl() {
             this._onPointerMove = (evt: PointerEvent) => {
                 var canvas = this._engine.getRenderingCanvas();
-                var pickResult = this.pick(evt.clientX, evt.clientY, mesh => mesh.actionManager && mesh.isPickable);
+                var pickResult = this.pick(evt.offsetX || evt.layerX, evt.offsetY || evt.layerY, mesh => mesh.actionManager && mesh.isPickable);
 
                 if (pickResult.hit) {
                     this.setPointerOverMesh(pickResult.pickedMesh);
@@ -240,7 +240,7 @@
             };
 
             this._onPointerDown = (evt: PointerEvent) => {
-                var pickResult = this.pick(evt.clientX, evt.clientY);
+                var pickResult = this.pick(evt.offsetX || evt.layerX, evt.offsetY || evt.layerY);
 
                 if (pickResult.hit) {
                     if (pickResult.pickedMesh.actionManager) {

File diff suppressed because it is too large
+ 5 - 5
babylon.1.12-beta.js