question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Circular dependency in WebGLCubeRenderTarget.fromEquirectangularTexture

See original GitHub issue

The last circular dependency in the library is: WebGLCubeRenderTarget -> CubeCamera -> WebGLCubeRenderTarget

This is caused by WebGLCubeRenderTarget.fromEquirectangularTexture, which was added in #16671 following discussion in https://github.com/mrdoob/three.js/pull/15331#issuecomment-442908452.

This is the last blocker for closing #6241.

To remove this, we could extract .fromEquirectangularTexture to an external utility (or maybe move it to CubeTexture?). I’m not sure if it’s worth doing so just to avoid a circular dependency though.

@WestLangley, @Mugen87 and @mrdoob - you guys were involved in adding this method. Do you think we need to fix this circular dependency? If not, then we can probably just mark as “won’t fix” and close #6241.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Mugen87commented, Apr 15, 2020

If @mrdoob approves (and consider no other objections), I can make a PR with the change.

2reactions
Mugen87commented, Apr 15, 2020

Do you think we need to fix this circular dependency?

As far as I understand, this circular dependency is not harmful. However, circular dependency is always an indicator that something with the class design is not right. This issue can only be solved by refactoring.

I’ve already though about this in the past and my preferred option is to inject the internal render target of CubeCamera to solve this issue. So instead of:

var camera = new THREE.CubeCamera( 1, 1000, 256, { format: THREE.RGBAFormat, magFilter: THREE.LinearFilter, minFilter: THREE.LinearFilter } );

we do this:

var renderTarget = new THREE.WebGLCubeRenderTarget( 256, { format: THREE.RGBAFormat, magFilter: THREE.LinearFilter, minFilter: THREE.LinearFilter }  );
var camera = new THREE.CubeCamera( 1, 1000, renderTarget );

I like latter one since the last two parameters of CubeCamera are obviously intended for WebGLCubeRenderTarget. And since users usually use cubeCamera.renderTarget to access the internal render target, they could instead refer to the variable created on app level (so just renderTarget).

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebGLCubeRenderTarget#fromEquirectangularTexture
Use this method if you want to convert an equirectangular panorama to the cubemap format. # .clear ( renderer : WebGLRenderer, color :...
Read more >
How to Eliminate Circular Dependencies from Your JavaScript ...
Circular dependencies (also known as cyclic dependencies) occur when two or more modules reference each other.
Read more >
NG0200: Circular dependency in DI detected while ... - Angular
A cyclic dependency exists when a dependency of a service directly or indirectly depends on the service itself. For example, if UserService depends...
Read more >
Circular Dependency - A progressive Node.js framework
A circular dependency occurs when two classes depend on each other. For example, class A needs class B, and class B also needs...
Read more >
Circular Dependencies in Spring - Baeldung
A quick writeup on dealing with circular dependencies in Spring: how they occur and several ways to work around them.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found