Textures & Colours

Three.js and WebGL 3D Programming Crash Course Three.js & WebGL 3D Programming
7 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€64.94
List Price:  €92.78
You save:  €27.83
£55.57
List Price:  £79.40
You save:  £23.82
CA$95.27
List Price:  CA$136.11
You save:  CA$40.83
A$107.88
List Price:  A$154.13
You save:  A$46.24
S$94.55
List Price:  S$135.08
You save:  S$40.52
HK$547.57
List Price:  HK$782.28
You save:  HK$234.71
CHF 63.42
List Price:  CHF 90.61
You save:  CHF 27.18
NOK kr759.63
List Price:  NOK kr1,085.23
You save:  NOK kr325.60
DKK kr484.38
List Price:  DKK kr692.01
You save:  DKK kr207.62
NZ$117.46
List Price:  NZ$167.80
You save:  NZ$50.34
د.إ257.02
List Price:  د.إ367.19
You save:  د.إ110.16
৳7,682.93
List Price:  ৳10,976.08
You save:  ৳3,293.15
₹5,837.41
List Price:  ₹8,339.52
You save:  ₹2,502.10
RM331.26
List Price:  RM473.25
You save:  RM141.99
₦99,285.71
List Price:  ₦141,842.81
You save:  ₦42,557.10
₨19,466.20
List Price:  ₨27,810.04
You save:  ₨8,343.84
฿2,553.28
List Price:  ฿3,647.70
You save:  ฿1,094.41
₺2,262.39
List Price:  ₺3,232.12
You save:  ₺969.73
B$349.43
List Price:  B$499.21
You save:  B$149.77
R1,335.92
List Price:  R1,908.54
You save:  R572.62
Лв126.45
List Price:  Лв180.65
You save:  Лв54.20
₩94,634.34
List Price:  ₩135,197.71
You save:  ₩40,563.37
₪258.03
List Price:  ₪368.63
You save:  ₪110.60
₱3,943.57
List Price:  ₱5,633.91
You save:  ₱1,690.34
¥10,600.67
List Price:  ¥15,144.47
You save:  ¥4,543.79
MX$1,161.53
List Price:  MX$1,659.40
You save:  MX$497.87
QR255
List Price:  QR364.31
You save:  QR109.30
P959.59
List Price:  P1,370.91
You save:  P411.31
KSh9,203.68
List Price:  KSh13,148.68
You save:  KSh3,945
E£3,310.52
List Price:  E£4,729.52
You save:  E£1,419
ብር3,976.27
List Price:  ብር5,680.63
You save:  ብር1,704.36
Kz58,526.41
List Price:  Kz83,612.74
You save:  Kz25,086.33
CLP$68,581.80
List Price:  CLP$97,978.20
You save:  CLP$29,396.40
CN¥506.04
List Price:  CN¥722.95
You save:  CN¥216.90
RD$4,144.87
List Price:  RD$5,921.50
You save:  RD$1,776.62
DA9,443.17
List Price:  DA13,490.83
You save:  DA4,047.65
FJ$158.28
List Price:  FJ$226.12
You save:  FJ$67.84
Q545.87
List Price:  Q779.86
You save:  Q233.98
GY$14,645.83
List Price:  GY$20,923.51
You save:  GY$6,277.68
ISK kr9,762.20
List Price:  ISK kr13,946.60
You save:  ISK kr4,184.40
DH709.20
List Price:  DH1,013.19
You save:  DH303.99
L1,234.28
List Price:  L1,763.34
You save:  L529.05
ден3,991.30
List Price:  ден5,702.11
You save:  ден1,710.80
MOP$564.10
List Price:  MOP$805.89
You save:  MOP$241.79
N$1,325.35
List Price:  N$1,893.44
You save:  N$568.09
C$2,576.69
List Price:  C$3,681.15
You save:  C$1,104.45
रु9,334.54
List Price:  रु13,335.63
You save:  रु4,001.09
S/259.58
List Price:  S/370.84
You save:  S/111.26
K267.89
List Price:  K382.72
You save:  K114.82
SAR262.49
List Price:  SAR375
You save:  SAR112.51
ZK1,765.85
List Price:  ZK2,522.76
You save:  ZK756.90
L322.98
List Price:  L461.43
You save:  L138.44
Kč1,645.46
List Price:  Kč2,350.75
You save:  Kč705.29
Ft25,709.21
List Price:  Ft36,729.02
You save:  Ft11,019.81
SEK kr749.87
List Price:  SEK kr1,071.30
You save:  SEK kr321.42
ARS$60,034.20
List Price:  ARS$85,766.82
You save:  ARS$25,732.62
Bs483.70
List Price:  Bs691.04
You save:  Bs207.33
COP$271,296.95
List Price:  COP$387,583.68
You save:  COP$116,286.73
₡35,581.11
List Price:  ₡50,832.34
You save:  ₡15,251.22
L1,728.07
List Price:  L2,468.78
You save:  L740.71
₲516,441.87
List Price:  ₲737,805.73
You save:  ₲221,363.85
$U2,647.22
List Price:  $U3,781.90
You save:  $U1,134.68
zł280.50
List Price:  zł400.73
You save:  zł120.23
Already have an account? Log In

