Closed dusunax closed 1 year ago
230610, 2์~3์๋ฐ ์งํ
camera.position.set(0, 0, 0);
camera.lookAt(mesh);
console.log(camera);
const controls = new OrbitControls(camera); // ์ฌ๊ธฐ controls.enableZoom = true; controls.autoRotate = true;
- ํ์
ํ์ธ => ๋๋ฒ์งธ ์ธ์๋ก container ๋๊ธฐ๋ ์ฝ๋ ์ถ๊ฐ
```tsx
(alias) new OrbitControls(object: THREE.Camera, domElement?: HTMLElement | undefined): OrbitControls
import OrbitControls
Orbit controls allow the camera to orbit around a target.
@param object
The camera to be controlled. The camera must not be a child of another object, unless that object is the scene itself.
@param domElement
The HTML element used for event listeners.
const controls = new OrbitControls(camera, container);
controls.enableZoom = true;
controls.autoRotate = true;
์๋ฌ๊ฐ ์์ด์ง๊ณ , scene์ด ๋ก๋ฉ ๋์์ง๋ง ์ด๋ฏธ์ง ์ถ๋ ฅ์ ์ด์์ด ์์ต๋๋ค.
์์ ๋ฌธ์ ์ : ๋ชจ๋ธ ํฌ๊ธฐ๊ฐ ๋๋ฌด ํผ, ์นด๋ฉ๋ผ ์์น๊ฐ ์๋ชป๋จ, ๋น์ด ๋ถ์กฑํจ
์์ ๋ด์ฉ
camera.position.set(0, 0, 1000);
์ผ๋ก ์์น ์กฐ์ loadPLYModelBySrc
=> ok
/** plyPath: ๊ฒฝ๋ก์ ply model์ loadํฉ๋๋ค. */
function loadPLYModelBySrc(
renderer: THREE.WebGLRenderer,
container: any,
scene: THREE.Scene,
plyPath: string
) {
console.log("๊ฒฝ๋ก ๋ก๋");
const loader = new PLYLoader();
loader.load(plyPath, (geometry) => {
handleGeometry(renderer, container, scene, geometry);
});
}
handleGeometry
handleGeometry (
renderer: THREE.WebGLRenderer,
container: any,
scene: THREE.Scene,
geometry: THREE.BufferGeometry<THREE.NormalBufferAttributes>
) => void
loadPLYModelByFile
=> ๋ก๋ฉ x
/** plyFile: ply model File์ loadํฉ๋๋ค. */
function loadPLYModelByFile(
renderer: THREE.WebGLRenderer,
container: any,
scene: THREE.Scene,
plyFile: File
) {
console.log("ํ์ผ ๋ก๋");
const loader = new PLYLoader();
const reader = new FileReader();
reader.onload = (event) => {
if (event.target && event.target.result) {
let plyData: string | ArrayBuffer = event.target.result;
if (typeof plyData === "string") {
const encoder = new TextEncoder();
plyData = encoder.encode(plyData);
}
const plyDataUint8 = new Uint8Array(plyData);
const geometry = loader.parse(plyDataUint8);
console.log(geometry);
handleGeometry(renderer, container, scene, geometry);
reader.readAsArrayBuffer(plyFile);
}
};
}
230610 - ThreeJS Viewer
2. Render 3D file
A-2. ply ํ์ผ์ ๋๋๋ง
(์ถ๊ฐ ๋ชฉํ)
์ปดํฌ๋ํธ์ ์ปค์คํ ํ ์ ์ ๋ฆฌํ์ฌ ์ฌ์ฌ์ฉํ ์ ์๋ ์ฝ๋ ์์ฑ
A-1. dcm ํ์ผ์ ply๋ก ๋ณํ
๋ ํผ๋ฐ์ค ์์น_ 230608 (๋ณํ ์คํจ)
converter ๊ตฌํ ์๋_230609 (๋ณํ ์คํจ)
frontend\src\components\converter\DicomToPly.tsx
A-2. ply ํ์ผ์ ๋๋๋ง
๊ณ ๋ คํ๊ธฐ
๊ธฐ์กด์ ์๋ฐ์คํฌ๋ฆฝํธ๋ก ํ ๋๋ก, geometry ์์๋ฅผ ์ง์ createํ๊ฑฐ๋, glbํ์ผ์ ๋ก๋ํ์ฌ ์์ ํด๋ณธ ์ ์ด ์์ต๋๋ค. ์ด๋ฒ ์์ ์ ์๋ก ๊ณ ๋ คํด์ผ ํ ์ ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
๊ตฌํ ๋ชฉํ
๋จ์ ์์ ๋ชฉํ