Browse Source

Fix detailMap with PBR

Popov72 5 năm trước cách đây
mục cha
commit
9f7b011eea
2 tập tin đã thay đổi với 17 bổ sung3 xóa
  1. 2 2
      src/Materials/PBR/pbrBaseMaterial.ts
  2. 15 1
      src/Materials/material.detailMap.ts

+ 2 - 2
src/Materials/PBR/pbrBaseMaterial.ts

@@ -1,4 +1,4 @@
-import { serialize, serializeAsImageProcessingConfiguration, expandToProperty, serializeAsTexture } from "../../Misc/decorators";
+import { serialize, serializeAsImageProcessingConfiguration, expandToProperty  } from "../../Misc/decorators";
 import { Observer } from "../../Misc/observable";
 import { Logger } from "../../Misc/logger";
 import { SmartArray } from "../../Misc/smartArray";
@@ -801,7 +801,7 @@ export abstract class PBRBaseMaterial extends PushMaterial {
     /**
      * Defines the detail map parameters for the material.
      */
-    public readonly detailMap = new DetailMap();
+    public readonly detailMap = new DetailMap(this._markAllSubMeshesAsTexturesDirty.bind(this));
 
     protected _rebuildInParallel = false;
 

+ 15 - 1
src/Materials/material.detailMap.ts

@@ -64,7 +64,21 @@ export class DetailMap {
      * Enable or disable the detail map on this material
      */
     @serialize()
-    public disableDetailMap: boolean = false;
+    /** @hidden */
+    private _internalMarkAllSubMeshesAsTexturesDirty: () => void;
+
+    /** @hidden */
+    public _markAllSubMeshesAsTexturesDirty(): void {
+        this._internalMarkAllSubMeshesAsTexturesDirty();
+    }
+
+    /**
+     * Instantiate a new detail map
+     * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
+     */
+    constructor(markAllSubMeshesAsTexturesDirty: () => void) {
+        this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
+    }
 
     /**
      * Gets whether the submesh is ready to be used or not.