@xort/cga 0.1.2 → 0.1.4

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/dist/three.d.cts CHANGED
@@ -4,7 +4,6 @@ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
4
4
  import { TransformControls } from 'three/addons/controls/TransformControls.js';
5
5
  import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
6
6
  import { Pass } from 'three/addons/postprocessing/Pass.js';
7
- import Decimal from 'decimal.js';
8
7
 
9
8
  type EventListener<T = unknown> = (data: T) => void;
10
9
  declare class EventHandler<Events extends object = Record<string, unknown>> {
@@ -204,6 +203,72 @@ declare const DiamondShader: {
204
203
  side: 2;
205
204
  };
206
205
 
206
+ /** Decimal arithmetic owned by cga.js: signed BigInt coefficient × 10^exponent. */
207
+ type DecimalValue = Decimal | string | number | bigint | {
208
+ toString(): string;
209
+ };
210
+ interface DecimalConfig {
211
+ precision?: number;
212
+ /** 0 up, 1 down, 2 ceil, 3 floor, 4 half-up, 5 half-down,
213
+ * 6 half-even, 7 half-ceil, 8 half-floor. */
214
+ rounding?: number;
215
+ }
216
+ /** Finite decimal subset used by HVec3, Robust and CSG.
217
+ * Constructors preserve input digits; arithmetic rounds to configured significant digits.
218
+ * Instances are immutable. Unsupported/non-finite inputs and division by zero throw.
219
+ */
220
+ declare class Decimal {
221
+ static precision: number;
222
+ static rounding: number;
223
+ static readonly ROUND_UP = 0;
224
+ static readonly ROUND_DOWN = 1;
225
+ static readonly ROUND_CEIL = 2;
226
+ static readonly ROUND_FLOOR = 3;
227
+ static readonly ROUND_HALF_UP = 4;
228
+ static readonly ROUND_HALF_DOWN = 5;
229
+ static readonly ROUND_HALF_EVEN = 6;
230
+ static readonly ROUND_HALF_CEIL = 7;
231
+ static readonly ROUND_HALF_FLOOR = 8;
232
+ private coefficient;
233
+ private exponent;
234
+ constructor(value?: DecimalValue);
235
+ static set(config: DecimalConfig): typeof Decimal;
236
+ static config(config: DecimalConfig): typeof Decimal;
237
+ static isDecimal(value: unknown): value is Decimal;
238
+ private normalize;
239
+ private static make;
240
+ add(value: DecimalValue): Decimal;
241
+ plus(value: DecimalValue): Decimal;
242
+ sub(value: DecimalValue): Decimal;
243
+ minus(value: DecimalValue): Decimal;
244
+ mul(value: DecimalValue): Decimal;
245
+ times(value: DecimalValue): Decimal;
246
+ div(value: DecimalValue): Decimal;
247
+ dividedBy(value: DecimalValue): Decimal;
248
+ sqrt(): Decimal;
249
+ negated(): Decimal;
250
+ neg(): Decimal;
251
+ abs(): Decimal;
252
+ comparedTo(value: DecimalValue): number;
253
+ cmp(value: DecimalValue): number;
254
+ eq(value: DecimalValue): boolean;
255
+ equals(value: DecimalValue): boolean;
256
+ lt(value: DecimalValue): boolean;
257
+ lte(value: DecimalValue): boolean;
258
+ gt(value: DecimalValue): boolean;
259
+ gte(value: DecimalValue): boolean;
260
+ isZero(): boolean;
261
+ isNegative(): boolean;
262
+ isPositive(): boolean;
263
+ isFinite(): boolean;
264
+ isNaN(): boolean;
265
+ toNumber(): number;
266
+ toString(): string;
267
+ toFixed(decimalPlaces?: number, rounding?: number): string;
268
+ toJSON(): string;
269
+ valueOf(): string;
270
+ }
271
+
207
272
  interface IHVec2 {
208
273
  x: Decimal;
209
274
  y: Decimal;
@@ -216,7 +281,7 @@ declare class HVec3 implements IHVec3 {
216
281
  x: Decimal;
217
282
  y: Decimal;
218
283
  z: Decimal;
219
- constructor(x?: Decimal.Value, y?: Decimal.Value, z?: Decimal.Value);
284
+ constructor(x?: DecimalValue, y?: DecimalValue, z?: DecimalValue);
220
285
  static isVec3(v: unknown): v is IHVec3;
221
286
  get isVec3(): boolean;
222
287
  static get Up(): HVec3;
@@ -224,9 +289,9 @@ declare class HVec3 implements IHVec3 {
224
289
  static get UnitX(): HVec3;
225
290
  static get UnitY(): HVec3;
226
291
  static get UnitZ(): HVec3;
227
- set(x: Decimal.Value, y: Decimal.Value, z: Decimal.Value): this;
228
- setScalar(s: Decimal.Value): this;
229
- setComponent(index: number, value: Decimal.Value): this;
292
+ set(x: DecimalValue, y: DecimalValue, z: DecimalValue): this;
293
+ setScalar(s: DecimalValue): this;
294
+ setComponent(index: number, value: DecimalValue): this;
230
295
  getComponent(index: number): Decimal;
231
296
  copy(v: IHVec3): this;
232
297
  clone(): HVec3;
@@ -234,15 +299,15 @@ declare class HVec3 implements IHVec3 {
234
299
  addVecs(a: IHVec3, b: IHVec3): this;
235
300
  sub(v: IHVec3, w?: IHVec3): this;
236
301
  subVecs(a: IHVec3, b: IHVec3): this;
237
- multiplyScalar(s: Decimal.Value): this;
238
- divideScalar(s: Decimal.Value): this;
302
+ multiplyScalar(s: DecimalValue): this;
303
+ divideScalar(s: DecimalValue): this;
239
304
  cross(v: IHVec3, w?: IHVec3): this;
240
305
  crossVecs(a: IHVec3, b: IHVec3): this;
241
306
  dot(v: IHVec3): Decimal;
242
307
  lengthSq(): Decimal;
243
308
  length(): Decimal;
244
309
  normalize(): this;
245
- lerp(v: IHVec3, alpha: Decimal.Value): this;
310
+ lerp(v: IHVec3, alpha: DecimalValue): this;
246
311
  distanceTo(v: IHVec3): Decimal;
247
312
  equals(v: IHVec3): boolean;
248
313
  toArray(): Decimal[];
@@ -260,7 +325,7 @@ declare class Polygon {
260
325
  normal: HVec3;
261
326
  vertices: HVec3[];
262
327
  readonly epsilon: Decimal;
263
- constructor(vertices?: readonly HVec3[], epsilon?: Decimal.Value);
328
+ constructor(vertices?: readonly HVec3[], epsilon?: DecimalValue);
264
329
  calcPlane(): this;
265
330
  flip(): this;
266
331
  classifyVertex(v: HVec3): Side.COPLANAR | Side.FRONT | Side.BACK;
package/dist/three.d.ts CHANGED
@@ -4,7 +4,6 @@ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
4
4
  import { TransformControls } from 'three/addons/controls/TransformControls.js';
5
5
  import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
6
6
  import { Pass } from 'three/addons/postprocessing/Pass.js';
7
- import Decimal from 'decimal.js';
8
7
 
9
8
  type EventListener<T = unknown> = (data: T) => void;
10
9
  declare class EventHandler<Events extends object = Record<string, unknown>> {
@@ -204,6 +203,72 @@ declare const DiamondShader: {
204
203
  side: 2;
205
204
  };
206
205
 
206
+ /** Decimal arithmetic owned by cga.js: signed BigInt coefficient × 10^exponent. */
207
+ type DecimalValue = Decimal | string | number | bigint | {
208
+ toString(): string;
209
+ };
210
+ interface DecimalConfig {
211
+ precision?: number;
212
+ /** 0 up, 1 down, 2 ceil, 3 floor, 4 half-up, 5 half-down,
213
+ * 6 half-even, 7 half-ceil, 8 half-floor. */
214
+ rounding?: number;
215
+ }
216
+ /** Finite decimal subset used by HVec3, Robust and CSG.
217
+ * Constructors preserve input digits; arithmetic rounds to configured significant digits.
218
+ * Instances are immutable. Unsupported/non-finite inputs and division by zero throw.
219
+ */
220
+ declare class Decimal {
221
+ static precision: number;
222
+ static rounding: number;
223
+ static readonly ROUND_UP = 0;
224
+ static readonly ROUND_DOWN = 1;
225
+ static readonly ROUND_CEIL = 2;
226
+ static readonly ROUND_FLOOR = 3;
227
+ static readonly ROUND_HALF_UP = 4;
228
+ static readonly ROUND_HALF_DOWN = 5;
229
+ static readonly ROUND_HALF_EVEN = 6;
230
+ static readonly ROUND_HALF_CEIL = 7;
231
+ static readonly ROUND_HALF_FLOOR = 8;
232
+ private coefficient;
233
+ private exponent;
234
+ constructor(value?: DecimalValue);
235
+ static set(config: DecimalConfig): typeof Decimal;
236
+ static config(config: DecimalConfig): typeof Decimal;
237
+ static isDecimal(value: unknown): value is Decimal;
238
+ private normalize;
239
+ private static make;
240
+ add(value: DecimalValue): Decimal;
241
+ plus(value: DecimalValue): Decimal;
242
+ sub(value: DecimalValue): Decimal;
243
+ minus(value: DecimalValue): Decimal;
244
+ mul(value: DecimalValue): Decimal;
245
+ times(value: DecimalValue): Decimal;
246
+ div(value: DecimalValue): Decimal;
247
+ dividedBy(value: DecimalValue): Decimal;
248
+ sqrt(): Decimal;
249
+ negated(): Decimal;
250
+ neg(): Decimal;
251
+ abs(): Decimal;
252
+ comparedTo(value: DecimalValue): number;
253
+ cmp(value: DecimalValue): number;
254
+ eq(value: DecimalValue): boolean;
255
+ equals(value: DecimalValue): boolean;
256
+ lt(value: DecimalValue): boolean;
257
+ lte(value: DecimalValue): boolean;
258
+ gt(value: DecimalValue): boolean;
259
+ gte(value: DecimalValue): boolean;
260
+ isZero(): boolean;
261
+ isNegative(): boolean;
262
+ isPositive(): boolean;
263
+ isFinite(): boolean;
264
+ isNaN(): boolean;
265
+ toNumber(): number;
266
+ toString(): string;
267
+ toFixed(decimalPlaces?: number, rounding?: number): string;
268
+ toJSON(): string;
269
+ valueOf(): string;
270
+ }
271
+
207
272
  interface IHVec2 {
208
273
  x: Decimal;
209
274
  y: Decimal;
@@ -216,7 +281,7 @@ declare class HVec3 implements IHVec3 {
216
281
  x: Decimal;
217
282
  y: Decimal;
218
283
  z: Decimal;
219
- constructor(x?: Decimal.Value, y?: Decimal.Value, z?: Decimal.Value);
284
+ constructor(x?: DecimalValue, y?: DecimalValue, z?: DecimalValue);
220
285
  static isVec3(v: unknown): v is IHVec3;
221
286
  get isVec3(): boolean;
222
287
  static get Up(): HVec3;
@@ -224,9 +289,9 @@ declare class HVec3 implements IHVec3 {
224
289
  static get UnitX(): HVec3;
225
290
  static get UnitY(): HVec3;
226
291
  static get UnitZ(): HVec3;
227
- set(x: Decimal.Value, y: Decimal.Value, z: Decimal.Value): this;
228
- setScalar(s: Decimal.Value): this;
229
- setComponent(index: number, value: Decimal.Value): this;
292
+ set(x: DecimalValue, y: DecimalValue, z: DecimalValue): this;
293
+ setScalar(s: DecimalValue): this;
294
+ setComponent(index: number, value: DecimalValue): this;
230
295
  getComponent(index: number): Decimal;
231
296
  copy(v: IHVec3): this;
232
297
  clone(): HVec3;
@@ -234,15 +299,15 @@ declare class HVec3 implements IHVec3 {
234
299
  addVecs(a: IHVec3, b: IHVec3): this;
235
300
  sub(v: IHVec3, w?: IHVec3): this;
236
301
  subVecs(a: IHVec3, b: IHVec3): this;
237
- multiplyScalar(s: Decimal.Value): this;
238
- divideScalar(s: Decimal.Value): this;
302
+ multiplyScalar(s: DecimalValue): this;
303
+ divideScalar(s: DecimalValue): this;
239
304
  cross(v: IHVec3, w?: IHVec3): this;
240
305
  crossVecs(a: IHVec3, b: IHVec3): this;
241
306
  dot(v: IHVec3): Decimal;
242
307
  lengthSq(): Decimal;
243
308
  length(): Decimal;
244
309
  normalize(): this;
245
- lerp(v: IHVec3, alpha: Decimal.Value): this;
310
+ lerp(v: IHVec3, alpha: DecimalValue): this;
246
311
  distanceTo(v: IHVec3): Decimal;
247
312
  equals(v: IHVec3): boolean;
248
313
  toArray(): Decimal[];
@@ -260,7 +325,7 @@ declare class Polygon {
260
325
  normal: HVec3;
261
326
  vertices: HVec3[];
262
327
  readonly epsilon: Decimal;
263
- constructor(vertices?: readonly HVec3[], epsilon?: Decimal.Value);
328
+ constructor(vertices?: readonly HVec3[], epsilon?: DecimalValue);
264
329
  calcPlane(): this;
265
330
  flip(): this;
266
331
  classifyVertex(v: HVec3): Side.COPLANAR | Side.FRONT | Side.BACK;