Quellcode durchsuchen

WebGPUTextures: Added more constants.

Mugen87 vor 4 Jahren
Ursprung
Commit
6e19f98d19

+ 7 - 6
examples/jsm/renderers/webgpu/WebGPUTextures.js

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

+ 11 - 0
examples/jsm/renderers/webgpu/constants.js

@@ -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'
+};