poppygl 0.0.32 → 0.0.33

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 CHANGED
@@ -15,6 +15,9 @@ interface Material {
15
15
  baseColorTexture: BitmapLike | null;
16
16
  metallicFactor?: number;
17
17
  roughnessFactor?: number;
18
+ emissiveFactor?: [number, number, number];
19
+ emissiveTexture?: BitmapLike | null;
20
+ emissiveStrength?: number;
18
21
  alphaMode?: "OPAQUE" | "MASK" | "BLEND";
19
22
  alphaCutoff?: number;
20
23
  }
package/dist/index.js CHANGED
@@ -1038,6 +1038,23 @@ var SoftwareRenderer = class {
1038
1038
  di
1039
1039
  );
1040
1040
  }
1041
+ const emission = material.emissiveFactor ?? [0, 0, 0];
1042
+ const strength = material.emissiveStrength ?? 1;
1043
+ let er = emission[0], eg = emission[1], eb = emission[2];
1044
+ if (uv && material.emissiveTexture) {
1045
+ const uvp = this.perspInterp(uv, invW, [l0, l1, l2]);
1046
+ const texel = this.sampleTextureNearest(
1047
+ material.emissiveTexture,
1048
+ uvp[0],
1049
+ uvp[1]
1050
+ );
1051
+ er *= srgbDecodeToLinear01(texel[0]);
1052
+ eg *= srgbDecodeToLinear01(texel[1]);
1053
+ eb *= srgbDecodeToLinear01(texel[2]);
1054
+ }
1055
+ r += er * strength;
1056
+ g += eg * strength;
1057
+ b += eb * strength;
1041
1058
  let a = baseColor[3];
1042
1059
  const linearR = r, linearG = g, linearB = b;
1043
1060
  const alphaMode = material.alphaMode ?? "OPAQUE";
@@ -2519,6 +2536,9 @@ function getMaterial(gltf, textures, images, materialIndex) {
2519
2536
  baseColorTexture: texImg,
2520
2537
  metallicFactor: pbr.metallicFactor ?? 1,
2521
2538
  roughnessFactor: pbr.roughnessFactor ?? 1,
2539
+ emissiveFactor: material.emissiveFactor ?? [0, 0, 0],
2540
+ emissiveTexture: images[textures[material.emissiveTexture?.index]?.source] ?? null,
2541
+ emissiveStrength: material.extensions?.KHR_materials_emissive_strength?.emissiveStrength ?? 1,
2522
2542
  alphaMode,
2523
2543
  alphaCutoff
2524
2544
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "poppygl",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.32",
4
+ "version": "0.0.33",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/tscircuit/poppygl.git"