We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Mapping textures with different aspect

Home Forums Programming Mapping textures with different aspect

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #29274
    web
    Customer

    I struggle a bit with mapping textures with different aspect ratio to a cloned object.

    I created a plane with simple planar mapping in 3dsMax. On runtime I clone this plane several times and position it to different locations. Every clone gets a different texture. Problem now is that because the plane is just a square and so is the mapping, that the texture is getting stretched to the size of the plane.

    What would be the best approach to overcome that issue?

    #29283
    web
    Customer

    I’ve just looked into the “get texture param” puzzle, in order to read the aspect and change the x/y scale of the cloned object.

    I tried to adapt the function, but it seems that the texture loading is async. So when I read texture.image it is undefined at runtime of the function. Would really appreciate some help in this regard.

    #29305
    web
    Customer

    Found a way. If anyone is interested.
    Moved the texture.image reading into the onload callback of the v3d.TextureLoader(). Then I can read the proper texture width and height and calculate the necessary scaling for the cloned geometry.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.