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.

HemisphereLight2.ts 2.6KB

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