quake2ts 0.0.78 → 0.0.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/package.json +1 -1
- package/packages/client/dist/browser/index.global.js +1 -1
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/cjs/index.cjs +856 -1
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +856 -1
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/client/dist/types/index.d.ts +2 -1
- package/packages/client/dist/types/index.d.ts.map +1 -1
- package/packages/engine/dist/browser/index.global.js +14 -14
- package/packages/engine/dist/browser/index.global.js.map +1 -1
- package/packages/engine/dist/cjs/index.cjs +875 -0
- package/packages/engine/dist/cjs/index.cjs.map +1 -1
- package/packages/engine/dist/esm/index.js +871 -0
- package/packages/engine/dist/esm/index.js.map +1 -1
- package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/types/demo/demoReader.d.ts +27 -0
- package/packages/engine/dist/types/demo/demoReader.d.ts.map +1 -0
- package/packages/engine/dist/types/demo/index.d.ts +4 -0
- package/packages/engine/dist/types/demo/index.d.ts.map +1 -0
- package/packages/engine/dist/types/demo/playback.d.ts +3 -4
- package/packages/engine/dist/types/demo/playback.d.ts.map +1 -1
- package/packages/engine/dist/types/index.d.ts +1 -0
- package/packages/engine/dist/types/index.d.ts.map +1 -1
- package/packages/game/dist/browser/index.global.js +1 -1
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs +88 -0
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +88 -0
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/physics/movement.d.ts.map +1 -1
|
@@ -14,6 +14,13 @@ function scaleVec3(a, scalar) {
|
|
|
14
14
|
function dotVec3(a, b) {
|
|
15
15
|
return a.x * b.x + a.y * b.y + a.z * b.z;
|
|
16
16
|
}
|
|
17
|
+
function crossVec3(a, b) {
|
|
18
|
+
return {
|
|
19
|
+
x: a.y * b.z - a.z * b.y,
|
|
20
|
+
y: a.z * b.x - a.x * b.z,
|
|
21
|
+
z: a.x * b.y - a.y * b.x
|
|
22
|
+
};
|
|
23
|
+
}
|
|
17
24
|
function lengthSquaredVec3(a) {
|
|
18
25
|
return dotVec3(a, a);
|
|
19
26
|
}
|
|
@@ -30,6 +37,24 @@ function normalizeVec3(a) {
|
|
|
30
37
|
const len = lengthVec3(a);
|
|
31
38
|
return len === 0 ? a : scaleVec3(a, 1 / len);
|
|
32
39
|
}
|
|
40
|
+
function projectPointOnPlane(point, normal) {
|
|
41
|
+
const invDenom = 1 / dotVec3(normal, normal);
|
|
42
|
+
const d = dotVec3(normal, point) * invDenom;
|
|
43
|
+
return subtractVec3(point, scaleVec3(normal, invDenom * d));
|
|
44
|
+
}
|
|
45
|
+
function perpendicularVec3(src) {
|
|
46
|
+
let pos = 0;
|
|
47
|
+
let minElement = Math.abs(src.x);
|
|
48
|
+
if (Math.abs(src.y) < minElement) {
|
|
49
|
+
pos = 1;
|
|
50
|
+
minElement = Math.abs(src.y);
|
|
51
|
+
}
|
|
52
|
+
if (Math.abs(src.z) < minElement) {
|
|
53
|
+
pos = 2;
|
|
54
|
+
}
|
|
55
|
+
const axis = pos === 0 ? { x: 1, y: 0, z: 0 } : pos === 1 ? { x: 0, y: 1, z: 0 } : { x: 0, y: 0, z: 1 };
|
|
56
|
+
return normalizeVec3(projectPointOnPlane(axis, src));
|
|
57
|
+
}
|
|
33
58
|
function closestPointToBox(point, mins, maxs) {
|
|
34
59
|
return {
|
|
35
60
|
x: point.x < mins.x ? mins.x : point.x > maxs.x ? maxs.x : point.x,
|
|
@@ -81,6 +106,48 @@ function clipVelocityVec3(inVel, normal, overbounce) {
|
|
|
81
106
|
}
|
|
82
107
|
return { x: outX, y: outY, z: outZ };
|
|
83
108
|
}
|
|
109
|
+
function concatRotationMatrices(a, b) {
|
|
110
|
+
const row = (rowIndex) => [
|
|
111
|
+
a[rowIndex][0] * b[0][0] + a[rowIndex][1] * b[1][0] + a[rowIndex][2] * b[2][0],
|
|
112
|
+
a[rowIndex][0] * b[0][1] + a[rowIndex][1] * b[1][1] + a[rowIndex][2] * b[2][1],
|
|
113
|
+
a[rowIndex][0] * b[0][2] + a[rowIndex][1] * b[1][2] + a[rowIndex][2] * b[2][2]
|
|
114
|
+
];
|
|
115
|
+
const result = [row(0), row(1), row(2)];
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
function rotatePointAroundVector(dir, point, degrees) {
|
|
119
|
+
const axisLength = lengthVec3(dir);
|
|
120
|
+
if (axisLength === 0) {
|
|
121
|
+
return point;
|
|
122
|
+
}
|
|
123
|
+
const vf = normalizeVec3(dir);
|
|
124
|
+
const vr = perpendicularVec3(vf);
|
|
125
|
+
const vup = crossVec3(vr, vf);
|
|
126
|
+
const m = [
|
|
127
|
+
[vr.x, vup.x, vf.x],
|
|
128
|
+
[vr.y, vup.y, vf.y],
|
|
129
|
+
[vr.z, vup.z, vf.z]
|
|
130
|
+
];
|
|
131
|
+
const im = [
|
|
132
|
+
[m[0][0], m[1][0], m[2][0]],
|
|
133
|
+
[m[0][1], m[1][1], m[2][1]],
|
|
134
|
+
[m[0][2], m[1][2], m[2][2]]
|
|
135
|
+
];
|
|
136
|
+
const radians = degrees * DEG_TO_RAD;
|
|
137
|
+
const cos = Math.cos(radians);
|
|
138
|
+
const sin = Math.sin(radians);
|
|
139
|
+
const zrot = [
|
|
140
|
+
[cos, sin, 0],
|
|
141
|
+
[-sin, cos, 0],
|
|
142
|
+
[0, 0, 1]
|
|
143
|
+
];
|
|
144
|
+
const rot = concatRotationMatrices(concatRotationMatrices(m, zrot), im);
|
|
145
|
+
return {
|
|
146
|
+
x: rot[0][0] * point.x + rot[0][1] * point.y + rot[0][2] * point.z,
|
|
147
|
+
y: rot[1][0] * point.x + rot[1][1] * point.y + rot[1][2] * point.z,
|
|
148
|
+
z: rot[2][0] * point.x + rot[2][1] * point.y + rot[2][2] * point.z
|
|
149
|
+
};
|
|
150
|
+
}
|
|
84
151
|
var PITCH = 0;
|
|
85
152
|
var YAW = 1;
|
|
86
153
|
var ROLL = 2;
|
|
@@ -952,6 +1019,27 @@ function runPush(pusher, system, imports, frametime) {
|
|
|
952
1019
|
y: ent.origin.y + move.y,
|
|
953
1020
|
z: ent.origin.z + move.z
|
|
954
1021
|
};
|
|
1022
|
+
if (ent.groundentity === pusher) {
|
|
1023
|
+
const pusherOldOrigin = pushed[0].origin;
|
|
1024
|
+
const pusherNewOrigin = pusher.origin;
|
|
1025
|
+
const entOldOrigin = pushed[pushed.length - 1].origin;
|
|
1026
|
+
let relPos = subtractVec3(entOldOrigin, pusherOldOrigin);
|
|
1027
|
+
if (amove.y !== 0) {
|
|
1028
|
+
relPos = rotatePointAroundVector({ x: 0, y: 0, z: 1 }, relPos, amove.y);
|
|
1029
|
+
}
|
|
1030
|
+
if (amove.x !== 0) {
|
|
1031
|
+
relPos = rotatePointAroundVector({ x: 0, y: 1, z: 0 }, relPos, amove.x);
|
|
1032
|
+
}
|
|
1033
|
+
if (amove.z !== 0) {
|
|
1034
|
+
relPos = rotatePointAroundVector({ x: 1, y: 0, z: 0 }, relPos, amove.z);
|
|
1035
|
+
}
|
|
1036
|
+
ent.origin = addVec3(pusherNewOrigin, relPos);
|
|
1037
|
+
ent.angles = {
|
|
1038
|
+
x: ent.angles.x + amove.x,
|
|
1039
|
+
y: ent.angles.y + amove.y,
|
|
1040
|
+
z: ent.angles.z + amove.z
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
955
1043
|
imports.linkentity(ent);
|
|
956
1044
|
if (!testEntityPosition(ent, imports)) {
|
|
957
1045
|
if (pusher.blocked) {
|