static decorateCamera(camera, animationController) {

				// setup animation controller property.
				camera._proxy_animationController = animationController;

				// decorate lookAt.
				const prevLookAt = camera.lookAt;
				camera.getLookAt = () => camera._proxy_lookAt;
				camera._proxy_lookAt = new THREE.Vector3();
				camera.lookAt = (lookAt) => {
					prevLookAt.bind(camera)(lookAt);
					camera._proxy_lookAt = lookAt;
				}; 

				// decorate update method.
				camera.getLookRight = () => camera._proxy_lookRight;
				camera.getLookUp = () => camera._proxy_lookUp;
				camera.getLookTo = () => camera._proxy_lookTo;
				camera.getLookToNormalized = () => camera._proxy_lookToNormalized;
				camera.getAspect = () => camera._proxy_aspect;
				
				const cameraDirection = new THREE.Vector3();
				const cameraRight = new THREE.Vector3();
				const cameraLookUp = new THREE.Vector3();
				const cameraLookTo = new THREE.Vector3();
				const cameraLookToNormalized = new THREE.Vector3();

				camera._proxy_cameraDirection = cameraDirection;
				camera._proxy_lookRight = cameraRight;
				camera._proxy_lookUp = cameraLookUp;
				camera._proxy_lookTo = cameraLookTo;
				camera._proxy_lookToNormalized = cameraLookToNormalized;

				const prepareParameters = () => {
					camera.getWorldDirection(cameraDirection);
					cameraRight.crossVectors(camera.up, cameraDirection).normalize();
					cameraLookUp.copy(camera.up);
					cameraLookTo.subVectors(camera.getLookAt(), camera.position);
					cameraLookToNormalized.copy(cameraLookTo).normalize();

					let aspect = 0;
					if (camera instanceof THREE.PerspectiveCamera) {
						aspect = camera.aspect;
					} else {
						aspect = Math.abs(camera.right - camera.left) / Math.abs(camera.top - camera.bottom);
					}
					camera._proxy_aspect = aspect;
				};

				const prevUpdate = camera.updateProjectionMatrix;
				camera.updateProjectionMatrix = () => {
					prepareParameters();
					prevUpdate.bind(camera)();
				};

				camera.setup = (viewInfo, duration) => {
					if (!viewInfo) {
						return;
					}
					if (camera._proxy_animationController && duration) {
						CameraHelper.animateCamera(camera._proxy_animationController, camera, viewInfo, duration);
					} else {
						if (viewInfo.fov) {
							camera.fov = viewInfo.fov;
						}
						if (viewInfo.position) {
							camera.position.copy(viewInfo.position);
						}		
						if (viewInfo.lookUp) {
							camera.up.copy(viewInfo.lookUp);
						}
						if (viewInfo.zoom) {
							camera.zoom = viewInfo.zoom;
						}
						if (viewInfo.lookAt) {
							camera.lookAt(viewInfo.lookAt);
						} else {
							camera.lookAt(camera.getLookAt());
						}
						camera.updateProjectionMatrix();
					}			
				};

				prepareParameters();
			}
// tricky way of making ThreeJS camera more functional.
tricky way of making ThreeJS camera more functional.
tricky way of making ThreeJS camera more functional .
static decorateCamera(camera, animationController) {
				camera._proxy_animationController = animationController;
				const prevLookAt = camera.lookAt;
				camera.getLookAt = () => camera._proxy_lookAt;
				camera._proxy_lookAt = new THREE.Vector3();
				camera.lookAt = (lookAt) => {
					prevLookAt.bind(camera)(lookAt);
					camera._proxy_lookAt = lookAt;
				}; 
				camera.getLookRight = () => camera._proxy_lookRight;
				camera.getLookUp = () => camera._proxy_lookUp;
				camera.getLookTo = () => camera._proxy_lookTo;
				camera.getLookToNormalized = () => camera._proxy_lookToNormalized;
				camera.getAspect = () => camera._proxy_aspect;
				const cameraDirection = new THREE.Vector3();
				const cameraRight = new THREE.Vector3();
				const cameraLookUp = new THREE.Vector3();
				const cameraLookTo = new THREE.Vector3();
				const cameraLookToNormalized = new THREE.Vector3();
				camera._proxy_cameraDirection = cameraDirection;
				camera._proxy_lookRight = cameraRight;
				camera._proxy_lookUp = cameraLookUp;
				camera._proxy_lookTo = cameraLookTo;
				camera._proxy_lookToNormalized = cameraLookToNormalized;
				const prepareParameters = () => {
					camera.getWorldDirection(cameraDirection);
					cameraRight.crossVectors(camera.up, cameraDirection).normalize();
					cameraLookUp.copy(camera.up);
					cameraLookTo.subVectors(camera.getLookAt(), camera.position);
					cameraLookToNormalized.copy(cameraLookTo).normalize();
					let aspect = 0;
					if (camera instanceof THREE.PerspectiveCamera) {
						aspect = camera.aspect;
					} else {
						aspect = Math.abs(camera.right - camera.left) / Math.abs(camera.top - camera.bottom);
					}
					camera._proxy_aspect = aspect;
				};
				const prevUpdate = camera.updateProjectionMatrix;
				camera.updateProjectionMatrix = () => {
					prepareParameters();
					prevUpdate.bind(camera)();
				};
				camera.setup = (viewInfo, duration) => {
					if (!viewInfo) {
						return;
					}
					if (camera._proxy_animationController && duration) {
						CameraHelper.animateCamera(camera._proxy_animationController, camera, viewInfo, duration);
					} else {
						if (viewInfo.fov) {
							camera.fov = viewInfo.fov;
						}
						if (viewInfo.position) {
							camera.position.copy(viewInfo.position);
						}		
						if (viewInfo.lookUp) {
							camera.up.copy(viewInfo.lookUp);
						}
						if (viewInfo.zoom) {
							camera.zoom = viewInfo.zoom;
						}
						if (viewInfo.lookAt) {
							camera.lookAt(viewInfo.lookAt);
						} else {
							camera.lookAt(camera.getLookAt());
						}
						camera.updateProjectionMatrix();
					}			
				};
				prepareParameters();
			}
