In Three.js I want to create an object and then add a variable to it. I'm sure it's simple but I can't seem to do it, nor work out how to do it.
For example, I create a cube, and I want it to store a variable "beenHit" that can then be accessed in a Raycast.intersectObjects 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;
Is clearly wrong, but I've tried different ways and searched quite a bit, but my feeble brain cannot compute. Any help most appreciated.