@relu-interactives/spatial-ecs 0.2.14 → 0.2.15
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-KDZ6VBRO.js → chunk-D3AKP6QQ.js} +33 -6
- package/dist/chunk-D3AKP6QQ.js.map +1 -0
- package/dist/index.cjs +31 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/systems/index.cjs +31 -4
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +4 -0
- package/dist/systems/index.d.ts +4 -0
- package/dist/systems/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-KDZ6VBRO.js.map +0 -1
|
@@ -3418,6 +3418,8 @@ var _AudioSystem = class _AudioSystem {
|
|
|
3418
3418
|
this.prevPlayingState = /* @__PURE__ */ new Map();
|
|
3419
3419
|
/** Snapshot of options applied in the previous frame, for change detection. */
|
|
3420
3420
|
this.prevOptions = /* @__PURE__ */ new Map();
|
|
3421
|
+
/** Tracks entities that were stopped due to invisibility. */
|
|
3422
|
+
this.stoppedDueToInvisibility = /* @__PURE__ */ new Set();
|
|
3421
3423
|
this.isEditor = isEditor;
|
|
3422
3424
|
}
|
|
3423
3425
|
update(world, _deltaTime) {
|
|
@@ -3429,12 +3431,21 @@ var _AudioSystem = class _AudioSystem {
|
|
|
3429
3431
|
if (!component?.audio) continue;
|
|
3430
3432
|
const sound = component.audio;
|
|
3431
3433
|
if (!world.isEntityVisible(entityId)) {
|
|
3432
|
-
if (sound.isPlaying)
|
|
3434
|
+
if (sound.isPlaying) {
|
|
3435
|
+
sound.stop();
|
|
3436
|
+
this.stoppedDueToInvisibility.add(entityId);
|
|
3437
|
+
}
|
|
3433
3438
|
continue;
|
|
3434
3439
|
}
|
|
3440
|
+
if (this.stoppedDueToInvisibility.has(entityId)) {
|
|
3441
|
+
this.stoppedDueToInvisibility.delete(entityId);
|
|
3442
|
+
if (component.isPlaying && !sound.isPlaying && sound.buffer) {
|
|
3443
|
+
sound.play();
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3435
3446
|
this._syncOptions(entityId, component, sound);
|
|
3436
3447
|
const prevWasPlaying = this.prevPlayingState.get(entityId) ?? false;
|
|
3437
|
-
if (prevWasPlaying && !sound.isPlaying && component.isPlaying && !component.isPaused) {
|
|
3448
|
+
if (prevWasPlaying && !sound.isPlaying && component.isPlaying && !component.isPaused && !this.stoppedDueToInvisibility.has(entityId)) {
|
|
3438
3449
|
component.isPlaying = false;
|
|
3439
3450
|
}
|
|
3440
3451
|
if (component.isPlaying && !sound.isPlaying) {
|
|
@@ -3454,6 +3465,7 @@ var _AudioSystem = class _AudioSystem {
|
|
|
3454
3465
|
if (!liveEntityIds.has(entityId)) {
|
|
3455
3466
|
this.prevPlayingState.delete(entityId);
|
|
3456
3467
|
this.prevOptions.delete(entityId);
|
|
3468
|
+
this.stoppedDueToInvisibility.delete(entityId);
|
|
3457
3469
|
}
|
|
3458
3470
|
}
|
|
3459
3471
|
}
|
|
@@ -3486,6 +3498,7 @@ var _AudioSystem = class _AudioSystem {
|
|
|
3486
3498
|
dispose(_world) {
|
|
3487
3499
|
this.prevPlayingState.clear();
|
|
3488
3500
|
this.prevOptions.clear();
|
|
3501
|
+
this.stoppedDueToInvisibility.clear();
|
|
3489
3502
|
}
|
|
3490
3503
|
};
|
|
3491
3504
|
__name(_AudioSystem, "AudioSystem");
|
|
@@ -3513,6 +3526,8 @@ var _VideoSystem = class _VideoSystem {
|
|
|
3513
3526
|
this.prevIntent = /* @__PURE__ */ new Map();
|
|
3514
3527
|
/** Snapshot of options applied in the previous frame, for change detection. */
|
|
3515
3528
|
this.prevOptions = /* @__PURE__ */ new Map();
|
|
3529
|
+
/** Tracks entities that were manually paused due to invisibility. */
|
|
3530
|
+
this.pausedDueToInvisibility = /* @__PURE__ */ new Set();
|
|
3516
3531
|
this.isEditor = isEditor;
|
|
3517
3532
|
}
|
|
3518
3533
|
update(world, _deltaTime) {
|
|
@@ -3524,12 +3539,22 @@ var _VideoSystem = class _VideoSystem {
|
|
|
3524
3539
|
if (!component?.videoElement) continue;
|
|
3525
3540
|
const video = component.videoElement;
|
|
3526
3541
|
if (!world.isEntityVisible(entityId)) {
|
|
3527
|
-
if (!video.paused)
|
|
3542
|
+
if (!video.paused) {
|
|
3543
|
+
video.pause();
|
|
3544
|
+
this.pausedDueToInvisibility.add(entityId);
|
|
3545
|
+
}
|
|
3528
3546
|
continue;
|
|
3529
3547
|
}
|
|
3548
|
+
if (this.pausedDueToInvisibility.has(entityId)) {
|
|
3549
|
+
this.pausedDueToInvisibility.delete(entityId);
|
|
3550
|
+
if (component.isPlaying && video.paused) {
|
|
3551
|
+
video.play().catch(() => {
|
|
3552
|
+
});
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3530
3555
|
this._syncOptions(entityId, component, video);
|
|
3531
3556
|
const prev = this.prevIntent.get(entityId) ?? { isPlaying: false, isPaused: false };
|
|
3532
|
-
if (prev.isPlaying && video.paused && !video.seeking && component.isPlaying && !component.isPaused) {
|
|
3557
|
+
if (prev.isPlaying && video.paused && !video.seeking && component.isPlaying && !component.isPaused && !this.pausedDueToInvisibility.has(entityId)) {
|
|
3533
3558
|
component.isPlaying = false;
|
|
3534
3559
|
}
|
|
3535
3560
|
const isStoppedNow = !component.isPlaying && !component.isPaused;
|
|
@@ -3561,6 +3586,7 @@ var _VideoSystem = class _VideoSystem {
|
|
|
3561
3586
|
if (!liveEntityIds.has(entityId)) {
|
|
3562
3587
|
this.prevIntent.delete(entityId);
|
|
3563
3588
|
this.prevOptions.delete(entityId);
|
|
3589
|
+
this.pausedDueToInvisibility.delete(entityId);
|
|
3564
3590
|
}
|
|
3565
3591
|
}
|
|
3566
3592
|
}
|
|
@@ -3613,11 +3639,12 @@ var _VideoSystem = class _VideoSystem {
|
|
|
3613
3639
|
dispose(_world) {
|
|
3614
3640
|
this.prevIntent.clear();
|
|
3615
3641
|
this.prevOptions.clear();
|
|
3642
|
+
this.pausedDueToInvisibility.clear();
|
|
3616
3643
|
}
|
|
3617
3644
|
};
|
|
3618
3645
|
__name(_VideoSystem, "VideoSystem");
|
|
3619
3646
|
var VideoSystem = _VideoSystem;
|
|
3620
3647
|
|
|
3621
3648
|
export { AnimationSystem, AudioSystem, Behaviour, CameraSyncSystem, EnvironmentSyncSystem, InputSystem, InstancedMeshSystem, KeyboardKeys, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, ObjectVisibilitySystem, PhysicsSyncSystem, PostprocessingSyncSystem, RenderSystem, ScriptBehaviourSystem, TransformSyncSystem, VideoSystem };
|
|
3622
|
-
//# sourceMappingURL=chunk-
|
|
3623
|
-
//# sourceMappingURL=chunk-
|
|
3649
|
+
//# sourceMappingURL=chunk-D3AKP6QQ.js.map
|
|
3650
|
+
//# sourceMappingURL=chunk-D3AKP6QQ.js.map
|