Tips for three.js

pixgram·2022년 1월 15일
0

css에서 정한 배경이 안보일때

this.renderer = new THREE.WebGLRenderer({
  antialias: true,
  alpha: true //alpha를 적용하면 배경이 보인다. 기본 속성은 검은색
});

자식을 순환해야할때

traverse() 함수를 이용한다

new GLTFLoader().load("./test.gbl", gltf => {
  const model = gltf.scene;
  this.scene.add(model);
  
  model.traverse(child => {
    if(child instanceof THREE.Mesh) {
      child.castShadow = true;
    }
  });
  
  const box = (new THREE.Box3).setFromObject(model);
  model.position.y = (box.max.y - box.min.y) / 2;
})
profile
Interactive Front-end Developer and WebGL Artist

0개의 댓글