%PDF- %PDF-
| Direktori : /home2/rezakur1/devita.rezakurnia.com/X9KQ7MW2RT8PY4ND6LV3JH5CG8BF2ZM7QW4/scene12/ |
| Current File : //home2/rezakur1/devita.rezakurnia.com/X9KQ7MW2RT8PY4ND6LV3JH5CG8BF2ZM7QW4/scene12/scene12.js |
/* ===================================
HEADER COMPONENT
=================================== */
fetch('../components/header.html')
.then(response => response.text())
.then(data => {
document.getElementById(
'header-container'
).innerHTML = data;
});
/* ===================================
REVEAL ANIMATION
=================================== */
const reveals =
document.querySelectorAll('.reveal');
function revealElements(){
reveals.forEach(item=>{
const top =
item.getBoundingClientRect().top;
const trigger =
window.innerHeight - 100;
if(top < trigger){
item.classList.add('show');
}
});
}
window.addEventListener(
'scroll',
revealElements
);
revealElements();
/* ===================================
DATA ANION
=================================== */
const anionData = {
cl:{
name:"Klorida",
formula:"Cl⁻",
charge:"-1",
type:"Halida",
property:"Sangat Hidrofilik",
example:"[Emim]Cl",
application:"Pelarut biomassa dan nanoselulosa.",
description:"Anion kecil dengan densitas muatan tinggi sehingga mudah berinteraksi dengan air."
},
br:{
name:"Bromida",
formula:"Br⁻",
charge:"-1",
type:"Halida",
property:"Hidrofilik",
example:"[Bmim]Br",
application:"Sintesis organik dan elektrolit.",
description:"Memiliki sifat mirip klorida namun lebih besar ukurannya."
},
i:{
name:"Iodida",
formula:"I⁻",
charge:"-1",
type:"Halida",
property:"Hidrofilik",
example:"[Bmim]I",
application:"Elektrokimia dan DSSC.",
description:"Anion halida terbesar dengan polarizabilitas tinggi."
},
no3:{
name:"Nitrat",
formula:"NO₃⁻",
charge:"-1",
type:"Okso-anion",
property:"Hidrofilik",
example:"[Emim]NO₃",
application:"Media reaksi dan pelarut.",
description:"Mudah berinteraksi dengan molekul polar dan air."
},
so4:{
name:"Sulfat",
formula:"SO₄²⁻",
charge:"-2",
type:"Okso-anion",
property:"Sangat Hidrofilik",
example:"[Bmim]SO₄",
application:"Katalisis dan ekstraksi.",
description:"Muatan tinggi menyebabkan interaksi kuat dengan air."
},
po4:{
name:"Fosfat",
formula:"PO₄³⁻",
charge:"-3",
type:"Okso-anion",
property:"Sangat Hidrofilik",
example:"[Emim]PO₄",
application:"Kimia hijau.",
description:"Anion bermuatan tinggi dengan hidrofilisitas tinggi."
},
pf6:{
name:"Hexafluorophosphate",
formula:"PF₆⁻",
charge:"-1",
type:"Fluorinated",
property:"Hidrofobik",
example:"[Bmim]PF₆",
application:"Ekstraksi fase cair organik.",
description:"Anion besar dan terfluorinasi sehingga sangat hidrofobik."
},
bf4:{
name:"Tetrafluoroborate",
formula:"BF₄⁻",
charge:"-1",
type:"Fluorinated",
property:"Hidrofobik Moderat",
example:"[Emim]BF₄",
application:"Elektrolit dan DSSC.",
description:"Lebih hidrofobik dibanding nitrat namun kurang dari PF₆⁻."
},
ntf2:{
name:"Bis(trifluoromethanesulfonyl)imide",
formula:"[NTF₂]⁻",
charge:"-1",
type:"Fluorinated",
property:"Sangat Hidrofobik",
example:"[Emim][NTF₂]",
application:"Baterai, DSSC dan pelumas.",
description:"Sangat stabil dan hidrofobik karena gugus fluorinasi besar."
},
acetate:{
name:"Asetat",
formula:"CH₃COO⁻",
charge:"-1",
type:"Bio-based",
property:"Hidrofilik",
example:"[Emim][Ac]",
application:"Pelarut selulosa.",
description:"Anion organik sederhana yang mudah berinteraksi dengan air."
},
lactate:{
name:"Laktat",
formula:"Laktat⁻",
charge:"-1",
type:"Bio-based",
property:"Hidrofilik",
example:"[Choline][Lactate]",
application:"Green solvent.",
description:"Berasal dari biomassa dan relatif ramah lingkungan."
},
succinate:{
name:"Suksinat",
formula:"Suksinat²⁻",
charge:"-2",
type:"Bio-based",
property:"Hidrofilik",
example:"[Choline][Succinate]",
application:"Green chemistry.",
description:"Anion berbasis biomassa dengan kelarutan tinggi."
}
};
const anionMedia = {
cl:{
type:"image",
src:"../assets/scene12/Cl-.png",
title:"Model 3D contoh [Emim]Cl",
loading:"Memuat struktur [Emim]Cl...",
error:"Struktur 3D [Emim]Cl gagal dimuat."
},
bf4:{
type:"fbx",
src:"../assets/scene12/tetrafloroborat (BF4).fbx",
title:"Model 3D contoh cairan ionik BF₄⁻",
loading:"Memuat struktur cairan ionik BF₄⁻...",
error:"Struktur 3D BF₄⁻ gagal dimuat."
},
br:{
type:"image",
src:"../assets/scene12/Br-.png",
title:"Ilustrasi aplikasi bromida sebagai elektrolit",
alt:"Ilustrasi baterai dan elektrolit"
},
i:{
type:"image",
src:"../assets/scene12/I-.png",
title:"Ilustrasi aplikasi iodida pada DSSC",
alt:"Ilustrasi DSSC"
},
pf6:{
type:"fbx",
src:"../assets/scene12/PF6-.fbx",
title:"Ilustrasi aplikasi [Bmim][PF₆]",
alt:"Ilustrasi ekstraksi cairan ionik hidrofobik"
},
ntf2:{
type:"image",
src:"../assets/scene12/MolView (model) (15).png",
title:"Ilustrasi aplikasi [NTF₂]⁻",
alt:"Ilustrasi pelumas industri untuk cairan ionik hidrofobik"
},
no3:{
type:"fbx",
src:"../assets/scene12/Nitrat.fbx",
title:"Ilustrasi aplikasi elektrokimia",
alt:"Ilustrasi aplikasi DSSC dan elektrokimia"
},
so4:{
type:"fbx",
src:"../assets/scene19/anions/sulfate.fbx",
title:"Ilustrasi cairan ionik stabil berbasis okso-anion",
alt:"Ilustrasi air stable ionic liquids"
},
po4:{
type:"fbx",
src:"../assets/scene19/anions/phosphate.fbx",
title:"Ilustrasi aplikasi fosfat pada sistem elektrolit",
alt:"Ilustrasi molten salt untuk baterai"
},
acetate:{
type:"image",
src:"../assets/scene12/Acetate Ion (1).png",
title:"Ilustrasi pelarut hijau berbasis asetat",
alt:"Ilustrasi green solvent"
},
lactate:{
type:"image",
src:"../assets/scene12/2-hydroxypropanoate.png",
title:"Ilustrasi green chemistry berbasis laktat",
alt:"Ilustrasi aplikasi energi dan material"
},
succinate:{
type:"image",
src:"../assets/scene12/butanedioate.png",
title:"Ilustrasi eksplorasi anion bio-based",
alt:"Ilustrasi eksplorasi cairan ionik"
}
};
let fbxViewerModule;
let activeMediaToken = 0;
let activeModalToken = 0;
const anionModalFbx = {
cl:{
src:"../assets/scene12/table/1-Ethyl-3-methylimidazolium Chloride (1).fbx",
title:"Model 3D Cl⁻",
subtitle:"Contoh struktur [Emim]Cl dengan anion klorida.",
loading:"Memuat model 3D Cl⁻...",
error:"Model 3D Cl⁻ gagal dimuat."
},
br:{
src:"../assets/scene12/table/1-butyl-3-methylimidazolium bromide.fbx",
title:"Model 3D Br⁻",
subtitle:"Representasi 3D cairan ionik halida untuk pembanding bromida.",
loading:"Memuat model 3D Br⁻...",
error:"Model 3D Br⁻ gagal dimuat."
},
no3:{
src:"../assets/scene12/table/1-ethyl-3-methylimidazolium nitrate.fbx",
title:"Model 3D NO₃⁻",
subtitle:"Struktur 3D anion nitrat.",
loading:"Memuat model 3D NO₃⁻...",
error:"Model 3D NO₃⁻ gagal dimuat."
},
bf4:{
src:"../assets/scene12/table/1-Ethyl-3-methylimidazolium tetrafluoroboratefbx.fbx",
title:"Model 3D BF₄⁻",
subtitle:"Contoh model cairan ionik tetrafluoroborate.",
loading:"Memuat model 3D BF₄⁻...",
error:"Model 3D BF₄⁻ gagal dimuat."
},
pf6:{
src:"../assets/scene12/1-butyl-3-methylimidazolium hexafluorophosphate.fbx",
title:"Model 3D PF₆⁻",
subtitle:"Struktur 3D anion hexafluorophosphate.",
loading:"Memuat model 3D PF₆⁻...",
error:"Model 3D PF₆⁻ gagal dimuat."
},
ntf2:{
src:"../assets/scene12/1-ethyl-3-methylimidazolium bis(trifluoromethylsulfonyl)imide.fbx",
title:"Model 3D [NTF₂]⁻",
subtitle:"Representasi 3D untuk contoh cairan ionik hidrofobik.",
loading:"Memuat model 3D [NTF₂]⁻...",
error:"Model 3D [NTF₂]⁻ gagal dimuat."
}
};
/* ===================================
ANION CARD CLICK
=================================== */
const anionCards =
document.querySelectorAll(
'.anion-card'
);
const viewer =
document.getElementById(
'anionViewer'
);
const detail =
document.getElementById(
'anionDetail'
);
anionCards.forEach(card=>{
card.addEventListener(
'click',
()=>{
anionCards.forEach(c=>{
c.classList.remove(
'active'
);
});
card.classList.add(
'active'
);
const id =
card.dataset.anion;
showAnion(id);
localStorage.setItem(
'selectedAnion',
id
);
}
);
});
function showAnion(id){
const a =
anionData[id];
renderAnionMedia(id, a);
detail.innerHTML = `
<h3>
${a.name}
</h3>
<br>
<p>
<strong>Formula:</strong>
${a.formula}
</p>
<p>
<strong>Muatan:</strong>
${a.charge}
</p>
<p>
<strong>Klasifikasi:</strong>
${a.type}
</p>
<p>
<strong>Sifat:</strong>
${a.property}
</p>
<p>
<strong>Contoh IL:</strong>
${a.example}
</p>
<p>
<strong>Aplikasi:</strong>
${a.application}
</p>
<br>
<p>
${a.description}
</p>
`;
}
function renderAnionMedia(id, anion){
activeMediaToken += 1;
const mediaToken =
activeMediaToken;
const media =
anionMedia[id];
if(!media){
viewer.innerHTML = `
<div class="anion-symbol-view">
<h2>
${anion.formula}
</h2>
<span>
Belum tersedia model 3D atau gambar.
</span>
</div>
`;
return;
}
if(media.type === "image"){
viewer.innerHTML = `
<figure class="anion-image-view">
<img
src="${media.src}"
alt="${media.alt}">
</figure>
`;
return;
}
viewer.innerHTML = `
<div
class="anion-model"
data-fbx="${media.src}"
data-rotate="true"
data-grid="false"
data-loading="${media.loading}"
data-error="${media.error}"
aria-label="${media.title}">
</div>
`;
const modelContainer =
viewer.querySelector(
'.anion-model'
);
loadFbxViewer()
.then(FBXViewer=>{
if(mediaToken !== activeMediaToken){
return;
}
new FBXViewer({
container:modelContainer,
model:media.src,
autoRotate:true,
showGrid:false,
loadingText:media.loading,
errorText:media.error
});
})
.catch(error=>{
console.error(
"FBX detail anion gagal dimuat:",
error
);
if(mediaToken !== activeMediaToken){
return;
}
viewer.innerHTML = `
<div class="anion-symbol-view">
<h2>
${anion.formula}
</h2>
<span>
Model 3D gagal dimuat.
</span>
</div>
`;
});
}
function loadFbxViewer(){
if(!fbxViewerModule){
fbxViewerModule =
import('../components/fbx/FBXViewer.js')
.then(module=>module.default);
}
return fbxViewerModule;
}
/* ===================================
TABLE 3D MODAL
=================================== */
const table3dButtons =
document.querySelectorAll(
'.table-3d-btn'
);
const anion3dModal =
document.getElementById(
'anion3dModal'
);
const anion3dTitle =
document.getElementById(
'anion3dTitle'
);
const anion3dSubtitle =
document.getElementById(
'anion3dSubtitle'
);
const anion3dViewer =
document.getElementById(
'anion3dViewer'
);
const modalCloseButton =
document.querySelector(
'.modal-close-btn'
);
table3dButtons.forEach(button=>{
button.addEventListener(
'click',
()=>{
openAnion3dModal(
button.dataset.tableAnion
);
}
);
});
modalCloseButton?.addEventListener(
'click',
closeAnion3dModal
);
anion3dModal?.addEventListener(
'click',
event=>{
if(event.target === anion3dModal){
closeAnion3dModal();
}
}
);
window.addEventListener(
'keydown',
event=>{
if(
event.key === 'Escape' &&
anion3dModal?.classList.contains('show')
){
closeAnion3dModal();
}
}
);
function openAnion3dModal(id){
const fbx =
anionModalFbx[id];
const anion =
anionData[id];
if(!fbx || !anion){
return;
}
activeModalToken += 1;
const modalToken =
activeModalToken;
anion3dTitle.textContent =
fbx.title;
anion3dSubtitle.textContent =
fbx.subtitle;
anion3dViewer.innerHTML = `
<div
class="anion-modal-model"
data-fbx="${fbx.src}"
data-rotate="true"
data-grid="false"
data-loading="${fbx.loading}"
data-error="${fbx.error}"
aria-label="${fbx.title}">
</div>
`;
anion3dModal.classList.add(
'show'
);
anion3dModal.setAttribute(
'aria-hidden',
'false'
);
const modelContainer =
anion3dViewer.querySelector(
'.anion-modal-model'
);
loadFbxViewer()
.then(FBXViewer=>{
if(modalToken !== activeModalToken){
return;
}
new FBXViewer({
container:modelContainer,
model:fbx.src,
autoRotate:true,
showGrid:false,
loadingText:fbx.loading,
errorText:fbx.error
});
})
.catch(error=>{
console.error(
"FBX modal anion gagal dimuat:",
error
);
if(modalToken !== activeModalToken){
return;
}
anion3dViewer.innerHTML = `
<div class="anion-symbol-view">
<h2>
${anion.formula}
</h2>
<span>
Model 3D gagal dimuat.
</span>
</div>
`;
});
}
function closeAnion3dModal(){
activeModalToken += 1;
anion3dModal?.classList.remove(
'show'
);
anion3dModal?.setAttribute(
'aria-hidden',
'true'
);
if(anion3dViewer){
anion3dViewer.innerHTML =
'Pilih anion dari tabel.';
}
}
/* ===================================
FILTER BUTTON
=================================== */
const filterButtons =
document.querySelectorAll(
'.filter-btn'
);
filterButtons.forEach(btn=>{
btn.addEventListener(
'click',
()=>{
filterButtons.forEach(b=>{
b.classList.remove(
'active'
);
});
btn.classList.add(
'active'
);
const filter =
btn.dataset.filter;
filterAnions(filter);
}
);
});
function filterAnions(filter){
anionCards.forEach(card=>{
if(filter === 'all'){
card.style.display =
'block';
return;
}
if(
card.classList.contains(
filter
)
){
card.style.display =
'block';
}else{
card.style.display =
'none';
}
});
}
/* ===================================
HYDROPHILICITY SCALE
=================================== */
const scalePoints =
document.querySelectorAll(
'.scale-point'
);
const scaleInfo =
document.getElementById(
'scaleInfo'
);
scalePoints.forEach(point=>{
point.addEventListener(
'click',
()=>{
const id =
point.dataset.anion;
const a =
anionData[id];
anionCards.forEach(card=>{
card.classList.toggle(
'active',
card.dataset.anion === id
);
});
scaleInfo.innerHTML = `
<h3>
${a.formula}
</h3>
<br>
<p>
<strong>${a.name}</strong>
termasuk anion
<strong>${a.property}</strong>.
</p>
<p>
${a.description}
</p>
`;
showAnion(id);
}
);
});
/* ===================================
RESTORE LAST SELECTED
=================================== */
// window.addEventListener(
// 'load',
// ()=>{
// const saved =
// localStorage.getItem(
// 'selectedAnion'
// );
// if(saved && anionData[saved]){
// showAnion(saved);
// document
// .querySelector(
// `[data-anion="${saved}"]`
// )
// ?.classList.add(
// 'active'
// );
// }
// }
// );