import { useEffect } from 'react'
import MaterialInstances from './instances/materialInstances'
import { usePlayButtonStore, useResetButtonStore } from '../../../store/usePlayButtonStore';
// import MaterialCollisionDetector from './collisionDetection/materialCollitionDetector';
import { useSceneContext } from '../../scene/sceneContext';

function Materials() {
    const { materialStore } = useSceneContext();
    const { clearMaterials } = materialStore();
    const { isPlaying } = usePlayButtonStore();
    const { isReset } = useResetButtonStore();

    useEffect(() => {
        if (isReset || !isPlaying) {
            clearMaterials();
        }
    }, [isReset, isPlaying]);

    return (
        <>

            {isPlaying &&

                <MaterialInstances />

            }

            {/* <MaterialCollisionDetector /> */}

        </>
    )
}

export default Materials