Skip to content

Commit

Permalink
fix: delete useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
gong9 committed Oct 24, 2023
1 parent 3d17e37 commit 8a61c71
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions src/hooks/useCreateLine.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useRef } from 'react'
import { useThree } from '@react-three/fiber'
import { Line2, LineGeometry, LineMaterial } from 'three-stdlib'
import type { LineMaterial } from 'three-stdlib'
import { Line2, LineGeometry } from 'three-stdlib'
import { BufferAttribute, BufferGeometry, Points, PointsMaterial, Vector3 } from 'three'

import useModeStore from '@/store/mode'
Expand All @@ -21,20 +22,6 @@ const useCreateLine = () => {
const { scene } = useThree()
const { drawline } = useModeStore(state => state)

const initCreateLine = () => {
const geometry = new LineGeometry()
geometry.setPositions(pointsRef.current)
const material = new LineMaterial({ color: 0x000000, linewidth: 0.001 })

const line = new Line2(geometry, material)
lineRef.current = line

scene.add(line)
geometry.attributes.position.needsUpdate = true

return geometry
}

/**
* line first point helper show
* @param x
Expand Down Expand Up @@ -144,13 +131,8 @@ const useCreateLine = () => {
}

useEffect(() => {
if (drawline) {
const setFunction = initCreateLine()
geometryRef.current = setFunction
}
else {
if (!drawline)
destroyLine()
}
}, [drawline])

return [pushPoint, tryPushPoint]
Expand Down

0 comments on commit 8a61c71

Please sign in to comment.