io/x3d-serializer

Serializer of JSCAD geometries to X3D source data (XML).

The serialization of the following geometries are possible.

  • serialization of 3D geometries (geom3) to X3D IndexedTriangleSet (a unique mesh containing coordinates)
  • serialization of 2D geometries (geom2) to X3D Polyline2D
  • serialization of 2D paths (path2) to X3D Polyline2D

Material (color) is added to X3D shapes when found on the geometry.

Source:
Example
const { serializer, mimeType } = require('@jscad/x3d-serializer')

Methods

(static) serialize(options, …objects) → {Array}

Source:

Serialize the give objects to X3D elements (XML).

Example
const geometry = primitives.cube()
const x3dData = serializer({unit: 'meter'}, geometry)
Parameters:
Name Type Attributes Description
options Object

options for serialization, REQUIRED

Properties
Name Type Attributes Default Description
color Array <optional>
[0,0,1,1]

default color for objects

metadata Boolean <optional>
true

add metadata to 3MF contents, such at CreationDate

unit String <optional>
'millimeter'

unit of design; millimeter, inch, feet, meter or micrometer

statusCallback function <optional>

call back function for progress ({ progress: 0-100 })

objects Object | Array <repeatable>

objects to serialize as X3D

Returns:

serialized contents, X3D format (XML)

Type
Array