threepipe
Version:
A 3D viewer framework built on top of three.js in TypeScript with a focus on quality rendering, modularity and extensibility.
86 lines (72 loc) • 2.9 kB
text/typescript
import {Color, ColorRepresentation, PointLight, PointLightShadow, Vector3} from 'three'
import {ILight, ILightEvent} from './ILight'
import {iLightCommons} from '../object/iLightCommons'
import {IObject3D} from '../IObject'
import {uiColor, uiNumber, UiObjectConfig, uiPanelContainer, uiSlider, uiToggle, uiVector} from 'uiconfig.js'
import {onChange3} from 'ts-browser-helpers'
('Point Light')
export class PointLight2 extends PointLight implements ILight<PointLightShadow> {
assetType = 'light' as const
setDirty = iLightCommons.setDirty
refreshUi = iLightCommons.refreshUi
declare uiConfig: UiObjectConfig
readonly isPointLight2 = true
('Enabled')
('setDirty')
declare visible: boolean
('Color', (that: PointLight2)=>({onChange: ()=>that.setDirty()}))
declare color: Color
('Intensity', [0, 30], 0.01)
('setDirty')
declare intensity: number
('Distance')
('setDirty')
declare distance: number
('Decay')
('setDirty')
declare decay: number
('Position', undefined, undefined, (that: PointLight2)=>({onChange: ()=>that.setDirty()}))
declare readonly position: Vector3
('Cast Shadow')
('setDirty')
declare castShadow: boolean
constructor(color?: ColorRepresentation, intensity?: number, distance?: number, decay?: number) {
super(color, intensity, distance, decay)
iLightCommons.upgradeLight.call(this)
}
autoScale() {
console.warn('AutoScale not supported on Lights')
return this
}
autoCenter() {
console.warn('AutoCenter not supported on Lights')
return this
}
/**
* @deprecated use `this` instead
*/
get lightObject(): this {
return this
}
/**
* @deprecated use `this` instead
*/
get modelObject(): this {
return this
}
// region inherited type fixes
// re-declaring from IObject3D because: https://github.com/microsoft/TypeScript/issues/16936
traverse: (callback: (object: IObject3D) => void) => void
traverseVisible: (callback: (object: IObject3D) => void) => void
traverseAncestors: (callback: (object: IObject3D) => void) => void
getObjectById: <T extends IObject3D = IObject3D>(id: number) => T | undefined
getObjectByName: <T extends IObject3D = IObject3D>(name: string) => T | undefined
getObjectByProperty: <T extends IObject3D = IObject3D>(name: string, value: string) => T | undefined
copy: (source: PointLight|IObject3D, recursive?: boolean, ...args: any[]) => this
clone: (recursive?: boolean) => this
remove: (...object: IObject3D[]) => this
dispatchEvent: (event: ILightEvent) => void
declare parent: null
declare children: IObject3D[]
// endregion
}