math-rust-lib 0.1.0 → 0.1.2

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.
@@ -24,10 +24,20 @@ export class Mat4 {
24
24
  export class Quat {
25
25
  free(): void;
26
26
  [Symbol.dispose](): void;
27
+ static from_euler(rot_x: number, rot_y: number, rot_z: number): Quat;
28
+ rotate_vec(v: Vec3): Vec3;
27
29
  to_euler_angles(): Vec3;
30
+ static from_unit_vectors(vec_from: Vec3, vec_to: Vec3, epsilon: number): Quat;
31
+ static rotation_yaw_pitch_roll(yaw: number, pitch: number, roll: number): Quat;
32
+ static from_unit_vectors_to_ref(vec_from: Vec3, vec_to: Vec3, result: Quat, epsilon: number): Quat;
28
33
  constructor(x: number, y: number, z: number, w: number);
34
+ set(x: number, y: number, z: number, w: number): Quat;
29
35
  clone(): Quat;
36
+ static slerp(a: Quat, b: Quat, t: number): Quat;
37
+ static identity(): Quat;
30
38
  multiply(other: Quat): Quat;
39
+ to_array(): Float32Array;
40
+ normalize(): Quat;
31
41
  x: number;
32
42
  y: number;
33
43
  z: number;
package/math_rust_lib.js CHANGED
@@ -312,6 +312,26 @@ class Quat {
312
312
  set w(arg0) {
313
313
  wasm.__wbg_set_quat_w(this.__wbg_ptr, arg0);
314
314
  }
315
+ /**
316
+ * @param {number} rot_x
317
+ * @param {number} rot_y
318
+ * @param {number} rot_z
319
+ * @returns {Quat}
320
+ */
321
+ static from_euler(rot_x, rot_y, rot_z) {
322
+ const ret = wasm.quat_from_euler(rot_x, rot_y, rot_z);
323
+ return Quat.__wrap(ret);
324
+ }
325
+ /**
326
+ * @param {Vec3} v
327
+ * @returns {Vec3}
328
+ */
329
+ rotate_vec(v) {
330
+ _assertClass(v, Vec3);
331
+ var ptr0 = v.__destroy_into_raw();
332
+ const ret = wasm.quat_rotate_vec(this.__wbg_ptr, ptr0);
333
+ return Vec3.__wrap(ret);
334
+ }
315
335
  /**
316
336
  * @returns {Vec3}
317
337
  */
@@ -319,6 +339,42 @@ class Quat {
319
339
  const ret = wasm.quat_to_euler_angles(this.__wbg_ptr);
320
340
  return Vec3.__wrap(ret);
321
341
  }
342
+ /**
343
+ * @param {Vec3} vec_from
344
+ * @param {Vec3} vec_to
345
+ * @param {number} epsilon
346
+ * @returns {Quat}
347
+ */
348
+ static from_unit_vectors(vec_from, vec_to, epsilon) {
349
+ _assertClass(vec_from, Vec3);
350
+ _assertClass(vec_to, Vec3);
351
+ const ret = wasm.quat_from_unit_vectors(vec_from.__wbg_ptr, vec_to.__wbg_ptr, epsilon);
352
+ return Quat.__wrap(ret);
353
+ }
354
+ /**
355
+ * @param {number} yaw
356
+ * @param {number} pitch
357
+ * @param {number} roll
358
+ * @returns {Quat}
359
+ */
360
+ static rotation_yaw_pitch_roll(yaw, pitch, roll) {
361
+ const ret = wasm.quat_rotation_yaw_pitch_roll(yaw, pitch, roll);
362
+ return Quat.__wrap(ret);
363
+ }
364
+ /**
365
+ * @param {Vec3} vec_from
366
+ * @param {Vec3} vec_to
367
+ * @param {Quat} result
368
+ * @param {number} epsilon
369
+ * @returns {Quat}
370
+ */
371
+ static from_unit_vectors_to_ref(vec_from, vec_to, result, epsilon) {
372
+ _assertClass(vec_from, Vec3);
373
+ _assertClass(vec_to, Vec3);
374
+ _assertClass(result, Quat);
375
+ const ret = wasm.quat_from_unit_vectors_to_ref(vec_from.__wbg_ptr, vec_to.__wbg_ptr, result.__wbg_ptr, epsilon);
376
+ return Quat.__wrap(ret);
377
+ }
322
378
  /**
323
379
  * @param {number} x
324
380
  * @param {number} y
@@ -331,6 +387,18 @@ class Quat {
331
387
  QuatFinalization.register(this, this.__wbg_ptr, this);
332
388
  return this;
333
389
  }
390
+ /**
391
+ * @param {number} x
392
+ * @param {number} y
393
+ * @param {number} z
394
+ * @param {number} w
395
+ * @returns {Quat}
396
+ */
397
+ set(x, y, z, w) {
398
+ const ptr = this.__destroy_into_raw();
399
+ const ret = wasm.quat_set(ptr, x, y, z, w);
400
+ return Quat.__wrap(ret);
401
+ }
334
402
  /**
335
403
  * @returns {Quat}
336
404
  */
@@ -338,6 +406,25 @@ class Quat {
338
406
  const ret = wasm.quat_clone(this.__wbg_ptr);
339
407
  return Quat.__wrap(ret);
340
408
  }
409
+ /**
410
+ * @param {Quat} a
411
+ * @param {Quat} b
412
+ * @param {number} t
413
+ * @returns {Quat}
414
+ */
415
+ static slerp(a, b, t) {
416
+ _assertClass(a, Quat);
417
+ _assertClass(b, Quat);
418
+ const ret = wasm.quat_slerp(a.__wbg_ptr, b.__wbg_ptr, t);
419
+ return Quat.__wrap(ret);
420
+ }
421
+ /**
422
+ * @returns {Quat}
423
+ */
424
+ static identity() {
425
+ const ret = wasm.quat_identity();
426
+ return Quat.__wrap(ret);
427
+ }
341
428
  /**
342
429
  * @param {Quat} other
343
430
  * @returns {Quat}
@@ -348,6 +435,23 @@ class Quat {
348
435
  const ret = wasm.quat_multiply(this.__wbg_ptr, ptr0);
349
436
  return Quat.__wrap(ret);
350
437
  }
438
+ /**
439
+ * @returns {Float32Array}
440
+ */
441
+ to_array() {
442
+ const ret = wasm.quat_to_array(this.__wbg_ptr);
443
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
444
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
445
+ return v1;
446
+ }
447
+ /**
448
+ * @returns {Quat}
449
+ */
450
+ normalize() {
451
+ const ptr = this.__destroy_into_raw();
452
+ const ret = wasm.quat_normalize(ptr);
453
+ return Quat.__wrap(ret);
454
+ }
351
455
  }
352
456
  if (Symbol.dispose) Quat.prototype[Symbol.dispose] = Quat.prototype.free;
353
457
  exports.Quat = Quat;
@@ -374,40 +478,40 @@ class Vec3 {
374
478
  * @returns {number}
375
479
  */
376
480
  get x() {
377
- const ret = wasm.__wbg_get_quat_x(this.__wbg_ptr);
481
+ const ret = wasm.__wbg_get_vec3_x(this.__wbg_ptr);
378
482
  return ret;
379
483
  }
380
484
  /**
381
485
  * @param {number} arg0
382
486
  */
383
487
  set x(arg0) {
384
- wasm.__wbg_set_quat_x(this.__wbg_ptr, arg0);
488
+ wasm.__wbg_set_vec3_x(this.__wbg_ptr, arg0);
385
489
  }
386
490
  /**
387
491
  * @returns {number}
388
492
  */
389
493
  get y() {
390
- const ret = wasm.__wbg_get_quat_y(this.__wbg_ptr);
494
+ const ret = wasm.__wbg_get_vec3_y(this.__wbg_ptr);
391
495
  return ret;
392
496
  }
393
497
  /**
394
498
  * @param {number} arg0
395
499
  */
396
500
  set y(arg0) {
397
- wasm.__wbg_set_quat_y(this.__wbg_ptr, arg0);
501
+ wasm.__wbg_set_vec3_y(this.__wbg_ptr, arg0);
398
502
  }
399
503
  /**
400
504
  * @returns {number}
401
505
  */
402
506
  get z() {
403
- const ret = wasm.__wbg_get_quat_z(this.__wbg_ptr);
507
+ const ret = wasm.__wbg_get_vec3_z(this.__wbg_ptr);
404
508
  return ret;
405
509
  }
406
510
  /**
407
511
  * @param {number} arg0
408
512
  */
409
513
  set z(arg0) {
410
- wasm.__wbg_set_quat_z(this.__wbg_ptr, arg0);
514
+ wasm.__wbg_set_vec3_z(this.__wbg_ptr, arg0);
411
515
  }
412
516
  /**
413
517
  * @returns {number}
Binary file
package/package.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
2
  "name": "math-rust-lib",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/GOH23/math-rust-lib"
8
+ },
4
9
  "files": [
5
10
  "math_rust_lib_bg.wasm",
6
11
  "math_rust_lib.js",