threejs中group下绑定唯一key导致parten丢失的问题

技术架构

  • 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值