@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
package/dist/index.cjs
CHANGED
|
@@ -7203,6 +7203,8 @@ var _AudioSystem = class _AudioSystem {
|
|
|
7203
7203
|
this.prevPlayingState = /* @__PURE__ */ new Map();
|
|
7204
7204
|
/** Snapshot of options applied in the previous frame, for change detection. */
|
|
7205
7205
|
this.prevOptions = /* @__PURE__ */ new Map();
|
|
7206
|
+
/** Tracks entities that were stopped due to invisibility. */
|
|
7207
|
+
this.stoppedDueToInvisibility = /* @__PURE__ */ new Set();
|
|
7206
7208
|
this.isEditor = isEditor;
|
|
7207
7209
|
}
|
|
7208
7210
|
update(world, _deltaTime) {
|
|
@@ -7214,12 +7216,21 @@ var _AudioSystem = class _AudioSystem {
|
|
|
7214
7216
|
if (!component?.audio) continue;
|
|
7215
7217
|
const sound = component.audio;
|
|
7216
7218
|
if (!world.isEntityVisible(entityId)) {
|
|
7217
|
-
if (sound.isPlaying)
|
|
7219
|
+
if (sound.isPlaying) {
|
|
7220
|
+
sound.stop();
|
|
7221
|
+
this.stoppedDueToInvisibility.add(entityId);
|
|
7222
|
+
}
|
|
7218
7223
|
continue;
|
|
7219
7224
|
}
|
|
7225
|
+
if (this.stoppedDueToInvisibility.has(entityId)) {
|
|
7226
|
+
this.stoppedDueToInvisibility.delete(entityId);
|
|
7227
|
+
if (component.isPlaying && !sound.isPlaying && sound.buffer) {
|
|
7228
|
+
sound.play();
|
|
7229
|
+
}
|
|
7230
|
+
}
|
|
7220
7231
|
this._syncOptions(entityId, component, sound);
|
|
7221
7232
|
const prevWasPlaying = this.prevPlayingState.get(entityId) ?? false;
|
|
7222
|
-
if (prevWasPlaying && !sound.isPlaying && component.isPlaying && !component.isPaused) {
|
|
7233
|
+
if (prevWasPlaying && !sound.isPlaying && component.isPlaying && !component.isPaused && !this.stoppedDueToInvisibility.has(entityId)) {
|
|
7223
7234
|
component.isPlaying = false;
|
|
7224
7235
|
}
|
|
7225
7236
|
if (component.isPlaying && !sound.isPlaying) {
|
|
@@ -7239,6 +7250,7 @@ var _AudioSystem = class _AudioSystem {
|
|
|
7239
7250
|
if (!liveEntityIds.has(entityId)) {
|
|
7240
7251
|
this.prevPlayingState.delete(entityId);
|
|
7241
7252
|
this.prevOptions.delete(entityId);
|
|
7253
|
+
this.stoppedDueToInvisibility.delete(entityId);
|
|
7242
7254
|
}
|
|
7243
7255
|
}
|
|
7244
7256
|
}
|
|
@@ -7271,6 +7283,7 @@ var _AudioSystem = class _AudioSystem {
|
|
|
7271
7283
|
dispose(_world) {
|
|
7272
7284
|
this.prevPlayingState.clear();
|
|
7273
7285
|
this.prevOptions.clear();
|
|
7286
|
+
this.stoppedDueToInvisibility.clear();
|
|
7274
7287
|
}
|
|
7275
7288
|
};
|
|
7276
7289
|
__name(_AudioSystem, "AudioSystem");
|
|
@@ -7298,6 +7311,8 @@ var _VideoSystem = class _VideoSystem {
|
|
|
7298
7311
|
this.prevIntent = /* @__PURE__ */ new Map();
|
|
7299
7312
|
/** Snapshot of options applied in the previous frame, for change detection. */
|
|
7300
7313
|
this.prevOptions = /* @__PURE__ */ new Map();
|
|
7314
|
+
/** Tracks entities that were manually paused due to invisibility. */
|
|
7315
|
+
this.pausedDueToInvisibility = /* @__PURE__ */ new Set();
|
|
7301
7316
|
this.isEditor = isEditor;
|
|
7302
7317
|
}
|
|
7303
7318
|
update(world, _deltaTime) {
|
|
@@ -7309,12 +7324,22 @@ var _VideoSystem = class _VideoSystem {
|
|
|
7309
7324
|
if (!component?.videoElement) continue;
|
|
7310
7325
|
const video = component.videoElement;
|
|
7311
7326
|
if (!world.isEntityVisible(entityId)) {
|
|
7312
|
-
if (!video.paused)
|
|
7327
|
+
if (!video.paused) {
|
|
7328
|
+
video.pause();
|
|
7329
|
+
this.pausedDueToInvisibility.add(entityId);
|
|
7330
|
+
}
|
|
7313
7331
|
continue;
|
|
7314
7332
|
}
|
|
7333
|
+
if (this.pausedDueToInvisibility.has(entityId)) {
|
|
7334
|
+
this.pausedDueToInvisibility.delete(entityId);
|
|
7335
|
+
if (component.isPlaying && video.paused) {
|
|
7336
|
+
video.play().catch(() => {
|
|
7337
|
+
});
|
|
7338
|
+
}
|
|
7339
|
+
}
|
|
7315
7340
|
this._syncOptions(entityId, component, video);
|
|
7316
7341
|
const prev = this.prevIntent.get(entityId) ?? { isPlaying: false, isPaused: false };
|
|
7317
|
-
if (prev.isPlaying && video.paused && !video.seeking && component.isPlaying && !component.isPaused) {
|
|
7342
|
+
if (prev.isPlaying && video.paused && !video.seeking && component.isPlaying && !component.isPaused && !this.pausedDueToInvisibility.has(entityId)) {
|
|
7318
7343
|
component.isPlaying = false;
|
|
7319
7344
|
}
|
|
7320
7345
|
const isStoppedNow = !component.isPlaying && !component.isPaused;
|
|
@@ -7346,6 +7371,7 @@ var _VideoSystem = class _VideoSystem {
|
|
|
7346
7371
|
if (!liveEntityIds.has(entityId)) {
|
|
7347
7372
|
this.prevIntent.delete(entityId);
|
|
7348
7373
|
this.prevOptions.delete(entityId);
|
|
7374
|
+
this.pausedDueToInvisibility.delete(entityId);
|
|
7349
7375
|
}
|
|
7350
7376
|
}
|
|
7351
7377
|
}
|
|
@@ -7398,6 +7424,7 @@ var _VideoSystem = class _VideoSystem {
|
|
|
7398
7424
|
dispose(_world) {
|
|
7399
7425
|
this.prevIntent.clear();
|
|
7400
7426
|
this.prevOptions.clear();
|
|
7427
|
+
this.pausedDueToInvisibility.clear();
|
|
7401
7428
|
}
|
|
7402
7429
|
};
|
|
7403
7430
|
__name(_VideoSystem, "VideoSystem");
|