티스토리 뷰
three.js journey강의를 듣고 작성합니다.
Three.js는 정점(Vertex)과 삼각형(Face)으로 Mesh를 만든다.
3개의 정점(Vertex)으로 삼각형을 만들고, 이를 여러 개 이어서 객체를 구성한다.
BoxGeometry
6개의 매개변수가 있음
width, height, depth, widthSegments, heightsegments, depthsegments
BufferGeometry
attribute 기반 구조를 사용해
float32array
:형식화된 배열 , float만 저장할 수 있음 , 고정된 길이 가지고있음
모든값을 넣어야하는 1차원 배열
const positionsArray = new Float32Array([
0,0,0,
0,1,0,
1,0,0
])
const positionsAttribute = new THREE.BufferAttribute(positionsArray, 3)
const geometry = new THREE.BoxGeometry()
geometry.setAttribute('position', positionsAttribute)
const material = new THREE.MeshBasicMaterial(
{
color:0xff0000,
wireframe:true
}
)