Can you use Random Color for Chapter 12

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);

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:

  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:

/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):

/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

Very helpful. Thank you