@woosh/meep-engine 2.33.24 → 2.33.25
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/bvh2/binary/IndexedBinaryBVH.js +1 -1
- package/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +5 -1
- package/core/bvh2/traversal/__detailed_box_volume_intersection.js +22 -5
- package/core/collection/array/binarySearchHighIndex.js +1 -1
- package/core/collection/array/copyArray.js +2 -2
- package/core/geom/3d/normal/hemioct/unit_hemioct.spec.js +1 -1
- package/core/geom/3d/shape/AbstractShape3D.js +9 -0
- package/core/geom/3d/shape/CompositeShape.js +188 -8
- package/core/geom/3d/shape/TransformedShape3D.js +58 -2
- package/core/geom/3d/shape/UnitCubeShape3D.js +11 -0
- package/core/geom/3d/shape/UnitSphereShape3D.js +8 -0
- package/core/geom/3d/shape/util/shape_to_visual_entity.js +159 -0
- package/core/geom/random/randomPointInSphere.js +3 -2
- package/core/json/resolvePathByArray.js +2 -2
- package/{engine/graphics/render/forward_plus/materials → core/primitives/strings}/insert_after.js +3 -0
- package/core/primitives/strings/insert_after_or_replace.js +27 -0
- package/editor/process/symbolic/makeHelperBoxGeometry.js +44 -0
- package/editor/view/ecs/EntityEditor.js +2 -2
- package/editor/view/ecs/components/particles/ParticleEmitterController.js +2 -2
- package/engine/EngineHarness.js +1 -0
- package/engine/animation/AnimationUtils.js +5 -5
- package/engine/ecs/EntityBuilder.js +25 -5
- package/engine/ecs/attachment/AttachmentBinding.js +8 -0
- package/engine/ecs/attachment/AttachmentSystem.js +4 -0
- package/engine/ecs/attachment/TransformAttachmentBinding.js +14 -44
- package/engine/ecs/components/Tag.js +27 -6
- package/engine/ecs/fow/FogOfWar.js +4 -0
- package/engine/ecs/fow/FogOfWarSystem.js +2 -0
- package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +2 -0
- package/engine/ecs/system/AbstractContextSystem.js +1 -1
- package/engine/ecs/systems/TagSystem.js +17 -0
- package/engine/ecs/transform/Transform.js +19 -6
- package/engine/graphics/GraphicsEngine.js +11 -6
- package/engine/graphics/composit/CompositLayer.js +17 -4
- package/engine/graphics/composit/CompositingStages.js +8 -0
- package/engine/graphics/composit/LayerCompositer.js +35 -6
- package/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +11 -7
- package/engine/graphics/ecs/light/Light.js +2 -0
- package/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +5 -1
- package/engine/graphics/ecs/mesh-v2/DrawMode.js +5 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +32 -18
- package/engine/graphics/particles/ParticleEmitterLibrary.js +3 -0
- package/engine/graphics/particles/ecs/{ParticleEmitterSystem2.js → ParticleEmitterSystem.js} +17 -9
- package/engine/graphics/particles/particular/engine/ParticularEngine.js +8 -2
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +14 -25
- package/engine/graphics/particles/particular/engine/emitter/ParticleEmitterFlag.js +5 -0
- package/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +90 -2
- package/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +7 -7
- package/engine/graphics/particles/particular/engine/renderers/billboard/BILLBOARD_PARTICLE_SPECIFICATION.js +15 -12
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +262 -51
- package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +80 -46
- package/engine/graphics/particles/particular/engine/shader/debugAtlas.js +14 -0
- package/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +141 -0
- package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +148 -54
- package/engine/graphics/particles/particular/engine/utils/volume/lut_to_sampler.js +27 -0
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +542 -165
- package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +12 -6
- package/engine/graphics/render/forward_plus/materials/FP_INJECTION_POINT_ACCUMULATION.js +1 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_ACCUMULATION.js +32 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_DECODE_PARS.js +51 -0
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_PREAMBLE.js +25 -0
- package/engine/graphics/render/forward_plus/materials/fp_build_fragment_shader.js +31 -120
- package/engine/graphics/render/forward_plus/materials/fp_build_vertex_lighting_shared.js +35 -0
- package/engine/graphics/render/forward_plus/materials/fp_build_vertex_shader.js +4 -5
- package/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +10 -3
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +588 -53
- package/engine/graphics/render/forward_plus/prototypeLightManager.js +29 -4
- package/engine/graphics/shaders/TerrainShader.js +4 -5
- package/engine/graphics/util/composeMatrix4.js +33 -23
- package/engine/graphics/util/decompose_matrix_4_array.js +61 -0
- package/engine/intelligence/behavior/ecs/BehaviorComponent.js +30 -14
- package/engine/knowledge/database/StaticKnowledgeDataTable.js +6 -1
- package/engine/navigation/ecs/components/Path.js +0 -5
- package/package.json +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { min2 } from "../../../../../core/math/min2.js";
|
|
2
1
|
import { seededRandom } from "../../../../../core/math/random/seededRandom.js";
|
|
3
2
|
import { EngineHarness } from "../../../../EngineHarness.js";
|
|
4
3
|
import { EngineConfiguration } from "../../../../EngineConfiguration.js";
|
|
@@ -44,7 +43,15 @@ import { BehaviorSystem } from "../../../../intelligence/behavior/ecs/BehaviorSy
|
|
|
44
43
|
import { SerializationMetadataSystem } from "../../../../ecs/systems/SerializationMetadataSystem.js";
|
|
45
44
|
import { InverseKinematicsSystem } from "../../../../ecs/animation/InverseKinematicsSystem.js";
|
|
46
45
|
import { PathDisplaySystem } from "../../../ecs/path/PathDisplaySystem.js";
|
|
47
|
-
import {
|
|
46
|
+
import {
|
|
47
|
+
BoxBufferGeometry,
|
|
48
|
+
Group,
|
|
49
|
+
Mesh as ThreeMesh,
|
|
50
|
+
MeshBasicMaterial,
|
|
51
|
+
MeshStandardMaterial,
|
|
52
|
+
OctahedronBufferGeometry,
|
|
53
|
+
TorusKnotBufferGeometry
|
|
54
|
+
} from "three";
|
|
48
55
|
import RenderSystem from "../../../../ecs/systems/RenderSystem.js";
|
|
49
56
|
import { makeEngineOptionsModel } from "../../../../../../model/game/options/makeEngineOptionsModel.js";
|
|
50
57
|
import { enableEditor } from "../../../../../editor/enableEditor.js";
|
|
@@ -61,23 +68,26 @@ import { LightType } from "../../../ecs/light/LightType.js";
|
|
|
61
68
|
import { parseColor } from "../../../../../core/color/ColorUtils.js";
|
|
62
69
|
import Renderable from "../../../../ecs/components/Renderable.js";
|
|
63
70
|
import { makeHelperSphereGeometry } from "../../../../../editor/process/symbolic/makeHelperSphereGeometry.js";
|
|
64
|
-
import GUIElement from "../../../../ecs/gui/GUIElement.js";
|
|
65
|
-
import View from "../../../../../view/View.js";
|
|
66
|
-
import { buildLightClusterWidget } from "../debug/buildLightClusterWidget.js";
|
|
67
|
-
import ViewportPosition from "../../../../ecs/gui/position/ViewportPosition.js";
|
|
68
71
|
import TopDownCameraController from "../../../ecs/camera/topdown/TopDownCameraController.js";
|
|
69
72
|
import ThreeFactory from "../../../three/ThreeFactory.js";
|
|
70
73
|
import { obtainTerrain } from "../../../../../../model/game/scenes/SceneUtils.js";
|
|
71
|
-
import Vector4 from "../../../../../core/geom/Vector4.js";
|
|
72
74
|
import { JsonAssetLoader } from "../../../../asset/loaders/JsonAssetLoader.js";
|
|
73
75
|
import { TextureAssetLoader } from "../../../../asset/loaders/texture/TextureAssetLoader.js";
|
|
74
76
|
import { GameAssetType } from "../../../../asset/GameAssetType.js";
|
|
75
77
|
import { GLTFAssetLoader } from "../../../../asset/loaders/GLTFAssetLoader.js";
|
|
76
78
|
import { ImageRGBADataLoader } from "../../../../asset/loaders/image/ImageRGBADataLoader.js";
|
|
77
|
-
import { buildCubeURLs } from "../../../texture/cubemap/buildCubeURLs.js";
|
|
78
79
|
import { randomFloatBetween } from "../../../../../core/math/random/randomFloatBetween.js";
|
|
79
|
-
|
|
80
|
+
import { ParticleEmitter } from "../../../particles/particular/engine/emitter/ParticleEmitter.js";
|
|
81
|
+
import { ParticleEmitterSystem } from "../../../particles/ecs/ParticleEmitterSystem.js";
|
|
82
|
+
import { ShadedGeometrySystem } from "../../../ecs/mesh-v2/ShadedGeometrySystem.js";
|
|
83
|
+
import { FogOfWar } from "../../../../ecs/fow/FogOfWar.js";
|
|
84
|
+
import { FogOfWarRevealer } from "../../../../ecs/fow/FogOfWarRevealer.js";
|
|
85
|
+
import Team from "../../../../../../model/game/ecs/component/Team.js";
|
|
86
|
+
|
|
87
|
+
const geo_light_center_octahedron = new BoxBufferGeometry(0.1, 0.1, 0.1);
|
|
80
88
|
const engineHarness = new EngineHarness();
|
|
89
|
+
const sphere_geometry = new OctahedronBufferGeometry(1, 5);
|
|
90
|
+
const sphere_geometry_shell = makeHelperSphereGeometry(1);
|
|
81
91
|
|
|
82
92
|
function makeConfig(engine) {
|
|
83
93
|
|
|
@@ -136,17 +146,19 @@ function makeConfig(engine) {
|
|
|
136
146
|
new InputSystem(devices),
|
|
137
147
|
new MeshHighlightSystem(engine),
|
|
138
148
|
new LightSystem(engine, {
|
|
139
|
-
shadowResolution:
|
|
149
|
+
shadowResolution: 2048
|
|
140
150
|
}),
|
|
141
151
|
new AnimationControllerSystem(),
|
|
142
152
|
new AnimationGraphSystem(graphics.viewport.size),
|
|
143
153
|
headsUpDisplaySystem,
|
|
154
|
+
new ParticleEmitterSystem(engine),
|
|
144
155
|
new FogOfWarSystem(graphics),
|
|
145
156
|
new FogOfWarRevealerSystem(0),
|
|
146
157
|
new BehaviorSystem(engine),
|
|
147
158
|
new SerializationMetadataSystem(),
|
|
148
159
|
new InverseKinematicsSystem(),
|
|
149
160
|
new PathDisplaySystem(engine),
|
|
161
|
+
new ShadedGeometrySystem(engine)
|
|
150
162
|
);
|
|
151
163
|
|
|
152
164
|
// Plugins
|
|
@@ -197,19 +209,30 @@ function makeLight(position, radius, color, intensity = 1) {
|
|
|
197
209
|
light.distance.set(radius);
|
|
198
210
|
light.intensity.set(intensity);
|
|
199
211
|
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
212
|
+
const color_uint = light.color.toUint();
|
|
213
|
+
const visual_group = new Group();
|
|
214
|
+
|
|
215
|
+
const mesh_center_0 = new ThreeMesh(sphere_geometry, new MeshBasicMaterial({
|
|
216
|
+
color: color_uint
|
|
217
|
+
}));
|
|
218
|
+
mesh_center_0.scale.setScalar(0.1);
|
|
219
|
+
mesh_center_0.matrixAutoUpdate = false;
|
|
220
|
+
|
|
221
|
+
visual_group.add(mesh_center_0);
|
|
222
|
+
|
|
223
|
+
const mesh_center_1 = new ThreeMesh(sphere_geometry, new MeshBasicMaterial({
|
|
224
|
+
color: color_uint,
|
|
203
225
|
transparent: true,
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
});
|
|
226
|
+
opacity: 0.06
|
|
227
|
+
}));
|
|
228
|
+
mesh_center_1.scale.setScalar(0.3);
|
|
229
|
+
mesh_center_1.matrixAutoUpdate = false;
|
|
209
230
|
|
|
210
|
-
|
|
231
|
+
visual_group.add(mesh_center_1);
|
|
232
|
+
|
|
233
|
+
const renderable = new Renderable(visual_group);
|
|
234
|
+
renderable.matrixAutoUpdate = true;
|
|
211
235
|
|
|
212
|
-
const renderable = new Renderable(new Line(geometry, sphere_material));
|
|
213
236
|
return new EntityBuilder()
|
|
214
237
|
.add(Transform.fromJSON({
|
|
215
238
|
position: {
|
|
@@ -218,8 +241,9 @@ function makeLight(position, radius, color, intensity = 1) {
|
|
|
218
241
|
z: position[2]
|
|
219
242
|
}
|
|
220
243
|
}))
|
|
244
|
+
// .add(center_geo)
|
|
221
245
|
.add(light)
|
|
222
|
-
|
|
246
|
+
.add(renderable)
|
|
223
247
|
}
|
|
224
248
|
|
|
225
249
|
|
|
@@ -265,13 +289,13 @@ function setup_scene_0(engine, ecd) {
|
|
|
265
289
|
|
|
266
290
|
console.log(terrain);
|
|
267
291
|
|
|
268
|
-
terrain.overlay.size.set(50, 50);
|
|
269
|
-
for (let i = 0; i < 50; i++) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
292
|
+
// terrain.overlay.size.set(50, 50);
|
|
293
|
+
// for (let i = 0; i < 50; i++) {
|
|
294
|
+
// for (let j = 0; j < 50; j++) {
|
|
295
|
+
//
|
|
296
|
+
// terrain.overlay.paintPoint(i, j, new Vector4(random(), random(), random(), 0.9));
|
|
297
|
+
// }
|
|
298
|
+
// }
|
|
275
299
|
|
|
276
300
|
/**
|
|
277
301
|
*
|
|
@@ -298,16 +322,16 @@ function setup_scene_0(engine, ecd) {
|
|
|
298
322
|
camera_controller.target.add(offset);
|
|
299
323
|
|
|
300
324
|
|
|
301
|
-
for (let i = 0; i <
|
|
325
|
+
for (let i = 0; i < 10; i++) {
|
|
302
326
|
|
|
303
327
|
const builder = makeLight([
|
|
304
328
|
randomFloatBetween(random, -18, 18) + offset.x,
|
|
305
|
-
randomFloatBetween(random, 0,
|
|
329
|
+
randomFloatBetween(random, 0.5, 13) + offset.y,
|
|
306
330
|
randomFloatBetween(random, -10, 10) + offset.z
|
|
307
331
|
],
|
|
308
|
-
randomFloatBetween(random,
|
|
332
|
+
randomFloatBetween(random, 5, 5),
|
|
309
333
|
`hsv(${random().toFixed(4)}, 1, 1)`,
|
|
310
|
-
|
|
334
|
+
5
|
|
311
335
|
);
|
|
312
336
|
|
|
313
337
|
const light = builder.getComponent(Light);
|
|
@@ -329,7 +353,154 @@ function setup_scene_0(engine, ecd) {
|
|
|
329
353
|
.build(ecd);
|
|
330
354
|
}
|
|
331
355
|
|
|
332
|
-
|
|
356
|
+
new EntityBuilder()
|
|
357
|
+
.add(ParticleEmitter.fromJSON({
|
|
358
|
+
"parameters": [
|
|
359
|
+
{
|
|
360
|
+
"name": "scale",
|
|
361
|
+
"itemSize": 1,
|
|
362
|
+
"defaultTrackValue": {
|
|
363
|
+
"itemSize": 1,
|
|
364
|
+
"data": [
|
|
365
|
+
1
|
|
366
|
+
],
|
|
367
|
+
"positions": [
|
|
368
|
+
0
|
|
369
|
+
]
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
"name": "color",
|
|
374
|
+
"itemSize": 4,
|
|
375
|
+
"defaultTrackValue": {
|
|
376
|
+
"itemSize": 4,
|
|
377
|
+
"data": [
|
|
378
|
+
1,
|
|
379
|
+
1,
|
|
380
|
+
1,
|
|
381
|
+
1
|
|
382
|
+
],
|
|
383
|
+
"positions": [
|
|
384
|
+
0
|
|
385
|
+
]
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
],
|
|
389
|
+
"preWarm": true,
|
|
390
|
+
"readDepth": true,
|
|
391
|
+
"softDepth": true,
|
|
392
|
+
"depthSort": true,
|
|
393
|
+
"velocityAlign": false,
|
|
394
|
+
"receiveLight": true,
|
|
395
|
+
"blendingMode": 0,
|
|
396
|
+
"layers": [
|
|
397
|
+
{
|
|
398
|
+
"imageURL": "data/textures/particle/smokeparticle.png",
|
|
399
|
+
"particleLife": {
|
|
400
|
+
"min": 3,
|
|
401
|
+
"max": 5
|
|
402
|
+
},
|
|
403
|
+
"particleSize": {
|
|
404
|
+
"min": 0.05,
|
|
405
|
+
"max": 0.1
|
|
406
|
+
},
|
|
407
|
+
"particleRotation": {
|
|
408
|
+
"min": 0,
|
|
409
|
+
"max": 0
|
|
410
|
+
},
|
|
411
|
+
"particleRotationSpeed": {
|
|
412
|
+
"min": 0,
|
|
413
|
+
"max": 0
|
|
414
|
+
},
|
|
415
|
+
"emissionShape": 1,
|
|
416
|
+
"emissionFrom": 1,
|
|
417
|
+
"emissionRate": 5000,
|
|
418
|
+
"emissionImmediate": 0,
|
|
419
|
+
"parameterTracks": [
|
|
420
|
+
{
|
|
421
|
+
"name": "color",
|
|
422
|
+
"track": {
|
|
423
|
+
"itemSize": 4,
|
|
424
|
+
"data": [
|
|
425
|
+
1,
|
|
426
|
+
1,
|
|
427
|
+
1,
|
|
428
|
+
0,
|
|
429
|
+
|
|
430
|
+
1,
|
|
431
|
+
1,
|
|
432
|
+
1,
|
|
433
|
+
0.7,
|
|
434
|
+
|
|
435
|
+
1,
|
|
436
|
+
1,
|
|
437
|
+
1,
|
|
438
|
+
0.7,
|
|
439
|
+
|
|
440
|
+
1,
|
|
441
|
+
1,
|
|
442
|
+
1,
|
|
443
|
+
0,
|
|
444
|
+
],
|
|
445
|
+
"positions": [
|
|
446
|
+
0,
|
|
447
|
+
0.2,
|
|
448
|
+
0.8,
|
|
449
|
+
1
|
|
450
|
+
]
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
"name": "scale",
|
|
455
|
+
"track": {
|
|
456
|
+
"itemSize": 1,
|
|
457
|
+
"data": [
|
|
458
|
+
1
|
|
459
|
+
],
|
|
460
|
+
"positions": [
|
|
461
|
+
0
|
|
462
|
+
]
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
],
|
|
466
|
+
"position": {
|
|
467
|
+
"x": 0,
|
|
468
|
+
"y": 0,
|
|
469
|
+
"z": 0
|
|
470
|
+
},
|
|
471
|
+
"scale": {
|
|
472
|
+
"x": 1,
|
|
473
|
+
"y": 1,
|
|
474
|
+
"z": 1
|
|
475
|
+
},
|
|
476
|
+
"particleVelocityDirection": {
|
|
477
|
+
"direction": {
|
|
478
|
+
"x": 0,
|
|
479
|
+
"y": 1,
|
|
480
|
+
"z": 0
|
|
481
|
+
},
|
|
482
|
+
"angle": 1.8
|
|
483
|
+
},
|
|
484
|
+
"particleSpeed": {
|
|
485
|
+
"min": 0.03,
|
|
486
|
+
"max": 0.2
|
|
487
|
+
},
|
|
488
|
+
"steps": [
|
|
489
|
+
{
|
|
490
|
+
"type": "FixedPhysics",
|
|
491
|
+
"parameters": []
|
|
492
|
+
}
|
|
493
|
+
]
|
|
494
|
+
}
|
|
495
|
+
]
|
|
496
|
+
}))
|
|
497
|
+
.add(Transform.fromJSON({
|
|
498
|
+
position: new Vector3(offset.x, offset.y + 7, offset.z),
|
|
499
|
+
scale: new Vector3(40, 14, 26)
|
|
500
|
+
}))
|
|
501
|
+
.build(ecd);
|
|
502
|
+
|
|
503
|
+
for (let i = 0; i < 100; i++) {
|
|
333
504
|
|
|
334
505
|
const builder = makeLight([
|
|
335
506
|
randomFloatBetween(random, -18, 18) + offset.x,
|
|
@@ -364,6 +535,370 @@ function setup_scene_0(engine, ecd) {
|
|
|
364
535
|
.build(ecd);
|
|
365
536
|
}
|
|
366
537
|
|
|
538
|
+
/**
|
|
539
|
+
* @param {Engine} engine
|
|
540
|
+
* @param {EntityComponentDataset} ecd
|
|
541
|
+
*/
|
|
542
|
+
function setup_scene_3(engine, ecd) {
|
|
543
|
+
|
|
544
|
+
const random = seededRandom(0);
|
|
545
|
+
//
|
|
546
|
+
// const light_key = new Light();
|
|
547
|
+
// light_key.intensity.set(0.1);
|
|
548
|
+
// light_key.type.set(LightType.DIRECTION);
|
|
549
|
+
// light_key.castShadow.set(true);
|
|
550
|
+
//
|
|
551
|
+
// const key_light_transform = new Transform();
|
|
552
|
+
// key_light_transform.position.set(10, 10, 0);
|
|
553
|
+
// key_light_transform.lookAt(new Vector3(0, 0, 0));
|
|
554
|
+
//
|
|
555
|
+
// new EntityBuilder()
|
|
556
|
+
// .add(light_key)
|
|
557
|
+
// .add(key_light_transform)
|
|
558
|
+
// .build(ecd);
|
|
559
|
+
|
|
560
|
+
const light_fill = new Light();
|
|
561
|
+
light_fill.intensity.set(0.03);
|
|
562
|
+
light_fill.type.set(LightType.AMBIENT);
|
|
563
|
+
light_fill.castShadow.set(false);
|
|
564
|
+
|
|
565
|
+
const fill_light_transform = new Transform();
|
|
566
|
+
fill_light_transform.position.set(40, 15, 30);
|
|
567
|
+
fill_light_transform.lookAt(new Vector3(30, 0, 20));
|
|
568
|
+
|
|
569
|
+
new EntityBuilder()
|
|
570
|
+
.add(light_fill)
|
|
571
|
+
.add(fill_light_transform)
|
|
572
|
+
.build(ecd);
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
const camera = CameraSystem.getFirstActiveCamera(ecd);
|
|
576
|
+
|
|
577
|
+
camera.component.fov.set(30);
|
|
578
|
+
camera.component.object.fov = 30;
|
|
579
|
+
|
|
580
|
+
// camera.component.autoClip = false;
|
|
581
|
+
// camera.component.object.near = 2;
|
|
582
|
+
// camera.component.object.far = 40;
|
|
583
|
+
|
|
584
|
+
EngineHarness.buildTerrain({
|
|
585
|
+
engine,
|
|
586
|
+
enableWater: false,
|
|
587
|
+
resolution: 4,
|
|
588
|
+
size: new Vector2(40, 40),
|
|
589
|
+
diffuse0: "data/textures/materials/terrain_township_set/1024/Grass_3.png"
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
const terrain = obtainTerrain(ecd, (terrain, entity) => {
|
|
593
|
+
|
|
594
|
+
const fow = new FogOfWar();
|
|
595
|
+
|
|
596
|
+
fow.scale.set(2);
|
|
597
|
+
fow.color.set(0.1, 0.1, 0.1, 1);
|
|
598
|
+
|
|
599
|
+
// ecd.addComponentToEntity(entity, fow);
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
console.log(terrain);
|
|
603
|
+
|
|
604
|
+
// terrain.overlay.size.set(50, 50);
|
|
605
|
+
// for (let i = 0; i < 50; i++) {
|
|
606
|
+
// for (let j = 0; j < 50; j++) {
|
|
607
|
+
//
|
|
608
|
+
// terrain.overlay.paintPoint(i, j, new Vector4(random(), random(), random(), 0.9));
|
|
609
|
+
// }
|
|
610
|
+
// }
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
*
|
|
614
|
+
* @type {TopDownCameraController|undefined}
|
|
615
|
+
*/
|
|
616
|
+
const camera_controller = ecd.getComponent(camera.entity, TopDownCameraController);
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
const offset = new Vector3(40, 0, 40);
|
|
620
|
+
|
|
621
|
+
camera_controller.fromJSON({
|
|
622
|
+
"target": offset,
|
|
623
|
+
"pitch": 0.7399999999999984,
|
|
624
|
+
"yaw": 2.283185307179597,
|
|
625
|
+
"roll": 0,
|
|
626
|
+
"distance": 37,
|
|
627
|
+
"distanceMin": 0,
|
|
628
|
+
"distanceMax": 1000
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
const volume_dim = new Vector3(15, 2, 15);
|
|
632
|
+
|
|
633
|
+
for (let i = 0; i < 0; i++) {
|
|
634
|
+
|
|
635
|
+
const builder = makeLight([
|
|
636
|
+
randomFloatBetween(random, -volume_dim.x / 2, volume_dim.x / 2) + offset.x,
|
|
637
|
+
randomFloatBetween(random, -volume_dim.y * 0.3, +volume_dim.y * 0.3) + offset.y,
|
|
638
|
+
randomFloatBetween(random, -volume_dim.z / 2, volume_dim.z / 2) + offset.z
|
|
639
|
+
],
|
|
640
|
+
randomFloatBetween(random, 10, 10),
|
|
641
|
+
`hsv(${random().toFixed(4)}, 1, 1)`,
|
|
642
|
+
5
|
|
643
|
+
);
|
|
644
|
+
|
|
645
|
+
const light = builder.getComponent(Light);
|
|
646
|
+
|
|
647
|
+
const b = new OrbitingBehavior();
|
|
648
|
+
|
|
649
|
+
const size = light.distance.getValue();
|
|
650
|
+
|
|
651
|
+
b.radius = randomFloatBetween(random, size, size * 3);
|
|
652
|
+
b.easing = 0;
|
|
653
|
+
b.rate = (random() < 0.5 ? 1 : -1) * randomFloatBetween(random, 2, 3) / b.radius;
|
|
654
|
+
|
|
655
|
+
const transform = builder.getComponent(Transform);
|
|
656
|
+
|
|
657
|
+
b.offset.copy(transform.position);
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
builder
|
|
661
|
+
.add(BehaviorComponent.fromOne(b))
|
|
662
|
+
// .add(BehaviorComponent.looping_function(()=>{
|
|
663
|
+
//
|
|
664
|
+
// }))
|
|
665
|
+
.build(ecd);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
new EntityBuilder()
|
|
669
|
+
.add(ParticleEmitter.fromJSON({
|
|
670
|
+
"parameters": [
|
|
671
|
+
{
|
|
672
|
+
"name": "scale",
|
|
673
|
+
"itemSize": 1,
|
|
674
|
+
"defaultTrackValue": {
|
|
675
|
+
"itemSize": 1,
|
|
676
|
+
"data": [
|
|
677
|
+
1
|
|
678
|
+
],
|
|
679
|
+
"positions": [
|
|
680
|
+
0
|
|
681
|
+
]
|
|
682
|
+
}
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
"name": "color",
|
|
686
|
+
"itemSize": 4,
|
|
687
|
+
"defaultTrackValue": {
|
|
688
|
+
"itemSize": 4,
|
|
689
|
+
"data": [
|
|
690
|
+
1,
|
|
691
|
+
1,
|
|
692
|
+
1,
|
|
693
|
+
1
|
|
694
|
+
],
|
|
695
|
+
"positions": [
|
|
696
|
+
0
|
|
697
|
+
]
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
],
|
|
701
|
+
"preWarm": true,
|
|
702
|
+
"readDepth": true,
|
|
703
|
+
"softDepth": true,
|
|
704
|
+
"depthSort": true,
|
|
705
|
+
"velocityAlign": false,
|
|
706
|
+
"receiveLight": true,
|
|
707
|
+
"blendingMode": 0,
|
|
708
|
+
"layers": [
|
|
709
|
+
{
|
|
710
|
+
"imageURL": "data/textures/particle/UETools/Cloud_04.png",
|
|
711
|
+
"particleLife": {
|
|
712
|
+
"min": 11,
|
|
713
|
+
"max": 11
|
|
714
|
+
},
|
|
715
|
+
"particleSize": {
|
|
716
|
+
"min": 0.05,
|
|
717
|
+
"max": 0.05
|
|
718
|
+
},
|
|
719
|
+
"particleRotation": {
|
|
720
|
+
"min": 0,
|
|
721
|
+
"max": 3.14
|
|
722
|
+
},
|
|
723
|
+
"particleRotationSpeed": {
|
|
724
|
+
"min": 0,
|
|
725
|
+
"max": 0
|
|
726
|
+
},
|
|
727
|
+
"emissionShape": 1,
|
|
728
|
+
"emissionFrom": 1,
|
|
729
|
+
"emissionRate": 1000,
|
|
730
|
+
"emissionImmediate": 0,
|
|
731
|
+
"parameterTracks": [
|
|
732
|
+
{
|
|
733
|
+
"name": "color",
|
|
734
|
+
"track": {
|
|
735
|
+
"itemSize": 4,
|
|
736
|
+
"data": [
|
|
737
|
+
1,
|
|
738
|
+
1,
|
|
739
|
+
1,
|
|
740
|
+
0.1,
|
|
741
|
+
|
|
742
|
+
1,
|
|
743
|
+
1,
|
|
744
|
+
1,
|
|
745
|
+
0.7,
|
|
746
|
+
|
|
747
|
+
1,
|
|
748
|
+
1,
|
|
749
|
+
1,
|
|
750
|
+
0.7,
|
|
751
|
+
|
|
752
|
+
1,
|
|
753
|
+
1,
|
|
754
|
+
1,
|
|
755
|
+
0,
|
|
756
|
+
],
|
|
757
|
+
"positions": [
|
|
758
|
+
0,
|
|
759
|
+
0.1,
|
|
760
|
+
0.8,
|
|
761
|
+
1
|
|
762
|
+
]
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
"name": "scale",
|
|
767
|
+
"track": {
|
|
768
|
+
"itemSize": 1,
|
|
769
|
+
"data": [
|
|
770
|
+
1.5,
|
|
771
|
+
1,
|
|
772
|
+
1,
|
|
773
|
+
0.2
|
|
774
|
+
],
|
|
775
|
+
"positions": [
|
|
776
|
+
0,
|
|
777
|
+
0.1,
|
|
778
|
+
0.8,
|
|
779
|
+
1
|
|
780
|
+
]
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
],
|
|
784
|
+
"position": {
|
|
785
|
+
"x": 0,
|
|
786
|
+
"y": 2.3,
|
|
787
|
+
"z": 0
|
|
788
|
+
},
|
|
789
|
+
"scale": {
|
|
790
|
+
"x": 1,
|
|
791
|
+
"y": 0.5,
|
|
792
|
+
"z": 1
|
|
793
|
+
},
|
|
794
|
+
"particleVelocityDirection": {
|
|
795
|
+
"direction": {
|
|
796
|
+
"x": 0,
|
|
797
|
+
"y": -1,
|
|
798
|
+
"z": 0
|
|
799
|
+
},
|
|
800
|
+
"angle": 0
|
|
801
|
+
},
|
|
802
|
+
"particleSpeed": {
|
|
803
|
+
"min": 0.2,
|
|
804
|
+
"max": 0.7
|
|
805
|
+
},
|
|
806
|
+
"steps": [
|
|
807
|
+
{
|
|
808
|
+
"type": "FixedPhysics",
|
|
809
|
+
"parameters": []
|
|
810
|
+
}
|
|
811
|
+
]
|
|
812
|
+
}
|
|
813
|
+
]
|
|
814
|
+
}))
|
|
815
|
+
.add(Transform.fromJSON({
|
|
816
|
+
position: new Vector3(offset.x, offset.y + volume_dim.y / 2, offset.z),
|
|
817
|
+
scale: new Vector3(volume_dim.x, volume_dim.y, volume_dim.z)
|
|
818
|
+
}))
|
|
819
|
+
.build(ecd);
|
|
820
|
+
|
|
821
|
+
const light_grid_size = 6;
|
|
822
|
+
for (let i = 0; i < light_grid_size; i++) {
|
|
823
|
+
for (let j = 0; j < light_grid_size; j++) {
|
|
824
|
+
|
|
825
|
+
const builder = makeLight([
|
|
826
|
+
((i / (light_grid_size - 1)) - 0.5) * volume_dim.x + offset.x,
|
|
827
|
+
volume_dim.y * 0.5 + offset.y,
|
|
828
|
+
((j / (light_grid_size - 1)) - 0.5) * volume_dim.z + offset.z
|
|
829
|
+
],
|
|
830
|
+
3,
|
|
831
|
+
`hsv(${random().toFixed(4)}, 0.8, 1)`,
|
|
832
|
+
10
|
|
833
|
+
);
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
builder
|
|
837
|
+
.build(ecd);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
new EntityBuilder()
|
|
843
|
+
.add(Transform.fromJSON({
|
|
844
|
+
position: offset,
|
|
845
|
+
scale: {
|
|
846
|
+
x: 4.5,
|
|
847
|
+
y: 4.5,
|
|
848
|
+
z: 4.5
|
|
849
|
+
}
|
|
850
|
+
}))
|
|
851
|
+
.add(FogOfWarRevealer.fromJSON({
|
|
852
|
+
radius: 5
|
|
853
|
+
}))
|
|
854
|
+
.add(new Team(0))
|
|
855
|
+
.add(Mesh.fromJSON({
|
|
856
|
+
url: 'data/models/LowPolyTownshipSet/Town_Hall/model.gltf',
|
|
857
|
+
castShadow: true,
|
|
858
|
+
receiveShadow: true
|
|
859
|
+
}))
|
|
860
|
+
.build(ecd);
|
|
861
|
+
|
|
862
|
+
const tree_grid_size = 5;
|
|
863
|
+
|
|
864
|
+
for (let i = 0; i < tree_grid_size; i++) {
|
|
865
|
+
for (let j = 0; j < tree_grid_size; j++) {
|
|
866
|
+
|
|
867
|
+
// const p = new Vector3(
|
|
868
|
+
// offset.x + ((i / (tree_grid_size - 1)) - 0.5) * (volume_dim.x * 0.9),
|
|
869
|
+
// offset.y,
|
|
870
|
+
// offset.z + ((j / (tree_grid_size - 1)) - 0.5) * (volume_dim.z * 0.9)
|
|
871
|
+
// );
|
|
872
|
+
|
|
873
|
+
const p = new Vector3(
|
|
874
|
+
offset.x + randomFloatBetween(random, -volume_dim.x * 0.5, volume_dim.x * 0.5),
|
|
875
|
+
offset.y,
|
|
876
|
+
offset.x + randomFloatBetween(random, -volume_dim.z * 0.5, volume_dim.z * 0.5),
|
|
877
|
+
);
|
|
878
|
+
|
|
879
|
+
if (p.distanceTo(offset) < 3) {
|
|
880
|
+
continue;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
new EntityBuilder()
|
|
884
|
+
.add(Transform.fromJSON({
|
|
885
|
+
position: p,
|
|
886
|
+
scale: {
|
|
887
|
+
x: 1,
|
|
888
|
+
y: 1,
|
|
889
|
+
z: 1
|
|
890
|
+
}
|
|
891
|
+
}))
|
|
892
|
+
.add(Mesh.fromJSON({
|
|
893
|
+
url: 'data/models/LowPolyTownshipSet/Tree_1/Tree_1.gltf',
|
|
894
|
+
castShadow: true,
|
|
895
|
+
receiveShadow: true
|
|
896
|
+
}))
|
|
897
|
+
.build(ecd);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
|
|
367
902
|
/**
|
|
368
903
|
* @param {Engine} engine
|
|
369
904
|
* @param {EntityComponentDataset} ecd
|
|
@@ -594,10 +1129,10 @@ function main(engine) {
|
|
|
594
1129
|
|
|
595
1130
|
engine.graphics.renderer.setClearColor('rgba(99,99,99,1)');
|
|
596
1131
|
|
|
597
|
-
|
|
1132
|
+
setup_scene_3(engine, ecd);
|
|
598
1133
|
// setup_scene_1(engine, ecd);
|
|
599
1134
|
|
|
600
|
-
engine.graphics.loadEnvironmentMap(buildCubeURLs('data/textures/cubemaps/hip_miramar/32/', '.png'));
|
|
1135
|
+
// engine.graphics.loadEnvironmentMap(buildCubeURLs('data/textures/cubemaps/hip_miramar/32/', '.png'));
|
|
601
1136
|
|
|
602
1137
|
/**
|
|
603
1138
|
*
|
|
@@ -605,27 +1140,27 @@ function main(engine) {
|
|
|
605
1140
|
*/
|
|
606
1141
|
const plugin = engine.plugins.getPlugin(ForwardPlusRenderingPlugin);
|
|
607
1142
|
const lm = plugin.getLightManager();
|
|
608
|
-
lm.setTileMapResolution(
|
|
1143
|
+
lm.setTileMapResolution(14, 8, 14);
|
|
609
1144
|
|
|
610
1145
|
console.log(lm);
|
|
611
1146
|
window.lm = lm;
|
|
612
1147
|
|
|
613
|
-
const v = new View();
|
|
614
|
-
const clusterWidget = buildLightClusterWidget(lm, engine.graphics.camera);
|
|
615
|
-
v.el = clusterWidget.domElement;
|
|
616
|
-
v.size.setSilent(256, 256);
|
|
617
|
-
v.css({
|
|
618
|
-
|
|
619
|
-
});
|
|
620
|
-
|
|
621
|
-
new EntityBuilder()
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
1148
|
+
// const v = new View();
|
|
1149
|
+
// const clusterWidget = buildLightClusterWidget(lm, engine.graphics.camera);
|
|
1150
|
+
// v.el = clusterWidget.domElement;
|
|
1151
|
+
// v.size.setSilent(256, 256);
|
|
1152
|
+
// v.css({
|
|
1153
|
+
// pointerEvents: 'auto'
|
|
1154
|
+
// });
|
|
1155
|
+
|
|
1156
|
+
// new EntityBuilder()
|
|
1157
|
+
// .add(ViewportPosition.fromJSON({
|
|
1158
|
+
// anchor: Vector2.one,
|
|
1159
|
+
// offset: new Vector2(-0, -0),
|
|
1160
|
+
// position: new Vector2(1, 1)
|
|
1161
|
+
// }))
|
|
1162
|
+
// .add(GUIElement.fromView(v))
|
|
1163
|
+
// .build(ecd);
|
|
629
1164
|
|
|
630
1165
|
engine.graphics.on.preRender.add(
|
|
631
1166
|
/**
|
|
@@ -657,7 +1192,7 @@ function main(engine) {
|
|
|
657
1192
|
// camera.updateProjectionMatrix();
|
|
658
1193
|
// camera.updateMatrixWorld(true);
|
|
659
1194
|
|
|
660
|
-
clusterWidget.update();
|
|
1195
|
+
// clusterWidget.update();
|
|
661
1196
|
|
|
662
1197
|
});
|
|
663
1198
|
|