mirror of
https://github.com/denismhz/solar-system.git
synced 2025-11-09 16:16:22 +01:00
try cameracontroler
This commit is contained in:
parent
3b0d2eba4c
commit
71e8deb2f7
|
|
@ -41,14 +41,13 @@ export const CameraController = () => {
|
||||||
|
|
||||||
useFrame(() => {
|
useFrame(() => {
|
||||||
//console.log(state);
|
//console.log(state);
|
||||||
if (animate) {
|
/*if (animate) {
|
||||||
camera.position.lerp(position, 0.1);
|
camera.position.lerp(position, 0.1);
|
||||||
camera.lookAt(lookAt);
|
camera.lookAt(lookAt);
|
||||||
if (camera.position.distanceTo(position) < 0.1) {
|
if (camera.position.distanceTo(position) < 0.1) {
|
||||||
setAnimate(false);
|
setAnimate(false);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//cameraRef.current.position.addScalar(2);
|
//cameraRef.current.position.addScalar(2);
|
||||||
//camera.position.addScalar(1);
|
//camera.position.addScalar(1);
|
||||||
//console.log(camera);
|
//console.log(camera);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import React, { Suspense, useRef, createContext, memo } from "react";
|
||||||
import { ScreenOverlay } from "./omnioverlay.jsx";
|
import { ScreenOverlay } from "./omnioverlay.jsx";
|
||||||
import { SharedPlanetState } from "./SharedPlanetState.jsx";
|
import { SharedPlanetState } from "./SharedPlanetState.jsx";
|
||||||
import { Skybox } from "./skybox.jsx";
|
import { Skybox } from "./skybox.jsx";
|
||||||
import { CameraController } from "./CameraController.jsx";
|
|
||||||
|
|
||||||
export const MyContext = createContext();
|
export const MyContext = createContext();
|
||||||
|
|
||||||
|
|
@ -26,7 +25,6 @@ const SolarSystemScene = () => {
|
||||||
position: [0, 0, 200],
|
position: [0, 0, 200],
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CameraController />
|
|
||||||
<Skybox />
|
<Skybox />
|
||||||
<ambientLight intensity={0.5} />
|
<ambientLight intensity={0.5} />
|
||||||
<SharedPlanetState />
|
<SharedPlanetState />
|
||||||
|
|
@ -35,6 +33,7 @@ const SolarSystemScene = () => {
|
||||||
enablePan={false}
|
enablePan={false}
|
||||||
ref={controls}
|
ref={controls}
|
||||||
/>
|
/>
|
||||||
|
<OrbitControls ref={controls} />
|
||||||
</Canvas>
|
</Canvas>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</MyContext.Provider>
|
</MyContext.Provider>
|
||||||
|
|
|
||||||
|
|
@ -60,16 +60,14 @@ export const PlanetOverlay = ({ planet }) => {
|
||||||
// native event
|
// native event
|
||||||
switch (event.nativeEvent.button) {
|
switch (event.nativeEvent.button) {
|
||||||
case 0:
|
case 0:
|
||||||
//controls.current.target.copy(planet.current.position.clone());
|
controls.current.target.copy(planet.current.position.clone());
|
||||||
customData.current.showInfo(planet.current.userData);
|
customData.current.showInfo(planet.current.userData);
|
||||||
console.log(planet.current.position);
|
|
||||||
|
|
||||||
customData.current.handleLookAt(planet.current.position);
|
//customData.current.handleLookAt(planet.current.position);
|
||||||
console.log(customData);
|
//setFollow(true);
|
||||||
setFollow(true);
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
setFollow(false);
|
//setFollow(false);
|
||||||
//controls.current.maxDistance = Infinity;
|
//controls.current.maxDistance = Infinity;
|
||||||
console.log("right click");
|
console.log("right click");
|
||||||
break;
|
break;
|
||||||
|
|
@ -85,7 +83,7 @@ export const PlanetOverlay = ({ planet }) => {
|
||||||
}, [planet, name, minDistance, customData, iconVis, nameVis]);
|
}, [planet, name, minDistance, customData, iconVis, nameVis]);
|
||||||
|
|
||||||
useFrame(() => {
|
useFrame(() => {
|
||||||
if (follow) {
|
/*if (follow) {
|
||||||
console.log(follow);
|
console.log(follow);
|
||||||
customData.current.handlePosition(
|
customData.current.handlePosition(
|
||||||
new THREE.Vector3(
|
new THREE.Vector3(
|
||||||
|
|
@ -94,18 +92,13 @@ export const PlanetOverlay = ({ planet }) => {
|
||||||
planet.current.position.z
|
planet.current.position.z
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}*/
|
||||||
var distance = camera.position.distanceTo(planet.current.position);
|
var distance = camera.position.distanceTo(planet.current.position);
|
||||||
if (distance < minDistance) {
|
if (distance < minDistance) {
|
||||||
setOpacity(0);
|
setOpacity(0);
|
||||||
} else {
|
} else {
|
||||||
setOpacity(1);
|
setOpacity(1);
|
||||||
}
|
}
|
||||||
if (follow && controls) {
|
|
||||||
//controls.current.target.copy(planet.current.position.clone());
|
|
||||||
//controls.current.maxDistance = 20;
|
|
||||||
}
|
|
||||||
//console.log(iconVis);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
function startFollow() {
|
function startFollow() {
|
||||||
|
|
@ -114,7 +107,7 @@ export const PlanetOverlay = ({ planet }) => {
|
||||||
|
|
||||||
function endFollow() {
|
function endFollow() {
|
||||||
setFollow(false);
|
setFollow(false);
|
||||||
controls.current.reset();
|
//controls.current.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue