rawTexture3D.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { Texture } from "./texture.js";
  2. import "../../Engines/Extensions/engine.rawTexture.js";
  3. /**
  4. * Class used to store 3D textures containing user data
  5. */
  6. export class RawTexture3D extends Texture {
  7. /**
  8. * Create a new RawTexture3D
  9. * @param data defines the data of the texture
  10. * @param width defines the width of the texture
  11. * @param height defines the height of the texture
  12. * @param depth defines the depth of the texture
  13. * @param format defines the texture format to use
  14. * @param scene defines the hosting scene
  15. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  16. * @param invertY defines if texture must be stored with Y axis inverted
  17. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  18. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  19. * @param creationFlags specific flags to use when creating the texture (1 for storage textures, for eg)
  20. */
  21. constructor(data, width, height, depth,
  22. /** Gets or sets the texture format to use */
  23. format, scene, generateMipMaps = true, invertY = false, samplingMode = Texture.TRILINEAR_SAMPLINGMODE, textureType = 0, creationFlags) {
  24. super(null, scene, !generateMipMaps, invertY);
  25. this.format = format;
  26. this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, null, textureType, creationFlags);
  27. this.is3D = true;
  28. }
  29. /**
  30. * Update the texture with new data
  31. * @param data defines the data to store in the texture
  32. */
  33. update(data) {
  34. if (!this._texture) {
  35. return;
  36. }
  37. this._getEngine().updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, null, this._texture.type);
  38. }
  39. }
  40. //# sourceMappingURL=rawTexture3D.js.map