This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In three.js, many functions have optional parameters. | |
// For example, the color constructor can take 0, 1, 2 or 3 parameters: | |
const c1 = new THREE.Color(0xff00ff); | |
const c2 = new THREE.Color(); | |
const c3 = new THREE.Color(1,0,0); | |
const c4 = new THREE.Color('blue'); | |
const c5 = new THREE.Color(new THREE.Color('green')); | |
// Here, the function is a bit complicated because the first parameter can have different types. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in three.js, there are various ways to define a color: | |
// using an int | |
const light1 = new THREE.AmbientLight(0xff0000); | |
// using a predefined color (string) | |
const light2 = new THREE.AmbientLight("green"); | |
// using a rgb triplet | |
const light3 = new THREE.AmbientLight(new THREE.Color(0,0,1)); |