AdminLTELogo

NOTICE

둘레 길이 라벨 가시화 구현 > NOTICE

Realese Notes

  둘레 길이 라벨 가시화 구현

작성일작성일: 2024-05-24 20:00
profile_image 작성자작성자: ADMIN
댓글댓    글: 0건
조회조    회: 55회

			{ // update circle stuff
				const circleRadiusLabel2 = this.circleRadiusLabel2; //둘레 추가수정
				const circleRadiusLabel = this.circleRadiusLabel;
				const circleRadiusLine = this.circleRadiusLine;
				const circleLine = this.circleLine;
				const circleCenter = this.circleCenter;


				const circleOkay = this.points.length === 3;


				circleRadiusLabel2.visible = this.showCircle && circleOkay; //둘레 추가수정
				circleRadiusLabel.visible = this.showCircle && circleOkay;
				
				circleRadiusLine.visible = this.showCircle && circleOkay;
				circleLine.visible = this.showCircle && circleOkay;
				circleCenter.visible = this.showCircle && circleOkay;


				if(this.showCircle && circleOkay){


					const A = this.points[0].position;
					const B = this.points[1].position;
					const C = this.points[2].position;
					const AB = B.clone().sub(A);
					const AC = C.clone().sub(A);
					const N = AC.clone().cross(AB).normalize();


					const center = Potree.Utils.computeCircleCenter(A, B, C);
					const radius = center.distanceTo(A);
					const circumference = 2 * Math.PI * radius; //둘레 추가 수정


					const scale = radius / 20;
					circleCenter.position.copy(center);
					circleCenter.scale.set(scale, scale, scale);


					//circleRadiusLine.geometry.vertices[0].set(0, 0, 0);
					//circleRadiusLine.geometry.vertices[1].copy(B.clone().sub(center));


					circleRadiusLine.geometry.setPositions( [
						0, 0, 0,
						...B.clone().sub(center).toArray()
					] );


					circleRadiusLine.geometry.verticesNeedUpdate = true;
					circleRadiusLine.geometry.computeBoundingSphere();
					circleRadiusLine.position.copy(center);
					circleRadiusLine.computeLineDistances();


					const target = center.clone().add(N);
					circleLine.position.copy(center);
					circleLine.scale.set(radius, radius, radius);
					circleLine.lookAt(target);
					
					circleRadiusLabel.visible = true;
					circleRadiusLabel.position.copy(center.clone().add(B).multiplyScalar(0.5));
					circleRadiusLabel.setText(`${radius.toFixed(3)} m`); //단위 추가 수정
					
					//둘레 추가수정
					circleRadiusLabel2.visible = true; 
					circleRadiusLabel2.position.copy(center);
					circleRadiusLabel2.setText(`${circumference.toFixed(3)} m`); //단위 추가 수정


				}
			}

댓글 0

등록된 댓글이 없습니다.