How to use the RGBAFormat function from three

Find comprehensive JavaScript three.RGBAFormat code examples handpicked from public code repositorys.

three.RGBAFormat is a constant in the Three.js library that represents the pixel format of an RGBA image texture.

170
171
172
173
174
175
176
177
178
179
if (this.disposed) {
    return;
}
const texture = new three.Texture(image);
texture.generateMipmaps = false;
texture.format = three.RGBAFormat;
texture.magFilter = three.LinearFilter;
texture.minFilter = three.LinearFilter;
texture.needsUpdate = true;
this.material.map = texture;
fork icon75
star icon468
watch icon0

+ 7 other calls in file

54
55
56
57
58
59
60
61
62
63

// var renderTarget = new THREE.WebGLRenderTarget(window.innerWidth, window.innerHeight, parameters);

var composer = new THREE.EffectComposer(renderer);
composer.renderTarget1.texture.format = THREE.RGBAFormat;
composer.renderTarget2.texture.format = THREE.RGBAFormat;
composer.setSize(window.innerWidth * dpr, window.innerHeight * dpr);

module.exports.init = function (_scene, _camera, done) {
  var start = Date.now();
fork icon2
star icon28
watch icon3

+ 19 other calls in file

How does three.RGBAFormat work?

three.RGBAFormat is a constant in the Three.js library that represents the pixel format of an RGBA image texture. In Three.js, textures are used to apply images or other visual data to 3D objects in a scene. Each texture has a pixel format that specifies how the individual pixels in the image are represented. The three.RGBAFormat constant indicates that each pixel in the texture should be represented by four values: red, green, blue, and alpha (transparency). The three.RGBAFormat constant is used in conjunction with other constants and properties in the Three.js library to create and manipulate textures. For example, you might use three.RGBAFormat when creating a new texture object like this: javascript Copy code {{{{{{{ const texture = new THREE.Texture(data, width, height, three.RGBAFormat); In this code, we create a new THREE.Texture object using the new operator and pass in some data (the image data for the texture), width, height, and the three.RGBAFormat constant. This creates a texture that represents an RGBA image with the specified dimensions. The three.RGBAFormat constant is just one of several constants available in Three.js that represent different pixel formats. Other constants include three.AlphaFormat, three.RGBFormat, and three.LuminanceFormat, among others.

181
182
183
184
185
186
187
188
189
190
    image_base_path + 'posy.jpg',
    image_base_path + 'negy.jpg',
    image_base_path + 'posz.jpg',
    image_base_path + 'negz.jpg',
]);
textureCube.format = THREE.RGBAFormat;
textureCube.mapping = THREE.CubeReflectionMapping;
textureCube.encoding = THREE.sRGBEncoding;

// Skybox
fork icon75
star icon0
watch icon0

133
134
135
136
137
138
139
140
141
142
    && header[off_GBitMask] & 0xff00
    && header[off_BBitMask] & 0xff
    && header[off_ABitMask] & 0xff000000) {
    isRGBAUncompressed = true;
    blockBytes = 64;
    dds.format = three_1.RGBAFormat;
}
else {
    console.error('THREE.DDSLoader.parse: Unsupported FourCC code ', int32ToFourCC(fourCC));
    return dds;
fork icon1
star icon3
watch icon0

+ 8 other calls in file

Ai Example

1
2
const texture = new THREE.TextureLoader().load("my-image.png");
texture.format = three.RGBAFormat;

In this example, we use the THREE.TextureLoader class to load an image file named my-image.png. This creates a new THREE.Texture object that represents the image data. We then set the format property of the texture to three.RGBAFormat. This tells Three.js that each pixel in the texture should be represented by four values: red, green, blue, and alpha (transparency). Once the texture has been created and configured, we can apply it to a 3D object in our scene, like a cube or a sphere, using a THREE.Mesh object. javascript Copy code

184
185
186
187
188
189
190
191
192
193
  && header[ off_BBitMask ] & 0xff
  && header[ off_ABitMask ] & 0xff000000 ) {

  isRGBAUncompressed = true;
  blockBytes = 64;
  dds.format = THREE.RGBAFormat;

} else {

  reject( new Error('THREE.DDSLoader.parse: Unsupported FourCC code ', int32ToFourCC( fourCC ) ));
fork icon0
star icon3
watch icon0

+ 3 other calls in file

137
138
139
140
141
142
143
144
145
146

default:
  if (header[22] === 32 && header[23] & 0xff0000 && header[24] & 0xff00 && header[25] & 0xff && header[26] & 0xff000000) {
    isRGBAUncompressed = true;
    blockBytes = 64;
    dds.format = _three.RGBAFormat;
  } else {
    console.error('THREE.DDSLoader.parse: Unsupported FourCC code ', int32ToFourCC(fourCC));
    return dds;
  }
fork icon0
star icon1
watch icon1

+ 12 other calls in file

814
815
816
817
818
819
820
821
822
823
textureLoader.setCrossOrigin(options.crossOrigin);
textureLoader.load(resolveURL(sourceUri, options.path), function (_texture) {
  if (isObjectURL) URL.revokeObjectURL(sourceUri);
  _texture.flipY = false;
  if (texture.name !== undefined) _texture.name = texture.name;
  _texture.format = texture.format !== undefined ? WEBGL_TEXTURE_FORMATS[texture.format] : THREE.RGBAFormat;

  if (texture.internalFormat !== undefined && _texture.format !== WEBGL_TEXTURE_FORMATS[texture.internalFormat]) {
    console.warn('threeExamples.LegacyGLTFLoader: Three.js doesn\'t support texture internalFormat which is different from texture format. ' + 'internalFormat will be forced to be the same value as format.');
  }
fork icon0
star icon1
watch icon0

+ 9 other calls in file

1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
if ( textureDef.name !== undefined ) texture.name = textureDef.name;

// .format of dds texture is set in DDSLoader
if ( ! textureExtensions[ EXTENSIONS.MSFT_TEXTURE_DDS ] ) {

	texture.format = textureDef.format !== undefined ? WEBGL_TEXTURE_FORMATS[ textureDef.format ] : THREE.RGBAFormat;

}

if ( textureDef.internalFormat !== undefined && texture.format !== WEBGL_TEXTURE_FORMATS[ textureDef.internalFormat ] ) {
fork icon0
star icon0
watch icon0

+ 8 other calls in file

Other functions in three

Sorted by popularity

function icon

three.Vector3 is the most popular function in three (22341 examples)