@adatechnology/game-weapons-three 0.21.2 → 0.21.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/{chunk-7WOQSHOL.js → chunk-O5SQTNFW.js} +19 -6
- package/dist/chunk-O5SQTNFW.js.map +1 -0
- package/dist/index.global.js +127 -20
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +9 -9
- package/dist/chunk-7WOQSHOL.js.map +0 -1
package/dist/index.global.js
CHANGED
|
@@ -67866,9 +67866,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
67866
67866
|
});
|
|
67867
67867
|
}
|
|
67868
67868
|
function placementOf(entry2) {
|
|
67869
|
+
const carrier = entry2.carrier;
|
|
67870
|
+
if (carrier) return { origin: carrier.origin, anchor: entry2.anchor, yaw: entry2.yaw, carrier, ...carrier.orientation ? { orientation: carrier.orientation } : {} };
|
|
67869
67871
|
const origin = entry2.follow ? [entry2.origin[0] + positionOf2(entry2.follow)[0], entry2.origin[1] + positionOf2(entry2.follow)[1], entry2.origin[2] + positionOf2(entry2.follow)[2]] : entry2.origin;
|
|
67870
67872
|
return { origin, anchor: entry2.anchor, yaw: entry2.yaw, ...entry2.orientation ? { orientation: entry2.orientation } : {} };
|
|
67871
67873
|
}
|
|
67874
|
+
function moveCarrier(entry2) {
|
|
67875
|
+
const pose = entry2.track?.();
|
|
67876
|
+
if (!pose || !entry2.carrier) return;
|
|
67877
|
+
entry2.carrier.origin = [pose.point[0], pose.point[1], pose.point[2]];
|
|
67878
|
+
if (pose.orientation) entry2.carrier.orientation = pose.orientation;
|
|
67879
|
+
}
|
|
67872
67880
|
function drawing(entry2, action) {
|
|
67873
67881
|
const context = engine.context;
|
|
67874
67882
|
const shared3 = context.random;
|
|
@@ -67894,7 +67902,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
67894
67902
|
anchor: def.anchor ?? ORIGIN5,
|
|
67895
67903
|
yaw: yawOf(heading, playOptions.direction),
|
|
67896
67904
|
orientation: playOptions.orientation,
|
|
67897
|
-
seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS)
|
|
67905
|
+
seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS),
|
|
67906
|
+
track: playOptions.track,
|
|
67907
|
+
carrier: playOptions.track ? { origin: point, orientation: playOptions.orientation } : void 0
|
|
67898
67908
|
};
|
|
67899
67909
|
playing.push(entry2);
|
|
67900
67910
|
drawing(
|
|
@@ -67916,11 +67926,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
67916
67926
|
for (let index = playing.length - 1; index >= 0; index--) {
|
|
67917
67927
|
const entry2 = playing[index];
|
|
67918
67928
|
const instance = entry2.instance;
|
|
67929
|
+
moveCarrier(entry2);
|
|
67919
67930
|
instance.setup = { ...instance.setup, placement: placementOf(entry2) };
|
|
67920
67931
|
drawing(entry2, () => instance.step(dt));
|
|
67921
67932
|
if (instance.time >= entry2.seconds) playing.splice(index, 1);
|
|
67922
67933
|
}
|
|
67923
67934
|
},
|
|
67935
|
+
retrack() {
|
|
67936
|
+
let tracked = false;
|
|
67937
|
+
for (const entry2 of playing) {
|
|
67938
|
+
if (!entry2.carrier) continue;
|
|
67939
|
+
moveCarrier(entry2);
|
|
67940
|
+
tracked = true;
|
|
67941
|
+
}
|
|
67942
|
+
return tracked;
|
|
67943
|
+
},
|
|
67924
67944
|
clear() {
|
|
67925
67945
|
playing.length = 0;
|
|
67926
67946
|
},
|
|
@@ -69532,6 +69552,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69532
69552
|
}
|
|
69533
69553
|
}
|
|
69534
69554
|
};
|
|
69555
|
+
function rotate(q, v) {
|
|
69556
|
+
const [qx, qy, qz, qw] = q;
|
|
69557
|
+
const ix = qw * v[0] + qy * v[2] - qz * v[1];
|
|
69558
|
+
const iy = qw * v[1] + qz * v[0] - qx * v[2];
|
|
69559
|
+
const iz = qw * v[2] + qx * v[1] - qy * v[0];
|
|
69560
|
+
const iw = -qx * v[0] - qy * v[1] - qz * v[2];
|
|
69561
|
+
return [ix * qw + iw * -qx + iy * -qz - iz * -qy, iy * qw + iw * -qy + iz * -qx - ix * -qz, iz * qw + iw * -qz + ix * -qy - iy * -qx];
|
|
69562
|
+
}
|
|
69563
|
+
function carriedPoint(carried) {
|
|
69564
|
+
const { carrier, local: local2 } = carried;
|
|
69565
|
+
const turned = carrier.orientation ? rotate(carrier.orientation, local2) : local2;
|
|
69566
|
+
return [carrier.origin[0] + turned[0], carrier.origin[1] + turned[1], carrier.origin[2] + turned[2]];
|
|
69567
|
+
}
|
|
69535
69568
|
var CAPACITY3 = 400;
|
|
69536
69569
|
var IDENTITY2 = [0, 0, 0, 1];
|
|
69537
69570
|
function multiply2(a, b) {
|
|
@@ -69549,7 +69582,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69549
69582
|
get count() {
|
|
69550
69583
|
return this.particles.length;
|
|
69551
69584
|
}
|
|
69552
|
-
spawn(options, frame2 = IDENTITY2) {
|
|
69585
|
+
spawn(options, frame2 = IDENTITY2, carried) {
|
|
69553
69586
|
const velocity = options.v ?? [0, 0, 0];
|
|
69554
69587
|
const world = options.wv ?? [0, 0, 0];
|
|
69555
69588
|
const particle = {
|
|
@@ -69566,6 +69599,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69566
69599
|
y: options.p[1],
|
|
69567
69600
|
z: options.p[2],
|
|
69568
69601
|
frame: options.roll ? multiply2(frame2, aboutX(options.roll)) : frame2,
|
|
69602
|
+
roll: options.roll ? aboutX(options.roll) : void 0,
|
|
69603
|
+
carried,
|
|
69604
|
+
drift: [0, 0, 0],
|
|
69569
69605
|
at: options.at ?? [0, 0, 0],
|
|
69570
69606
|
rx: options.rot?.[0] ?? 0,
|
|
69571
69607
|
ry: options.rot?.[1] ?? 0,
|
|
@@ -69606,9 +69642,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69606
69642
|
particle.vy *= keep;
|
|
69607
69643
|
particle.vz *= keep;
|
|
69608
69644
|
}
|
|
69609
|
-
particle.
|
|
69610
|
-
|
|
69611
|
-
|
|
69645
|
+
if (particle.carried) this.ride(particle, dt);
|
|
69646
|
+
else {
|
|
69647
|
+
particle.x += particle.vx * dt;
|
|
69648
|
+
particle.y += particle.vy * dt;
|
|
69649
|
+
particle.z += particle.vz * dt;
|
|
69650
|
+
}
|
|
69612
69651
|
particle.rx += particle.spin[0] * dt;
|
|
69613
69652
|
particle.ry += particle.spin[1] * dt;
|
|
69614
69653
|
particle.rz += particle.spin[2] * dt;
|
|
@@ -69619,6 +69658,30 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69619
69658
|
clear() {
|
|
69620
69659
|
this.particles.length = 0;
|
|
69621
69660
|
}
|
|
69661
|
+
/** Puts every carried piece where its carrier is now (after the frame moved the thing it belongs to). */
|
|
69662
|
+
follow() {
|
|
69663
|
+
for (const particle of this.particles) if (particle.carried) this.place(particle);
|
|
69664
|
+
}
|
|
69665
|
+
/** A carried piece: how far its own velocity took it, then its place on the carrier. */
|
|
69666
|
+
ride(particle, dt) {
|
|
69667
|
+
const drift = particle.drift;
|
|
69668
|
+
drift[0] += particle.vx * dt;
|
|
69669
|
+
drift[1] += particle.vy * dt;
|
|
69670
|
+
drift[2] += particle.vz * dt;
|
|
69671
|
+
this.place(particle);
|
|
69672
|
+
}
|
|
69673
|
+
/** A carried piece's place on the carrier now plus its drift, turned with the carrier. */
|
|
69674
|
+
place(particle) {
|
|
69675
|
+
const carried = particle.carried;
|
|
69676
|
+
if (!carried) return;
|
|
69677
|
+
const drift = particle.drift;
|
|
69678
|
+
const [x, y, z] = carriedPoint(carried);
|
|
69679
|
+
particle.x = x + drift[0];
|
|
69680
|
+
particle.y = y + drift[1];
|
|
69681
|
+
particle.z = z + drift[2];
|
|
69682
|
+
const turn2 = carried.carrier.orientation;
|
|
69683
|
+
if (turn2) particle.frame = particle.roll ? multiply2(turn2, particle.roll) : turn2;
|
|
69684
|
+
}
|
|
69622
69685
|
};
|
|
69623
69686
|
var DEFAULT_FADE_IN = 0.1;
|
|
69624
69687
|
var FLOATS_PER_VECTOR = 3;
|
|
@@ -69979,8 +70042,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69979
70042
|
}
|
|
69980
70043
|
flash(point, color2, intensity, duration, distance4, force, steady) {
|
|
69981
70044
|
const { level } = this.context.quality;
|
|
69982
|
-
if (level >= 1 && !force) return;
|
|
69983
|
-
if (level >= 2 && force !== "boom") return;
|
|
70045
|
+
if (level >= 1 && !force) return void 0;
|
|
70046
|
+
if (level >= 2 && force !== "boom") return void 0;
|
|
69984
70047
|
const light = this.lights[this.next++ % LIGHT_CAPACITY];
|
|
69985
70048
|
light.x = point[0];
|
|
69986
70049
|
light.y = point[1];
|
|
@@ -69992,17 +70055,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69992
70055
|
light.t = 0;
|
|
69993
70056
|
light.steady = steady === true;
|
|
69994
70057
|
light.intensity = intensity;
|
|
70058
|
+
light.carried = void 0;
|
|
70059
|
+
return light;
|
|
69995
70060
|
}
|
|
69996
70061
|
clear() {
|
|
69997
70062
|
for (const light of this.lights) light.intensity = 0;
|
|
69998
70063
|
for (const light of this.fire) light.intensity = 0;
|
|
69999
70064
|
}
|
|
70065
|
+
/** Puts every carried light that burns where its carrier is now. */
|
|
70066
|
+
follow() {
|
|
70067
|
+
for (const light of this.lights) if (light.intensity > 0 && light.carried) [light.x, light.y, light.z] = carriedPoint(light.carried);
|
|
70068
|
+
}
|
|
70000
70069
|
update(dt) {
|
|
70001
70070
|
for (const light of this.lights) {
|
|
70002
70071
|
if (light.intensity <= 0) continue;
|
|
70003
70072
|
light.t += dt;
|
|
70004
70073
|
const age = light.t / light.duration;
|
|
70005
70074
|
light.intensity = age >= 1 ? 0 : light.steady ? light.peak : light.peak * (1 - age) * (1 - age);
|
|
70075
|
+
if (light.carried) [light.x, light.y, light.z] = carriedPoint(light.carried);
|
|
70006
70076
|
}
|
|
70007
70077
|
}
|
|
70008
70078
|
};
|
|
@@ -70010,7 +70080,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70010
70080
|
var FIRE_FLICKER_SWAY = 0.25;
|
|
70011
70081
|
var FIRE_FLICKER_JITTER = 0.08;
|
|
70012
70082
|
var LENS_FADE = 0.16;
|
|
70013
|
-
function
|
|
70083
|
+
function rotate2(q, v) {
|
|
70014
70084
|
const [qx, qy, qz, qw] = q;
|
|
70015
70085
|
const ix = qw * v[0] + qy * v[2] - qz * v[1];
|
|
70016
70086
|
const iy = qw * v[1] + qz * v[0] - qx * v[2];
|
|
@@ -70067,7 +70137,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70067
70137
|
if (!placement) return point;
|
|
70068
70138
|
const { anchor, origin, yaw, orientation } = placement;
|
|
70069
70139
|
if (orientation) {
|
|
70070
|
-
const turned =
|
|
70140
|
+
const turned = rotate2(orientation, [point[0] - anchor[0], point[1] - anchor[1], point[2] - anchor[2]]);
|
|
70071
70141
|
return [origin[0] + turned[0], origin[1] + turned[1], origin[2] + turned[2]];
|
|
70072
70142
|
}
|
|
70073
70143
|
const x = point[0] - anchor[0];
|
|
@@ -70076,11 +70146,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70076
70146
|
const sin2 = Math.sin(yaw);
|
|
70077
70147
|
return [origin[0] + cos2 * x + sin2 * z, origin[1] + point[1] - anchor[1], origin[2] - sin2 * x + cos2 * z];
|
|
70078
70148
|
}
|
|
70149
|
+
/** A point of the recipe's space from the anchor, turned by the placement's yaw when it has no orientation (the carrier turns the rest). */
|
|
70150
|
+
local(point) {
|
|
70151
|
+
const placement = this.placement;
|
|
70152
|
+
if (!placement) return point;
|
|
70153
|
+
const offset = [point[0] - placement.anchor[0], point[1] - placement.anchor[1], point[2] - placement.anchor[2]];
|
|
70154
|
+
if (placement.carrier?.orientation) return offset;
|
|
70155
|
+
const turned = this.place(point);
|
|
70156
|
+
return [turned[0] - placement.origin[0], turned[1] - placement.origin[1], turned[2] - placement.origin[2]];
|
|
70157
|
+
}
|
|
70079
70158
|
/** A direction or velocity of the recipe's space in the world. */
|
|
70080
70159
|
turn(vector2) {
|
|
70081
70160
|
const placement = this.placement;
|
|
70082
70161
|
if (!placement) return vector2;
|
|
70083
|
-
if (placement.orientation) return
|
|
70162
|
+
if (placement.orientation) return rotate2(placement.orientation, vector2);
|
|
70084
70163
|
const cos2 = Math.cos(placement.yaw);
|
|
70085
70164
|
const sin2 = Math.sin(placement.yaw);
|
|
70086
70165
|
return [cos2 * vector2[0] + sin2 * vector2[2], vector2[1], -sin2 * vector2[0] + cos2 * vector2[2]];
|
|
@@ -70115,7 +70194,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70115
70194
|
const options = placement ? { ...recipe2, p: this.place(recipe2.p), ...recipe2.v ? { v: this.turn(recipe2.v) } : {} } : recipe2;
|
|
70116
70195
|
this.context.trace?.("mesh", [options]);
|
|
70117
70196
|
const grouped = recipe2.at !== void 0 || recipe2.roll !== void 0;
|
|
70118
|
-
|
|
70197
|
+
const carried = placement?.carrier && grouped ? { carrier: placement.carrier, local: this.local(recipe2.p) } : void 0;
|
|
70198
|
+
return this.meshes.spawn(options, placement && grouped ? placement.orientation ?? [0, Math.sin(placement.yaw / 2), 0, Math.cos(placement.yaw / 2)] : void 0, carried);
|
|
70119
70199
|
}
|
|
70120
70200
|
debrisPiece(recipe2) {
|
|
70121
70201
|
const options = this.placed(recipe2);
|
|
@@ -70139,9 +70219,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70139
70219
|
}
|
|
70140
70220
|
/** `steady` (a seventh number): the light holds its intensity for its duration and goes out, where the Workshop's fades with the square of its age. */
|
|
70141
70221
|
flash(recipe2) {
|
|
70142
|
-
const
|
|
70222
|
+
const placement = this.placement;
|
|
70223
|
+
const args = placement ? [this.place(recipe2[0]), recipe2[1], recipe2[2], recipe2[3], recipe2[4], recipe2[5], recipe2[6]] : recipe2;
|
|
70143
70224
|
this.context.trace?.("flash", args.slice(0, 6));
|
|
70144
|
-
this.lights.flash(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
|
70225
|
+
const light = this.lights.flash(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
|
70226
|
+
if (light && placement?.carrier) light.carried = { carrier: placement.carrier, local: this.local(recipe2[0]) };
|
|
70145
70227
|
}
|
|
70146
70228
|
/** `fireLight` (W400): sways with the clock and flickers with one draw. */
|
|
70147
70229
|
fireLight(slot, recipe2, intensity, time) {
|
|
@@ -70300,6 +70382,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70300
70382
|
const seed = playOptions.seed ?? (randomMode === "shared" ? void 0 : Math.imul(++handles.events, AUTO_SEED) + (options.seed ?? 0));
|
|
70301
70383
|
return effectPlayer().play(id, [point[0], point[1], point[2]], { ...playOptions, ...seed !== void 0 ? { seed } : {} });
|
|
70302
70384
|
},
|
|
70385
|
+
follow() {
|
|
70386
|
+
if (!engine || !player?.retrack()) return false;
|
|
70387
|
+
engine.meshes.follow();
|
|
70388
|
+
engine.lights.follow();
|
|
70389
|
+
return true;
|
|
70390
|
+
},
|
|
70303
70391
|
burst: (kind, point, normal, count, speed, spriteOptions) => spriteSystem.burst(kind, point, normal, count, speed, spriteOptions),
|
|
70304
70392
|
spawn: (kind, point, velocity, spriteOptions) => spriteSystem.spawn(kind, point, velocity, spriteOptions),
|
|
70305
70393
|
onLand: (owner, listener) => spriteSystem.onLand(owner, listener),
|
|
@@ -70448,7 +70536,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70448
70536
|
};
|
|
70449
70537
|
}
|
|
70450
70538
|
|
|
70451
|
-
// ../game-vfx-three/dist/chunk-
|
|
70539
|
+
// ../game-vfx-three/dist/chunk-HJXLYDNY.js
|
|
70452
70540
|
var GLOW_VERTEX = `attribute vec4 aP;attribute vec4 aC;varying vec2 vU;varying vec4 vC;
|
|
70453
70541
|
void main(){vec3 R=vec3(viewMatrix[0][0],viewMatrix[1][0],viewMatrix[2][0]);vec3 Up=vec3(viewMatrix[0][1],viewMatrix[1][1],viewMatrix[2][1]);
|
|
70454
70542
|
vec3 wp=aP.xyz+(R*position.x+Up*position.y)*aP.w;vU=position.xy;vC=aC;gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.);}`;
|
|
@@ -71883,7 +71971,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
71883
71971
|
...request.orientation ? { orientation: request.orientation } : {},
|
|
71884
71972
|
...request.seed !== void 0 ? { seed: request.seed } : {},
|
|
71885
71973
|
...request.param !== void 0 ? { param: request.param } : {},
|
|
71886
|
-
...request.values ? { values: request.values } : {}
|
|
71974
|
+
...request.values ? { values: request.values } : {},
|
|
71975
|
+
...request.track ? { track: request.track } : {}
|
|
71887
71976
|
});
|
|
71888
71977
|
},
|
|
71889
71978
|
stop: (handle) => world.stop(handle),
|
|
@@ -71912,6 +72001,11 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
71912
72001
|
syncAll();
|
|
71913
72002
|
overlay?.update(screenNow());
|
|
71914
72003
|
},
|
|
72004
|
+
present() {
|
|
72005
|
+
if (!world.follow()) return;
|
|
72006
|
+
lights.sync();
|
|
72007
|
+
workshopLayers?.sync();
|
|
72008
|
+
},
|
|
71915
72009
|
warmUpProbes() {
|
|
71916
72010
|
releaseAnchors();
|
|
71917
72011
|
marks.prepare();
|
|
@@ -71965,9 +72059,13 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
71965
72059
|
const seed = () => 1 + Math.floor(random() * 2147483646);
|
|
71966
72060
|
const barrel = (orientation) => vec3(new THREE.Vector3(1, 0, 0).applyQuaternion(orientation));
|
|
71967
72061
|
return {
|
|
71968
|
-
muzzleFlash(position, orientation, size, profile = MUZZLE_SMOKE.smokeless) {
|
|
72062
|
+
muzzleFlash(position, orientation, size, profile = MUZZLE_SMOKE.smokeless, track) {
|
|
71969
72063
|
if (profile.puffs <= 0 && profile.flash <= 0) return;
|
|
71970
|
-
|
|
72064
|
+
const follow = track ? () => {
|
|
72065
|
+
const pose = track();
|
|
72066
|
+
return pose ? { point: vec3(pose.position), orientation: quaternion(pose.orientation) } : null;
|
|
72067
|
+
} : void 0;
|
|
72068
|
+
sink?.play({ effect: VIEWMODEL_EFFECT_IDS.flash, point: vec3(position), direction: barrel(orientation), orientation: quaternion(orientation), seed: seed(), values: { size, ...profile }, ...follow ? { track: follow } : {} });
|
|
71971
72069
|
},
|
|
71972
72070
|
smoke(position, velocity, size, life, opacity) {
|
|
71973
72071
|
sink?.play({ effect: VIEWMODEL_EFFECT_IDS.smoke, point: vec3(position), seed: seed(), values: { vx: velocity.x, vy: velocity.y, vz: velocity.z, radius: size, life, opacity } });
|
|
@@ -72360,17 +72458,19 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
72360
72458
|
particles.spawn(round5.group, toWorld2(session, vector2(-0.2, 1.1, 1.2)), { kind: "round", life: 25, radius: round5.radius, bounce: 0.3, spin: vector2(8, 12, 6), onRest: restFlat, ownsGeometry: true });
|
|
72361
72459
|
} else ejectFromPort(false);
|
|
72362
72460
|
};
|
|
72461
|
+
const trackOf = (mark) => () => root.parent ? { position: positionOf3(mark), orientation: root.getWorldQuaternion(new THREE.Quaternion()) } : null;
|
|
72363
72462
|
return (event) => {
|
|
72364
72463
|
const data = event.data ?? {};
|
|
72365
72464
|
switch (event.type) {
|
|
72366
72465
|
case "muzzle_flash":
|
|
72367
72466
|
if (data.at === "ugl") {
|
|
72368
|
-
|
|
72467
|
+
const ugl = parts.uglMuzzle;
|
|
72468
|
+
if (ugl && world.layers.muzzleFlash) world.afterPose(() => effects.muzzleFlash(positionOf3(ugl), root.getWorldQuaternion(new THREE.Quaternion()), UGL_FLASH, void 0, trackOf(ugl)));
|
|
72369
72469
|
} else if (parts.muzzle && world.layers.muzzleFlash && (session.def.action.kind === "firearm" || session.def.action.kind === "launcher")) {
|
|
72370
72470
|
const profile = muzzleSmokeOf({ caliber: session.caliber, weapon: session.def, suppressed: session.suppressed });
|
|
72371
72471
|
const size = session.def.action.kind === "launcher" ? 2.2 : FLASH_BY_CASE[session.caseType];
|
|
72372
72472
|
const muzzle2 = parts.muzzle;
|
|
72373
|
-
world.afterPose(() => effects.muzzleFlash(positionOf3(muzzle2), root.getWorldQuaternion(new THREE.Quaternion()), size, profile));
|
|
72473
|
+
world.afterPose(() => effects.muzzleFlash(positionOf3(muzzle2), root.getWorldQuaternion(new THREE.Quaternion()), size, profile, trackOf(muzzle2)));
|
|
72374
72474
|
}
|
|
72375
72475
|
break;
|
|
72376
72476
|
case "eject_casing":
|
|
@@ -72959,11 +73059,17 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
72959
73059
|
play: (request) => {
|
|
72960
73060
|
if (!lens2 || !request.point) return worldSink.play(request);
|
|
72961
73061
|
const at4 = toWorldLens(camera2, lensPoint.set(...request.point), worldFovOf(), lens2.fov);
|
|
72962
|
-
|
|
73062
|
+
const track = request.track;
|
|
73063
|
+
return worldSink.play({ ...request, point: [at4.x, at4.y, at4.z], ...track ? { track: () => seenThroughLens(track()) } : {} });
|
|
72963
73064
|
},
|
|
72964
73065
|
stop: (handle) => worldSink.stop(handle)
|
|
72965
73066
|
} : void 0;
|
|
72966
73067
|
const effects = createEffects(THREE, lensSink, random);
|
|
73068
|
+
function seenThroughLens(pose) {
|
|
73069
|
+
if (!pose || !lens2) return pose;
|
|
73070
|
+
const at4 = toWorldLens(camera2, trackPoint.set(...pose.point), worldFovOf(), lens2.fov);
|
|
73071
|
+
return { ...pose, point: [at4.x, at4.y, at4.z] };
|
|
73072
|
+
}
|
|
72967
73073
|
const hand = new THREE.Group();
|
|
72968
73074
|
hand.name = VIEWMODEL_NODE_NAME;
|
|
72969
73075
|
scene.add(hand);
|
|
@@ -73130,6 +73236,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
73130
73236
|
let lens2 = null;
|
|
73131
73237
|
let lensLayer = -1;
|
|
73132
73238
|
const lensPoint = new THREE.Vector3();
|
|
73239
|
+
const trackPoint = new THREE.Vector3();
|
|
73133
73240
|
const worldFovOf = () => camera2.fov ?? 72;
|
|
73134
73241
|
const setLens = (kind) => {
|
|
73135
73242
|
const fov = kind ? VIEW_HOLD[kind].fov : null;
|