mirror of
https://github.com/denismhz/solar-system.git
synced 2025-11-09 16:16:22 +01:00
path done for now
This commit is contained in:
parent
fa614c8ddb
commit
598991bcab
|
|
@ -6,12 +6,14 @@ import React, {
|
||||||
useLayoutEffect,
|
useLayoutEffect,
|
||||||
useEffect,
|
useEffect,
|
||||||
useState,
|
useState,
|
||||||
|
useContext,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useControls } from "leva";
|
import { useControls } from "leva";
|
||||||
import * as THREE from "three";
|
import * as THREE from "three";
|
||||||
import glsl from "glslify";
|
import glsl from "glslify";
|
||||||
import { TextureLoader } from "three/src/loaders/TextureLoader";
|
import { TextureLoader } from "three/src/loaders/TextureLoader";
|
||||||
import { PlanetOverlay } from "./planetOverlay";
|
import { PlanetOverlay } from "./planetOverlay";
|
||||||
|
import { PlanetOverlayContext } from "./SharedPlanetState";
|
||||||
|
|
||||||
export const PlanetPath = ({
|
export const PlanetPath = ({
|
||||||
positions,
|
positions,
|
||||||
|
|
@ -23,6 +25,7 @@ export const PlanetPath = ({
|
||||||
planet,
|
planet,
|
||||||
}) => {
|
}) => {
|
||||||
const lineref = useRef();
|
const lineref = useRef();
|
||||||
|
const { speed } = useContext(PlanetOverlayContext);
|
||||||
|
|
||||||
useLayoutEffect(() => {});
|
useLayoutEffect(() => {});
|
||||||
|
|
||||||
|
|
@ -77,10 +80,14 @@ export const PlanetPath = ({
|
||||||
|
|
||||||
const lineGeometry = new THREE.BufferGeometry();
|
const lineGeometry = new THREE.BufferGeometry();
|
||||||
useFrame(() => {
|
useFrame(() => {
|
||||||
|
if (speed === 0) {
|
||||||
|
linePos.length = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
lineref.current.geometry.setFromPoints(linePos);
|
lineref.current.geometry.setFromPoints(linePos);
|
||||||
lineref.current.geometry.setDrawRange(0, Infinity);
|
lineref.current.geometry.setDrawRange(0, Infinity);
|
||||||
cutPath(linePos, lineLength);
|
cutPath(linePos, lineLength);
|
||||||
console.log(getLength(linePos));
|
//console.log(getLength(linePos));
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue