Skip to content

Commit

Permalink
WebGPUTextures: Added more constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 committed Sep 3, 2020
1 parent 26472f8 commit 6e19f98
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
13 changes: 7 additions & 6 deletions examples/jsm/renderers/webgpu/WebGPUTextures.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { GPUTextureFormat, GPUAddressMode, GPUFilterMode } from './constants.js';
import { Texture, NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter, RepeatWrapping, MirroredRepeatWrapping } from '../../../../build/three.module.js';

class WebGPUTextures {
Expand Down Expand Up @@ -129,15 +130,15 @@ class WebGPUTextures {

_convertAddressMode( value ) {

let addressMode = 'clamp-to-edge';
let addressMode = GPUAddressMode.ClampToEdge;

if ( value === RepeatWrapping ) {

addressMode = 'repeat';
addressMode = GPUAddressMode.Repeat;

} else if ( value === MirroredRepeatWrapping ) {

addressMode = 'mirror-repeat';
addressMode = GPUAddressMode.MirrorRepeat;

}

Expand All @@ -147,11 +148,11 @@ class WebGPUTextures {

_convertFilterMode( value ) {

let filterMode = 'linear';
let filterMode = GPUFilterMode.Linear;

if ( value === NearestFilter || value === NearestMipmapNearestFilter || value === NearestMipmapLinearFilter ) {

filterMode = 'nearest';
filterMode = GPUFilterMode.Nearest;

}

Expand All @@ -173,7 +174,7 @@ class WebGPUTextures {
height: height,
depth: 1,
},
format: "rgba8unorm",
format: GPUTextureFormat.RGBA8Unorm,
usage: GPUTextureUsage.SAMPLED | GPUTextureUsage.COPY_DST,
} );

Expand Down
11 changes: 11 additions & 0 deletions examples/jsm/renderers/webgpu/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,14 @@ export const GPUTextureFormat = {
Depth32FloatStencil8: 'depth32float-stencil8',

};

export const GPUAddressMode = {
ClampToEdge: 'clamp-to-edge',
Repeat: 'repeat',
MirrorRepeat: 'mirror-repeat'
};

export const GPUFilterMode = {
Linear: 'linear',
Nearest: 'nearest'
};

0 comments on commit 6e19f98

Please sign in to comment.