Sfoglia il codice sorgente

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

David Catuhe 5 anni fa
parent
commit
2b4e4ee5f5
3 ha cambiato i file con 15 aggiunte e 7 eliminazioni
  1. 1 0
      CNAME.txt
  2. 1 0
      dist/preview release/what's new.md
  3. 13 7
      src/Sprites/spriteManager.ts

+ 1 - 0
CNAME.txt

@@ -0,0 +1 @@
+babylonjs.com

+ 1 - 0
dist/preview release/what's new.md

@@ -180,6 +180,7 @@
 - MultiPickSprite and multiPickSpriteWithRay added to sprites ([JohnK](https://github.com/BabylonJSGuide))
 - SpritePackedManager support for JSON Objects that where not stringified, of with the frames parameter accepting Objects and Arrays ([Pryme8](https://github.com/Pryme8))
 - Added `SpriteMap` for creation of grid-based dynamically animated sprite atlas rendering (Beta) ([Pryme8](https://github.com/Pryme8))
+- Add `SpriteManager.disableDepthWrite` property ([Popov72](https://github.com/Popov72))
 
 ### WebXR / WebVR
 

+ 13 - 7
src/Sprites/spriteManager.ts

@@ -151,6 +151,12 @@ export class SpriteManager implements ISpriteManager {
         this._blendMode = blendMode;
     }
 
+    /** Disables writing to the depth buffer when rendering the sprites.
+     *  It can be handy to disable depth writing when using textures without alpha channel
+     *  and setting some specific blend modes.
+    */
+    public disableDepthWrite: boolean = false;
+
     /**
      * Creates a new sprite manager
      * @param name defines the manager's name
@@ -264,8 +270,6 @@ export class SpriteManager implements ISpriteManager {
 
                 let spritemap = (<string[]>(<any>Reflect).ownKeys(celldata.frames));
 
-                console.log(spritemap);
-
                 this._spriteMap = spritemap;
                 this._packedAndReady = true;
                 this._cellData = celldata.frames;
@@ -576,11 +580,13 @@ export class SpriteManager implements ISpriteManager {
 
         // Draw order
         engine.setDepthFunctionToLessOrEqual();
-        effect.setBool("alphaTest", true);
-        engine.setColorWrite(false);
-        engine.drawElementsType(Material.TriangleFillMode, 0, (offset / 4) * 6);
-        engine.setColorWrite(true);
-        effect.setBool("alphaTest", false);
+        if (!this.disableDepthWrite) {
+            effect.setBool("alphaTest", true);
+            engine.setColorWrite(false);
+            engine.drawElementsType(Material.TriangleFillMode, 0, (offset / 4) * 6);
+            engine.setColorWrite(true);
+            effect.setBool("alphaTest", false);
+        }
 
         engine.setAlphaMode(this._blendMode);
         engine.drawElementsType(Material.TriangleFillMode, 0, (offset / 4) * 6);