Creating an object in Three.js and adding a variable seems like a simple task, but I'm struggling to figure it out. For instance, I want to create a cube and have it store a variable called "beenHit" that can be accessed later on.
var geometry = new THREE.BoxGeometry( 1, 1, 1 );
var newColor = new THREE.Color("rgb(12%, 6%, 0%)");
var material = new THREE.MeshStandardMaterial( { color: newColor } );
var cube = new THREE.Mesh( geometry, material );
scene.add( cube );
var cube.beenHit = false;
I've tried different methods and searched extensively, but I'm still unable to get it right. Any assistance would be greatly appreciated.