Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuadraticBezierLine component broken with @react-three/fiber version 8.0.18 and higher #2315

Closed
stellarlyjess opened this issue Jun 4, 2022 · 7 comments · Fixed by #2316
Closed
Labels
bug Something isn't working

Comments

@stellarlyjess
Copy link

stellarlyjess commented Jun 4, 2022

  • three version: 0.136.0 (tried lower and higher +/- 10 versions
  • @react-three/fiber version: 8.0.22
  • @react-three/drei version: 9.11.3
  • node version: v16.13.2
  • npm (or yarn) version: npm version 8.1.2

Problem description:

Increment to version 8.0.18 for @react-three/fiber or higher and observe 'cannot read property data of undefined` message.

App crashes :(

Relevant code:

https://codesandbox.io/s/spaceman-dz5jj0?file=/package.json
^ forked from example of QuadraticBezierLine.

@stellarlyjess stellarlyjess added the bug Something isn't working label Jun 4, 2022
@stellarlyjess stellarlyjess changed the title QuadraticBezierLine component broken in React 18 and @react-three/fiber version 8+ QuadraticBezierLine component broken in React 18 and @react-three/fiber version 8.0.18 and higher Jun 4, 2022
@stellarlyjess stellarlyjess changed the title QuadraticBezierLine component broken in React 18 and @react-three/fiber version 8.0.18 and higher QuadraticBezierLine component broken with @react-three/fiber version 8.0.18 and higher Jun 4, 2022
@FarazzShaikh
Copy link
Member

Broken box for refrence https://codesandbox.io/s/spaceman-forked-23lx8t

@drcmda
Copy link
Member

drcmda commented Jun 13, 2022

this should be fixed with latest r3f, ... it's not?

edit,

  React.useLayoutEffect(() => {
    line2.computeLineDistances();

which then leads to

    (0, _defineProperty.default)(this, "computeLineDistances", () => {
      const geometry = this.geometry;
      const instanceStart = geometry.attributes.instanceStart;
      const instanceEnd = geometry.attributes.instanceEnd;
      const lineDistances = new Float32Array(2 * instanceStart.data.count); <--- crash, instanceStart is undefined

@drcmda
Copy link
Member

drcmda commented Jun 13, 2022

@CodyJasonBennett it still seems related to the attach change made in .18-.19 despite the revert. i've debugged it a little and the instanceStart stuff is OK, it's being set by setPositions. the geometry is correct, instanceStart is not undefined, but it's later being used like so:

  return (
    <primitive object={line2} ref={ref} {...rest}>
      <primitive object={lineGeom} attach="geometry" />

and although this could be <primitive object={line2} geometry={lineGeom} something must have changed that fails the attach.

@CodyJasonBennett CodyJasonBennett transferred this issue from pmndrs/drei Jun 13, 2022
@drcmda
Copy link
Member

drcmda commented Jun 13, 2022

i can confirm now that it doesn't attach it, the uuid's don't match. what's on the line is the empty default buffergeom, the attach of the geometry created by the component is neglected for some reason.

@CodyJasonBennett
Copy link
Member

This is unrelated to multi-attach, but with #2268. Can reproduce since 8.0.18.

@FarazzShaikh
Copy link
Member

Still broken on latest r3f and latest drei https://codesandbox.io/s/spaceman-forked-23lx8t

I will close pmndrs/drei#946 as it looks like the root cause is not within drei?

@drcmda
Copy link
Member

drcmda commented Jun 13, 2022

correct this is caused by r3f. when useLayoutEffect fires everything must be attached already, the view must be completed. but it looks like that isn't the case no more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants