Skip to content

Conversation

kungfooman
Copy link
Collaborator

@kungfooman kungfooman commented Jul 4, 2025

This PR aligns StandardMaterial#constructor with other classes like Texture#constructor to accept an optional options object, allowing properties (e.g., diffuse, depthTest) to be set during instantiation without being forced to call additional methods like Material#update - reducing boilerplate code.

Example:

const entity = new pc.Entity("test");
entity.addComponent("render", {
    type: "box",
    material: new pc.StandardMaterial({diffuse: pc.Color.RED})
});

Basically, the aim is to keep the code short and readable and to reduce manual bookkeeping.

@mvaligursky I'm not entirely sure about the requirement for this.update() or if these property assignments should happen before e.g. this.reset()?

I confirm I have read the contributing guidelines and signed the Contributor License Agreement.

@mvaligursky
Copy link
Contributor

Thanks, I'll check into this, not sure about .reset(), not familiar with it.
calling update should not be needed, no problem there, it's only needed after material has been used to render, not when constructing I believe. Again - I'll double check.

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

Successfully merging this pull request may close these issues.

2 participants