taenykim / web-graphics-playground

🎡 웹 그래픽스 놀이터
3 stars 1 forks source link

threejs Manual 읽고 따라하기 #3

Closed taenykim closed 2 years ago

taenykim commented 2 years ago

https://threejs.org/manual/#ko/fundamentals

taenykim commented 2 years ago

Threejs 란

Threejs

스크린샷 2022-05-05 오후 10 04 58
taenykim commented 2 years ago

https://github.com/taenykim/web-graphics-playground/issues/2#issuecomment-1118042298 에 광원 추가하기

{
  const color = 0xFFFFFF;
  const intensity = 1;
  const light = new THREE.DirectionalLight(color, intensity);
  light.position.set(-1, 2, 4);
  scene.add(light);
}
taenykim commented 2 years ago

반응형 디자인

창 크기에 따라 비율이 깨지는 이슈

계단 이슈

canvas의 원본 크기와 디스플레이 크기를 비교해 원본 크기를 변경할지 결정하는 함수

function resizeRendererToDisplaySize(renderer) {
  const canvas = renderer.domElement;
  const width = canvas.clientWidth;
  const height = canvas.clientHeight;
  const needResize = canvas.width !== width || canvas.height !== height;
  if (needResize) {
    renderer.setSize(width, height, false);
  }
  return needResize;
}

CSS를 제어하지 않고 CSS로 제어하기

HD-DPI 디스플레이

taenykim commented 2 years ago

해당페이지에 버그가 있어서 PR 올려서 수정했다. 😊 https://github.com/mrdoob/three.js/pull/24026

원시 모델(primitives)

BoxGeometry (육면체)

const width = 8;  // ui: width
const height = 8;  // ui: height
const depth = 8;  // ui: depth
const widthSegments = 4;  // ui: widthSegments
const heightSegments = 4;  // ui: heightSegments
const depthSegments = 4;  // ui: depthSegments
const geometry = new THREE.BoxGeometry(
    width, height, depth,
    widthSegments, heightSegments, depthSegments);

CircleGeometry (플랫 원)

const radius = 7;  // ui: radius
const segments = 24;  // ui: segments
const thetaStart = Math.PI * 0.25;  // ui: thetaStart
const thetaLength = Math.PI * 1.5;  // ui: thetaLength
const geometry = new THREE.CircleGeometry(
    radius, segments, thetaStart, thetaLength);
taenykim commented 2 years ago

이슈 close