Преглед на файлове

Merge pull request #6841 from ycw/patch-2

copy DynamicTexture img data on clone
David Catuhe преди 6 години
родител
ревизия
c7d68ce204
променени са 1 файла, в които са добавени 9 реда и са изтрити 1 реда
  1. 9 1
      src/Particles/particleSystem.ts

+ 9 - 1
src/Particles/particleSystem.ts

@@ -11,6 +11,7 @@ import { MaterialHelper } from "../Materials/materialHelper";
 import { Effect } from "../Materials/effect";
 import { ImageProcessingConfiguration } from "../Materials/imageProcessingConfiguration";
 import { Texture } from "../Materials/Textures/texture";
+import { DynamicTexture } from "../Materials/Textures/dynamicTexture";
 import { RawTexture } from "../Materials/Textures/rawTexture";
 import { ProceduralTexture } from "../Materials/Textures/Procedurals/proceduralTexture";
 import { EngineStore } from "../Engines/engineStore";
@@ -1927,7 +1928,14 @@ export class ParticleSystem extends BaseParticleSystem implements IDisposable, I
         result.noiseTexture = this.noiseTexture;
         result.emitter = newEmitter;
         if (this.particleTexture) {
-            result.particleTexture = new Texture(this.particleTexture.url, this._scene);
+            if (this.particleTexture instanceof DynamicTexture) {
+                result.particleTexture = this.particleTexture.clone();
+                const ctx = (<unknown>result.particleTexture as DynamicTexture).getContext();
+                ctx.drawImage((<unknown>this.particleTexture as DynamicTexture).getContext().canvas, 0, 0);
+                (<unknown>result.particleTexture as DynamicTexture).update();
+            } else {
+                result.particleTexture = new Texture(this.particleTexture.url, this._scene);
+            }
         }
 
         // Clone gradients