Transcript

Hello in this video we are going to look at using textures and colors with our geometry. More specifically, we're going to use it with our cube, but you can use it with any geometry within free j s pretty simple stuff. We've already got some images that we've just created using logos from our various divisions in Sona and our products, you can use whatever image you want and obviously the dimensions will match the actual object or geometry or more specifically, the face of the geometry that you're applying to. But again, pretty simple stuff. This tutorial is relevant for cube cuboid, see our all our goods. And as usual, if you go to three JS dot o website, look at the example look at the documentation thing got great stuff there to help you even if this series doesn't cover a particular node function.

So first of all, what we have is a mesh basic material. We are going to use Using our new mesh, mesh basic material, but we're going to be using one for each face. At the moment, we're just using a global mesh basic material for our geometry. But as the two paths, as you can see 12345 and stick faces obviously, in wireframe mode, we'll disable wireframe mode when we're actually viewing our textures. So what we want to do after we created the geometry we can just leave that as it is and actually increase the size later on so we can see the textures a little better on a create a new variable called Vol. Two materials equals this is going to be an array of mesh basic material, like said we're going to have six different mesh basic materials for each face I can easily customize them.

So you want to do new free dot mesh mesh, basic Cheerio. And now, in here, we'll do curly braces and then in here, instead of doing color and then wireframe, you want to do a new free drop texture loader dot load. And now you simply specify the path of the image you want to load for me image for slash one dot png. And then outside the breakfast is Saeed. cola on Free dot double sided. Let's see what this does in a moment.

All in all, I think demonstrate it once we've implemented it can we can remove this semicolon because we're within an array. Just put a comma there and then copy and paste that five more times while also tat indentation. So, fix this indentation. Finally, fix this one. Now we got to do is change this to two to three to four, five to six. So we are all done this i love about brackets, it gives you a preview of all the images which is fantastic with dimensions as well.

So it's a great way of just taking a look at files without having to go into the find arrow to the Explorer, depending on operating system you use using and wasting time. I'm just gonna put some comments. So you Know what soy did refer to right side, left side, top side, bottom side, front side of it, and guess what the last one is the backside. So now that we've got this cube materials created, we want to leave this material because we're going to be using this, but we need to replace it. Instead of using a new mesh, basic material which we've already used in our array, we need to do new three dot mesh face material to specify the array so that's cube materials. And now in here, we just specify the material and it's as simple as that.

So if we save this Go back to a web browser refresh. And as you can see, we have our little cube. Or I'm actually going to do obviously we don't need actually Oh yeah, that will go y prime anymore anyway, because we removed it from we removed the old mesh basic material, which is fine plastic, are actually going to increase the size of this 32 to the soul crucible quite a bit. Yeah, this is a lot better so we can easily see each of the sides. So if you want to use a color, you can easily mix and match. So instead of doing math, you could do could do color colon, zero x. FF, FF, FF, which is white.

Save that and that was there. Right? likes So we now have a Boyd side as well. So it's easy to mix and match colors and textures. So like I was saying before, we have this double size. So let me show you what it does.

And inside we can see our texture. And if I go inside, so if we're inside the object, we can also see the text is obviously the reversed. And if I were to, let's just say change this to Front, side, I'll change it up one to one side as well. Front side are changing to one, two, back soy. Soy so now we have two front side textures are actually ones a collapse, two, front side, two backs up to backside textures and to duplicate textures. As we've seen, the double sided can be viewed the Like and when the camera is on the inside of the the model.

So if we were to refresh we can view certain textures because we are not inside the Sophie were to go inside it certain objects we can see and certain objects we can't. So it's pretty simple stuff honoree reverse didn't look very nice at all turns back to do soy turbo soy double size there we go we have our beautiful little cube running with textures and colors. It's really that simple. Like I said, if you want to use it with all the geometry, just check out the free j s website and they got loads of examples and documentation. If you have any questions, feel free to message us and we will respond as usual. And thanks for watching and I hope you have a great day.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.