From 9613fa7c5ab80d6019532b4b13e00987d96a0701 Mon Sep 17 00:00:00 2001 From: Cody Bennett Date: Sun, 4 Jun 2023 13:59:28 -0500 Subject: [PATCH] BufferAttribute: add gpuType (#469) * BufferAttribute: add gpuType * Shorten line --------- Co-authored-by: Nathan Bierema --- types/three/src/constants.d.ts | 2 ++ types/three/src/core/BufferAttribute.d.ts | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/types/three/src/constants.d.ts b/types/three/src/constants.d.ts index 151b5106c..d7e709a8a 100644 --- a/types/three/src/constants.d.ts +++ b/types/three/src/constants.d.ts @@ -323,6 +323,8 @@ export const UnsignedShort4444Type: 1017; export const UnsignedShort5551Type: 1018; export const UnsignedInt248Type: 1020; +export type AttributeGPUType = typeof FloatType | typeof IntType; + /** * Texture Types. * @remarks Must correspond to the correct {@link PixelFormat | format}. diff --git a/types/three/src/core/BufferAttribute.d.ts b/types/three/src/core/BufferAttribute.d.ts index 9efbd03f2..24e9a4e51 100644 --- a/types/three/src/core/BufferAttribute.d.ts +++ b/types/three/src/core/BufferAttribute.d.ts @@ -1,4 +1,4 @@ -import { Usage } from '../constants'; +import { Usage, AttributeGPUType } from '../constants'; import { Matrix3 } from './../math/Matrix3'; import { Matrix4 } from './../math/Matrix4'; @@ -66,6 +66,14 @@ export class BufferAttribute { */ usage: Usage; + /** + * Configures the bound GPU type for use in shaders. Either {@link FloatType} or {@link IntType}, default is {@link FloatType}. + * + * Note: this only has an effect for integer arrays and is not configurable for float arrays. For lower precision + * float types, see https://threejs.org/docs/#api/en/core/bufferAttributeTypes/BufferAttributeTypes. + */ + gpuType: AttributeGPUType; + /** * This can be used to only update some components of stored vectors (for example, just the component related to color). * @defaultValue `{ offset: number = 0; count: number = -1 }`