meshUVSpaceRenderer.d.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import type { Texture } from "../Materials/Textures/texture.js";
  2. import type { Vector3 } from "../Maths/math.vector.js";
  3. import type { Scene } from "../scene.js";
  4. import type { AbstractMesh } from "./abstractMesh";
  5. import type { BaseTexture } from "../Materials/Textures/baseTexture.js";
  6. import type { Nullable } from "../types.js";
  7. import { ShaderMaterial } from "../Materials/shaderMaterial.js";
  8. import { Color4 } from "../Maths/math.color.js";
  9. import "../Shaders/meshUVSpaceRenderer.vertex";
  10. import "../Shaders/meshUVSpaceRenderer.fragment";
  11. import "../Shaders/meshUVSpaceRendererMasker.vertex";
  12. import "../Shaders/meshUVSpaceRendererMasker.fragment";
  13. import "../Shaders/meshUVSpaceRendererFinaliser.fragment";
  14. import "../Shaders/meshUVSpaceRendererFinaliser.vertex";
  15. declare module "../scene" {
  16. interface Scene {
  17. /** @internal */
  18. _meshUVSpaceRendererShader: Nullable<ShaderMaterial>;
  19. /** @internal */
  20. _meshUVSpaceRendererMaskShader: Nullable<ShaderMaterial>;
  21. }
  22. }
  23. /**
  24. * Options for the MeshUVSpaceRenderer
  25. * @since 5.49.1
  26. */
  27. export interface IMeshUVSpaceRendererOptions {
  28. /**
  29. * Width of the texture. Default: 1024
  30. */
  31. width?: number;
  32. /**
  33. * Height of the texture. Default: 1024
  34. */
  35. height?: number;
  36. /**
  37. * Type of the texture. Default: Constants.TEXTURETYPE_UNSIGNED_BYTE
  38. */
  39. textureType?: number;
  40. /**
  41. * Generate mip maps. Default: true
  42. */
  43. generateMipMaps?: boolean;
  44. /**
  45. * Optimize UV allocation. Default: true
  46. * If you plan to use the texture as a decal map and rotate / offset the texture, you should set this to false
  47. */
  48. optimizeUVAllocation?: boolean;
  49. /**
  50. * If true, a post processing effect will be applied to the texture to fix seams. Default: false
  51. */
  52. uvEdgeBlending?: boolean;
  53. }
  54. /**
  55. * Class used to render in the mesh UV space
  56. * @since 5.49.1
  57. */
  58. export declare class MeshUVSpaceRenderer {
  59. private _mesh;
  60. private _scene;
  61. private _options;
  62. private _textureCreatedInternally;
  63. private _configureUserCreatedTexture;
  64. private _maskTexture;
  65. private _finalPostProcess;
  66. private static _GetShader;
  67. private static _GetMaskShader;
  68. private static _IsRenderTargetTexture;
  69. /**
  70. * Clear color of the texture
  71. */
  72. clearColor: Color4;
  73. /**
  74. * Target texture used for rendering
  75. * If you don't set the property, a RenderTargetTexture will be created internally given the options provided to the constructor.
  76. * If you provide a RenderTargetTexture, it will be used directly.
  77. */
  78. texture: Texture;
  79. /**
  80. * Creates a new MeshUVSpaceRenderer
  81. * @param mesh The mesh used for the source UV space
  82. * @param scene The scene the mesh belongs to
  83. * @param options The options to use when creating the texture
  84. */
  85. constructor(mesh: AbstractMesh, scene: Scene, options?: IMeshUVSpaceRendererOptions);
  86. /**
  87. * Checks if the texture is ready to be used
  88. * @returns true if the texture is ready to be used
  89. */
  90. isReady(): boolean;
  91. /**
  92. * Projects and renders a texture in the mesh UV space
  93. * @param texture The texture
  94. * @param position The position of the center of projection (world space coordinates)
  95. * @param normal The direction of the projection (world space coordinates)
  96. * @param size The size of the projection
  97. * @param angle The rotation angle around the direction of the projection
  98. */
  99. renderTexture(texture: BaseTexture, position: Vector3, normal: Vector3, size: Vector3, angle?: number): void;
  100. /**
  101. * Clears the texture map
  102. */
  103. clear(): void;
  104. /**
  105. * Disposes of the resources
  106. */
  107. dispose(): void;
  108. private _configureUserCreatedRTT;
  109. private _createDiffuseRTT;
  110. private _createMaskTexture;
  111. private _createPostProcess;
  112. private _createRenderTargetTexture;
  113. private _createProjectionMatrix;
  114. }