| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- /**
- * https://github.com/mrdoob/eventtarget.js/
- */
- THREE.EventTarget = function () {
- var listeners = {};
- this.addEventListener = function ( type, listener ) {
- if ( listeners[ type ] === undefined ) {
- listeners[ type ] = [];
- }
- if ( listeners[ type ].indexOf( listener ) === - 1 ) {
- listeners[ type ].push( listener );
- }
- };
- this.dispatchEvent = function ( event ) {
- for ( var i = 0; i < listeners[ event.type ].length; i ++ ) {
- listeners[ event.type ][ i ]( event );
- }
- };
- this.removeEventListener = function ( type, listener ) {
- var index = listeners[ type ].indexOf( listener );
- if ( index !== - 1 ) {
- listeners[ type ].splice( index, 1 );
- }
- };
- };
|