상세 컨텐츠

본문 제목

dat.gui, lil-gui 차이점 (1)

JavaScript

by 폴리프레임 2024. 9. 23. 11:18

본문

반응형
dat.gui와 lil-gui는 둘 다 JavaScript를 사용하여 웹 브라우저에서 인터페이스 컨트롤을 쉽게 추가할 수 있는 라이브러리입니다. 그러나 이 두 라이브러리 간에는 차이점이 있습니다.

 

dat.gui

npm install dat.gui

또는 CDN 이용

<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>

- 상대적으로 더 크고 무거운 라이브러리입니다. 다양한 기능과 옵션을 제공하지만, 크기 면에서는 조금 부담이 될 수 있습니다.

- 더 많은 설정과 기능을 제공하지만, 그만큼 약간 더 복잡할 수 있습니다. 개발자가 다양한 사용자 인터페이스 요소를 쉽게 추가하고, 제어할 수 있는 기능을 많이 갖추고 있습니다.

- 오랜 역사를 가지고 있고, 다양한 프로젝트에서 사용되어 왔지만, 최근에는 유지보수와 업데이트가 비교적 느립니다.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>dat.gui Example</title>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
</head>
<body>
  <script>
    // 설정할 객체
    const params = {
      speed: 0.5,
      color: "#ff0000",
    };

    // dat.gui를 생성하고 GUI 컨트롤 추가
    const gui = new dat.GUI();
    gui.add(params, 'speed', 0, 1); // 0 ~ 1 사이 슬라이더
    gui.addColor(params, 'color');  // 색상 선택기
  </script>
</body>
</html>

 

lil-gui

npm install lil-gui

또는 CDN 이용

<script src="https://cdn.jsdelivr.net/npm/lil-gui@0.16/lil-gui.min.js"></script>

- dat.gui의 경량화 버전이라고 볼 수 있습니다. 불필요한 기능을 제거하고 기본적인 GUI 기능만 제공함으로써 더 가볍습니다. 파일 크기가 작아 성능 최적화가 중요한 프로젝트에 유리합니다.

- dat.gui와 API 구조는 거의 비슷하지만, 덜 사용되는 기능들을 제거하여 더 단순하고 가볍게 만들었습니다. 빠르게 설정하고 사용할 수 있습니다.

- 새로운 경량 대안으로 최근 더 활발하게 사용되고 있으며, 성능 최적화와 간편한 사용을 목표로 개발되었습니다.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>lil-gui Example</title>
  <script src="https://cdn.jsdelivr.net/npm/lil-gui@0.16/lil-gui.min.js"></script>
</head>
<body>
  <script>
    // 설정할 객체
    const params = {
      speed: 0.5,
      color: "#ff0000",
    };

    // lil-gui를 생성하고 GUI 컨트롤 추가
    const gui = new lil.GUI();
    gui.add(params, 'speed', 0, 1); // 0 ~ 1 사이 슬라이더
    gui.addColor(params, 'color');  // 색상 선택기
  </script>
</body>
</html>

** 여기서 lil 의 의미는 little 입니다.

 

참고 : dat-gui, lil-gui 차이점 (2)

관련글 더보기