@dcl/ecs 7.2.1-5222626606.commit-efc0f49 → 7.2.1-5225991589.commit-830bc74
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/index.d.ts +6 -0
- package/dist/components/index.js +6 -0
- package/dist/components/manual/Name.d.ts +9 -0
- package/dist/components/manual/Name.js +8 -0
- package/dist/components/types.d.ts +1 -0
- package/dist/engine/component.d.ts +9 -1
- package/dist/engine/index.js +19 -9
- package/dist/engine/types.d.ts +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/runtime/types.d.ts +1 -1
- package/dist-cjs/components/index.d.ts +6 -0
- package/dist-cjs/components/index.js +11 -1
- package/dist-cjs/components/manual/Name.d.ts +9 -0
- package/dist-cjs/components/manual/Name.js +10 -0
- package/dist-cjs/components/types.d.ts +1 -0
- package/dist-cjs/engine/component.d.ts +9 -1
- package/dist-cjs/engine/index.js +19 -9
- package/dist-cjs/engine/types.d.ts +11 -0
- package/dist-cjs/index.d.ts +2 -0
- package/dist-cjs/index.js +2 -1
- package/dist-cjs/runtime/types.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { GrowOnlyValueSetComponentDefinition, LastWriteWinElementSetComponentDefinition } from '../engine/component';
|
|
2
|
+
import { IEngine } from '../engine/types';
|
|
2
3
|
import { AnimatorComponentDefinitionExtended } from './extended/Animator';
|
|
3
4
|
import { MaterialComponentDefinitionExtended } from './extended/Material';
|
|
4
5
|
import { MeshColliderComponentDefinitionExtended } from './extended/MeshCollider';
|
|
5
6
|
import { MeshRendererComponentDefinitionExtended } from './extended/MeshRenderer';
|
|
6
7
|
import { LwwComponentGetter, GSetComponentGetter } from './generated/index.gen';
|
|
8
|
+
import { NameType } from './manual/Name';
|
|
7
9
|
import { TransformComponentExtended } from './manual/Transform';
|
|
8
10
|
export * from './generated/index.gen';
|
|
9
11
|
export type { GrowOnlyValueSetComponentDefinition, LastWriteWinElementSetComponentDefinition, LwwComponentGetter, GSetComponentGetter };
|
|
@@ -12,3 +14,7 @@ export declare const Material: LwwComponentGetter<MaterialComponentDefinitionExt
|
|
|
12
14
|
export declare const Animator: LwwComponentGetter<AnimatorComponentDefinitionExtended>;
|
|
13
15
|
export declare const MeshRenderer: LwwComponentGetter<MeshRendererComponentDefinitionExtended>;
|
|
14
16
|
export declare const MeshCollider: LwwComponentGetter<MeshColliderComponentDefinitionExtended>;
|
|
17
|
+
/**
|
|
18
|
+
* @alpha
|
|
19
|
+
*/
|
|
20
|
+
export declare const Name: (engine: Pick<IEngine, 'defineComponent'>) => LastWriteWinElementSetComponentDefinition<NameType>;
|
package/dist/components/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { defineAnimatorComponent } from './extended/Animator';
|
|
|
2
2
|
import { defineMaterialComponent } from './extended/Material';
|
|
3
3
|
import { defineMeshColliderComponent } from './extended/MeshCollider';
|
|
4
4
|
import { defineMeshRendererComponent } from './extended/MeshRenderer';
|
|
5
|
+
import defineNameComponent from './manual/Name';
|
|
5
6
|
import { defineTransformComponent } from './manual/Transform';
|
|
6
7
|
export * from './generated/index.gen';
|
|
7
8
|
/* @__PURE__ */
|
|
@@ -14,3 +15,8 @@ export const Animator = (engine) => defineAnimatorComponent(engine);
|
|
|
14
15
|
export const MeshRenderer = (engine) => defineMeshRendererComponent(engine);
|
|
15
16
|
/* @__PURE__ */
|
|
16
17
|
export const MeshCollider = (engine) => defineMeshColliderComponent(engine);
|
|
18
|
+
/**
|
|
19
|
+
* @alpha
|
|
20
|
+
*/
|
|
21
|
+
/* @__PURE__ */
|
|
22
|
+
export const Name = (engine) => defineNameComponent(engine);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IEngine, LastWriteWinElementSetComponentDefinition } from '../../engine/types';
|
|
2
|
+
export type NameComponent = LastWriteWinElementSetComponentDefinition<NameType>;
|
|
3
|
+
export interface NameType {
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
declare function defineNameComponent(engine: Pick<IEngine, 'defineComponent'>): import("../../engine/types").MapComponentDefinition<import("../..").MapResult<{
|
|
7
|
+
value: import("../../schemas").ISchema<string>;
|
|
8
|
+
}>>;
|
|
9
|
+
export default defineNameComponent;
|
|
@@ -3,3 +3,4 @@ export type { MeshRendererComponentDefinitionExtended } from './extended/MeshRen
|
|
|
3
3
|
export type { MeshColliderComponentDefinitionExtended } from './extended/MeshCollider';
|
|
4
4
|
export type { TextureHelper, MaterialComponentDefinitionExtended } from './extended/Material';
|
|
5
5
|
export type { TransformComponentExtended, TransformTypeWithOptionals } from './manual/Transform';
|
|
6
|
+
export type { NameComponent, NameType } from './manual/Name';
|
|
@@ -123,6 +123,10 @@ export interface LastWriteWinElementSetComponentDefinition<T> extends BaseCompon
|
|
|
123
123
|
*/
|
|
124
124
|
getOrCreateMutable(entity: Entity, initialValue?: T): T;
|
|
125
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
export type ReadOnlyLastWriteWinElementSetComponentDefinition<T> = Omit<LastWriteWinElementSetComponentDefinition<T>, 'create' | 'createOrReplace' | 'deleteFrom' | 'getMutable' | 'getMutableOrNull' | 'getOrCreateMutable'>;
|
|
126
130
|
/**
|
|
127
131
|
* @public
|
|
128
132
|
*/
|
|
@@ -146,4 +150,8 @@ export interface GrowOnlyValueSetComponentDefinition<T> extends BaseComponent<T>
|
|
|
146
150
|
/**
|
|
147
151
|
* @public
|
|
148
152
|
*/
|
|
149
|
-
export type
|
|
153
|
+
export type ReadOnlyGrowOnlyValueSetComponentDefinition<T> = Omit<GrowOnlyValueSetComponentDefinition<T>, 'addValue'>;
|
|
154
|
+
/**
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
157
|
+
export type ComponentDefinition<T> = LastWriteWinElementSetComponentDefinition<T> | GrowOnlyValueSetComponentDefinition<T> | ReadOnlyGrowOnlyValueSetComponentDefinition<T> | ReadOnlyLastWriteWinElementSetComponentDefinition<T>;
|
package/dist/engine/index.js
CHANGED
|
@@ -52,42 +52,42 @@ function preEngine() {
|
|
|
52
52
|
return component;
|
|
53
53
|
}
|
|
54
54
|
function defineComponentFromSchema(componentName, schema) {
|
|
55
|
-
/* istanbul ignore next */
|
|
56
|
-
if (sealed)
|
|
57
|
-
throw new Error('Engine is already sealed. No components can be added at this stage');
|
|
58
55
|
const componentId = componentNumberFromName(componentName);
|
|
59
56
|
const prev = componentsDefinition.get(componentId);
|
|
60
57
|
if (prev) {
|
|
61
58
|
// TODO: assert spec === prev.spec
|
|
62
59
|
return prev;
|
|
63
60
|
}
|
|
61
|
+
/* istanbul ignore next */
|
|
62
|
+
if (sealed)
|
|
63
|
+
throw new Error('Engine is already sealed. No components can be added at this stage');
|
|
64
64
|
const newComponent = createComponentDefinitionFromSchema(componentName, componentId, schema);
|
|
65
65
|
componentsDefinition.set(componentId, newComponent);
|
|
66
66
|
return newComponent;
|
|
67
67
|
}
|
|
68
68
|
function defineValueSetComponentFromSchema(componentName, schema, options) {
|
|
69
|
-
/* istanbul ignore next */
|
|
70
|
-
if (sealed)
|
|
71
|
-
throw new Error('Engine is already sealed. No components can be added at this stage');
|
|
72
69
|
const componentId = componentNumberFromName(componentName);
|
|
73
70
|
const prev = componentsDefinition.get(componentId);
|
|
74
71
|
if (prev) {
|
|
75
72
|
// TODO: assert spec === prev.spec
|
|
76
73
|
return prev;
|
|
77
74
|
}
|
|
75
|
+
/* istanbul ignore next */
|
|
76
|
+
if (sealed)
|
|
77
|
+
throw new Error('Engine is already sealed. No components can be added at this stage');
|
|
78
78
|
const newComponent = createValueSetComponentDefinitionFromSchema(componentName, componentId, schema, options);
|
|
79
79
|
componentsDefinition.set(componentId, newComponent);
|
|
80
80
|
return newComponent;
|
|
81
81
|
}
|
|
82
82
|
function defineComponent(componentName, mapSpec, constructorDefault) {
|
|
83
|
-
if (sealed)
|
|
84
|
-
throw new Error('Engine is already sealed. No components can be added at this stage');
|
|
85
83
|
const componentId = componentNumberFromName(componentName);
|
|
86
84
|
const prev = componentsDefinition.get(componentId);
|
|
87
85
|
if (prev) {
|
|
88
86
|
// TODO: assert spec === prev.spec
|
|
89
87
|
return prev;
|
|
90
88
|
}
|
|
89
|
+
if (sealed)
|
|
90
|
+
throw new Error('Engine is already sealed. No components can be added at this stage');
|
|
91
91
|
const schemaSpec = Schemas.Map(mapSpec, constructorDefault);
|
|
92
92
|
const def = createComponentDefinitionFromSchema(componentName, componentId, schemaSpec);
|
|
93
93
|
const newComponent = {
|
|
@@ -121,6 +121,14 @@ function preEngine() {
|
|
|
121
121
|
yield [entity, ...groupComp.map((c) => c.get(entity))];
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
+
function getEntityOrNullByName(value) {
|
|
125
|
+
const LabelComponent = components.Name({ defineComponent });
|
|
126
|
+
for (const [entity, name] of getEntitiesWith(LabelComponent)) {
|
|
127
|
+
if (name.value === value)
|
|
128
|
+
return entity;
|
|
129
|
+
}
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
124
132
|
function* getComponentDefGroup(...args) {
|
|
125
133
|
const [firstComponentDef, ...componentDefinitions] = args;
|
|
126
134
|
for (const [entity] of firstComponentDef.iterator()) {
|
|
@@ -165,7 +173,8 @@ function preEngine() {
|
|
|
165
173
|
defineValueSetComponentFromSchema,
|
|
166
174
|
getEntitiesWith,
|
|
167
175
|
getComponent,
|
|
168
|
-
getComponentOrNull,
|
|
176
|
+
getComponentOrNull: getComponentOrNull,
|
|
177
|
+
getEntityOrNullByName,
|
|
169
178
|
removeComponentDefinition,
|
|
170
179
|
registerComponentDefinition,
|
|
171
180
|
entityContainer,
|
|
@@ -206,6 +215,7 @@ export function Engine(options) {
|
|
|
206
215
|
removeComponentDefinition: partialEngine.removeComponentDefinition,
|
|
207
216
|
componentsIter: partialEngine.componentsIter,
|
|
208
217
|
seal: partialEngine.seal,
|
|
218
|
+
getEntityOrNullByName: partialEngine.getEntityOrNullByName,
|
|
209
219
|
update,
|
|
210
220
|
RootEntity: 0,
|
|
211
221
|
PlayerEntity: 1,
|
package/dist/engine/types.d.ts
CHANGED
|
@@ -177,11 +177,22 @@ export interface IEngine {
|
|
|
177
177
|
* ```
|
|
178
178
|
*/
|
|
179
179
|
getEntitiesWith<T extends [ComponentDefinition<any>, ...ComponentDefinition<any>[]]>(...components: T): Iterable<[Entity, ...ReadonlyComponentSchema<T>]>;
|
|
180
|
+
/**
|
|
181
|
+
* @alpha
|
|
182
|
+
* Search for the entity that matches de label string defined in the editor.
|
|
183
|
+
* @param value - Name value string
|
|
184
|
+
*/
|
|
185
|
+
getEntityOrNullByName(label: string): Entity | null;
|
|
180
186
|
/**
|
|
181
187
|
* @public
|
|
182
188
|
* @param deltaTime - deltaTime in seconds
|
|
183
189
|
*/
|
|
184
190
|
update(deltaTime: number): Promise<void>;
|
|
191
|
+
/**
|
|
192
|
+
* @public
|
|
193
|
+
* @param componentId - component number or name
|
|
194
|
+
*/
|
|
195
|
+
removeComponentDefinition(componentId: number | string): void;
|
|
185
196
|
/**
|
|
186
197
|
* @public
|
|
187
198
|
* Refer to the root of the scene, all Transforms without a parent are parenting with RootEntity.
|
package/dist/index.d.ts
CHANGED
|
@@ -11,11 +11,13 @@ export * from './systems/async-task';
|
|
|
11
11
|
export * from './engine/entity';
|
|
12
12
|
export * from './components/types';
|
|
13
13
|
import { MaterialComponentDefinitionExtended, MeshColliderComponentDefinitionExtended, MeshRendererComponentDefinitionExtended, TransformComponentExtended, AnimatorComponentDefinitionExtended } from './components/types';
|
|
14
|
+
import { NameComponent } from './components/manual/Name';
|
|
14
15
|
export declare const Transform: TransformComponentExtended;
|
|
15
16
|
export declare const Animator: AnimatorComponentDefinitionExtended;
|
|
16
17
|
export declare const Material: MaterialComponentDefinitionExtended;
|
|
17
18
|
export declare const MeshRenderer: MeshRendererComponentDefinitionExtended;
|
|
18
19
|
export declare const MeshCollider: MeshColliderComponentDefinitionExtended;
|
|
20
|
+
export declare const Name: NameComponent;
|
|
19
21
|
export * from './components/generated/global.gen';
|
|
20
22
|
export * from './components/generated/types.gen';
|
|
21
23
|
export * from './serialization/crdt';
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ export const Animator = /* @__PURE__*/ components.Animator(engine);
|
|
|
22
22
|
export const Material = /* @__PURE__*/ components.Material(engine);
|
|
23
23
|
export const MeshRenderer = /* @__PURE__*/ components.MeshRenderer(engine);
|
|
24
24
|
export const MeshCollider = /* @__PURE__*/ components.MeshCollider(engine);
|
|
25
|
+
export const Name = /* @__PURE__*/ components.Name(engine);
|
|
25
26
|
// export components for global engine
|
|
26
27
|
export * from './components/generated/global.gen';
|
|
27
28
|
export * from './components/generated/types.gen';
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { SystemFn } from '../engine/systems';
|
|
1
|
+
export type { SystemFn, SYSTEMS_REGULAR_PRIORITY } from '../engine/systems';
|
|
2
2
|
export type { TransportMessage, ReceiveMessage, Transport } from '../systems/crdt/types';
|
|
3
3
|
export { TransformType, TransformComponent } from '../components/manual/Transform';
|
|
4
4
|
export * from '../engine/component';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { GrowOnlyValueSetComponentDefinition, LastWriteWinElementSetComponentDefinition } from '../engine/component';
|
|
2
|
+
import { IEngine } from '../engine/types';
|
|
2
3
|
import { AnimatorComponentDefinitionExtended } from './extended/Animator';
|
|
3
4
|
import { MaterialComponentDefinitionExtended } from './extended/Material';
|
|
4
5
|
import { MeshColliderComponentDefinitionExtended } from './extended/MeshCollider';
|
|
5
6
|
import { MeshRendererComponentDefinitionExtended } from './extended/MeshRenderer';
|
|
6
7
|
import { LwwComponentGetter, GSetComponentGetter } from './generated/index.gen';
|
|
8
|
+
import { NameType } from './manual/Name';
|
|
7
9
|
import { TransformComponentExtended } from './manual/Transform';
|
|
8
10
|
export * from './generated/index.gen';
|
|
9
11
|
export type { GrowOnlyValueSetComponentDefinition, LastWriteWinElementSetComponentDefinition, LwwComponentGetter, GSetComponentGetter };
|
|
@@ -12,3 +14,7 @@ export declare const Material: LwwComponentGetter<MaterialComponentDefinitionExt
|
|
|
12
14
|
export declare const Animator: LwwComponentGetter<AnimatorComponentDefinitionExtended>;
|
|
13
15
|
export declare const MeshRenderer: LwwComponentGetter<MeshRendererComponentDefinitionExtended>;
|
|
14
16
|
export declare const MeshCollider: LwwComponentGetter<MeshColliderComponentDefinitionExtended>;
|
|
17
|
+
/**
|
|
18
|
+
* @alpha
|
|
19
|
+
*/
|
|
20
|
+
export declare const Name: (engine: Pick<IEngine, 'defineComponent'>) => LastWriteWinElementSetComponentDefinition<NameType>;
|
|
@@ -13,12 +13,16 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
16
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.MeshCollider = exports.MeshRenderer = exports.Animator = exports.Material = exports.Transform = void 0;
|
|
20
|
+
exports.Name = exports.MeshCollider = exports.MeshRenderer = exports.Animator = exports.Material = exports.Transform = void 0;
|
|
18
21
|
const Animator_1 = require("./extended/Animator");
|
|
19
22
|
const Material_1 = require("./extended/Material");
|
|
20
23
|
const MeshCollider_1 = require("./extended/MeshCollider");
|
|
21
24
|
const MeshRenderer_1 = require("./extended/MeshRenderer");
|
|
25
|
+
const Name_1 = __importDefault(require("./manual/Name"));
|
|
22
26
|
const Transform_1 = require("./manual/Transform");
|
|
23
27
|
__exportStar(require("./generated/index.gen"), exports);
|
|
24
28
|
/* @__PURE__ */
|
|
@@ -36,3 +40,9 @@ exports.MeshRenderer = MeshRenderer;
|
|
|
36
40
|
/* @__PURE__ */
|
|
37
41
|
const MeshCollider = (engine) => (0, MeshCollider_1.defineMeshColliderComponent)(engine);
|
|
38
42
|
exports.MeshCollider = MeshCollider;
|
|
43
|
+
/**
|
|
44
|
+
* @alpha
|
|
45
|
+
*/
|
|
46
|
+
/* @__PURE__ */
|
|
47
|
+
const Name = (engine) => (0, Name_1.default)(engine);
|
|
48
|
+
exports.Name = Name;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IEngine, LastWriteWinElementSetComponentDefinition } from '../../engine/types';
|
|
2
|
+
export type NameComponent = LastWriteWinElementSetComponentDefinition<NameType>;
|
|
3
|
+
export interface NameType {
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
declare function defineNameComponent(engine: Pick<IEngine, 'defineComponent'>): import("../../engine/types").MapComponentDefinition<import("../..").MapResult<{
|
|
7
|
+
value: import("../../schemas").ISchema<string>;
|
|
8
|
+
}>>;
|
|
9
|
+
export default defineNameComponent;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const schemas_1 = require("../../schemas");
|
|
4
|
+
function defineNameComponent(engine) {
|
|
5
|
+
const Name = engine.defineComponent('core-schema::Name', {
|
|
6
|
+
value: schemas_1.Schemas.String
|
|
7
|
+
});
|
|
8
|
+
return Name;
|
|
9
|
+
}
|
|
10
|
+
exports.default = defineNameComponent;
|
|
@@ -3,3 +3,4 @@ export type { MeshRendererComponentDefinitionExtended } from './extended/MeshRen
|
|
|
3
3
|
export type { MeshColliderComponentDefinitionExtended } from './extended/MeshCollider';
|
|
4
4
|
export type { TextureHelper, MaterialComponentDefinitionExtended } from './extended/Material';
|
|
5
5
|
export type { TransformComponentExtended, TransformTypeWithOptionals } from './manual/Transform';
|
|
6
|
+
export type { NameComponent, NameType } from './manual/Name';
|
|
@@ -123,6 +123,10 @@ export interface LastWriteWinElementSetComponentDefinition<T> extends BaseCompon
|
|
|
123
123
|
*/
|
|
124
124
|
getOrCreateMutable(entity: Entity, initialValue?: T): T;
|
|
125
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
export type ReadOnlyLastWriteWinElementSetComponentDefinition<T> = Omit<LastWriteWinElementSetComponentDefinition<T>, 'create' | 'createOrReplace' | 'deleteFrom' | 'getMutable' | 'getMutableOrNull' | 'getOrCreateMutable'>;
|
|
126
130
|
/**
|
|
127
131
|
* @public
|
|
128
132
|
*/
|
|
@@ -146,4 +150,8 @@ export interface GrowOnlyValueSetComponentDefinition<T> extends BaseComponent<T>
|
|
|
146
150
|
/**
|
|
147
151
|
* @public
|
|
148
152
|
*/
|
|
149
|
-
export type
|
|
153
|
+
export type ReadOnlyGrowOnlyValueSetComponentDefinition<T> = Omit<GrowOnlyValueSetComponentDefinition<T>, 'addValue'>;
|
|
154
|
+
/**
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
157
|
+
export type ComponentDefinition<T> = LastWriteWinElementSetComponentDefinition<T> | GrowOnlyValueSetComponentDefinition<T> | ReadOnlyGrowOnlyValueSetComponentDefinition<T> | ReadOnlyLastWriteWinElementSetComponentDefinition<T>;
|
package/dist-cjs/engine/index.js
CHANGED
|
@@ -81,42 +81,42 @@ function preEngine() {
|
|
|
81
81
|
return component;
|
|
82
82
|
}
|
|
83
83
|
function defineComponentFromSchema(componentName, schema) {
|
|
84
|
-
/* istanbul ignore next */
|
|
85
|
-
if (sealed)
|
|
86
|
-
throw new Error('Engine is already sealed. No components can be added at this stage');
|
|
87
84
|
const componentId = (0, component_number_1.componentNumberFromName)(componentName);
|
|
88
85
|
const prev = componentsDefinition.get(componentId);
|
|
89
86
|
if (prev) {
|
|
90
87
|
// TODO: assert spec === prev.spec
|
|
91
88
|
return prev;
|
|
92
89
|
}
|
|
90
|
+
/* istanbul ignore next */
|
|
91
|
+
if (sealed)
|
|
92
|
+
throw new Error('Engine is already sealed. No components can be added at this stage');
|
|
93
93
|
const newComponent = (0, lww_element_set_component_definition_1.createComponentDefinitionFromSchema)(componentName, componentId, schema);
|
|
94
94
|
componentsDefinition.set(componentId, newComponent);
|
|
95
95
|
return newComponent;
|
|
96
96
|
}
|
|
97
97
|
function defineValueSetComponentFromSchema(componentName, schema, options) {
|
|
98
|
-
/* istanbul ignore next */
|
|
99
|
-
if (sealed)
|
|
100
|
-
throw new Error('Engine is already sealed. No components can be added at this stage');
|
|
101
98
|
const componentId = (0, component_number_1.componentNumberFromName)(componentName);
|
|
102
99
|
const prev = componentsDefinition.get(componentId);
|
|
103
100
|
if (prev) {
|
|
104
101
|
// TODO: assert spec === prev.spec
|
|
105
102
|
return prev;
|
|
106
103
|
}
|
|
104
|
+
/* istanbul ignore next */
|
|
105
|
+
if (sealed)
|
|
106
|
+
throw new Error('Engine is already sealed. No components can be added at this stage');
|
|
107
107
|
const newComponent = (0, grow_only_value_set_component_definition_1.createValueSetComponentDefinitionFromSchema)(componentName, componentId, schema, options);
|
|
108
108
|
componentsDefinition.set(componentId, newComponent);
|
|
109
109
|
return newComponent;
|
|
110
110
|
}
|
|
111
111
|
function defineComponent(componentName, mapSpec, constructorDefault) {
|
|
112
|
-
if (sealed)
|
|
113
|
-
throw new Error('Engine is already sealed. No components can be added at this stage');
|
|
114
112
|
const componentId = (0, component_number_1.componentNumberFromName)(componentName);
|
|
115
113
|
const prev = componentsDefinition.get(componentId);
|
|
116
114
|
if (prev) {
|
|
117
115
|
// TODO: assert spec === prev.spec
|
|
118
116
|
return prev;
|
|
119
117
|
}
|
|
118
|
+
if (sealed)
|
|
119
|
+
throw new Error('Engine is already sealed. No components can be added at this stage');
|
|
120
120
|
const schemaSpec = schemas_1.Schemas.Map(mapSpec, constructorDefault);
|
|
121
121
|
const def = (0, lww_element_set_component_definition_1.createComponentDefinitionFromSchema)(componentName, componentId, schemaSpec);
|
|
122
122
|
const newComponent = {
|
|
@@ -150,6 +150,14 @@ function preEngine() {
|
|
|
150
150
|
yield [entity, ...groupComp.map((c) => c.get(entity))];
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
+
function getEntityOrNullByName(value) {
|
|
154
|
+
const LabelComponent = components.Name({ defineComponent });
|
|
155
|
+
for (const [entity, name] of getEntitiesWith(LabelComponent)) {
|
|
156
|
+
if (name.value === value)
|
|
157
|
+
return entity;
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
153
161
|
function* getComponentDefGroup(...args) {
|
|
154
162
|
const [firstComponentDef, ...componentDefinitions] = args;
|
|
155
163
|
for (const [entity] of firstComponentDef.iterator()) {
|
|
@@ -194,7 +202,8 @@ function preEngine() {
|
|
|
194
202
|
defineValueSetComponentFromSchema,
|
|
195
203
|
getEntitiesWith,
|
|
196
204
|
getComponent,
|
|
197
|
-
getComponentOrNull,
|
|
205
|
+
getComponentOrNull: getComponentOrNull,
|
|
206
|
+
getEntityOrNullByName,
|
|
198
207
|
removeComponentDefinition,
|
|
199
208
|
registerComponentDefinition,
|
|
200
209
|
entityContainer,
|
|
@@ -235,6 +244,7 @@ function Engine(options) {
|
|
|
235
244
|
removeComponentDefinition: partialEngine.removeComponentDefinition,
|
|
236
245
|
componentsIter: partialEngine.componentsIter,
|
|
237
246
|
seal: partialEngine.seal,
|
|
247
|
+
getEntityOrNullByName: partialEngine.getEntityOrNullByName,
|
|
238
248
|
update,
|
|
239
249
|
RootEntity: 0,
|
|
240
250
|
PlayerEntity: 1,
|
|
@@ -177,11 +177,22 @@ export interface IEngine {
|
|
|
177
177
|
* ```
|
|
178
178
|
*/
|
|
179
179
|
getEntitiesWith<T extends [ComponentDefinition<any>, ...ComponentDefinition<any>[]]>(...components: T): Iterable<[Entity, ...ReadonlyComponentSchema<T>]>;
|
|
180
|
+
/**
|
|
181
|
+
* @alpha
|
|
182
|
+
* Search for the entity that matches de label string defined in the editor.
|
|
183
|
+
* @param value - Name value string
|
|
184
|
+
*/
|
|
185
|
+
getEntityOrNullByName(label: string): Entity | null;
|
|
180
186
|
/**
|
|
181
187
|
* @public
|
|
182
188
|
* @param deltaTime - deltaTime in seconds
|
|
183
189
|
*/
|
|
184
190
|
update(deltaTime: number): Promise<void>;
|
|
191
|
+
/**
|
|
192
|
+
* @public
|
|
193
|
+
* @param componentId - component number or name
|
|
194
|
+
*/
|
|
195
|
+
removeComponentDefinition(componentId: number | string): void;
|
|
185
196
|
/**
|
|
186
197
|
* @public
|
|
187
198
|
* Refer to the root of the scene, all Transforms without a parent are parenting with RootEntity.
|
package/dist-cjs/index.d.ts
CHANGED
|
@@ -11,11 +11,13 @@ export * from './systems/async-task';
|
|
|
11
11
|
export * from './engine/entity';
|
|
12
12
|
export * from './components/types';
|
|
13
13
|
import { MaterialComponentDefinitionExtended, MeshColliderComponentDefinitionExtended, MeshRendererComponentDefinitionExtended, TransformComponentExtended, AnimatorComponentDefinitionExtended } from './components/types';
|
|
14
|
+
import { NameComponent } from './components/manual/Name';
|
|
14
15
|
export declare const Transform: TransformComponentExtended;
|
|
15
16
|
export declare const Animator: AnimatorComponentDefinitionExtended;
|
|
16
17
|
export declare const Material: MaterialComponentDefinitionExtended;
|
|
17
18
|
export declare const MeshRenderer: MeshRendererComponentDefinitionExtended;
|
|
18
19
|
export declare const MeshCollider: MeshColliderComponentDefinitionExtended;
|
|
20
|
+
export declare const Name: NameComponent;
|
|
19
21
|
export * from './components/generated/global.gen';
|
|
20
22
|
export * from './components/generated/types.gen';
|
|
21
23
|
export * from './serialization/crdt';
|
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.MeshCollider = exports.MeshRenderer = exports.Material = exports.Animator = exports.Transform = exports.components = exports.cyclicParentingChecker = void 0;
|
|
29
|
+
exports.Name = exports.MeshCollider = exports.MeshRenderer = exports.Material = 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);
|
|
@@ -51,6 +51,7 @@ exports.Animator = components.Animator(initialization_1.engine);
|
|
|
51
51
|
exports.Material = components.Material(initialization_1.engine);
|
|
52
52
|
exports.MeshRenderer = components.MeshRenderer(initialization_1.engine);
|
|
53
53
|
exports.MeshCollider = components.MeshCollider(initialization_1.engine);
|
|
54
|
+
exports.Name = components.Name(initialization_1.engine);
|
|
54
55
|
// export components for global engine
|
|
55
56
|
__exportStar(require("./components/generated/global.gen"), exports);
|
|
56
57
|
__exportStar(require("./components/generated/types.gen"), exports);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { SystemFn } from '../engine/systems';
|
|
1
|
+
export type { SystemFn, SYSTEMS_REGULAR_PRIORITY } from '../engine/systems';
|
|
2
2
|
export type { TransportMessage, ReceiveMessage, Transport } from '../systems/crdt/types';
|
|
3
3
|
export { TransformType, TransformComponent } from '../components/manual/Transform';
|
|
4
4
|
export * from '../engine/component';
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/ecs",
|
|
3
3
|
"description": "Decentraland ECS",
|
|
4
|
-
"version": "7.2.1-
|
|
4
|
+
"version": "7.2.1-5225991589.commit-830bc74",
|
|
5
5
|
"author": "DCL",
|
|
6
6
|
"bugs": "https://github.com/decentraland/ecs/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@dcl/js-runtime": "7.2.1-
|
|
8
|
+
"@dcl/js-runtime": "7.2.1-5225991589.commit-830bc74"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
},
|
|
37
37
|
"types": "./dist/index.d.ts",
|
|
38
38
|
"typings": "./dist/index.d.ts",
|
|
39
|
-
"commit": "
|
|
39
|
+
"commit": "830bc74bd1fd3357c6e894bf624db4a1049be858"
|
|
40
40
|
}
|