Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Progressive triangle streams are an implementation of Hugues Hoppe's progressive meshes with minor modifications favoring fast decoding over visual fidelity. The format is flexible and different codecs can choose different strategies for splitting vertices. This module documents progressive triangle streams and implements reference codecs for the binary and JSON formats. The intention of this file format is to provide a basic container format for experimenting with different strategies for performing edge collapses on meshes, and to provide a common language for processing progressive mesh data.
Progressive meshes have two advantages over standard mesh representations like indexed face lists:
Like the PLY file format, 3P files can specify arbitrary vertex and face data. 3P is also a lossless encoding, so attributes like vertex positions are not truncated in intermediate representations. 3P can be combined with standard HTTP compression schemes like gzip for further size reductions.
These reference codecs are installable via npm:
npm install 3p
Once installed, they can be required and used as CommonJS modules.
Note Reference codecs are not optimized.
require('3p/encode-json')(vertexCount, cells[, vertexAttributes, cellAttributes, vertexTypes, cellTypes])
Compresses a triangulated mesh into a JSON formatted progressive triangle stream.
cells
is a list of triangles, each encoded as a list of 3 vertex indicesvertexAttributes
is an optional array of vertex attributescellAttributes
is an optional array of per-face attributesReturns A 3PJ encoded mesh object
require('3p/encode-binary')(vertexCount, cells[, vertexAttributes, cellAttributes, vertexTypes, cellTypes])
Same interface as above, except returns a node.js Buffer object storing a binary 3PB file.
require('3p/decode-json')(json)
Decodes a JSON formatted 3PJ object.
json
is a plain old JavaScript object storing the parsed 3PJ dataReturns An object representing the mesh with with the following properties:
cells
is an array storing the faces of the meshvertexAttributes
is an array of vertex attributescellAttributes
is an array of cell attributesrequire('3p/decode-binary')(buffer)
Same as above, except takes a binary 3PB file instead of JSON.
require('3p/json-to-binary')(json)
Converts a JSON 3PJ file to a binary 3PB buffer
json
is a 3PJ javascript objectReturns A Buffer
representing a binary 3PB
file
require('3p/binary-to-json')(buffer)
Converts a binary 3PB file to a JSON 3PJ object
buffer
is a Buffer
encoding a 3PB objectReturns A JSON 3PJ object
Progressive triangle streams encode 3D triangulated meshes as a sequence of vertex split operations. Progressive triangle streams can have any number of vertex and/or face attributes, and can be truncated to produce approximations of the initial geometry. Progressive triangle streams support two distinct formats: a reference JSON format for debugging and a binary format. These formats store equivalent information.
For debugging purposes, 3P supports a JSON format. The JSON format for a progressive triangle stream contains the same data as above. Each 3P
JSON object has 3 fields with the following data:
version
- a string representing the version of the 3P file in semver formatvertexCount
- the number of vertices in the streamcellCount
- the number of cells in the streamvertexAttributeTypes
- an array of types for each vertex attributecellAttributeTypes
- an array of types for each cell attributecells
- an array of 3 tuples of integers representing the vertex indices for each trianglevertexAttributes
- an array of arrays of vertex attributescellAttributes
- an array of arrays of cell attributesbaseVertex
- the vertex to splitattributes
- attributes for newly created vertexleft
- index of left vertex in 1-ring around base vertexleftOrientation
- orientation of left faceleftAttributes
- attributes for left faceright
- index of right facerightOrientation
- orientation of right facerightAttributes
- attributes for right faceEach type declaration should have the following data:
name
which is an ascii string storing the name of the typecount
which is the size of the type valuetype
a string encoding the type of the attributeThe possible values for type
are as follows:
uint8
an unsigned 8 bit integeruint16
an unsigned 16 bit integeruint32
an unsigned 32 bit integerint8
int16
int32
float32
float64
JSON formatted progressive triangle streams should use the file extension .3PJ
struct S3PBFile {
uint8[4] "3PB\n"
S3PBHeader header
S3PBComplex initialComplex
S3PBVertexSplit[] vertexSplits
}
struct S3PBHeader {
uint32 splitOffset
uint32 majorVersion
uint32 minorVersion
uint32 patchVersion
uint32 vertexCount
uint32 cellCount
uint32 vertexAttributeCount
uint32 cellAttributeCount
S3PBAttribute[] vertexAttributeTypes
S3PBAttribute[] cellAttributeTypes
}
struct S3PBAttribute {
uint32 count
S3PBAttributeType type
uint32 nameLength
char[] name
}
enum S3PBAttributeType: uint32 {
uint8: 0
uint16: 1
uint32: 2
int8: 3
int16: 4
int32: 5
float32: 6
float64: 7
}
struct S3PBComplex {
uint32 initialVertexCount
uint32 initialCellCount
VertexAttribute[] vertexAttributes
uint32[3][] cells
CellAttribute[] cellAttributes
}
struct S3PBVertexSplit {
uint32 baseVertex
uint8 left
uint8 right
VertexAttribute attributes
CellAttribute leftAttributes
CellAttribute rightAttributes
}
S3PBVertexSplit
, the upper bit of left
and right
stores the orientation of the vertexs
cellCount
and vertexCount
should describe the total number of vertices in the stream. If more vertices in the stream are encountered, the decoder may choose to continue processing additional splitsSizes are in bytes
Mesh | JSON | 3p | 3p + gzip |
---|---|---|---|
Stanford bunny | 110361 | 33190 | 27531 |
TODO
Copyright 2014 Mikola Lysenko. MIT license
FAQs
Progressive triangle streams
The npm package 3p receives a total of 2 weekly downloads. As such, 3p popularity was classified as not popular.
We found that 3p demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.