@dcl/ecs 7.4.9 → 7.4.10-8394982680.commit-841a9e7
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/components/extended/AudioSource.d.ts +28 -0
- package/dist/components/extended/AudioSource.js +26 -0
- package/dist/components/generated/pb/decentraland/sdk/components/audio_source.gen.d.ts +11 -0
- package/dist/components/generated/pb/decentraland/sdk/components/audio_source.gen.js +27 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +3 -0
- package/dist/components/types.d.ts +1 -0
- package/dist/composite/proto/gen/composite.gen.js +1 -1
- package/dist/composite/proto/gen/google/protobuf/struct.gen.js +1 -1
- package/dist/engine/index.js +1 -0
- package/dist/engine/types.d.ts +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -0
- package/dist/systems/tween.d.ts +6 -1
- package/dist/systems/tween.js +11 -2
- package/dist-cjs/components/extended/AudioSource.d.ts +28 -0
- package/dist-cjs/components/extended/AudioSource.js +30 -0
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/audio_source.gen.d.ts +11 -0
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/audio_source.gen.js +27 -1
- package/dist-cjs/components/index.d.ts +2 -0
- package/dist-cjs/components/index.js +5 -1
- package/dist-cjs/components/types.d.ts +1 -0
- package/dist-cjs/composite/proto/gen/composite.gen.js +1 -1
- package/dist-cjs/composite/proto/gen/google/protobuf/struct.gen.js +1 -1
- package/dist-cjs/engine/index.js +1 -0
- package/dist-cjs/engine/types.d.ts +1 -0
- package/dist-cjs/index.d.ts +3 -1
- package/dist-cjs/index.js +3 -1
- package/dist-cjs/systems/tween.d.ts +6 -1
- package/dist-cjs/systems/tween.js +11 -2
- package/package.json +2 -2
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Entity, IEngine } from '../../engine';
|
|
2
|
+
import { LastWriteWinElementSetComponentDefinition } from '../../engine/component';
|
|
3
|
+
import { PBAudioSource } from '../generated/pb/decentraland/sdk/components/audio_source.gen';
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface AudioSourceComponentDefinitionExtended extends LastWriteWinElementSetComponentDefinition<PBAudioSource> {
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*
|
|
11
|
+
* Set playing=true the sound `$name`
|
|
12
|
+
* @param entity - entity with AudioSource component
|
|
13
|
+
* @param src - the path to the sound to play
|
|
14
|
+
* @param resetCursor - the sound starts at 0 or continues from the current cursor position
|
|
15
|
+
* @returns true in successful playing, false if it doesn't find the AudioSource component
|
|
16
|
+
*/
|
|
17
|
+
playSound(entity: Entity, src: string, resetCursor?: boolean): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
*
|
|
21
|
+
* Set playing=false all sounds
|
|
22
|
+
* @param entity - entity with AudioSource component
|
|
23
|
+
* @param resetCursor - the sound stops at 0 or at the current cursor position
|
|
24
|
+
* @returns true in successful stopping, false if it doesn't find the AudioSource component
|
|
25
|
+
*/
|
|
26
|
+
stopSound(entity: Entity, resetCursor?: boolean): boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function defineAudioSourceComponent(engine: Pick<IEngine, 'defineComponentFromSchema'>): AudioSourceComponentDefinitionExtended;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AudioSource } from '../generated/index.gen';
|
|
2
|
+
export function defineAudioSourceComponent(engine) {
|
|
3
|
+
const theComponent = AudioSource(engine);
|
|
4
|
+
return {
|
|
5
|
+
...theComponent,
|
|
6
|
+
playSound(entity, src, resetCursor = true) {
|
|
7
|
+
// Get the mutable to modify
|
|
8
|
+
const audioSource = theComponent.getMutableOrNull(entity);
|
|
9
|
+
if (!audioSource)
|
|
10
|
+
return false;
|
|
11
|
+
audioSource.audioClipUrl = src;
|
|
12
|
+
audioSource.playing = true;
|
|
13
|
+
audioSource.currentTime = resetCursor ? 0 : audioSource.currentTime;
|
|
14
|
+
return true;
|
|
15
|
+
},
|
|
16
|
+
stopSound(entity, resetCursor = true) {
|
|
17
|
+
// Get the mutable to modify
|
|
18
|
+
const audioSource = theComponent.getMutableOrNull(entity);
|
|
19
|
+
if (!audioSource)
|
|
20
|
+
return false;
|
|
21
|
+
audioSource.playing = false;
|
|
22
|
+
audioSource.currentTime = resetCursor ? 0 : audioSource.currentTime;
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -9,6 +9,13 @@ import _m0 from "protobufjs/minimal";
|
|
|
9
9
|
* Note that the `audio_clip_url` is not actually a URL, but rather the path of a file bundled with
|
|
10
10
|
* the scene and declared in its manifest. The name was chosen because the URL use-case will
|
|
11
11
|
* eventually be supported.
|
|
12
|
+
*
|
|
13
|
+
* `playing=true` when it's previously `playing=true`
|
|
14
|
+
* a) if clip is playing and `current_time` is NOT SET, the clip remains in the current `current_time`
|
|
15
|
+
* b) if clip is stopped or `current_time` is set, the clip is played from the `current_time` (if set) or from the beginning
|
|
16
|
+
*
|
|
17
|
+
* If other property (volume, loop, pitch) is changed while playing, the clip is keep playing with the new properties
|
|
18
|
+
* Changing `audio_clip_url` while playing stops the current clip and plays the new one (as a new instance)
|
|
12
19
|
*/
|
|
13
20
|
/**
|
|
14
21
|
* @public
|
|
@@ -24,6 +31,10 @@ export interface PBAudioSource {
|
|
|
24
31
|
pitch?: number | undefined;
|
|
25
32
|
/** the clip path as given in the `files` array of the scene's manifest. */
|
|
26
33
|
audioClipUrl: string;
|
|
34
|
+
/** specifies the current playback time of the clip in seconds (default: 0). */
|
|
35
|
+
currentTime?: number | undefined;
|
|
36
|
+
/** whether the audio plays at constant volume across the scene. */
|
|
37
|
+
global?: boolean | undefined;
|
|
27
38
|
}
|
|
28
39
|
/**
|
|
29
40
|
* @public
|
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
import _m0 from "protobufjs/minimal";
|
|
3
3
|
const protobufPackageSarasa = "decentraland.sdk.components";
|
|
4
4
|
function createBasePBAudioSource() {
|
|
5
|
-
return {
|
|
5
|
+
return {
|
|
6
|
+
playing: undefined,
|
|
7
|
+
volume: undefined,
|
|
8
|
+
loop: undefined,
|
|
9
|
+
pitch: undefined,
|
|
10
|
+
audioClipUrl: "",
|
|
11
|
+
currentTime: undefined,
|
|
12
|
+
global: undefined,
|
|
13
|
+
};
|
|
6
14
|
}
|
|
7
15
|
/**
|
|
8
16
|
* @public
|
|
@@ -25,6 +33,12 @@ export var PBAudioSource;
|
|
|
25
33
|
if (message.audioClipUrl !== "") {
|
|
26
34
|
writer.uint32(42).string(message.audioClipUrl);
|
|
27
35
|
}
|
|
36
|
+
if (message.currentTime !== undefined) {
|
|
37
|
+
writer.uint32(53).float(message.currentTime);
|
|
38
|
+
}
|
|
39
|
+
if (message.global !== undefined) {
|
|
40
|
+
writer.uint32(56).bool(message.global);
|
|
41
|
+
}
|
|
28
42
|
return writer;
|
|
29
43
|
}
|
|
30
44
|
PBAudioSource.encode = encode;
|
|
@@ -65,6 +79,18 @@ export var PBAudioSource;
|
|
|
65
79
|
}
|
|
66
80
|
message.audioClipUrl = reader.string();
|
|
67
81
|
continue;
|
|
82
|
+
case 6:
|
|
83
|
+
if (tag !== 53) {
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
message.currentTime = reader.float();
|
|
87
|
+
continue;
|
|
88
|
+
case 7:
|
|
89
|
+
if (tag !== 56) {
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
message.global = reader.bool();
|
|
93
|
+
continue;
|
|
68
94
|
}
|
|
69
95
|
if ((tag & 7) === 4 || tag === 0) {
|
|
70
96
|
break;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { GrowOnlyValueSetComponentDefinition, LastWriteWinElementSetComponentDefinition } from '../engine/component';
|
|
2
2
|
import { IEngine } from '../engine/types';
|
|
3
3
|
import { AnimatorComponentDefinitionExtended } from './extended/Animator';
|
|
4
|
+
import { AudioSourceComponentDefinitionExtended } from './extended/AudioSource';
|
|
4
5
|
import { MaterialComponentDefinitionExtended } from './extended/Material';
|
|
5
6
|
import { MeshColliderComponentDefinitionExtended } from './extended/MeshCollider';
|
|
6
7
|
import { MeshRendererComponentDefinitionExtended } from './extended/MeshRenderer';
|
|
@@ -16,6 +17,7 @@ export type { GrowOnlyValueSetComponentDefinition, LastWriteWinElementSetCompone
|
|
|
16
17
|
export declare const Transform: LwwComponentGetter<TransformComponentExtended>;
|
|
17
18
|
export declare const Material: LwwComponentGetter<MaterialComponentDefinitionExtended>;
|
|
18
19
|
export declare const Animator: LwwComponentGetter<AnimatorComponentDefinitionExtended>;
|
|
20
|
+
export declare const AudioSource: LwwComponentGetter<AudioSourceComponentDefinitionExtended>;
|
|
19
21
|
export declare const MeshRenderer: LwwComponentGetter<MeshRendererComponentDefinitionExtended>;
|
|
20
22
|
export declare const MeshCollider: LwwComponentGetter<MeshColliderComponentDefinitionExtended>;
|
|
21
23
|
export declare const Tween: LwwComponentGetter<TweenComponentDefinitionExtended>;
|
package/dist/components/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineAnimatorComponent } from './extended/Animator';
|
|
2
|
+
import { defineAudioSourceComponent } from './extended/AudioSource';
|
|
2
3
|
import { defineMaterialComponent } from './extended/Material';
|
|
3
4
|
import { defineMeshColliderComponent } from './extended/MeshCollider';
|
|
4
5
|
import { defineMeshRendererComponent } from './extended/MeshRenderer';
|
|
@@ -16,6 +17,8 @@ export const Material = (engine) => defineMaterialComponent(engine);
|
|
|
16
17
|
/* @__PURE__ */
|
|
17
18
|
export const Animator = (engine) => defineAnimatorComponent(engine);
|
|
18
19
|
/* @__PURE__ */
|
|
20
|
+
export const AudioSource = (engine) => defineAudioSourceComponent(engine);
|
|
21
|
+
/* @__PURE__ */
|
|
19
22
|
export const MeshRenderer = (engine) => defineMeshRendererComponent(engine);
|
|
20
23
|
/* @__PURE__ */
|
|
21
24
|
export const MeshCollider = (engine) => defineMeshColliderComponent(engine);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { AnimatorComponentDefinitionExtended } from './extended/Animator';
|
|
2
|
+
export type { AudioSourceComponentDefinitionExtended } from './extended/AudioSource';
|
|
2
3
|
export type { MeshRendererComponentDefinitionExtended } from './extended/MeshRenderer';
|
|
3
4
|
export type { MeshColliderComponentDefinitionExtended } from './extended/MeshCollider';
|
|
4
5
|
export type { TextureHelper, MaterialComponentDefinitionExtended } from './extended/Material';
|
|
@@ -84,7 +84,7 @@ export var CompositeComponent;
|
|
|
84
84
|
if (message.jsonSchema !== undefined) {
|
|
85
85
|
Value.encode(Value.wrap(message.jsonSchema), writer.uint32(18).fork()).ldelim();
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
message.data.forEach((value, key) => {
|
|
88
88
|
CompositeComponent_DataEntry.encode({ key: key, value }, writer.uint32(26).fork()).ldelim();
|
|
89
89
|
});
|
|
90
90
|
return writer;
|
|
@@ -47,7 +47,7 @@ function createBaseStruct() {
|
|
|
47
47
|
export var Struct;
|
|
48
48
|
(function (Struct) {
|
|
49
49
|
function encode(message, writer = _m0.Writer.create()) {
|
|
50
|
-
|
|
50
|
+
message.fields.forEach((value, key) => {
|
|
51
51
|
if (value !== undefined) {
|
|
52
52
|
Struct_FieldsEntry.encode({ key: key, value }, writer.uint32(10).fork()).ldelim();
|
|
53
53
|
}
|
package/dist/engine/index.js
CHANGED
|
@@ -229,6 +229,7 @@ export function Engine(options) {
|
|
|
229
229
|
await crdtSystem.sendMessages(deletedEntites);
|
|
230
230
|
}
|
|
231
231
|
return {
|
|
232
|
+
_id: Date.now(),
|
|
232
233
|
addEntity: partialEngine.addEntity,
|
|
233
234
|
removeEntity: partialEngine.removeEntity,
|
|
234
235
|
removeEntityWithChildren: partialEngine.removeEntityWithChildren,
|
package/dist/engine/types.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -8,12 +8,14 @@ export * from './systems/events';
|
|
|
8
8
|
export * from './systems/raycast';
|
|
9
9
|
export * from './systems/videoEvents';
|
|
10
10
|
export * from './systems/async-task';
|
|
11
|
+
export * from './systems/tween';
|
|
11
12
|
export * from './engine/entity';
|
|
12
13
|
export * from './components/types';
|
|
13
|
-
import { MaterialComponentDefinitionExtended, MeshColliderComponentDefinitionExtended, MeshRendererComponentDefinitionExtended, TransformComponentExtended, AnimatorComponentDefinitionExtended, ISyncComponents, TweenComponentDefinitionExtended, INetowrkEntity, INetowrkParent } from './components/types';
|
|
14
|
+
import { MaterialComponentDefinitionExtended, MeshColliderComponentDefinitionExtended, MeshRendererComponentDefinitionExtended, TransformComponentExtended, AnimatorComponentDefinitionExtended, AudioSourceComponentDefinitionExtended, ISyncComponents, TweenComponentDefinitionExtended, INetowrkEntity, INetowrkParent } from './components/types';
|
|
14
15
|
import { NameComponent } from './components/manual/Name';
|
|
15
16
|
export declare const Transform: TransformComponentExtended;
|
|
16
17
|
export declare const Animator: AnimatorComponentDefinitionExtended;
|
|
18
|
+
export declare const AudioSource: AudioSourceComponentDefinitionExtended;
|
|
17
19
|
export declare const Material: MaterialComponentDefinitionExtended;
|
|
18
20
|
export declare const MeshRenderer: MeshRendererComponentDefinitionExtended;
|
|
19
21
|
export declare const MeshCollider: MeshColliderComponentDefinitionExtended;
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export * from './systems/events';
|
|
|
9
9
|
export * from './systems/raycast';
|
|
10
10
|
export * from './systems/videoEvents';
|
|
11
11
|
export * from './systems/async-task';
|
|
12
|
+
export * from './systems/tween';
|
|
12
13
|
export * from './engine/entity';
|
|
13
14
|
export * from './components/types';
|
|
14
15
|
// @internal
|
|
@@ -19,6 +20,7 @@ import { engine } from './runtime/initialization';
|
|
|
19
20
|
// export components for global engine
|
|
20
21
|
export const Transform = /* @__PURE__*/ components.Transform(engine);
|
|
21
22
|
export const Animator = /* @__PURE__*/ components.Animator(engine);
|
|
23
|
+
export const AudioSource = /* @__PURE__*/ components.AudioSource(engine);
|
|
22
24
|
export const Material = /* @__PURE__*/ components.Material(engine);
|
|
23
25
|
export const MeshRenderer = /* @__PURE__*/ components.MeshRenderer(engine);
|
|
24
26
|
export const MeshCollider = /* @__PURE__*/ components.MeshCollider(engine);
|
package/dist/systems/tween.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import { Entity } from '../engine';
|
|
1
|
+
import { Entity, IEngine } from '../engine';
|
|
2
2
|
export type TweenSystem = {
|
|
3
3
|
tweenCompleted(entity: Entity): boolean;
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
* @returns tween helper to be used on the scene
|
|
8
|
+
*/
|
|
9
|
+
export declare function createTweenSystem(engine: IEngine): TweenSystem;
|
package/dist/systems/tween.js
CHANGED
|
@@ -2,10 +2,17 @@ import * as components from '../components';
|
|
|
2
2
|
import { ReadWriteByteBuffer } from '../serialization/ByteBuffer';
|
|
3
3
|
import { dataCompare } from './crdt/utils';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Avoid creating multiple tween systems
|
|
6
|
+
*/
|
|
7
|
+
const cacheTween = new Map();
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
6
10
|
* @returns tween helper to be used on the scene
|
|
7
11
|
*/
|
|
8
12
|
export function createTweenSystem(engine) {
|
|
13
|
+
if (cacheTween.has(engine._id)) {
|
|
14
|
+
return cacheTween.get(engine._id);
|
|
15
|
+
}
|
|
9
16
|
const Tween = components.Tween(engine);
|
|
10
17
|
const TweenState = components.TweenState(engine);
|
|
11
18
|
const TweenSequence = components.TweenSequence(engine);
|
|
@@ -109,8 +116,10 @@ export function createTweenSystem(engine) {
|
|
|
109
116
|
/* istanbul ignore next */
|
|
110
117
|
throw new Error('Invalid tween');
|
|
111
118
|
}
|
|
112
|
-
|
|
119
|
+
const tweenSystem = {
|
|
113
120
|
// This event is fired only once per tween
|
|
114
121
|
tweenCompleted: isCompleted
|
|
115
122
|
};
|
|
123
|
+
cacheTween.set(engine._id, tweenSystem);
|
|
124
|
+
return tweenSystem;
|
|
116
125
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Entity, IEngine } from '../../engine';
|
|
2
|
+
import { LastWriteWinElementSetComponentDefinition } from '../../engine/component';
|
|
3
|
+
import { PBAudioSource } from '../generated/pb/decentraland/sdk/components/audio_source.gen';
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface AudioSourceComponentDefinitionExtended extends LastWriteWinElementSetComponentDefinition<PBAudioSource> {
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*
|
|
11
|
+
* Set playing=true the sound `$name`
|
|
12
|
+
* @param entity - entity with AudioSource component
|
|
13
|
+
* @param src - the path to the sound to play
|
|
14
|
+
* @param resetCursor - the sound starts at 0 or continues from the current cursor position
|
|
15
|
+
* @returns true in successful playing, false if it doesn't find the AudioSource component
|
|
16
|
+
*/
|
|
17
|
+
playSound(entity: Entity, src: string, resetCursor?: boolean): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
*
|
|
21
|
+
* Set playing=false all sounds
|
|
22
|
+
* @param entity - entity with AudioSource component
|
|
23
|
+
* @param resetCursor - the sound stops at 0 or at the current cursor position
|
|
24
|
+
* @returns true in successful stopping, false if it doesn't find the AudioSource component
|
|
25
|
+
*/
|
|
26
|
+
stopSound(entity: Entity, resetCursor?: boolean): boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function defineAudioSourceComponent(engine: Pick<IEngine, 'defineComponentFromSchema'>): AudioSourceComponentDefinitionExtended;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defineAudioSourceComponent = void 0;
|
|
4
|
+
const index_gen_1 = require("../generated/index.gen");
|
|
5
|
+
function defineAudioSourceComponent(engine) {
|
|
6
|
+
const theComponent = (0, index_gen_1.AudioSource)(engine);
|
|
7
|
+
return {
|
|
8
|
+
...theComponent,
|
|
9
|
+
playSound(entity, src, resetCursor = true) {
|
|
10
|
+
// Get the mutable to modify
|
|
11
|
+
const audioSource = theComponent.getMutableOrNull(entity);
|
|
12
|
+
if (!audioSource)
|
|
13
|
+
return false;
|
|
14
|
+
audioSource.audioClipUrl = src;
|
|
15
|
+
audioSource.playing = true;
|
|
16
|
+
audioSource.currentTime = resetCursor ? 0 : audioSource.currentTime;
|
|
17
|
+
return true;
|
|
18
|
+
},
|
|
19
|
+
stopSound(entity, resetCursor = true) {
|
|
20
|
+
// Get the mutable to modify
|
|
21
|
+
const audioSource = theComponent.getMutableOrNull(entity);
|
|
22
|
+
if (!audioSource)
|
|
23
|
+
return false;
|
|
24
|
+
audioSource.playing = false;
|
|
25
|
+
audioSource.currentTime = resetCursor ? 0 : audioSource.currentTime;
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.defineAudioSourceComponent = defineAudioSourceComponent;
|
|
@@ -9,6 +9,13 @@ import _m0 from "protobufjs/minimal";
|
|
|
9
9
|
* Note that the `audio_clip_url` is not actually a URL, but rather the path of a file bundled with
|
|
10
10
|
* the scene and declared in its manifest. The name was chosen because the URL use-case will
|
|
11
11
|
* eventually be supported.
|
|
12
|
+
*
|
|
13
|
+
* `playing=true` when it's previously `playing=true`
|
|
14
|
+
* a) if clip is playing and `current_time` is NOT SET, the clip remains in the current `current_time`
|
|
15
|
+
* b) if clip is stopped or `current_time` is set, the clip is played from the `current_time` (if set) or from the beginning
|
|
16
|
+
*
|
|
17
|
+
* If other property (volume, loop, pitch) is changed while playing, the clip is keep playing with the new properties
|
|
18
|
+
* Changing `audio_clip_url` while playing stops the current clip and plays the new one (as a new instance)
|
|
12
19
|
*/
|
|
13
20
|
/**
|
|
14
21
|
* @public
|
|
@@ -24,6 +31,10 @@ export interface PBAudioSource {
|
|
|
24
31
|
pitch?: number | undefined;
|
|
25
32
|
/** the clip path as given in the `files` array of the scene's manifest. */
|
|
26
33
|
audioClipUrl: string;
|
|
34
|
+
/** specifies the current playback time of the clip in seconds (default: 0). */
|
|
35
|
+
currentTime?: number | undefined;
|
|
36
|
+
/** whether the audio plays at constant volume across the scene. */
|
|
37
|
+
global?: boolean | undefined;
|
|
27
38
|
}
|
|
28
39
|
/**
|
|
29
40
|
* @public
|
|
@@ -8,7 +8,15 @@ exports.PBAudioSource = void 0;
|
|
|
8
8
|
const minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
9
9
|
const protobufPackageSarasa = "decentraland.sdk.components";
|
|
10
10
|
function createBasePBAudioSource() {
|
|
11
|
-
return {
|
|
11
|
+
return {
|
|
12
|
+
playing: undefined,
|
|
13
|
+
volume: undefined,
|
|
14
|
+
loop: undefined,
|
|
15
|
+
pitch: undefined,
|
|
16
|
+
audioClipUrl: "",
|
|
17
|
+
currentTime: undefined,
|
|
18
|
+
global: undefined,
|
|
19
|
+
};
|
|
12
20
|
}
|
|
13
21
|
/**
|
|
14
22
|
* @public
|
|
@@ -31,6 +39,12 @@ var PBAudioSource;
|
|
|
31
39
|
if (message.audioClipUrl !== "") {
|
|
32
40
|
writer.uint32(42).string(message.audioClipUrl);
|
|
33
41
|
}
|
|
42
|
+
if (message.currentTime !== undefined) {
|
|
43
|
+
writer.uint32(53).float(message.currentTime);
|
|
44
|
+
}
|
|
45
|
+
if (message.global !== undefined) {
|
|
46
|
+
writer.uint32(56).bool(message.global);
|
|
47
|
+
}
|
|
34
48
|
return writer;
|
|
35
49
|
}
|
|
36
50
|
PBAudioSource.encode = encode;
|
|
@@ -71,6 +85,18 @@ var PBAudioSource;
|
|
|
71
85
|
}
|
|
72
86
|
message.audioClipUrl = reader.string();
|
|
73
87
|
continue;
|
|
88
|
+
case 6:
|
|
89
|
+
if (tag !== 53) {
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
message.currentTime = reader.float();
|
|
93
|
+
continue;
|
|
94
|
+
case 7:
|
|
95
|
+
if (tag !== 56) {
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
message.global = reader.bool();
|
|
99
|
+
continue;
|
|
74
100
|
}
|
|
75
101
|
if ((tag & 7) === 4 || tag === 0) {
|
|
76
102
|
break;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { GrowOnlyValueSetComponentDefinition, LastWriteWinElementSetComponentDefinition } from '../engine/component';
|
|
2
2
|
import { IEngine } from '../engine/types';
|
|
3
3
|
import { AnimatorComponentDefinitionExtended } from './extended/Animator';
|
|
4
|
+
import { AudioSourceComponentDefinitionExtended } from './extended/AudioSource';
|
|
4
5
|
import { MaterialComponentDefinitionExtended } from './extended/Material';
|
|
5
6
|
import { MeshColliderComponentDefinitionExtended } from './extended/MeshCollider';
|
|
6
7
|
import { MeshRendererComponentDefinitionExtended } from './extended/MeshRenderer';
|
|
@@ -16,6 +17,7 @@ export type { GrowOnlyValueSetComponentDefinition, LastWriteWinElementSetCompone
|
|
|
16
17
|
export declare const Transform: LwwComponentGetter<TransformComponentExtended>;
|
|
17
18
|
export declare const Material: LwwComponentGetter<MaterialComponentDefinitionExtended>;
|
|
18
19
|
export declare const Animator: LwwComponentGetter<AnimatorComponentDefinitionExtended>;
|
|
20
|
+
export declare const AudioSource: LwwComponentGetter<AudioSourceComponentDefinitionExtended>;
|
|
19
21
|
export declare const MeshRenderer: LwwComponentGetter<MeshRendererComponentDefinitionExtended>;
|
|
20
22
|
export declare const MeshCollider: LwwComponentGetter<MeshColliderComponentDefinitionExtended>;
|
|
21
23
|
export declare const Tween: LwwComponentGetter<TweenComponentDefinitionExtended>;
|
|
@@ -17,8 +17,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.NetworkParent = exports.NetworkEntity = exports.SyncComponents = exports.Name = exports.Tween = exports.MeshCollider = exports.MeshRenderer = exports.Animator = exports.Material = exports.Transform = void 0;
|
|
20
|
+
exports.NetworkParent = exports.NetworkEntity = exports.SyncComponents = exports.Name = exports.Tween = exports.MeshCollider = exports.MeshRenderer = exports.AudioSource = exports.Animator = exports.Material = exports.Transform = void 0;
|
|
21
21
|
const Animator_1 = require("./extended/Animator");
|
|
22
|
+
const AudioSource_1 = require("./extended/AudioSource");
|
|
22
23
|
const Material_1 = require("./extended/Material");
|
|
23
24
|
const MeshCollider_1 = require("./extended/MeshCollider");
|
|
24
25
|
const MeshRenderer_1 = require("./extended/MeshRenderer");
|
|
@@ -39,6 +40,9 @@ exports.Material = Material;
|
|
|
39
40
|
const Animator = (engine) => (0, Animator_1.defineAnimatorComponent)(engine);
|
|
40
41
|
exports.Animator = Animator;
|
|
41
42
|
/* @__PURE__ */
|
|
43
|
+
const AudioSource = (engine) => (0, AudioSource_1.defineAudioSourceComponent)(engine);
|
|
44
|
+
exports.AudioSource = AudioSource;
|
|
45
|
+
/* @__PURE__ */
|
|
42
46
|
const MeshRenderer = (engine) => (0, MeshRenderer_1.defineMeshRendererComponent)(engine);
|
|
43
47
|
exports.MeshRenderer = MeshRenderer;
|
|
44
48
|
/* @__PURE__ */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { AnimatorComponentDefinitionExtended } from './extended/Animator';
|
|
2
|
+
export type { AudioSourceComponentDefinitionExtended } from './extended/AudioSource';
|
|
2
3
|
export type { MeshRendererComponentDefinitionExtended } from './extended/MeshRenderer';
|
|
3
4
|
export type { MeshColliderComponentDefinitionExtended } from './extended/MeshCollider';
|
|
4
5
|
export type { TextureHelper, MaterialComponentDefinitionExtended } from './extended/Material';
|
|
@@ -90,7 +90,7 @@ var CompositeComponent;
|
|
|
90
90
|
if (message.jsonSchema !== undefined) {
|
|
91
91
|
struct_gen_1.Value.encode(struct_gen_1.Value.wrap(message.jsonSchema), writer.uint32(18).fork()).ldelim();
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
message.data.forEach((value, key) => {
|
|
94
94
|
CompositeComponent_DataEntry.encode({ key: key, value }, writer.uint32(26).fork()).ldelim();
|
|
95
95
|
});
|
|
96
96
|
return writer;
|
|
@@ -55,7 +55,7 @@ function createBaseStruct() {
|
|
|
55
55
|
var Struct;
|
|
56
56
|
(function (Struct) {
|
|
57
57
|
function encode(message, writer = minimal_1.default.Writer.create()) {
|
|
58
|
-
|
|
58
|
+
message.fields.forEach((value, key) => {
|
|
59
59
|
if (value !== undefined) {
|
|
60
60
|
Struct_FieldsEntry.encode({ key: key, value }, writer.uint32(10).fork()).ldelim();
|
|
61
61
|
}
|
package/dist-cjs/engine/index.js
CHANGED
|
@@ -258,6 +258,7 @@ function Engine(options) {
|
|
|
258
258
|
await crdtSystem.sendMessages(deletedEntites);
|
|
259
259
|
}
|
|
260
260
|
return {
|
|
261
|
+
_id: Date.now(),
|
|
261
262
|
addEntity: partialEngine.addEntity,
|
|
262
263
|
removeEntity: partialEngine.removeEntity,
|
|
263
264
|
removeEntityWithChildren: partialEngine.removeEntityWithChildren,
|
package/dist-cjs/index.d.ts
CHANGED
|
@@ -8,12 +8,14 @@ export * from './systems/events';
|
|
|
8
8
|
export * from './systems/raycast';
|
|
9
9
|
export * from './systems/videoEvents';
|
|
10
10
|
export * from './systems/async-task';
|
|
11
|
+
export * from './systems/tween';
|
|
11
12
|
export * from './engine/entity';
|
|
12
13
|
export * from './components/types';
|
|
13
|
-
import { MaterialComponentDefinitionExtended, MeshColliderComponentDefinitionExtended, MeshRendererComponentDefinitionExtended, TransformComponentExtended, AnimatorComponentDefinitionExtended, ISyncComponents, TweenComponentDefinitionExtended, INetowrkEntity, INetowrkParent } from './components/types';
|
|
14
|
+
import { MaterialComponentDefinitionExtended, MeshColliderComponentDefinitionExtended, MeshRendererComponentDefinitionExtended, TransformComponentExtended, AnimatorComponentDefinitionExtended, AudioSourceComponentDefinitionExtended, ISyncComponents, TweenComponentDefinitionExtended, INetowrkEntity, INetowrkParent } from './components/types';
|
|
14
15
|
import { NameComponent } from './components/manual/Name';
|
|
15
16
|
export declare const Transform: TransformComponentExtended;
|
|
16
17
|
export declare const Animator: AnimatorComponentDefinitionExtended;
|
|
18
|
+
export declare const AudioSource: AudioSourceComponentDefinitionExtended;
|
|
17
19
|
export declare const Material: MaterialComponentDefinitionExtended;
|
|
18
20
|
export declare const MeshRenderer: MeshRendererComponentDefinitionExtended;
|
|
19
21
|
export declare const MeshCollider: MeshColliderComponentDefinitionExtended;
|
package/dist-cjs/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.NetworkParent = exports.NetworkEntity = exports.SyncComponents = exports.Tween = exports.Name = exports.MeshCollider = exports.MeshRenderer = exports.Material = exports.Animator = exports.Transform = exports.components = exports.cyclicParentingChecker = void 0;
|
|
29
|
+
exports.NetworkParent = exports.NetworkEntity = exports.SyncComponents = exports.Tween = exports.Name = exports.MeshCollider = exports.MeshRenderer = exports.Material = exports.AudioSource = exports.Animator = exports.Transform = exports.components = exports.cyclicParentingChecker = void 0;
|
|
30
30
|
// The order of the following imports matters. Please do not auto-sort
|
|
31
31
|
__exportStar(require("./engine"), exports);
|
|
32
32
|
__exportStar(require("./schemas"), exports);
|
|
@@ -39,6 +39,7 @@ __exportStar(require("./systems/events"), exports);
|
|
|
39
39
|
__exportStar(require("./systems/raycast"), exports);
|
|
40
40
|
__exportStar(require("./systems/videoEvents"), exports);
|
|
41
41
|
__exportStar(require("./systems/async-task"), exports);
|
|
42
|
+
__exportStar(require("./systems/tween"), exports);
|
|
42
43
|
__exportStar(require("./engine/entity"), exports);
|
|
43
44
|
__exportStar(require("./components/types"), exports);
|
|
44
45
|
// @internal
|
|
@@ -48,6 +49,7 @@ const initialization_1 = require("./runtime/initialization");
|
|
|
48
49
|
// export components for global engine
|
|
49
50
|
exports.Transform = components.Transform(initialization_1.engine);
|
|
50
51
|
exports.Animator = components.Animator(initialization_1.engine);
|
|
52
|
+
exports.AudioSource = components.AudioSource(initialization_1.engine);
|
|
51
53
|
exports.Material = components.Material(initialization_1.engine);
|
|
52
54
|
exports.MeshRenderer = components.MeshRenderer(initialization_1.engine);
|
|
53
55
|
exports.MeshCollider = components.MeshCollider(initialization_1.engine);
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import { Entity } from '../engine';
|
|
1
|
+
import { Entity, IEngine } from '../engine';
|
|
2
2
|
export type TweenSystem = {
|
|
3
3
|
tweenCompleted(entity: Entity): boolean;
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
* @returns tween helper to be used on the scene
|
|
8
|
+
*/
|
|
9
|
+
export declare function createTweenSystem(engine: IEngine): TweenSystem;
|
|
@@ -28,10 +28,17 @@ const components = __importStar(require("../components"));
|
|
|
28
28
|
const ByteBuffer_1 = require("../serialization/ByteBuffer");
|
|
29
29
|
const utils_1 = require("./crdt/utils");
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Avoid creating multiple tween systems
|
|
32
|
+
*/
|
|
33
|
+
const cacheTween = new Map();
|
|
34
|
+
/**
|
|
35
|
+
* @public
|
|
32
36
|
* @returns tween helper to be used on the scene
|
|
33
37
|
*/
|
|
34
38
|
function createTweenSystem(engine) {
|
|
39
|
+
if (cacheTween.has(engine._id)) {
|
|
40
|
+
return cacheTween.get(engine._id);
|
|
41
|
+
}
|
|
35
42
|
const Tween = components.Tween(engine);
|
|
36
43
|
const TweenState = components.TweenState(engine);
|
|
37
44
|
const TweenSequence = components.TweenSequence(engine);
|
|
@@ -135,9 +142,11 @@ function createTweenSystem(engine) {
|
|
|
135
142
|
/* istanbul ignore next */
|
|
136
143
|
throw new Error('Invalid tween');
|
|
137
144
|
}
|
|
138
|
-
|
|
145
|
+
const tweenSystem = {
|
|
139
146
|
// This event is fired only once per tween
|
|
140
147
|
tweenCompleted: isCompleted
|
|
141
148
|
};
|
|
149
|
+
cacheTween.set(engine._id, tweenSystem);
|
|
150
|
+
return tweenSystem;
|
|
142
151
|
}
|
|
143
152
|
exports.createTweenSystem = createTweenSystem;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/ecs",
|
|
3
3
|
"description": "Decentraland ECS",
|
|
4
|
-
"version": "7.4.
|
|
4
|
+
"version": "7.4.10-8394982680.commit-841a9e7",
|
|
5
5
|
"author": "DCL",
|
|
6
6
|
"bugs": "https://github.com/decentraland/ecs/issues",
|
|
7
7
|
"files": [
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
},
|
|
34
34
|
"types": "./dist/index.d.ts",
|
|
35
35
|
"typings": "./dist/index.d.ts",
|
|
36
|
-
"commit": "
|
|
36
|
+
"commit": "841a9e70897121a4e420f983c632544bb7ff7f12"
|
|
37
37
|
}
|