@woosh/meep-engine 2.36.14 → 2.36.15
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/engine/graphics/ecs/highlight/Highlight.d.ts +2 -0
- package/engine/graphics/ecs/mesh-v2/aggregate/SGMeshHighlightSystem.d.ts +7 -0
- package/engine/graphics/ecs/mesh-v2/aggregate/SGMeshHighlightSystem.js +81 -0
- package/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +1 -4
- package/engine/graphics/ecs/mesh-v2/aggregate/prototypeSGMesh.js +12 -6
- package/package.json +1 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { System } from "../../../../ecs/System.js";
|
|
2
|
+
import { SGMesh } from "./SGMesh.js";
|
|
3
|
+
import Highlight from "../../highlight/Highlight.js";
|
|
4
|
+
import { SGMeshEvents } from "./SGMeshEvents.js";
|
|
5
|
+
|
|
6
|
+
export class SGMeshHighlightSystem extends System {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
|
|
10
|
+
this.dependencies = [Highlight, SGMesh];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param event
|
|
16
|
+
* @param {number} entity
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
__apply_highlight( event, entity) {
|
|
20
|
+
const ecd = this.entityManager.dataset;
|
|
21
|
+
|
|
22
|
+
const sg_mesh = ecd.getComponent(entity, SGMesh);
|
|
23
|
+
const highlight = ecd.getComponent(entity, Highlight);
|
|
24
|
+
|
|
25
|
+
const node = sg_mesh.__node;
|
|
26
|
+
|
|
27
|
+
node.traverse(t => {
|
|
28
|
+
t.entity.add(highlight);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param event
|
|
35
|
+
* @param {number} entity
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
__remove_highlight( event, entity) {
|
|
39
|
+
|
|
40
|
+
const ecd = this.entityManager.dataset;
|
|
41
|
+
|
|
42
|
+
const sg_mesh = ecd.getComponent(entity, SGMesh);
|
|
43
|
+
|
|
44
|
+
const node = sg_mesh.__node;
|
|
45
|
+
|
|
46
|
+
node.traverse(t => {
|
|
47
|
+
t.entity.removeComponent(Highlight);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @param {Highlight} highlight
|
|
54
|
+
* @param {SGMesh} mesh
|
|
55
|
+
* @param {number} entity
|
|
56
|
+
*/
|
|
57
|
+
link(highlight, mesh, entity) {
|
|
58
|
+
if (mesh.__node !== null) {
|
|
59
|
+
this.__apply_highlight(undefined, entity);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const ecd = this.entityManager.dataset;
|
|
63
|
+
|
|
64
|
+
ecd.addEntityEventListener(entity, SGMeshEvents.AssetLoaded, this.__apply_highlight, this);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
*
|
|
69
|
+
* @param {Highlight} highlight
|
|
70
|
+
* @param {SGMesh} mesh
|
|
71
|
+
* @param {number} entity
|
|
72
|
+
*/
|
|
73
|
+
unlink(highlight, mesh, entity) {
|
|
74
|
+
const ecd = this.entityManager.dataset;
|
|
75
|
+
ecd.removeEntityEventListener(entity, SGMeshEvents.AssetLoaded, this.__apply_highlight, this);
|
|
76
|
+
|
|
77
|
+
if (mesh.__node !== null) {
|
|
78
|
+
this.__remove_highlight(undefined, entity);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -79,10 +79,7 @@ export class SGMeshSystem extends System {
|
|
|
79
79
|
const entity_node = three_object_to_entity_composition(asset.create());
|
|
80
80
|
|
|
81
81
|
// attach parent entity to link hierarchy to this entity
|
|
82
|
-
|
|
83
|
-
parentEntity.entity = entity;
|
|
84
|
-
|
|
85
|
-
entity_node.entity.add(parentEntity)
|
|
82
|
+
entity_node.entity.add(ParentEntity.from(entity));
|
|
86
83
|
|
|
87
84
|
mesh.__node = entity_node;
|
|
88
85
|
|
|
@@ -12,6 +12,9 @@ import { TransformAttachmentSystem } from "../../../../ecs/transform-attachment/
|
|
|
12
12
|
import { SGMeshEvents } from "./SGMeshEvents.js";
|
|
13
13
|
import { ShadedGeometry } from "../ShadedGeometry.js";
|
|
14
14
|
import { MeshSystem } from "../../mesh/MeshSystem.js";
|
|
15
|
+
import { SGMeshHighlightSystem } from "./SGMeshHighlightSystem.js";
|
|
16
|
+
import Highlight from "../../highlight/Highlight.js";
|
|
17
|
+
import { ShadedGeometryHighlightSystem } from "../../highlight/system/ShadedGeometryHighlightSystem.js";
|
|
15
18
|
|
|
16
19
|
new EngineHarness().initialize({
|
|
17
20
|
configuration(config, engine) {
|
|
@@ -20,7 +23,9 @@ new EngineHarness().initialize({
|
|
|
20
23
|
new SGMeshSystem(engine),
|
|
21
24
|
new BehaviorSystem(engine),
|
|
22
25
|
new MeshSystem(engine),
|
|
23
|
-
new TransformAttachmentSystem()
|
|
26
|
+
new TransformAttachmentSystem(),
|
|
27
|
+
new SGMeshHighlightSystem(),
|
|
28
|
+
new ShadedGeometryHighlightSystem(engine)
|
|
24
29
|
);
|
|
25
30
|
|
|
26
31
|
config.addLoader(GameAssetType.ModelGLTF_JSON, new GLTFAssetLoader());
|
|
@@ -46,12 +51,13 @@ function main(engine) {
|
|
|
46
51
|
.add(Transform.fromJSON({
|
|
47
52
|
position: new Vector3(10, 0, 10)
|
|
48
53
|
}))
|
|
54
|
+
.add(Highlight.fromOne(1, 0, 0, 1))
|
|
49
55
|
.add(mesh)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
/* .add(BehaviorComponent.fromOne(OrbitingBehavior.from({
|
|
57
|
+
center: new Vector3(10, 0, 10),
|
|
58
|
+
radius: 5,
|
|
59
|
+
rate: 2
|
|
60
|
+
})))*/
|
|
55
61
|
.addEventListener(SGMeshEvents.AssetLoaded, () => {
|
|
56
62
|
mesh.__node.traverse(n => {
|
|
57
63
|
/**
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"productName": "Meep",
|
|
6
6
|
"description": "production-ready JavaScript game engine based on Entity Component System Architecture",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.36.
|
|
8
|
+
"version": "2.36.15",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|