New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@jbroll/jscad-fluent

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jbroll/jscad-fluent - npm Package Compare versions

Comparing version

to
0.2.0

dist/FluentGeom2.d.ts

69

dist/index.d.ts

@@ -1,45 +0,28 @@

import { maths, utils } from '@jscad/modeling';
import Geom2Wrapper from './Geom2Wrapper';
import Geom3Wrapper from './Geom3Wrapper';
import type { Point2, Point3 } from './types';
interface StarOptions {
vertices: number;
outerRadius: number;
innerRadius: number;
}
interface PolyhedronOptions {
points: Point3[];
faces: number[][];
orientation?: 'inward' | 'outward';
}
import { FluentGeom2 } from './FluentGeom2';
import { FluentGeom3 } from './FluentGeom3';
import type { Point2, StarOptions, RectangleOptions, CircleOptions, EllipseOptions, CubeOptions, SphereOptions, CylinderOptions, CylinderEllipticOptions, TorusOptions, SquareOptions } from './types';
/**
* Main entry point for the JSCAD Fluent API.
* Provides factory functions for creating fluent geometry objects.
*/
export declare const jscadFluent: {
rectangle: (options: any) => Geom2Wrapper;
circle: (options: any) => Geom2Wrapper;
ellipse: (options: any) => Geom2Wrapper;
polygon: (points: Point2[]) => Geom2Wrapper;
square: (options: any) => Geom2Wrapper;
star: (options: StarOptions) => Geom2Wrapper;
cube: (options: any) => Geom3Wrapper;
cuboid: (options: any) => Geom3Wrapper;
sphere: (options: any) => Geom3Wrapper;
cylinder: (options: {
radius: number;
height: number;
}) => Geom3Wrapper;
cylinderElliptic: (options: {
height: number;
startRadius: [number, number];
endRadius?: [number, number];
}) => Geom3Wrapper;
torus: (options: {
innerRadius: number;
outerRadius: number;
}) => Geom3Wrapper;
polyhedron: (options: PolyhedronOptions) => Geom3Wrapper;
vec2: typeof maths.vec2;
vec3: typeof maths.vec3;
mat4: typeof maths.mat4;
degToRad: typeof utils.degToRad;
radToDeg: typeof utils.radToDeg;
rectangle(options: RectangleOptions): FluentGeom2;
circle(options: CircleOptions): FluentGeom2;
ellipse(options: EllipseOptions): FluentGeom2;
polygon(points: Point2[]): FluentGeom2;
square(options: SquareOptions): FluentGeom2;
star(options: StarOptions): FluentGeom2;
cube(options: CubeOptions): FluentGeom3;
sphere(options: SphereOptions): FluentGeom3;
cylinder(options: CylinderOptions): FluentGeom3;
cylinderElliptic(options: CylinderEllipticOptions): FluentGeom3;
torus(options: TorusOptions): FluentGeom3;
polyhedron({ points, faces }: {
points: [number, number, number][];
faces: number[][];
}): FluentGeom3;
};
export default jscadFluent;
export { FluentGeom2 } from './FluentGeom2';
export { FluentGeom3 } from './FluentGeom3';
export { FluentGeom2Array } from './FluentGeom2Array';
export { FluentGeom3Array } from './FluentGeom3Array';

@@ -7,14 +7,32 @@ 'use strict';

