threepipe
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

const-mappings.ts 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import {
  2. AdditiveBlending,
  3. AnyMapping,
  4. BasicDepthPacking,
  5. Blending,
  6. ByteType,
  7. ColorSpace,
  8. CubeReflectionMapping,
  9. CubeUVReflectionMapping,
  10. CustomBlending,
  11. DepthPackingStrategies,
  12. DisplayP3ColorSpace,
  13. EquirectangularReflectionMapping,
  14. FloatType,
  15. HalfFloatType,
  16. IntType,
  17. LinearSRGBColorSpace,
  18. MultiplyBlending,
  19. NoBlending,
  20. NormalBlending,
  21. RGBADepthPacking,
  22. RGBM16ColorSpace,
  23. ShortType,
  24. SRGBColorSpace,
  25. SubtractiveBlending,
  26. TextureDataType,
  27. UnsignedByteType,
  28. UnsignedInt248Type,
  29. UnsignedIntType,
  30. UnsignedShort4444Type,
  31. UnsignedShort5551Type,
  32. UnsignedShortType,
  33. UVMapping,
  34. } from 'three'
  35. import {UiObjectConfig} from 'uiconfig.js'
  36. const blending: Record<string, Blending> = {
  37. None: NoBlending,
  38. Normal: NormalBlending,
  39. Additive: AdditiveBlending,
  40. Subtractive: SubtractiveBlending,
  41. Multiply: MultiplyBlending,
  42. Custom: CustomBlending,
  43. }
  44. const mapping: Record<string, AnyMapping> = {
  45. UV: UVMapping,
  46. Cube: CubeReflectionMapping,
  47. // CubeRefraction: CubeRefractionMapping,
  48. CubeUV: CubeUVReflectionMapping,
  49. Equirectangular: EquirectangularReflectionMapping,
  50. // EquirectangularRefraction: EquirectangularRefractionMapping,
  51. }
  52. const colorSpace: Record<string, ColorSpace> = {
  53. None: '',
  54. SRGB: SRGBColorSpace,
  55. LinearSRGB: LinearSRGBColorSpace,
  56. RGBM16: RGBM16ColorSpace,
  57. DisplayP3: DisplayP3ColorSpace,
  58. }
  59. const textureDataType: Record<string, TextureDataType> = {
  60. UnsignedByte: UnsignedByteType,
  61. Byte: ByteType,
  62. Short: ShortType,
  63. UnsignedShort: UnsignedShortType,
  64. Int: IntType,
  65. UnsignedInt: UnsignedIntType,
  66. Float: FloatType,
  67. HalfFloat: HalfFloatType,
  68. UnsignedShort4444: UnsignedShort4444Type,
  69. UnsignedShort5551: UnsignedShort5551Type,
  70. UnsignedInt248: UnsignedInt248Type,
  71. }
  72. const depthPackingStrategies: Record<string, DepthPackingStrategies> = {
  73. Basic: BasicDepthPacking,
  74. RGBADepthPacking: RGBADepthPacking,
  75. }
  76. function makeMapping<T extends string|number|symbol>(a: Record<string, T>) {
  77. return {
  78. map: a,
  79. inv: Object.fromEntries(Object.entries(a).map(([k, v]) => [v, k])) as Record<T, string>,
  80. uiConfig: Object.entries(a).map(([k, v]) => ({label: k, value: v})) as UiObjectConfig[],
  81. } as const
  82. }
  83. export const threeConstMappings = {
  84. Blending: makeMapping(blending),
  85. AnyMapping: makeMapping(mapping),
  86. ColorSpace: makeMapping(colorSpace),
  87. TextureDataType: makeMapping(textureDataType),
  88. DepthPackingStrategies: makeMapping(depthPackingStrategies),
  89. } as const