threepipe
Version:
A modern 3D viewer framework built on top of three.js, written in TypeScript, designed to make creating high-quality, modular, and extensible 3D experiences on the web simple and enjoyable.
26 lines (22 loc) • 977 B
text/typescript
import {ILight} from '../light/ILight'
import {IObjectSetDirtyOptions} from '../IObject'
import {iObjectCommons} from './iObjectCommons'
export const iLightCommons = {
setDirty: function(this: ILight, options?: IObjectSetDirtyOptions, ...args: any[]): void {
if (typeof options === 'string') { // just incase called by decorators
options = {change: options}
}
// this.dispatchEvent({bubbleToParent: true, ...options, type: 'lightUpdate', light: this, object: this, args}) // this sets sceneUpdate in root scene
iObjectCommons.setDirty.call(this, options, ...args)
},
upgradeLight: upgradeLight,
refreshUi: iObjectCommons.refreshUi,
}
/**
* Converts three.js Light to ILight setup object events, adds utility methods, and runs objectProcessor.
* @param parent
*/
function upgradeLight(this: ILight, parent?: ILight|undefined): void {
if (!this) return
iObjectCommons.upgradeObject3D.call(this, parent)
}