# Can you use Random Color for Chapter 12

**URL:** <https://talk.code3dgames.com/t/can-you-use-random-color-for-chapter-12/474>\
**Category:** Uncategorized\
**Created:** [March 3, 2022, 7:38pm UTC](https://talk.code3dgames.com/t/can-you-use-random-color-for-chapter-12/474 "2022-03-03T19:38:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sharond](https://talk.code3dgames.com/user_avatar/talk.code3dgames.com/sharond/32/52_2.png) [@Sharond](https://talk.code3dgames.com/u/Sharond)\
**Post date:** [March 3, 2022, 7:39pm UTC](https://talk.code3dgames.com/t/can-you-use-random-color-for-chapter-12/474/1 "2022-03-03T19:39:00Z")

</div>

Hello,

We are working on Chapter 12: I have two questions

1. Can you use random colors instead of selection one color:

var shape = new THREE.TorusGeometry(50, 20, 8,29);  
var cover = new THREE.MeshPhongMaterial({color: ‘purple’});  
cover.specular.setRGB(0.9, 0.9, 0.9);  
var donut = new THREE.Mesh(shape, cover);  
donut.position.set(0, 150, 0);  
donut.castShadow = true;  
scene.add(donut);

1. If you want to change the texture, are you limited to the one mentioned in the book?  
var texture = new THREE.TextureLoader().load("/textures/rock.png");  
var shape = new THREE.PlaneGeometry(1000, 1000, 10, 10);  
var cover = new THREE.MeshPhongMaterial();  
cover.map = texture;  
var ground = new THREE.Mesh(shape, cover);  
ground.rotation.x = -Math.PI/2;  
ground.receiveShadow = true;  
scene.add(ground);

---

<div class="post-metadata">

**Author:** ![chris](https://talk.code3dgames.com/user_avatar/talk.code3dgames.com/chris/32/5_2.png) [@chris](https://talk.code3dgames.com/u/chris)\
**Post date:** [March 3, 2022, 8:09pm UTC](https://talk.code3dgames.com/t/can-you-use-random-color-for-chapter-12/474/2 "2022-03-03T20:09:47Z")

</div>

You can use random colors similar to what we did in chapter 5. The following will give you random colors each time the page is updated:

```auto
  var shape = new THREE.TorusGeometry(50, 20, 8, 20);
  var color = new THREE.Color(Math.random(), Math.random(), Math.random());
  var cover = new THREE.MeshPhongMaterial({color: color});
  cover.specular.setRGB(0.9, 0.9, 0.9);
  var donut = new THREE.Mesh(shape, cover);
  donut.position.set(0, 150, 0);
  donut.castShadow = true;
  scene.add(donut);

```

There are bunch of textures that you can try. Some are better than others:

```auto
/textures/albedo.png
/textures/flare.png
/textures/player.png
/textures/perlin-512.png
/textures/moon.png
/textures/metal.png
/textures/waterbump.png
/textures/rock.png
/textures/tree.png
/textures/lensflare0.png
/textures/hardwood.png
/textures/envmap.png
/textures/lava/cloud.png
/textures/lensflare1.png
/textures/square-outline.png
/textures/ground.png
/textures/square-outline-textured.png
/textures/particle2.png
/textures/patterns/bright_squares256.png
/textures/patterns/circuit_pattern.png
/textures/colors.png
/textures/spark.png
/textures/memorial.png
/textures/skyboxsun25degtest.png
/textures/rockn.png
/textures/spe/bullet2.png
/textures/spe/smokeparticle.png
/textures/spe/star.png
/textures/spe/bullet.png
/textures/spe/cloud.png
/textures/spe/shockwave.png
/textures/sun.png
/textures/earth.png
/textures/brick.png
/textures/minecraft/atlas.png
/textures/minecraft/grass_dirt.png
/textures/minecraft/dirt.png
/textures/minecraft/grass.png
/textures/floor.png
/textures/grass.png
/textures/planets/earth_clouds_2048.png
/textures/planets/earth_lights_2048.png
/textures/planets/earth_clouds_1024.png
/textures/grassn.png
/textures/test.png
/textures/fire.png
/textures/wood.png
/textures/grid.png

```

There are some addition images in JPEG format (note the `.jpg` extensions):

```auto
/textures/terrain/grasslight-big.jpg
/textures/terrain/grasslight-thin.jpg
/textures/terrain/grasslight-big-nm.jpg
/textures/terrain/backgrounddetailed6.jpg
/textures/speckles.jpg
/textures/tri_pattern.jpg
/textures/ricoh_theta_s.jpg
/textures/lava/lavatile.jpg
/textures/metal.jpg
/textures/grass.jpg
/textures/roughness_map.jpg
/textures/disturb.jpg
/textures/hardwood2_roughness.jpg
/textures/waternormals.jpg
/textures/spe/flames.jpg
/textures/lensflare2.jpg
/textures/water.jpg
/textures/brick_roughness.jpg
/textures/decal/decal-normal.jpg
/textures/land_ocean_ice_cloud_2048.jpg
/textures/misc.jpg
/textures/planets/earth_normal_2048.jpg
/textures/planets/earth_atmos_4096.jpg
/textures/planets/earth_specular_2048.jpg
/textures/planets/moon_1024.jpg
/textures/planets/earth_atmos_2048.jpg
/textures/amiga.jpg

```

One of the 3DE features that we have been working on is the ability to upload your own pictures. That’s not quite ready just yet, but hopefully in the next couple of months!

-Chris

---

<div class="post-metadata">

**Author:** ![Sharond](https://talk.code3dgames.com/user_avatar/talk.code3dgames.com/sharond/32/52_2.png) [@Sharond](https://talk.code3dgames.com/u/Sharond)\
**Post date:** [March 5, 2022, 2:24am UTC](https://talk.code3dgames.com/t/can-you-use-random-color-for-chapter-12/474/3 "2022-03-05T02:24:19Z")

</div>

Very helpful. Thank you
