Learn R Programming

svgViewR (version 1.4.3)

objToJSON: Converts OBJ to JSON

Description

Converts a mesh file in the OBJ format into the JSON format

Usage

objToJSON(obj, file = NULL)

Value

A JSON object, if file is NULL

Arguments

obj

A filepath to a file of type '.obj' or an 'obj' object, the value returned by the function readOBJ.

file

A filepath to a file of type '.json' where the converted obj object will be saved. If is NULL (default) then no file is written and the JSON object is returned.

Author

Aaron Olsen

Details

This function convert a Wavefront .obj file or OBJ object into a JSON (JavaScript Object Notation) object and optionally saves this JSON object as a .json file. This function was written in order directly convert CT scan meshes exported from Horos into the JSON format for web visualization, eliminating intermediate conversions in programs such as meshlab and Blender. See readOBJ for more details and limitations in .obj file reading.

See Also

readOBJ

Examples

Run this code
if (FALSE) {
# Convert OBJ to JSON file
objToJSON(obj='obj_file.obj', file='json_file.json')

# Convert OBJ to JSON list object
json_list <- objToJSON(obj='obj_file.obj')
}

Run the code above in your browser using DataLab