Browse Source

Merge pull request #7855 from Popov72/shadermaterial-settexture

setTexture and setTextureArray from ShaderMaterial take now a BaseTex…
sebavan 5 years ago
parent
commit
fefded78ee
2 changed files with 5 additions and 4 deletions
  1. 1 0
      dist/preview release/what's new.md
  2. 4 4
      src/Materials/shaderMaterial.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -53,6 +53,7 @@
 - Added the `transparencyMode` property to the `StandardMaterial` class ([Popov72](https://github.com/Popov72))
 - Added to `FresnelParameters` constructor options and equals method ([brianzinn](https://github.com/brianzinn))
 - Added `AddAttribute` to `CustomMaterial` and `PBRCustomMaterial` ([Popov72](https://github.com/Popov72))
+- `setTexture` and `setTextureArray` from `ShaderMaterial` take now a `BaseTexture` as input instead of a `Texture`, allowing to pass a `CubeTexture` ([Popov72](https://github.com/Popov72))
 
 ### WebXR
 

+ 4 - 4
src/Materials/shaderMaterial.ts

@@ -64,8 +64,8 @@ export interface IShaderMaterialOptions {
 export class ShaderMaterial extends Material {
     private _shaderPath: any;
     private _options: IShaderMaterialOptions;
-    private _textures: { [name: string]: Texture } = {};
-    private _textureArrays: { [name: string]: Texture[] } = {};
+    private _textures: { [name: string]: BaseTexture } = {};
+    private _textureArrays: { [name: string]: BaseTexture[] } = {};
     private _floats: { [name: string]: number } = {};
     private _ints: { [name: string]: number } = {};
     private _floatsArrays: { [name: string]: number[] } = {};
@@ -179,7 +179,7 @@ export class ShaderMaterial extends Material {
      * @param texture Define the texture to bind to this sampler
      * @return the material itself allowing "fluent" like uniform updates
      */
-    public setTexture(name: string, texture: Texture): ShaderMaterial {
+    public setTexture(name: string, texture: BaseTexture): ShaderMaterial {
         if (this._options.samplers.indexOf(name) === -1) {
             this._options.samplers.push(name);
         }
@@ -194,7 +194,7 @@ export class ShaderMaterial extends Material {
      * @param textures Define the list of textures to bind to this sampler
      * @return the material itself allowing "fluent" like uniform updates
      */
-    public setTextureArray(name: string, textures: Texture[]): ShaderMaterial {
+    public setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial {
         if (this._options.samplers.indexOf(name) === -1) {
             this._options.samplers.push(name);
         }