mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
100.38k stars 35.2k forks source link

Naming Mesh and Particle #423

Closed mrdoob closed 12 years ago

mrdoob commented 12 years ago

So here are some issues I'm having.

Mesh

I think Geometry and Material make a lot of sense. And so does new THREE.Line( geometry, material ) but I'm just not sure about new THREE.Mesh( geometry, material ). I think Mesh isn't too intuitive for the function is doing here. I was thinking maybe change it to new THREE.Solid( geometry, material )?

Particle

This one is even harder. Right now we have Particle, ParticleSystem and Sprite. I think ParticleSystem can be eventually moved to a kind of material of a Mesh. But I'm specially struggling with Particle and Sprite. The problem with Particle is that a particle doesn't need to be 2D, it could be 3D too, so the use of that name may be confusing. The problem with Sprite is that, unless you have done some graphic programming already, it doesn't mean much. Alternatives to this one are Billboard, Impostor, ... which aren't too intuitive either, but maybe the later makes the most sense, because we're putting images in 3D space to create the illusion that they're 3D but they're not.

Thoughts?

alteredq commented 12 years ago

I wouldn't change Mesh. Mesh is well mesh, a pretty fundamental concept in computer graphics, calling it by any other name would just lead to confusion:

http://en.wikipedia.org/wiki/Polygon_mesh

Solid at least for me would suggest full 3d volume (as opposed to just the outer shell of the object, which is what mesh is, plus mesh doesn't have to be volume, it's perfectly ok to have just a "sheet", like in plane or terrain or flag or skirt).

http://en.wikipedia.org/wiki/Solid_modeling

(that's btw what TinkerCad does)

Our particles situation, on the other hand is indeed a mess. I think we need two different types of objects for "particle / impostor / billboard/ sprite" and "particle system" but not sure about names.

Maybe ParticleSystem could be called PointSprites or maybe just Points (to be closer to actual primitive used plus it implies size is generally small)?

And Particle and Sprite merged into one type of object called Billboard?

I find Impostor bit weird, in normal English it carries negative connotations I think (from Webster: "impostor: one that assumes an identity or title not his own for the purpose of deception"). It's kinda ok to use it for thing where 2d snapshot stands in for 3d real object, but that's not always the case.

Sprite is also valid, seems for quite a few people this is the primary use case for this type of objects - not "fake" 3d objects but simply 2d images which have been traditionally called "sprites" (could be for example hand-animated pixel art):

http://en.wikipedia.org/wiki/Sprite_%28computer_graphics%29

zz85 commented 12 years ago

My first impression of ParticleSystem was that it was a particle emitter which generates particles.

Since its more like a group, it could be called ParticleGroup, or ParticleMesh since its takes in geometry and material like Mesh, or maybe just simply call it Particles?

Just 2 cents.

alteredq commented 12 years ago

@zz85 Maybe. If individually addressable object wouldn't be anymore called Particle then group object could be Particles.

Problem with having "particle" in both was that some people tried to stuff Particle in ParticleSystem, which just from names make perfect sense.

But Billboard / Sprite vs Particles could be ok.

Then your real ParticleSystem could operate on Particles.

mrdoob commented 12 years ago

Mesh

@alteredq I see your points about Mesh and Solid. Makes sense to me. Here are some other options I was wondering though:

Object3D > SceneNode. This one is interesting as it makes more sense if you think of the Scene Graph. Mesh > Object. This one may be annoying because of IDE highlighting for the word "Object" - at least in gEdit...

And a new one:

Group which would be pretty much a SceneNode that would make the grouping more intuitive (now we use Object3D for that).

Particle

Maybe the simplest one is Sprite, ... or PointSprite, ... or, while we're at it. what about Image?

As per ParticleSystem... is there a way to do something like... new THREE.Mesh( geometry, new THREE.MeshPointSpriteMaterial( { map: texture } ) );?

alteredq commented 12 years ago

Object3D > SceneNode. This one is interesting as it makes more sense if you think of the Scene Graph.

Yes, this I can see. I'm finding myself using empty Object3D more and more as a scene graph node. Or maybe just Node?

Mesh > Object. This one may be annoying because of IDE highlighting for the word "Object" - at least in gEdit...

Mesh I wouldn't touch. IMHO it's good as it is.

Group maybe, but what would be difference to Node? Node / Object3D can have multiple children as well. Or was this supposed to be just an alias?

Maybe the simplest one is Sprite, ... or PointSprite, ... or, while we're at it. what about Image?

Not Image, this suggest more using the thing as whole, while Sprite implies it is a component. Also there is already DOM Image object, it would be better to have something different to avoid confusion.

And I think Sprite is preferable to PointSprite in this case, as sprites can be potentially large.

As per ParticleSystem... is there a way to do something like... new THREE.Mesh( geometry, new THREE.MeshPointSpriteMaterial( { map: texture } ) );?

Not sure, I would prefer particle systems stay separated from meshes.

We are far from done experimenting around particles. If nothing else, for pure practical reasons it's good to have them in separate code paths.

Eventually, we should have some true particle systems, with stuff like emitters, lifecycles, texture atlases, maybe GPU computed behaviors.

Particle systems kinda look like meshes just for now.

mrdoob commented 12 years ago

Object3D > SceneNode. This one is interesting as it makes more sense if you think of the Scene Graph.

Yes, this I can see. I'm finding myself using empty Object3D more and more as a scene graph node. Or maybe just Node?

I think SceneNode is better. It's just self-descriptive.

Mesh > Object. This one may be annoying because of IDE highlighting for the word "Object" - at least in gEdit...

Mesh I wouldn't touch. IMHO it's good as it is.

Ok! :)

