@woosh/meep-engine 2.39.16 → 2.39.17
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.
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {OrthographicCamera, PerspectiveCamera} from "three";
|
|
2
|
+
import {EntityComponentDataset} from "../../../engine/ecs/EntityComponentDataset";
|
|
3
|
+
import {EntityNode} from "../../../engine/ecs/parent/EntityNode";
|
|
4
|
+
|
|
5
|
+
export class TransformControls extends EntityNode {
|
|
6
|
+
constructor(camera: PerspectiveCamera | OrthographicCamera, domElement: HTMLElement)
|
|
7
|
+
|
|
8
|
+
build(ecd: EntityComponentDataset): void
|
|
9
|
+
|
|
10
|
+
destroy(): void
|
|
11
|
+
|
|
12
|
+
attach(entity: number): void
|
|
13
|
+
|
|
14
|
+
detach(): void
|
|
15
|
+
}
|
|
@@ -23,50 +23,51 @@ async function main(engine) {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
// create something to drag
|
|
27
26
|
const ecd = engine.entityManager.dataset;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
|
|
28
|
+
// create something to drag
|
|
29
|
+
const cube_entity = new EntityBuilder()
|
|
30
|
+
.add(ShadedGeometry.from(
|
|
31
|
+
new BoxBufferGeometry(1, 1, 1),
|
|
32
|
+
new MeshStandardMaterial({
|
|
33
|
+
color: 0xFFAAAA
|
|
34
|
+
})
|
|
35
|
+
))
|
|
32
36
|
.add(Transform.fromJSON({
|
|
33
37
|
position: {
|
|
34
38
|
x: 10,
|
|
35
39
|
y: 0,
|
|
36
40
|
z: 10
|
|
37
41
|
}
|
|
38
|
-
}))
|
|
39
|
-
|
|
40
|
-
const cube_entity = cube
|
|
42
|
+
}))
|
|
41
43
|
.build(ecd);
|
|
42
44
|
|
|
43
45
|
const camera = ecd.getAnyComponent(Camera);
|
|
44
46
|
|
|
45
47
|
const controls = new TransformControls(camera.component.object, engine.gameView.el);
|
|
46
48
|
|
|
47
|
-
controls.build(ecd);
|
|
48
|
-
controls.attach(cube_entity);
|
|
49
|
-
|
|
50
|
-
// cube.getComponentSafe(Transform).position.onChanged.add(console.log);
|
|
51
|
-
// cube.getComponentSafe(Transform).scale.onChanged.add(console.warn);
|
|
52
49
|
|
|
50
|
+
controls.build(ecd); // add controls to the scene
|
|
51
|
+
controls.attach(cube_entity); // make controls target the cube
|
|
53
52
|
|
|
54
|
-
new EntityBuilder()
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
53
|
+
new EntityBuilder()
|
|
54
|
+
.add(new InputController([{
|
|
55
|
+
path: 'keyboard/keys/w/down',
|
|
56
|
+
listener() {
|
|
57
|
+
controls.mode = "translate"
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
path: 'keyboard/keys/e/down',
|
|
61
|
+
listener() {
|
|
62
|
+
controls.mode = "scale"
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
path: 'keyboard/keys/r/down',
|
|
66
|
+
listener() {
|
|
67
|
+
controls.mode = "rotate"
|
|
68
|
+
}
|
|
69
|
+
}]))
|
|
70
|
+
.build(ecd);
|
|
70
71
|
|
|
71
72
|
}
|
|
72
73
|
|
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.39.
|
|
8
|
+
"version": "2.39.17",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|