Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function serialize (CSG, options) {
options && options.statusCallback && options.statusCallback({progress: 0})
CSG = ensureManifoldness(CSG)
const DOMImplementation = typeof document !== 'undefined' ? document.implementation : new xmldom.DOMImplementation()
// materialPolygonLists
// key: a color string (e.g. "0 1 1" for yellow)
// value: an array of strings specifying polygons of this color
// (as space-separated indices into vertexCoords)
var materialPolygonLists = {}
// list of coordinates (as "x y z" strings)
var vertexCoords = []
// map to look up the index in vertexCoords of a given vertex
var vertexTagToCoordIndexMap = {}
CSG.polygons.map(function (p, i) {
var red = 0
var green = 0
var blue = 1 // default color is blue
if (p.shared && p.shared.color) {
let entityContents = objects.map(function (object, i) {
if (isCAG(object)) {
let paths = object.getOutlinePaths()
if (options.cagTo === 'polyline') {
return PathsToPolyine(paths, options)
}
return PathsToLwpolyine(paths, options)
}
if (isCSG(object)) {
object = ensureManifoldness(object)
if (options.csgTo === 'polyline') {
return PolygonsToPolyline(object, options)
}
return PolygonsTo3DFaces(object, options)
}
if (isPath(object)) {
// mimic a CAG outline path
let points = object.getPoints()
let closed = object.isClosed()
let path = {closed: closed, points: points}
return PathsToLwpolyine([path], options)
}
return ''
})
let section = ` 0
let entityContents = objects.map(function (object, i) {
if (isCAG(object)) {
let paths = object.getOutlinePaths()
if (options.cagTo === 'polyline') {
return PathsToPolyine(paths, options)
}
return PathsToLwpolyine(paths, options)
}
if (isCSG(object)) {
object = ensureManifoldness(object)
if (options.csgTo === 'polyline') {
return PolygonsToPolyline(object, options)
}
return PolygonsTo3DFaces(object, options)
}
if (isPath(object)) {
// mimic a CAG outline path
let points = object.getPoints()
let closed = object.isClosed()
let path = {closed: closed, points: points}
return PathsToLwpolyine([path], options)
}
return ''
})
let section = ` 0
function serialize (CSG, m, options) {
options && options.statusCallback && options.statusCallback({progress: 0})
CSG = ensureManifoldness(CSG)
var result = '\n\n'
for (var k in m) {
result += '\n'
}
result += '\n\n\n'
CSG.polygons.map(function (p) { // first we dump all vertices of all polygons
for (var i = 0; i < p.vertices.length; i++) {
result += CSGVertextoAMFString(p.vertices[i])
}
})
result += '\n'
var n = 0
CSG.polygons.map(function (p, i) { // then we dump all polygons
result += '\n'
function serialize (data, options) {
const defaults = {
binary: true
}
options = Object.assign({}, defaults, options)
data = ensureManifoldness(data)
return options.binary ? binarySerializer(data, options) : asciiSerializer(data, options)
}
objects.forEach(function (object, i) {
if (isCSG(object) & object.polygons.length > 0) {
csgs.push(ensureManifoldness(object))
}
})
return options.binary ? serializeBinary(csgs, options) : serializeText(csgs, options)
objects.forEach(function (object, i) {
if (isCSG(object) && object.polygons.length > 0) {
object = ensureManifoldness(object)
options.id = i
contents.push(convertCSG(object, options))
}
})
return contents
objects.forEach(function (object, i) {
if (isCSG(object) && object.polygons.length > 0) {
let data = ensureManifoldness(object)
contents.push(fromCSG(data, options))
}
if (isCAG(object) && object.sides.length > 0) {
contents.push(fromCAG(object, options))
}
options.statusCallback && options.statusCallback({progress: 100 * i / objects.length})
})
objects.forEach(function (object, i) {
options.statusCallback && options.statusCallback({progress: 100 * i / objects.length})
if (isCSG(object) && object.polygons.length > 0) {
object = ensureManifoldness(object)
shapes.push(convertCSG(object, options))
}
})
scene = scene.concat(shapes)