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

[Geometry] Add geometry for superquadric #28036

Closed

Conversation

MatteoVoges
Copy link

Description

Feature proposal: SuperquadricGeometry

This pull request introduces a new geometry type to Three.js: Superquadric Geometry. Superquadrics offer a versatile and powerful way to create a wide range of complex shapes that go beyond traditional primitives like spheres and cubes.

I hope I covered all important requirements for a Three.js geometry (e.g. widthSegments/heightSegments or phi/theta).

Once the idea is accepted, I'm willing to add tests, docs and examples if necessary.

Demo Preview

superquadrics.mp4

Visit my full demo page with interactive playgrounds and the interplay between other concepts in computer graphics:
matteovoges.github.io/extending-three.js/

Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
671.1 kB (166.4 kB) 672.8 kB (166.9 kB) +1.66 kB

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Filesize dev Filesize PR Diff
451 kB (109 kB) 451 kB (109 kB) +0 B

@@ -14,6 +14,7 @@ export * from './PolyhedronGeometry.js';
export * from './RingGeometry.js';
export * from './ShapeGeometry.js';
export * from './SphereGeometry.js';
export * from './SuperquadricGeometry.js';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we decide to add SuperquadricGeometry, I would prefer to add it as an addon so it should be placed in the examples/jsm/geometries directory.

Copy link
Collaborator

@Mugen87 Mugen87 May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the meanwhile I suggest a different approach. Please host SuperquadricGeometry as a separate npm package and then create a new example that uses your library as an external dependency. We use this approach for other demos as well e.g. https://threejs.org/examples/?q=subdivision#webgl_modifier_subdivision

The import of the subvision library looks like so:

"three-subdivide": "https://cdn.jsdelivr.net/npm/three-subdivide@1.1.2/build/index.module.js"

Your import could look like so:

"three-superquadric": "https://cdn.jsdelivr.net/npm/three-superquadric@1.0.0/build/index.module.js"

Later in the code, the module is imported like so:

import { SuperquadricGeometry } from 'three-superquadric';

@Mugen87
Copy link
Collaborator

Mugen87 commented May 8, 2024

Closing. Please create a new PR based on the suggestion in #28036 (comment).

@Mugen87 Mugen87 closed this May 8, 2024
@Mugen87 Mugen87 added this to the r165 milestone May 8, 2024
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.

None yet

2 participants