프로그래밍/JavaScript

Babylonjs 설정

이재만박사 2024. 3. 15. 13:38

npm create vite@latest .

 

Vanilla

JavaScript

 

npm install

npm run dev

 

npm install -D @babylonjs/core

 

counter.js javascript.svg 삭제

 

main.js style.css 내용 전체 삭제

 

main.js에 기본 코드 입력

 

import * as BABYLON from '@babylonjs/core';


const canvas = document.querySelector('#renderCanvas');

const engine = new BABYLON.Engine(canvas);


const createScene = () => {

  const scene = new BABYLON.Scene(engine);


  return scene;

}


const scene = createScene();


engine.runRenderLoop(() => {

  scene.render();

});

style.css 에 기본 스타일 입력

 

html, body { overflow: hidden; width: 100%; height: 100%; margin: 0; padding: 0; }

#renderCanvas { width: 100%; height: 100%; touch-action: none; }