Skip to content

Commit

Permalink
Implemented transparency into the loadmaterials
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhruv-0-Arora committed Jul 15, 2024
1 parent 264ba4d commit 570f40f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions fission/src/mirabuf/MirabufInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,26 +116,29 @@ class MirabufInstance {
Object.entries(this._mirabufParser.assembly.data!.materials!.appearances!).forEach(
([appearanceId, appearance]) => {
let hex = 0xe32b50
let opacity = 1.0
if (appearance.albedo) {
const { A, B, G, R } = appearance.albedo
if (A && B && G && R) hex = (A << 24) | (R << 16) | (G << 8) | B
console.log(A)
if (A && B && G && R) {
hex = (A << 24) | (R << 16) | (G << 8) | B
opacity = A / 255.0
}
}

let material: THREE.Material
if (materialStyle == MaterialStyle.Regular) {
material = new THREE.MeshPhongMaterial({
color: hex,
shininess: 0.0,
opacity: opacity,
transparent: opacity < 1.0,
})
} else if (materialStyle == MaterialStyle.Normals) {
material = new THREE.MeshNormalMaterial()
} else if (materialStyle == MaterialStyle.Toon) {
material = World.SceneRenderer.CreateToonMaterial(hex, 5)
console.debug("Toon Material")
} else if (materialStyle == MaterialStyle.Transparent) {
material = new THREE.MeshStandardMaterial({
transparent: true,
})
}

this._materials.set(appearanceId, material!)
Expand Down

0 comments on commit 570f40f

Please sign in to comment.