Jump to content

sequential textures


Noyogi
 Share

Recommended Posts

Hello again,

How have you been?

I've been well, thank you.

At this playground:

http://www.babylonjs-playground.com/#10BT9S#10

I have some clones of a plane with texture A1 in folder tex

I would like to apply a different texture to each clone

The textures will be named A1, A2, A3, A4 ... some B1, B2, B3, B4 ...

I could change the B's and C's to A's to make it a little simpler

How do apply texture without specifying for each one?

1st clone pulls from A1

2nd clone pulls from A2

3rd clone pulls from A3

4th from A4 and so on

Link to comment
Share on other sites

Hi again, Noyogi... thanks for the welcoming greets.  I am well, thank you for asking.  It is good to hear that you are well, as well.  :)

Let's see... first, you had a problem with the .backFaceCulling.  It is a property on StandardMaterial... so it should be mesh.material.backFaceCulling = true/false.  No big deal, because you have billBoardMode ALL turned-on, so mesh always faced you, no matter.  :)

About the best way to do this... is with file name adjustments... happening inside the inner-most for-loop.  Take a look at this mess...

http://www.babylonjs-playground.com/#10BT9S#13

In lines 31-36, I did some serious manipulating of urlString... using the values of x, y, and z.  This may not produce the filename template you wished-for, but it DOES produce 80 unique file names for 80 separate textures.  Check your console.

Line 31 does a basic boolean test.  IF left-hand pile, file name begins with "A".  Else, file name begins with "B". 
Line 32 appends it onto the urlString.
Line 33 does some more-advanced 4-condition testing, yet still boolean-based. 

(y == 1 ? "A" : (y == 2 ? "B" : (y == "3" ? "C" : "D")));
 y=1? add "A" OR y=2? add "B" OR  y=3?  add "C" OR add "D"

Line 34 appends this 2nd letter of the file name... onto the urlString.
Line 35 adds an underscore and then uses the String of z's value... 1 thru 10.
Line 36 appends this onto the urlString, along with the ".jpg" ending.

When you go into production, remark-out line 38, activate line 39, and have your 80 textures ready within the /tex folder...  AA_[1-10].jpg, AB_[1-10].jpg, AC_[1-10].jpg, AD_[1-10].jpg, BA_[1-10].jpg, BB_[1-10].jpg, BC_[1-10].jpg and BD_[1-10].jpg .   Hope this helps. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...