UNPKG

molstar

Version:

A comprehensive macromolecular library.

45 lines (44 loc) 1.18 kB
/** * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ // http://paulbourke.net/dataformats/ply/ // https://en.wikipedia.org/wiki/PLY_(file_format) export var PlyTypeByteLength = { 'char': 1, 'uchar': 1, 'short': 2, 'ushort': 2, 'int': 4, 'uint': 4, 'float': 4, 'double': 8, 'int8': 1, 'uint8': 1, 'int16': 2, 'uint16': 2, 'int32': 4, 'uint32': 4, 'float32': 4, 'float64': 8 }; export var PlyTypes = new Set(Object.keys(PlyTypeByteLength)); export function PlyType(str) { if (!PlyTypes.has(str)) throw new Error("unknown ply type '".concat(str, "'")); return str; } export function PlyFile(elements, elementNames, comments) { var elementMap = new Map(); for (var i = 0, il = elementNames.length; i < il; ++i) { elementMap.set(elementNames[i], elements[i]); } return { comments: comments, elementNames: elementNames, getElement: function (name) { return elementMap.get(name); } }; }