threepipe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AmbientLight2.ts 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import {AmbientLight, Color, ColorRepresentation} from 'three'
  2. import {ILight, ILightEvent} from './ILight'
  3. import {iLightCommons} from '../object/iLightCommons'
  4. import {IObject3D} from '../IObject'
  5. import {uiColor, uiPanelContainer, uiSlider, uiToggle} from 'uiconfig.js'
  6. import {onChange3} from 'ts-browser-helpers'
  7. @uiPanelContainer('Ambient Light')
  8. export class AmbientLight2 extends AmbientLight implements ILight<undefined> {
  9. assetType = 'light' as const
  10. setDirty = iLightCommons.setDirty
  11. refreshUi = iLightCommons.refreshUi
  12. readonly isAmbientLight2 = true
  13. @uiToggle('Enabled')
  14. @onChange3('setDirty')
  15. visible: boolean
  16. @uiColor('Color', (that: AmbientLight2)=>({onChange: ()=>that.setDirty()}))
  17. color: Color
  18. @uiSlider('Intensity', [0, 30], 0.01)
  19. @onChange3('setDirty')
  20. intensity: number
  21. constructor(color?: ColorRepresentation, intensity?: number) {
  22. super(color, intensity)
  23. iLightCommons.upgradeLight.call(this)
  24. }
  25. autoScale() {
  26. console.warn('AutoScale not supported on Lights')
  27. return this
  28. }
  29. autoCenter() {
  30. console.warn('AutoCenter not supported on Lights')
  31. return this
  32. }
  33. /**
  34. * @deprecated use `this` instead
  35. */
  36. get lightObject(): this {
  37. return this
  38. }
  39. /**
  40. * @deprecated use `this` instead
  41. */
  42. get modelObject(): this {
  43. return this
  44. }
  45. // region inherited type fixes
  46. // re-declaring from IObject3D because: https://github.com/microsoft/TypeScript/issues/16936
  47. traverse: (callback: (object: IObject3D) => void) => void
  48. traverseVisible: (callback: (object: IObject3D) => void) => void
  49. traverseAncestors: (callback: (object: IObject3D) => void) => void
  50. getObjectById: <T extends IObject3D = IObject3D>(id: number) => T | undefined
  51. getObjectByName: <T extends IObject3D = IObject3D>(name: string) => T | undefined
  52. getObjectByProperty: <T extends IObject3D = IObject3D>(name: string, value: string) => T | undefined
  53. copy: (source: AmbientLight|IObject3D, recursive?: boolean, ...args: any[]) => this
  54. clone: (recursive?: boolean) => this
  55. remove: (...object: IObject3D[]) => this
  56. dispatchEvent: (event: ILightEvent) => void
  57. parent: null
  58. children: IObject3D[]
  59. // endregion
  60. }