How to use the RGB_ETC1_Format function from three

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

three.RGB_ETC1_Format is a compressed texture format in the Three.js library that uses the Ericsson Texture Compression (ETC1) algorithm to reduce the size of RGB textures.

123
124
125
126
127
128
129
130
131
132
    blockBytes = 16;
    dds.format = three_1.RGBA_S3TC_DXT5_Format;
    break;
case FOURCC_ETC1:
    blockBytes = 8;
    dds.format = three_1.RGB_ETC1_Format;
    break;
default:
    if (header[off_RGBBitCount] === 32
        && header[off_RBitMask] & 0xff0000
fork icon1
star icon3
watch icon0

+ 8 other calls in file

171
172
173
174
175
176
177
178
179
  break;

case FOURCC_ETC1:

  blockBytes = 8;
  dds.format = THREE.RGB_ETC1_Format;
  break;

default:
fork icon0
star icon3
watch icon0

+ 3 other calls in file

How does three.RGB_ETC1_Format work?

three.RGB_ETC1_Format is a compressed texture format in the Three.js library that uses the Ericsson Texture Compression (ETC1) algorithm to reduce the size of RGB textures. When you use three.RGB_ETC1_Format to compress a texture, the RGB data is compressed using the ETC1 algorithm, which is a lossy compression algorithm that uses 4x4 blocks to reduce the size of the texture. The ETC1 algorithm works by quantizing the RGB color space, which means that it reduces the number of possible color values that can be represented in the texture. This can result in some loss of image quality, but it can significantly reduce the size of the texture file. After the texture data is compressed using the ETC1 algorithm, it can be uploaded to the graphics card and used in a Three.js scene. Note that three.RGB_ETC1_Format is just one of several compressed texture formats that are available in Three.js. Other compressed texture formats include three.RGBA_PVRTC_4BPPV1_Format, three.RGBA_S3TC_DXT5_Format, and three.RGB_ETC2_Format. Overall, three.RGB_ETC1_Format is a useful texture format in the Three.js library that can be used to reduce the size of RGB textures using the ETC1 compression algorithm.

130
131
132
133
134
135
136
137
138
139
  dds.format = _three.RGBA_S3TC_DXT5_Format;
  break;

case FOURCC_ETC1:
  blockBytes = 8;
  dds.format = _three.RGB_ETC1_Format;
  break;

default:
  if (header[22] === 32 && header[23] & 0xff0000 && header[24] & 0xff00 && header[25] & 0xff && header[26] & 0xff000000) {
fork icon0
star icon1
watch icon1

+ 12 other calls in file

Ai Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
const textureLoader = new THREE.TextureLoader();
textureLoader.setPath("textures/");

const compressedTexture = textureLoader.load("compressed_texture.etc1", () => {
  // The texture has been loaded
});

compressedTexture.format = THREE.RGB_ETC1_Format;

const planeGeometry = new THREE.PlaneGeometry(10, 10);
const planeMaterial = new THREE.MeshBasicMaterial({ map: compressedTexture });
const planeMesh = new THREE.Mesh(planeGeometry, planeMaterial);

scene.add(planeMesh);

In this example, we first create a new TextureLoader object and set its base path to 'textures/'. We then call textureLoader.load('compressed_texture.etc1') to load a compressed texture file named 'compressed_texture.etc1'. Once the texture is loaded, we set its format to THREE.RGB_ETC1_Format by setting the format property of the texture object. We then create a new PlaneGeometry, MeshBasicMaterial, and Mesh object to display the compressed texture in a Three.js scene. Overall, this example demonstrates how to use three.RGB_ETC1_Format to load a compressed texture file in Three.js, and how to use it in a mesh material.

Other functions in three

Sorted by popularity

function icon

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