dacha 0.18.0-alpha.5 → 0.18.0-alpha.7
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/build/contrib/components/audio-source/index.d.ts +1 -1
- package/build/contrib/components/audio-source/index.js +1 -1
- package/build/contrib/components/character-body/index.d.ts +7 -1
- package/build/contrib/components/character-body/index.js +10 -1
- package/build/contrib/events/index.d.ts +0 -49
- package/build/contrib/events/index.js +0 -27
- package/build/contrib/systems/audio-system/api.d.ts +38 -0
- package/build/contrib/systems/audio-system/api.js +44 -0
- package/build/contrib/systems/audio-system/index.d.ts +4 -3
- package/build/contrib/systems/audio-system/index.js +24 -30
- package/build/contrib/systems/character-controller/index.d.ts +1 -1
- package/build/contrib/systems/character-controller/index.js +29 -29
- package/build/contrib/systems/index.d.ts +1 -1
- package/build/contrib/systems/index.js +1 -1
- package/build/contrib/systems/physics-system/subsystems/collision-detection/dynamic-aabb-tree/index.d.ts +28 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/dynamic-aabb-tree/index.js +299 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-box-geometry.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-box-geometry.js +8 -8
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-capsule-geometry.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-capsule-geometry.js +9 -9
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-circle-geometry.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-circle-geometry.js +6 -6
- package/build/contrib/systems/physics-system/subsystems/collision-detection/index.d.ts +2 -1
- package/build/contrib/systems/physics-system/subsystems/collision-detection/index.js +21 -34
- package/build/contrib/systems/physics-system/subsystems/collision-detection/query-utils.js +72 -49
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-box/check-box-cast-and-box.d.ts +6 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-box/check-box-cast-and-box.js +6 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-capsule/check-box-cast-and-capsule.d.ts +6 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-capsule/check-box-cast-and-capsule.js +8 -1
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-capsule/utils.d.ts +3 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-capsule/utils.js +23 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-circle/check-box-cast-and-circle.d.ts +6 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-circle/check-box-cast-and-circle.js +6 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-segment/check-box-cast-and-segment.d.ts +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-segment/check-box-cast-and-segment.js +7 -5
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-utils.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-utils.js +24 -120
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-box/check-capsule-cast-and-box.d.ts +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-box/check-capsule-cast-and-box.js +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-capsule/check-capsule-cast-and-capsule.d.ts +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-capsule/check-capsule-cast-and-capsule.js +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-circle/check-capsule-cast-and-circle.d.ts +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-circle/check-capsule-cast-and-circle.js +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-segment/check-capsule-cast-and-segment.d.ts +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-segment/check-capsule-cast-and-segment.js +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-box/check-circle-cast-and-box.d.ts +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-box/check-circle-cast-and-box.js +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-capsule/check-circle-cast-and-capsule.d.ts +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-capsule/check-circle-cast-and-capsule.js +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-circle/check-circle-cast-and-circle.d.ts +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-circle/check-circle-cast-and-circle.js +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-segment/check-circle-cast-and-segment.d.ts +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-segment/check-circle-cast-and-segment.js +5 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/common/axis-aligned-box-workspace.d.ts +24 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/common/axis-aligned-box-workspace.js +60 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/common/constants.d.ts +1 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/common/constants.js +6 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/common/convex-hull-workspace.d.ts +92 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/common/convex-hull-workspace.js +205 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/common/geometry.d.ts +6 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/common/geometry.js +10 -0
- package/build/contrib/systems/physics-system/subsystems/collision-detection/types.d.ts +5 -0
- package/build/contrib/systems/physics-system/types.d.ts +47 -59
- package/build/contrib/systems/renderer/builders/shape-builder/utils.js +38 -62
- package/build/engine/consts.d.ts +2 -0
- package/build/engine/consts.js +2 -0
- package/build/engine/game-loop.d.ts +6 -2
- package/build/engine/game-loop.js +27 -6
- package/build/engine/math-lib/vector/vector2.d.ts +8 -0
- package/build/engine/math-lib/vector/vector2.js +11 -1
- package/build/events/index.d.ts +2 -2
- package/build/events/index.js +1 -1
- package/package.json +1 -1
|
@@ -26,6 +26,8 @@ export declare class CharacterBody extends Component {
|
|
|
26
26
|
private _up;
|
|
27
27
|
/** @internal Pending one-step displacement consumed by CharacterController */
|
|
28
28
|
_displacement: Vector2;
|
|
29
|
+
/** @internal Whether CharacterController should run overlap recovery */
|
|
30
|
+
_needsRecovery: boolean;
|
|
29
31
|
/** Controls contact classification and whether ground snapping is enabled. */
|
|
30
32
|
motionMode: CharacterMotionMode;
|
|
31
33
|
/** Desired character velocity in world units per second */
|
|
@@ -36,7 +38,7 @@ export declare class CharacterBody extends Component {
|
|
|
36
38
|
maxSlopeAngle: number;
|
|
37
39
|
/** Maximum sweep/slide collision iterations used during one fixed update */
|
|
38
40
|
maxSlides: number;
|
|
39
|
-
/** Maximum overlap depenetration iterations used
|
|
41
|
+
/** Maximum overlap depenetration iterations used when recovery is requested */
|
|
40
42
|
maxRecoveries: number;
|
|
41
43
|
/** Distance used to probe opposite upDirection and keep ground contact over small gaps */
|
|
42
44
|
groundSnapDistance: number;
|
|
@@ -63,4 +65,8 @@ export declare class CharacterBody extends Component {
|
|
|
63
65
|
* update and is already expected to be scaled by delta time.
|
|
64
66
|
*/
|
|
65
67
|
move(displacement: Vector2): void;
|
|
68
|
+
/**
|
|
69
|
+
* Requests overlap depenetration on the next CharacterController update.
|
|
70
|
+
*/
|
|
71
|
+
recover(): void;
|
|
66
72
|
}
|
|
@@ -13,6 +13,8 @@ export class CharacterBody extends Component {
|
|
|
13
13
|
_up;
|
|
14
14
|
/** @internal Pending one-step displacement consumed by CharacterController */
|
|
15
15
|
_displacement;
|
|
16
|
+
/** @internal Whether CharacterController should run overlap recovery */
|
|
17
|
+
_needsRecovery;
|
|
16
18
|
/** Controls contact classification and whether ground snapping is enabled. */
|
|
17
19
|
motionMode;
|
|
18
20
|
/** Desired character velocity in world units per second */
|
|
@@ -23,7 +25,7 @@ export class CharacterBody extends Component {
|
|
|
23
25
|
maxSlopeAngle;
|
|
24
26
|
/** Maximum sweep/slide collision iterations used during one fixed update */
|
|
25
27
|
maxSlides;
|
|
26
|
-
/** Maximum overlap depenetration iterations used
|
|
28
|
+
/** Maximum overlap depenetration iterations used when recovery is requested */
|
|
27
29
|
maxRecoveries;
|
|
28
30
|
/** Distance used to probe opposite upDirection and keep ground contact over small gaps */
|
|
29
31
|
groundSnapDistance;
|
|
@@ -43,6 +45,7 @@ export class CharacterBody extends Component {
|
|
|
43
45
|
super();
|
|
44
46
|
this._up = new Vector2(0, -1);
|
|
45
47
|
this._displacement = new Vector2(0, 0);
|
|
48
|
+
this._needsRecovery = true;
|
|
46
49
|
this.upDirection = new Vector2(config.upDirectionX ?? 0, config.upDirectionY ?? -1);
|
|
47
50
|
this.motionMode = config.motionMode ?? 'surface';
|
|
48
51
|
this.disabled = config.disabled ?? false;
|
|
@@ -77,5 +80,11 @@ export class CharacterBody extends Component {
|
|
|
77
80
|
move(displacement) {
|
|
78
81
|
this._displacement.add(displacement);
|
|
79
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Requests overlap depenetration on the next CharacterController update.
|
|
85
|
+
*/
|
|
86
|
+
recover() {
|
|
87
|
+
this._needsRecovery = true;
|
|
88
|
+
}
|
|
80
89
|
}
|
|
81
90
|
CharacterBody.componentName = 'CharacterBody';
|
|
@@ -65,33 +65,6 @@ export declare const CollisionLeave = "CollisionLeave";
|
|
|
65
65
|
* @category Events
|
|
66
66
|
*/
|
|
67
67
|
export declare const CharacterHit = "CharacterHit";
|
|
68
|
-
/**
|
|
69
|
-
* Dispatched to play audio on an actor
|
|
70
|
-
*
|
|
71
|
-
* @event
|
|
72
|
-
* @type {ActorEvent}
|
|
73
|
-
*
|
|
74
|
-
* @category Events
|
|
75
|
-
*/
|
|
76
|
-
export declare const PlayAudio = "PlayAudio";
|
|
77
|
-
/**
|
|
78
|
-
* Dispatched to stop audio on an actor
|
|
79
|
-
*
|
|
80
|
-
* @event
|
|
81
|
-
* @type {ActorEvent}
|
|
82
|
-
*
|
|
83
|
-
* @category Events
|
|
84
|
-
*/
|
|
85
|
-
export declare const StopAudio = "StopAudio";
|
|
86
|
-
/**
|
|
87
|
-
* Dispatched to set audio volume
|
|
88
|
-
*
|
|
89
|
-
* @event
|
|
90
|
-
* @type {SetAudioSourceVolumeEvent} (for actors) or {@link SetAudioGroupVolumeEvent} (for whole groups)
|
|
91
|
-
*
|
|
92
|
-
* @category Events
|
|
93
|
-
*/
|
|
94
|
-
export declare const SetAudioVolume = "SetAudioVolume";
|
|
95
68
|
/** Event signature for the {@link MouseInput} event
|
|
96
69
|
*
|
|
97
70
|
* @category Events
|
|
@@ -112,16 +85,6 @@ export type GameStatsUpdateEvent = WorldEvent<{
|
|
|
112
85
|
/** Current number of actors in the scene */
|
|
113
86
|
actorsCount: number;
|
|
114
87
|
}>;
|
|
115
|
-
/** Event signature for the {@link SetAudioVolume} event when used on world level
|
|
116
|
-
*
|
|
117
|
-
* @category Events
|
|
118
|
-
*/
|
|
119
|
-
export type SetAudioGroupVolumeEvent = WorldEvent<{
|
|
120
|
-
/** Audio group name to set volume for */
|
|
121
|
-
group: string;
|
|
122
|
-
/** Volume value (0.0 to 1.0) */
|
|
123
|
-
value: number;
|
|
124
|
-
}>;
|
|
125
88
|
/** Event signature for mouse control events
|
|
126
89
|
*
|
|
127
90
|
* @category Events
|
|
@@ -183,29 +146,17 @@ export type CharacterHitEvent = ActorEvent<{
|
|
|
183
146
|
/** Surface classification used by the character controller */
|
|
184
147
|
kind: 'ground' | 'wall' | 'ceiling';
|
|
185
148
|
}>;
|
|
186
|
-
/** Event signature for the {@link SetAudioVolume} event when used on actor level
|
|
187
|
-
*
|
|
188
|
-
* @category Events
|
|
189
|
-
*/
|
|
190
|
-
export type SetAudioSourceVolumeEvent = ActorEvent<{
|
|
191
|
-
/** Volume value (0.0 to 1.0) */
|
|
192
|
-
value: number;
|
|
193
|
-
}>;
|
|
194
149
|
declare module '../../types/events' {
|
|
195
150
|
interface WorldEventMap {
|
|
196
151
|
[MouseInput]: MouseInputEvent;
|
|
197
152
|
[KeyboardInput]: KeyboardInputEvent;
|
|
198
153
|
[GameStatsUpdate]: GameStatsUpdateEvent;
|
|
199
|
-
[SetAudioVolume]: SetAudioGroupVolumeEvent;
|
|
200
154
|
}
|
|
201
155
|
interface ActorEventMap {
|
|
202
156
|
[CollisionEnter]: CollisionEnterEvent;
|
|
203
157
|
[CollisionStay]: CollisionStayEvent;
|
|
204
158
|
[CollisionLeave]: CollisionLeaveEvent;
|
|
205
159
|
[CharacterHit]: CharacterHitEvent;
|
|
206
|
-
[PlayAudio]: ActorEvent;
|
|
207
|
-
[StopAudio]: ActorEvent;
|
|
208
|
-
[SetAudioVolume]: SetAudioSourceVolumeEvent;
|
|
209
160
|
}
|
|
210
161
|
}
|
|
211
162
|
export {};
|
|
@@ -61,30 +61,3 @@ export const CollisionLeave = 'CollisionLeave';
|
|
|
61
61
|
* @category Events
|
|
62
62
|
*/
|
|
63
63
|
export const CharacterHit = 'CharacterHit';
|
|
64
|
-
/**
|
|
65
|
-
* Dispatched to play audio on an actor
|
|
66
|
-
*
|
|
67
|
-
* @event
|
|
68
|
-
* @type {ActorEvent}
|
|
69
|
-
*
|
|
70
|
-
* @category Events
|
|
71
|
-
*/
|
|
72
|
-
export const PlayAudio = 'PlayAudio';
|
|
73
|
-
/**
|
|
74
|
-
* Dispatched to stop audio on an actor
|
|
75
|
-
*
|
|
76
|
-
* @event
|
|
77
|
-
* @type {ActorEvent}
|
|
78
|
-
*
|
|
79
|
-
* @category Events
|
|
80
|
-
*/
|
|
81
|
-
export const StopAudio = 'StopAudio';
|
|
82
|
-
/**
|
|
83
|
-
* Dispatched to set audio volume
|
|
84
|
-
*
|
|
85
|
-
* @event
|
|
86
|
-
* @type {SetAudioSourceVolumeEvent} (for actors) or {@link SetAudioGroupVolumeEvent} (for whole groups)
|
|
87
|
-
*
|
|
88
|
-
* @category Events
|
|
89
|
-
*/
|
|
90
|
-
export const SetAudioVolume = 'SetAudioVolume';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface AudioAPIHandlers {
|
|
2
|
+
getGroupVolume(group: string): number;
|
|
3
|
+
setGroupVolume(group: string, volume: number): void;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* API that provides synchronous audio mixer controls.
|
|
7
|
+
*
|
|
8
|
+
* Actor playback is controlled through AudioSource component state.
|
|
9
|
+
* This API is intended for global audio state such as group and master volume.
|
|
10
|
+
*
|
|
11
|
+
* @category Systems
|
|
12
|
+
*/
|
|
13
|
+
export declare class AudioAPI {
|
|
14
|
+
private handlers;
|
|
15
|
+
constructor(handlers: AudioAPIHandlers);
|
|
16
|
+
/**
|
|
17
|
+
* Current master volume.
|
|
18
|
+
*/
|
|
19
|
+
get masterVolume(): number;
|
|
20
|
+
/**
|
|
21
|
+
* Sets the master volume.
|
|
22
|
+
*/
|
|
23
|
+
set masterVolume(volume: number);
|
|
24
|
+
/**
|
|
25
|
+
* Returns the volume for an audio group.
|
|
26
|
+
*
|
|
27
|
+
* @param group - Audio group name
|
|
28
|
+
* @returns Audio group volume
|
|
29
|
+
*/
|
|
30
|
+
getGroupVolume(group: string): number;
|
|
31
|
+
/**
|
|
32
|
+
* Sets the volume for an audio group.
|
|
33
|
+
*
|
|
34
|
+
* @param group - Audio group name
|
|
35
|
+
* @param volume - New group volume
|
|
36
|
+
*/
|
|
37
|
+
setGroupVolume(group: string, volume: number): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API that provides synchronous audio mixer controls.
|
|
3
|
+
*
|
|
4
|
+
* Actor playback is controlled through AudioSource component state.
|
|
5
|
+
* This API is intended for global audio state such as group and master volume.
|
|
6
|
+
*
|
|
7
|
+
* @category Systems
|
|
8
|
+
*/
|
|
9
|
+
export class AudioAPI {
|
|
10
|
+
handlers;
|
|
11
|
+
constructor(handlers) {
|
|
12
|
+
this.handlers = handlers;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Current master volume.
|
|
16
|
+
*/
|
|
17
|
+
get masterVolume() {
|
|
18
|
+
return this.getGroupVolume('master');
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sets the master volume.
|
|
22
|
+
*/
|
|
23
|
+
set masterVolume(volume) {
|
|
24
|
+
this.setGroupVolume('master', volume);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns the volume for an audio group.
|
|
28
|
+
*
|
|
29
|
+
* @param group - Audio group name
|
|
30
|
+
* @returns Audio group volume
|
|
31
|
+
*/
|
|
32
|
+
getGroupVolume(group) {
|
|
33
|
+
return this.handlers.getGroupVolume(group);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Sets the volume for an audio group.
|
|
37
|
+
*
|
|
38
|
+
* @param group - Audio group name
|
|
39
|
+
* @param volume - New group volume
|
|
40
|
+
*/
|
|
41
|
+
setGroupVolume(group, volume) {
|
|
42
|
+
this.handlers.setGroupVolume(group, volume);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -25,13 +25,14 @@ export declare class AudioSystem extends WorldSystem {
|
|
|
25
25
|
private loadAudio;
|
|
26
26
|
private handleActorAdd;
|
|
27
27
|
private handleActorRemove;
|
|
28
|
-
private handlePlayAudio;
|
|
29
|
-
private handleStopAudio;
|
|
30
|
-
private handleSetAudioVolume;
|
|
31
28
|
private resumeIfSuspended;
|
|
29
|
+
private getGroup;
|
|
30
|
+
private getGroupVolume;
|
|
31
|
+
private setGroupVolume;
|
|
32
32
|
private initAudio;
|
|
33
33
|
private playAudio;
|
|
34
34
|
private stopAudio;
|
|
35
35
|
private updateAudio;
|
|
36
36
|
update(): void;
|
|
37
37
|
}
|
|
38
|
+
export { AudioAPI } from './api';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { WorldSystem } from '../../../engine/system';
|
|
2
|
-
import {
|
|
2
|
+
import { ActorQuery } from '../../../engine/actor';
|
|
3
3
|
import { AddActor, RemoveActor } from '../../../engine/events';
|
|
4
4
|
import { CacheStore } from '../../../engine/data-lib';
|
|
5
5
|
import { AudioSource } from '../../components';
|
|
6
|
-
import {
|
|
6
|
+
import { AudioAPI } from './api';
|
|
7
7
|
import { getAllSources, getAllTemplateSources, loadAudio } from './utils';
|
|
8
8
|
const MASTER_GROUP = 'master';
|
|
9
9
|
const VOLUME_TOLERANCE = 0.001;
|
|
@@ -44,9 +44,13 @@ export class AudioSystem extends WorldSystem {
|
|
|
44
44
|
}, { [MASTER_GROUP]: masterAudioGroup });
|
|
45
45
|
this.audioStore = new CacheStore();
|
|
46
46
|
this.audioState = new Map();
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
const audioApi = new AudioAPI({
|
|
48
|
+
getGroupVolume: (group) => this.getGroupVolume(group),
|
|
49
|
+
setGroupVolume: (group, volume) => {
|
|
50
|
+
this.setGroupVolume(group, volume);
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
this.world.systemApi.register(audioApi);
|
|
50
54
|
window.addEventListener('click', this.resumeIfSuspended, { once: true });
|
|
51
55
|
window.addEventListener('keydown', this.resumeIfSuspended, { once: true });
|
|
52
56
|
window.addEventListener('touchstart', this.resumeIfSuspended, {
|
|
@@ -96,9 +100,6 @@ export class AudioSystem extends WorldSystem {
|
|
|
96
100
|
}
|
|
97
101
|
onWorldDestroy() {
|
|
98
102
|
void this.audioContext.close();
|
|
99
|
-
this.world.removeEventListener(PlayAudio, this.handlePlayAudio);
|
|
100
|
-
this.world.removeEventListener(StopAudio, this.handleStopAudio);
|
|
101
|
-
this.world.removeEventListener(SetAudioVolume, this.handleSetAudioVolume);
|
|
102
103
|
window.removeEventListener('click', this.resumeIfSuspended);
|
|
103
104
|
window.removeEventListener('keydown', this.resumeIfSuspended);
|
|
104
105
|
window.removeEventListener('touchstart', this.resumeIfSuspended);
|
|
@@ -129,28 +130,6 @@ export class AudioSystem extends WorldSystem {
|
|
|
129
130
|
this.audioStore.release(src);
|
|
130
131
|
this.stopAudio(actor);
|
|
131
132
|
};
|
|
132
|
-
handlePlayAudio = (event) => {
|
|
133
|
-
this.playAudio(event.target);
|
|
134
|
-
};
|
|
135
|
-
handleStopAudio = (event) => {
|
|
136
|
-
this.stopAudio(event.target);
|
|
137
|
-
};
|
|
138
|
-
handleSetAudioVolume = (event) => {
|
|
139
|
-
if (event.target instanceof Actor) {
|
|
140
|
-
const audioSource = event.target.getComponent(AudioSource);
|
|
141
|
-
if (!audioSource) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
audioSource.volume = event.value;
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
const audioGroup = this.audioGroups[event.group];
|
|
148
|
-
if (!audioGroup) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
audioGroup.gain.value = event.value;
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
133
|
resumeIfSuspended = () => {
|
|
155
134
|
if (this.audioContext.state === 'suspended') {
|
|
156
135
|
void this.audioContext.resume().catch((err) => {
|
|
@@ -158,6 +137,19 @@ export class AudioSystem extends WorldSystem {
|
|
|
158
137
|
});
|
|
159
138
|
}
|
|
160
139
|
};
|
|
140
|
+
getGroup(group) {
|
|
141
|
+
const audioGroup = this.audioGroups[group];
|
|
142
|
+
if (!audioGroup) {
|
|
143
|
+
throw new Error(`Can't find audio group with the following name: ${group}`);
|
|
144
|
+
}
|
|
145
|
+
return audioGroup;
|
|
146
|
+
}
|
|
147
|
+
getGroupVolume(group) {
|
|
148
|
+
return this.getGroup(group).gain.value;
|
|
149
|
+
}
|
|
150
|
+
setGroupVolume(group, volume) {
|
|
151
|
+
this.getGroup(group).gain.value = volume;
|
|
152
|
+
}
|
|
161
153
|
initAudio(actor) {
|
|
162
154
|
const audioSource = actor.getComponent(AudioSource);
|
|
163
155
|
if (audioSource.autoplay) {
|
|
@@ -217,6 +209,7 @@ export class AudioSystem extends WorldSystem {
|
|
|
217
209
|
if (Math.abs(audioSource.volume - audioState.properties.volume) >
|
|
218
210
|
VOLUME_TOLERANCE) {
|
|
219
211
|
audioState.gainNode.gain.value = audioSource.volume;
|
|
212
|
+
audioState.properties.volume = audioSource.volume;
|
|
220
213
|
}
|
|
221
214
|
}
|
|
222
215
|
update() {
|
|
@@ -236,3 +229,4 @@ export class AudioSystem extends WorldSystem {
|
|
|
236
229
|
}
|
|
237
230
|
}
|
|
238
231
|
AudioSystem.systemName = 'AudioSystem';
|
|
232
|
+
export { AudioAPI } from './api';
|
|
@@ -21,8 +21,8 @@ export declare class CharacterController extends SceneSystem {
|
|
|
21
21
|
private isRecoverableOverlap;
|
|
22
22
|
private resetGroundState;
|
|
23
23
|
private resetState;
|
|
24
|
-
private castAll;
|
|
25
24
|
private cast;
|
|
25
|
+
private castMotion;
|
|
26
26
|
private castGround;
|
|
27
27
|
private recoverOverlaps;
|
|
28
28
|
private handleHit;
|
|
@@ -71,15 +71,15 @@ export class CharacterController extends SceneSystem {
|
|
|
71
71
|
character.onWall = false;
|
|
72
72
|
character.onCeiling = false;
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
cast(actor, position, displacement, hitFilter) {
|
|
75
|
+
if (displacement.squaredMagnitude <= DISTANCE_EPSILON) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
75
78
|
const physicsApi = this.world.systemApi.get(PhysicsAPI);
|
|
76
79
|
const character = actor.getComponent(CharacterBody);
|
|
77
80
|
const transform = actor.getComponent(Transform);
|
|
78
81
|
const distance = displacement.magnitude;
|
|
79
|
-
|
|
80
|
-
return [];
|
|
81
|
-
}
|
|
82
|
-
return physicsApi.castActorAll({
|
|
82
|
+
return physicsApi.castActor({
|
|
83
83
|
actor,
|
|
84
84
|
offset: {
|
|
85
85
|
x: position.x - transform.world.position.x,
|
|
@@ -87,35 +87,28 @@ export class CharacterController extends SceneSystem {
|
|
|
87
87
|
},
|
|
88
88
|
direction: displacement,
|
|
89
89
|
maxDistance: distance + character.skinWidth,
|
|
90
|
+
hitFilter,
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
for (const hit of hits) {
|
|
93
|
+
castMotion(actor, position, displacement) {
|
|
94
|
+
return this.cast(actor, position, displacement, (hit) => {
|
|
95
95
|
if (hit.distance <= DISTANCE_EPSILON &&
|
|
96
96
|
VectorOps.dotProduct(displacement, hit.normal) > DISTANCE_EPSILON) {
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
if (this.isBlockingHit(actor, hit)) {
|
|
100
|
-
return hit;
|
|
97
|
+
return false;
|
|
101
98
|
}
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
return this.isBlockingHit(actor, hit);
|
|
100
|
+
});
|
|
104
101
|
}
|
|
105
102
|
castGround(actor, position, displacement) {
|
|
106
|
-
|
|
107
|
-
for (const hit of hits) {
|
|
108
|
-
if (this.isBlockingHit(actor, hit) &&
|
|
109
|
-
this.isWalkable(actor, hit.normal)) {
|
|
110
|
-
return hit;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return null;
|
|
103
|
+
return this.cast(actor, position, displacement, (hit) => this.isBlockingHit(actor, hit) && this.isWalkable(actor, hit.normal));
|
|
114
104
|
}
|
|
115
105
|
recoverOverlaps(actor, position) {
|
|
116
|
-
const physicsApi = this.world.systemApi.get(PhysicsAPI);
|
|
117
106
|
const character = actor.getComponent(CharacterBody);
|
|
107
|
+
if (!character._needsRecovery) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
118
110
|
const transform = actor.getComponent(Transform);
|
|
111
|
+
const physicsApi = this.world.systemApi.get(PhysicsAPI);
|
|
119
112
|
for (let i = 0; i < character.maxRecoveries; i += 1) {
|
|
120
113
|
const hits = physicsApi.overlapActor({
|
|
121
114
|
actor,
|
|
@@ -138,6 +131,7 @@ export class CharacterController extends SceneSystem {
|
|
|
138
131
|
recovered = true;
|
|
139
132
|
}
|
|
140
133
|
if (!recovered) {
|
|
134
|
+
character._needsRecovery = false;
|
|
141
135
|
break;
|
|
142
136
|
}
|
|
143
137
|
}
|
|
@@ -176,13 +170,16 @@ export class CharacterController extends SceneSystem {
|
|
|
176
170
|
});
|
|
177
171
|
}
|
|
178
172
|
move(actor, position, displacement) {
|
|
173
|
+
if (displacement.squaredMagnitude <= DISTANCE_EPSILON) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
179
176
|
const character = actor.getComponent(CharacterBody);
|
|
180
177
|
for (let i = 0; i < character.maxSlides; i += 1) {
|
|
181
|
-
|
|
182
|
-
if (distance <= DISTANCE_EPSILON) {
|
|
178
|
+
if (displacement.squaredMagnitude <= DISTANCE_EPSILON) {
|
|
183
179
|
break;
|
|
184
180
|
}
|
|
185
|
-
const
|
|
181
|
+
const distance = displacement.magnitude;
|
|
182
|
+
const hit = this.castMotion(actor, position, displacement);
|
|
186
183
|
if (!hit) {
|
|
187
184
|
position.add(displacement);
|
|
188
185
|
break;
|
|
@@ -243,17 +240,20 @@ export class CharacterController extends SceneSystem {
|
|
|
243
240
|
character._displacement.multiplyNumber(0);
|
|
244
241
|
return;
|
|
245
242
|
}
|
|
243
|
+
const position = new Vector2(transform.world.position.x, transform.world.position.y);
|
|
244
|
+
this.recoverOverlaps(actor, position);
|
|
246
245
|
const displacement = character.velocity
|
|
247
246
|
.clone()
|
|
248
247
|
.multiplyNumber(deltaTimeInSeconds)
|
|
249
248
|
.add(character._displacement);
|
|
250
249
|
const movingUp = VectorOps.dotProduct(displacement, character.upDirection) >
|
|
251
250
|
SNAP_EPSILON;
|
|
252
|
-
const position = new Vector2(transform.world.position.x, transform.world.position.y);
|
|
253
|
-
this.recoverOverlaps(actor, position);
|
|
254
251
|
this.move(actor, position, displacement);
|
|
255
252
|
this.updateGroundState(actor, position, movingUp || character.motionMode === 'free');
|
|
256
|
-
|
|
253
|
+
if (Math.abs(position.x - transform.world.position.x) > DISTANCE_EPSILON ||
|
|
254
|
+
Math.abs(position.y - transform.world.position.y) > DISTANCE_EPSILON) {
|
|
255
|
+
rigidBody.movePosition(position);
|
|
256
|
+
}
|
|
257
257
|
character._displacement.multiplyNumber(0);
|
|
258
258
|
});
|
|
259
259
|
this.oneWayValidator.lateUpdate();
|
|
@@ -11,5 +11,5 @@ export { BehaviorSystem, Behavior } from './behavior-system';
|
|
|
11
11
|
export type { BehaviorOptions } from './behavior-system';
|
|
12
12
|
export { UIBridge } from './ui-bridge';
|
|
13
13
|
export type { UIOptions, UIInitFn, UIDestroyFn, LoadUIFn } from './ui-bridge';
|
|
14
|
-
export { AudioSystem } from './audio-system';
|
|
14
|
+
export { AudioSystem, AudioAPI } from './audio-system';
|
|
15
15
|
export { Renderer, RendererAPI, FilterEffect, Shader } from './renderer';
|
|
@@ -9,5 +9,5 @@ export { MouseInputSystem } from './mouse-input-system';
|
|
|
9
9
|
export { PhysicsSystem, PhysicsAPI } from './physics-system';
|
|
10
10
|
export { BehaviorSystem, Behavior } from './behavior-system';
|
|
11
11
|
export { UIBridge } from './ui-bridge';
|
|
12
|
-
export { AudioSystem } from './audio-system';
|
|
12
|
+
export { AudioSystem, AudioAPI } from './audio-system';
|
|
13
13
|
export { Renderer, RendererAPI, FilterEffect, Shader } from './renderer';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AABB } from '../types';
|
|
2
|
+
export type DynamicAABBTreeEntryId = number;
|
|
3
|
+
export declare class DynamicAABBTree<T> {
|
|
4
|
+
private root;
|
|
5
|
+
private nodesById;
|
|
6
|
+
private freeInternalNodes;
|
|
7
|
+
private queryStack;
|
|
8
|
+
private nextId;
|
|
9
|
+
get size(): number;
|
|
10
|
+
insert(aabb: AABB, value: T): DynamicAABBTreeEntryId;
|
|
11
|
+
update(id: DynamicAABBTreeEntryId, aabb: AABB): void;
|
|
12
|
+
remove(id: DynamicAABBTreeEntryId): void;
|
|
13
|
+
query(aabb: AABB, visitor: (value: T) => unknown): void;
|
|
14
|
+
queryAll(aabb: AABB, output?: T[]): T[];
|
|
15
|
+
clear(): void;
|
|
16
|
+
private createNode;
|
|
17
|
+
private getNode;
|
|
18
|
+
private insertLeaf;
|
|
19
|
+
private removeLeaf;
|
|
20
|
+
private createInternalNode;
|
|
21
|
+
private releaseInternalNode;
|
|
22
|
+
private findBestSibling;
|
|
23
|
+
private getDescentCost;
|
|
24
|
+
private fixAncestors;
|
|
25
|
+
private balance;
|
|
26
|
+
private rotateLeft;
|
|
27
|
+
private rotateRight;
|
|
28
|
+
}
|