技术架构
- react
- threejs
- @react-three/drei
- @react-three/fiber
- @use-gesture/react
场景
一个分组下有一个Line,当使用gesture的useDrag触发事件以后:
import { Line } from '@react-three/drei'
import { ThreeEvent, useFrame } from '@react-three/fiber'
import { useDrag } from '@use-gesture/react'
import { useEffect, useState } from 'react'
import { DoubleSide, Vector3 } from 'three'
const lineWidth = 4
const LinePropsData = {
color: 0x3b61fa,
lineWidth: lineWidth,
dashSize: lineWidth,
gapSize: lineWidth,
side: DoubleSide,
}
/**
* 区域入参定义
*/
export interface ExampleProps {
positions?: Vector3[]
}
const Example: React.FC<ExampleProps> = (props) => {
const { positions = [] } = props
const [linePositions, setLinePositions] = useState<Vector3[]>([...positions])
useEffect(() => {
if (!positions) {
return
}
setLineP