From 264ba4ddd797ae19630a098f1250ee81ad8a10db Mon Sep 17 00:00:00 2001 From: arorad1 Date: Mon, 15 Jul 2024 15:11:45 -0700 Subject: [PATCH 1/4] Added transparent materials support --- fission/src/mirabuf/MirabufInstance.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fission/src/mirabuf/MirabufInstance.ts b/fission/src/mirabuf/MirabufInstance.ts index 390c6f3ef6..2cf818e640 100644 --- a/fission/src/mirabuf/MirabufInstance.ts +++ b/fission/src/mirabuf/MirabufInstance.ts @@ -9,6 +9,7 @@ export enum MaterialStyle { Regular = 0, Normals = 1, Toon = 2, + Transparent = 3, } export const matToString = (mat: THREE.Matrix4) => { @@ -131,6 +132,10 @@ class MirabufInstance { } 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!) From 570f40f003c5cf65079b1e06d19af9d2fa146fee Mon Sep 17 00:00:00 2001 From: arorad1 Date: Mon, 15 Jul 2024 15:30:20 -0700 Subject: [PATCH 2/4] Implemented transparency into the loadmaterials --- fission/src/mirabuf/MirabufInstance.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/fission/src/mirabuf/MirabufInstance.ts b/fission/src/mirabuf/MirabufInstance.ts index 2cf818e640..6c20162ac0 100644 --- a/fission/src/mirabuf/MirabufInstance.ts +++ b/fission/src/mirabuf/MirabufInstance.ts @@ -116,9 +116,14 @@ 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 @@ -126,16 +131,14 @@ class MirabufInstance { 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!) From 671f5191cf4f61bec918a4de456ab9c32a0e4714 Mon Sep 17 00:00:00 2001 From: arorad1 Date: Mon, 15 Jul 2024 15:31:12 -0700 Subject: [PATCH 3/4] Removed unused enum value --- fission/src/mirabuf/MirabufInstance.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/fission/src/mirabuf/MirabufInstance.ts b/fission/src/mirabuf/MirabufInstance.ts index 6c20162ac0..175efb6564 100644 --- a/fission/src/mirabuf/MirabufInstance.ts +++ b/fission/src/mirabuf/MirabufInstance.ts @@ -9,7 +9,6 @@ export enum MaterialStyle { Regular = 0, Normals = 1, Toon = 2, - Transparent = 3, } export const matToString = (mat: THREE.Matrix4) => { From 09377a632a80913b1ea19cff56a2c1d11e4b034c Mon Sep 17 00:00:00 2001 From: arorad1 Date: Mon, 15 Jul 2024 15:33:30 -0700 Subject: [PATCH 4/4] Removed console log --- fission/src/mirabuf/MirabufInstance.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/fission/src/mirabuf/MirabufInstance.ts b/fission/src/mirabuf/MirabufInstance.ts index 175efb6564..68402d4efb 100644 --- a/fission/src/mirabuf/MirabufInstance.ts +++ b/fission/src/mirabuf/MirabufInstance.ts @@ -118,7 +118,6 @@ class MirabufInstance { let opacity = 1.0 if (appearance.albedo) { const { A, B, G, R } = appearance.albedo - console.log(A) if (A && B && G && R) { hex = (A << 24) | (R << 16) | (G << 8) | B opacity = A / 255.0