@dcl/ecs 1.0.0-20220601102612.commit-8b31ac4 → 1.0.0-2448628808.commit-1a55b7a
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/index.d.ts +1676 -3
- package/dist/index.js +5815 -3
- package/dist/index.min.js +1 -0
- package/dist/index.min.js.map +1 -0
- package/package.json +8 -5
- package/dist/Math.d.ts +0 -2
- package/dist/Math.js +0 -2
- package/dist/built-in-types/ArrayType.d.ts +0 -5
- package/dist/built-in-types/ArrayType.js +0 -21
- package/dist/built-in-types/EcsType.d.ts +0 -8
- package/dist/built-in-types/EcsType.js +0 -1
- package/dist/built-in-types/MapType.d.ts +0 -18
- package/dist/built-in-types/MapType.js +0 -22
- package/dist/built-in-types/Optional.d.ts +0 -5
- package/dist/built-in-types/Optional.js +0 -22
- package/dist/built-in-types/basic/Boolean.d.ts +0 -5
- package/dist/built-in-types/basic/Boolean.js +0 -11
- package/dist/built-in-types/basic/Enum.d.ts +0 -5
- package/dist/built-in-types/basic/Enum.js +0 -13
- package/dist/built-in-types/basic/Float.d.ts +0 -9
- package/dist/built-in-types/basic/Float.js +0 -22
- package/dist/built-in-types/basic/Integer.d.ts +0 -17
- package/dist/built-in-types/basic/Integer.js +0 -44
- package/dist/built-in-types/basic/String.d.ts +0 -9
- package/dist/built-in-types/basic/String.js +0 -15
- package/dist/built-in-types/index.d.ts +0 -9
- package/dist/built-in-types/index.js +0 -9
- package/dist/built-in-types/typing.d.ts +0 -16
- package/dist/built-in-types/typing.js +0 -1
- package/dist/components/generated/AudioSource.d.ts +0 -1
- package/dist/components/generated/AudioSource.js +0 -19
- package/dist/components/generated/AudioStream.d.ts +0 -1
- package/dist/components/generated/AudioStream.js +0 -19
- package/dist/components/generated/BoxShape.d.ts +0 -1
- package/dist/components/generated/BoxShape.js +0 -19
- package/dist/components/generated/CylinderShape.d.ts +0 -1
- package/dist/components/generated/CylinderShape.js +0 -19
- package/dist/components/generated/PlaneShape.d.ts +0 -1
- package/dist/components/generated/PlaneShape.js +0 -19
- package/dist/components/generated/SphereShape.d.ts +0 -1
- package/dist/components/generated/SphereShape.js +0 -19
- package/dist/components/generated/index.d.ts +0 -9
- package/dist/components/generated/index.js +0 -16
- package/dist/components/generated/pb/AudioSource.d.ts +0 -8
- package/dist/components/generated/pb/AudioSource.js +0 -74
- package/dist/components/generated/pb/AudioStream.d.ts +0 -5
- package/dist/components/generated/pb/AudioStream.js +0 -49
- package/dist/components/generated/pb/BoxShape.d.ts +0 -6
- package/dist/components/generated/pb/BoxShape.js +0 -70
- package/dist/components/generated/pb/CylinderShape.d.ts +0 -7
- package/dist/components/generated/pb/CylinderShape.js +0 -67
- package/dist/components/generated/pb/PlaneShape.d.ts +0 -6
- package/dist/components/generated/pb/PlaneShape.js +0 -70
- package/dist/components/generated/pb/SphereShape.d.ts +0 -5
- package/dist/components/generated/pb/SphereShape.js +0 -49
- package/dist/components/index.d.ts +0 -15
- package/dist/components/index.js +0 -7
- package/dist/components/legacy/Transform.d.ts +0 -14
- package/dist/components/legacy/Transform.js +0 -28
- package/dist/components/legacy/index.d.ts +0 -11
- package/dist/components/legacy/index.js +0 -9
- package/dist/components/legacy/types.d.ts +0 -51
- package/dist/components/legacy/types.js +0 -53
- package/dist/components/types.d.ts +0 -3
- package/dist/components/types.js +0 -4
- package/dist/engine/component.d.ts +0 -34
- package/dist/engine/component.js +0 -98
- package/dist/engine/entity-utils.d.ts +0 -7
- package/dist/engine/entity-utils.js +0 -18
- package/dist/engine/entity.d.ts +0 -20
- package/dist/engine/entity.js +0 -75
- package/dist/engine/index.d.ts +0 -11
- package/dist/engine/index.js +0 -132
- package/dist/engine/types.d.ts +0 -34
- package/dist/engine/types.js +0 -1
- package/dist/engine/utils.d.ts +0 -4
- package/dist/engine/utils.js +0 -11
- package/dist/proto-definitions/AudioSource.proto +0 -16
- package/dist/proto-definitions/AudioStream.proto +0 -13
- package/dist/proto-definitions/BoxShape.proto +0 -14
- package/dist/proto-definitions/CylinderShape.proto +0 -15
- package/dist/proto-definitions/PlaneShape.proto +0 -14
- package/dist/proto-definitions/README.md +0 -0
- package/dist/proto-definitions/SphereShape.proto +0 -13
- package/dist/proto-definitions/Transform.md +0 -23
- package/dist/serialization/ByteBuffer/index.d.ts +0 -130
- package/dist/serialization/ByteBuffer/index.js +0 -281
- package/dist/serialization/crdt/componentOperation.d.ts +0 -25
- package/dist/serialization/crdt/componentOperation.js +0 -39
- package/dist/serialization/wireMessage.d.ts +0 -39
- package/dist/serialization/wireMessage.js +0 -53
- package/dist/systems/crdt/index.d.ts +0 -6
- package/dist/systems/crdt/index.js +0 -147
- package/dist/systems/crdt/transport.d.ts +0 -8
- package/dist/systems/crdt/transport.js +0 -21
- package/dist/systems/crdt/types.d.ts +0 -10
- package/dist/systems/crdt/types.js +0 -1
- package/dist/systems/crdt/utils.d.ts +0 -11
- package/dist/systems/crdt/utils.js +0 -51
package/dist/engine/component.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { createByteBuffer } from '../serialization/ByteBuffer';
|
|
2
|
-
import { deepReadonly } from './utils';
|
|
3
|
-
export function defineComponent(componentId, spec
|
|
4
|
-
// meta: { syncFlags }
|
|
5
|
-
) {
|
|
6
|
-
const data = new Map();
|
|
7
|
-
const dirtyIterator = new Set();
|
|
8
|
-
return {
|
|
9
|
-
_id: componentId,
|
|
10
|
-
isDirty: function (entity) {
|
|
11
|
-
return dirtyIterator.has(entity);
|
|
12
|
-
},
|
|
13
|
-
has: function (entity) {
|
|
14
|
-
return data.has(entity);
|
|
15
|
-
},
|
|
16
|
-
deleteFrom: function (entity) {
|
|
17
|
-
const component = data.get(entity);
|
|
18
|
-
data.delete(entity);
|
|
19
|
-
dirtyIterator.add(entity);
|
|
20
|
-
return component || null;
|
|
21
|
-
},
|
|
22
|
-
getOrNull: function (entity) {
|
|
23
|
-
const component = data.get(entity);
|
|
24
|
-
return component ? deepReadonly(component) : null;
|
|
25
|
-
},
|
|
26
|
-
getFrom: function (entity) {
|
|
27
|
-
const component = data.get(entity);
|
|
28
|
-
if (!component) {
|
|
29
|
-
throw new Error(`[getFrom] Component ${componentId} for ${entity} not found`);
|
|
30
|
-
}
|
|
31
|
-
return deepReadonly(component);
|
|
32
|
-
},
|
|
33
|
-
create: function (entity, value) {
|
|
34
|
-
const component = data.get(entity);
|
|
35
|
-
if (component) {
|
|
36
|
-
throw new Error(`[create] Component ${componentId} for ${entity} already exists`);
|
|
37
|
-
}
|
|
38
|
-
data.set(entity, value);
|
|
39
|
-
dirtyIterator.add(entity);
|
|
40
|
-
return value;
|
|
41
|
-
},
|
|
42
|
-
createOrReplace: function (entity, value) {
|
|
43
|
-
data.set(entity, value);
|
|
44
|
-
dirtyIterator.add(entity);
|
|
45
|
-
return value;
|
|
46
|
-
},
|
|
47
|
-
mutable: function (entity) {
|
|
48
|
-
const component = data.get(entity);
|
|
49
|
-
if (!component) {
|
|
50
|
-
throw new Error(`[mutable] Component ${componentId} for ${entity} not found`);
|
|
51
|
-
}
|
|
52
|
-
dirtyIterator.add(entity);
|
|
53
|
-
return component;
|
|
54
|
-
},
|
|
55
|
-
iterator: function* () {
|
|
56
|
-
for (const [entity, component] of data) {
|
|
57
|
-
yield [entity, component];
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
dirtyIterator: function* () {
|
|
61
|
-
for (const entity of dirtyIterator) {
|
|
62
|
-
yield entity;
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
toBinary(entity) {
|
|
66
|
-
const component = data.get(entity);
|
|
67
|
-
if (!component) {
|
|
68
|
-
throw new Error(`Component ${componentId} for ${entity} not found`);
|
|
69
|
-
}
|
|
70
|
-
const writeBuffer = createByteBuffer();
|
|
71
|
-
spec.serialize(component, writeBuffer);
|
|
72
|
-
return writeBuffer;
|
|
73
|
-
},
|
|
74
|
-
writeToByteBuffer(entity, buffer) {
|
|
75
|
-
const component = data.get(entity);
|
|
76
|
-
if (!component) {
|
|
77
|
-
throw new Error(`[toBinary] Component ${componentId} for ${entity} not found`);
|
|
78
|
-
}
|
|
79
|
-
spec.serialize(component, buffer);
|
|
80
|
-
},
|
|
81
|
-
updateFromBinary(entity, buffer) {
|
|
82
|
-
const component = data.get(entity);
|
|
83
|
-
if (!component) {
|
|
84
|
-
throw new Error(`[updateFromBinary] Component ${componentId} for ${entity} not found`);
|
|
85
|
-
}
|
|
86
|
-
return this.upsertFromBinary(entity, buffer);
|
|
87
|
-
},
|
|
88
|
-
upsertFromBinary(entity, buffer) {
|
|
89
|
-
const newValue = spec.deserialize(buffer);
|
|
90
|
-
data.set(entity, newValue);
|
|
91
|
-
dirtyIterator.add(entity);
|
|
92
|
-
return newValue;
|
|
93
|
-
},
|
|
94
|
-
clearDirty: function () {
|
|
95
|
-
dirtyIterator.clear();
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export var EntityUtils;
|
|
2
|
-
(function (EntityUtils) {
|
|
3
|
-
EntityUtils.MAX_ENTITIES = 10000;
|
|
4
|
-
let offset = EntityUtils.MAX_ENTITIES;
|
|
5
|
-
function getOffset() {
|
|
6
|
-
const off = offset + 1;
|
|
7
|
-
offset += EntityUtils.MAX_ENTITIES;
|
|
8
|
-
return off;
|
|
9
|
-
}
|
|
10
|
-
EntityUtils.getOffset = getOffset;
|
|
11
|
-
const STATIC_ENTITIES = [0, EntityUtils.MAX_ENTITIES];
|
|
12
|
-
function isStaticEntity(entity) {
|
|
13
|
-
const [min, max] = STATIC_ENTITIES;
|
|
14
|
-
return entity >= min && entity <= max;
|
|
15
|
-
}
|
|
16
|
-
EntityUtils.isStaticEntity = isStaticEntity;
|
|
17
|
-
})(EntityUtils || (EntityUtils = {}));
|
|
18
|
-
export default EntityUtils;
|
package/dist/engine/entity.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
declare const entitySymbol: unique symbol;
|
|
2
|
-
/**
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
export declare type Entity = number & {
|
|
6
|
-
[entitySymbol]: true;
|
|
7
|
-
};
|
|
8
|
-
export declare function EntityContainer(): {
|
|
9
|
-
generateEntity(dynamic?: boolean): Entity;
|
|
10
|
-
removeEntity(entity: Entity): void;
|
|
11
|
-
getUnusedEntities(): Set<Entity>;
|
|
12
|
-
getUsedEntities(): Set<Entity>;
|
|
13
|
-
};
|
|
14
|
-
declare function Entity(withOffset?: boolean): {
|
|
15
|
-
getUnusedEntities(): Set<Entity>;
|
|
16
|
-
getUsedEntities(): Set<Entity>;
|
|
17
|
-
generateEntity: () => Entity;
|
|
18
|
-
removeEntity: (entity: Entity) => void;
|
|
19
|
-
};
|
|
20
|
-
export {};
|
package/dist/engine/entity.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { EntityUtils } from './entity-utils';
|
|
2
|
-
export function EntityContainer() {
|
|
3
|
-
const staticEntity = Entity();
|
|
4
|
-
const dynamicEntity = Entity(true);
|
|
5
|
-
return {
|
|
6
|
-
generateEntity(dynamic = false) {
|
|
7
|
-
if (dynamic)
|
|
8
|
-
return dynamicEntity.generateEntity();
|
|
9
|
-
return staticEntity.generateEntity();
|
|
10
|
-
},
|
|
11
|
-
removeEntity(entity) {
|
|
12
|
-
staticEntity.removeEntity(entity);
|
|
13
|
-
dynamicEntity.removeEntity(entity);
|
|
14
|
-
},
|
|
15
|
-
getUnusedEntities() {
|
|
16
|
-
return new Set([
|
|
17
|
-
...staticEntity.getUnusedEntities(),
|
|
18
|
-
...dynamicEntity.getUnusedEntities()
|
|
19
|
-
]);
|
|
20
|
-
},
|
|
21
|
-
getUsedEntities() {
|
|
22
|
-
return new Set([
|
|
23
|
-
...staticEntity.getUsedEntities(),
|
|
24
|
-
...dynamicEntity.getUsedEntities()
|
|
25
|
-
]);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function Entity(withOffset = false) {
|
|
30
|
-
function createEntity(entity) {
|
|
31
|
-
return entity;
|
|
32
|
-
}
|
|
33
|
-
// TODO: getoffset from a server?
|
|
34
|
-
const offset = withOffset ? EntityUtils.getOffset() : 0;
|
|
35
|
-
const usedEntities = new Set();
|
|
36
|
-
const unusedEntities = new Set();
|
|
37
|
-
function generateEntity() {
|
|
38
|
-
if (!unusedEntities.size && !usedEntities.size) {
|
|
39
|
-
const entity = createEntity(offset);
|
|
40
|
-
usedEntities.add(entity);
|
|
41
|
-
return entity;
|
|
42
|
-
}
|
|
43
|
-
// TODO: what happens if we delete an entity
|
|
44
|
-
// and creates a new one in the same tick
|
|
45
|
-
const iterator = unusedEntities[Symbol.iterator]().next();
|
|
46
|
-
if (iterator.done) {
|
|
47
|
-
const entity = createEntity(Math.max(...usedEntities.values()) + 1);
|
|
48
|
-
if (entity >= EntityUtils.MAX_ENTITIES + offset) {
|
|
49
|
-
throw new Error('Entity rate limit exceed');
|
|
50
|
-
}
|
|
51
|
-
usedEntities.add(entity);
|
|
52
|
-
return entity;
|
|
53
|
-
}
|
|
54
|
-
const entity = iterator.value;
|
|
55
|
-
unusedEntities.delete(entity);
|
|
56
|
-
usedEntities.add(entity);
|
|
57
|
-
return entity;
|
|
58
|
-
}
|
|
59
|
-
function removeEntity(entity) {
|
|
60
|
-
if (!usedEntities.has(entity))
|
|
61
|
-
return;
|
|
62
|
-
usedEntities.delete(entity);
|
|
63
|
-
unusedEntities.add(entity);
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
getUnusedEntities() {
|
|
67
|
-
return new Set(unusedEntities);
|
|
68
|
-
},
|
|
69
|
-
getUsedEntities() {
|
|
70
|
-
return new Set(usedEntities);
|
|
71
|
-
},
|
|
72
|
-
generateEntity,
|
|
73
|
-
removeEntity
|
|
74
|
-
};
|
|
75
|
-
}
|
package/dist/engine/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { SdkComponetns } from '../components';
|
|
2
|
-
import { Entity } from './entity';
|
|
3
|
-
import { ComponentType, ComponentDefinition } from './component';
|
|
4
|
-
import { IEngine } from './types';
|
|
5
|
-
import { ByteBuffer } from '../serialization/ByteBuffer';
|
|
6
|
-
export { ComponentType, Entity, ByteBuffer, SdkComponetns, ComponentDefinition };
|
|
7
|
-
export * from './types';
|
|
8
|
-
/**
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export declare function Engine(): IEngine;
|
package/dist/engine/index.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { defineSdkComponents } from '../components';
|
|
2
|
-
import { crdtSceneSystem } from '../systems/crdt';
|
|
3
|
-
import { EntityContainer } from './entity';
|
|
4
|
-
import { defineComponent as defComponent } from './component';
|
|
5
|
-
export * from './types';
|
|
6
|
-
function preEngine() {
|
|
7
|
-
const entityContainer = EntityContainer();
|
|
8
|
-
const componentsDefinition = new Map();
|
|
9
|
-
// TODO: find a way to make this work.
|
|
10
|
-
// Maybe a proxy/callback to be up-to-date
|
|
11
|
-
const entitiesComponent = new Map();
|
|
12
|
-
const systems = new Set();
|
|
13
|
-
function addSystem(fn) {
|
|
14
|
-
if (systems.has(fn)) {
|
|
15
|
-
throw new Error('System already added');
|
|
16
|
-
}
|
|
17
|
-
systems.add(fn);
|
|
18
|
-
}
|
|
19
|
-
function addEntity(dynamic = false) {
|
|
20
|
-
// entitiesCompnonent.set(entity, new Set())
|
|
21
|
-
const entity = entityContainer.generateEntity(dynamic);
|
|
22
|
-
return entity;
|
|
23
|
-
}
|
|
24
|
-
function addDynamicEntity() {
|
|
25
|
-
return addEntity(true);
|
|
26
|
-
}
|
|
27
|
-
function removeEntity(entity) {
|
|
28
|
-
// TODO: Remove all the components of that entity
|
|
29
|
-
for (const [, component] of componentsDefinition) {
|
|
30
|
-
if (component.has(entity)) {
|
|
31
|
-
component.deleteFrom(entity);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
// entitiesComponent.delete(entity)
|
|
35
|
-
return entityContainer.removeEntity(entity);
|
|
36
|
-
}
|
|
37
|
-
function defineComponent(componentId, spec) {
|
|
38
|
-
if (componentsDefinition.get(componentId)) {
|
|
39
|
-
throw new Error(`Component ${componentId} already declared`);
|
|
40
|
-
}
|
|
41
|
-
const newComponent = defComponent(componentId, spec);
|
|
42
|
-
componentsDefinition.set(componentId, newComponent);
|
|
43
|
-
return newComponent;
|
|
44
|
-
}
|
|
45
|
-
function getComponent(componentId) {
|
|
46
|
-
const component = componentsDefinition.get(componentId);
|
|
47
|
-
if (!component) {
|
|
48
|
-
throw new Error('Component not found. You need to declare the components at the beginnig of the engine declaration');
|
|
49
|
-
}
|
|
50
|
-
return component;
|
|
51
|
-
}
|
|
52
|
-
function* mutableGroupOf(...components) {
|
|
53
|
-
for (const [entity, ...groupComp] of getComponentDefGroup(...components)) {
|
|
54
|
-
yield [entity, ...groupComp.map((c) => c.mutable(entity))];
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function* groupOf(...components) {
|
|
58
|
-
for (const [entity, ...groupComp] of getComponentDefGroup(...components)) {
|
|
59
|
-
yield [entity, ...groupComp.map((c) => c.getFrom(entity))];
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function* getComponentDefGroup(...args) {
|
|
63
|
-
const [firstComponentDef, ...componentDefinitions] = args;
|
|
64
|
-
for (const [entity] of firstComponentDef.iterator()) {
|
|
65
|
-
let matches = true;
|
|
66
|
-
for (const componentDef of componentDefinitions) {
|
|
67
|
-
if (!componentDef.has(entity)) {
|
|
68
|
-
matches = false;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (matches) {
|
|
73
|
-
yield [entity, ...args];
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
78
|
-
entitiesComponent,
|
|
79
|
-
componentsDefinition,
|
|
80
|
-
systems,
|
|
81
|
-
addEntity,
|
|
82
|
-
addDynamicEntity,
|
|
83
|
-
removeEntity,
|
|
84
|
-
addSystem,
|
|
85
|
-
defineComponent,
|
|
86
|
-
mutableGroupOf,
|
|
87
|
-
groupOf,
|
|
88
|
-
getComponent
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* @public
|
|
93
|
-
*/
|
|
94
|
-
export function Engine() {
|
|
95
|
-
const engine = preEngine();
|
|
96
|
-
const crdtSystem = crdtSceneSystem(engine);
|
|
97
|
-
const baseComponents = defineSdkComponents(engine);
|
|
98
|
-
function update(dt) {
|
|
99
|
-
crdtSystem.receiveMessages();
|
|
100
|
-
for (const system of engine.systems) {
|
|
101
|
-
system(dt);
|
|
102
|
-
}
|
|
103
|
-
// TODO: Perf tip
|
|
104
|
-
// Should we add some dirtyIteratorSet at engine level so we dont have
|
|
105
|
-
// to iterate all the component definitions to get the dirty ones ?
|
|
106
|
-
const dirtySet = new Map();
|
|
107
|
-
for (const [componentId, definition] of engine.componentsDefinition) {
|
|
108
|
-
for (const entity of definition.dirtyIterator()) {
|
|
109
|
-
if (!dirtySet.has(entity)) {
|
|
110
|
-
dirtySet.set(entity, new Set());
|
|
111
|
-
}
|
|
112
|
-
dirtySet.get(entity).add(componentId);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
crdtSystem.createMessages(dirtySet);
|
|
116
|
-
for (const [_componentId, definition] of engine.componentsDefinition) {
|
|
117
|
-
definition.clearDirty();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return {
|
|
121
|
-
addEntity: engine.addEntity,
|
|
122
|
-
addDynamicEntity: engine.addDynamicEntity,
|
|
123
|
-
removeEntity: engine.removeEntity,
|
|
124
|
-
addSystem: engine.addSystem,
|
|
125
|
-
defineComponent: engine.defineComponent,
|
|
126
|
-
mutableGroupOf: engine.mutableGroupOf,
|
|
127
|
-
groupOf: engine.groupOf,
|
|
128
|
-
getComponent: engine.getComponent,
|
|
129
|
-
update,
|
|
130
|
-
baseComponents
|
|
131
|
-
};
|
|
132
|
-
}
|
package/dist/engine/types.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { EcsType } from '../built-in-types/EcsType';
|
|
2
|
-
import { SdkComponetns } from '../components';
|
|
3
|
-
import { ComponentDefinition as CompDef } from './component';
|
|
4
|
-
import { Entity } from './entity';
|
|
5
|
-
import type { DeepReadonly } from './utils';
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export declare type Unpacked<T> = T extends (infer U)[] ? U : T;
|
|
10
|
-
/**
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
export declare type Update = (dt: number) => void;
|
|
14
|
-
/**
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
export declare type ComponentEcsType<T extends [CompDef, ...CompDef[]]> = {
|
|
18
|
-
[K in keyof T]: T[K] extends CompDef ? ReturnType<T[K]['mutable']> : never;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* @public
|
|
22
|
-
*/
|
|
23
|
-
export declare type IEngine = {
|
|
24
|
-
addEntity(dynamic?: boolean): Entity;
|
|
25
|
-
addDynamicEntity(): Entity;
|
|
26
|
-
removeEntity(entity: Entity): void;
|
|
27
|
-
addSystem(system: Update): void;
|
|
28
|
-
defineComponent<T extends EcsType>(componentId: number, spec: T): CompDef<T>;
|
|
29
|
-
mutableGroupOf<T extends [CompDef, ...CompDef[]]>(...components: T): Iterable<[Entity, ...ComponentEcsType<T>]>;
|
|
30
|
-
groupOf<T extends [CompDef, ...CompDef[]]>(...components: T): Iterable<[Entity, ...DeepReadonly<ComponentEcsType<T>>]>;
|
|
31
|
-
getComponent<T extends EcsType>(componentId: number): CompDef<T>;
|
|
32
|
-
update(dt: number): void;
|
|
33
|
-
baseComponents: SdkComponetns;
|
|
34
|
-
};
|
package/dist/engine/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/engine/utils.d.ts
DELETED
package/dist/engine/utils.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const isProd = () => !!process.env.PRODUCTION || false;
|
|
2
|
-
export function deepReadonly(val) {
|
|
3
|
-
// Fail only on development due to perf issues
|
|
4
|
-
if (isProd()) {
|
|
5
|
-
return val;
|
|
6
|
-
}
|
|
7
|
-
return Object.freeze({ ...val });
|
|
8
|
-
}
|
|
9
|
-
export function isNotUndefined(val) {
|
|
10
|
-
return !!val;
|
|
11
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
syntax = "proto3";
|
|
2
|
-
|
|
3
|
-
// ComponentDefinition.ComponentID=20;
|
|
4
|
-
// This parameter is processed by the tool
|
|
5
|
-
|
|
6
|
-
package decentraland.ecs;
|
|
7
|
-
option csharp_namespace = "DCL.ECSComponents";
|
|
8
|
-
|
|
9
|
-
message PBAudioSource {
|
|
10
|
-
bool playing = 1;
|
|
11
|
-
float volume = 2;
|
|
12
|
-
bool loop = 3;
|
|
13
|
-
float pitch = 4;
|
|
14
|
-
int32 played_at_timestamp = 5;
|
|
15
|
-
string audio_clip_url = 6;
|
|
16
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
syntax = "proto3";
|
|
2
|
-
|
|
3
|
-
// ComponentDefinition.ComponentID=21;
|
|
4
|
-
// This parameter is processed by the tool
|
|
5
|
-
|
|
6
|
-
package decentraland.ecs;
|
|
7
|
-
option csharp_namespace = "DCL.ECSComponents";
|
|
8
|
-
|
|
9
|
-
message PBAudioStream {
|
|
10
|
-
bool playing = 1;
|
|
11
|
-
float volume = 2;
|
|
12
|
-
string url = 3;
|
|
13
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
syntax = "proto3";
|
|
2
|
-
|
|
3
|
-
// ComponentDefinition.ComponentID=13;
|
|
4
|
-
// This parameter is processed by the tool
|
|
5
|
-
|
|
6
|
-
package decentraland.ecs;
|
|
7
|
-
option csharp_namespace = "DCL.ECSComponents";
|
|
8
|
-
|
|
9
|
-
message PBBoxShape {
|
|
10
|
-
bool with_collisions = 1;
|
|
11
|
-
bool is_pointer_blocker = 2;
|
|
12
|
-
bool visible = 3;
|
|
13
|
-
repeated float uvs = 4;
|
|
14
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
syntax = "proto3";
|
|
2
|
-
|
|
3
|
-
// ComponentDefinition.ComponentID=17;
|
|
4
|
-
// This parameter is processed by the tool
|
|
5
|
-
|
|
6
|
-
package decentraland.ecs;
|
|
7
|
-
option csharp_namespace = "DCL.ECSComponents";
|
|
8
|
-
|
|
9
|
-
message PBCylinderShape {
|
|
10
|
-
bool with_collisions = 1;
|
|
11
|
-
bool is_pointer_blocker = 2;
|
|
12
|
-
bool visible = 3;
|
|
13
|
-
float radius_top = 4;
|
|
14
|
-
float radius_bottom = 5;
|
|
15
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
syntax = "proto3";
|
|
2
|
-
|
|
3
|
-
// ComponentDefinition.ComponentID=14;
|
|
4
|
-
// This parameter is processed by the tool
|
|
5
|
-
|
|
6
|
-
package decentraland.ecs;
|
|
7
|
-
option csharp_namespace = "DCL.ECSComponents";
|
|
8
|
-
|
|
9
|
-
message PBPlaneShape {
|
|
10
|
-
bool with_collisions = 1;
|
|
11
|
-
bool is_pointer_blocker = 2;
|
|
12
|
-
bool visible = 3;
|
|
13
|
-
repeated float uvs = 4;
|
|
14
|
-
}
|
|
File without changes
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
syntax = "proto3";
|
|
2
|
-
|
|
3
|
-
// ComponentDefinition.ComponentID=15;
|
|
4
|
-
// This parameter is processed by the tool
|
|
5
|
-
|
|
6
|
-
package decentraland.ecs;
|
|
7
|
-
option csharp_namespace = "DCL.ECSComponents";
|
|
8
|
-
|
|
9
|
-
message PBSphereShape {
|
|
10
|
-
bool with_collisions = 1;
|
|
11
|
-
bool is_pointer_blocker = 2;
|
|
12
|
-
bool visible = 3;
|
|
13
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Transform
|
|
3
|
-
|
|
4
|
-
```cpp
|
|
5
|
-
// Transform length = 44
|
|
6
|
-
struct Transform {
|
|
7
|
-
float positionX;
|
|
8
|
-
float positionY;
|
|
9
|
-
float positionZ;
|
|
10
|
-
|
|
11
|
-
float rotationX;
|
|
12
|
-
float rotationY;
|
|
13
|
-
float rotationZ;
|
|
14
|
-
float rotationW;
|
|
15
|
-
|
|
16
|
-
float scaleX;
|
|
17
|
-
float scaleY;
|
|
18
|
-
float scaleZ;
|
|
19
|
-
|
|
20
|
-
uint32_t parentEntity;
|
|
21
|
-
};
|
|
22
|
-
```
|
|
23
|
-
- Serialized in big-endian
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param writing - writing option, see object specs.
|
|
3
|
-
* @param reading - reading option, see object specs.
|
|
4
|
-
* @param initialCapacity - Initial capacity of buffer to allocate, ignored if you use writing or reading options
|
|
5
|
-
*/
|
|
6
|
-
export interface CreateByteBufferOptions {
|
|
7
|
-
/**
|
|
8
|
-
* @param buffer - a buffer already allocated to read from there.
|
|
9
|
-
* @param currentOffset - set the cursor where begins to read. Default 0
|
|
10
|
-
* @param length - delimite where the valid data ends. Default: buffer.length
|
|
11
|
-
*/
|
|
12
|
-
reading?: {
|
|
13
|
-
buffer: Uint8Array;
|
|
14
|
-
length?: number;
|
|
15
|
-
currentOffset: number;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* @param buffer - a buffer already allocated to write there.
|
|
19
|
-
* @param currentOffset - set the cursor to not start writing from the begin of it. Default 0
|
|
20
|
-
*/
|
|
21
|
-
writing?: {
|
|
22
|
-
buffer: Uint8Array;
|
|
23
|
-
currentOffset?: number;
|
|
24
|
-
};
|
|
25
|
-
initialCapacity?: number;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* ByteBuffer is a wrapper of DataView which also adds a read and write offset.
|
|
29
|
-
* Also in a write operation it resizes the buffer is being used if it needs.
|
|
30
|
-
*
|
|
31
|
-
* - Use read and write function to generate or consume data.
|
|
32
|
-
* - Use set and get only if you are sure that you're doing.
|
|
33
|
-
*/
|
|
34
|
-
export declare function createByteBuffer(options?: CreateByteBufferOptions): {
|
|
35
|
-
/**
|
|
36
|
-
* @returns The entire current Uint8Array.
|
|
37
|
-
*
|
|
38
|
-
* WARNING: if the buffer grows, the view had changed itself,
|
|
39
|
-
* and the reference will be a invalid one.
|
|
40
|
-
*/
|
|
41
|
-
buffer(): Uint8Array;
|
|
42
|
-
/**
|
|
43
|
-
* @returns The capacity of the current buffer
|
|
44
|
-
*/
|
|
45
|
-
bufferLength(): number;
|
|
46
|
-
/**
|
|
47
|
-
* Resets byteBuffer to avoid creating a new one
|
|
48
|
-
*/
|
|
49
|
-
resetBuffer(): void;
|
|
50
|
-
/**
|
|
51
|
-
* @returns The current read offset
|
|
52
|
-
*/
|
|
53
|
-
currentReadOffset(): number;
|
|
54
|
-
/**
|
|
55
|
-
* @returns The current write offset
|
|
56
|
-
*/
|
|
57
|
-
currentWriteOffset(): number;
|
|
58
|
-
/**
|
|
59
|
-
* Reading purpose
|
|
60
|
-
* Returns the previuos offsset size before incrementing
|
|
61
|
-
*/
|
|
62
|
-
incrementReadOffset(amount: number): number;
|
|
63
|
-
/**
|
|
64
|
-
* @returns How many bytes are available to read.
|
|
65
|
-
*/
|
|
66
|
-
remainingBytes(): number;
|
|
67
|
-
readFloat32(): number;
|
|
68
|
-
readFloat64(): number;
|
|
69
|
-
readInt8(): number;
|
|
70
|
-
readInt16(): number;
|
|
71
|
-
readInt32(): number;
|
|
72
|
-
readInt64(): bigint;
|
|
73
|
-
readUint8(): number;
|
|
74
|
-
readUint16(): number;
|
|
75
|
-
readUint32(): number;
|
|
76
|
-
readUint64(): bigint;
|
|
77
|
-
readBuffer(): Uint8Array;
|
|
78
|
-
/**
|
|
79
|
-
* Writing purpose
|
|
80
|
-
*/
|
|
81
|
-
/**
|
|
82
|
-
* Increment offset
|
|
83
|
-
* @param amount - how many bytes
|
|
84
|
-
* @returns The offset when this reserving starts.
|
|
85
|
-
*/
|
|
86
|
-
incrementWriteOffset(amount: number): number;
|
|
87
|
-
/**
|
|
88
|
-
* @returns The total number of bytes writen in the buffer.
|
|
89
|
-
*/
|
|
90
|
-
size(): number;
|
|
91
|
-
/**
|
|
92
|
-
* @returns The subarray from 0 to offset.
|
|
93
|
-
*/
|
|
94
|
-
toBinary(): Uint8Array;
|
|
95
|
-
writeBuffer(value: Uint8Array, writeLength?: boolean): void;
|
|
96
|
-
writeFloat32(value: number): void;
|
|
97
|
-
writeFloat64(value: number): void;
|
|
98
|
-
writeInt8(value: number): void;
|
|
99
|
-
writeInt16(value: number): void;
|
|
100
|
-
writeInt32(value: number): void;
|
|
101
|
-
writeInt64(value: bigint): void;
|
|
102
|
-
writeUint8(value: number): void;
|
|
103
|
-
writeUint16(value: number): void;
|
|
104
|
-
writeUint32(value: number): void;
|
|
105
|
-
writeUint64(value: bigint): void;
|
|
106
|
-
getFloat32(offset: number): number;
|
|
107
|
-
getFloat64(offset: number): number;
|
|
108
|
-
getInt8(offset: number): number;
|
|
109
|
-
getInt16(offset: number): number;
|
|
110
|
-
getInt32(offset: number): number;
|
|
111
|
-
getInt64(offset: number): bigint;
|
|
112
|
-
getUint8(offset: number): number;
|
|
113
|
-
getUint16(offset: number): number;
|
|
114
|
-
getUint32(offset: number): number;
|
|
115
|
-
getUint64(offset: number): bigint;
|
|
116
|
-
setFloat32(offset: number, value: number): void;
|
|
117
|
-
setFloat64(offset: number, value: number): void;
|
|
118
|
-
setInt8(offset: number, value: number): void;
|
|
119
|
-
setInt16(offset: number, value: number): void;
|
|
120
|
-
setInt32(offset: number, value: number): void;
|
|
121
|
-
setInt64(offset: number, value: bigint): void;
|
|
122
|
-
setUint8(offset: number, value: number): void;
|
|
123
|
-
setUint16(offset: number, value: number): void;
|
|
124
|
-
setUint32(offset: number, value: number): void;
|
|
125
|
-
setUint64(offset: number, value: bigint): void;
|
|
126
|
-
};
|
|
127
|
-
/**
|
|
128
|
-
* @public
|
|
129
|
-
*/
|
|
130
|
-
export declare type ByteBuffer = ReturnType<typeof createByteBuffer>;
|