threepipe
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

PointLight2.ts 2.7KB

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