Tresjs / cientos

Collection of useful helpers and fully functional, ready-made abstractions for TresJS
https://cientos.tresjs.org/
MIT License
288 stars 40 forks source link

Lensflare playground demo is broken #435

Closed alvarosabu closed 2 months ago

alvarosabu commented 5 months ago

Describe the bug

Lensflare seems to be broken on v4

Cannot destructure property 'registerCamera' of '(intermediate value)(intermediate value)(intermediate value)' as it is undefined.

Screenshot 2024-06-05 at 17 25 43

Reproduction

Run local playground

Steps to reproduce

No response

System Info

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M1 Pro
    Memory: 51.02 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
    pnpm: 8.15.4 - ~/Library/pnpm/pnpm
    bun: 1.0.2 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 120.1.61.116
    Chrome: 125.0.6422.142
    Safari: 17.5
  npmPackages:
    @tresjs/core: 4.0.0-rc.2 => 4.0.0-rc.2 
    @tresjs/leches: ^0.14.0 => 0.14.0

Used Package Manager

pnpm

Code of Conduct

andretchen0 commented 5 months ago

I think this is a problem with nodeOps in the core:

      const { registerCamera } = child?.__tres?.root as TresContext;

The optional chaining (?) signals that one might expect undefined is sometimes returned. undefined can't be destructured:

$ node
> { foo } = undefined
Uncaught TypeError: Cannot destructure property 'foo' of 'undefined' as it is undefined.

On the team Discord, @garrlker and I were just briefly talking about passing in context in order to factor out some of this optional chaining and long lookups.

I'll go ahead and open a PR for that refactor today. It should fix this issue.

andretchen0 commented 5 months ago

There wasn't a camera in the demo and that made v4 nodeOps throw.

It'd be great if we always had a dummy camera in Tres.

JaimeTorrealba commented 2 months ago

I'll close this one, if this is not complete please feel free to re-open @andretchen0