|
@@ -9,6 +9,7 @@ import { BaseTexture } from "../Materials/Textures/baseTexture";
|
|
import { Light } from "./light";
|
|
import { Light } from "./light";
|
|
import { ShadowLight } from "./shadowLight";
|
|
import { ShadowLight } from "./shadowLight";
|
|
import { Texture } from '../Materials/Textures/texture';
|
|
import { Texture } from '../Materials/Textures/texture';
|
|
|
|
+import { ProceduralTexture } from '../Materials';
|
|
|
|
|
|
Node.AddNodeConstructor("Light_Type_2", (name, scene) => {
|
|
Node.AddNodeConstructor("Light_Type_2", (name, scene) => {
|
|
return () => new SpotLight(name, Vector3.Zero(), Vector3.Zero(), 0, 0, scene);
|
|
return () => new SpotLight(name, Vector3.Zero(), Vector3.Zero(), 0, 0, scene);
|
|
@@ -176,15 +177,27 @@ export class SpotLight extends ShadowLight {
|
|
this._projectionTexture = value;
|
|
this._projectionTexture = value;
|
|
this._projectionTextureDirty = true;
|
|
this._projectionTextureDirty = true;
|
|
if (this._projectionTexture && !this._projectionTexture.isReady()) {
|
|
if (this._projectionTexture && !this._projectionTexture.isReady()) {
|
|
- let texture = this._projectionTexture as Texture;
|
|
|
|
- if (texture.onLoadObservable) {
|
|
|
|
- texture.onLoadObservable.addOnce(() => {
|
|
|
|
|
|
+ if (SpotLight._IsProceduralTexture(this._projectionTexture)) {
|
|
|
|
+ this._projectionTexture.getEffect().executeWhenCompiled(() => {
|
|
|
|
+ this._markMeshesAsLightDirty();
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ else if (SpotLight._IsTexture(this._projectionTexture)) {
|
|
|
|
+ this._projectionTexture.onLoadObservable.addOnce(() => {
|
|
this._markMeshesAsLightDirty();
|
|
this._markMeshesAsLightDirty();
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static _IsProceduralTexture(texture: BaseTexture): texture is ProceduralTexture {
|
|
|
|
+ return (texture as ProceduralTexture).onGeneratedObservable !== undefined;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static _IsTexture(texture: BaseTexture): texture is Texture {
|
|
|
|
+ return (texture as Texture).onLoadObservable !== undefined;
|
|
|
|
+ }
|
|
|
|
+
|
|
private _projectionTextureViewLightDirty = true;
|
|
private _projectionTextureViewLightDirty = true;
|
|
private _projectionTextureProjectionLightDirty = true;
|
|
private _projectionTextureProjectionLightDirty = true;
|
|
private _projectionTextureDirty = true;
|
|
private _projectionTextureDirty = true;
|