Nikos123

BaseTexture prop uscale not valid

Recommended Posts

 

Any idea whats changed in  2.3.0 ?

 

matGround.diffuseTexture.uScale = common.MEDIUM_SIZE_MAP_SUBDIVISIONS;

getting errors:

 

ERROR in [at-loader] ./client/Ground.ts:18:30 
    TS2339: Property 'uScale' does not exist on type 'BaseTexture'.
 

my source:

 

https://github.com/QuantumInformation/Density-Wars/blob/master/client/Ground.ts#L18

 

 

Share this post


Link to post
Share on other sites

Hi @Nikos123,

I just wanted to highlight the point you figured out.

In a StandardMaterial, the textures are defined as BaseTexture objects (and not Texture objects, that extend BaseTexture): https://doc.babylonjs.com/classes/2.5/standardmaterial#diffusetexture-basetexture-classes-2-5-basetexture-

Is that normal? Indeed, if I want to set properties such as uScale, vScale, uOffset or vOffset, I should cast my ambientTextures, diffuseTextures etc. as you did... but it could be risky, couldn't it?

However, I am unable to do so: when I write:

(BABYLON.BaseTexture(ground.diffuseTexture) as BABYLON.Texture)

the BJS playground warns me: "Unexpected identifier".

Thanks

Share this post


Link to post
Share on other sites

will this work if I use standard material instead of a texture?  I can't seem to get it working.

So lets say I have something like:

var material = new BABYLON.StandardMaterial("texture",scene);

material.diffuseTexture = new BABYLON.Texture("textures/background.png",scene);

material.diffuseTexture.uScale = 2.0;

 

Any ideas what I should do to get them to have the qualities uScale, vScale, and uOffset etc?

 

I had this working in javascript but when I switched over to typescript it kept giving me this error:

"Property 'uScale' does not exist on type 'BaseTexture'. Did you mean 'scale'?"

I did not mean scale.

Goal: Use .uScale on the StandardMaterial

Problem:  VScode/typescript says uScale does not exist on BaseTexture

@Deltakosh ping

Share this post


Link to post
Share on other sites
1 hour ago, Deltakosh said:

write it like that:


var material = new BABYLON.StandardMaterial("texture",scene);
var texture = new BABYLON.Texture("textures/background.png",scene);
texture.uScale = 2.0;

material.diffuseTexture = texture ;

This worked great, thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.