How to use geometry-extrude - 5 common examples

To help you get started, we’ve selected a few geometry-extrude examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github maptalks / maptalks.three / src / worker / index.js View on Github external
function extrudePolygons(d) {
    const { data, height } = d;
    const { position, normal, uv, indices } = extrudePolygon(
        // polygons same with coordinates of MultiPolygon type geometry in GeoJSON
        // See http://wiki.geojson.org/GeoJSON_draft_version_6#MultiPolygon
        data,
        // Options of extrude
        {
            // Can be a constant value, or a function.
            // Default to be 1.
            depth: height
        }
    );
    return { position, normal, uv, indices };
}
github pissang / paper-quilling-art / src / main.js View on Github external
}
                polylines.push(polyline);
            }
            this._maskOutlinePoints = new Float32Array(maskOutlinePoints);


            if (!(config.outlineHeight > 0 && config.outlineThickness > 0)) {
                this._rootNode.remove(this._outlineMesh);
                this._advancedRenderer.render();
                return;
            }

            this._rootNode.add(this._outlineMesh);


            let {indices, position, normal, uv} = extrudePolyline(polylines, {
                // TODO Configuration
                lineWidth: config.outlineThickness, depth: config.outlineHeight,
                smoothSide: true
            });
            if (this._outlineMesh.geometry) {
                this._outlineMesh.geometry.dispose(this._renderer);
            }
            let geo = this._outlineMesh.geometry = new Geometry();
            geo.attributes.position.value = position;
            geo.attributes.normal.value = normal;
            geo.attributes.texcoord0.value = uv;
            geo.indices = indices;
            geo.generateTangents();
            geo.updateBoundingBox();
            geo.dirty();
github maptalks / maptalks.three / src / util / ExtrudeUtil.js View on Github external
export function getExtrudeGeometryParams(polygon, height, layer, center) {
    const datas = getPolygonPositions(polygon, layer, center);
    const shapes = datas;
    //Possible later use of geojson
    if (!shapes) return null;
    height = layer.distanceToVector3(height, height).x;
    const { position, normal, uv, indices } = extrudePolygon(shapes, {
        depth: height
    });
    return {
        position, normal, uv, indices
    };
}
github maptalks / maptalks.three / src / util / LineUtil.js View on Github external
export function getExtrudeLineGeometry(lineString, lineWidth = 1, depth = 1, layer, center) {
    const positions = getLinePosition(lineString, layer, center).positionsV;
    const ps = [];
    for (let i = 0, len = positions.length; i < len; i++) {
        const p = positions[i];
        ps.push([p.x, p.y]);
    }
    const {
        indices,
        position,
        normal
    } = extrudePolyline([ps], {
        lineWidth,
        depth
    });
    const geometry = new THREE.BufferGeometry();
    addAttribute(geometry, 'position', new THREE.Float32BufferAttribute(position, 3));
    addAttribute(geometry, 'normal', new THREE.Float32BufferAttribute(normal, 3));
    geometry.setIndex(new THREE.Uint32BufferAttribute(indices, 1));
    return geometry;
}
github maptalks / maptalks.three / src / util / LineUtil.js View on Github external
export function getExtrudeLineParams(lineString, lineWidth = 1, depth = 1, layer, center) {
    const positions = getLinePosition(lineString, layer, center).positionsV;
    const ps = [];
    for (let i = 0, len = positions.length; i < len; i++) {
        const p = positions[i];
        ps.push([p.x, p.y]);
    }
    const {
        indices,
        position,
        normal
    } = extrudePolyline([ps], {
        lineWidth: lineWidth,
        depth: depth
    });
    return {
        position: position,
        normal: normal,
        indices: indices
    };
}

geometry-extrude

A small and fast JavaScript library for extruding 2D polygons and polylines to 3D meshes. It depends on [earcut](https://github.com/mapbox/earcut) to do triangulation.

MIT
Latest version published 2 years ago

Package Health Score

45 / 100
Full package analysis

Similar packages