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.4KB

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