@xort/cga 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/cga.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import Decimal from 'decimal.js';
2
-
3
1
  declare class Quat {
4
2
  _x: number;
5
3
  _y: number;
@@ -2283,6 +2281,72 @@ declare function simplifyPolygon(points: Vec3[], normal?: Vec3): Vec3[][];
2283
2281
  /** Restore owned geometry from plain data. Never trusts a serialized prototype. */
2284
2282
  declare function geometryFromJSON(data: GeometryData): GeometryQuery<any>;
2285
2283
 
2284
+ /** Decimal arithmetic owned by cga.js: signed BigInt coefficient × 10^exponent. */
2285
+ type DecimalValue = Decimal | string | number | bigint | {
2286
+ toString(): string;
2287
+ };
2288
+ interface DecimalConfig {
2289
+ precision?: number;
2290
+ /** 0 up, 1 down, 2 ceil, 3 floor, 4 half-up, 5 half-down,
2291
+ * 6 half-even, 7 half-ceil, 8 half-floor. */
2292
+ rounding?: number;
2293
+ }
2294
+ /** Finite decimal subset used by HVec3, Robust and CSG.
2295
+ * Constructors preserve input digits; arithmetic rounds to configured significant digits.
2296
+ * Instances are immutable. Unsupported/non-finite inputs and division by zero throw.
2297
+ */
2298
+ declare class Decimal {
2299
+ static precision: number;
2300
+ static rounding: number;
2301
+ static readonly ROUND_UP = 0;
2302
+ static readonly ROUND_DOWN = 1;
2303
+ static readonly ROUND_CEIL = 2;
2304
+ static readonly ROUND_FLOOR = 3;
2305
+ static readonly ROUND_HALF_UP = 4;
2306
+ static readonly ROUND_HALF_DOWN = 5;
2307
+ static readonly ROUND_HALF_EVEN = 6;
2308
+ static readonly ROUND_HALF_CEIL = 7;
2309
+ static readonly ROUND_HALF_FLOOR = 8;
2310
+ private coefficient;
2311
+ private exponent;
2312
+ constructor(value?: DecimalValue);
2313
+ static set(config: DecimalConfig): typeof Decimal;
2314
+ static config(config: DecimalConfig): typeof Decimal;
2315
+ static isDecimal(value: unknown): value is Decimal;
2316
+ private normalize;
2317
+ private static make;
2318
+ add(value: DecimalValue): Decimal;
2319
+ plus(value: DecimalValue): Decimal;
2320
+ sub(value: DecimalValue): Decimal;
2321
+ minus(value: DecimalValue): Decimal;
2322
+ mul(value: DecimalValue): Decimal;
2323
+ times(value: DecimalValue): Decimal;
2324
+ div(value: DecimalValue): Decimal;
2325
+ dividedBy(value: DecimalValue): Decimal;
2326
+ sqrt(): Decimal;
2327
+ negated(): Decimal;
2328
+ neg(): Decimal;
2329
+ abs(): Decimal;
2330
+ comparedTo(value: DecimalValue): number;
2331
+ cmp(value: DecimalValue): number;
2332
+ eq(value: DecimalValue): boolean;
2333
+ equals(value: DecimalValue): boolean;
2334
+ lt(value: DecimalValue): boolean;
2335
+ lte(value: DecimalValue): boolean;
2336
+ gt(value: DecimalValue): boolean;
2337
+ gte(value: DecimalValue): boolean;
2338
+ isZero(): boolean;
2339
+ isNegative(): boolean;
2340
+ isPositive(): boolean;
2341
+ isFinite(): boolean;
2342
+ isNaN(): boolean;
2343
+ toNumber(): number;
2344
+ toString(): string;
2345
+ toFixed(decimalPlaces?: number, rounding?: number): string;
2346
+ toJSON(): string;
2347
+ valueOf(): string;
2348
+ }
2349
+
2286
2350
  interface IHVec2 {
2287
2351
  x: Decimal;
2288
2352
  y: Decimal;
@@ -2298,7 +2362,7 @@ declare class HVec3 implements IHVec3 {
2298
2362
  x: Decimal;
2299
2363
  y: Decimal;
2300
2364
  z: Decimal;
2301
- constructor(x?: Decimal.Value, y?: Decimal.Value, z?: Decimal.Value);
2365
+ constructor(x?: DecimalValue, y?: DecimalValue, z?: DecimalValue);
2302
2366
  static isVec3(v: unknown): v is IHVec3;
2303
2367
  get isVec3(): boolean;
2304
2368
  static get Up(): HVec3;
@@ -2306,9 +2370,9 @@ declare class HVec3 implements IHVec3 {
2306
2370
  static get UnitX(): HVec3;
2307
2371
  static get UnitY(): HVec3;
2308
2372
  static get UnitZ(): HVec3;
2309
- set(x: Decimal.Value, y: Decimal.Value, z: Decimal.Value): this;
2310
- setScalar(s: Decimal.Value): this;
2311
- setComponent(index: number, value: Decimal.Value): this;
2373
+ set(x: DecimalValue, y: DecimalValue, z: DecimalValue): this;
2374
+ setScalar(s: DecimalValue): this;
2375
+ setComponent(index: number, value: DecimalValue): this;
2312
2376
  getComponent(index: number): Decimal;
2313
2377
  copy(v: IHVec3): this;
2314
2378
  clone(): HVec3;
@@ -2316,15 +2380,15 @@ declare class HVec3 implements IHVec3 {
2316
2380
  addVecs(a: IHVec3, b: IHVec3): this;
2317
2381
  sub(v: IHVec3, w?: IHVec3): this;
2318
2382
  subVecs(a: IHVec3, b: IHVec3): this;
2319
- multiplyScalar(s: Decimal.Value): this;
2320
- divideScalar(s: Decimal.Value): this;
2383
+ multiplyScalar(s: DecimalValue): this;
2384
+ divideScalar(s: DecimalValue): this;
2321
2385
  cross(v: IHVec3, w?: IHVec3): this;
2322
2386
  crossVecs(a: IHVec3, b: IHVec3): this;
2323
2387
  dot(v: IHVec3): Decimal;
2324
2388
  lengthSq(): Decimal;
2325
2389
  length(): Decimal;
2326
2390
  normalize(): this;
2327
- lerp(v: IHVec3, alpha: Decimal.Value): this;
2391
+ lerp(v: IHVec3, alpha: DecimalValue): this;
2328
2392
  distanceTo(v: IHVec3): Decimal;
2329
2393
  equals(v: IHVec3): boolean;
2330
2394
  toArray(): Decimal[];
@@ -2333,7 +2397,7 @@ declare class HVec3 implements IHVec3 {
2333
2397
 
2334
2398
  declare class Vec {
2335
2399
  _data: Decimal[];
2336
- constructor(...values: Decimal.Value[]);
2400
+ constructor(...values: DecimalValue[]);
2337
2401
  get dim(): number;
2338
2402
  check(v: Vec): boolean;
2339
2403
  private requireDimension;
@@ -2341,7 +2405,7 @@ declare class Vec {
2341
2405
  clone(): Vec;
2342
2406
  add(v: Vec): this;
2343
2407
  sub(v: Vec): this;
2344
- multiplyScalar(s: Decimal.Value): this;
2408
+ multiplyScalar(s: DecimalValue): this;
2345
2409
  cross(v: Vec): this;
2346
2410
  get extentSq(): Decimal;
2347
2411
  get extent(): Decimal;
@@ -2386,7 +2450,7 @@ declare class Polygon {
2386
2450
  normal: HVec3;
2387
2451
  vertices: HVec3[];
2388
2452
  readonly epsilon: Decimal;
2389
- constructor(vertices?: readonly HVec3[], epsilon?: Decimal.Value);
2453
+ constructor(vertices?: readonly HVec3[], epsilon?: DecimalValue);
2390
2454
  calcPlane(): this;
2391
2455
  flip(): this;
2392
2456
  classifyVertex(v: HVec3): Side.COPLANAR | Side.FRONT | Side.BACK;
@@ -2639,7 +2703,7 @@ declare class Rectangle {
2639
2703
  southeast(result?: Cartographic): Cartographic;
2640
2704
  }
2641
2705
 
2642
- /** Karney geodesics via GeographicLib; antipodal inputs are supported. */
2706
+ /** Internal TypeScript Karney geodesics; antipodal inputs are supported. */
2643
2707
  declare class EllipsoidGeodesic {
2644
2708
  ellipsoid: Ellipsoid;
2645
2709
  start: Cartographic;
@@ -3175,5 +3239,5 @@ declare class DelaunaySlow {
3175
3239
  contains(tri: Vec3[], p: Vec3): number[] | null;
3176
3240
  }
3177
3241
 
3178
- export { ArrayObject, BSP$1 as BSP, BTree, Box, BufferAttribute, BufferGeometry, index_d$2 as CSG, Capsule, Circle, ClipType, Color, ConvexHull, Curve, DEGREES_PER_RADIAN, Delaunator, Delaunay, DelaunaySlow, Disk, Distance, EndType, Euler, EventHandler, Extrude, Float32BufferAttribute, Float64BufferAttribute, Frustum, index_d as GIS, HVec3, index_d$1 as IK, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntersectType, JoinType, KdTree, Line, Mat3, Mat4, MeshTool, ONE_OVER_PI, ONE_OVER_TWO_PI, Orientation, PI, PI_OVER_FOUR, PI_OVER_SIX, PI_OVER_THREE, PI_OVER_TWO, PI_TWO, Path, Plane$1 as Plane, Point, PolyTree, Polygon$1 as Polygon, Polyline, QuadTree, Quat, QuadTree as QuatTree, RADIANS_PER_ARCSECOND, RADIANS_PER_DEGREE, Ray, Rectangle$1 as Rectangle, index_d$3 as Robust, Segment, Shape, Sphere, THREE_PI_OVER_TWO, ToDegrees, Tree, Triangle, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Vec2, Vec3, Vec4, Voronoi, angle, applyMatrix4, applyQuat, approximateEqual, boundingBox, calcCircleFromThreePoint, calculateVolume, ceilPowerOfTwo, circle, circleDistance, clamp, classify, cleanPolygon, clipPolygons, clone, closestPair, compose, convexHull, convexHull3D, delta4, delta5, delta6, delta7, delta8, delta9, disk, diskDistance, distance, euler, extrude, extrudeNext, extrudeToGeometryBuffer, extrude_obsolete, flat, floorPowerOfTwo, forall, geometryFromJSON, intersects, isInOnePlane, isPowerOfTwo, lerp, line, linkSide, linkSides, linkToGeometry, linksToGeometry, m3, m4, offsetPaths, pointsCollinear, projectOnPlane, quat, randFloat, randInt, recognitionPlane, reverseOnPlane, rotate, rotateByUnitVectors, scale, segment, sign, simplifyPointList, simplifyPolygon, smootherstep, smoothstep, splitPlaneGeometry, toFixed, toFixedAry, toGeometryBuffer, toRadians, translate, triangulation, unique, v2, v3, v4, vecs, vectorCompare };
3179
- export type { AxisPlane, CatmullRomOptions, ConvexHull3DResult, CurvedQueryOptions, DistanceParameter, DistanceResult, EventListener, GeometryData, GeometryKind, GeometryQuery, IBufferGeometry, IDistanceResut, IExtrudeOptions, IExtrudeOptionsEx, IExtrudeOptionsNext, IGeometry, IHVec2, IHVec3, IHVec4, ILinkSideOption, ILinkSideOptions, ITriangulationOption, IVec2, IVec3, IVec4, IntersectResult, MeshSplitOptions, PolyNode };
3242
+ export { ArrayObject, BSP$1 as BSP, BTree, Box, BufferAttribute, BufferGeometry, index_d$2 as CSG, Capsule, Circle, ClipType, Color, ConvexHull, Curve, DEGREES_PER_RADIAN, Decimal, Delaunator, Delaunay, DelaunaySlow, Disk, Distance, EndType, Euler, EventHandler, Extrude, Float32BufferAttribute, Float64BufferAttribute, Frustum, index_d as GIS, HVec3, index_d$1 as IK, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntersectType, JoinType, KdTree, Line, Mat3, Mat4, MeshTool, ONE_OVER_PI, ONE_OVER_TWO_PI, Orientation, PI, PI_OVER_FOUR, PI_OVER_SIX, PI_OVER_THREE, PI_OVER_TWO, PI_TWO, Path, Plane$1 as Plane, Point, PolyTree, Polygon$1 as Polygon, Polyline, QuadTree, Quat, QuadTree as QuatTree, RADIANS_PER_ARCSECOND, RADIANS_PER_DEGREE, Ray, Rectangle$1 as Rectangle, index_d$3 as Robust, Segment, Shape, Sphere, THREE_PI_OVER_TWO, ToDegrees, Tree, Triangle, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Vec2, Vec3, Vec4, Voronoi, angle, applyMatrix4, applyQuat, approximateEqual, boundingBox, calcCircleFromThreePoint, calculateVolume, ceilPowerOfTwo, circle, circleDistance, clamp, classify, cleanPolygon, clipPolygons, clone, closestPair, compose, convexHull, convexHull3D, delta4, delta5, delta6, delta7, delta8, delta9, disk, diskDistance, distance, euler, extrude, extrudeNext, extrudeToGeometryBuffer, extrude_obsolete, flat, floorPowerOfTwo, forall, geometryFromJSON, intersects, isInOnePlane, isPowerOfTwo, lerp, line, linkSide, linkSides, linkToGeometry, linksToGeometry, m3, m4, offsetPaths, pointsCollinear, projectOnPlane, quat, randFloat, randInt, recognitionPlane, reverseOnPlane, rotate, rotateByUnitVectors, scale, segment, sign, simplifyPointList, simplifyPolygon, smootherstep, smoothstep, splitPlaneGeometry, toFixed, toFixedAry, toGeometryBuffer, toRadians, translate, triangulation, unique, v2, v3, v4, vecs, vectorCompare };
3243
+ export type { AxisPlane, CatmullRomOptions, ConvexHull3DResult, CurvedQueryOptions, DecimalConfig, DecimalValue, DistanceParameter, DistanceResult, EventListener, GeometryData, GeometryKind, GeometryQuery, IBufferGeometry, IDistanceResut, IExtrudeOptions, IExtrudeOptionsEx, IExtrudeOptionsNext, IGeometry, IHVec2, IHVec3, IHVec4, ILinkSideOption, ILinkSideOptions, ITriangulationOption, IVec2, IVec3, IVec4, IntersectResult, MeshSplitOptions, PolyNode };