Skip to content

Component - Add support for componentization in the renderer #31185

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

Open
ylfq opened this issue May 27, 2025 · 6 comments
Open

Component - Add support for componentization in the renderer #31185

ylfq opened this issue May 27, 2025 · 6 comments

Comments

@ylfq
Copy link

ylfq commented May 27, 2025

Description

Add support for componentized code to nodes, use lifecycle and event-driven for better code management.

Solution

Use components to manage your code, like this.

Image

Image

Alternatives

It's very inconvenient to wrap all the componentization logic into methods and then call them manually, so I tried modifying the code of Object3D and Renderer to support componentization

Additional context

No response

@mrdoob
Copy link
Owner

mrdoob commented May 27, 2025

Why does this need to be built-in?

@mrdoob
Copy link
Owner

mrdoob commented May 27, 2025

Can you create a jsfiddle that showcases your proposal better than these two screenshots?

@ylfq
Copy link
Author

ylfq commented May 27, 2025

Can you create a jsfiddle that showcases your proposal better than these two screenshots?

Okay, I'll get back to you after uploading the example

@ylfq
Copy link
Author

ylfq commented May 27, 2025

Can you create a jsfiddle that showcases your proposal better than these two screenshots?

Currently, only WebGLRenderer is supported, and WebGPURenderer is not yet fully adapted
jsfiddle: https://jsfiddle.net/ylfq__/jcdpk0na/8/

@mrdoob
Copy link
Owner

mrdoob commented May 28, 2025

	onLoad() {

		console.log( `${this.obj.name} loaded` );

	}
	onUpdate() {

		// console.log(`${this.obj.name} update`);

	}
	onEnable() {

		console.log( `${this.obj.name} enable` );

	}
	onDisable() {

		console.log( `${this.obj.name} disable` );

	}
	onDestroy() {

		console.log( `${this.obj.name} destroy` );

	}

Are these all the needed callbacks for this?
Would people need more like onAdded, onRemoved, onHover, onClick, onDrag, ...

@mrdoob
Copy link
Owner

mrdoob commented May 28, 2025

More questions...

  • When is onLoad called?
  • When is onEnable called?
  • When is onDisable called?
  • When is onUpdate called?
  • When is onDestroy` called?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants