trimesh_to_threejson: trimesh_to_threejson

Description Usage Arguments Details Value

View source: R/trimesh_to_threejson.R

Description

Generate threejs model JSON from a triangular mesh.

Usage

1
2
3
trimesh_to_threejson(vertices, face_vertices, colours, face_vertex_colours,
  normals, face_vertex_normals, vertex_uvs, texture_file,
  transparency = 1)

Arguments

vertices

a matrix of vertices with 3 columns corresponding to: x, y, z.

face_vertices

a matrix with 3 columns of faces as defined by their vertices. column 1 is the row index of a vertex in 'vertices', column 2 is a second row index in of a vertex, and so on for column 3, making up three vertices of a triangular face.

colours

a character vector of colours of form: '0x7cccba' (hex)

face_vertex_colours

a matrix with 3 columns of face vertex colour indicies in 'colours', each row corresponds to a face in 'face_vertices'. Row 1, column 1 is the colour index of vertex 1 in face 1.

normals

a 3 column matrix of normal vectors in x, y, z space.

face_vertex_normals

a matrix with 3 columns of face vertex normal indicies in 'normals', each row corresponds to a face in 'face_vertices'. Row 1, column 1 is the normal index of vertex 1 in face 1.

vertex_uvs

A 2 column matrix of texture coordinates, the same length as 'vertices'.

texture_file

An path to an image file.

transparency

A numeric value between 0 and 1 indicating to what degree the model should be transparent. 1.0 is fully opaque, 0 is fully transparent.

Details

The format of threejs model JSON is described here: https://github.com/mrdoob/three.js/wiki/JSON-Model-format-3 In this format each face is described by lists of indicies into lists of vertices, colours and normals. Colours, normals and vertices can be re-used or shared among faces so there are no length requirements on 'vertices', 'colours', or 'normals'. All the 'face_' arguments must have the same length or be not supplied.

Value

JSON describing the mesh.


MilesMcBain/r2vr.gis documentation built on May 24, 2019, 7:52 a.m.