Skip to content

Commit

Permalink
fixed: camera zoom범위 조절
Browse files Browse the repository at this point in the history
  • Loading branch information
5nxtnxtnxt committed Dec 7, 2023
1 parent 6ca1405 commit 6e0667f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions front/src/components/SnowGlobeCanvas/SnowGlobeCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const SnowGlobeCanvas = React.memo<SnowGlobeCanvasProps>(
<CanvasContainer>
<Canvas
camera={{
position: [25, 2, 0],
position: [15, 2, 0],
fov: 100
}}
shadows={true}
Expand Down Expand Up @@ -69,7 +69,7 @@ const SnowGlobeCanvas = React.memo<SnowGlobeCanvasProps>(
<Models.Raycaster isClickedRef={isClicked} />
<Models.Ground scale={1} position={new THREE.Vector3(0, 0, 0)} />
<Models.Glass
position={new THREE.Vector3(0, glassRadius / 2, 0)}
position={glassPosition}
color={new THREE.Color('white')}
radius={glassRadius}
opacity={0.1}
Expand Down
6 changes: 3 additions & 3 deletions front/src/components/SnowGlobeCanvas/models/Raycaster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const Raycaster: React.FC<RaycasterProps> = ({ isClickedRef }) => {
const zoomOutSpeed = 1 + delta * 2;
if (isAnimating.current) {
if (isClicked && !isZoom) {
const targetPosition = new THREE.Vector3(0, 3.5, 0);
const targetPosition = new THREE.Vector3(0, 2.5, 0);
setView(true);
if (camera.position.distanceTo(targetPosition) > 6.5) {
if (camera.position.distanceTo(targetPosition) > 6) {
camera.position.lerp(targetPosition, delta * 2);
} else {
isAnimating.current = false;
Expand All @@ -35,7 +35,7 @@ const Raycaster: React.FC<RaycasterProps> = ({ isClickedRef }) => {
if (view) {
setIsZoom(true);
} else if (isZoom && !view) {
if (camera.position.distanceTo(new THREE.Vector3(0, 3.5, 0)) < 25) {
if (camera.position.distanceTo(new THREE.Vector3(0, 3.5, 0)) < 15) {
camera.position.x = camera.position.x * zoomOutSpeed;
camera.position.y = camera.position.y * zoomOutSpeed;
camera.position.z = camera.position.z * zoomOutSpeed;
Expand Down

0 comments on commit 6e0667f

Please sign in to comment.