I am building a scenegraph out of Object3D nodes. Several of the nodes I would like to treat as Spin objects that are not active since the beginning but they become active when they receive a specific 'start' event, probably using a timer to fire it up. I need some assistance in setting this up. I have tried the following code
var spinner_obj = new THREE.Object3D();
spinner_obj.addEventListener('start', function(event) {alert("GOT THE EVENT");});
but this gives me an error "TypeError: spinner_obj.addEventListener is not a function"
In addition what would I have to do to fire this 'start' event? I am a javascript beginner. I have tried to follow https://github.com/mrdoob/eventdispatcher.js but I need some more pointers. Thank you.
Try doing this:
var spinner_obj = new THREE.Object3D();
THREE.EventDispatcher.call( spinner_obj );
spinner_obj.addEventListener('start', function(event) {alert("GOT THE EVENT");});
spinner_obj.dispatchEvent({type:'start'});