@woosh/meep-engine 2.37.7 → 2.37.10
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/core/collection/map/CachedAsyncMap.js +2 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +0 -9
- package/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +25 -24
- package/engine/graphics/ecs/mesh-v2/aggregate/prototypeSGMesh.js +24 -1
- package/engine/graphics/micron/plugin/MicronRenderPlugin.js +3 -2
- package/engine/graphics/micron/plugin/shaded_geometry/MicronShadedGeometryRenderAdapter.js +14 -3
- package/package.json +1 -1
|
@@ -68,15 +68,6 @@ export class ShadedGeometry {
|
|
|
68
68
|
*/
|
|
69
69
|
this.__c_transform = null;
|
|
70
70
|
|
|
71
|
-
/**
|
|
72
|
-
* Transform matrix
|
|
73
|
-
* Transient, assigned in the system
|
|
74
|
-
* @type {number[]|null}
|
|
75
|
-
* @readonly
|
|
76
|
-
* @private
|
|
77
|
-
*/
|
|
78
|
-
this.__transform = allocate_transform_m4();
|
|
79
|
-
|
|
80
71
|
/**
|
|
81
72
|
*
|
|
82
73
|
* @type {DrawMode|number}
|
|
@@ -8,13 +8,14 @@ import { ShadedGeometryFlags } from "../ShadedGeometryFlags.js";
|
|
|
8
8
|
import { SGMeshEvents } from "./SGMeshEvents.js";
|
|
9
9
|
import { ParentEntity } from "../../../../ecs/parent/ParentEntity.js";
|
|
10
10
|
import { EntityNode } from "../../../../ecs/parent/EntityNode.js";
|
|
11
|
+
import { min2 } from "../../../../../core/math/min2.js";
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @readonly
|
|
15
16
|
* @type {number}
|
|
16
17
|
*/
|
|
17
|
-
const
|
|
18
|
+
const MAX_CYCLE_COUNT = 128;
|
|
18
19
|
|
|
19
20
|
export class SGMeshSystem extends System {
|
|
20
21
|
/**
|
|
@@ -98,31 +99,23 @@ export class SGMeshSystem extends System {
|
|
|
98
99
|
|
|
99
100
|
mesh.__node = entity_node;
|
|
100
101
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
entity_node.build(ecd);
|
|
104
|
-
|
|
105
|
-
function update_position() {
|
|
106
|
-
entity_node.transform.position.copy(transform.position);
|
|
102
|
+
function copy_transform() {
|
|
103
|
+
entity_node.transform.copy(transform);
|
|
107
104
|
}
|
|
108
105
|
|
|
109
|
-
|
|
110
|
-
entity_node.transform.rotation.copy(transform.rotation);
|
|
111
|
-
}
|
|
106
|
+
copy_transform();
|
|
112
107
|
|
|
113
|
-
|
|
114
|
-
entity_node.transform.scale.copy(transform.scale);
|
|
115
|
-
}
|
|
108
|
+
entity_node.build(ecd);
|
|
116
109
|
|
|
117
|
-
transform.position.onChanged.add(
|
|
118
|
-
transform.rotation.onChanged.add(
|
|
119
|
-
transform.scale.onChanged.add(
|
|
110
|
+
transform.position.onChanged.add(copy_transform);
|
|
111
|
+
transform.rotation.onChanged.add(copy_transform);
|
|
112
|
+
transform.scale.onChanged.add(copy_transform);
|
|
120
113
|
|
|
121
114
|
entity_node.on.destroyed.addOne(() => {
|
|
122
115
|
|
|
123
|
-
transform.position.onChanged.remove(
|
|
124
|
-
transform.rotation.onChanged.remove(
|
|
125
|
-
transform.scale.onChanged.remove(
|
|
116
|
+
transform.position.onChanged.remove(copy_transform);
|
|
117
|
+
transform.rotation.onChanged.remove(copy_transform);
|
|
118
|
+
transform.scale.onChanged.remove(copy_transform);
|
|
126
119
|
|
|
127
120
|
});
|
|
128
121
|
|
|
@@ -183,6 +176,13 @@ export class SGMeshSystem extends System {
|
|
|
183
176
|
|
|
184
177
|
update(time_delta) {
|
|
185
178
|
|
|
179
|
+
const entityManager = this.entityManager;
|
|
180
|
+
const dataset = entityManager.dataset;
|
|
181
|
+
|
|
182
|
+
if (dataset === null) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
186
|
const waiting = this.__wait_queue;
|
|
187
187
|
|
|
188
188
|
let l = waiting.length;
|
|
@@ -191,17 +191,20 @@ export class SGMeshSystem extends System {
|
|
|
191
191
|
|
|
192
192
|
let pointer = this.__wait_queue_process_index;
|
|
193
193
|
|
|
194
|
-
const dataset = this.entityManager.dataset;
|
|
195
194
|
|
|
196
|
-
|
|
195
|
+
let pointer_limit = pointer + min2(l, MAX_CYCLE_COUNT);
|
|
196
|
+
|
|
197
|
+
while (pointer < pointer_limit) {
|
|
197
198
|
|
|
198
199
|
const index = pointer % l;
|
|
200
|
+
pointer++;
|
|
199
201
|
|
|
200
202
|
const entity = waiting[index];
|
|
201
203
|
|
|
202
204
|
const mesh = dataset.getComponent(entity, SGMesh);
|
|
203
205
|
|
|
204
206
|
if (mesh.url === null) {
|
|
207
|
+
// no URL yet
|
|
205
208
|
continue;
|
|
206
209
|
}
|
|
207
210
|
|
|
@@ -209,10 +212,8 @@ export class SGMeshSystem extends System {
|
|
|
209
212
|
|
|
210
213
|
this.process(entity, mesh, transform);
|
|
211
214
|
|
|
212
|
-
waiting.splice(
|
|
215
|
+
waiting.splice(index, 1);
|
|
213
216
|
|
|
214
|
-
i--;
|
|
215
|
-
l--;
|
|
216
217
|
}
|
|
217
218
|
|
|
218
219
|
this.__wait_queue_process_index = pointer;
|
|
@@ -15,6 +15,8 @@ import { MeshSystem } from "../../mesh/MeshSystem.js";
|
|
|
15
15
|
import { SGMeshHighlightSystem } from "./SGMeshHighlightSystem.js";
|
|
16
16
|
import Highlight from "../../highlight/Highlight.js";
|
|
17
17
|
import { ShadedGeometryHighlightSystem } from "../../highlight/system/ShadedGeometryHighlightSystem.js";
|
|
18
|
+
import Quaternion from "../../../../../core/geom/Quaternion.js";
|
|
19
|
+
import { seededRandom } from "../../../../../core/math/random/seededRandom.js";
|
|
18
20
|
|
|
19
21
|
new EngineHarness().initialize({
|
|
20
22
|
configuration(config, engine) {
|
|
@@ -71,5 +73,26 @@ function main(engine) {
|
|
|
71
73
|
}
|
|
72
74
|
});
|
|
73
75
|
})
|
|
74
|
-
|
|
76
|
+
// .build(ecd);
|
|
77
|
+
const r = seededRandom(1);
|
|
78
|
+
|
|
79
|
+
for (let i = 0; i < 10; i++) {
|
|
80
|
+
for (let j = 0; j < 10; j++) {
|
|
81
|
+
const quaternion = new Quaternion();
|
|
82
|
+
|
|
83
|
+
quaternion.__setFromEuler(0, r() * Math.PI, 0);
|
|
84
|
+
|
|
85
|
+
new EntityBuilder()
|
|
86
|
+
.add(SGMesh.fromURL("data/models/RTS_Buildings_Humans/18/Building_R_18_out/Building_R_18.gltf"))
|
|
87
|
+
.add(Transform.fromJSON({
|
|
88
|
+
position: {
|
|
89
|
+
x: i * 8,
|
|
90
|
+
y: 0,
|
|
91
|
+
z: j * 8
|
|
92
|
+
},
|
|
93
|
+
rotation: quaternion
|
|
94
|
+
}))
|
|
95
|
+
.build(ecd);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
75
98
|
}
|
|
@@ -49,7 +49,7 @@ export class MicronRenderPlugin extends EnginePlugin {
|
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
*
|
|
52
|
-
* @type {AsyncRemoteHashMap}
|
|
52
|
+
* @type {AsyncRemoteHashMap<THREE.BufferGeometry, MicronGeometry>}
|
|
53
53
|
* @private
|
|
54
54
|
*/
|
|
55
55
|
this.__persisted_geometry = new AsyncRemoteHashMap({
|
|
@@ -60,6 +60,7 @@ export class MicronRenderPlugin extends EnginePlugin {
|
|
|
60
60
|
storageKeyPrefix: STORAGE_KEY,
|
|
61
61
|
|
|
62
62
|
});
|
|
63
|
+
|
|
63
64
|
/**
|
|
64
65
|
*
|
|
65
66
|
* @type {AbstractAsyncMap<THREE.BufferGeometry, MicronGeometry>}
|
|
@@ -109,7 +110,7 @@ export class MicronRenderPlugin extends EnginePlugin {
|
|
|
109
110
|
const sg_system = system;
|
|
110
111
|
|
|
111
112
|
sg_system.register_render_adapter(2, () => {
|
|
112
|
-
const adapter = new MicronShadedGeometryRenderAdapter();
|
|
113
|
+
const adapter = new MicronShadedGeometryRenderAdapter(this.__cache);
|
|
113
114
|
|
|
114
115
|
adapter.ctx = this.__vgtr.ctx;
|
|
115
116
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AbstractRenderAdapter } from "../../../ecs/mesh-v2/render/adapters/AbstractRenderAdapter.js";
|
|
2
2
|
import Vector2 from "../../../../../core/geom/Vector2.js";
|
|
3
|
-
import { buildMicronGeometryFromBufferGeometry } from "../../build/buildMicronGeometryFromBufferGeometry.js";
|
|
4
3
|
import { ShadedGeometryFlags } from "../../../ecs/mesh-v2/ShadedGeometryFlags.js";
|
|
5
4
|
import { MaterialVertexSpec, MaterialVertexSpecFlags } from "../../render/v1/MaterialVertexSpec.js";
|
|
6
5
|
import { compute_geometry_polycount } from "../../../geometry/compute_geometry_polycount.js";
|
|
@@ -26,7 +25,11 @@ const MICRON_POLYCOUNT_THRESHOLD_MAX = 10000;
|
|
|
26
25
|
|
|
27
26
|
export class MicronShadedGeometryRenderAdapter extends AbstractRenderAdapter {
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param {AbstractAsyncMap<THREE.BufferGeometry, MicronGeometry>} cache
|
|
31
|
+
*/
|
|
32
|
+
constructor(cache) {
|
|
30
33
|
super();
|
|
31
34
|
|
|
32
35
|
/**
|
|
@@ -48,6 +51,13 @@ export class MicronShadedGeometryRenderAdapter extends AbstractRenderAdapter {
|
|
|
48
51
|
* @private
|
|
49
52
|
*/
|
|
50
53
|
this.__geometry_building_promises = new Map();
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @type {AbstractAsyncMap<THREE.BufferGeometry, MicronGeometry>}
|
|
58
|
+
* @private
|
|
59
|
+
*/
|
|
60
|
+
this.__cache = cache;
|
|
51
61
|
}
|
|
52
62
|
|
|
53
63
|
score(geometry, material, instance_count) {
|
|
@@ -72,9 +82,10 @@ export class MicronShadedGeometryRenderAdapter extends AbstractRenderAdapter {
|
|
|
72
82
|
return micron_geometry;
|
|
73
83
|
|
|
74
84
|
} else {
|
|
85
|
+
|
|
75
86
|
// no micron geometry
|
|
76
87
|
if (!this.__geometry_building_promises.has(geometry_id)) {
|
|
77
|
-
const p =
|
|
88
|
+
const p = this.__cache.get(sg.geometry);
|
|
78
89
|
|
|
79
90
|
this.__geometry_building_promises.set(geometry_id, p);
|
|
80
91
|
|
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.37.
|
|
8
|
+
"version": "2.37.10",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|