threepipe
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

RectAreaLight2.ts 2.6KB

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