New ShapeBufferGeometry #9970

Merged
merged 2 commits into from Oct 31, 2016

Projects

None yet

3 participants

@Mugen87
Contributor
Mugen87 commented Oct 29, 2016 edited

This PR introduces ShapeBufferGeometry.

The first DEMO shows a simple shape geometry with a hole.
The second DEMO shows a geometry constructed out of two shapes.

Unfortunately i had to perform some changes in order to make ShapeBufferGeometry and ShapeGeometry more consistent to the new geometry entities.

  • The public methods addShape and addShapeList were removed. The correct way for creating a ShapeBufferGeometry is this: 1. Create your shape list. 2. Call the respective constructor. 3. If your shape list changes, recreate the geometry.
  • ShapeBufferGeometry has no options parameter anymore. All parameters must be assigned explicitly.
  • ShapeBufferGeometry dropped the support for the material parameter. If you pass an array of shapes, each shape automatically gets its own material index. You can check out this behavior in the second demo.
  • There is no support for the uvGenerator parameter anymore. ShapeBufferGeometry creates "world uvs" by default. If users want to change this, they should maybe apply something like this:
UVWorldGenerator.generate( bufferGeometry );

I hope the implementation is okay so far. There was no need to change webgl_geometry_shapes to keep things working. What do you think?

@Mugen87 Mugen87 changed the title from ShapeBufferGeometry: Initial commit to New ShapeBufferGeometry Oct 29, 2016
src/geometries/ShapeBufferGeometry.js
+
+ // generate normals
+
+ this.computeVertexNormals();
@WestLangley
WestLangley Oct 30, 2016 Collaborator

I would avoid calling computeVertexNormals() when you can compute the normals analytically. Are not all the normals ( 0, 0, 1 )?

@Mugen87
Mugen87 Oct 30, 2016 edited Contributor

You're right! It's actually better to create the normals like the other buffers. The value is always ( 0, 0, 1 ).

@WestLangley
Collaborator

I would note in the example that you are compensating for the so-called "world UVs" by setting offset/repeat on the texture.

@Mugen87
Contributor
Mugen87 commented Oct 30, 2016

Done!

@mrdoob mrdoob merged commit 7ea23ec into mrdoob:dev Oct 31, 2016
@mrdoob
Owner
mrdoob commented Oct 31, 2016

Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment