Parcourir la source

copy image data on clone

otherwise, blank texture.. see https://www.babylonjs-playground.com/#231HR5
ycw il y a 6 ans
Parent
commit
fd64426a60
1 fichiers modifiés avec 11 ajouts et 1 suppressions
  1. 11 1
      src/Particles/particleSystem.ts

+ 11 - 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 { InternalTexture } from "../Materials/Textures/internalTexture"
 import { RawTexture } from "../Materials/Textures/rawTexture";
 import { ProceduralTexture } from "../Materials/Textures/Procedurals/proceduralTexture";
 import { EngineStore } from "../Engines/engineStore";
@@ -1927,7 +1928,16 @@ 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.getInternalTexture().dataSource === InternalTexture.DATASOURCE_DYNAMIC) {
+                // clone 
+                result.particleTexture = this.particleTexture.clone();
+                // copy underlying image data 
+                const ctx = result.particleTexture.getContext();
+                ctx.drawImage(this.particleTexture.getContext().canvas, 0, 0);
+                result.particleTexture.update();
+            } else {
+                result.particleTexture = new Texture(this.particleTexture.url, this._scene);
+            }
         }
 
         // Clone gradients