Skip to content

Commit 0ef3cbf

Browse files
committed
fix(vtkWebGPUBackground): background is RGB
1 parent a829738 commit 0ef3cbf

2 files changed

Lines changed: 27 additions & 24 deletions

File tree

Sources/Rendering/Core/Viewport/index.d.ts

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,28 @@ export interface vtkViewport extends vtkObject {
3838
getActors2D(): vtkActor2D[];
3939

4040
/**
41-
*
41+
* Get the viewport background.
42+
* @returns {RGBColor}
4243
*/
43-
getBackground2(): number[];
44+
getBackground2(): RGBColor;
4445

4546
/**
46-
*
47+
* Get the viewport background.
48+
* @returns {RGBColor}
4749
*/
48-
getBackground2ByReference(): number[];
50+
getBackground2ByReference(): RGBColor;
4951

5052
/**
51-
*
53+
* Get the viewport background.
54+
* @returns {RGBColor}
5255
*/
53-
getBackground(): number[];
56+
getBackground(): RGBColor;
5457

5558
/**
56-
*
59+
* Get the viewport background.
60+
* @returns {RGBColor}
5761
*/
58-
getBackgroundByReference(): number[];
62+
getBackgroundByReference(): RGBColor;
5963

6064
/**
6165
* Get the gradient background flag.
@@ -64,7 +68,7 @@ export interface vtkViewport extends vtkObject {
6468
getGradientBackground(): boolean;
6569

6670
/**
67-
*
71+
* Get the size and origin of the viewport in display coordinates.
6872
*/
6973
getSize(): Size;
7074

@@ -158,30 +162,30 @@ export interface vtkViewport extends vtkObject {
158162
setBackground(background: number[]): boolean;
159163

160164
/**
161-
*
165+
* Set the viewport secondary background.
162166
* @param {Number} r Defines the red component (between 0 and 1).
163167
* @param {Number} g Defines the green component (between 0 and 1).
164168
* @param {Number} b Defines the blue component (between 0 and 1).
165169
*/
166170
setBackground2(r: number, g: number, b: number): boolean;
167171

168172
/**
169-
*
170-
* @param {Number[]} background
173+
* Set the viewport secondary background.
174+
* @param {RGBColor} background
171175
*/
172-
setBackground2(background: number[]): boolean;
176+
setBackground2(background: RGBColor): boolean;
173177

174178
/**
175-
*
176-
* @param {Number[]} background
179+
* Set the viewport secondary background.
180+
* @param {RGBColor} background
177181
*/
178-
setBackground2From(background: number[]): boolean;
182+
setBackground2From(background: RGBColor): boolean;
179183

180184
/**
181-
*
182-
* @param {Number[]} background
185+
* Set the viewport background.
186+
* @param {RGBColor} background
183187
*/
184-
setBackgroundFrom(background: number[]): boolean;
188+
setBackgroundFrom(background: RGBColor): boolean;
185189

186190
/**
187191
* Set the gradient background flag.

Sources/Rendering/WebGPU/Background/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,9 @@ function vtkWebGPUBackground(publicAPI, model) {
159159
}
160160

161161
const isGradientBackground = renderer.getGradientBackground?.();
162-
const background = renderer.getBackgroundByReference?.() ?? [0, 0, 0, 1];
162+
const background = renderer.getBackgroundByReference?.() ?? [0, 0, 0];
163163
const background2 = renderer.getBackground2ByReference?.() ?? [0, 0, 0];
164-
const background2rgba = [...background2, 1.0];
165-
if (isGradientBackground && !areEquals(background, background2rgba)) {
164+
if (isGradientBackground && !areEquals(background, background2)) {
166165
return {
167166
mode: 'gradient',
168167
texture: null,
@@ -243,9 +242,9 @@ function vtkWebGPUBackground(publicAPI, model) {
243242
};
244243

245244
publicAPI.updateUBO = (device, rendererNode, renderer) => {
246-
const background = renderer.getBackgroundByReference?.() ?? [0, 0, 0, 1];
245+
const background = renderer.getBackgroundByReference?.() ?? [0, 0, 0];
247246
const background2 = renderer.getBackground2ByReference?.() ?? [0, 0, 0];
248-
model.UBO.setArray('BackgroundColor', background);
247+
model.UBO.setArray('BackgroundColor', [background[0], background[1], background[2], 1.0]);
249248
model.UBO.setArray('BackgroundColor2', [...background2, 1.0]);
250249

251250
const keyMats = model.webgpuCamera.getKeyMatrices(rendererNode);

0 commit comments

Comments
 (0)