@predy-js/math 0.3.4-beta.8 → 0.3.4-beta.80

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/index.js CHANGED
@@ -814,6 +814,16 @@ function vec2MulMat3(out, a, m) {
814
814
 
815
815
  const cos$1 = Math.cos;
816
816
  const sin$1 = Math.sin;
817
+ function vecClone(out, a) {
818
+ if (arguments.length === 1) {
819
+ a = out;
820
+ out = [];
821
+ }
822
+ for (let i = 0; i < a.length; i++) {
823
+ out[i] = a[i];
824
+ }
825
+ return out;
826
+ }
817
827
  function vecAdd(out, a, b) {
818
828
  for (let i = 0, len = a.length; i < len; i++) {
819
829
  out[i] = a[i] + b[i];
@@ -1129,6 +1139,19 @@ function quatFromRotationXYZ(out, x, y, z) {
1129
1139
  out[3] = c1 * c2 * c3 - s1 * s2 * s3;
1130
1140
  return out;
1131
1141
  }
1142
+ function quatFromRotationZXY(out, x, y, z) {
1143
+ const c1 = Math.cos(x * d2r * 0.5);
1144
+ const c2 = Math.cos(y * d2r * 0.5);
1145
+ const c3 = Math.cos(z * d2r * 0.5);
1146
+ const s1 = Math.sin(x * d2r * 0.5);
1147
+ const s2 = Math.sin(y * d2r * 0.5);
1148
+ const s3 = Math.sin(z * d2r * 0.5);
1149
+ out[0] = s1 * c2 * c3 - c1 * s2 * s3;
1150
+ out[1] = c1 * s2 * c3 + s1 * c2 * s3;
1151
+ out[2] = c1 * c2 * s3 + s1 * s2 * c3;
1152
+ out[3] = c1 * c2 * c3 - s1 * s2 * s3;
1153
+ return out;
1154
+ }
1132
1155
  function quatStar(out, quat) {
1133
1156
  const x = quat[0], y = quat[1], z = quat[2], w = quat[3];
1134
1157
  out[0] = -x;
@@ -1199,6 +1222,7 @@ exports.quatCreate = quatCreate;
1199
1222
  exports.quatEquals = quatEquals;
1200
1223
  exports.quatFromRotation = quatFromRotation;
1201
1224
  exports.quatFromRotationXYZ = quatFromRotationXYZ;
1225
+ exports.quatFromRotationZXY = quatFromRotationZXY;
1202
1226
  exports.quatFromVec3s = quatFromVec3s;
1203
1227
  exports.quatMultiply = quatMultiply;
1204
1228
  exports.quatStar = quatStar;
@@ -1226,6 +1250,7 @@ exports.vec4Create = vec4Create;
1226
1250
  exports.vecAdd = vecAdd;
1227
1251
  exports.vecAddCombine = vecAddCombine;
1228
1252
  exports.vecAssign = vecAssign;
1253
+ exports.vecClone = vecClone;
1229
1254
  exports.vecDot = vecDot;
1230
1255
  exports.vecFill = vecFill;
1231
1256
  exports.vecMinus = vecMinus;
package/dist/index.mjs CHANGED
@@ -810,6 +810,16 @@ function vec2MulMat3(out, a, m) {
810
810
 
811
811
  const cos$1 = Math.cos;
812
812
  const sin$1 = Math.sin;
813
+ function vecClone(out, a) {
814
+ if (arguments.length === 1) {
815
+ a = out;
816
+ out = [];
817
+ }
818
+ for (let i = 0; i < a.length; i++) {
819
+ out[i] = a[i];
820
+ }
821
+ return out;
822
+ }
813
823
  function vecAdd(out, a, b) {
814
824
  for (let i = 0, len = a.length; i < len; i++) {
815
825
  out[i] = a[i] + b[i];
@@ -1125,6 +1135,19 @@ function quatFromRotationXYZ(out, x, y, z) {
1125
1135
  out[3] = c1 * c2 * c3 - s1 * s2 * s3;
1126
1136
  return out;
1127
1137
  }
1138
+ function quatFromRotationZXY(out, x, y, z) {
1139
+ const c1 = Math.cos(x * d2r * 0.5);
1140
+ const c2 = Math.cos(y * d2r * 0.5);
1141
+ const c3 = Math.cos(z * d2r * 0.5);
1142
+ const s1 = Math.sin(x * d2r * 0.5);
1143
+ const s2 = Math.sin(y * d2r * 0.5);
1144
+ const s3 = Math.sin(z * d2r * 0.5);
1145
+ out[0] = s1 * c2 * c3 - c1 * s2 * s3;
1146
+ out[1] = c1 * s2 * c3 + s1 * c2 * s3;
1147
+ out[2] = c1 * c2 * s3 + s1 * s2 * c3;
1148
+ out[3] = c1 * c2 * c3 - s1 * s2 * s3;
1149
+ return out;
1150
+ }
1128
1151
  function quatStar(out, quat) {
1129
1152
  const x = quat[0], y = quat[1], z = quat[2], w = quat[3];
1130
1153
  out[0] = -x;
@@ -1161,4 +1184,4 @@ function quatFromVec3s(v1, v2) {
1161
1184
  return vecNormalize([cross[0], cross[1], cross[2], w]);
1162
1185
  }
1163
1186
 
1164
- export { NumberEpsilon, clamp, ensureVec3, getMat4TR, getMat4TRS, getMat4Transform, invertMat4, isZeroVec, mat3FromQuat, mat3FromRotation, mat3FromRotationZ, mat3MulMat3, mat3NormalFromMat4, mat3Rotate, mat3Scale, mat3Translate, mat3create, mat4Clone, mat4Determinate, mat4FromArray, mat4create, mat4fromRotationTranslationScale, mat4identity, mat4invert, mat4multiply, mat4perspective, mat4rotate, mat4scale, mat4translate, mat4transpose, quatCreate, quatEquals, quatFromRotation, quatFromRotationXYZ, quatFromVec3s, quatMultiply, quatStar, rotateVec2, rotationFromMat3, transposeMat3, transposeMat4, vec2AddVec2, vec2Create, vec2MulMat3, vec2MulVec2, vec2SubVec2, vec2TransformByMat3, vec3AddVec3, vec3Create, vec3Cross, vec3MulMat3, vec3MulMat4, vec3MulNum, vec3MulVec3, vec3RotateByMat4, vec3RotateByQuat, vec3TranslateByMat4, vec4Create, vecAdd, vecAddCombine, vecAssign, vecDot, vecFill, vecMinus, vecMulCombine, vecMulScalar, vecNormalize, vecSquareDistance, vecSub };
1187
+ export { NumberEpsilon, clamp, ensureVec3, getMat4TR, getMat4TRS, getMat4Transform, invertMat4, isZeroVec, mat3FromQuat, mat3FromRotation, mat3FromRotationZ, mat3MulMat3, mat3NormalFromMat4, mat3Rotate, mat3Scale, mat3Translate, mat3create, mat4Clone, mat4Determinate, mat4FromArray, mat4create, mat4fromRotationTranslationScale, mat4identity, mat4invert, mat4multiply, mat4perspective, mat4rotate, mat4scale, mat4translate, mat4transpose, quatCreate, quatEquals, quatFromRotation, quatFromRotationXYZ, quatFromRotationZXY, quatFromVec3s, quatMultiply, quatStar, rotateVec2, rotationFromMat3, transposeMat3, transposeMat4, vec2AddVec2, vec2Create, vec2MulMat3, vec2MulVec2, vec2SubVec2, vec2TransformByMat3, vec3AddVec3, vec3Create, vec3Cross, vec3MulMat3, vec3MulMat4, vec3MulNum, vec3MulVec3, vec3RotateByMat4, vec3RotateByQuat, vec3TranslateByMat4, vec4Create, vecAdd, vecAddCombine, vecAssign, vecClone, vecDot, vecFill, vecMinus, vecMulCombine, vecMulScalar, vecNormalize, vecSquareDistance, vecSub };
package/dist/quat.d.ts CHANGED
@@ -5,6 +5,7 @@ export declare function mat3FromQuat(out: mat3 | number[], quat: vec4): mat3;
5
5
  export declare function quatEquals(q1: vec4, q2: vec4): boolean;
6
6
  export declare function quatFromRotation(out: vec4, x: number, y: number, z: number): vec4;
7
7
  export declare function quatFromRotationXYZ(out: vec4, x: number, y: number, z: number): vec4;
8
+ export declare function quatFromRotationZXY(out: vec4, x: number, y: number, z: number): vec4;
8
9
  export declare function quatStar(out: vec4, quat: vec4): vec4;
9
10
  /**
10
11
  * @param {vec3} vstart
package/dist/vec.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { vec3, vec4, vec2, mat4, mat2, mat3 } from '@predy-js/render-interface';
2
2
  export type vec = number[];
3
3
  export { vec2, vec4, vec3, mat2, mat3, mat4 };
4
+ export declare function vecClone<T extends vec | vec2 | vec3 | vec4 | Float32Array>(out: T | number[], a?: T | number[]): T;
4
5
  export declare function vecAdd<T extends vec | vec3 | vec4 | vec2>(out: T | number[], a: T, b: T): T;
5
6
  export declare function vecSub<T extends vec | vec3 | vec4 | vec2>(out: T | number[], a: T, b: T): T;
6
7
  export declare function vecFill<T extends vec | vec3 | vec4 | vec2>(out: T | number[], number: number): T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@predy-js/math",
3
- "version": "0.3.4-beta.8",
3
+ "version": "0.3.4-beta.80",
4
4
  "description": "Mars JSON Specification",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",
@@ -28,7 +28,7 @@
28
28
  "prepublishOnly": "npm run build"
29
29
  },
30
30
  "devDependencies": {
31
- "@predy-js/render-interface": "0.3.4-beta.8",
31
+ "@predy-js/render-interface": "0.3.4-beta.80",
32
32
  "@commitlint/cli": "^13.2.1",
33
33
  "@commitlint/config-conventional": "^13.2.0",
34
34
  "@rollup/plugin-commonjs": "^21.0.3",