static decorateCamera ( camera , animationController ) { camera . _proxy_animationController = animationController ; const prevLookAt = camera . lookAt ; camera . getLookAt = ( ) => camera . _proxy_lookAt ; camera . _proxy_lookAt = new THREE . Vector3 ( ) ; camera . lookAt = ( lookAt ) => { prevLookAt . bind ( camera ) ( lookAt ) ; camera . _proxy_lookAt = lookAt ; } ; camera . getLookRight = ( ) => camera . _proxy_lookRight ; camera . getLookUp = ( ) => camera . _proxy_lookUp ; camera . getLookTo = ( ) => camera . _proxy_lookTo ; camera . getLookToNormalized = ( ) => camera . _proxy_lookToNormalized ; camera . getAspect = ( ) => camera . _proxy_aspect ; const cameraDirection = new THREE . Vector3 ( ) ; const cameraRight = new THREE . Vector3 ( ) ; const cameraLookUp = new THREE . Vector3 ( ) ; const cameraLookTo = new THREE . Vector3 ( ) ; const cameraLookToNormalized = new THREE . Vector3 ( ) ; camera . _proxy_cameraDirection = cameraDirection ; camera . _proxy_lookRight = cameraRight ; camera . _proxy_lookUp = cameraLookUp ; camera . _proxy_lookTo = cameraLookTo ; camera . _proxy_lookToNormalized = cameraLookToNormalized ; const prepareParameters = ( ) => { camera . getWorldDirection ( cameraDirection ) ; cameraRight . crossVectors ( camera . up , cameraDirection ) . normalize ( ) ; cameraLookUp . copy ( camera . up ) ; cameraLookTo . subVectors ( camera . getLookAt ( ) , camera . position ) ; cameraLookToNormalized . copy ( cameraLookTo ) . normalize ( ) ; let aspect = 0 ; if ( camera instanceof THREE . PerspectiveCamera ) { aspect = camera . aspect ; } else { aspect = Math . abs ( camera . right - camera . left ) / Math . abs ( camera . top - camera . bottom ) ; } camera . _proxy_aspect = aspect ; } ; const prevUpdate = camera . updateProjectionMatrix ; camera . updateProjectionMatrix = ( ) => { prepareParameters ( ) ; prevUpdate . bind ( camera ) ( ) ; } ; camera . setup = ( viewInfo , duration ) => { if ( ! viewInfo ) { return ; } if ( camera . _proxy_animationController && duration ) { CameraHelper . animateCamera ( camera . _proxy_animationController , camera , viewInfo , duration ) ; } else { if ( viewInfo . fov ) { camera . fov = viewInfo . fov ; } if ( viewInfo . position ) { camera . position . copy ( viewInfo . position ) ; } if ( viewInfo . lookUp ) { camera . up . copy ( viewInfo . lookUp ) ; } if ( viewInfo . zoom ) { camera . zoom = viewInfo . zoom ; } if ( viewInfo . lookAt ) { camera . lookAt ( viewInfo . lookAt ) ; } else { camera . lookAt ( camera . getLookAt ( ) ) ; } camera . updateProjectionMatrix ( ) ; } } ; prepareParameters ( ) ; }
tricky way of making ThreeJS camera more functional.
tricky way of making ThreeJS camera more functional .
// setup animation controller property. // decorate lookAt. // decorate update method.