I was just messing around with three.js and came across the following example HERE. I see the following init function(i am not posting the whole function , but just a part of it):
function init() {
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( fov, window.innerWidth / window.innerHeight, 1, 1000 );
camera.position.z = 100;
camera.target = new THREE.Vector3();
controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.minDistance = 50;
controls.maxDistance = 200;
scene.add( new THREE.AmbientLight( 0x443333 ) );
var light = new THREE.DirectionalLight( 0xffddcc, 1 );
light.position.set( 1, 0.75, 0.5 );
scene.add( light );
var light = new THREE.DirectionalLight( 0xccccff, 1 );
light.position.set( -1, 0.75, -0.5 );
scene.add( light );
//..... more code
}
Now in a couple of places i see the following line of code used :
scene.add( new THREE.AmbientLight( 0x443333 ) );
When i surf the docs for the function AmbientLight i get the following:
AmbientLight docs,
AmbientLight( color, intensity )
color — Numeric value of the RGB component of the color. intensity -- Numeric value of the light's strength/intensity.
But what exactly is 0x443333 , I have never before come across something like this. Can somebody explain what exactly does 0x443333 mean ?
0x443333is the same as the hexidecimal#443333(in CSS, for example, or Photoshop) - just expressed with a0xto indicate that the number is written in base 16, so javascript parses these correctly. (this is also why you cannot write the number01in javascript, as it will be marked as incorrect)