|
@@ -13,6 +13,8 @@ import { _TypeStore } from '../../../../Misc/typeStore';
|
|
|
import { Texture } from '../../../Textures/texture';
|
|
|
import { Scene } from '../../../../scene';
|
|
|
import { NodeMaterialModes } from '../../Enums/nodeMaterialModes';
|
|
|
+import { Engine } from "../../../../Engines/engine";
|
|
|
+import { Constants } from '../../../../Engines/constants';
|
|
|
|
|
|
import "../../../../Shaders/ShadersInclude/helperFunctions";
|
|
|
|
|
@@ -32,10 +34,35 @@ export class TextureBlock extends NodeMaterialBlock {
|
|
|
private _mainUVDefineName: string;
|
|
|
private _fragmentOnly: boolean;
|
|
|
|
|
|
+ protected _texture: Nullable<Texture>;
|
|
|
/**
|
|
|
* Gets or sets the texture associated with the node
|
|
|
*/
|
|
|
- public texture: Nullable<Texture>;
|
|
|
+ public get texture(): Nullable<Texture> {
|
|
|
+ return this._texture;
|
|
|
+ }
|
|
|
+
|
|
|
+ public set texture(texture: Nullable<Texture>) {
|
|
|
+ if (this._texture === texture) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const scene = texture?.getScene() ?? Engine.LastCreatedScene;
|
|
|
+
|
|
|
+ if (!texture && scene) {
|
|
|
+ scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag, (mat) => {
|
|
|
+ return mat.hasTexture(this._texture!);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ this._texture = texture;
|
|
|
+
|
|
|
+ if (texture && scene) {
|
|
|
+ scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag, (mat) => {
|
|
|
+ return mat.hasTexture(texture);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Gets or sets a boolean indicating if content needs to be converted to gamma space
|