Skip to content

Commit

Permalink
Update metadata and props handling for Lightmaps.
Browse files Browse the repository at this point in the history
  • Loading branch information
digisomni committed Feb 11, 2024
1 parent dde0d3d commit 70b4d0f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/modules/scene/LightmapManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class LightmapManager {

Texture.WhenAllReady([materialToUse.albedoTexture], () => {
(mesh.material as PBRMaterial).lightmapTexture = materialToUse.albedoTexture;
(mesh.material as PBRMaterial).useLightmapAsShadowmap = true;
(mesh.material as PBRMaterial).useLightmapAsShadowmap = metadata.vircadia_lightmap_use_as_shadowmap ?? true;

if ((mesh.material as PBRMaterial).lightmapTexture && metadata.vircadia_lightmap_texcoord) {
(mesh.material as PBRMaterial).lightmapTexture!.coordinatesIndex = metadata.vircadia_lightmap_texcoord;
Expand Down
33 changes: 23 additions & 10 deletions types/vircadia_gameUse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,28 @@ export namespace glTF {
vircadia_lod_hide: number | null;
vircadia_billboard_mode: string | null;
// Lightmap
vircadia_lightmap_default: string | null;
vircadia_lightmap: string | null;
vircadia_lightmap_texcoord: number | null;
vircadia_lightmap_use_as_shadowmap: boolean | null;
// Lightmap -> Lights
vircadia_lightmap_mode: Lightmap.Modes | null;
}

export class Metadata implements MetadataInterface {
[key: string]: LOD.Modes | boolean | number | string | null;
[key: string]: LOD.Modes | Lightmap.Modes | boolean | number | string | null;

public vircadia_lod_mode: LOD.Modes | null = null;
public vircadia_lod_auto: boolean | null = null;
public vircadia_lod_distance: number | null = null;
public vircadia_lod_size: number | null = null;
public vircadia_lod_hide: number | null = null;
public vircadia_billboard_mode: string | null = null;
public vircadia_lightmap_default: string | null = null;
public vircadia_lightmap_texcoord: number | null = null;
public vircadia_lod_mode = null;
public vircadia_lod_auto = null;
public vircadia_lod_distance = null;
public vircadia_lod_size = null;
public vircadia_lod_hide = null;
public vircadia_billboard_mode = null;
// Lightmap
public vircadia_lightmap = null;
public vircadia_lightmap_texcoord = null;
public vircadia_lightmap_use_as_shadowmap = null;
// Lightmap -> Lights
public vircadia_lightmap_mode = null;

constructor(metadata?: Partial<NonNullable<MetadataInterface>>) {
if (metadata) {
Expand Down Expand Up @@ -55,5 +62,11 @@ export namespace glTF {

export namespace Lightmap {
export const DATA_MESH_NAME = "vircadia_lightmapData";

export enum Modes {
DEFAULT = "default",
SHADOWSONLY = "shadowsOnly",
SPECULAR = "specular",
}
}
}

0 comments on commit 70b4d0f

Please sign in to comment.