diff --git a/.storybook/stories/useBVH.stories.tsx b/.storybook/stories/useBVH.stories.tsx index c9e7b018b..98fc13229 100644 --- a/.storybook/stories/useBVH.stories.tsx +++ b/.storybook/stories/useBVH.stories.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import { Setup } from '../Setup' -import { MeshBVHVisualizer } from 'three-mesh-bvh' +import { MeshBVHHelper } from 'three-mesh-bvh' import { useHelper, useBVH, TorusKnot, OrbitControls } from '../../src' import { useFrame, useThree } from '@react-three/fiber' @@ -24,7 +24,7 @@ function TorusBVH({ bvh, ...props }) { }) const debug = boolean('vizualize bounds', true) - useHelper(debug ? mesh : dummy, MeshBVHVisualizer) + useHelper(debug ? mesh : dummy, MeshBVHHelper) const [hovered, setHover] = React.useState(false) return ( diff --git a/package.json b/package.json index e9f82a07f..6208c503c 100644 --- a/package.json +++ b/package.json @@ -74,8 +74,8 @@ "stats-gl": "^2.0.0", "stats.js": "^0.17.0", "suspend-react": "^0.1.3", - "three-mesh-bvh": "^0.6.7", - "three-stdlib": "^2.28.0", + "three-mesh-bvh": "^0.7.0", + "three-stdlib": "^2.29.4", "troika-three-text": "^0.47.2", "tunnel-rat": "^0.1.2", "utility-types": "^3.10.0", diff --git a/src/core/Line.tsx b/src/core/Line.tsx index 583dcef9b..965c69dbb 100644 --- a/src/core/Line.tsx +++ b/src/core/Line.tsx @@ -13,7 +13,7 @@ import { ForwardRefComponent } from '../helpers/ts-utils' export type LineProps = { points: Array - vertexColors?: Array + vertexColors?: Array lineWidth?: number segments?: boolean } & Omit & @@ -29,6 +29,7 @@ export const Line: ForwardRefComponent = /* @_ const size = useThree((state) => state.size) const line2 = React.useMemo(() => (segments ? new LineSegments2() : new Line2()), [segments]) const [lineMaterial] = React.useState(() => new LineMaterial()) + const itemSize = (vertexColors?.[0] as number[] | undefined)?.length === 4 ? 4 : 3 const lineGeom = React.useMemo(() => { const geom = segments ? new LineSegmentsGeometry() : new LineGeometry() const pValues = points.map((p) => { @@ -48,11 +49,11 @@ export const Line: ForwardRefComponent = /* @_ if (vertexColors) { const cValues = vertexColors.map((c) => (c instanceof Color ? c.toArray() : c)) - geom.setColors(cValues.flat()) + geom.setColors(cValues.flat(), itemSize) } return geom - }, [points, segments, vertexColors]) + }, [points, segments, vertexColors, itemSize]) React.useLayoutEffect(() => { line2.computeLineDistances() @@ -83,6 +84,7 @@ export const Line: ForwardRefComponent = /* @_ resolution={[size.width, size.height]} linewidth={linewidth ?? lineWidth} dashed={dashed} + transparent={itemSize === 4} {...rest} /> diff --git a/yarn.lock b/yarn.lock index 02a83af14..96424091c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13037,15 +13037,15 @@ text-table@^0.2.0, text-table@~0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== -three-mesh-bvh@^0.6.7: - version "0.6.7" - resolved "https://registry.yarnpkg.com/three-mesh-bvh/-/three-mesh-bvh-0.6.7.tgz#6491876f5bf0c0d67be81a4402f2abdbb2266d76" - integrity sha512-RYdjMsH+vZvjLwA+ehI4+ZqTaTehAz4iho2yfL5PdGsIHyxpB78g0iy4Emj8079m/9KBX02TzddkvPSKSruQjg== - -three-stdlib@^2.28.0: - version "2.28.5" - resolved "https://registry.yarnpkg.com/three-stdlib/-/three-stdlib-2.28.5.tgz#8184f5bacc90c2eec6ed36a861224e18799226fd" - integrity sha512-JdLMhkpT+1ZWeQPyKQNW1zqUwISI2hsUljS6u3vB9lp5EvwsayaAzGnbVeR35895udOF+zxcTiQY3psk+qqlxg== +three-mesh-bvh@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/three-mesh-bvh/-/three-mesh-bvh-0.7.0.tgz#8327c3483060bb7fe3e0151d7863d338095527d4" + integrity sha512-Hj0Z1Rp02yy5H+/xtMBu/dYAeRsSONaBaVLZoST9sMpZxycHypRiUeMHucPOLWFHnpc5hwelOnONcLpkfhDg0Q== + +three-stdlib@^2.29.4: + version "2.29.4" + resolved "https://registry.yarnpkg.com/three-stdlib/-/three-stdlib-2.29.4.tgz#6e8741f6a2d435d15ed73f3a14dd149660d4ce51" + integrity sha512-XNzGCrz/uAk9XoLwd35eN7dQyI4ggXZTeqjcN034YdYBpBlNO9kmLHehl/0Nw9jCelblB7jla+unHAOIyLyV6Q== dependencies: "@types/draco3d" "^1.4.0" "@types/offscreencanvas" "^2019.6.4"