@woosh/meep-engine 2.100.0 → 2.100.1
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/build/meep.cjs +553 -17
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +553 -17
- package/package.json +1 -1
- package/src/core/color/Color.d.ts.map +1 -1
- package/src/core/color/Color.js +39 -8
- package/src/engine/animation/async/prototypeAsyncAnimation.d.ts +2 -0
- package/src/engine/animation/async/prototypeAsyncAnimation.d.ts.map +1 -0
- package/src/engine/animation/async/prototypeAsyncAnimation.js +344 -0
- package/src/engine/asset/AssetManager.d.ts.map +1 -1
- package/src/engine/asset/AssetManager.js +17 -0
- package/src/engine/ecs/Entity.d.ts.map +1 -1
- package/src/engine/ecs/Entity.js +1 -0
- package/src/engine/ecs/terrain/ecs/TerrainSystem.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/TerrainSystem.js +3 -3
- package/src/engine/input/ecs/systems/InputControllerSystem.d.ts.map +1 -1
- package/src/engine/input/ecs/systems/InputControllerSystem.js +4 -8
- package/src/engine/intelligence/behavior/util/RandomDelayBehavior.d.ts +46 -0
- package/src/engine/intelligence/behavior/util/RandomDelayBehavior.d.ts.map +1 -0
- package/src/engine/intelligence/behavior/util/RandomDelayBehavior.js +85 -0
package/src/core/color/Color.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assert } from "../assert.js";
|
|
2
2
|
import { float2uint8 } from "../binary/float2uint8.js";
|
|
3
|
+
import { uint82float } from "../binary/uint82float.js";
|
|
3
4
|
import Signal from "../events/signal/Signal.js";
|
|
4
5
|
import { clamp01 } from "../math/clamp01.js";
|
|
5
6
|
import { lerp } from "../math/lerp.js";
|
|
@@ -14,14 +15,15 @@ import { linear_to_sRGB } from "./sRGB/linear_to_sRGB.js";
|
|
|
14
15
|
import { sRGB_to_linear } from "./sRGB/sRGB_to_linear.js";
|
|
15
16
|
|
|
16
17
|
/**
|
|
18
|
+
* @extends {Array.<number>}
|
|
17
19
|
* @class
|
|
18
20
|
*/
|
|
19
21
|
export class Color {
|
|
20
22
|
/**
|
|
21
23
|
*
|
|
22
|
-
* @param {number} r
|
|
23
|
-
* @param {number} g
|
|
24
|
-
* @param {number} b
|
|
24
|
+
* @param {number} [r] Red from 0 to 1
|
|
25
|
+
* @param {number} [g] Green from 0 to 1
|
|
26
|
+
* @param {number} [b] Blue from 0 to 1
|
|
25
27
|
* @param {number} [a] value from 0 to 1 Alpha channel (transparency)
|
|
26
28
|
*/
|
|
27
29
|
constructor(r = 0, g = 0, b = 0, a = 1) {
|
|
@@ -141,6 +143,20 @@ export class Color {
|
|
|
141
143
|
this.set(r, g, b, this.a);
|
|
142
144
|
}
|
|
143
145
|
|
|
146
|
+
/**
|
|
147
|
+
*
|
|
148
|
+
* @param {number} r
|
|
149
|
+
* @param {number} g
|
|
150
|
+
* @param {number} b
|
|
151
|
+
*/
|
|
152
|
+
setRGBUint8(r, g, b) {
|
|
153
|
+
this.setRGB(
|
|
154
|
+
uint82float(r),
|
|
155
|
+
uint82float(g),
|
|
156
|
+
uint82float(b),
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
|
|
144
160
|
/**
|
|
145
161
|
* set alpha
|
|
146
162
|
* @param {number} a
|
|
@@ -167,11 +183,28 @@ export class Color {
|
|
|
167
183
|
assert.notNaN(b, 'b');
|
|
168
184
|
assert.notNaN(a, 'a');
|
|
169
185
|
|
|
186
|
+
assert.isFiniteNumber(r, 'r');
|
|
187
|
+
assert.isFiniteNumber(g, 'g');
|
|
188
|
+
assert.isFiniteNumber(b, 'b');
|
|
189
|
+
assert.isFiniteNumber(a, 'a');
|
|
190
|
+
|
|
191
|
+
// remember old values
|
|
170
192
|
const _r = this.r;
|
|
171
193
|
const _g = this.g;
|
|
172
194
|
const _b = this.b;
|
|
173
195
|
const _a = this.a;
|
|
174
196
|
|
|
197
|
+
if (
|
|
198
|
+
_r === r
|
|
199
|
+
&& _g === g
|
|
200
|
+
&& _b === b
|
|
201
|
+
&& _a === a
|
|
202
|
+
) {
|
|
203
|
+
// no change
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// set new values
|
|
175
208
|
this.r = r;
|
|
176
209
|
this.g = g;
|
|
177
210
|
this.b = b;
|
|
@@ -414,7 +447,7 @@ export class Color {
|
|
|
414
447
|
const g = (value >> 8) & 0xFF;
|
|
415
448
|
const b = (value) & 0xFF;
|
|
416
449
|
|
|
417
|
-
this.
|
|
450
|
+
this.setRGBUint8(r, g, b);
|
|
418
451
|
}
|
|
419
452
|
|
|
420
453
|
/**
|
|
@@ -479,8 +512,7 @@ export class Color {
|
|
|
479
512
|
}
|
|
480
513
|
|
|
481
514
|
fromJSON({ r, g, b, a = 1 }) {
|
|
482
|
-
this.
|
|
483
|
-
this.a = a;
|
|
515
|
+
this.set(r, g, b, a);
|
|
484
516
|
}
|
|
485
517
|
|
|
486
518
|
toJSON() {
|
|
@@ -534,8 +566,7 @@ export class Color {
|
|
|
534
566
|
const b = buffer.readFloat32();
|
|
535
567
|
const a = buffer.readFloat32();
|
|
536
568
|
|
|
537
|
-
this.
|
|
538
|
-
this.a = a;
|
|
569
|
+
this.set(r, g, b, a);
|
|
539
570
|
}
|
|
540
571
|
|
|
541
572
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prototypeAsyncAnimation.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/async/prototypeAsyncAnimation.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { GUI } from "dat.gui";
|
|
2
|
+
import { MeshBasicMaterial, MeshStandardMaterial, OctahedronBufferGeometry } from "three";
|
|
3
|
+
import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
|
|
4
|
+
import { RowFirstTable } from "../../../core/collection/table/RowFirstTable.js";
|
|
5
|
+
import { RowFirstTableSpec } from "../../../core/collection/table/RowFirstTableSpec.js";
|
|
6
|
+
import { Color } from "../../../core/color/Color.js";
|
|
7
|
+
import { inverseLerp } from "../../../core/math/inverseLerp.js";
|
|
8
|
+
import { lerp } from "../../../core/math/lerp.js";
|
|
9
|
+
import { max2 } from "../../../core/math/max2.js";
|
|
10
|
+
import { min2 } from "../../../core/math/min2.js";
|
|
11
|
+
import { randomFloatBetween } from "../../../core/math/random/randomFloatBetween.js";
|
|
12
|
+
import { seededRandom } from "../../../core/math/random/seededRandom.js";
|
|
13
|
+
import Clock from "../../Clock.js";
|
|
14
|
+
import Entity from "../../ecs/Entity.js";
|
|
15
|
+
import { Transform } from "../../ecs/transform/Transform.js";
|
|
16
|
+
import { EngineHarness } from "../../EngineHarness.js";
|
|
17
|
+
import { ShadedGeometry } from "../../graphics/ecs/mesh-v2/ShadedGeometry.js";
|
|
18
|
+
import { ShadedGeometrySystem } from "../../graphics/ecs/mesh-v2/ShadedGeometrySystem.js";
|
|
19
|
+
import Trail2D from "../../graphics/ecs/trail2d/Trail2D.js";
|
|
20
|
+
import Trail2DSystem from "../../graphics/ecs/trail2d/Trail2DSystem.js";
|
|
21
|
+
import {
|
|
22
|
+
RGBA_LUT_HEATMAP_IR
|
|
23
|
+
} from "../../graphics/particles/particular/engine/parameter/sample/RGBA_LUT_HEATMAP_IR.js";
|
|
24
|
+
import { SequenceBehavior } from "../../intelligence/behavior/composite/SequenceBehavior.js";
|
|
25
|
+
import { RepeatBehavior } from "../../intelligence/behavior/decorator/RepeatBehavior.js";
|
|
26
|
+
import { BehaviorComponent } from "../../intelligence/behavior/ecs/BehaviorComponent.js";
|
|
27
|
+
import { BehaviorSystem } from "../../intelligence/behavior/ecs/BehaviorSystem.js";
|
|
28
|
+
import { ActionBehavior } from "../../intelligence/behavior/primitive/ActionBehavior.js";
|
|
29
|
+
import { RandomDelayBehavior } from "../../intelligence/behavior/util/RandomDelayBehavior.js";
|
|
30
|
+
|
|
31
|
+
const harness = new EngineHarness();
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param {RowFirstTable} table
|
|
36
|
+
* @param {number} time
|
|
37
|
+
* @return {number}
|
|
38
|
+
*/
|
|
39
|
+
function findSampleIndex(table, time) {
|
|
40
|
+
let minIndex = 0;
|
|
41
|
+
let maxIndex = table.length - 1;
|
|
42
|
+
|
|
43
|
+
while (minIndex <= maxIndex) {
|
|
44
|
+
|
|
45
|
+
const pivotIndex = (minIndex + maxIndex) >> 1;
|
|
46
|
+
|
|
47
|
+
const cmp = time - table.readCellValue(pivotIndex, 0);
|
|
48
|
+
|
|
49
|
+
if (cmp > 0) {
|
|
50
|
+
minIndex = pivotIndex + 1;
|
|
51
|
+
} else if (cmp < 0) {
|
|
52
|
+
maxIndex = pivotIndex - 1;
|
|
53
|
+
} else {
|
|
54
|
+
//set low boundary for next step based on assumption that upper bound is higher than lower bound
|
|
55
|
+
return pivotIndex;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return min2(minIndex, maxIndex);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param {EntityComponentDataset} ecd
|
|
65
|
+
* @param {RowFirstTable} table
|
|
66
|
+
* @param {number} [count]
|
|
67
|
+
*/
|
|
68
|
+
function makeGhostMarkers({
|
|
69
|
+
ecd,
|
|
70
|
+
table,
|
|
71
|
+
count = 5
|
|
72
|
+
}) {
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
const g = new OctahedronBufferGeometry(1, 3);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @type {Entity[]}
|
|
80
|
+
*/
|
|
81
|
+
const entities = [];
|
|
82
|
+
|
|
83
|
+
for (let i = 0; i < count; i++) {
|
|
84
|
+
|
|
85
|
+
const color = new Color();
|
|
86
|
+
|
|
87
|
+
const sample = [];
|
|
88
|
+
|
|
89
|
+
RGBA_LUT_HEATMAP_IR.sample(i / (count - 1), sample);
|
|
90
|
+
|
|
91
|
+
color.setRGBUint8(...sample);
|
|
92
|
+
|
|
93
|
+
const transform = new Transform();
|
|
94
|
+
|
|
95
|
+
const entity = new Entity();
|
|
96
|
+
|
|
97
|
+
entities.push(entity);
|
|
98
|
+
|
|
99
|
+
entity
|
|
100
|
+
.add(transform)
|
|
101
|
+
.add(ShadedGeometry.from(g, new MeshBasicMaterial({
|
|
102
|
+
wireframe: true,
|
|
103
|
+
color: color.toUint()
|
|
104
|
+
})))
|
|
105
|
+
.build(ecd);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
set time(time) {
|
|
110
|
+
|
|
111
|
+
const ref_index = findSampleIndex(table, time);
|
|
112
|
+
|
|
113
|
+
const start_index = max2(0, ref_index - Math.floor(count / 2));
|
|
114
|
+
const limit_index = min2(table.length - 1, ref_index + Math.ceil(count / 2));
|
|
115
|
+
|
|
116
|
+
for (let i = 0; i < count; i++) {
|
|
117
|
+
|
|
118
|
+
const entity = entities[i];
|
|
119
|
+
|
|
120
|
+
const sample_index = ref_index - Math.floor(count / 2) + i;
|
|
121
|
+
|
|
122
|
+
const out_of_bound_marker = sample_index < start_index || sample_index > limit_index;
|
|
123
|
+
|
|
124
|
+
if (out_of_bound_marker) {
|
|
125
|
+
if (entity.isBuilt) {
|
|
126
|
+
entity.destroy();
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
if (!entity.isBuilt) {
|
|
130
|
+
entity.build(ecd);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (out_of_bound_marker) {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const transform = entity.getComponentSafe(Transform);
|
|
139
|
+
|
|
140
|
+
transform.position.set(
|
|
141
|
+
table.readCellValue(sample_index, 1),
|
|
142
|
+
table.readCellValue(sample_index, 2),
|
|
143
|
+
table.readCellValue(sample_index, 3)
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
*
|
|
153
|
+
* @param {Engine} engine
|
|
154
|
+
* @return {Promise<void>}
|
|
155
|
+
*/
|
|
156
|
+
async function main(engine) {
|
|
157
|
+
await EngineHarness.buildBasics({
|
|
158
|
+
engine
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
const table = new RowFirstTable(
|
|
162
|
+
RowFirstTableSpec.get([
|
|
163
|
+
BinaryDataType.Float64, // time
|
|
164
|
+
BinaryDataType.Float32, // x
|
|
165
|
+
BinaryDataType.Float32, //y
|
|
166
|
+
BinaryDataType.Float32 //z
|
|
167
|
+
])
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const random = seededRandom(42);
|
|
171
|
+
|
|
172
|
+
table.addRow([
|
|
173
|
+
0, 0, 1, 0
|
|
174
|
+
]);
|
|
175
|
+
|
|
176
|
+
const sample = [];
|
|
177
|
+
|
|
178
|
+
const sim_clock = new Clock();
|
|
179
|
+
sim_clock.start();
|
|
180
|
+
|
|
181
|
+
function addSample() {
|
|
182
|
+
|
|
183
|
+
const time_delta = sim_clock.getDelta();
|
|
184
|
+
|
|
185
|
+
// get last row
|
|
186
|
+
const row_count = table.length;
|
|
187
|
+
|
|
188
|
+
table.getRow(row_count - 1, sample);
|
|
189
|
+
|
|
190
|
+
const speed = 7;
|
|
191
|
+
|
|
192
|
+
const displacement = speed * time_delta;
|
|
193
|
+
|
|
194
|
+
const direction = randomFloatBetween(random, -Math.PI, Math.PI);
|
|
195
|
+
|
|
196
|
+
const displacement_x = displacement * Math.cos(direction);
|
|
197
|
+
const displacement_y = displacement * Math.sin(direction);
|
|
198
|
+
|
|
199
|
+
const new_x = sample[1] + displacement_x;
|
|
200
|
+
const new_z = sample[3] + displacement_y;
|
|
201
|
+
|
|
202
|
+
table.addRow([
|
|
203
|
+
sample[0] + time_delta,
|
|
204
|
+
new_x,
|
|
205
|
+
1,
|
|
206
|
+
new_z,
|
|
207
|
+
|
|
208
|
+
]);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
const ecd = engine.entityManager.dataset;
|
|
213
|
+
|
|
214
|
+
// simulate data arriving from the network
|
|
215
|
+
const sample_delay = RandomDelayBehavior.from(0.5, 1);
|
|
216
|
+
new Entity()
|
|
217
|
+
.add(BehaviorComponent.fromOne(RepeatBehavior.from(
|
|
218
|
+
SequenceBehavior.from([
|
|
219
|
+
sample_delay,
|
|
220
|
+
new ActionBehavior(addSample)
|
|
221
|
+
])
|
|
222
|
+
)))
|
|
223
|
+
.build(ecd);
|
|
224
|
+
|
|
225
|
+
const sim_parameters = {
|
|
226
|
+
playing: true,
|
|
227
|
+
play_time: -1,
|
|
228
|
+
get latest_data_time() {
|
|
229
|
+
return table.readCellValue(table.length - 1, 0);
|
|
230
|
+
},
|
|
231
|
+
get behind_latest() {
|
|
232
|
+
return table.readCellValue(table.length - 1, 0) - this.play_time;
|
|
233
|
+
},
|
|
234
|
+
set behind_latest(v) {
|
|
235
|
+
|
|
236
|
+
const current_delay = table.readCellValue(table.length - 1, 0) - this.play_time;
|
|
237
|
+
|
|
238
|
+
const delta = v - current_delay;
|
|
239
|
+
|
|
240
|
+
this.play_time += delta;
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
// simulate agent moving through space
|
|
246
|
+
const subject = new Entity();
|
|
247
|
+
|
|
248
|
+
subject
|
|
249
|
+
.add(Transform.fromJSON({
|
|
250
|
+
position: 0
|
|
251
|
+
}))
|
|
252
|
+
.add(Trail2D.fromJSON({
|
|
253
|
+
textureURL: "data/textures/trail/Circle_04.png",
|
|
254
|
+
width: 0.2
|
|
255
|
+
}))
|
|
256
|
+
.add(ShadedGeometry.from(new OctahedronBufferGeometry(1, 5), new MeshStandardMaterial()))
|
|
257
|
+
.add(BehaviorComponent.fromOne(RepeatBehavior.from(
|
|
258
|
+
new ActionBehavior((delta) => {
|
|
259
|
+
if (sim_parameters.playing) {
|
|
260
|
+
sim_parameters.play_time += delta;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
// seek to the right sample
|
|
265
|
+
const sample_index = max2(0, findSampleIndex(table, sim_parameters.play_time));
|
|
266
|
+
const next_sample_index = min2(table.length - 1, sample_index + 1);
|
|
267
|
+
|
|
268
|
+
const prev = table.readCellValue(sample_index, 0);
|
|
269
|
+
const next = table.readCellValue(next_sample_index, 0);
|
|
270
|
+
|
|
271
|
+
const normalized_offset = inverseLerp(prev, next, sim_parameters.play_time);
|
|
272
|
+
|
|
273
|
+
const transform = subject.getComponentSafe(Transform);
|
|
274
|
+
|
|
275
|
+
const x0 = table.readCellValue(sample_index, 1);
|
|
276
|
+
const x1 = table.readCellValue(next_sample_index, 1);
|
|
277
|
+
|
|
278
|
+
const y0 = table.readCellValue(sample_index, 2);
|
|
279
|
+
const y1 = table.readCellValue(next_sample_index, 2);
|
|
280
|
+
|
|
281
|
+
const z0 = table.readCellValue(sample_index, 3);
|
|
282
|
+
const z1 = table.readCellValue(next_sample_index, 3);
|
|
283
|
+
|
|
284
|
+
transform.position.set(
|
|
285
|
+
lerp(x0, x1, normalized_offset),
|
|
286
|
+
lerp(y0, y1, normalized_offset),
|
|
287
|
+
lerp(z0, z1, normalized_offset),
|
|
288
|
+
);
|
|
289
|
+
})
|
|
290
|
+
)))
|
|
291
|
+
.build(ecd);
|
|
292
|
+
|
|
293
|
+
const markers = makeGhostMarkers({
|
|
294
|
+
ecd, table, count: 5
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
engine.ticker.onTick.add(() => markers.time = sim_parameters.play_time);
|
|
298
|
+
|
|
299
|
+
const gui = new GUI();
|
|
300
|
+
|
|
301
|
+
const gui_samples = gui.addFolder("samples");
|
|
302
|
+
gui_samples.add(sample_delay.limits, 'min').name("min_delay").step(0.01)
|
|
303
|
+
gui_samples.add(sample_delay.limits, 'max').name("max_delay").step(0.01)
|
|
304
|
+
|
|
305
|
+
for (const k in sim_parameters) {
|
|
306
|
+
|
|
307
|
+
const control = gui.add(sim_parameters, k);
|
|
308
|
+
|
|
309
|
+
if (typeof sim_parameters[k] === "number") {
|
|
310
|
+
control.step(0.01);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
let last_value = sim_parameters[k];
|
|
314
|
+
|
|
315
|
+
engine.ticker.onTick.add(() => {
|
|
316
|
+
let should_update = true;
|
|
317
|
+
|
|
318
|
+
const current_value = sim_parameters[k];
|
|
319
|
+
if (last_value === current_value) {
|
|
320
|
+
should_update = false;
|
|
321
|
+
} else {
|
|
322
|
+
last_value = current_value;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
if (should_update) {
|
|
327
|
+
control.updateDisplay();
|
|
328
|
+
}
|
|
329
|
+
})
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
gui.open();
|
|
333
|
+
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
harness.initialize({
|
|
337
|
+
configuration(config, engine) {
|
|
338
|
+
config.addManySystems(
|
|
339
|
+
new BehaviorSystem(engine),
|
|
340
|
+
new ShadedGeometrySystem(engine),
|
|
341
|
+
new Trail2DSystem(engine)
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
}).then(main);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/asset/AssetManager.js"],"names":[],"mappings":"AAiDA;;;;GAIG;AACH;IAgII;;;;;OAKG;IACH,oCAJW,GAAG,EAYb;IA7ID;;;;OAIG;IACH,eAEG;IAEH;;;OAGG;IACH,aAFU,YAAY,gBAAgB,EAAE,YAAY,CAAC,CAER;IAe7C;;;;;;OAMG;IACH,kBAFU,MAAM,CAEY;IAyB5B;;;;OAIG;IACH,iBAAc;IAEd;;;OAGG;IACH,mBAFU,iBAAiB,CAEiB;IAwE5C,gBAQC;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACL,QAAQ,IAAI,CAAC,CAexB;IAED;;;;;OAKG;IACH,oCAFa,OAAO,CAOnB;IAED;;OAEG;IACH,cAEC;IAED,8BAEC;IAED;;;;;;OAMG;IACH,4DAJW,iBAAiB,GAEf,cAAc,CAY1B;IAED;;;;;;;;;OASG;IACH,qFAsCC;IAED;;;;;OAKG;IACH,aAJW,MAAM,QACN,MAAM,sBAehB;IAsQD;;;;;OAKG;IACH,sBA2BC;IAGD;;;;OAIG;IACH,uBAHW,MAAM,GACL,OAAO,CAIlB;IAED;;;;OAIG;IACH,sBAHW,MAAM,GACJ,wBAAY,SAAS,CAMjC;IAaD;;;;OAIG;IACH,+BAHW,MAAM,4CAqBhB;IAED;;;;OAIG;IACH,iCAHW,MAAM,+CAyBhB;IAED;;;;;OAKG;IACH,0BAJW,MAAM,iEAwChB;IAED;;;OAGG;IACH,uBAFW,MAAM,iBAkBhB;IAED;;;;;;OAMG;IACH,yCAFa,aAAS,IAAI,CAYzB;IAED;;;;;OAKG;IACH,eAJW,MAAM,QACN,MAAM,GACJ,OAAO,CAMnB;IAED;;;;OAIG;IACH,2BAHW,MAAM,GACL,mBAAiB,CAa5B;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACL,gBAAgB,GAAC,SAAS,CAQrC;IAED;;;;;OAKG;IACH,mBAJW,MAAM,QACN,MAAM,QACN,MAAM,QAUhB;IAGL;;;OAGG;IACH,yBAFU,OAAO,CAEoB;;CANpC;
|
|
1
|
+
{"version":3,"file":"AssetManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/asset/AssetManager.js"],"names":[],"mappings":"AAiDA;;;;GAIG;AACH;IAgII;;;;;OAKG;IACH,oCAJW,GAAG,EAYb;IA7ID;;;;OAIG;IACH,eAEG;IAEH;;;OAGG;IACH,aAFU,YAAY,gBAAgB,EAAE,YAAY,CAAC,CAER;IAe7C;;;;;;OAMG;IACH,kBAFU,MAAM,CAEY;IAyB5B;;;;OAIG;IACH,iBAAc;IAEd;;;OAGG;IACH,mBAFU,iBAAiB,CAEiB;IAwE5C,gBAQC;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACL,QAAQ,IAAI,CAAC,CAexB;IAED;;;;;OAKG;IACH,oCAFa,OAAO,CAOnB;IAED;;OAEG;IACH,cAEC;IAED,8BAEC;IAED;;;;;;OAMG;IACH,4DAJW,iBAAiB,GAEf,cAAc,CAY1B;IAED;;;;;;;;;OASG;IACH,qFAsCC;IAED;;;;;OAKG;IACH,aAJW,MAAM,QACN,MAAM,sBAehB;IAsQD;;;;;OAKG;IACH,sBA2BC;IAGD;;;;OAIG;IACH,uBAHW,MAAM,GACL,OAAO,CAIlB;IAED;;;;OAIG;IACH,sBAHW,MAAM,GACJ,wBAAY,SAAS,CAMjC;IAaD;;;;OAIG;IACH,+BAHW,MAAM,4CAqBhB;IAED;;;;OAIG;IACH,iCAHW,MAAM,+CAyBhB;IAED;;;;;;OAMG;IACH,6BAJW,MAAM,kCAEJ,QAAQ,OAAO,CAAC,CAU5B;IAED;;;;;OAKG;IACH,0BAJW,MAAM,iEAwChB;IAED;;;OAGG;IACH,uBAFW,MAAM,iBAkBhB;IAED;;;;;;OAMG;IACH,yCAFa,aAAS,IAAI,CAYzB;IAED;;;;;OAKG;IACH,eAJW,MAAM,QACN,MAAM,GACJ,OAAO,CAMnB;IAED;;;;OAIG;IACH,2BAHW,MAAM,GACL,mBAAiB,CAa5B;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACL,gBAAgB,GAAC,SAAS,CAQrC;IAED;;;;;OAKG;IACH,mBAJW,MAAM,QACN,MAAM,QACN,MAAM,QAUhB;IAGL;;;OAGG;IACH,yBAFU,OAAO,CAEoB;;CANpC;4BAx2B2B,0CAA0C;iCAOrC,uBAAuB;6BAM3B,mBAAmB;kCAFd,6BAA6B;kCAD7B,wBAAwB;4BAE9B,0BAA0B"}
|
|
@@ -720,6 +720,23 @@ export class AssetManager {
|
|
|
720
720
|
return true;
|
|
721
721
|
}
|
|
722
722
|
|
|
723
|
+
/**
|
|
724
|
+
* Will register loader only if none exists for this type
|
|
725
|
+
* @template T
|
|
726
|
+
* @param {string} type
|
|
727
|
+
* @param {AssetLoader<T>} loader
|
|
728
|
+
* @returns {Promise<boolean>} true if registered , false otherwise
|
|
729
|
+
*/
|
|
730
|
+
async tryRegisterLoader(type, loader) {
|
|
731
|
+
if (this.hasLoaderForType(type)) {
|
|
732
|
+
return false;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
await this.registerLoader(type, loader);
|
|
736
|
+
|
|
737
|
+
return true;
|
|
738
|
+
}
|
|
739
|
+
|
|
723
740
|
/**
|
|
724
741
|
* @template T
|
|
725
742
|
* @param {string} type
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/Entity.js"],"names":[],"mappings":";AAeA;;;GAGG;AACH;
|
|
1
|
+
{"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/Entity.js"],"names":[],"mappings":";AAeA;;;GAGG;AACH;IAoYI;;;;;OAKG;IACH,+BAJW,MAAM,oCAEJ,MAAM,CAelB;IArZD;;;OAGG;IACH,IAFU,MAAM,CAER;IAER;;;;OAIG;IACH,YAFU,MAAM,CAEA;IAEhB;;;;OAIG;IACH,2BAAgB;IAQhB;;;OAGG;IACH,gCAAe;IAEf;;;OAGG;IACH,OAFU,WAAW,GAAC,MAAM,CAEN;IAEtB;;;OAGG;IACH,gBAAgB;IAEhB;;OAEG;IACH;;MAEE;IAUF;;;OAGG;IACH,eAFW,MAAM,GAAC,WAAW,QAI5B;IAED;;;;OAIG;IACH,cAHW,MAAM,GAAC,WAAW,GAChB,OAAO,CAMnB;IAED;;;OAGG;IACH,gBAFW,MAAM,GAAC,WAAW,QAI5B;IAED;;;OAGG;IACH,uBAEC;IAED;;OAEG;IACH,4BAQC;IAED;;;OAGG;IACH,oBAEC;IAED;;;;OAIG;IACH,8BAFa,MAAM,CAiBlB;IAED;;;;OAIG;IACH,+BAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,0CAYC;IAED;;;;;OAKG;IACH,8CAQC;IAED;;;;OAIG;IACH,kCAFa,MAAE,IAAI,CA0BlB;IAED;;;;OAIG;IACH,qBAHW,MAAM,qBAShB;IAED;;;OAGG;IACH,wBAFW,MAAM,gBAiBhB;IAED;;;;;;OAMG;IACH,4BALW,MAAM,sCAGJ,MAAM,CAalB;IAED;;;;;;OAMG;IACH,+BALW,MAAM,sCAGJ,MAAM,CAyBlB;IAED;;;OAGG;IACH,WAFa,OAAO,CAwBnB;IAED;;;;OAIG;IACH,+CAqDC;IAwBL;;;;OAIG;IACH,mBAFU,OAAO,CAEQ;;CAPxB;4BAxa2B,kBAAkB;mBAF3B,oCAAoC"}
|
package/src/engine/ecs/Entity.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TerrainSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/terrain/ecs/TerrainSystem.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"TerrainSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/terrain/ecs/TerrainSystem.js"],"names":[],"mappings":";AA+BA;IA2MI;;;;;OAKG;IACH,kEAHW,OAAO,uBAwCjB;IA7ND;;;;;OAKG;IACH,kEAeC;IA7CD,iCAAyB;IAEzB,mBAAe;IACf,mBAAe;IAEf;;;;OAIG;IACH,qBAAiB;IAEjB;;;OAGG;IACH,aAFU,cAAY,IAAI,CAEP;IAEnB;;;OAGG;IACH,KAFU,GAAG,CAEG;IAoBZ,yBAAwB;IAExB,2BAAgC;IAGpC,kDAMC;IAED,mFAyDC;IAED,2EAIC;IAED;;;;OAIG;IACH,gBAHW,OAAO,qBAqBjB;IAED;;;;OAIG;IACH,kBAHW,OAAO,qBAKjB;IAED,6BAaC;IAED;;;;;OAKG;IACH,gCAwBC;CA+CJ;uBA1QsB,iBAAiB;oBAEpB,cAAc;oBAbd,mCAAmC"}
|
|
@@ -8,6 +8,7 @@ import { noop } from "../../../../core/function/noop.js";
|
|
|
8
8
|
import { read_three_planes_to_array } from "../../../../core/geom/3d/frustum/read_three_planes_to_array.js";
|
|
9
9
|
import { MATRIX_4_IDENTITY } from "../../../../core/geom/3d/mat4/MATRIX_4_IDENTITY.js";
|
|
10
10
|
import { ImageRGBADataLoader } from "../../../asset/loaders/image/ImageRGBADataLoader.js";
|
|
11
|
+
import { TextureAssetLoader } from "../../../asset/loaders/texture/TextureAssetLoader.js";
|
|
11
12
|
import { CameraSystem } from '../../../graphics/ecs/camera/CameraSystem.js';
|
|
12
13
|
import { System } from '../../System.js';
|
|
13
14
|
import { Transform } from "../../transform/Transform.js";
|
|
@@ -137,9 +138,8 @@ class TerrainSystem extends System {
|
|
|
137
138
|
|
|
138
139
|
const am = this.assetManager;
|
|
139
140
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
141
|
+
await am.tryRegisterLoader('image', new ImageRGBADataLoader());
|
|
142
|
+
await am.tryRegisterLoader('texture', new TextureAssetLoader());
|
|
143
143
|
|
|
144
144
|
readyCallback();
|
|
145
145
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputControllerSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/ecs/systems/InputControllerSystem.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"InputControllerSystem.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/ecs/systems/InputControllerSystem.js"],"names":[],"mappings":";AAsLA;;GAEG;AACH;IACI,0BA+BC;IA7BG,gCAAsC;IAEtC,yCAAqC;IAErC,aAAsB;IA2B1B,0EAIC;IAFG,YAAiB;IAIrB;;;;OAIG;IACH,gBAHW,eAAe,qBAOzB;IAED;;;;OAIG;IACH,kBAHW,eAAe,qBASzB;CACJ;uBAhPsB,wBAAwB;0BADrB,yCAAyC;4BAEvC,kCAAkC"}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
import { assert } from "../../../../core/assert.js";
|
|
6
7
|
import { resolvePath } from "../../../../core/json/resolvePath.js";
|
|
8
|
+
import ObservedValue from "../../../../core/model/ObservedValue.js";
|
|
7
9
|
import { System } from "../../../ecs/System.js";
|
|
8
10
|
import InputController from "../components/InputController.js";
|
|
9
|
-
import ObservedValue from "../../../../core/model/ObservedValue.js";
|
|
10
|
-
import { assert } from "../../../../core/assert.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
*
|
|
@@ -122,12 +122,8 @@ function getOrCreateProxy(proxies, path, signal) {
|
|
|
122
122
|
* @param {InputControllerBinding} binding
|
|
123
123
|
*/
|
|
124
124
|
Proxy.prototype.add = function (binding) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
this.deferred.push(binding);
|
|
128
|
-
} else {
|
|
129
|
-
this.registerBinding(binding);
|
|
130
|
-
}
|
|
125
|
+
//TODO handle case where binding is added mid-dispatch
|
|
126
|
+
this.registerBinding(binding);
|
|
131
127
|
};
|
|
132
128
|
|
|
133
129
|
/**
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wait for a certain amount of time
|
|
3
|
+
*/
|
|
4
|
+
export class RandomDelayBehavior extends Behavior<any> {
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param json
|
|
8
|
+
* @return {RandomDelayBehavior}
|
|
9
|
+
*/
|
|
10
|
+
static fromJSON(json: any): RandomDelayBehavior;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @return {RandomDelayBehavior}
|
|
14
|
+
* @param min
|
|
15
|
+
* @param max
|
|
16
|
+
*/
|
|
17
|
+
static from(min: any, max: any): RandomDelayBehavior;
|
|
18
|
+
constructor();
|
|
19
|
+
/**
|
|
20
|
+
* Delay value in seconds
|
|
21
|
+
* @type {number}
|
|
22
|
+
*/
|
|
23
|
+
value: number;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @type {NumericInterval}
|
|
27
|
+
*/
|
|
28
|
+
limits: NumericInterval;
|
|
29
|
+
/**
|
|
30
|
+
* Time elapsed
|
|
31
|
+
* @private
|
|
32
|
+
* @type {number}
|
|
33
|
+
*/
|
|
34
|
+
private elapsed;
|
|
35
|
+
random: () => number;
|
|
36
|
+
fromJSON({ limits, elapsed }: {
|
|
37
|
+
limits: any;
|
|
38
|
+
elapsed?: number;
|
|
39
|
+
}): void;
|
|
40
|
+
initialize(ctx: any): void;
|
|
41
|
+
tick(timeDelta: any): BehaviorStatus.Running | BehaviorStatus.Succeeded;
|
|
42
|
+
}
|
|
43
|
+
import { Behavior } from "../Behavior.js";
|
|
44
|
+
import { NumericInterval } from "../../../../core/math/interval/NumericInterval.js";
|
|
45
|
+
import { BehaviorStatus } from "../BehaviorStatus.js";
|
|
46
|
+
//# sourceMappingURL=RandomDelayBehavior.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RandomDelayBehavior.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/intelligence/behavior/util/RandomDelayBehavior.js"],"names":[],"mappings":"AAWA;;GAEG;AACH;IA6BI;;;;OAIG;IACH,4BAFY,mBAAmB,CAM9B;IAED;;;;;OAKG;IACH,iCAJY,mBAAmB,CAU9B;;IAlDD;;;OAGG;IACH,OAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,QAFU,eAAe,CAEU;IAEnC;;;;OAIG;IACH,gBAAY;IAEZ,qBAAiC;IAGjC;;;aAGC;IA2BD,2BAKC;IAED,wEAQC;CACJ;yBAjFwB,gBAAgB;gCAFT,mDAAmD;+BAGpD,sBAAsB"}
|