@woosh/meep-engine 2.119.2 → 2.119.4
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/src/core/graph/layout/box/resolveBoxOverlapUsingForce.d.ts +0 -1
- package/src/core/graph/layout/box/resolveBoxOverlapUsingForce.d.ts.map +1 -1
- package/src/core/graph/layout/box/resolveBoxOverlapUsingForce.js +4 -10
- package/src/engine/Engine.js +18 -0
- package/src/engine/graphics/render/visibility/IncrementalDeltaSet.d.ts.map +1 -1
- package/src/engine/graphics/render/visibility/IncrementalDeltaSet.js +23 -3
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.d.ts +7 -0
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.d.ts.map +1 -1
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +40 -4
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveBoxOverlapUsingForce.d.ts","sourceRoot":"","sources":["../../../../../../src/core/graph/layout/box/resolveBoxOverlapUsingForce.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolveBoxOverlapUsingForce.d.ts","sourceRoot":"","sources":["../../../../../../src/core/graph/layout/box/resolveBoxOverlapUsingForce.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oDAJW,SAAS,SACT,YAAa,GACX,MAAM,CAyFlB"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import Vector2 from "../../../geom/Vector2.js";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
*
|
|
5
3
|
* @param {Vector2[]} forces
|
|
@@ -63,10 +61,6 @@ export function resolveBoxOverlapUsingForce(forces, boxes) {
|
|
|
63
61
|
dX = 0;
|
|
64
62
|
}
|
|
65
63
|
|
|
66
|
-
//create separation vector
|
|
67
|
-
const d = new Vector2(dX, dY);
|
|
68
|
-
const halfD = d.multiplyScalar(0.5);
|
|
69
|
-
|
|
70
64
|
const f1 = forces[i];
|
|
71
65
|
const f2 = forces[j];
|
|
72
66
|
|
|
@@ -74,12 +68,12 @@ export function resolveBoxOverlapUsingForce(forces, boxes) {
|
|
|
74
68
|
if (b0.locked === true && b1.locked === true) {
|
|
75
69
|
continue;
|
|
76
70
|
} else if (b0.locked === true) {
|
|
77
|
-
f2.
|
|
71
|
+
f2._sub(dX, dY);
|
|
78
72
|
} else if (b1.locked === true) {
|
|
79
|
-
f1.
|
|
73
|
+
f1._add(dX, dY);
|
|
80
74
|
} else {
|
|
81
|
-
f1.
|
|
82
|
-
f2.
|
|
75
|
+
f1._add(dX*0.5, dY*0.5);
|
|
76
|
+
f2._sub(dX*0.5, dY*0.5);
|
|
83
77
|
}
|
|
84
78
|
|
|
85
79
|
moves++;
|
package/src/engine/Engine.js
CHANGED
|
@@ -301,6 +301,22 @@ class Engine {
|
|
|
301
301
|
this.plugins.initialize(this);
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
+
#initialize_audio() {
|
|
305
|
+
const sound = this.sound;
|
|
306
|
+
if (sound === undefined || sound === null) {
|
|
307
|
+
// no sound engine
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// hook up context resumption to input
|
|
312
|
+
if (this.devices.pointer !== undefined) {
|
|
313
|
+
|
|
314
|
+
this.devices.pointer.on.down.addOne(sound.resumeContext, sound);
|
|
315
|
+
this.devices.keyboard.on.down.addOne(sound.resumeContext, sound);
|
|
316
|
+
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
304
320
|
|
|
305
321
|
get inputEngine() {
|
|
306
322
|
throw new Error('Deprecated, use .devices instead');
|
|
@@ -449,6 +465,8 @@ class Engine {
|
|
|
449
465
|
start() {
|
|
450
466
|
this.assetManager.startup();
|
|
451
467
|
|
|
468
|
+
this.#initialize_audio();
|
|
469
|
+
|
|
452
470
|
const promiseEntityManager = () => {
|
|
453
471
|
return new Promise((resolve, reject) => {
|
|
454
472
|
//initialize entity manager
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IncrementalDeltaSet.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/render/visibility/IncrementalDeltaSet.js"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH;IACI;;;OAGG;IACH,4BAFoB,CAAC,QAAC,CAAC,KAAE,MAAM,EA0E9B;IArEG;;;;OAIG;IACH,mBAAoB;IAEpB;;;;OAIG;IACH,0BAA0B;IAE1B;;;;OAIG;IACH,wBAAyB;IACzB;;;;OAIG;IACH,8BAA8B;IAE9B;;;;OAIG;IACH,kBAAwB;IAExB;;;OAGG;IACH,SAFU,MAAM,CAEA;IAEhB;;;OAGG;IACH,MAFU,MAAM,CAEH;IAEb;;;OAGG;IACH,kBAFU,MAAM,CAEoB;IAEpC;;;OAGG;IACH,SAFU,MAAM,CAEW;IAE3B;;;OAGG;IACH,WAFU,MAAM,CAEa;IAE7B;;;OAGG;IACH,OAFU,wBAAwB,GAAC,MAAM,CAEE;IAG/C;;;OAGG;IACH,oBAEC;IAED;;;;OAIG;IACH,6BAHgB,GAAG,8BAYlB;IAGD;;;;;OAKG;IACH,kCAJuB,MAAM,wBAEhB,IAAI,CAIhB;IAED;;;;OAIG;IACH,kBAHW,CAAC,GACC,OAAO,CAInB;IAED;;;;;OAKG;IACH,kBAQC;IAED;;;;;OAKG;IACH,wBAEC;IAED;;;;OAIG;IACH,qBAHW,CAAC,GACC,OAAO,CAmBnB;IAED,cAWC;IAED,mBAEC;IAED,yBAeC;IAED,uBAwDC;IAED;;;OAGG;IACH,cAFW,CAAC,QAMX;IAED;;;OAGG;IACH,iBAFW,oBAAoB,CAAC,CAAC,QAWhC;IAIL;;;OAGG;IACH,gCAFU,OAAO,CAEkC;CAPlD;
|
|
1
|
+
{"version":3,"file":"IncrementalDeltaSet.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/render/visibility/IncrementalDeltaSet.js"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH;IACI;;;OAGG;IACH,4BAFoB,CAAC,QAAC,CAAC,KAAE,MAAM,EA0E9B;IArEG;;;;OAIG;IACH,mBAAoB;IAEpB;;;;OAIG;IACH,0BAA0B;IAE1B;;;;OAIG;IACH,wBAAyB;IACzB;;;;OAIG;IACH,8BAA8B;IAE9B;;;;OAIG;IACH,kBAAwB;IAExB;;;OAGG;IACH,SAFU,MAAM,CAEA;IAEhB;;;OAGG;IACH,MAFU,MAAM,CAEH;IAEb;;;OAGG;IACH,kBAFU,MAAM,CAEoB;IAEpC;;;OAGG;IACH,SAFU,MAAM,CAEW;IAE3B;;;OAGG;IACH,WAFU,MAAM,CAEa;IAE7B;;;OAGG;IACH,OAFU,wBAAwB,GAAC,MAAM,CAEE;IAG/C;;;OAGG;IACH,oBAEC;IAED;;;;OAIG;IACH,6BAHgB,GAAG,8BAYlB;IAGD;;;;;OAKG;IACH,kCAJuB,MAAM,wBAEhB,IAAI,CAIhB;IAED;;;;OAIG;IACH,kBAHW,CAAC,GACC,OAAO,CAInB;IAED;;;;;OAKG;IACH,kBAQC;IAED;;;;;OAKG;IACH,wBAEC;IAED;;;;OAIG;IACH,kBAHW,CAAC,GACA,OAAO,CAelB;IAED;;;;OAIG;IACH,qBAHW,CAAC,GACC,OAAO,CAmBnB;IAED,cAWC;IAED,mBAEC;IAED,yBAeC;IAED,uBAwDC;IAED;;;OAGG;IACH,cAFW,CAAC,QAMX;IAED;;;OAGG;IACH,iBAFW,oBAAoB,CAAC,CAAC,QAWhC;IAIL;;;OAGG;IACH,gCAFU,OAAO,CAEkC;CAPlD;mBAvUkB,0CAA0C;gCAKnD,MAAM"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import Signal from "../../../../core/events/signal/Signal.js";
|
|
2
1
|
import { assert } from "../../../../core/assert.js";
|
|
3
|
-
import { IllegalStateException } from "../../../../core/fsm/exceptions/IllegalStateException.js";
|
|
4
|
-
import { binarySearchHighIndex } from "../../../../core/collection/array/binarySearchHighIndex.js";
|
|
5
2
|
import { array_shrink_to_size } from "../../../../core/collection/array/array_shrink_to_size.js";
|
|
3
|
+
import { binarySearchHighIndex } from "../../../../core/collection/array/binarySearchHighIndex.js";
|
|
4
|
+
import Signal from "../../../../core/events/signal/Signal.js";
|
|
5
|
+
import { IllegalStateException } from "../../../../core/fsm/exceptions/IllegalStateException.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @readonly
|
|
@@ -168,6 +168,26 @@ export class IncrementalDeltaSet {
|
|
|
168
168
|
return binarySearchHighIndex(this.__elements, element, this.__compare, 0, this.size - 1);
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
+
/**
|
|
172
|
+
*
|
|
173
|
+
* @param {V} element
|
|
174
|
+
* @return {boolean}
|
|
175
|
+
*/
|
|
176
|
+
forceAdd(element) {
|
|
177
|
+
const i = this.__indexExpected(element);
|
|
178
|
+
|
|
179
|
+
if (this.elements[i] === element) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
this.__elements.splice(i, 0, element);
|
|
184
|
+
|
|
185
|
+
this.size++;
|
|
186
|
+
this.version++;
|
|
187
|
+
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
|
|
171
191
|
/**
|
|
172
192
|
*
|
|
173
193
|
* @param {V} element
|
|
@@ -94,7 +94,14 @@ export class SoundEmitterSystem extends System<any, any, any, any, any> {
|
|
|
94
94
|
* @param {number} entity
|
|
95
95
|
*/
|
|
96
96
|
unlink(emitter: SoundEmitter, transform: Transform, entity: number): void;
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* @param {SoundEmitterComponentContext} emitter
|
|
100
|
+
* @returns {boolean}
|
|
101
|
+
*/
|
|
102
|
+
emitter_in_hearing_range(emitter: SoundEmitterComponentContext): boolean;
|
|
97
103
|
update(timeDelta: any): void;
|
|
104
|
+
#private;
|
|
98
105
|
}
|
|
99
106
|
import { System } from '../../../ecs/System.js';
|
|
100
107
|
import { Transform } from '../../../ecs/transform/Transform.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SoundEmitterSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/sound/ecs/emitter/SoundEmitterSystem.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SoundEmitterSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/sound/ecs/emitter/SoundEmitterSystem.js"],"names":[],"mappings":"mCAmBU,MAAM;;;;;;AAchB;IACI;;;;;;;OAOG;IACH,yDALW,SAAS,WACT,YAAY,EA0DtB;IAnDG,yDAA6C;IAG7C,2BAAsC;IACtC;;;OAGG;IACH,iBAFU,YAAY,CAEQ;IAC9B,2BAAgC;IAEhC;;;OAGG;IACH,cAAkB;IAWlB;;;OAGG;IACH,MAFU,4BAA4B,EAAE,CAE1B;IAEd;;;OAGG;IACH,WAFU,oBAAoB,4BAA4B,CAAC,CAEE;IAE7D;;;;OAIG;IACH,cAAsB;IAEtB;;;;OAIG;IACH,sBAAsB;IAG1B,0EAKC;IAED,2EAKC;IAED;;;OAGG;IACH,6BAFW,4BAA4B,QAItC;IAED;;;OAGG;IACH,+BAFW,4BAA4B,QAItC;IAED;;;;OAIG;IACH,gCAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,sCAFW,MAAM,QAIhB;IAED,4BAeC;IAED;;;;OAIG;IACH,0BAFa,OAAO,CAInB;IAED;;;;;OAKG;IACH,cAJW,YAAY,aACZ,SAAS,UACT,MAAM,QA6DhB;IAED;;;;;OAKG;IACH,gBAJW,YAAY,aACZ,SAAS,UACT,MAAM,QAmBhB;IAED;;;;OAIG;IACH,kCAHW,4BAA4B,GAC1B,OAAO,CAKnB;IAQD,6BA6GC;;CAGJ;uBAjYsB,wBAAwB;0BACrB,qCAAqC;6BAGlC,mBAAmB;6CAEH,mCAAmC;oCAJ5C,4DAA4D"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BVH } from "../../../../core/bvh2/bvh3/BVH.js";
|
|
2
2
|
import { bvh_query_user_data_generic } from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_generic.js";
|
|
3
3
|
import { BVHQueryIntersectsSphere } from "../../../../core/bvh2/bvh3/query/BVHQueryIntersectsSphere.js";
|
|
4
|
+
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
4
5
|
import { invokeObjectCompare } from "../../../../core/model/object/invokeObjectCompare.js";
|
|
5
6
|
import { GameAssetType } from "../../../asset/GameAssetType.js";
|
|
6
7
|
import { SoundAssetLoader } from "../../../asset/loaders/SoundAssetLoader.js";
|
|
@@ -208,10 +209,29 @@ export class SoundEmitterSystem extends System {
|
|
|
208
209
|
|
|
209
210
|
ctx.targetNode = targetNode;
|
|
210
211
|
|
|
211
|
-
|
|
212
|
+
{
|
|
213
|
+
// wire context if it's in hearing range
|
|
214
|
+
const distance = ctx.transform.position.distanceTo(this.#cached_listener_position);
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
if (distance <= ctx.emitter.distanceMax) {
|
|
218
|
+
|
|
219
|
+
// add immediately
|
|
220
|
+
this.activeSet.forceAdd(ctx);
|
|
221
|
+
|
|
222
|
+
if (ctx.emitter.getFlag(SoundEmitterFlags.Attenuation)) {
|
|
223
|
+
// is attenuated
|
|
224
|
+
ctx.emitter.writeAttenuationVolume(distance);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
ctx.connect();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
212
230
|
|
|
213
231
|
ctx.update();
|
|
214
232
|
|
|
233
|
+
ctx.link();
|
|
234
|
+
|
|
215
235
|
this.data[entity] = ctx;
|
|
216
236
|
|
|
217
237
|
this.__linkedCount++;
|
|
@@ -242,6 +262,22 @@ export class SoundEmitterSystem extends System {
|
|
|
242
262
|
this.__linkedCount--;
|
|
243
263
|
}
|
|
244
264
|
|
|
265
|
+
/**
|
|
266
|
+
*
|
|
267
|
+
* @param {SoundEmitterComponentContext} emitter
|
|
268
|
+
* @returns {boolean}
|
|
269
|
+
*/
|
|
270
|
+
emitter_in_hearing_range(emitter) {
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Used to decide whether emitter is in hearing range when it is being added
|
|
277
|
+
* @type {Vector3}
|
|
278
|
+
*/
|
|
279
|
+
#cached_listener_position = new Vector3();
|
|
280
|
+
|
|
245
281
|
update(timeDelta) {
|
|
246
282
|
const entityManager = this.entityManager;
|
|
247
283
|
const ecd = entityManager.dataset;
|
|
@@ -255,13 +291,13 @@ export class SoundEmitterSystem extends System {
|
|
|
255
291
|
|
|
256
292
|
const soundListener = ecd.getAnyComponent(SoundListener);
|
|
257
293
|
|
|
258
|
-
let listenerTransform;
|
|
259
|
-
|
|
260
294
|
if (soundListener.entity !== -1) {
|
|
261
|
-
listenerTransform = ecd.getComponent(soundListener.entity, Transform);
|
|
295
|
+
const listenerTransform = ecd.getComponent(soundListener.entity, Transform);
|
|
262
296
|
|
|
263
297
|
const listenerPosition = listenerTransform.position;
|
|
264
298
|
|
|
299
|
+
this.#cached_listener_position.copy(listenerPosition);
|
|
300
|
+
|
|
265
301
|
const query = BVHQueryIntersectsSphere.from([listenerPosition.x, listenerPosition.y, listenerPosition.z, 0]);
|
|
266
302
|
|
|
267
303
|
const matchCount = bvh_query_user_data_generic(
|