%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home2/rezakur1/devita.rezakurnia.com/X9KQ7MW2RT8PY4ND6LV3JH5CG8BF2ZM7QW4/scene7/
Upload File :
Create Path :
Current File : //home2/rezakur1/devita.rezakurnia.com/X9KQ7MW2RT8PY4ND6LV3JH5CG8BF2ZM7QW4/scene7/scene7.js

/* ===========================
HEADER COMPONENT
=========================== */

fetch('../components/header.html')
.then(response => response.text())
.then(data => {

    document.getElementById(
        'header-container'
    ).innerHTML = data;

});


/* ===========================
REVEAL ON SCROLL
=========================== */

const reveals =
document.querySelectorAll(
    '.reveal'
);

function revealOnScroll(){

    reveals.forEach(item=>{

        const top =
        item.getBoundingClientRect()
        .top;

        const trigger =
        window.innerHeight - 120;

        if(top < trigger){

            item.classList.add(
                'show'
            );
        }

    });

}

window.addEventListener(
    'scroll',
    revealOnScroll
);

revealOnScroll();

/* ===========================
VERIFIKASI DISKUSI
=========================== */

const verifyBtn =
document.getElementById(
    'verifyBtn'
);

if (verifyBtn) {

    verifyBtn.addEventListener(
        'click',
        async () => {

            const answer =
            document.getElementById(
                'discussionAnswer'
            ).value.trim();

            if (!answer) {

                alert(
                    'Silakan isi jawaban terlebih dahulu.'
                );

                return;
            }

            try {

                await ParticipantAnswerService.save({
                    sceneNumber: 7,
                    questionKey: 'discussion_answer',
                    questionTitle: 'Berdasarkan data pada tabel dan wacana di atas, keunikan karakteristik kedua senyawa ionik tersebut menjadi hal yang menarik untuk diselidiki oleh para ilmuwan. Menurut Anda, jika Anda berperan sebagai seorang saintis, konsep kimia apa yang akan Anda gunakan untuk menyelidiki karakteristik kedua senyawa ionik tersebut secara sistematis?',
                    answer: answer,
                });

                const box =
                document.getElementById(
                    'verificationResult'
                );

                box.style.display =
                    'block';

                box.innerHTML = `
                    <strong>Verifikasi Jawaban</strong>
                    <br><br>

                    Konsep yang dapat digunakan antara lain:

                    <ul style="margin-top:10px;padding-left:20px;line-height:1.8;">
                        <li>Gaya Coulomb</li>
                        <li>Energi Kisi</li>
                        <li>Ukuran dan Bentuk Ion</li>
                        <li>Simetri Struktur Ion</li>
                        <li>Interaksi Antarmolekul</li>
                        <li>Hubungan Struktur dan Sifat</li>
                    </ul>

                    <br>

                    Jawaban Anda berhasil disimpan dan akan dibandingkan pada akhir pembelajaran.
                `;

                box.scrollIntoView({
                    behavior: 'smooth'
                });

            } catch (error) {

                console.error(error);

                alert(
                    'Gagal menyimpan jawaban.'
                );
            }

        }
    );
}


/* ===========================
ANIMASI NaCl
=========================== */
function createNaClAnimation() {

    const container =
    document.getElementById(
        'nacl-animation'
    );

    if (!container) return;

    container.innerHTML = '';

    const positions = [

        [60,40],
        [140,40],
        [220,40],

        [100,100],
        [180,100],

        [60,160],
        [140,160],
        [220,160]

    ];

    positions.forEach((pos,index)=>{

        const isNa =
        index % 2 === 0;

        const ion =
        document.createElement(
            'div'
        );

        ion.className =
            isNa
            ? 'ion na'
            : 'ion cl';

        ion.innerText =
            isNa
            ? 'Na⁺'
            : 'Cl⁻';

        ion.style.left =
            pos[0] + 'px';

        ion.style.top =
            pos[1] + 'px';

        ion.animate(
            [
                {
                    transform:
                    'translateY(0px)'
                },
                {
                    transform:
                    'translateY(-6px)'
                },
                {
                    transform:
                    'translateY(0px)'
                }
            ],
            {
                duration:
                1000 + Math.random() * 800,

                iterations:
                Infinity
            }
        );

        container.appendChild(
            ion
        );

    });

}

createNaClAnimation();


/* ===========================
ANIMASI IONIC LIQUID
=========================== */

