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

THREE.SetValues #14726

Closed
wants to merge 2 commits into from
Closed

THREE.SetValues #14726

wants to merge 2 commits into from

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Aug 16, 2018

This is a continuation of: #14572 (comment)
Only if there is interest in continuing with parameters as an object we could use THREE.SetValues in others class and examples that use parameters as an object too.

// material
var material = new THREE.MeshLambertMaterial( { map: texture, transparent: true, test:"123" } );

// log warn
"THREE.MeshLambertMaterial: 'test' property does not exist or has become obsolete."

image

@sunag
Copy link
Collaborator Author

sunag commented Aug 16, 2018

Other use would be:

var props = { color: 0xdddddd, specular: 0x009900, shininess: 30, flatShading: true };

THREE.SetValues( material1, props );
THREE.SetValues( material2, props );
THREE.SetValues( material3, props );
// n

@mrdoob
Copy link
Owner

mrdoob commented Aug 18, 2018

Only if there is interest in continuing with parameters as an object ...

I never got to like that API style. It's prone to errors and hard to evolve.

I think I prefer this kind of API:

var material = new THREE.MeshLambertMaterial().setMap( texture ).setTransparent( true );

With such API it's the browser the one notifying that something doesn't exist (undefined method).

@sunag
Copy link
Collaborator Author

sunag commented Aug 19, 2018

I never got to like that API style. It's prone to errors and hard to evolve.

Ok, could we make a function generator like shortcut of NodeMaterial?

(1)

addProperties( THREE.MeshLambertMaterial.prototype, [ "map", "transparent" ] );

or you want to do this manually like?

(2)

setMap: function ( values ) {

	this.map = value;

	return this;

},

getMap: function ( ) {

	return this.map;

},

setTransparent: function ( values ) {

	this.transparent = value;

	return this;

},

getTransparent: function ( ) {

	return this.transparent;

}

An appropriate interface like first approach could help even in serialization.

It would not be a little ambiguous to have both material.map and material.getMap()?

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