Skip to content

Commit

Permalink
Examples: Remove remaining RGBFormat usage. (#23218)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 authored Jan 13, 2022
1 parent 2828243 commit 8ca01f8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 31 deletions.
2 changes: 1 addition & 1 deletion docs/examples/en/objects/Lensflare.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<h1>[name]</h1>

<p class="desc">
Creates a simulated lens flare that tracks a light.
Creates a simulated lens flare that tracks a light. [name] can only be used when setting the *alpha* context parameter of [page:WebGLRenderer] to *true*.
</p>

<h2>Code Example</h2>
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/zh/objects/Lensflare.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<h1>镜头光晕([name])</h1>

<p class="desc">
创建一个模拟追踪着灯光的镜头光晕。
创建一个模拟追踪着灯光的镜头光晕。 [name] can only be used when setting the *alpha* context parameter of [page:WebGLRenderer] to *true*.
</p>

<h2>代码示例</h2>
Expand Down
32 changes: 8 additions & 24 deletions examples/jsm/exporters/GLTFExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
NearestMipmapNearestFilter,
PropertyBinding,
RGBAFormat,
RGBFormat,
RepeatWrapping,
Scene,
Vector3
Expand Down Expand Up @@ -962,7 +961,7 @@ class GLTFWriter {
/**
* Process image
* @param {Image} image to process
* @param {Integer} format of the image (e.g. RGBFormat, RGBAFormat etc)
* @param {Integer} format of the image (RGBAFormat)
* @param {Boolean} flipY before writing out the image
* @return {Integer} Index of the processed texture in the "images" array
*/
Expand Down Expand Up @@ -1011,9 +1010,9 @@ class GLTFWriter {

} else {

if ( format !== RGBAFormat && format !== RGBFormat ) {
if ( format !== RGBAFormat ) {

console.error( 'GLTFExporter: Only RGB and RGBA formats are supported.' );
console.error( 'GLTFExporter: Only RGBAFormat is supported.' );

}

Expand All @@ -1025,27 +1024,12 @@ class GLTFWriter {

const data = new Uint8ClampedArray( image.height * image.width * 4 );

if ( format === RGBAFormat ) {
for ( let i = 0; i < data.length; i += 4 ) {

for ( let i = 0; i < data.length; i += 4 ) {

data[ i + 0 ] = image.data[ i + 0 ];
data[ i + 1 ] = image.data[ i + 1 ];
data[ i + 2 ] = image.data[ i + 2 ];
data[ i + 3 ] = image.data[ i + 3 ];

}

} else {

for ( let i = 0, j = 0; i < data.length; i += 4, j += 3 ) {

data[ i + 0 ] = image.data[ j + 0 ];
data[ i + 1 ] = image.data[ j + 1 ];
data[ i + 2 ] = image.data[ j + 2 ];
data[ i + 3 ] = 255;

}
data[ i + 0 ] = image.data[ i + 0 ];
data[ i + 1 ] = image.data[ i + 1 ];
data[ i + 2 ] = image.data[ i + 2 ];
data[ i + 3 ] = image.data[ i + 3 ];

}

Expand Down
8 changes: 4 additions & 4 deletions examples/jsm/objects/Lensflare.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
InterleavedBufferAttribute,
Mesh,
MeshBasicMaterial,
RGBFormat,
RawShaderMaterial,
Vector2,
Vector3,
Vector4
Vector4,
RGBAFormat
} from '../../../build/three.module.js';

class Lensflare extends Mesh {
Expand All @@ -32,8 +32,8 @@ class Lensflare extends Mesh {

// textures

const tempMap = new FramebufferTexture( 16, 16, RGBFormat );
const occlusionMap = new FramebufferTexture( 16, 16, RGBFormat );
const tempMap = new FramebufferTexture( 16, 16, RGBAFormat );
const occlusionMap = new FramebufferTexture( 16, 16, RGBAFormat );

// material

Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_lensflares.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@

// renderer

renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer = new THREE.WebGLRenderer( { antialias: true, alpha: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.outputEncoding = THREE.sRGBEncoding;
Expand Down

0 comments on commit 8ca01f8

Please sign in to comment.