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

PointLight2.ts 2.8KB

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