-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
166 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// LightmapManager.ts | ||
// | ||
// Created by Kalila on 08 Feb 2024. | ||
// Copyright 2024 Vircadia contributors. | ||
// Copyright 2024 DigiSomni LLC. | ||
// | ||
// Distributed under the Apache License, Version 2.0. | ||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | ||
// | ||
|
||
// WIP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* eslint-disable */ | ||
|
||
const createScene = function () { | ||
const scene = new BABYLON.Scene(engine); | ||
const camera = new BABYLON.ArcRotateCamera( | ||
"camera2", | ||
Math.PI / 2, | ||
Math.PI / 4, | ||
10, | ||
new BABYLON.Vector3.Zero(), | ||
scene | ||
); | ||
camera.attachControl(canvas, true); | ||
const light = new BABYLON.HemisphericLight( | ||
"light2", | ||
new BABYLON.Vector3(0, 1, 0), | ||
scene | ||
); | ||
light.intensity = 0.7; | ||
|
||
BABYLON.SceneLoader.ImportMesh( | ||
"", | ||
"https://digisomni-singapore-1.ap-south-1.linodeobjects.com/falah-tech/virtual-collaboration/Testing/Vircadia/Lightmaps/Test3/", | ||
"LightmapTest_jpg.glb", | ||
scene, | ||
function (newMeshes) { | ||
newMeshes.forEach((mesh) => { | ||
console.info( | ||
"Mesh:", | ||
mesh.name, | ||
"has metadata:", | ||
mesh.metadata | ||
); | ||
|
||
if ( | ||
mesh.metadata && | ||
mesh.metadata.gltf && | ||
mesh.metadata.gltf.extras && | ||
mesh.metadata.gltf.extras.vircadia_lightmap_default | ||
) { | ||
console.info( | ||
"Found lightmap in metadata:", | ||
mesh.metadata.gltf.extras.vircadia_lightmap_default | ||
); | ||
// Attempt to find the embedded lightmap texture by name | ||
const lightmapName = | ||
mesh.metadata.gltf.extras.vircadia_lightmap_default; | ||
|
||
console.info( | ||
"Before checking, here are the lightmaps:", | ||
scene.textures | ||
); | ||
const embeddedLightmap = lightmaps.find( | ||
(texture) => texture.name === lightmapName | ||
); | ||
|
||
console.info( | ||
"Found embedded lightmap texture:", | ||
embeddedLightmap | ||
); | ||
if (embeddedLightmap) { | ||
mesh.material.lightmapTexture = embeddedLightmap; | ||
mesh.material.useLightmapAsShadowmap = true; | ||
mesh.material.lightmapTexture.coordinatesIndex = | ||
mesh.metadata.gltf.extras.vircadia_lightmap_texcoord; | ||
console.info( | ||
"Successfully applied embedded lightmap texture:", | ||
lightmapName | ||
); | ||
} else { | ||
console.error( | ||
"Failed to find embedded lightmap texture for:", | ||
mesh.name, | ||
"with lightmap name:", | ||
lightmapName | ||
); | ||
} | ||
} | ||
// Check if the mesh name matches 'vircadia_lightmapData' and hide it | ||
if (mesh.name === "vircadia_lightmapData") { | ||
mesh.isVisible = false; // This hides the mesh | ||
console.info("Mesh vircadia_lightmapData is now hidden"); | ||
} | ||
}); | ||
} | ||
); | ||
|
||
return scene; | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
export namespace Mesh { | ||
export interface Metadata { | ||
vircadia_lod_mode?: LOD.Modes; | ||
vircadia_lod_auto?: boolean; | ||
vircadia_lod_distance?: number; | ||
vircadia_lod_size?: number; | ||
vircadia_lod_hide?: number; | ||
vircadia_billboard_mode?: string; | ||
// Lightmap | ||
vircadia_lightmap_default?: string, | ||
vircadia_lightmap_texcoord?: number | ||
} | ||
|
||
export namespace LOD { | ||
export enum Modes { | ||
DISTANCE = "distance", | ||
SIZE = "size", | ||
} | ||
|
||
export enum Levels { | ||
LOD0 = "LOD0", | ||
LOD1 = "LOD1", | ||
LOD2 = "LOD2", | ||
LOD3 = "LOD3", | ||
LOD4 = "LOD4", | ||
} | ||
} | ||
|
||
export enum BillboardModes { | ||
BILLBOARDMODE_NONE = 0, | ||
BILLBOARDMODE_X = 1, | ||
BILLBOARDMODE_Y = 2, | ||
BILLBOARDMODE_Z = 4, | ||
BILLBOARDMODE_ALL = 7, | ||
} | ||
|
||
export namespace Lightmap { | ||
export const LightmapDataMesh = "vircadia_lightmapData_"; // + lightmap name | ||
} | ||
} |