threepipe
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ITexture.ts 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import {IMaterial} from './IMaterial'
  2. import {Source, Texture, TextureEventMap} from 'three'
  3. import {IRenderTarget} from '../rendering'
  4. export interface ITextureUserData{
  5. mimeType?: string
  6. embedUrlImagePreviews?: boolean
  7. /**
  8. * Automatically dispose texture when not used by any material that's applied to some object in the scene.
  9. * Works only after it's applied to a material once.
  10. */
  11. disposeOnIdle?: boolean
  12. }
  13. // export type ITextureEventTypes = 'dispose' | 'update'
  14. // export type ITextureEvent<T extends string = ITextureEventTypes> = Event & {
  15. // type: T
  16. // texture?: ITexture
  17. // uiChangeEvent?: ChangeEvent
  18. // }
  19. export type ITextureEventMap = TextureEventMap
  20. export interface ITexture<TE extends ITextureEventMap = ITextureEventMap> extends Texture<TE> {
  21. assetType?: 'texture'
  22. userData: ITextureUserData
  23. readonly isTexture: true
  24. isDataTexture?: boolean
  25. isCubeTexture?: boolean
  26. isVideoTexture?: boolean
  27. isCanvasTexture?: boolean
  28. isCompressedTexture?: boolean
  29. is3DDataTexture?: boolean
  30. setDirty?(): void
  31. source: Source & {
  32. _sourceImgBuffer?: ArrayBuffer|Uint8Array // see KTX2LoadPlugin and serializeTextureInExtras
  33. _canSerialize?: boolean // see KTX2LoadPlugin and GLTFExporter.js. Disables auto decompress for glTF export
  34. }
  35. _appliedMaterials?: Set<IMaterial> // for internal use only. refers to the materials that this texture is applied to
  36. _target?: IRenderTarget // for internal use only. refers to the render target that this texture is attached to
  37. }
  38. export function upgradeTexture(this: ITexture) {
  39. this.assetType = 'texture'
  40. if (!this.userData) this.userData = {}
  41. if (!this._appliedMaterials) this._appliedMaterials = new Set()
  42. if (!this.setDirty) this.setDirty = ()=>this.needsUpdate = true
  43. // todo: uiconfig, dispose, etc
  44. }