How to use @jscad/io - 10 common examples

To help you get started, we’ve selected a few @jscad/io examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jscad / OpenJSCAD.org / packages / core / code-loading / transformSources.js View on Github external
const transformAmfToJscad = (options, entry) => {
  // console.log('***** transformAmfToJscad',options,entry)
  const deserialize = require('@jscad/io').amfDeSerializer.deserialize
  const source = deserialize(entry.source, entry.name, options)
  return createJscadEntry(entry, source)
}
github jscad / OpenJSCAD.org / packages / core / code-loading / transformSources.js View on Github external
const transformStlToJscad = (options, entry) => {
  // console.log('***** transformStlToJscad',options,entry)
  const deserialize = require('@jscad/io').stlDeSerializer.deserialize
  const source = deserialize(entry.source, entry.name, options)
  return createJscadEntry(entry, source)
}
github jscad / OpenJSCAD.org / packages / core / code-loading / transformSources.js View on Github external
const transformSvgToJscad = (options, entry) => {
  // console.log('***** transformSvgToJscad',options,entry)
  const deserialize = require('@jscad/io').svgDeSerializer.deserialize
  const source = deserialize(entry.source, entry.name, options)
  return createJscadEntry(entry, source)
}
github jscad / OpenJSCAD.org / packages / core / code-loading / transformSources.js View on Github external
const transformObjToJscad = (options, entry) => {
  // console.log('***** transformObjToJscad',options,entry)
  const deserialize = require('@jscad/io').objDeSerializer.deserialize
  const source = deserialize(entry.source, entry.name, options)
  return createJscadEntry(entry, source)
}
github jscad / OpenJSCAD.org / packages / core / code-loading / transformSources.js View on Github external
const transformDxfToJscad = (options, entry) => {
  // console.log('***** transformDxfToJscad',options,entry)
  const deserialize = require('@jscad/io').dxfDeSerializer.deserialize
  const source = deserialize(entry.source, entry.name, options)
  return createJscadEntry(entry, source)
}
github jscad / OpenJSCAD.org / packages / web / src / io / conversionWorker.js View on Github external
var data = e.data
      if ('cache' in data) {
        r.cache = data.cache // forward cache (gMemFS) controls
      }
      if ('baseurl' in data) {
        r.baseurl = data.baseurl
      }
      if ('filename' in data) {
        r.filename = data.filename
        if ('source' in data) {
          var e = data.filename.toLowerCase().match(/\.(\w+)$/i)
          e = RegExp.$1
          const options = {version: data.version}
          switch (e) {
            case 'amf':
              const deserializeAmf = require('@jscad/io').amfDeSerializer.deserialize
              r.source = r.converted = deserializeAmf(data.source, data.filename, options)
              break
            case 'gcode':
              const deserializeGcode = require('@jscad/io').gcodeDeSerializer.deserialize
              r.source = r.converted = deserializeGcode(data.source, data.filename, options)
              break
            case 'obj':
              const deserializeObj = require('@jscad/io').objDeSerializer.deserialize
              r.source = r.converted = deserializeObj(data.source, data.filename, options)
              break
            case 'scad':
              // importScripts(r.baseurl + 'js/lib/csg.js', r.baseurl + 'js/openjscad.js', r.baseurl + 'js/openscad.js', r.baseurl + 'js/lib/underscore.js', r.baseurl + 'js/lib/openscad-openjscad-translator.js')
              r.source = data.source
              if (!r.source.match(/^\/\/!OpenSCAD/i)) {
                r.source = '//!OpenSCAD\n' + data.source
              }
github jscad / OpenJSCAD.org / packages / web / src / io / conversionWorker.js View on Github external
break
            case 'obj':
              const deserializeObj = require('@jscad/io').objDeSerializer.deserialize
              r.source = r.converted = deserializeObj(data.source, data.filename, options)
              break
            case 'scad':
              // importScripts(r.baseurl + 'js/lib/csg.js', r.baseurl + 'js/openjscad.js', r.baseurl + 'js/openscad.js', r.baseurl + 'js/lib/underscore.js', r.baseurl + 'js/lib/openscad-openjscad-translator.js')
              r.source = data.source
              if (!r.source.match(/^\/\/!OpenSCAD/i)) {
                r.source = '//!OpenSCAD\n' + data.source
              }
              const openscadOpenJscadParser = require('@jscad/openscad-openjscad-translator')
              r.converted = openscadOpenJscadParser.parse(r.source)
              break
            case 'stl':
              const deserializeStl = require('@jscad/io').stlDeSerializer.deserialize
              r.source = r.converted = deserializeStl(data.source, data.filename, options)
              break
            case 'js':
              r.source = r.converted = data.source
              break
            case 'jscad':
              r.source = r.converted = data.source
              break
            case 'svg':
              const deserializeSvg = require('@jscad/io').svgDeSerializer.deserialize
              r.source = r.converted = deserializeSvg(data.source, data.filename, options)
              break
            case 'json':
              const deserializeJson = require('@jscad/io').jsonDeSerializer.deserialize
              r.source = r.converted = deserializeJson(data.source, data.filename, options)
              break
github jscad / OpenJSCAD.org / packages / core / io / prepareOutput.js View on Github external
      serialize: data => stlSerializer.serialize(data, {binary: false})
    }, // CSG to STL ASCII
github jscad / OpenJSCAD.org / packages / core / io / prepareOutput.js View on Github external
      serialize: (options, data) => stlSerializer.serialize(Object.assign({}, { binary: false }, options), data)
    }, // Geom3 to STL ASCII
github jscad / jscad-desktop / src / core / io / prepareOutput.js View on Github external
      serialize: data => stlSerializer.serialize(data, {binary: false})
    }, // CSG to STL ASCII