Group maybe, but what would be difference to Node? Node / Object3D can have multiple children as well. Or was this supposed to be just an alias?

Yeah, it can be an alias or it can extend SceneNode if we find that we need exra properties. It's just a more descriptive API:

var group = new THREE.Group(); // better than var group = new THREE.SceneNode();
group.addObject( mesh1 );
group.addObject( mesh2 );

scene.addObject( group );

Still battling with addChild and addObject also...

Not Image, this suggest more using the thing as whole, while Sprite implies it is a component. Also there is already DOM Image object, it would be better to have something different to avoid confusion.

Bitmap?

As per ParticleSystem... is there a way to do something like... new THREE.Mesh( geometry, new THREE.MeshPointSpriteMaterial( { map: texture } ) );?

Not sure, I would prefer particle systems stay separated from meshes.

I can see the need of a Particle System, but would it be viable to do the MeshPointSpriteMaterial thing as well? It's just simpler if you just want to draw sprites in the vertices.

alteredq commented 12 years ago

I think SceneNode is better. It's just self-descriptive.

Ok.

Still battling with addChild and addObject also...

Yes, it's not good to have both. At first I didn't like addChild but now I already got used. Any of them would be ok.

Not Image, this suggest more using the thing as whole, while Sprite implies it is a component. Also there is already DOM Image object, it would be better to have something different to avoid confusion.

Bitmap?

Not really, Bitmap is more like subclass / alias for Image.

Also if it's to be used at the place of Particle, in CanvasRenderer currently this can also be procedural thing for drawing, so not really a bitmap.

I can see the need of a Particle System, but would it be viable to do the MeshPointSpriteMaterial thing as well? It's just simpler if you just want to draw sprites in the vertices.

I see your point but this would bring too much mess implementation wise. I think you can't even share the same geometry instance between mesh and particle system, buffers are organized in a different way, updates are done differently, particle systems are streamlined for performance.

zz85 commented 12 years ago

Yes, it's not good to have both. At first I didn't like addChild but now I already got used. Any of them would be ok.

addChild() seems to have more meaning for me. Otherwise I kind of prefer add() over addObject();

Not really, Bitmap is more like subclass / alias for Image.

similar impressions here.

mrdoob commented 12 years ago

I see your point but this would bring too much mess implementation wise. I think you can't even share the same geometry instance between mesh and particle system, buffers are organized in a different way, updates are done differently, particle systems are streamlined for performance.

Yeah, that's what I was asking. Cool then!

addChild() seems to have more meaning for me. Otherwise I kind of prefer add() over addObject();

Kind of prefer add() myself too.

SceneNode, Mesh, Sprite,Group, Scene.add, SceneNode.add it is! :)