Source: objects/DirectionalLight.js

import { Utils } from '../common/Utils'
import { DirectionalLightHelperComponent } from '../components/DirectionalLightHelperComponent';
import { BaseShadowLight } from './BaseShadowLight';

const registerComponentParam = { isResident: true };

/**
 * @class DirectionalLight
 * The directional light object.
 * @memberof THING
 * @extends THING.BaseShadowLight
 * @public
 */
class DirectionalLight extends BaseShadowLight {

	/**
	 * The directional light object in scene.
	 * @param {Object} param The initial parameters.
	 */
	constructor(param = {}) {
		super(param);
	}

	onBeforeSetup(param) {
		param['renderableNode'] = param['renderableNode'] || Utils.createObject('DirectionalLight');

		super.onBeforeSetup(param);
	}

	onSetupComponent(param) {
		super.onSetupComponent(param);

		this.addComponent(DirectionalLightHelperComponent, 'helper', registerComponentParam);
	}

	onBeforeDestroy() {
		if (!super.onBeforeDestroy()) {
			return false;
		}

		if (this.app.objectManager.keepAliveObjects.includes(this)) {
			return false;
		}

		return true;
	}

	// #region Accessor

	// #endregion

	/**
	 * Check whether it's DirectionalLight type or inherit from it.
	 * @type {Boolean}
	 * @public
	 */
	get isDirectionalLight() {
		return true;
	}

}

export { DirectionalLight }