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
|
@@ -157,6 +157,13 @@ function scaleVec3(a, scalar) {
|
|
|
157
157
|
function dotVec3(a, b) {
|
|
158
158
|
return a.x * b.x + a.y * b.y + a.z * b.z;
|
|
159
159
|
}
|
|
160
|
+
function crossVec3(a, b) {
|
|
161
|
+
return {
|
|
162
|
+
x: a.y * b.z - a.z * b.y,
|
|
163
|
+
y: a.z * b.x - a.x * b.z,
|
|
164
|
+
z: a.x * b.y - a.y * b.x
|
|
165
|
+
};
|
|
166
|
+
}
|
|
160
167
|
function lengthSquaredVec3(a) {
|
|
161
168
|
return dotVec3(a, a);
|
|
162
169
|
}
|
|
@@ -173,6 +180,24 @@ function normalizeVec3(a) {
|
|
|
173
180
|
const len = lengthVec3(a);
|
|
174
181
|
return len === 0 ? a : scaleVec3(a, 1 / len);
|
|
175
182
|
}
|
|
183
|
+
function projectPointOnPlane(point, normal) {
|
|
184
|
+
const invDenom = 1 / dotVec3(normal, normal);
|
|
185
|
+
const d = dotVec3(normal, point) * invDenom;
|
|
186
|
+
return subtractVec3(point, scaleVec3(normal, invDenom * d));
|
|
187
|
+
}
|
|
188
|
+
function perpendicularVec3(src) {
|
|
189
|
+
let pos = 0;
|
|
190
|
+
let minElement = Math.abs(src.x);
|
|
191
|
+
if (Math.abs(src.y) < minElement) {
|
|
192
|
+
pos = 1;
|
|
193
|
+
minElement = Math.abs(src.y);
|
|
194
|
+
}
|
|
195
|
+
if (Math.abs(src.z) < minElement) {
|
|
196
|
+
pos = 2;
|
|
197
|
+
}
|
|
198
|
+
const axis = pos === 0 ? { x: 1, y: 0, z: 0 } : pos === 1 ? { x: 0, y: 1, z: 0 } : { x: 0, y: 0, z: 1 };
|
|
199
|
+
return normalizeVec3(projectPointOnPlane(axis, src));
|
|
200
|
+
}
|
|
176
201
|
function closestPointToBox(point, mins, maxs) {
|
|
177
202
|
return {
|
|
178
203
|
x: point.x < mins.x ? mins.x : point.x > maxs.x ? maxs.x : point.x,
|
|
@@ -224,6 +249,48 @@ function clipVelocityVec3(inVel, normal, overbounce) {
|
|
|
224
249
|
}
|
|
225
250
|
return { x: outX, y: outY, z: outZ };
|
|
226
251
|
}
|
|
252
|
+
function concatRotationMatrices(a, b) {
|
|
253
|
+
const row = (rowIndex) => [
|
|
254
|
+
a[rowIndex][0] * b[0][0] + a[rowIndex][1] * b[1][0] + a[rowIndex][2] * b[2][0],
|
|
255
|
+
a[rowIndex][0] * b[0][1] + a[rowIndex][1] * b[1][1] + a[rowIndex][2] * b[2][1],
|
|
256
|
+
a[rowIndex][0] * b[0][2] + a[rowIndex][1] * b[1][2] + a[rowIndex][2] * b[2][2]
|
|
257
|
+
];
|
|
258
|
+
const result = [row(0), row(1), row(2)];
|
|
259
|
+
return result;
|
|
260
|
+
}
|
|
261
|
+
function rotatePointAroundVector(dir, point, degrees) {
|
|
262
|
+
const axisLength = lengthVec3(dir);
|
|
263
|
+
if (axisLength === 0) {
|
|
264
|
+
return point;
|
|
265
|
+
}
|
|
266
|
+
const vf = normalizeVec3(dir);
|
|
267
|
+
const vr = perpendicularVec3(vf);
|
|
268
|
+
const vup = crossVec3(vr, vf);
|
|
269
|
+
const m = [
|
|
270
|
+
[vr.x, vup.x, vf.x],
|
|
271
|
+
[vr.y, vup.y, vf.y],
|
|
272
|
+
[vr.z, vup.z, vf.z]
|
|
273
|
+
];
|
|
274
|
+
const im = [
|
|
275
|
+
[m[0][0], m[1][0], m[2][0]],
|
|
276
|
+
[m[0][1], m[1][1], m[2][1]],
|
|
277
|
+
[m[0][2], m[1][2], m[2][2]]
|
|
278
|
+
];
|
|
279
|
+
const radians = degrees * DEG_TO_RAD;
|
|
280
|
+
const cos = Math.cos(radians);
|
|
281
|
+
const sin = Math.sin(radians);
|
|
282
|
+
const zrot = [
|
|
283
|
+
[cos, sin, 0],
|
|
284
|
+
[-sin, cos, 0],
|
|
285
|
+
[0, 0, 1]
|
|
286
|
+
];
|
|
287
|
+
const rot = concatRotationMatrices(concatRotationMatrices(m, zrot), im);
|
|
288
|
+
return {
|
|
289
|
+
x: rot[0][0] * point.x + rot[0][1] * point.y + rot[0][2] * point.z,
|
|
290
|
+
y: rot[1][0] * point.x + rot[1][1] * point.y + rot[1][2] * point.z,
|
|
291
|
+
z: rot[2][0] * point.x + rot[2][1] * point.y + rot[2][2] * point.z
|
|
292
|
+
};
|
|
293
|
+
}
|
|
227
294
|
var PITCH = 0;
|
|
228
295
|
var YAW = 1;
|
|
229
296
|
var ROLL = 2;
|
|
@@ -1095,6 +1162,27 @@ function runPush(pusher, system, imports, frametime) {
|
|
|
1095
1162
|
y: ent.origin.y + move.y,
|
|
1096
1163
|
z: ent.origin.z + move.z
|
|
1097
1164
|
};
|
|
1165
|
+
if (ent.groundentity === pusher) {
|
|
1166
|
+
const pusherOldOrigin = pushed[0].origin;
|
|
1167
|
+
const pusherNewOrigin = pusher.origin;
|
|
1168
|
+
const entOldOrigin = pushed[pushed.length - 1].origin;
|
|
1169
|
+
let relPos = subtractVec3(entOldOrigin, pusherOldOrigin);
|
|
1170
|
+
if (amove.y !== 0) {
|
|
1171
|
+
relPos = rotatePointAroundVector({ x: 0, y: 0, z: 1 }, relPos, amove.y);
|
|
1172
|
+
}
|
|
1173
|
+
if (amove.x !== 0) {
|
|
1174
|
+
relPos = rotatePointAroundVector({ x: 0, y: 1, z: 0 }, relPos, amove.x);
|
|
1175
|
+
}
|
|
1176
|
+
if (amove.z !== 0) {
|
|
1177
|
+
relPos = rotatePointAroundVector({ x: 1, y: 0, z: 0 }, relPos, amove.z);
|
|
1178
|
+
}
|
|
1179
|
+
ent.origin = addVec3(pusherNewOrigin, relPos);
|
|
1180
|
+
ent.angles = {
|
|
1181
|
+
x: ent.angles.x + amove.x,
|
|
1182
|
+
y: ent.angles.y + amove.y,
|
|
1183
|
+
z: ent.angles.z + amove.z
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1098
1186
|
imports.linkentity(ent);
|
|
1099
1187
|
if (!testEntityPosition(ent, imports)) {
|
|
1100
1188
|
if (pusher.blocked) {
|