function createIonicAnimation(){

    const container =
    document.getElementById(
        'ionic-animation'
    );

    if(!container) return;

    const ions = [

        {
            text:'Emim+',
            x:40,
            y:50,
            cls:'emim'
        },

        {
            text:'Cl-',
            x:220,
            y:40,
            cls:'anion'
        },

        {
            text:'Emim+',
            x:160,
            y:120,
            cls:'emim'
        },

        {
            text:'Cl-',
            x:80,
            y:180,
            cls:'anion'
        },

        {
            text:'Emim+',
            x:260,
            y:180,
            cls:'emim'
        }

    ];

    ions.forEach(data=>{

        const ion =
        document.createElement(
            'div'
        );

        ion.className =
        'ion ' + data.cls;

        ion.innerText =
        data.text;

        ion.style.left =
            data.x + 'px';

        ion.style.top =
            data.y + 'px';

        ion.animate([
            {
                transform:
                'translate(0px,0px)'
            },
            {
                transform:
                'translate(8px,-10px)'
            },
            {
                transform:
                'translate(-8px,6px)'
            },
            {
                transform:
                'translate(0px,0px)'
            }
        ],{
            duration:
            3500 + Math.random()*2000,
            iterations:
            Infinity
        });

        container.appendChild(
            ion
        );

    });

}

createIonicAnimation();


/* ===========================
THREE JS - NaCl
=========================== */

function createNaClViewer(){

    const container =
    document.getElementById(
        'naclViewer'
    );

    if(!container) return;

    const scene =
    new THREE.Scene();

    const camera =
    new THREE.PerspectiveCamera(
        60,
        container.clientWidth /
        container.clientHeight,
        0.1,
        1000
    );

    const renderer =
    new THREE.WebGLRenderer({
        antialias:true,
        alpha:true
    });

    renderer.setSize(
        container.clientWidth,
        container.clientHeight
    );

    container.innerHTML = '';
    container.appendChild(
        renderer.domElement
    );

    const group =
    new THREE.Group();

    const geometry =
    new THREE.SphereGeometry(
        0.5,
        32,
        32
    );

    const material1 =
    new THREE.MeshBasicMaterial({
        color:0xffd54f
    });

    const material2 =
    new THREE.MeshBasicMaterial({
        color:0xffffff
    });

    for(let x=-1;x<=1;x++){

        for(let y=-1;y<=1;y++){

            const sphere =
            new THREE.Mesh(
                geometry,
                (x+y)%2===0
                ? material1
                : material2
            );

            sphere.position.set(
                x,
                y,
                0
            );

            group.add(
                sphere
            );

        }

    }

    scene.add(group);

    camera.position.z = 5;

    function animate(){

        requestAnimationFrame(
            animate
        );

        group.rotation.y += 0.01;

        renderer.render(
            scene,
            camera
        );
    }

    animate();

}

createNaClViewer();


/* ===========================
THREE JS - EMIM
=========================== */

function createEmimViewer(){

    const container =
    document.getElementById(
        'emimViewer'
    );

    if(!container) return;

    const scene =
    new THREE.Scene();

    const camera =
    new THREE.PerspectiveCamera(
        60,
        container.clientWidth /
        container.clientHeight,
        0.1,
        1000
    );

    const renderer =
    new THREE.WebGLRenderer({
        antialias:true,
        alpha:true
    });

    renderer.setSize(
        container.clientWidth,
        container.clientHeight
    );

    container.innerHTML = '';
    container.appendChild(
        renderer.domElement
    );

    const group =
    new THREE.Group();

    const geometry =
    new THREE.SphereGeometry(
        0.45,
        32,
        32
    );

    const material =
    new THREE.MeshBasicMaterial({
        color:0x42a5f5
    });

    for(let i=0;i<6;i++){

        const atom =
        new THREE.Mesh(
            geometry,
            material
        );

        atom.position.x =
            Math.cos(i)*1.4;

        atom.position.y =
            Math.sin(i)*1.4;

        group.add(atom);
    }

    scene.add(group);

    camera.position.z = 5;

    function animate(){

        requestAnimationFrame(
            animate
        );

        group.rotation.x += 0.01;
        group.rotation.y += 0.01;

        renderer.render(
            scene,
            camera
        );
    }

    animate();

}

createEmimViewer();


/* ===========================
RESIZE
=========================== */

window.addEventListener(
    'resize',
    ()=>{

        location.reload();

    }
);

Zerion Mini Shell 1.0