일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 시뮬레이션
- 기본 문법
- 티스토리챌린지
- 자료 구조
- JavaScript
- 브루트포스
- Next.js
- 세그먼트 트리
- 자바스크립트
- 프론트엔드
- HTML5
- 개발 회고
- js
- 엔트리포인트
- 백준
- 모던 자바스크립트 튜토리얼
- 수학
- 회고
- 토이 프로젝트
- State
- 자바
- three.js
- 해시를 사용한 집합과 맵
- 구현
- 코딩일기
- poiemaweb
- REACT
- 오블완
- react-three/fiber
- styled-components
Archives
- Today
- Total
코딩하는 고릴라
[react-three/fiber] 오브젝트 내부 렌더링 본문
🍕 문제 상황
검은색 커다란 구를 생성한 후, 검은색 구 내부에 초록색 구, 노란색 구 등을 배치시켰다.
의도는 해당 초록, 노란 구들의 배경이 검은색으로 깔리는 것이였는데 외부에서는 검은색 구가 정상적으로 출력되나 검은색 구 내부에서는 검은 면이 출력되지 않았다.
🍔 문제 해결
렌더링 대상이 되는 오브젝트의 material 속성에는 오브젝트의 내부, 외부, 양면 모두 렌더링 옵션을 선택할 수 있는 속성이 존재했고, 따로 지정해주지 않으면 외부만 렌더링 하는 것이 기본값이다.
따라서 이 옵션을 내부 렌더링으로 바꿔 검은색 구 내부에서 검은 배경을 깔 수 있게 되었다.
function Sphere({ position, size, color, type }) {
const mesh = useRef(null);
return (
<mesh ref={mesh} position={position}>
<sphereGeometry args={size} />
// material의 side 속성값을 조절해 오브젝트의 외부, 내부, 양면 렌더링
<meshStandardMaterial color={color} side={type === "double" ? THREE.DoubleSide : type === "front" ? THREE.FrontSide : THREE.BackSide} />
</mesh>
);
}
🍟 REFERENCE
THREE.JS: Seeing geometry when inside mesh
When entering the geometry, for example a sphere mesh, it acts as if the geometry doesn't exist. The color and texture are visible on the outside. But once I zoom into the mesh, the properties are ...
stackoverflow.com
반응형
'트러블 슈팅' 카테고리의 다른 글
[Cypress] 커스텀 커맨드 vscode 자동완성 적용시키기 (0) | 2024.12.17 |
---|---|
[vscode] exited with code=3221225477 (0) | 2024.11.23 |
[Jest] A React Element from an older version of React was rendered. (0) | 2024.06.19 |
[webpack] process is not defined (0) | 2024.03.19 |
[Eclipse IDE] Editor does not contain a main type (0) | 2024.01.13 |