A fast Python Quantized Mesh encoder
Project description
quantized-mesh-encoder
A fast Python Quantized Mesh encoder. Encodes a mesh with 100k coordinates and 180k triangles in 20ms.
Overview
Quantized Mesh is a format to encode terrain meshes for efficient client-side terrain rendering. Such files are supported in Cesium and deck.gl (as of release 8.2, expected July 2020.)
This library is designed to support performant server-side on-demand terrain mesh generation.
Install
pip install numpy Cython
pip install quantized-mesh-encoder
Cython is used internally, and currently only source builds are provided, so you'll need to have Cython and a C compiler available during installation. Additionally Numpy must already exist during install. Pull requests are welcome to package as platform-specific wheels.
Using
API
encode
Parameters:
f
: a file object in which to write encoded bytespositions
: (array[float]
): a flat Numpy array of 3D positions.indices
(array[int]
): a flat Numpy array indicating triples of coordinates frompositions
to make triangles. For example, if the first three values ofindices
are0
,1
,2
, then that defines a triangle formed by the first 9 values inpositions
, three for the first vertex (index0
), three for the second vertex, and three for the third vertex.bounds
(List[float]
, optional): a list of bounds,[minx, miny, maxx, maxy]
. By default, inferred as the minimum and maximum values ofpositions
.
Examples
Write to file
from quantized_mesh_encoder import encode
with open('output.terrain', 'wb') as f:
encode(f, positions, indices)
Quantized mesh files are usually saved gzipped. An easy way to create a gzipped
file is to use gzip.open
:
import gzip
from quantized_mesh_encoder import encode
with gzip.open('output.terrain', 'wb') as f:
encode(f, positions, indices)
Write to buffer
It's also pretty simple to write to a buffer instead of a file
from io import BytesIO
from quantized_mesh_encoder import encode
buf = BytesIO()
encode(buf, positions, indices)
To read the bytes out of the buffer, e.g. to gzip the buffer
import zlib
buf.seek(0)
out_bytes = zlib.compress(buf.read())
Generating the mesh
To encode a mesh into a quantized mesh file, you first need a mesh! This project
was designed to be used with pymartini
, a fast elevation
heightmap to terrain mesh generator.
martini = Martini(257)
# generate RTIN hierarchy from terrain data (an array of size^2 length)
tile = martini.create_tile(terrain)
# get a mesh (vertices and triangles indices) for a 10m error
vertices, triangles = tile.get_mesh(10)
buf = BytesIO()
encode(buf, vertices, triangles)
License
Much of this code is ported or derived from
quantized-mesh-tile
in some way. quantized-mesh-tile
is also released under the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for quantized_mesh_encoder-0.1.2-pp36-pypy36_pp73-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c456984b4d9cdcda40adcc0b14ba0dee5b03a513802b11df09c1426e9117cd5a |
|
MD5 | 3d1704996d21659ba9e36e082a9f3ebc |
|
BLAKE2b-256 | 17b6ae05f949ea1a6e12d0fe34d656860132c35e88135b93448eee975244f2ad |
Hashes for quantized_mesh_encoder-0.1.2-pp36-pypy36_pp73-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0d5d0452401580c15528e30df3c6e3480729ae58c718a974644bbe336a6ad53 |
|
MD5 | 8b7372c55c142ce80a0e81c3e1dd539f |
|
BLAKE2b-256 | 58074c908020610c0c75ecd789c0cefda36bf2c1a52a85350efcb1f85ab63f85 |
Hashes for quantized_mesh_encoder-0.1.2-pp36-pypy36_pp73-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73d9c7478a54155cb08563c0f679180a3769f5a052196eadd87bc749f9b12ea2 |
|
MD5 | ce58fd757fb2bf65d55791d04aaeb2b9 |
|
BLAKE2b-256 | f21c59c9ed38978dbdc3e7a2214f0e9a92d30e8ad48b3666828f9fb3331a907a |
Hashes for quantized_mesh_encoder-0.1.2-pp36-pypy36_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 408a271d163fad4bbdfd638ee6b06c0e97a5d722def1b6c88f45210f23ea9f1b |
|
MD5 | 7ba49696ffbfad3e33fbffdf9110ebfb |
|
BLAKE2b-256 | a3ea30e071a604e370972be010fbcd238b284f709adc4c6f80d75ffdde1b7eb0 |
Hashes for quantized_mesh_encoder-0.1.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3eb96830cdd8ebd7b86f62fb456cfeffb2d2f9c90c2d188f7da3745afd546ee5 |
|
MD5 | a0578941bfe1c5b047b29e832b612cd8 |
|
BLAKE2b-256 | 4e216de1a312e111e1830335a653a5a4259dfa4f71466e3bf05bdd1f1d7f2e3c |
Hashes for quantized_mesh_encoder-0.1.2-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32ab4e100c74cfcc30bfac94dd97fbeeb09eecc232e24313e9e25e3f90492ff7 |
|
MD5 | 4598e867ca6cb7a0b648d91605b5e63e |
|
BLAKE2b-256 | 31f1cfe6c06687aac301a18c3e3ff402f0b47008b4d7f199092a56754cbcc293 |
Hashes for quantized_mesh_encoder-0.1.2-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de1153ddead11c4daa49e75cd44581d43dce6d037835c72c4ff857406e521054 |
|
MD5 | ed0788e221eafaf6c7b7524e4f3c363c |
|
BLAKE2b-256 | dc5c1dd2fdfc79d1c30156c7bb77d102c155395b5ad8f32b9e8116cdc1881b8e |
Hashes for quantized_mesh_encoder-0.1.2-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 159e844afb29cec6ea418be9b46c23fa1bda36bfdb8a76d9fd07e5664d937df4 |
|
MD5 | bb90b39394faf9df8cd8063070a08523 |
|
BLAKE2b-256 | ff62d7195c15cfc8c2b621dc16b18b895324887f26f987a4b6c9a020646d831e |
Hashes for quantized_mesh_encoder-0.1.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e532f5fe3c8a3272bbc254aba9545bd00925cbfc6e1113085121816e03a2354f |
|
MD5 | b9b0379923bcb463b1f3fbe32419c416 |
|
BLAKE2b-256 | c9475baffdea76bdaf0a22f6537ea9673a86c21d2ee6ab462aa7b9f411fb8bd1 |
Hashes for quantized_mesh_encoder-0.1.2-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 303a072f5eb4e574688db7110f77bde17ed9f324f9ad1de9cc0ea5a77668d759 |
|
MD5 | c2398f0247aefbb1929790bd9bf91fbd |
|
BLAKE2b-256 | 90bb198b9fd2bcb9b5a4303019ca98f80464dedf921514644ce7577361cff1f1 |
Hashes for quantized_mesh_encoder-0.1.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2e39fe1af172c70da40263160f99a5e20451159e042cc0d73e11c5aa462e9a9 |
|
MD5 | 2b8a1830b24f2420691f8a4a02851191 |
|
BLAKE2b-256 | 7191e98d455f6ae3f7d95b5e3f06936d89db7978caaa73755b64c3d9aad3b299 |
Hashes for quantized_mesh_encoder-0.1.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a2e8433fca0f67c9b91f4373ff768bf4d6ff554ffa8122d7099bdbc8fdc4d94 |
|
MD5 | ce0a70b1597008a1af262a3e3575b2a8 |
|
BLAKE2b-256 | dfcc6ec4d182124bf75d3f603b18ce1671575c46b726cb183b4922c5906674c6 |
Hashes for quantized_mesh_encoder-0.1.2-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab8b7d06c6eb48bca2ba59e3a354c966813fa37c6feca7483e2244e9412aee6b |
|
MD5 | ca9620c12cf5d5b828ac4e70d7d16e01 |
|
BLAKE2b-256 | bea3be7a67cbbcf188524ea466bddcd8b22b3139abf6ab7eeef96dc1b183fc1e |
Hashes for quantized_mesh_encoder-0.1.2-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70928c9957378a45a2a09b4d0b43011b1be40778fccc65fde3507838aff19cd9 |
|
MD5 | a0d772d4b31f1e4fc49d634804c24d6e |
|
BLAKE2b-256 | e5e691f5b1e65345118a5537aa5e020d6e19d8dfa894bb3079bdac9c5bedc6bf |
Hashes for quantized_mesh_encoder-0.1.2-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebd62cbe1f58841e08d98756d94acedfaa0a038b759f180e19a2e97d432e33c7 |
|
MD5 | b01e81232b7db64d0b5397d583fba1c2 |
|
BLAKE2b-256 | 8ec3f165ca6c5824bdf58b776c975eaf423100c80f582acaad88e84821a68868 |
Hashes for quantized_mesh_encoder-0.1.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d2af24c26bed76974362fba1855df1d75d213e41d9eb097de767c272b13bf9f |
|
MD5 | a83b29de170c94d877e6021b32286472 |
|
BLAKE2b-256 | ee153c1276e9ace3ba6797047c866c1253b556c0577d73350f1ee8f07196cf08 |
Hashes for quantized_mesh_encoder-0.1.2-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68f01686ab569e4be0d37f81c72d9890c28a0d36db3dd72b3ed80db89670a8b2 |
|
MD5 | 781b6a0b7033b9c7514d82b838e29522 |
|
BLAKE2b-256 | 3c15c5b9de8e1f692f1094335827284db61d04f2e4ba1b3860114c2b7ef39607 |
Hashes for quantized_mesh_encoder-0.1.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4bcc81bf45b10906e411b7514213db9db616f9f8a51ec575a9a73d6079e6fc6 |
|
MD5 | 74d62aa455e600becd8ddc46209d9976 |
|
BLAKE2b-256 | ccfe9759436df423014159e3d96f8a68ba0f44c1da427373a214ef2a88c5810e |
Hashes for quantized_mesh_encoder-0.1.2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8988e00719fdbff52324532b63a3c8a5a5ce09dbf92fb61748575f4628a2fb70 |
|
MD5 | 71c411dbc31db1d272a445f911ecc3a2 |
|
BLAKE2b-256 | 6fb5270a57cf37237eb8cd675bbfa2caaf5005011e802d11f8897720ffa2677f |
Hashes for quantized_mesh_encoder-0.1.2-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2dd686866c64b7b945b1af97259183e9b7153b771decde710fde5fdbe760ad8e |
|
MD5 | e90cf07e61ec0c16a0ccde1d12fbc8d5 |
|
BLAKE2b-256 | bcd5d4d41cd4adf0164bcb1a321a5e2587c7e1bb700aa62ded62790636f60555 |
Hashes for quantized_mesh_encoder-0.1.2-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9db7243cde81e8c2f47dced79aefcf34aba0ccc06209cfa276384bf6a2677c4e |
|
MD5 | ee86045df11b2a79c6232d5c93e556f3 |
|
BLAKE2b-256 | c47fd90ce71ab4baf0ea582999c6c88cfe2535d12f0539fd4308e2c315a4fb6f |
Hashes for quantized_mesh_encoder-0.1.2-cp36-cp36m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f88ee8e5c27e4d3bf723ca7aa25ab531310b9b134d4db2cd7c253a710e4ce180 |
|
MD5 | 7e7c2b8b34bebe1fc170ca25084a5240 |
|
BLAKE2b-256 | 3c648cb29e82ac9cbfe735473ba364fa8c1cd9895009c94b8abdea6941df5372 |
Hashes for quantized_mesh_encoder-0.1.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0075dcabb5d37e373d956e9a9a14f323c304c86920c424c38c4ebf32367710d |
|
MD5 | 547f4a4ff20de054414b66acc35515f2 |
|
BLAKE2b-256 | d81e38f017387a6fb4d0e6eae90ebecfa22a8c99e18ab9c15ec5e900dea21b27 |
Hashes for quantized_mesh_encoder-0.1.2-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a936af8935f57afacf75601fcea9f4c639b8ddad9d0e058a726b660ca9d6376 |
|
MD5 | d6e39d70f58890a38df7c33f747d5840 |
|
BLAKE2b-256 | 64fef68ed442825609bce846a915b0ef60ca6bc7a9b38f74441fdfff0ec659c9 |
Hashes for quantized_mesh_encoder-0.1.2-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 235e14c0c892b2e8809239cba0d492a808a928e97cafe7d899070caa3cc8d4b9 |
|
MD5 | f07ed0e8bf4a2301b8718e3fa65387c1 |
|
BLAKE2b-256 | bdc63ad1d70a2f737ce2aafca45fcf83dc3c591a113fe507a3e98895ddec800b |
Hashes for quantized_mesh_encoder-0.1.2-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44d74e40d685074a8bc8dd45ee3f0605de697244dab8a767ae2a616fc40b3a68 |
|
MD5 | ff187868e6e339bd1fccbd1101c3c785 |
|
BLAKE2b-256 | 74a590f04a40da633b1cbfa31d45d342e9880a998b059af801134b853c9b45ac |
Hashes for quantized_mesh_encoder-0.1.2-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa8c58adf0ff82feaf9c113cca4acb21c14b56ab0f09a7a2f6b479898254fa62 |
|
MD5 | 632f58c718afc3a5fc03b1ab6e4b5900 |
|
BLAKE2b-256 | 17eb5741adbd0b29d93884afe22093773fe2685cbeb6aafb403274759bf83401 |
Hashes for quantized_mesh_encoder-0.1.2-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97cd876379fe72703b13068ad57cce33ab90c379cf77bdc7befba20f794b06fc |
|
MD5 | 14b6710b522ecbd069df72d73ea16d61 |
|
BLAKE2b-256 | c12cf599bc9eef4798765d351da046ffc2ad0710af04ac4b5f86395d8c704149 |
Hashes for quantized_mesh_encoder-0.1.2-cp35-cp35m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa0e86feace54926498c9c8312b5d4bdf60015d2770a43acfc6c7db75ea596ad |
|
MD5 | 9f7e1f530b361173bd6e6e1d672cdd7b |
|
BLAKE2b-256 | c1cbca188caaef9e4795e140a686fa1d5060498c4e1329a2738f960530506b26 |
Hashes for quantized_mesh_encoder-0.1.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddc5d57c211461cc461c694aba040c9b191b4b42fdae2db3d76a4c27e938eba3 |
|
MD5 | 747435ee912d55d18af7e5392d34ba07 |
|
BLAKE2b-256 | 0c68d563be4891d046ea68d11eea04de88f13e8822b550fff26c7a81aadb7eff |
Hashes for quantized_mesh_encoder-0.1.2-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84106bbae2524bd0bfa33f92226a9c553caafba02bce02a61839bf8ff72252f2 |
|
MD5 | 244143d94fb89c4094e69ea0a706ebaa |
|
BLAKE2b-256 | 068c4f46a313c225c9e9c63a504217cdd1e51a83dfdfbf9e77646e9a9664c067 |
Hashes for quantized_mesh_encoder-0.1.2-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9024b3f7afa03a91585a29fb76910abd88306a60fdd57f53e1af5f07f6702f0 |
|
MD5 | 48656937ecbd882cadf722b19846b6ff |
|
BLAKE2b-256 | b487b8bf2de685a104e2583a79072acf271427318427e675ef83ff6f94d58116 |