@xort/cga 0.1.1 → 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/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>> {
@@ -117,6 +116,9 @@ declare const DiamondShader: {
117
116
  vertexShader: string;
118
117
  fragmentShader: string;
119
118
  uniforms: {
119
+ invModelMatrix: {
120
+ value: three.Matrix4;
121
+ };
120
122
  tCubeMapNormals: {
121
123
  type: string;
122
124
  value: null;
@@ -201,6 +203,72 @@ declare const DiamondShader: {
201
203
  side: 2;
202
204
  };
203
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
+
204
272
  interface IHVec2 {
205
273
  x: Decimal;
206
274
  y: Decimal;
@@ -213,7 +281,7 @@ declare class HVec3 implements IHVec3 {
213
281
  x: Decimal;
214
282
  y: Decimal;
215
283
  z: Decimal;
216
- constructor(x?: Decimal.Value, y?: Decimal.Value, z?: Decimal.Value);
284
+ constructor(x?: DecimalValue, y?: DecimalValue, z?: DecimalValue);
217
285
  static isVec3(v: unknown): v is IHVec3;
218
286
  get isVec3(): boolean;
219
287
  static get Up(): HVec3;
@@ -221,9 +289,9 @@ declare class HVec3 implements IHVec3 {
221
289
  static get UnitX(): HVec3;
222
290
  static get UnitY(): HVec3;
223
291
  static get UnitZ(): HVec3;
224
- set(x: Decimal.Value, y: Decimal.Value, z: Decimal.Value): this;
225
- setScalar(s: Decimal.Value): this;
226
- 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;
227
295
  getComponent(index: number): Decimal;
228
296
  copy(v: IHVec3): this;
229
297
  clone(): HVec3;
@@ -231,15 +299,15 @@ declare class HVec3 implements IHVec3 {
231
299
  addVecs(a: IHVec3, b: IHVec3): this;
232
300
  sub(v: IHVec3, w?: IHVec3): this;
233
301
  subVecs(a: IHVec3, b: IHVec3): this;
234
- multiplyScalar(s: Decimal.Value): this;
235
- divideScalar(s: Decimal.Value): this;
302
+ multiplyScalar(s: DecimalValue): this;
303
+ divideScalar(s: DecimalValue): this;
236
304
  cross(v: IHVec3, w?: IHVec3): this;
237
305
  crossVecs(a: IHVec3, b: IHVec3): this;
238
306
  dot(v: IHVec3): Decimal;
239
307
  lengthSq(): Decimal;
240
308
  length(): Decimal;
241
309
  normalize(): this;
242
- lerp(v: IHVec3, alpha: Decimal.Value): this;
310
+ lerp(v: IHVec3, alpha: DecimalValue): this;
243
311
  distanceTo(v: IHVec3): Decimal;
244
312
  equals(v: IHVec3): boolean;
245
313
  toArray(): Decimal[];
@@ -257,7 +325,7 @@ declare class Polygon {
257
325
  normal: HVec3;
258
326
  vertices: HVec3[];
259
327
  readonly epsilon: Decimal;
260
- constructor(vertices?: readonly HVec3[], epsilon?: Decimal.Value);
328
+ constructor(vertices?: readonly HVec3[], epsilon?: DecimalValue);
261
329
  calcPlane(): this;
262
330
  flip(): this;
263
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>> {
@@ -117,6 +116,9 @@ declare const DiamondShader: {
117
116
  vertexShader: string;
118
117
  fragmentShader: string;
119
118
  uniforms: {
119
+ invModelMatrix: {
120
+ value: three.Matrix4;
121
+ };
120
122
  tCubeMapNormals: {
121
123
  type: string;
122
124
  value: null;
@@ -201,6 +203,72 @@ declare const DiamondShader: {
201
203
  side: 2;
202
204
  };
203
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
+
204
272
  interface IHVec2 {
205
273
  x: Decimal;
206
274
  y: Decimal;
@@ -213,7 +281,7 @@ declare class HVec3 implements IHVec3 {
213
281
  x: Decimal;
214
282
  y: Decimal;
215
283
  z: Decimal;
216
- constructor(x?: Decimal.Value, y?: Decimal.Value, z?: Decimal.Value);
284
+ constructor(x?: DecimalValue, y?: DecimalValue, z?: DecimalValue);
217
285
  static isVec3(v: unknown): v is IHVec3;
218
286
  get isVec3(): boolean;
219
287
  static get Up(): HVec3;
@@ -221,9 +289,9 @@ declare class HVec3 implements IHVec3 {
221
289
  static get UnitX(): HVec3;
222
290
  static get UnitY(): HVec3;
223
291
  static get UnitZ(): HVec3;
224
- set(x: Decimal.Value, y: Decimal.Value, z: Decimal.Value): this;
225
- setScalar(s: Decimal.Value): this;
226
- 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;
227
295
  getComponent(index: number): Decimal;
228
296
  copy(v: IHVec3): this;
229
297
  clone(): HVec3;
@@ -231,15 +299,15 @@ declare class HVec3 implements IHVec3 {
231
299
  addVecs(a: IHVec3, b: IHVec3): this;
232
300
  sub(v: IHVec3, w?: IHVec3): this;
233
301
  subVecs(a: IHVec3, b: IHVec3): this;
234
- multiplyScalar(s: Decimal.Value): this;
235
- divideScalar(s: Decimal.Value): this;
302
+ multiplyScalar(s: DecimalValue): this;
303
+ divideScalar(s: DecimalValue): this;
236
304
  cross(v: IHVec3, w?: IHVec3): this;
237
305
  crossVecs(a: IHVec3, b: IHVec3): this;
238
306
  dot(v: IHVec3): Decimal;
239
307
  lengthSq(): Decimal;
240
308
  length(): Decimal;
241
309
  normalize(): this;
242
- lerp(v: IHVec3, alpha: Decimal.Value): this;
310
+ lerp(v: IHVec3, alpha: DecimalValue): this;
243
311
  distanceTo(v: IHVec3): Decimal;
244
312
  equals(v: IHVec3): boolean;
245
313
  toArray(): Decimal[];
@@ -257,7 +325,7 @@ declare class Polygon {
257
325
  normal: HVec3;
258
326
  vertices: HVec3[];
259
327
  readonly epsilon: Decimal;
260
- constructor(vertices?: readonly HVec3[], epsilon?: Decimal.Value);
328
+ constructor(vertices?: readonly HVec3[], epsilon?: DecimalValue);
261
329
  calcPlane(): this;
262
330
  flip(): this;
263
331
  classifyVertex(v: HVec3): Side.COPLANAR | Side.FRONT | Side.BACK;