function _extends() {
return _extends = Object.assign ? Object.assign.bind() : function (n) {
for (var e = 1; e < arguments.length; e++) {
var t = arguments[e];
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
}
return n;
}, _extends.apply(null, arguments);
function _construct(t, e, r) {
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
var o = [null];
o.push.apply(o, e);
var p = new (t.bind.apply(t, o))();
return r && _setPrototypeOf(p, r.prototype), p;
}
function _getPrototypeOf(t) {
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
return t.__proto__ || Object.getPrototypeOf(t);
}, _getPrototypeOf(t);
}
function _inheritsLoose(t, o) {
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
}
function _isNativeFunction(t) {
try {
return -1 !== Function.toString.call(t).indexOf("[native code]");
} catch (n) {
return "function" == typeof t;
}
}
function _isNativeReflectConstruct() {
try {
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
} catch (t) {}
return (_isNativeReflectConstruct = function () {
return !!t;
})();
}
function _setPrototypeOf(t, e) {

@@ -25,338 +43,519 @@ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {

}
function _wrapNativeSuper(t) {
var r = "function" == typeof Map ? new Map() : void 0;
return _wrapNativeSuper = function (t) {
if (null === t || !_isNativeFunction(t)) return t;
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
if (void 0 !== r) {
if (r.has(t)) return r.get(t);
r.set(t, Wrapper);
}
function Wrapper() {
return _construct(t, arguments, _getPrototypeOf(this).constructor);
}
return Wrapper.prototype = Object.create(t.prototype, {
constructor: {
value: Wrapper,
enumerable: !1,
writable: !0,
configurable: !0
}
}), _setPrototypeOf(Wrapper, t);
}, _wrapNativeSuper(t);
}
var TransformWrapper = /*#__PURE__*/function () {
function TransformWrapper(geometry) {
this.geometry = geometry;
var FluentGeometryArray = /*#__PURE__*/function (_Array) {
function FluentGeometryArray() {
var _this;
for (var _len = arguments.length, items = new Array(_len), _key = 0; _key < _len; _key++) {
items[_key] = arguments[_key];
}
_this = _Array.call.apply(_Array, [this].concat(items)) || this;
Object.setPrototypeOf(_this, FluentGeometryArray.prototype);
return _this;
}
var _proto = TransformWrapper.prototype;
_proto.translate = function translate(vec) {
this.geometry = modeling.transforms.translate(vec, this.geometry);
_inheritsLoose(FluentGeometryArray, _Array);
var _proto = FluentGeometryArray.prototype;
_proto.translate = function translate(offset) {
return _construct(FluentGeometryArray, modeling.transforms.translate(offset, this));
};
_proto.translateX = function translateX(offset) {
return _construct(FluentGeometryArray, modeling.transforms.translateX(offset, this));
};
_proto.translateY = function translateY(offset) {
return _construct(FluentGeometryArray, modeling.transforms.translateY(offset, this));
};
_proto.translateZ = function translateZ(offset) {
return _construct(FluentGeometryArray, modeling.transforms.translateZ(offset, this));
};
_proto.rotate = function rotate(angle) {
return _construct(FluentGeometryArray, modeling.transforms.rotate(angle, this));
};
_proto.rotateX = function rotateX(angle) {
return _construct(FluentGeometryArray, modeling.transforms.rotateX(angle, this));
};
_proto.rotateY = function rotateY(angle) {
return _construct(FluentGeometryArray, modeling.transforms.rotateY(angle, this));
};
_proto.rotateZ = function rotateZ(angle) {
return _construct(FluentGeometryArray, modeling.transforms.rotateZ(angle, this));
};
_proto.scale = function scale(factor) {
return _construct(FluentGeometryArray, modeling.transforms.scale(factor, this));
};
_proto.scaleX = function scaleX(factor) {
return _construct(FluentGeometryArray, modeling.transforms.scaleX(factor, this));
};
_proto.scaleY = function scaleY(factor) {
return _construct(FluentGeometryArray, modeling.transforms.scaleY(factor, this));
};
_proto.scaleZ = function scaleZ(factor) {
return _construct(FluentGeometryArray, modeling.transforms.scaleZ(factor, this));
};
_proto.mirror = function mirror(options) {
return _construct(FluentGeometryArray, modeling.transforms.mirror(options, this));
};
_proto.mirrorX = function mirrorX() {
return _construct(FluentGeometryArray, modeling.transforms.mirrorX(this));
};
_proto.mirrorY = function mirrorY() {
return _construct(FluentGeometryArray, modeling.transforms.mirrorY(this));
};
_proto.mirrorZ = function mirrorZ() {
return _construct(FluentGeometryArray, modeling.transforms.mirrorZ(this));
};
_proto.center = function center(axes) {
return _construct(FluentGeometryArray, modeling.transforms.center(axes, this));
};
_proto.centerX = function centerX() {
return _construct(FluentGeometryArray, modeling.transforms.centerX(this));
};
_proto.centerY = function centerY() {
return _construct(FluentGeometryArray, modeling.transforms.centerY(this));
};
_proto.centerZ = function centerZ() {
return _construct(FluentGeometryArray, modeling.transforms.centerZ(this));
};
_proto.transform = function transform(matrix) {
return _construct(FluentGeometryArray, modeling.transforms.transform(matrix, this));
};
_proto.colorize = function colorize(color) {
return _construct(FluentGeometryArray, modeling.colors.colorize(color, this));
};
_proto.toString = function toString() {
return "FluentGeometryArray(" + this.length + ")[" + this.map(function (item) {
return item.toString();
}).join(', ') + "]";
};
return FluentGeometryArray;
}(/*#__PURE__*/_wrapNativeSuper(Array));
var geom3 = modeling.geometries.geom3;
var FluentGeom3 = /*#__PURE__*/function () {
function FluentGeom3(geometry) {
this.type = 'geom3';
Object.assign(this, geometry != null ? geometry : geom3.create());
}
var _proto = FluentGeom3.prototype;
_proto.clone = function clone() {
return new FluentGeom3(geom3.clone(this));
};
_proto.append = function append(geometry) {
return FluentGeom3Array.create(this, geometry);
};
_proto.translate = function translate(offset) {
Object.assign(this, modeling.transforms.translate(offset, this));
return this;
};
_proto.translateX = function translateX(offset) {
this.geometry = modeling.transforms.translateX(offset, this.geometry);
Object.assign(this, modeling.transforms.translateX(offset, this));
return this;
};
_proto.translateY = function translateY(offset) {
this.geometry = modeling.transforms.translateY(offset, this.geometry);
Object.assign(this, modeling.transforms.translateY(offset, this));
return this;
};
_proto.translateZ = function translateZ(offset) {
this.geometry = modeling.transforms.translateZ(offset, this.geometry);
Object.assign(this, modeling.transforms.translateZ(offset, this));
return this;
};
_proto.rotate = function rotate(angle) {
this.geometry = modeling.transforms.rotate(angle, this.geometry);
Object.assign(this, modeling.transforms.rotate(angle, this));
return this;
};
_proto.rotateX = function rotateX(angle) {
this.geometry = modeling.transforms.rotateX(angle, this.geometry);
Object.assign(this, modeling.transforms.rotateX(angle, this));
return this;
};
_proto.rotateY = function rotateY(angle) {
this.geometry = modeling.transforms.rotateY(angle, this.geometry);
Object.assign(this, modeling.transforms.rotateY(angle, this));
return this;
};
_proto.rotateZ = function rotateZ(angle) {
this.geometry = modeling.transforms.rotateZ(angle, this.geometry);
Object.assign(this, modeling.transforms.rotateZ(angle, this));
return this;
};
_proto.scale = function scale(vec) {
this.geometry = modeling.transforms.scale(vec, this.geometry);
_proto.scale = function scale(factor) {
Object.assign(this, modeling.transforms.scale(factor, this));
return this;
};
_proto.scaleX = function scaleX(factor) {
this.geometry = modeling.transforms.scaleX(factor, this.geometry);
Object.assign(this, modeling.transforms.scaleX(factor, this));
return this;
};
_proto.scaleY = function scaleY(factor) {
this.geometry = modeling.transforms.scaleY(factor, this.geometry);
Object.assign(this, modeling.transforms.scaleY(factor, this));
return this;
};
_proto.scaleZ = function scaleZ(factor) {
this.geometry = modeling.transforms.scaleZ(factor, this.geometry);
Object.assign(this, modeling.transforms.scaleZ(factor, this));
return this;
};
_proto.mirror = function mirror(vec) {
this.geometry = modeling.transforms.mirror(vec, this.geometry);
_proto.mirror = function mirror(options) {
Object.assign(this, modeling.transforms.mirror(options, this));
return this;
};
_proto.mirrorX = function mirrorX() {
this.geometry = modeling.transforms.mirrorX(this.geometry);
Object.assign(this, modeling.transforms.mirrorX(this));
return this;
};
_proto.mirrorY = function mirrorY() {
this.geometry = modeling.transforms.mirrorY(this.geometry);
Object.assign(this, modeling.transforms.mirrorY(this));
return this;
};
_proto.mirrorZ = function mirrorZ() {
this.geometry = modeling.transforms.mirrorZ(this.geometry);
Object.assign(this, modeling.transforms.mirrorZ(this));
return this;
};
_proto.center = function center(axes) {
Object.assign(this, modeling.transforms.center(axes, this));
return this;
};
_proto.centerX = function centerX() {
Object.assign(this, modeling.transforms.centerX(this));
return this;
};
_proto.centerY = function centerY() {
Object.assign(this, modeling.transforms.centerY(this));
return this;
};
_proto.centerZ = function centerZ() {
Object.assign(this, modeling.transforms.centerZ(this));
return this;
};
_proto.transform = function transform(matrix) {
this.geometry = modeling.transforms.transform(matrix, this.geometry);
Object.assign(this, modeling.transforms.transform(matrix, this));
return this;
};
return TransformWrapper;
_proto.colorize = function colorize(color) {
Object.assign(this, modeling.colors.colorize(color, this));
return this;
};
_proto.hull = function hull() {
Object.assign(this, modeling.hulls.hull(this));
return this;
};
_proto.hullChain = function hullChain() {
Object.assign(this, modeling.hulls.hullChain(this));
return this;
};
_proto.expand = function expand(options) {
Object.assign(this, modeling.expansions.expand(options, this));
return this;
};
_proto.union = function union(others) {
Object.assign(this, modeling.booleans.union([this, others]));
return this;
};
_proto.subtract = function subtract(others) {
Object.assign(this, modeling.booleans.subtract([this, others]));
return this;
};
_proto.intersect = function intersect(others) {
Object.assign(this, modeling.booleans.intersect([this, others]));
return this;
};
_proto.measureBoundingBox = function measureBoundingBox() {
return modeling.measurements.measureBoundingBox(this);
};
_proto.measureBoundingSphere = function measureBoundingSphere() {
return modeling.measurements.measureBoundingSphere(this);
};
_proto.measureCenter = function measureCenter() {
return modeling.measurements.measureCenter(this);
};
_proto.measureDimensions = function measureDimensions() {
return modeling.measurements.measureDimensions(this);
};
_proto.measureVolume = function measureVolume() {
return modeling.measurements.measureVolume(this);
};
_proto.toPolygons = function toPolygons() {
return geom3.toPolygons(this);
};
_proto.validate = function validate() {
return geom3.validate(this);
};
_proto.toString = function toString() {
return geom3.toString(this);
};
return FluentGeom3;
}();
var GeometryWrapper = /*#__PURE__*/function (_TransformWrapper) {
function GeometryWrapper(geometry) {
return _TransformWrapper.call(this, geometry) || this;
var FluentGeom3Array = /*#__PURE__*/function (_FluentGeometryArray) {
function FluentGeom3Array() {
var _this;
for (var _len = arguments.length, geometries = new Array(_len), _key = 0; _key < _len; _key++) {
geometries[_key] = arguments[_key];
}
_this = _FluentGeometryArray.call.apply(_FluentGeometryArray, [this].concat(geometries)) || this;
Object.setPrototypeOf(_this, FluentGeom3Array.prototype);
return _this;
}
_inheritsLoose(GeometryWrapper, _TransformWrapper);
var _proto = GeometryWrapper.prototype;
_proto.measureBoundingBox = function measureBoundingBox() {
return modeling.measurements.measureBoundingBox(this.geometry);
_inheritsLoose(FluentGeom3Array, _FluentGeometryArray);
FluentGeom3Array.create = function create() {
for (var _len2 = arguments.length, items = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
items[_key2] = arguments[_key2];
}
return _construct(FluentGeom3Array, items);
};
_proto.measureBoundingSphere = function measureBoundingSphere(others) {
if (!others) {
return modeling.measurements.measureBoundingSphere(this.geometry);
var _proto = FluentGeom3Array.prototype;
_proto.append = function append(geometry) {
_FluentGeometryArray.prototype.push.call(this, geometry);
return this;
};
_proto.hull = function hull() {
return new FluentGeom3(modeling.hulls.hull(this));
};
_proto.hullChain = function hullChain() {
return new FluentGeom3(modeling.hulls.hullChain(this));
};
return FluentGeom3Array;
}(FluentGeometryArray);
var FluentGeom2Array = /*#__PURE__*/function (_FluentGeometryArray) {
function FluentGeom2Array() {
var _this;
for (var _len = arguments.length, geometries = new Array(_len), _key = 0; _key < _len; _key++) {
geometries[_key] = arguments[_key];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
_this = _FluentGeometryArray.call.apply(_FluentGeometryArray, [this].concat(geometries)) || this;
Object.setPrototypeOf(_this, FluentGeom2Array.prototype);
return _this;
}
_inheritsLoose(FluentGeom2Array, _FluentGeometryArray);
FluentGeom2Array.create = function create() {
for (var _len2 = arguments.length, items = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
items[_key2] = arguments[_key2];
}
return _construct(FluentGeom2Array, items);
};
var _proto = FluentGeom2Array.prototype;
_proto.append = function append(geometry) {
_FluentGeometryArray.prototype.push.call(this, geometry);
return this;
};
_proto.extrudeLinear = function extrudeLinear(options) {
return FluentGeom3Array.create.apply(FluentGeom3Array, this.map(function (geom) {
return modeling.extrusions.extrudeLinear(options, geom);
}));
return modeling.measurements.measureBoundingSphere(geometries);
};
_proto.measureCenter = function measureCenter() {
return modeling.measurements.measureCenter(this.geometry);
_proto.extrudeRotate = function extrudeRotate(options) {
return FluentGeom3Array.create.apply(FluentGeom3Array, this.map(function (geom) {
return modeling.extrusions.extrudeRotate(options, geom);
}));
};
_proto.measureDimensions = function measureDimensions() {
return modeling.measurements.measureDimensions(this.geometry);
_proto.hull = function hull() {
return new FluentGeom2(modeling.hulls.hull(this));
};
_proto.setColor = function setColor(color) {
var colorSpec = color.length === 3 ? [].concat(color, [1]) : color;
this.geometry = _extends({}, this.geometry, {
color: colorSpec
});
_proto.hullChain = function hullChain() {
return new FluentGeom2(modeling.hulls.hullChain(this));
};
return FluentGeom2Array;
}(FluentGeometryArray);
var geom2 = modeling.geometries.geom2;
var FluentGeom2 = /*#__PURE__*/function () {
function FluentGeom2(geometry) {
this.type = 'geom2';
Object.assign(this, geometry != null ? geometry : geom2.create());
}
var _proto = FluentGeom2.prototype;
_proto.clone = function clone() {
return new FluentGeom2(geom2.clone(this));
};
_proto.append = function append(geometry) {
return FluentGeom2Array.create(this, geometry);
};
_proto.translate = function translate(offset) {
Object.assign(this, modeling.transforms.translate(offset, this));
return this;
};
_proto.center = function center(axes) {
this.geometry = modeling.transforms.center({
axes: axes
}, this.geometry);
_proto.translateX = function translateX(offset) {
Object.assign(this, modeling.transforms.translateX(offset, this));
return this;
};
_proto.centerX = function centerX() {
this.geometry = modeling.transforms.centerX(this.geometry);
_proto.translateY = function translateY(offset) {
Object.assign(this, modeling.transforms.translateY(offset, this));
return this;
};
_proto.centerY = function centerY() {
this.geometry = modeling.transforms.centerY(this.geometry);
_proto.translateZ = function translateZ(offset) {
Object.assign(this, modeling.transforms.translateZ(offset, this));
return this;
};
_proto.centerZ = function centerZ() {
this.geometry = modeling.transforms.centerZ(this.geometry);
_proto.rotate = function rotate(angle) {
Object.assign(this, modeling.transforms.rotate(angle, this));
return this;
};
return GeometryWrapper;
}(TransformWrapper);
var geom3 = modeling.geometries.geom3;
var Geom3Wrapper = /*#__PURE__*/function (_GeometryWrapper) {
function Geom3Wrapper(geometry) {
return _GeometryWrapper.call(this, geometry) || this;
}
_inheritsLoose(Geom3Wrapper, _GeometryWrapper);
var _proto = Geom3Wrapper.prototype;
_proto.measureVolume = function measureVolume() {
return modeling.measurements.measureVolume(this.geometry);
_proto.rotateX = function rotateX(angle) {
Object.assign(this, modeling.transforms.rotateX(angle, this));
return this;
};
_proto.union = function union() {
for (var _len = arguments.length, others = new Array(_len), _key = 0; _key < _len; _key++) {
others[_key] = arguments[_key];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = modeling.booleans.union(geometries);
_proto.rotateY = function rotateY(angle) {
Object.assign(this, modeling.transforms.rotateY(angle, this));
return this;
};
_proto.subtract = function subtract() {
for (var _len2 = arguments.length, others = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
others[_key2] = arguments[_key2];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = modeling.booleans.subtract(geometries);
_proto.rotateZ = function rotateZ(angle) {
Object.assign(this, modeling.transforms.rotateZ(angle, this));
return this;
};
_proto.intersect = function intersect() {
for (var _len3 = arguments.length, others = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
others[_key3] = arguments[_key3];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = modeling.booleans.intersect(geometries);
_proto.scale = function scale(factor) {
Object.assign(this, modeling.transforms.scale(factor, this));
return this;
};
_proto.expand = function expand(delta, corners) {
if (corners === void 0) {
corners = 'round';
}
this.geometry = modeling.expansions.expand({
delta: delta,
corners: corners
}, this.geometry);
_proto.scaleX = function scaleX(factor) {
Object.assign(this, modeling.transforms.scaleX(factor, this));
return this;
};
_proto.offset = function offset(delta) {
var actualDelta = delta + (delta > 0 ? 0.01 : -0.01);
this.geometry = modeling.expansions.offset({
delta: actualDelta
}, this.geometry);
_proto.scaleY = function scaleY(factor) {
Object.assign(this, modeling.transforms.scaleY(factor, this));
return this;
};
_proto.hull = function hull() {
for (var _len4 = arguments.length, others = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
others[_key4] = arguments[_key4];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = modeling.hulls.hull(geometries);
_proto.scaleZ = function scaleZ(factor) {
Object.assign(this, modeling.transforms.scaleZ(factor, this));
return this;
};
_proto.hullChain = function hullChain() {
for (var _len5 = arguments.length, others = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
others[_key5] = arguments[_key5];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = modeling.hulls.hullChain(geometries);
_proto.mirror = function mirror(options) {
Object.assign(this, modeling.transforms.mirror(options, this));
return this;
};
_proto.toPolygons = function toPolygons() {
return geom3.toPolygons(this.geometry);
_proto.mirrorX = function mirrorX() {
Object.assign(this, modeling.transforms.mirrorX(this));
return this;
};
_proto.toString = function toString() {
return geom3.toString(this.geometry);
_proto.mirrorY = function mirrorY() {
Object.assign(this, modeling.transforms.mirrorY(this));
return this;
};
_proto.clone = function clone() {
return new Geom3Wrapper(geom3.clone(this.geometry));
_proto.mirrorZ = function mirrorZ() {
Object.assign(this, modeling.transforms.mirrorZ(this));
return this;
};
_proto.validate = function validate() {
geom3.validate(this.geometry);
_proto.center = function center(axes) {
Object.assign(this, modeling.transforms.center(axes, this));
return this;
};
return Geom3Wrapper;
}(GeometryWrapper);
var geom2 = modeling.geometries.geom2;
var Geom2Wrapper = /*#__PURE__*/function (_GeometryWrapper) {
function Geom2Wrapper(geometry) {
return _GeometryWrapper.call(this, geometry) || this;
}
_inheritsLoose(Geom2Wrapper, _GeometryWrapper);
var _proto = Geom2Wrapper.prototype;
_proto.measureArea = function measureArea() {
return modeling.measurements.measureArea(this.geometry);
_proto.centerX = function centerX() {
Object.assign(this, modeling.transforms.centerX(this));
return this;
};
_proto.extrudeLinear = function extrudeLinear(options) {
var extruded = modeling.extrusions.extrudeLinear(options, this.geometry);
return new Geom3Wrapper(extruded);
_proto.centerY = function centerY() {
Object.assign(this, modeling.transforms.centerY(this));
return this;
};
_proto.extrudeRotate = function extrudeRotate(options) {
var extruded = modeling.extrusions.extrudeRotate(options, this.geometry);
return new Geom3Wrapper(extruded);
_proto.centerZ = function centerZ() {
Object.assign(this, modeling.transforms.centerZ(this));
return this;
};
_proto.union = function union() {
for (var _len = arguments.length, others = new Array(_len), _key = 0; _key < _len; _key++) {
others[_key] = arguments[_key];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = modeling.booleans.union(geometries);
_proto.transform = function transform(matrix) {
Object.assign(this, modeling.transforms.transform(matrix, this));
return this;
};
_proto.subtract = function subtract() {
for (var _len2 = arguments.length, others = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
others[_key2] = arguments[_key2];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = modeling.booleans.subtract(geometries);
_proto.colorize = function colorize(color) {
Object.assign(this, modeling.colors.colorize(color, this));
return this;
};
_proto.intersect = function intersect() {
for (var _len3 = arguments.length, others = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
others[_key3] = arguments[_key3];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = modeling.booleans.intersect(geometries);
_proto.expand = function expand(options) {
Object.assign(this, modeling.expansions.expand(options, this));
return this;
};
_proto.expand = function expand(delta, corners) {
if (corners === void 0) {
corners = 'round';
}
this.geometry = modeling.expansions.expand({
delta: delta,
corners: corners
}, this.geometry);
_proto.offset = function offset(options) {
Object.assign(this, modeling.expansions.offset(options, this));
return this;
};
_proto.offset = function offset(delta) {
this.geometry = modeling.expansions.offset({
delta: delta
}, this.geometry);
_proto.union = function union(others) {
Object.assign(this, modeling.booleans.union([this, others]));
return this;
};
_proto.subtract = function subtract(others) {
Object.assign(this, modeling.booleans.subtract([this, others]));
return this;
};
_proto.intersect = function intersect(others) {
Object.assign(this, modeling.booleans.intersect([this, others]));
return this;
};
_proto.hull = function hull() {
for (var _len4 = arguments.length, others = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
others[_key4] = arguments[_key4];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = modeling.hulls.hull(geometries);
Object.assign(this, modeling.hulls.hull(this));
return this;
};
_proto.hullChain = function hullChain() {
for (var _len5 = arguments.length, others = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
others[_key5] = arguments[_key5];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = modeling.hulls.hullChain(geometries);
Object.assign(this, modeling.hulls.hullChain(this));
return this;
};
_proto.toPoints = function toPoints() {
return geom2.toPoints(this.geometry);
_proto.extrudeLinear = function extrudeLinear(options) {
var extruded = modeling.extrusions.extrudeLinear(options, this);
return new FluentGeom3(extruded);
};
_proto.toString = function toString() {
return geom2.toString(this.geometry);
_proto.extrudeRotate = function extrudeRotate(options) {
var extruded = modeling.extrusions.extrudeRotate(options, this);
return new FluentGeom3(extruded);
};
_proto.clone = function clone() {
return new Geom2Wrapper(geom2.clone(this.geometry));
_proto.measureBoundingBox = function measureBoundingBox() {
return modeling.measurements.measureBoundingBox(this);
};
_proto.validate = function validate() {
geom2.validate(this.geometry);
_proto.measureBoundingSphere = function measureBoundingSphere() {
return modeling.measurements.measureBoundingSphere(this);
};
_proto.measureCenter = function measureCenter() {
return modeling.measurements.measureCenter(this);
};
_proto.measureDimensions = function measureDimensions() {
return modeling.measurements.measureDimensions(this);
};
_proto.measureArea = function measureArea() {
return modeling.measurements.measureArea(this);
};
_proto.toPoints = function toPoints() {
return geom2.toPoints(this);
};
_proto.toOutlines = function toOutlines() {
return geom2.toOutlines(this.geometry);
return geom2.toOutlines(this);
};
return Geom2Wrapper;
}(GeometryWrapper);
_proto.validate = function validate() {
return geom2.validate(this);
};
_proto.toString = function toString() {
return geom2.toString(this);
};
return FluentGeom2;
}();
/**
* Main entry point for the JSCAD Fluent API.
* Provides factory functions for creating fluent geometry objects.
*/
var jscadFluent = {
// 2D primitives
// 2D Primitives
rectangle: function rectangle(options) {
return new Geom2Wrapper(modeling.primitives.rectangle(options));
return new FluentGeom2(modeling.primitives.rectangle(options));
},
circle: function circle(options) {
return new Geom2Wrapper(modeling.primitives.circle(options));
return new FluentGeom2(modeling.primitives.circle(options));
},
ellipse: function ellipse(options) {
return new Geom2Wrapper(modeling.primitives.ellipse(options));
return new FluentGeom2(modeling.primitives.ellipse(options));
},
polygon: function polygon(points) {
return new Geom2Wrapper(modeling.primitives.polygon({
return new FluentGeom2(modeling.primitives.polygon({
points: points

@@ -366,39 +565,38 @@ }));

square: function square(options) {
return new Geom2Wrapper(modeling.primitives.square(options));
return new FluentGeom2(modeling.primitives.square(options));
},
star: function star(options) {
return new Geom2Wrapper(modeling.primitives.star(options));
return new FluentGeom2(modeling.primitives.star(options));
},
// 3D primitives
// 3D Primitives
cube: function cube(options) {
return new Geom3Wrapper(modeling.primitives.cube(options));
return new FluentGeom3(modeling.primitives.cube(options));
},
cuboid: function cuboid(options) {
return new Geom3Wrapper(modeling.primitives.cuboid(options));
},
sphere: function sphere(options) {
return new Geom3Wrapper(modeling.primitives.sphere(options));
return new FluentGeom3(modeling.primitives.sphere(options));
},
cylinder: function cylinder(options) {
return new Geom3Wrapper(modeling.primitives.cylinder(options));
return new FluentGeom3(modeling.primitives.cylinder(options));
},
cylinderElliptic: function cylinderElliptic(options) {
return new Geom3Wrapper(modeling.primitives.cylinderElliptic(options));
return new FluentGeom3(modeling.primitives.cylinderElliptic(options));
},
torus: function torus(options) {
return new Geom3Wrapper(modeling.primitives.torus(options));
return new FluentGeom3(modeling.primitives.torus(options));
},
polyhedron: function polyhedron(options) {
return new Geom3Wrapper(modeling.primitives.polyhedron(options));
},
// Utility functions
vec2: modeling.maths.vec2,
vec3: modeling.maths.vec3,
mat4: modeling.maths.mat4,
degToRad: modeling.utils.degToRad,
radToDeg: modeling.utils.radToDeg
polyhedron: function polyhedron(_ref) {
var points = _ref.points,
faces = _ref.faces;
return new FluentGeom3(modeling.primitives.polyhedron({
points: points,
faces: faces
}));
}
};
exports.default = jscadFluent;
exports.FluentGeom2 = FluentGeom2;
exports.FluentGeom2Array = FluentGeom2Array;
exports.FluentGeom3 = FluentGeom3;
exports.FluentGeom3Array = FluentGeom3Array;
exports.jscadFluent = jscadFluent;
//# sourceMappingURL=jscad-fluent.cjs.development.js.map

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@jscad/modeling");function e(){return(e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(null,arguments)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,function(t,e){(Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}(t,e)}var n=function(n){function o(t){return n.call(this,t)||this}r(o,n);var i=o.prototype;return i.measureBoundingBox=function(){return t.measurements.measureBoundingBox(this.geometry)},i.measureBoundingSphere=function(e){if(!e)return t.measurements.measureBoundingSphere(this.geometry);var r=[this.geometry].concat(e.map((function(t){return t.geometry})));return t.measurements.measureBoundingSphere(r)},i.measureCenter=function(){return t.measurements.measureCenter(this.geometry)},i.measureDimensions=function(){return t.measurements.measureDimensions(this.geometry)},i.setColor=function(t){var r=3===t.length?[].concat(t,[1]):t;return this.geometry=e({},this.geometry,{color:r}),this},i.center=function(e){return this.geometry=t.transforms.center({axes:e},this.geometry),this},i.centerX=function(){return this.geometry=t.transforms.centerX(this.geometry),this},i.centerY=function(){return this.geometry=t.transforms.centerY(this.geometry),this},i.centerZ=function(){return this.geometry=t.transforms.centerZ(this.geometry),this},o}(function(){function e(t){this.geometry=t}var r=e.prototype;return r.translate=function(e){return this.geometry=t.transforms.translate(e,this.geometry),this},r.translateX=function(e){return this.geometry=t.transforms.translateX(e,this.geometry),this},r.translateY=function(e){return this.geometry=t.transforms.translateY(e,this.geometry),this},r.translateZ=function(e){return this.geometry=t.transforms.translateZ(e,this.geometry),this},r.rotate=function(e){return this.geometry=t.transforms.rotate(e,this.geometry),this},r.rotateX=function(e){return this.geometry=t.transforms.rotateX(e,this.geometry),this},r.rotateY=function(e){return this.geometry=t.transforms.rotateY(e,this.geometry),this},r.rotateZ=function(e){return this.geometry=t.transforms.rotateZ(e,this.geometry),this},r.scale=function(e){return this.geometry=t.transforms.scale(e,this.geometry),this},r.scaleX=function(e){return this.geometry=t.transforms.scaleX(e,this.geometry),this},r.scaleY=function(e){return this.geometry=t.transforms.scaleY(e,this.geometry),this},r.scaleZ=function(e){return this.geometry=t.transforms.scaleZ(e,this.geometry),this},r.mirror=function(e){return this.geometry=t.transforms.mirror(e,this.geometry),this},r.mirrorX=function(){return this.geometry=t.transforms.mirrorX(this.geometry),this},r.mirrorY=function(){return this.geometry=t.transforms.mirrorY(this.geometry),this},r.mirrorZ=function(){return this.geometry=t.transforms.mirrorZ(this.geometry),this},r.transform=function(e){return this.geometry=t.transforms.transform(e,this.geometry),this},e}()),o=t.geometries.geom3,i=function(e){function n(t){return e.call(this,t)||this}r(n,e);var i=n.prototype;return i.measureVolume=function(){return t.measurements.measureVolume(this.geometry)},i.union=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o=[this.geometry].concat(r.map((function(t){return t.geometry})));return this.geometry=t.booleans.union(o),this},i.subtract=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o=[this.geometry].concat(r.map((function(t){return t.geometry})));return this.geometry=t.booleans.subtract(o),this},i.intersect=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o=[this.geometry].concat(r.map((function(t){return t.geometry})));return this.geometry=t.booleans.intersect(o),this},i.expand=function(e,r){return void 0===r&&(r="round"),this.geometry=t.expansions.expand({delta:e,corners:r},this.geometry),this},i.offset=function(e){return this.geometry=t.expansions.offset({delta:e+(e>0?.01:-.01)},this.geometry),this},i.hull=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o=[this.geometry].concat(r.map((function(t){return t.geometry})));return this.geometry=t.hulls.hull(o),this},i.hullChain=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o=[this.geometry].concat(r.map((function(t){return t.geometry})));return this.geometry=t.hulls.hullChain(o),this},i.toPolygons=function(){return o.toPolygons(this.geometry)},i.toString=function(){return o.toString(this.geometry)},i.clone=function(){return new n(o.clone(this.geometry))},i.validate=function(){o.validate(this.geometry)},n}(n),s=t.geometries.geom2,u=function(e){function n(t){return e.call(this,t)||this}r(n,e);var o=n.prototype;return o.measureArea=function(){return t.measurements.measureArea(this.geometry)},o.extrudeLinear=function(e){var r=t.extrusions.extrudeLinear(e,this.geometry);return new i(r)},o.extrudeRotate=function(e){var r=t.extrusions.extrudeRotate(e,this.geometry);return new i(r)},o.union=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o=[this.geometry].concat(r.map((function(t){return t.geometry})));return this.geometry=t.booleans.union(o),this},o.subtract=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o=[this.geometry].concat(r.map((function(t){return t.geometry})));return this.geometry=t.booleans.subtract(o),this},o.intersect=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o=[this.geometry].concat(r.map((function(t){return t.geometry})));return this.geometry=t.booleans.intersect(o),this},o.expand=function(e,r){return void 0===r&&(r="round"),this.geometry=t.expansions.expand({delta:e,corners:r},this.geometry),this},o.offset=function(e){return this.geometry=t.expansions.offset({delta:e},this.geometry),this},o.hull=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o=[this.geometry].concat(r.map((function(t){return t.geometry})));return this.geometry=t.hulls.hull(o),this},o.hullChain=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o=[this.geometry].concat(r.map((function(t){return t.geometry})));return this.geometry=t.hulls.hullChain(o),this},o.toPoints=function(){return s.toPoints(this.geometry)},o.toString=function(){return s.toString(this.geometry)},o.clone=function(){return new n(s.clone(this.geometry))},o.validate=function(){s.validate(this.geometry)},o.toOutlines=function(){return s.toOutlines(this.geometry)},n}(n),a={rectangle:function(e){return new u(t.primitives.rectangle(e))},circle:function(e){return new u(t.primitives.circle(e))},ellipse:function(e){return new u(t.primitives.ellipse(e))},polygon:function(e){return new u(t.primitives.polygon({points:e}))},square:function(e){return new u(t.primitives.square(e))},star:function(e){return new u(t.primitives.star(e))},cube:function(e){return new i(t.primitives.cube(e))},cuboid:function(e){return new i(t.primitives.cuboid(e))},sphere:function(e){return new i(t.primitives.sphere(e))},cylinder:function(e){return new i(t.primitives.cylinder(e))},cylinderElliptic:function(e){return new i(t.primitives.cylinderElliptic(e))},torus:function(e){return new i(t.primitives.torus(e))},polyhedron:function(e){return new i(t.primitives.polyhedron(e))},vec2:t.maths.vec2,vec3:t.maths.vec3,mat4:t.maths.mat4,degToRad:t.utils.degToRad,radToDeg:t.utils.radToDeg};exports.default=a,exports.jscadFluent=a;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@jscad/modeling");function n(t,n,r){if(s())return Reflect.construct.apply(null,arguments);var e=[null];e.push.apply(e,n);var o=new(t.bind.apply(t,e));return r&&i(o,r.prototype),o}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function e(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,i(t,n)}function s(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(s=function(){return!!t})()}function i(t,n){return(i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}function o(t){var e="function"==typeof Map?new Map:void 0;return(o=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(n){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,s)}function s(){return n(t,arguments,r(this).constructor)}return s.prototype=Object.create(t.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),i(s,t)})(t)}var u=function(r){function s(){for(var t,n=arguments.length,e=new Array(n),i=0;i<n;i++)e[i]=arguments[i];return t=r.call.apply(r,[this].concat(e))||this,Object.setPrototypeOf(t,s.prototype),t}e(s,r);var i=s.prototype;return i.translate=function(r){return n(s,t.transforms.translate(r,this))},i.translateX=function(r){return n(s,t.transforms.translateX(r,this))},i.translateY=function(r){return n(s,t.transforms.translateY(r,this))},i.translateZ=function(r){return n(s,t.transforms.translateZ(r,this))},i.rotate=function(r){return n(s,t.transforms.rotate(r,this))},i.rotateX=function(r){return n(s,t.transforms.rotateX(r,this))},i.rotateY=function(r){return n(s,t.transforms.rotateY(r,this))},i.rotateZ=function(r){return n(s,t.transforms.rotateZ(r,this))},i.scale=function(r){return n(s,t.transforms.scale(r,this))},i.scaleX=function(r){return n(s,t.transforms.scaleX(r,this))},i.scaleY=function(r){return n(s,t.transforms.scaleY(r,this))},i.scaleZ=function(r){return n(s,t.transforms.scaleZ(r,this))},i.mirror=function(r){return n(s,t.transforms.mirror(r,this))},i.mirrorX=function(){return n(s,t.transforms.mirrorX(this))},i.mirrorY=function(){return n(s,t.transforms.mirrorY(this))},i.mirrorZ=function(){return n(s,t.transforms.mirrorZ(this))},i.center=function(r){return n(s,t.transforms.center(r,this))},i.centerX=function(){return n(s,t.transforms.centerX(this))},i.centerY=function(){return n(s,t.transforms.centerY(this))},i.centerZ=function(){return n(s,t.transforms.centerZ(this))},i.transform=function(r){return n(s,t.transforms.transform(r,this))},i.colorize=function(r){return n(s,t.colors.colorize(r,this))},i.toString=function(){return"FluentGeometryArray("+this.length+")["+this.map((function(t){return t.toString()})).join(", ")+"]"},s}(o(Array)),a=t.geometries.geom3,c=function(){function n(t){this.type="geom3",Object.assign(this,null!=t?t:a.create())}var r=n.prototype;return r.clone=function(){return new n(a.clone(this))},r.append=function(t){return h.create(this,t)},r.translate=function(n){return Object.assign(this,t.transforms.translate(n,this)),this},r.translateX=function(n){return Object.assign(this,t.transforms.translateX(n,this)),this},r.translateY=function(n){return Object.assign(this,t.transforms.translateY(n,this)),this},r.translateZ=function(n){return Object.assign(this,t.transforms.translateZ(n,this)),this},r.rotate=function(n){return Object.assign(this,t.transforms.rotate(n,this)),this},r.rotateX=function(n){return Object.assign(this,t.transforms.rotateX(n,this)),this},r.rotateY=function(n){return Object.assign(this,t.transforms.rotateY(n,this)),this},r.rotateZ=function(n){return Object.assign(this,t.transforms.rotateZ(n,this)),this},r.scale=function(n){return Object.assign(this,t.transforms.scale(n,this)),this},r.scaleX=function(n){return Object.assign(this,t.transforms.scaleX(n,this)),this},r.scaleY=function(n){return Object.assign(this,t.transforms.scaleY(n,this)),this},r.scaleZ=function(n){return Object.assign(this,t.transforms.scaleZ(n,this)),this},r.mirror=function(n){return Object.assign(this,t.transforms.mirror(n,this)),this},r.mirrorX=function(){return Object.assign(this,t.transforms.mirrorX(this)),this},r.mirrorY=function(){return Object.assign(this,t.transforms.mirrorY(this)),this},r.mirrorZ=function(){return Object.assign(this,t.transforms.mirrorZ(this)),this},r.center=function(n){return Object.assign(this,t.transforms.center(n,this)),this},r.centerX=function(){return Object.assign(this,t.transforms.centerX(this)),this},r.centerY=function(){return Object.assign(this,t.transforms.centerY(this)),this},r.centerZ=function(){return Object.assign(this,t.transforms.centerZ(this)),this},r.transform=function(n){return Object.assign(this,t.transforms.transform(n,this)),this},r.colorize=function(n){return Object.assign(this,t.colors.colorize(n,this)),this},r.hull=function(){return Object.assign(this,t.hulls.hull(this)),this},r.hullChain=function(){return Object.assign(this,t.hulls.hullChain(this)),this},r.expand=function(n){return Object.assign(this,t.expansions.expand(n,this)),this},r.union=function(n){return Object.assign(this,t.booleans.union([this,n])),this},r.subtract=function(n){return Object.assign(this,t.booleans.subtract([this,n])),this},r.intersect=function(n){return Object.assign(this,t.booleans.intersect([this,n])),this},r.measureBoundingBox=function(){return t.measurements.measureBoundingBox(this)},r.measureBoundingSphere=function(){return t.measurements.measureBoundingSphere(this)},r.measureCenter=function(){return t.measurements.measureCenter(this)},r.measureDimensions=function(){return t.measurements.measureDimensions(this)},r.measureVolume=function(){return t.measurements.measureVolume(this)},r.toPolygons=function(){return a.toPolygons(this)},r.validate=function(){return a.validate(this)},r.toString=function(){return a.toString(this)},n}(),h=function(r){function s(){for(var t,n=arguments.length,e=new Array(n),i=0;i<n;i++)e[i]=arguments[i];return t=r.call.apply(r,[this].concat(e))||this,Object.setPrototypeOf(t,s.prototype),t}e(s,r),s.create=function(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];return n(s,r)};var i=s.prototype;return i.append=function(t){return r.prototype.push.call(this,t),this},i.hull=function(){return new c(t.hulls.hull(this))},i.hullChain=function(){return new c(t.hulls.hullChain(this))},s}(u),f=function(r){function s(){for(var t,n=arguments.length,e=new Array(n),i=0;i<n;i++)e[i]=arguments[i];return t=r.call.apply(r,[this].concat(e))||this,Object.setPrototypeOf(t,s.prototype),t}e(s,r),s.create=function(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];return n(s,r)};var i=s.prototype;return i.append=function(t){return r.prototype.push.call(this,t),this},i.extrudeLinear=function(n){return h.create.apply(h,this.map((function(r){return t.extrusions.extrudeLinear(n,r)})))},i.extrudeRotate=function(n){return h.create.apply(h,this.map((function(r){return t.extrusions.extrudeRotate(n,r)})))},i.hull=function(){return new m(t.hulls.hull(this))},i.hullChain=function(){return new m(t.hulls.hullChain(this))},s}(u),l=t.geometries.geom2,m=function(){function n(t){this.type="geom2",Object.assign(this,null!=t?t:l.create())}var r=n.prototype;return r.clone=function(){return new n(l.clone(this))},r.append=function(t){return f.create(this,t)},r.translate=function(n){return Object.assign(this,t.transforms.translate(n,this)),this},r.translateX=function(n){return Object.assign(this,t.transforms.translateX(n,this)),this},r.translateY=function(n){return Object.assign(this,t.transforms.translateY(n,this)),this},r.translateZ=function(n){return Object.assign(this,t.transforms.translateZ(n,this)),this},r.rotate=function(n){return Object.assign(this,t.transforms.rotate(n,this)),this},r.rotateX=function(n){return Object.assign(this,t.transforms.rotateX(n,this)),this},r.rotateY=function(n){return Object.assign(this,t.transforms.rotateY(n,this)),this},r.rotateZ=function(n){return Object.assign(this,t.transforms.rotateZ(n,this)),this},r.scale=function(n){return Object.assign(this,t.transforms.scale(n,this)),this},r.scaleX=function(n){return Object.assign(this,t.transforms.scaleX(n,this)),this},r.scaleY=function(n){return Object.assign(this,t.transforms.scaleY(n,this)),this},r.scaleZ=function(n){return Object.assign(this,t.transforms.scaleZ(n,this)),this},r.mirror=function(n){return Object.assign(this,t.transforms.mirror(n,this)),this},r.mirrorX=function(){return Object.assign(this,t.transforms.mirrorX(this)),this},r.mirrorY=function(){return Object.assign(this,t.transforms.mirrorY(this)),this},r.mirrorZ=function(){return Object.assign(this,t.transforms.mirrorZ(this)),this},r.center=function(n){return Object.assign(this,t.transforms.center(n,this)),this},r.centerX=function(){return Object.assign(this,t.transforms.centerX(this)),this},r.centerY=function(){return Object.assign(this,t.transforms.centerY(this)),this},r.centerZ=function(){return Object.assign(this,t.transforms.centerZ(this)),this},r.transform=function(n){return Object.assign(this,t.transforms.transform(n,this)),this},r.colorize=function(n){return Object.assign(this,t.colors.colorize(n,this)),this},r.expand=function(n){return Object.assign(this,t.expansions.expand(n,this)),this},r.offset=function(n){return Object.assign(this,t.expansions.offset(n,this)),this},r.union=function(n){return Object.assign(this,t.booleans.union([this,n])),this},r.subtract=function(n){return Object.assign(this,t.booleans.subtract([this,n])),this},r.intersect=function(n){return Object.assign(this,t.booleans.intersect([this,n])),this},r.hull=function(){return Object.assign(this,t.hulls.hull(this)),this},r.hullChain=function(){return Object.assign(this,t.hulls.hullChain(this)),this},r.extrudeLinear=function(n){var r=t.extrusions.extrudeLinear(n,this);return new c(r)},r.extrudeRotate=function(n){var r=t.extrusions.extrudeRotate(n,this);return new c(r)},r.measureBoundingBox=function(){return t.measurements.measureBoundingBox(this)},r.measureBoundingSphere=function(){return t.measurements.measureBoundingSphere(this)},r.measureCenter=function(){return t.measurements.measureCenter(this)},r.measureDimensions=function(){return t.measurements.measureDimensions(this)},r.measureArea=function(){return t.measurements.measureArea(this)},r.toPoints=function(){return l.toPoints(this)},r.toOutlines=function(){return l.toOutlines(this)},r.validate=function(){return l.validate(this)},r.toString=function(){return l.toString(this)},n}(),p={rectangle:function(n){return new m(t.primitives.rectangle(n))},circle:function(n){return new m(t.primitives.circle(n))},ellipse:function(n){return new m(t.primitives.ellipse(n))},polygon:function(n){return new m(t.primitives.polygon({points:n}))},square:function(n){return new m(t.primitives.square(n))},star:function(n){return new m(t.primitives.star(n))},cube:function(n){return new c(t.primitives.cube(n))},sphere:function(n){return new c(t.primitives.sphere(n))},cylinder:function(n){return new c(t.primitives.cylinder(n))},cylinderElliptic:function(n){return new c(t.primitives.cylinderElliptic(n))},torus:function(n){return new c(t.primitives.torus(n))},polyhedron:function(n){return new c(t.primitives.polyhedron({points:n.points,faces:n.faces}))}};exports.FluentGeom2=m,exports.FluentGeom2Array=f,exports.FluentGeom3=c,exports.FluentGeom3Array=h,exports.jscadFluent=p;
//# sourceMappingURL=jscad-fluent.cjs.production.min.js.map

@@ -1,15 +0,33 @@

import { transforms, measurements, booleans, expansions, hulls, geometries, extrusions, primitives, maths, utils } from '@jscad/modeling';
import { transforms, colors, hulls, expansions, booleans, measurements, geometries, extrusions, primitives } from '@jscad/modeling';
function _extends() {
return _extends = Object.assign ? Object.assign.bind() : function (n) {
for (var e = 1; e < arguments.length; e++) {
var t = arguments[e];
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
}
return n;
}, _extends.apply(null, arguments);
function _construct(t, e, r) {
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
var o = [null];
o.push.apply(o, e);
var p = new (t.bind.apply(t, o))();
return r && _setPrototypeOf(p, r.prototype), p;
}
function _getPrototypeOf(t) {
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
return t.__proto__ || Object.getPrototypeOf(t);
}, _getPrototypeOf(t);
}
function _inheritsLoose(t, o) {
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
}
function _isNativeFunction(t) {
try {
return -1 !== Function.toString.call(t).indexOf("[native code]");
} catch (n) {
return "function" == typeof t;
}
}
function _isNativeReflectConstruct() {
try {
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
} catch (t) {}
return (_isNativeReflectConstruct = function () {
return !!t;
})();
}
function _setPrototypeOf(t, e) {

@@ -20,338 +38,519 @@ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {

}
function _wrapNativeSuper(t) {
var r = "function" == typeof Map ? new Map() : void 0;
return _wrapNativeSuper = function (t) {
if (null === t || !_isNativeFunction(t)) return t;
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
if (void 0 !== r) {
if (r.has(t)) return r.get(t);
r.set(t, Wrapper);
}
function Wrapper() {
return _construct(t, arguments, _getPrototypeOf(this).constructor);
}
return Wrapper.prototype = Object.create(t.prototype, {
constructor: {
value: Wrapper,
enumerable: !1,
writable: !0,
configurable: !0
}
}), _setPrototypeOf(Wrapper, t);
}, _wrapNativeSuper(t);
}
var TransformWrapper = /*#__PURE__*/function () {
function TransformWrapper(geometry) {
this.geometry = geometry;
var FluentGeometryArray = /*#__PURE__*/function (_Array) {
function FluentGeometryArray() {
var _this;
for (var _len = arguments.length, items = new Array(_len), _key = 0; _key < _len; _key++) {
items[_key] = arguments[_key];
}
_this = _Array.call.apply(_Array, [this].concat(items)) || this;
Object.setPrototypeOf(_this, FluentGeometryArray.prototype);
return _this;
}
var _proto = TransformWrapper.prototype;
_proto.translate = function translate(vec) {
this.geometry = transforms.translate(vec, this.geometry);
_inheritsLoose(FluentGeometryArray, _Array);
var _proto = FluentGeometryArray.prototype;
_proto.translate = function translate(offset) {
return _construct(FluentGeometryArray, transforms.translate(offset, this));
};
_proto.translateX = function translateX(offset) {
return _construct(FluentGeometryArray, transforms.translateX(offset, this));
};
_proto.translateY = function translateY(offset) {
return _construct(FluentGeometryArray, transforms.translateY(offset, this));
};
_proto.translateZ = function translateZ(offset) {
return _construct(FluentGeometryArray, transforms.translateZ(offset, this));
};
_proto.rotate = function rotate(angle) {
return _construct(FluentGeometryArray, transforms.rotate(angle, this));
};
_proto.rotateX = function rotateX(angle) {
return _construct(FluentGeometryArray, transforms.rotateX(angle, this));
};
_proto.rotateY = function rotateY(angle) {
return _construct(FluentGeometryArray, transforms.rotateY(angle, this));
};
_proto.rotateZ = function rotateZ(angle) {
return _construct(FluentGeometryArray, transforms.rotateZ(angle, this));
};
_proto.scale = function scale(factor) {
return _construct(FluentGeometryArray, transforms.scale(factor, this));
};
_proto.scaleX = function scaleX(factor) {
return _construct(FluentGeometryArray, transforms.scaleX(factor, this));
};
_proto.scaleY = function scaleY(factor) {
return _construct(FluentGeometryArray, transforms.scaleY(factor, this));
};
_proto.scaleZ = function scaleZ(factor) {
return _construct(FluentGeometryArray, transforms.scaleZ(factor, this));
};
_proto.mirror = function mirror(options) {
return _construct(FluentGeometryArray, transforms.mirror(options, this));
};
_proto.mirrorX = function mirrorX() {
return _construct(FluentGeometryArray, transforms.mirrorX(this));
};
_proto.mirrorY = function mirrorY() {
return _construct(FluentGeometryArray, transforms.mirrorY(this));
};
_proto.mirrorZ = function mirrorZ() {
return _construct(FluentGeometryArray, transforms.mirrorZ(this));
};
_proto.center = function center(axes) {
return _construct(FluentGeometryArray, transforms.center(axes, this));
};
_proto.centerX = function centerX() {
return _construct(FluentGeometryArray, transforms.centerX(this));
};
_proto.centerY = function centerY() {
return _construct(FluentGeometryArray, transforms.centerY(this));
};
_proto.centerZ = function centerZ() {
return _construct(FluentGeometryArray, transforms.centerZ(this));
};
_proto.transform = function transform(matrix) {
return _construct(FluentGeometryArray, transforms.transform(matrix, this));
};
_proto.colorize = function colorize(color) {
return _construct(FluentGeometryArray, colors.colorize(color, this));
};
_proto.toString = function toString() {
return "FluentGeometryArray(" + this.length + ")[" + this.map(function (item) {
return item.toString();
}).join(', ') + "]";
};
return FluentGeometryArray;
}(/*#__PURE__*/_wrapNativeSuper(Array));
var geom3 = geometries.geom3;
var FluentGeom3 = /*#__PURE__*/function () {
function FluentGeom3(geometry) {
this.type = 'geom3';
Object.assign(this, geometry != null ? geometry : geom3.create());
}
var _proto = FluentGeom3.prototype;
_proto.clone = function clone() {
return new FluentGeom3(geom3.clone(this));
};
_proto.append = function append(geometry) {
return FluentGeom3Array.create(this, geometry);
};
_proto.translate = function translate(offset) {
Object.assign(this, transforms.translate(offset, this));
return this;
};
_proto.translateX = function translateX(offset) {
this.geometry = transforms.translateX(offset, this.geometry);
Object.assign(this, transforms.translateX(offset, this));
return this;
};
_proto.translateY = function translateY(offset) {
this.geometry = transforms.translateY(offset, this.geometry);
Object.assign(this, transforms.translateY(offset, this));
return this;
};
_proto.translateZ = function translateZ(offset) {
this.geometry = transforms.translateZ(offset, this.geometry);
Object.assign(this, transforms.translateZ(offset, this));
return this;
};
_proto.rotate = function rotate(angle) {
this.geometry = transforms.rotate(angle, this.geometry);
Object.assign(this, transforms.rotate(angle, this));
return this;
};
_proto.rotateX = function rotateX(angle) {
this.geometry = transforms.rotateX(angle, this.geometry);
Object.assign(this, transforms.rotateX(angle, this));
return this;
};
_proto.rotateY = function rotateY(angle) {
this.geometry = transforms.rotateY(angle, this.geometry);
Object.assign(this, transforms.rotateY(angle, this));
return this;
};
_proto.rotateZ = function rotateZ(angle) {
this.geometry = transforms.rotateZ(angle, this.geometry);
Object.assign(this, transforms.rotateZ(angle, this));
return this;
};
_proto.scale = function scale(vec) {
this.geometry = transforms.scale(vec, this.geometry);
_proto.scale = function scale(factor) {
Object.assign(this, transforms.scale(factor, this));
return this;
};
_proto.scaleX = function scaleX(factor) {
this.geometry = transforms.scaleX(factor, this.geometry);
Object.assign(this, transforms.scaleX(factor, this));
return this;
};
_proto.scaleY = function scaleY(factor) {
this.geometry = transforms.scaleY(factor, this.geometry);
Object.assign(this, transforms.scaleY(factor, this));
return this;
};
_proto.scaleZ = function scaleZ(factor) {
this.geometry = transforms.scaleZ(factor, this.geometry);
Object.assign(this, transforms.scaleZ(factor, this));
return this;
};
_proto.mirror = function mirror(vec) {
this.geometry = transforms.mirror(vec, this.geometry);
_proto.mirror = function mirror(options) {
Object.assign(this, transforms.mirror(options, this));
return this;
};
_proto.mirrorX = function mirrorX() {
this.geometry = transforms.mirrorX(this.geometry);
Object.assign(this, transforms.mirrorX(this));
return this;
};
_proto.mirrorY = function mirrorY() {
this.geometry = transforms.mirrorY(this.geometry);
Object.assign(this, transforms.mirrorY(this));
return this;
};
_proto.mirrorZ = function mirrorZ() {
this.geometry = transforms.mirrorZ(this.geometry);
Object.assign(this, transforms.mirrorZ(this));
return this;
};
_proto.center = function center(axes) {
Object.assign(this, transforms.center(axes, this));
return this;
};
_proto.centerX = function centerX() {
Object.assign(this, transforms.centerX(this));
return this;
};
_proto.centerY = function centerY() {
Object.assign(this, transforms.centerY(this));
return this;
};
_proto.centerZ = function centerZ() {
Object.assign(this, transforms.centerZ(this));
return this;
};
_proto.transform = function transform(matrix) {
this.geometry = transforms.transform(matrix, this.geometry);
Object.assign(this, transforms.transform(matrix, this));
return this;
};
return TransformWrapper;
_proto.colorize = function colorize(color) {
Object.assign(this, colors.colorize(color, this));
return this;
};
_proto.hull = function hull() {
Object.assign(this, hulls.hull(this));
return this;
};
_proto.hullChain = function hullChain() {
Object.assign(this, hulls.hullChain(this));
return this;
};
_proto.expand = function expand(options) {
Object.assign(this, expansions.expand(options, this));
return this;
};
_proto.union = function union(others) {
Object.assign(this, booleans.union([this, others]));
return this;
};
_proto.subtract = function subtract(others) {
Object.assign(this, booleans.subtract([this, others]));
return this;
};
_proto.intersect = function intersect(others) {
Object.assign(this, booleans.intersect([this, others]));
return this;
};
_proto.measureBoundingBox = function measureBoundingBox() {
return measurements.measureBoundingBox(this);
};
_proto.measureBoundingSphere = function measureBoundingSphere() {
return measurements.measureBoundingSphere(this);
};
_proto.measureCenter = function measureCenter() {
return measurements.measureCenter(this);
};
_proto.measureDimensions = function measureDimensions() {
return measurements.measureDimensions(this);
};
_proto.measureVolume = function measureVolume() {
return measurements.measureVolume(this);
};
_proto.toPolygons = function toPolygons() {
return geom3.toPolygons(this);
};
_proto.validate = function validate() {
return geom3.validate(this);
};
_proto.toString = function toString() {
return geom3.toString(this);
};
return FluentGeom3;
}();
var GeometryWrapper = /*#__PURE__*/function (_TransformWrapper) {
function GeometryWrapper(geometry) {
return _TransformWrapper.call(this, geometry) || this;
var FluentGeom3Array = /*#__PURE__*/function (_FluentGeometryArray) {
function FluentGeom3Array() {
var _this;
for (var _len = arguments.length, geometries = new Array(_len), _key = 0; _key < _len; _key++) {
geometries[_key] = arguments[_key];
}
_this = _FluentGeometryArray.call.apply(_FluentGeometryArray, [this].concat(geometries)) || this;
Object.setPrototypeOf(_this, FluentGeom3Array.prototype);
return _this;
}
_inheritsLoose(GeometryWrapper, _TransformWrapper);
var _proto = GeometryWrapper.prototype;
_proto.measureBoundingBox = function measureBoundingBox() {
return measurements.measureBoundingBox(this.geometry);
_inheritsLoose(FluentGeom3Array, _FluentGeometryArray);
FluentGeom3Array.create = function create() {
for (var _len2 = arguments.length, items = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
items[_key2] = arguments[_key2];
}
return _construct(FluentGeom3Array, items);
};
_proto.measureBoundingSphere = function measureBoundingSphere(others) {
if (!others) {
return measurements.measureBoundingSphere(this.geometry);
var _proto = FluentGeom3Array.prototype;
_proto.append = function append(geometry) {
_FluentGeometryArray.prototype.push.call(this, geometry);
return this;
};
_proto.hull = function hull() {
return new FluentGeom3(hulls.hull(this));
};
_proto.hullChain = function hullChain() {
return new FluentGeom3(hulls.hullChain(this));
};
return FluentGeom3Array;
}(FluentGeometryArray);
var FluentGeom2Array = /*#__PURE__*/function (_FluentGeometryArray) {
function FluentGeom2Array() {
var _this;
for (var _len = arguments.length, geometries = new Array(_len), _key = 0; _key < _len; _key++) {
geometries[_key] = arguments[_key];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
_this = _FluentGeometryArray.call.apply(_FluentGeometryArray, [this].concat(geometries)) || this;
Object.setPrototypeOf(_this, FluentGeom2Array.prototype);
return _this;
}
_inheritsLoose(FluentGeom2Array, _FluentGeometryArray);
FluentGeom2Array.create = function create() {
for (var _len2 = arguments.length, items = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
items[_key2] = arguments[_key2];
}
return _construct(FluentGeom2Array, items);
};
var _proto = FluentGeom2Array.prototype;
_proto.append = function append(geometry) {
_FluentGeometryArray.prototype.push.call(this, geometry);
return this;
};
_proto.extrudeLinear = function extrudeLinear(options) {
return FluentGeom3Array.create.apply(FluentGeom3Array, this.map(function (geom) {
return extrusions.extrudeLinear(options, geom);
}));
return measurements.measureBoundingSphere(geometries);
};
_proto.measureCenter = function measureCenter() {
return measurements.measureCenter(this.geometry);
_proto.extrudeRotate = function extrudeRotate(options) {
return FluentGeom3Array.create.apply(FluentGeom3Array, this.map(function (geom) {
return extrusions.extrudeRotate(options, geom);
}));
};
_proto.measureDimensions = function measureDimensions() {
return measurements.measureDimensions(this.geometry);
_proto.hull = function hull() {
return new FluentGeom2(hulls.hull(this));
};
_proto.setColor = function setColor(color) {
var colorSpec = color.length === 3 ? [].concat(color, [1]) : color;
this.geometry = _extends({}, this.geometry, {
color: colorSpec
});
_proto.hullChain = function hullChain() {
return new FluentGeom2(hulls.hullChain(this));
};
return FluentGeom2Array;
}(FluentGeometryArray);
var geom2 = geometries.geom2;
var FluentGeom2 = /*#__PURE__*/function () {
function FluentGeom2(geometry) {
this.type = 'geom2';
Object.assign(this, geometry != null ? geometry : geom2.create());
}
var _proto = FluentGeom2.prototype;
_proto.clone = function clone() {
return new FluentGeom2(geom2.clone(this));
};
_proto.append = function append(geometry) {
return FluentGeom2Array.create(this, geometry);
};
_proto.translate = function translate(offset) {
Object.assign(this, transforms.translate(offset, this));
return this;
};
_proto.center = function center(axes) {
this.geometry = transforms.center({
axes: axes
}, this.geometry);
_proto.translateX = function translateX(offset) {
Object.assign(this, transforms.translateX(offset, this));
return this;
};
_proto.centerX = function centerX() {
this.geometry = transforms.centerX(this.geometry);
_proto.translateY = function translateY(offset) {
Object.assign(this, transforms.translateY(offset, this));
return this;
};
_proto.centerY = function centerY() {
this.geometry = transforms.centerY(this.geometry);
_proto.translateZ = function translateZ(offset) {
Object.assign(this, transforms.translateZ(offset, this));
return this;
};
_proto.centerZ = function centerZ() {
this.geometry = transforms.centerZ(this.geometry);
_proto.rotate = function rotate(angle) {
Object.assign(this, transforms.rotate(angle, this));
return this;
};
return GeometryWrapper;
}(TransformWrapper);
var geom3 = geometries.geom3;
var Geom3Wrapper = /*#__PURE__*/function (_GeometryWrapper) {
function Geom3Wrapper(geometry) {
return _GeometryWrapper.call(this, geometry) || this;
}
_inheritsLoose(Geom3Wrapper, _GeometryWrapper);
var _proto = Geom3Wrapper.prototype;
_proto.measureVolume = function measureVolume() {
return measurements.measureVolume(this.geometry);
_proto.rotateX = function rotateX(angle) {
Object.assign(this, transforms.rotateX(angle, this));
return this;
};
_proto.union = function union() {
for (var _len = arguments.length, others = new Array(_len), _key = 0; _key < _len; _key++) {
others[_key] = arguments[_key];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = booleans.union(geometries);
_proto.rotateY = function rotateY(angle) {
Object.assign(this, transforms.rotateY(angle, this));
return this;
};
_proto.subtract = function subtract() {
for (var _len2 = arguments.length, others = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
others[_key2] = arguments[_key2];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = booleans.subtract(geometries);
_proto.rotateZ = function rotateZ(angle) {
Object.assign(this, transforms.rotateZ(angle, this));
return this;
};
_proto.intersect = function intersect() {
for (var _len3 = arguments.length, others = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
others[_key3] = arguments[_key3];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = booleans.intersect(geometries);
_proto.scale = function scale(factor) {
Object.assign(this, transforms.scale(factor, this));
return this;
};
_proto.expand = function expand(delta, corners) {
if (corners === void 0) {
corners = 'round';
}
this.geometry = expansions.expand({
delta: delta,
corners: corners
}, this.geometry);
_proto.scaleX = function scaleX(factor) {
Object.assign(this, transforms.scaleX(factor, this));
return this;
};
_proto.offset = function offset(delta) {
var actualDelta = delta + (delta > 0 ? 0.01 : -0.01);
this.geometry = expansions.offset({
delta: actualDelta
}, this.geometry);
_proto.scaleY = function scaleY(factor) {
Object.assign(this, transforms.scaleY(factor, this));
return this;
};
_proto.hull = function hull() {
for (var _len4 = arguments.length, others = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
others[_key4] = arguments[_key4];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = hulls.hull(geometries);
_proto.scaleZ = function scaleZ(factor) {
Object.assign(this, transforms.scaleZ(factor, this));
return this;
};
_proto.hullChain = function hullChain() {
for (var _len5 = arguments.length, others = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
others[_key5] = arguments[_key5];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = hulls.hullChain(geometries);
_proto.mirror = function mirror(options) {
Object.assign(this, transforms.mirror(options, this));
return this;
};
_proto.toPolygons = function toPolygons() {
return geom3.toPolygons(this.geometry);
_proto.mirrorX = function mirrorX() {
Object.assign(this, transforms.mirrorX(this));
return this;
};
_proto.toString = function toString() {
return geom3.toString(this.geometry);
_proto.mirrorY = function mirrorY() {
Object.assign(this, transforms.mirrorY(this));
return this;
};
_proto.clone = function clone() {
return new Geom3Wrapper(geom3.clone(this.geometry));
_proto.mirrorZ = function mirrorZ() {
Object.assign(this, transforms.mirrorZ(this));
return this;
};
_proto.validate = function validate() {
geom3.validate(this.geometry);
_proto.center = function center(axes) {
Object.assign(this, transforms.center(axes, this));
return this;
};
return Geom3Wrapper;
}(GeometryWrapper);
var geom2 = geometries.geom2;
var Geom2Wrapper = /*#__PURE__*/function (_GeometryWrapper) {
function Geom2Wrapper(geometry) {
return _GeometryWrapper.call(this, geometry) || this;
}
_inheritsLoose(Geom2Wrapper, _GeometryWrapper);
var _proto = Geom2Wrapper.prototype;
_proto.measureArea = function measureArea() {
return measurements.measureArea(this.geometry);
_proto.centerX = function centerX() {
Object.assign(this, transforms.centerX(this));
return this;
};
_proto.extrudeLinear = function extrudeLinear(options) {
var extruded = extrusions.extrudeLinear(options, this.geometry);
return new Geom3Wrapper(extruded);
_proto.centerY = function centerY() {
Object.assign(this, transforms.centerY(this));
return this;
};
_proto.extrudeRotate = function extrudeRotate(options) {
var extruded = extrusions.extrudeRotate(options, this.geometry);
return new Geom3Wrapper(extruded);
_proto.centerZ = function centerZ() {
Object.assign(this, transforms.centerZ(this));
return this;
};
_proto.union = function union() {
for (var _len = arguments.length, others = new Array(_len), _key = 0; _key < _len; _key++) {
others[_key] = arguments[_key];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = booleans.union(geometries);
_proto.transform = function transform(matrix) {
Object.assign(this, transforms.transform(matrix, this));
return this;
};
_proto.subtract = function subtract() {
for (var _len2 = arguments.length, others = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
others[_key2] = arguments[_key2];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = booleans.subtract(geometries);
_proto.colorize = function colorize(color) {
Object.assign(this, colors.colorize(color, this));
return this;
};
_proto.intersect = function intersect() {
for (var _len3 = arguments.length, others = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
others[_key3] = arguments[_key3];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = booleans.intersect(geometries);
_proto.expand = function expand(options) {
Object.assign(this, expansions.expand(options, this));
return this;
};
_proto.expand = function expand(delta, corners) {
if (corners === void 0) {
corners = 'round';
}
this.geometry = expansions.expand({
delta: delta,
corners: corners
}, this.geometry);
_proto.offset = function offset(options) {
Object.assign(this, expansions.offset(options, this));
return this;
};
_proto.offset = function offset(delta) {
this.geometry = expansions.offset({
delta: delta
}, this.geometry);
_proto.union = function union(others) {
Object.assign(this, booleans.union([this, others]));
return this;
};
_proto.subtract = function subtract(others) {
Object.assign(this, booleans.subtract([this, others]));
return this;
};
_proto.intersect = function intersect(others) {
Object.assign(this, booleans.intersect([this, others]));
return this;
};
_proto.hull = function hull() {
for (var _len4 = arguments.length, others = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
others[_key4] = arguments[_key4];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = hulls.hull(geometries);
Object.assign(this, hulls.hull(this));
return this;
};
_proto.hullChain = function hullChain() {
for (var _len5 = arguments.length, others = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
others[_key5] = arguments[_key5];
}
var geometries = [this.geometry].concat(others.map(function (o) {
return o.geometry;
}));
this.geometry = hulls.hullChain(geometries);
Object.assign(this, hulls.hullChain(this));
return this;
};
_proto.toPoints = function toPoints() {
return geom2.toPoints(this.geometry);
_proto.extrudeLinear = function extrudeLinear(options) {
var extruded = extrusions.extrudeLinear(options, this);
return new FluentGeom3(extruded);
};
_proto.toString = function toString() {
return geom2.toString(this.geometry);
_proto.extrudeRotate = function extrudeRotate(options) {
var extruded = extrusions.extrudeRotate(options, this);
return new FluentGeom3(extruded);
};
_proto.clone = function clone() {
return new Geom2Wrapper(geom2.clone(this.geometry));
_proto.measureBoundingBox = function measureBoundingBox() {
return measurements.measureBoundingBox(this);
};
_proto.validate = function validate() {
geom2.validate(this.geometry);
_proto.measureBoundingSphere = function measureBoundingSphere() {
return measurements.measureBoundingSphere(this);
};
_proto.measureCenter = function measureCenter() {
return measurements.measureCenter(this);
};
_proto.measureDimensions = function measureDimensions() {
return measurements.measureDimensions(this);
};
_proto.measureArea = function measureArea() {
return measurements.measureArea(this);
};
_proto.toPoints = function toPoints() {
return geom2.toPoints(this);
};
_proto.toOutlines = function toOutlines() {
return geom2.toOutlines(this.geometry);
return geom2.toOutlines(this);
};
return Geom2Wrapper;
}(GeometryWrapper);
_proto.validate = function validate() {
return geom2.validate(this);
};
_proto.toString = function toString() {
return geom2.toString(this);
};
return FluentGeom2;
}();
/**
* Main entry point for the JSCAD Fluent API.
* Provides factory functions for creating fluent geometry objects.
*/
var jscadFluent = {
// 2D primitives
// 2D Primitives
rectangle: function rectangle(options) {
return new Geom2Wrapper(primitives.rectangle(options));
return new FluentGeom2(primitives.rectangle(options));
},
circle: function circle(options) {
return new Geom2Wrapper(primitives.circle(options));
return new FluentGeom2(primitives.circle(options));
},
ellipse: function ellipse(options) {
return new Geom2Wrapper(primitives.ellipse(options));
return new FluentGeom2(primitives.ellipse(options));
},
polygon: function polygon(points) {
return new Geom2Wrapper(primitives.polygon({
return new FluentGeom2(primitives.polygon({
points: points

@@ -361,39 +560,34 @@ }));

square: function square(options) {
return new Geom2Wrapper(primitives.square(options));
return new FluentGeom2(primitives.square(options));
},
star: function star(options) {
return new Geom2Wrapper(primitives.star(options));
return new FluentGeom2(primitives.star(options));
},
// 3D primitives
// 3D Primitives
cube: function cube(options) {
return new Geom3Wrapper(primitives.cube(options));
return new FluentGeom3(primitives.cube(options));
},
cuboid: function cuboid(options) {
return new Geom3Wrapper(primitives.cuboid(options));
},
sphere: function sphere(options) {
return new Geom3Wrapper(primitives.sphere(options));
return new FluentGeom3(primitives.sphere(options));
},
cylinder: function cylinder(options) {
return new Geom3Wrapper(primitives.cylinder(options));
return new FluentGeom3(primitives.cylinder(options));
},
cylinderElliptic: function cylinderElliptic(options) {
return new Geom3Wrapper(primitives.cylinderElliptic(options));
return new FluentGeom3(primitives.cylinderElliptic(options));
},
torus: function torus(options) {
return new Geom3Wrapper(primitives.torus(options));
return new FluentGeom3(primitives.torus(options));
},
polyhedron: function polyhedron(options) {
return new Geom3Wrapper(primitives.polyhedron(options));
},
// Utility functions
vec2: maths.vec2,
vec3: maths.vec3,
mat4: maths.mat4,
degToRad: utils.degToRad,
radToDeg: utils.radToDeg
polyhedron: function polyhedron(_ref) {
var points = _ref.points,
faces = _ref.faces;
return new FluentGeom3(primitives.polyhedron({
points: points,
faces: faces
}));
}
};
export default jscadFluent;
export { jscadFluent };
export { FluentGeom2, FluentGeom2Array, FluentGeom3, FluentGeom3Array, jscadFluent };
//# sourceMappingURL=jscad-fluent.esm.js.map
{
"name": "@jbroll/jscad-fluent",
"author": "John Roll",
"version": "0.1.0",
"version": "0.2.0",
"license": "MIT",

@@ -47,15 +47,16 @@ "main": "dist/index.js",

"devDependencies": {
"@jbroll/mustache": "^4.3.1",
"@size-limit/preset-small-lib": "^11.1.6",
"@typescript-eslint/eslint-plugin": "^8.23.0",
"@typescript-eslint/parser": "^8.23.0",
"husky": "^9.1.7",
"npm-check-updates": "^17.1.14",
"size-limit": "^11.1.6",
"tsdx": "^0.14.1",
"tslib": "^2.8.1",
"typescript": "^5.0.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0"
"typescript": "^5.7.3"
},
"dependencies": {
"@jscad/modeling": "^2.12.0"
"@jscad/modeling": "^2.12.5"
}
}

@@ -1,6 +0,8 @@

import { primitives, maths, utils } from '@jscad/modeling';
import Geom2Wrapper from './Geom2Wrapper';
import Geom3Wrapper from './Geom3Wrapper';
import type {
RectangleOptions,
import { primitives } from '@jscad/modeling';
import { FluentGeom2 } from './FluentGeom2';
import { FluentGeom3 } from './FluentGeom3';
import type {
Point2,
StarOptions,
RectangleOptions,
CircleOptions,

@@ -10,68 +12,68 @@ EllipseOptions,

SphereOptions,
Point2,
Point3
CylinderOptions,
CylinderEllipticOptions,
TorusOptions,
SquareOptions
} from './types';
interface StarOptions {
vertices: number;
outerRadius: number;
innerRadius: number;
}
/**
* Main entry point for the JSCAD Fluent API.
* Provides factory functions for creating fluent geometry objects.
*/
export const jscadFluent = {
// 2D Primitives
rectangle(options: RectangleOptions): FluentGeom2 {
return new FluentGeom2(primitives.rectangle(options));
},
interface PolyhedronOptions {
points: Point3[];
faces: number[][];
orientation?: 'inward' | 'outward';
}
circle(options: CircleOptions): FluentGeom2 {
return new FluentGeom2(primitives.circle(options));
},
export const jscadFluent = {
// 2D primitives
rectangle: (options: RectangleOptions): Geom2Wrapper =>
new Geom2Wrapper(primitives.rectangle(options)),
circle: (options: CircleOptions): Geom2Wrapper =>
new Geom2Wrapper(primitives.circle(options)),
ellipse: (options: EllipseOptions): Geom2Wrapper =>
new Geom2Wrapper(primitives.ellipse(options)),
polygon: (points: Point2[]): Geom2Wrapper =>
new Geom2Wrapper(primitives.polygon({ points })),
square: (options: RectangleOptions): Geom2Wrapper =>
new Geom2Wrapper(primitives.square(options)),
star: (options: StarOptions): Geom2Wrapper =>
new Geom2Wrapper(primitives.star(options)),
ellipse(options: EllipseOptions): FluentGeom2 {
return new FluentGeom2(primitives.ellipse(options));
},
// 3D primitives
cube: (options: CubeOptions): Geom3Wrapper =>
new Geom3Wrapper(primitives.cube(options)),
cuboid: (options: CubeOptions): Geom3Wrapper =>
new Geom3Wrapper(primitives.cuboid(options)),
sphere: (options: SphereOptions): Geom3Wrapper =>
new Geom3Wrapper(primitives.sphere(options)),
cylinder: (options: { radius: number; height: number }): Geom3Wrapper =>
new Geom3Wrapper(primitives.cylinder(options)),
cylinderElliptic: (options: { height: number; startRadius: [number, number]; endRadius?: [number, number] }): Geom3Wrapper =>
new Geom3Wrapper(primitives.cylinderElliptic(options)),
torus: (options: { innerRadius: number; outerRadius: number }): Geom3Wrapper =>
new Geom3Wrapper(primitives.torus(options)),
polyhedron: (options: PolyhedronOptions): Geom3Wrapper =>
new Geom3Wrapper(primitives.polyhedron(options)),
polygon(points: Point2[]): FluentGeom2 {
return new FluentGeom2(primitives.polygon({ points }));
},
// Utility functions
vec2: maths.vec2,
vec3: maths.vec3,
mat4: maths.mat4,
degToRad: utils.degToRad,
radToDeg: utils.radToDeg
square(options: SquareOptions): FluentGeom2 {
return new FluentGeom2(primitives.square(options));
},
star(options: StarOptions): FluentGeom2 {
return new FluentGeom2(primitives.star(options));
},
// 3D Primitives
cube(options: CubeOptions): FluentGeom3 {
return new FluentGeom3(primitives.cube(options));
},
sphere(options: SphereOptions): FluentGeom3 {
return new FluentGeom3(primitives.sphere(options));
},
cylinder(options: CylinderOptions): FluentGeom3 {
return new FluentGeom3(primitives.cylinder(options));
},
cylinderElliptic(options: CylinderEllipticOptions): FluentGeom3 {
return new FluentGeom3(primitives.cylinderElliptic(options));
},
torus(options: TorusOptions): FluentGeom3 {
return new FluentGeom3(primitives.torus(options));
},
polyhedron({ points, faces }: { points: [number, number, number][], faces: number[][] }): FluentGeom3 {
return new FluentGeom3(primitives.polyhedron({ points, faces }));
}
};
export default jscadFluent;
// Export classes for advanced usage
export { FluentGeom2 } from './FluentGeom2';
export { FluentGeom3 } from './FluentGeom3';
export { FluentGeom2Array } from './FluentGeom2Array';
export { FluentGeom3Array } from './FluentGeom3Array';

@@ -1,15 +0,51 @@

import { geometries, primitives, maths } from '@jscad/modeling';
import { maths } from '@jscad/modeling';
import type { Geometry } from '@jscad/modeling/src/geometries/types';
import type { ExtrudeLinearOptions, ExtrudeRotateOptions } from '@jscad/modeling/src/operations/extrusions/types';
import type { Geom2, Geom3, Path2 } from '@jscad/modeling/src/geometries/types';
import type { ExtrudeLinearOptions, ExtrudeRotateOptions } from '@jscad/modeling/src/operations/extrusions';
import type { BoundingBox } from '@jscad/modeling/src/measurements/types';
import type {
StarOptions,
RectangleOptions,
CircleOptions,
EllipseOptions,
CubeOptions,
SphereOptions,
CylinderOptions,
CylinderEllipticOptions,
TorusOptions,
SquareOptions
} from '@jscad/modeling/src/primitives';
import type { CenterOptions, MirrorOptions } from '@jscad/modeling/src/operations/transforms';
import { ExpandOptions, OffsetOptions } from '@jscad/modeling/src/operations/expansions';
export type { JSCADGeom2, JSCADGeom3 } from '@jscad/modeling/src/geometries/types';
export type { ExtrudeLinearOptions, ExtrudeRotateOptions } from '@jscad/modeling/src/operations/extrusions';
export type RecursiveArray<T> = Array<T | RecursiveArray<T>>;
import mat4 from '@jscad/modeling/src/maths/mat4';
export { mat4 };
export type Geom2Like = JSCADGeom2 | RecursiveArray<JSCADGeom2>;
export type Geom3Like = JSCADGeom3 | RecursiveArray<JSCADGeom3>;
export type GeometryLike = Geometry | RecursiveArray<Geometry>;
// Re-export JSCAD types that we need
export type {
Geometry,
Geom2,
Geom3,
Path2,
BoundingBox,
CenterOptions,
CircleOptions,
CubeOptions,
CylinderOptions,
CylinderEllipticOptions,
EllipseOptions,
ExpandOptions,
ExtrudeLinearOptions,
ExtrudeRotateOptions,
MirrorOptions,
OffsetOptions,
RectangleOptions,
SphereOptions,
SquareOptions,
StarOptions,
TorusOptions
};
// Re-export vector and matrix types from JSCAD
export type Vec = maths.vec2.Vec;
export type Vec2 = maths.vec2.Vec2;

@@ -19,11 +55,3 @@ export type Vec3 = maths.vec3.Vec3;

// Export base geometry type
export type { Geometry };
// Re-export extrusion types
export type { ExtrudeLinearOptions, ExtrudeRotateOptions };
export type Centroid = [number, number, number]
// Custom types for our wrapper classes
// Common types used throughout the fluent API
export type Point2 = [number, number];

@@ -33,21 +61,6 @@ export type Point3 = [number, number, number];

export type RGBA = [number, number, number, number];
export type AlignOptions = ['min' | 'center' | 'max', 'min' | 'center' | 'max', 'min' | 'center' | 'max'];
export type Corners = 'edge' | 'chamfer' | 'round'
export type Centroid = Point3;
export type Corners = 'edge' | 'chamfer' | 'round';
// Re-export JSCAD's option types
export type {
RectangleOptions,
CircleOptions,
EllipseOptions,
CubeOptions,
SphereOptions
} from '@jscad/modeling/src/primitives/types';
// Type guard functions
export function isGeom2(geom: Geometry): geom is JSCADGeom2 {
return geom.type === 'geom2';
}
export function isGeom3(geom: Geometry): geom is JSCADGeom3 {
return geom.type === 'geom3';
}
// Array type for collections
export type GeometryArray<T extends Geometry> = T[];

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet