meta data for this page
  •  

This is an old revision of the document!


Shape Transformations

The 'transforms' are accessed through the modeling API using the following:

const { translate, scale, rotateX } = require('@jscad/modeling').transforms

The 'transforms' return a single shape or an array of shapes depending on the given shapes.

const newshape = align({modes: ['none', 'center', 'none']}, oldshape)  /* Returns a single shape */
const newshapes = align({modes: ['min', 'center', 'none'], alignTo: [10, null, 10], grouped: true }, oldshape, [oldshape0, oldshape1])  /* Returns an array of new shapes*/
Transform Notes
const newshape = align({modes: ['min', 'center', 'none'], alignTo: [10, null, 10], grouped: true}, oldshape) API
const newshape = center({axes: [true, true, false], center: [15, 10, 0]}, oldshape) API
const newshape = centerX(oldshape) API
const newshape = centerY(oldshape) API
const newshape = centerZ(oldshape) API
const newshape = mirror({origin: [5, 5, 5], normal: [0, 0, 10]}, oldshape)) API
const newshape = mirrorX(oldshape) API
const newshape = mirrorY(oldshape) API
const newshape = mirrorZ(oldshape) API
const newshape = rotate([Math.PI / 4, 0, 0], oldshape) API
const newshape = rotateX(oldshape) API
const newshape = rotateY(oldshape) API
const newshape = rotateZ(oldshape) API
const newshape = scale([5, 0, 10], oldshape) API
const newshape = scaleX(5, oldshape) API
const newshape = scaleY(0.5, oldshape) API
const newshape = scaleZ(5, oldshape) API
const newshape = transform(mat4.rotateX(Math.PI/4), oldshape) API