poppygl 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +13 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ interface RenderOptions {
|
|
|
21
21
|
lightDir: readonly [number, number, number];
|
|
22
22
|
camPos?: readonly [number, number, number] | null;
|
|
23
23
|
lookAt?: readonly [number, number, number] | null;
|
|
24
|
+
backgroundColor?: readonly [number, number, number] | null;
|
|
24
25
|
}
|
|
25
26
|
type RenderOptionsInput = Partial<RenderOptions>;
|
|
26
27
|
declare const DEFAULT_RENDER_OPTIONS: RenderOptions;
|
package/dist/index.js
CHANGED
|
@@ -94,7 +94,8 @@ var DEFAULT_RENDER_OPTIONS = {
|
|
|
94
94
|
ambient: 0.15,
|
|
95
95
|
lightDir: DEFAULT_LIGHT_DIR,
|
|
96
96
|
camPos: null,
|
|
97
|
-
lookAt: null
|
|
97
|
+
lookAt: null,
|
|
98
|
+
backgroundColor: null
|
|
98
99
|
};
|
|
99
100
|
function getDefaultRenderOptions() {
|
|
100
101
|
return { ...DEFAULT_RENDER_OPTIONS };
|
|
@@ -194,7 +195,6 @@ var SoftwareRenderer = class {
|
|
|
194
195
|
this.height = height;
|
|
195
196
|
this.bitmap = imageFactory(width, height);
|
|
196
197
|
this.depth = new Float32Array(width * height);
|
|
197
|
-
this.clear([0, 0, 0, 255]);
|
|
198
198
|
}
|
|
199
199
|
get buffer() {
|
|
200
200
|
return this.bitmap.data;
|
|
@@ -457,6 +457,17 @@ function renderDrawCalls(drawCalls, optionsInput = {}, imageFactory = createUint
|
|
|
457
457
|
options.height,
|
|
458
458
|
imageFactory
|
|
459
459
|
);
|
|
460
|
+
if (options.backgroundColor) {
|
|
461
|
+
const [r, g, b] = options.backgroundColor;
|
|
462
|
+
renderer.clear([
|
|
463
|
+
Math.round(r * 255),
|
|
464
|
+
Math.round(g * 255),
|
|
465
|
+
Math.round(b * 255),
|
|
466
|
+
255
|
|
467
|
+
]);
|
|
468
|
+
} else {
|
|
469
|
+
renderer.clear([0, 0, 0, 0]);
|
|
470
|
+
}
|
|
460
471
|
for (const dc of drawCalls) {
|
|
461
472
|
renderer.drawMesh(
|
|
462
473
|
dc,
|