Skip to content

Commit

Permalink
etc: camera์กฐ์ •
Browse files Browse the repository at this point in the history
fov์กฐ์ ˆ
orbitcontrols ์ด๋™, ํ™•๋Œ€์ถ•์†Œ ๋ง‰์Œ

Co-authored-by: Mina Seo <[email protected]>
  • Loading branch information
5nxtnxtnxt and esthel7 committed Dec 7, 2023
1 parent 417a6c9 commit 6ca1405
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
7 changes: 4 additions & 3 deletions front/src/components/SnowGlobeCanvas/SnowGlobeCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ const SnowGlobeCanvas = React.memo<SnowGlobeCanvasProps>(
<CanvasContainer>
<Canvas
camera={{
position: [25, 2, 0]
position: [25, 2, 0],
fov: 100
}}
shadows={true}
>
<OrbitControls
target={new THREE.Vector3(0, 2, 0)}
enablePan={true}
enableZoom={true}
enablePan={false}
enableZoom={false}
maxPolarAngle={Math.PI / 2}
minPolarAngle={0}
/>
Expand Down
4 changes: 4 additions & 0 deletions front/src/components/SnowGlobeCanvas/models/MainDeco.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ const MainDeco = ({ id, scale, position, color }: MyModelProps) => {
colorPart.material = makeColorChangedMaterial(colorPart, color);

useFrame((_, delta) => {
//์ด๊ฑฐ 1์ดˆ์— 1ํ”„๋ ˆ์ž„๋„ ์•ˆ๋‚˜์˜ค๋ฉด ๋ฉ”์ธ์žฅ์‹ ๋ฉˆ์ถœ์ˆ˜๋„์žˆ์Œ
if (delta > 1) {
delta = 0;
}
if (!isStoppedRef.current) {
fallingModel(deco, speedRef, delta, isStoppedRef);
}
Expand Down
8 changes: 3 additions & 5 deletions front/src/components/SnowGlobeCanvas/models/Raycaster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ const Raycaster: React.FC<RaycasterProps> = ({ isClickedRef }) => {

useFrame((_, delta) => {
const isClicked = isClickedRef.current;
const zoomInSpeed = 1 - delta * 2;
const zoomOutSpeed = 1 + delta * 2;
if (isAnimating.current) {
if (isClicked && !isZoom) {
const targetPosition = new THREE.Vector3(0, 3.5, 0);
setView(true);
if (camera.position.distanceTo(new THREE.Vector3(0, 3.5, 0)) > 7) {
camera.position.x = camera.position.x * zoomInSpeed;
camera.position.y = camera.position.y * zoomInSpeed;
camera.position.z = camera.position.z * zoomInSpeed;
if (camera.position.distanceTo(targetPosition) > 6.5) {
camera.position.lerp(targetPosition, delta * 2);
} else {
isAnimating.current = false;
}
Expand Down

0 comments on commit 6ca1405

Please sign in to comment.