BeetleBlocks icon indicating copy to clipboard operation
BeetleBlocks copied to clipboard

new primitives

Open ShuraChechel opened this issue 9 years ago • 5 comments

new primitives

ShuraChechel avatar Mar 03 '16 17:03 ShuraChechel

How to make pyramids in Three.js: http://stackoverflow.com/a/26436728/599939

Some examples including a cone, a truncated cone and a pyramid: https://stemkoski.github.io/Three.js/Shapes.html

In particular, we do have THREE.TetrahedronGeometry, and applying scale transformations to it would give us any kind of pyramid.

As for cones, they're just particular cases of cylinders: new THREE.CylinderGeometry( 0, 30, 100, 20, 4 ), and truncating them is also a particular case:

    // radiusAtTop, radiusAtBottom, height, segmentsAroundRadius, segmentsAlongHeight,
    new THREE.CylinderGeometry( 10, 30, 100, 20, 4 )

Wedges are different animals, I believe the easiest way would be to build them out of simple triangle extrusions.

bromagosa avatar Mar 04 '16 09:03 bromagosa

Ok, and here's the wedge:

Process.prototype.wedge = function(length, width, height, type) {

    // Change positions according to width, height and type
    var triangleShape = new THREE.Shape();
                shape.moveTo(8, 2);
                shape.lineTo(4, 8);
                shape.lineTo(12, 8);
                shape.lineTo(8, 2);

   // The rest is already correct:
    var wedgeGeometry = new THREE.ExtrudeGeometry( triangleShape, { amount: length, steps: 1} );

    var mesh = new THREE.Mesh(wedgeGeometry, beetle.makeMaterial());
                    mesh.position.copy(beetle.position);
                    mesh.rotation.copy(beetle.rotation);

    // Missing the usual reRender() etc.
    [ ... ]
};

bromagosa avatar Mar 04 '16 10:03 bromagosa

A wedge implementation: http://beetleblocks.com/run/#present:Username=bromagosa&ProjectName=wedge

bromagosa avatar Jun 09 '16 08:06 bromagosa

Interesting general case. I would have added a let/right menu pulldown. It also does not comply with the centroid we usually have...

gitduks avatar Jun 13 '16 20:06 gitduks

Proposal: have these as an "extra shapes" library.

bromagosa avatar Nov 09 '19 21:11 bromagosa