sebavan 4 年之前
父节点
当前提交
81d0b945f4
共有 2 个文件被更改,包括 14 次插入7 次删除
  1. 4 6
      src/Materials/Textures/thinTexture.ts
  2. 10 1
      src/Sprites/spriteRenderer.ts

+ 4 - 6
src/Materials/Textures/thinTexture.ts

@@ -8,8 +8,7 @@ import { ThinEngine } from '../../Engines/thinEngine';
 
 /**
  * Base class of all the textures in babylon.
- * It groups all the common properties the materials, post process, lights... might need
- * in order to make a correct use of the texture.
+ * It groups all the common properties required to work with Thin Engine.
  */
 export class ThinTexture {
     protected _wrapU = Constants.TEXTURE_WRAP_ADDRESSMODE;
@@ -147,11 +146,10 @@ export class ThinTexture {
     private _cachedBaseSize: ISize = Size.Zero();
 
     /**
-     * Instantiates a new BaseTexture.
+     * Instantiates a new ThinTexture.
      * Base class of all the textures in babylon.
-     * It groups all the common properties the materials, post process, lights... might need
-     * in order to make a correct use of the texture.
-     * @param sceneOrEngine Define the scene or engine the texture blongs to
+     * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
+     * @param internalTexture Define the internalTexture to wrap
      */
     constructor(internalTexture: Nullable<InternalTexture>) {
         this._texture = internalTexture;

+ 10 - 1
src/Sprites/spriteRenderer.ts

@@ -46,6 +46,12 @@ export class SpriteRenderer {
     public blendMode = Constants.ALPHA_COMBINE;
 
     /**
+     * Gets or sets a boolean indicating if alpha mode is automatically
+     * reset.
+     */
+    public autoResetAlpha = true;
+
+    /**
      * 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.
@@ -278,7 +284,10 @@ export class SpriteRenderer {
         } else {
             engine.drawElementsType(Constants.MATERIAL_TriangleFillMode, 0, (offset / 4) * 6);
         }
-        engine.setAlphaMode(Constants.ALPHA_DISABLE);
+
+        if (this.autoResetAlpha) {
+            engine.setAlphaMode(Constants.ALPHA_DISABLE);
+        }
 
         // Restore Right Handed
         if (useRightHandedSystem) {