@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
package/{engine/graphics/render/forward_plus/materials → core/primitives/strings}/insert_after.js
RENAMED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* @param {string} source
|
|
4
4
|
* @param {string} term
|
|
5
5
|
* @param {string} extra
|
|
6
|
+
* @returns {string}
|
|
6
7
|
*/
|
|
7
8
|
export function insert_after(source, term, extra) {
|
|
8
9
|
const i = source.indexOf(term);
|
|
@@ -16,3 +17,5 @@ export function insert_after(source, term, extra) {
|
|
|
16
17
|
|
|
17
18
|
return source.slice(0, end) + extra + source.slice(end);
|
|
18
19
|
}
|
|
20
|
+
|
|
21
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {string} source
|
|
4
|
+
* @param {string} insert_term
|
|
5
|
+
* @param {string} replace_term
|
|
6
|
+
* @param {string} value
|
|
7
|
+
* @returns {string}
|
|
8
|
+
*/
|
|
9
|
+
export function insert_after_or_replace(source, insert_term, replace_term, value) {
|
|
10
|
+
const insert_term_index = source.indexOf(insert_term);
|
|
11
|
+
|
|
12
|
+
if (insert_term_index !== -1) {
|
|
13
|
+
const end = insert_term_index + insert_term.length;
|
|
14
|
+
return source.slice(0, end) + value + source.slice(end);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const replace_term_index = source.indexOf(replace_term);
|
|
18
|
+
|
|
19
|
+
if (replace_term_index === -1) {
|
|
20
|
+
// not found
|
|
21
|
+
console.warn(`Neither insert term '${insert_term}', nor replacement term '${replace_term}' were found in the source`, source, value);
|
|
22
|
+
return source;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
return source.slice(0, replace_term_index) + value + source.slice(replace_term_index + replace_term.length);
|
|
27
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BufferAttribute, BufferGeometry, Float32BufferAttribute } from "three";
|
|
2
|
+
|
|
3
|
+
export function makeHelperBoxGeometry(sx = 1, sy = 1, sz = 1) {
|
|
4
|
+
|
|
5
|
+
const geometry = new BufferGeometry();
|
|
6
|
+
|
|
7
|
+
const dx = sx / 2;
|
|
8
|
+
const dy = sy / 2;
|
|
9
|
+
const dz = sz / 2;
|
|
10
|
+
|
|
11
|
+
const vertices = new Float32Array([
|
|
12
|
+
-dx, -dy, -dz,
|
|
13
|
+
dx, -dy, -dz,
|
|
14
|
+
dx, dy, -dz,
|
|
15
|
+
-dx, dy, -dz,
|
|
16
|
+
|
|
17
|
+
-dx, dy, dz,
|
|
18
|
+
dx, dy, dz,
|
|
19
|
+
dx, -dy, dz,
|
|
20
|
+
-dx, -dy, dz
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));
|
|
24
|
+
|
|
25
|
+
geometry.setIndex(new BufferAttribute(new Uint8Array([
|
|
26
|
+
0, 1,
|
|
27
|
+
1, 2,
|
|
28
|
+
2, 3,
|
|
29
|
+
3, 0,
|
|
30
|
+
|
|
31
|
+
4, 5,
|
|
32
|
+
5, 6,
|
|
33
|
+
6, 7,
|
|
34
|
+
7, 4,
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
0, 7,
|
|
38
|
+
1, 6,
|
|
39
|
+
2, 5,
|
|
40
|
+
3, 4
|
|
41
|
+
]), 1, false));
|
|
42
|
+
|
|
43
|
+
return geometry;
|
|
44
|
+
}
|
|
@@ -38,7 +38,7 @@ import { HeadsUpDisplayController } from "./components/HeadsUpDisplayController.
|
|
|
38
38
|
import { BlackboardController } from "./components/BlackboardController.js";
|
|
39
39
|
import { GridObstacleController } from "./components/GridObstacleController.js";
|
|
40
40
|
import { AttachmentSocketsController } from "./components/sockets/AttachmentSocketsController.js";
|
|
41
|
-
import {
|
|
41
|
+
import { ParticleEmitterSystem } from "../../../engine/graphics/particles/ecs/ParticleEmitterSystem.js";
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
*
|
|
@@ -82,7 +82,7 @@ function prepareComponentFactory(factory, editor) {
|
|
|
82
82
|
.register('ParticleEmitter', () => {
|
|
83
83
|
const em = editor.engine.entityManager;
|
|
84
84
|
|
|
85
|
-
const particleEmitterSystem = em.getSystem(
|
|
85
|
+
const particleEmitterSystem = em.getSystem(ParticleEmitterSystem);
|
|
86
86
|
|
|
87
87
|
return new ParticleEmitterController(particleEmitterSystem);
|
|
88
88
|
})
|
|
@@ -24,7 +24,7 @@ export function enumNameByValue(value, enumerable) {
|
|
|
24
24
|
/**
|
|
25
25
|
*
|
|
26
26
|
* @param {ParticleEmitter} emitter
|
|
27
|
-
* @param {
|
|
27
|
+
* @param {ParticleEmitterSystem} system
|
|
28
28
|
* @param {function} op
|
|
29
29
|
* @param {*} [arg0]
|
|
30
30
|
*/
|
|
@@ -61,7 +61,7 @@ function applyEmitterChanges(emitter, system, op, arg0) {
|
|
|
61
61
|
export class ParticleEmitterController extends EmptyView {
|
|
62
62
|
/**
|
|
63
63
|
*
|
|
64
|
-
* @param {
|
|
64
|
+
* @param {ParticleEmitterSystem} particleEmitterSystem
|
|
65
65
|
* @constructor
|
|
66
66
|
*/
|
|
67
67
|
constructor(particleEmitterSystem) {
|
package/engine/EngineHarness.js
CHANGED
|
@@ -7,7 +7,7 @@ import { removeComponentsExcept } from "../ecs/util/removeComponentsExcept.js";
|
|
|
7
7
|
import { createSound, createTimer } from "../EntityCreator.js";
|
|
8
8
|
import Mesh from "../graphics/ecs/mesh/Mesh.js";
|
|
9
9
|
import Trail2D, { Trail2DFlags } from "../graphics/ecs/trail2d/Trail2D.js";
|
|
10
|
-
import {
|
|
10
|
+
import { ParticleEmitterSystem } from "../graphics/particles/ecs/ParticleEmitterSystem.js";
|
|
11
11
|
import { ParticleEmitter } from "../graphics/particles/particular/engine/emitter/ParticleEmitter.js";
|
|
12
12
|
import { ParticleEmitterFlag } from "../graphics/particles/particular/engine/emitter/ParticleEmitterFlag.js";
|
|
13
13
|
import { distributeParticlesOnObject3D } from "../graphics/particles/particular/engine/utils/distributeParticlesOnObject3D.js";
|
|
@@ -137,9 +137,9 @@ export function removeEntityWithMeshParticlesEffect(
|
|
|
137
137
|
|
|
138
138
|
/**
|
|
139
139
|
*
|
|
140
|
-
* @type {
|
|
140
|
+
* @type {ParticleEmitterSystem}
|
|
141
141
|
*/
|
|
142
|
-
const sPE = entityManager.getSystem(
|
|
142
|
+
const sPE = entityManager.getSystem(ParticleEmitterSystem);
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
*
|
|
@@ -214,9 +214,9 @@ export function removeEntityGenericEffect(
|
|
|
214
214
|
|
|
215
215
|
/**
|
|
216
216
|
*
|
|
217
|
-
* @type {
|
|
217
|
+
* @type {ParticleEmitterSystem}
|
|
218
218
|
*/
|
|
219
|
-
const sPE = engine.entityManager.getSystem(
|
|
219
|
+
const sPE = engine.entityManager.getSystem(ParticleEmitterSystem);
|
|
220
220
|
|
|
221
221
|
/**
|
|
222
222
|
*
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Signal from "../../core/events/signal/Signal.js";
|
|
2
2
|
import { assert } from "../../core/assert.js";
|
|
3
3
|
import { EventType } from "./EntityManager.js";
|
|
4
|
+
import { isDefined } from "../../core/process/matcher/Matchers.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
*
|
|
@@ -63,7 +64,6 @@ class EntityBuilder {
|
|
|
63
64
|
this.on = {
|
|
64
65
|
built: new Signal()
|
|
65
66
|
};
|
|
66
|
-
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
@@ -238,10 +238,10 @@ class EntityBuilder {
|
|
|
238
238
|
this.dataset.addEntityEventListener(this.entity, eventName, listener, context);
|
|
239
239
|
} else {
|
|
240
240
|
this.deferredListeners.push({
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
241
|
+
name: eventName,
|
|
242
|
+
listener: listener,
|
|
243
|
+
context
|
|
244
|
+
});
|
|
245
245
|
}
|
|
246
246
|
return this;
|
|
247
247
|
}
|
|
@@ -356,6 +356,26 @@ class EntityBuilder {
|
|
|
356
356
|
this.on.built.send2(entity, dataset);
|
|
357
357
|
return entity;
|
|
358
358
|
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
*
|
|
362
|
+
* @param {number} entity
|
|
363
|
+
* @param {EntityComponentDataset} dataset
|
|
364
|
+
* @returns {EntityBuilder}
|
|
365
|
+
*/
|
|
366
|
+
static readFromDataset(entity, dataset) {
|
|
367
|
+
const r = new EntityBuilder();
|
|
368
|
+
|
|
369
|
+
dataset.getAllComponents(entity)
|
|
370
|
+
.filter(isDefined)
|
|
371
|
+
.forEach(r.add, r);
|
|
372
|
+
|
|
373
|
+
r.setFlag(EntityBuilderFlags.Built);
|
|
374
|
+
r.entity = entity;
|
|
375
|
+
r.dataset = dataset;
|
|
376
|
+
|
|
377
|
+
return r;
|
|
378
|
+
}
|
|
359
379
|
}
|
|
360
380
|
|
|
361
381
|
/**
|
|
@@ -265,6 +265,8 @@ export class AttachmentSystem extends System {
|
|
|
265
265
|
//update iterator
|
|
266
266
|
this.waiting.splice(i, 1);
|
|
267
267
|
|
|
268
|
+
binding.link();
|
|
269
|
+
|
|
268
270
|
i--;
|
|
269
271
|
numRecords--;
|
|
270
272
|
}
|
|
@@ -305,6 +307,8 @@ export class AttachmentSystem extends System {
|
|
|
305
307
|
parentBindings.splice(i, 1);
|
|
306
308
|
}
|
|
307
309
|
|
|
310
|
+
attachmentBinding.unlink();
|
|
311
|
+
|
|
308
312
|
break;
|
|
309
313
|
}
|
|
310
314
|
}
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import Vector3 from "../../../core/geom/Vector3.js";
|
|
2
|
-
import { Matrix4, Quaternion as ThreeQuaternion } from "three";
|
|
3
1
|
import { AttachmentBinding } from "./AttachmentBinding.js";
|
|
4
|
-
import
|
|
2
|
+
import { mat4 } from "gl-matrix";
|
|
5
3
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const pScale = new Vector3();
|
|
11
|
-
const pPosition = new Vector3();
|
|
12
|
-
|
|
13
|
-
const attachmentM4 = new Matrix4();
|
|
14
|
-
|
|
15
|
-
const parentM4 = new Matrix4();
|
|
4
|
+
const scratch_m4_0 = new Float32Array(16);
|
|
5
|
+
const scratch_m4_1 = new Float32Array(16);
|
|
6
|
+
const scratch_m4_2 = new Float32Array(16);
|
|
16
7
|
|
|
17
8
|
export class TransformAttachmentBinding extends AttachmentBinding {
|
|
18
9
|
constructor() {
|
|
@@ -24,40 +15,19 @@ export class TransformAttachmentBinding extends AttachmentBinding {
|
|
|
24
15
|
* TODO make use of Transform.multiplyTransforms for better readability and performance
|
|
25
16
|
*/
|
|
26
17
|
update() {
|
|
27
|
-
const socketTransform = this.socket.transform;
|
|
28
|
-
|
|
29
|
-
threeQuaternion.copy(socketTransform.rotation);
|
|
30
|
-
|
|
31
|
-
socketM4.compose(socketTransform.position, threeQuaternion, socketTransform.scale);
|
|
32
|
-
|
|
33
|
-
const parentTransform = this.parentTransform;
|
|
34
|
-
|
|
35
|
-
threeQuaternion.copy(parentTransform.rotation);
|
|
36
|
-
|
|
37
|
-
parentM4.compose(parentTransform.position, threeQuaternion, parentTransform.scale);
|
|
38
|
-
|
|
39
|
-
const attachment = this.attachment;
|
|
40
|
-
const aT = attachment.transform;
|
|
41
|
-
|
|
42
|
-
threeQuaternion.copy(aT.rotation);
|
|
43
|
-
|
|
44
|
-
attachmentM4.compose(aT.position, threeQuaternion, aT.scale);
|
|
45
|
-
|
|
46
|
-
socketM4.multiplyMatrices(parentM4, socketM4);
|
|
47
|
-
socketM4.multiply(attachmentM4);
|
|
48
|
-
socketM4.decompose(pPosition, threeQuaternion, pScale);
|
|
49
|
-
|
|
50
|
-
const t = this.attachedTransform;
|
|
51
18
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
t.rotation.copy(threeQuaternion);
|
|
56
|
-
}
|
|
19
|
+
this.socket.transform.toMatrix4(scratch_m4_0);
|
|
20
|
+
this.parentTransform.toMatrix4(scratch_m4_1);
|
|
21
|
+
this.attachment.transform.toMatrix4(scratch_m4_2);
|
|
57
22
|
|
|
58
|
-
|
|
23
|
+
mat4.multiply(
|
|
24
|
+
scratch_m4_0, scratch_m4_1, scratch_m4_0
|
|
25
|
+
);
|
|
26
|
+
mat4.multiply(
|
|
27
|
+
scratch_m4_0, scratch_m4_0, scratch_m4_2
|
|
28
|
+
);
|
|
59
29
|
|
|
60
|
-
|
|
30
|
+
this.attachedTransform.fromMatrix4(scratch_m4_0);
|
|
61
31
|
}
|
|
62
32
|
|
|
63
33
|
link() {
|
|
@@ -81,6 +81,8 @@ export class Tag {
|
|
|
81
81
|
* @returns {boolean}
|
|
82
82
|
*/
|
|
83
83
|
add(value) {
|
|
84
|
+
assert.isString(value, 'value');
|
|
85
|
+
|
|
84
86
|
if (this.contains(value)) {
|
|
85
87
|
return false;
|
|
86
88
|
}
|
|
@@ -117,6 +119,8 @@ export class Tag {
|
|
|
117
119
|
* @returns {boolean}
|
|
118
120
|
*/
|
|
119
121
|
contains(value) {
|
|
122
|
+
assert.isString(value, 'value');
|
|
123
|
+
|
|
120
124
|
return this.values.indexOf(value) !== -1;
|
|
121
125
|
}
|
|
122
126
|
|
|
@@ -125,16 +129,20 @@ export class Tag {
|
|
|
125
129
|
* @param {string[]} values
|
|
126
130
|
*/
|
|
127
131
|
containsAll(values) {
|
|
128
|
-
|
|
132
|
+
assert.isArray(values, 'values');
|
|
133
|
+
|
|
134
|
+
const search_value_count = values.length;
|
|
135
|
+
|
|
136
|
+
const these_values = this.values;
|
|
137
|
+
const these_values_count = these_values.length;
|
|
129
138
|
|
|
130
|
-
|
|
131
|
-
const tagCount = values1.length;
|
|
139
|
+
let i = 0, j = 0;
|
|
132
140
|
|
|
133
|
-
main: for (
|
|
141
|
+
main: for (; i < search_value_count; i++) {
|
|
134
142
|
const v = values[i];
|
|
135
143
|
|
|
136
|
-
for (
|
|
137
|
-
const tag =
|
|
144
|
+
for (j = 0; j < these_values_count; j++) {
|
|
145
|
+
const tag = these_values[j];
|
|
138
146
|
|
|
139
147
|
if (tag === v) {
|
|
140
148
|
continue main;
|
|
@@ -287,6 +295,19 @@ export class Tag {
|
|
|
287
295
|
return result;
|
|
288
296
|
}
|
|
289
297
|
|
|
298
|
+
/**
|
|
299
|
+
*
|
|
300
|
+
* @param {string} tag
|
|
301
|
+
* @returns {Tag}
|
|
302
|
+
*/
|
|
303
|
+
static fromOne(tag) {
|
|
304
|
+
const r = new Tag();
|
|
305
|
+
|
|
306
|
+
r.add(tag);
|
|
307
|
+
|
|
308
|
+
return r;
|
|
309
|
+
}
|
|
310
|
+
|
|
290
311
|
|
|
291
312
|
/**
|
|
292
313
|
*
|
|
@@ -12,6 +12,7 @@ import { BlendingType } from "../../graphics/texture/sampler/BlendingType.js";
|
|
|
12
12
|
import { FogOfWarRenderer } from "./shader/FogOfWarRenderer.js";
|
|
13
13
|
import { StandardFrameBuffers } from "../../graphics/StandardFrameBuffers.js";
|
|
14
14
|
import { CompositLayer } from "../../graphics/composit/CompositLayer.js";
|
|
15
|
+
import { CompositingStages } from "../../graphics/composit/CompositingStages.js";
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
const frustum = new Frustum();
|
|
@@ -133,6 +134,7 @@ export class FogOfWarSystem extends System {
|
|
|
133
134
|
|
|
134
135
|
const compositerLayer = graphics.layerComposer.createLayer({}, BlendingType.Normal);
|
|
135
136
|
compositerLayer.name = 'Fog of War';
|
|
137
|
+
compositerLayer.stage = CompositingStages.POST_TRANSPARENT;
|
|
136
138
|
|
|
137
139
|
// Fog of war should be drawn last typically, over everything else, so we set order to a large number
|
|
138
140
|
compositerLayer.order = 1000;
|
|
@@ -144,7 +144,9 @@ class HeadsUpDisplaySystem extends System {
|
|
|
144
144
|
up.set(worldPositionX, worldPositionY + 1, worldPositionZ, 1);
|
|
145
145
|
up.threeApplyMatrix4(projectionMatrix);
|
|
146
146
|
|
|
147
|
+
// compute perspective divide
|
|
147
148
|
const d = 1 / Math.abs(up.w);
|
|
149
|
+
|
|
148
150
|
up.x *= d;
|
|
149
151
|
up.y *= d;
|
|
150
152
|
up.z *= d;
|
|
@@ -13,6 +13,23 @@ class TagSystem extends System {
|
|
|
13
13
|
|
|
14
14
|
this.entityManager = null;
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param {string} tag
|
|
20
|
+
* @param {EntityComponentDataset} ecd
|
|
21
|
+
* @returns {number[]}
|
|
22
|
+
*/
|
|
23
|
+
static find_entities_with_tag(tag, ecd) {
|
|
24
|
+
const r = [];
|
|
25
|
+
ecd.traverseComponents(Tag, (t, e) => {
|
|
26
|
+
if (t.contains(tag)) {
|
|
27
|
+
r.push(e);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return r;
|
|
32
|
+
}
|
|
16
33
|
}
|
|
17
34
|
|
|
18
35
|
|
|
@@ -5,14 +5,13 @@
|
|
|
5
5
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
6
6
|
import Quaternion from "../../../core/geom/Quaternion.js";
|
|
7
7
|
import { Matrix4 } from "../../../core/geom/Matrix4.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { compose_matrix4_array } from "../../graphics/util/composeMatrix4.js";
|
|
9
|
+
import { decompose_matrix_4_array } from "../../graphics/util/decompose_matrix_4_array.js";
|
|
10
10
|
|
|
11
11
|
const delta = new Vector3();
|
|
12
12
|
|
|
13
13
|
const m4_0 = new Matrix4();
|
|
14
14
|
const m4_1 = new Matrix4();
|
|
15
|
-
const threeQuaternion = new ThreeQuaternion();
|
|
16
15
|
|
|
17
16
|
export class Transform {
|
|
18
17
|
/**
|
|
@@ -166,9 +165,15 @@ export class Transform {
|
|
|
166
165
|
* @param {Matrix4} matrix
|
|
167
166
|
*/
|
|
168
167
|
fromThreeMatrix4(matrix) {
|
|
169
|
-
|
|
168
|
+
this.fromMatrix4(matrix.elements);
|
|
169
|
+
}
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
/**
|
|
172
|
+
*
|
|
173
|
+
* @param {mat4|number[]|Float32Array} m
|
|
174
|
+
*/
|
|
175
|
+
fromMatrix4(m) {
|
|
176
|
+
decompose_matrix_4_array(m, this.position, this.rotation, this.scale);
|
|
172
177
|
}
|
|
173
178
|
|
|
174
179
|
/**
|
|
@@ -176,7 +181,15 @@ export class Transform {
|
|
|
176
181
|
* @param {Matrix4} matrix
|
|
177
182
|
*/
|
|
178
183
|
toThreeMatrix(matrix) {
|
|
179
|
-
|
|
184
|
+
this.toMatrix4(matrix.elements);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
*
|
|
189
|
+
* @param {number[]|Float32Array} result
|
|
190
|
+
*/
|
|
191
|
+
toMatrix4(result) {
|
|
192
|
+
compose_matrix4_array(result, this.position, this.rotation, this.scale);
|
|
180
193
|
}
|
|
181
194
|
}
|
|
182
195
|
|
|
@@ -40,6 +40,7 @@ import { ShadowMapRenderer } from "./shadows/ShadowMapRenderer.js";
|
|
|
40
40
|
import { CameraViewManager } from "./render/view/CameraViewManager.js";
|
|
41
41
|
import { StandardFrameBuffers } from "./StandardFrameBuffers.js";
|
|
42
42
|
import { load_environment_map } from "./texture/cubemap/load_environment_map.js";
|
|
43
|
+
import { CompositingStages } from "./composit/CompositingStages.js";
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
46
|
*
|
|
@@ -96,7 +97,13 @@ function GraphicsEngine(camera, entityManger) {
|
|
|
96
97
|
preRender: new Signal(),
|
|
97
98
|
postRender: new Signal(),
|
|
98
99
|
|
|
100
|
+
/**
|
|
101
|
+
* @deprecated
|
|
102
|
+
*/
|
|
99
103
|
preComposite: new Signal(),
|
|
104
|
+
/**
|
|
105
|
+
* @deprecated
|
|
106
|
+
*/
|
|
100
107
|
postComposite: new Signal(),
|
|
101
108
|
|
|
102
109
|
buffersRendered: new Signal(),
|
|
@@ -370,7 +377,7 @@ GraphicsEngine.prototype.start = function () {
|
|
|
370
377
|
const domElement = this.domElement = webGLRenderer.domElement;
|
|
371
378
|
//disable selection
|
|
372
379
|
const style = domElement.style;
|
|
373
|
-
domElement.classList.add("
|
|
380
|
+
domElement.classList.add("graphics-engine-render-canvas");
|
|
374
381
|
style.userSelect = style.webkitUserSelect = style.mozUserSelect = "none";
|
|
375
382
|
// see : https://www.w3.org/TR/pointerevents/#the-touch-action-css-property
|
|
376
383
|
style.touchAction = "none";
|
|
@@ -628,16 +635,14 @@ GraphicsEngine.prototype.render = function (renderTarget) {
|
|
|
628
635
|
//do the opaque pass
|
|
629
636
|
this.renderOpaque();
|
|
630
637
|
|
|
638
|
+
this.layerComposer.composite(renderer, CompositingStages.POST_OPAQUE);
|
|
639
|
+
|
|
631
640
|
this.on.buffersRendered.send3(renderer, camera, scene);
|
|
632
641
|
|
|
633
642
|
// transparent pass
|
|
634
643
|
this.renderTransparent();
|
|
635
644
|
|
|
636
|
-
this.
|
|
637
|
-
|
|
638
|
-
this.layerComposer.composite(renderer);
|
|
639
|
-
|
|
640
|
-
this.on.postComposite.send3(renderer, camera, scene);
|
|
645
|
+
this.layerComposer.composite(renderer, CompositingStages.POST_TRANSPARENT);
|
|
641
646
|
|
|
642
647
|
|
|
643
648
|
//dispatch post-render event
|
|
@@ -5,6 +5,7 @@ import { blendingType2three } from "../texture/sampler/blendingType2Three.js";
|
|
|
5
5
|
import { ScreenSpaceQuadShader } from "../shaders/ScreenSpaceQuadShader.js";
|
|
6
6
|
import { BlendingType } from "../texture/sampler/BlendingType.js";
|
|
7
7
|
import { FULL_SCREEN_TRIANGLE_GEOMETRY } from "../geometry/FULL_SCREEN_TRIANGLE_GEOMETRY.js";
|
|
8
|
+
import Signal from "../../../core/events/signal/Signal.js";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
*
|
|
@@ -29,11 +30,15 @@ function assignMaterialBlending(material, blending) {
|
|
|
29
30
|
export class CompositLayer {
|
|
30
31
|
/**
|
|
31
32
|
*
|
|
32
|
-
* @param {WebGLRenderTarget} renderTarget
|
|
33
|
+
* @param {THREE.WebGLRenderTarget} renderTarget
|
|
33
34
|
* @param {BlendingType} blending
|
|
34
35
|
* @param {number} renderTargetScale
|
|
35
36
|
*/
|
|
36
|
-
constructor({
|
|
37
|
+
constructor({
|
|
38
|
+
renderTarget,
|
|
39
|
+
blending,
|
|
40
|
+
renderTargetScale = 1
|
|
41
|
+
}) {
|
|
37
42
|
/**
|
|
38
43
|
* Human-readable name, useful for debugging
|
|
39
44
|
* @type {string}
|
|
@@ -57,9 +62,13 @@ export class CompositLayer {
|
|
|
57
62
|
*/
|
|
58
63
|
this.renderTargetScale = renderTargetScale;
|
|
59
64
|
|
|
60
|
-
|
|
65
|
+
this.object = new Mesh(FULL_SCREEN_TRIANGLE_GEOMETRY, this.buildMaterial());
|
|
61
66
|
|
|
62
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Which compositing stage this layer belongs to, stages are rendered independently
|
|
69
|
+
* @type {number}
|
|
70
|
+
*/
|
|
71
|
+
this.stage = 0;
|
|
63
72
|
|
|
64
73
|
this.size = new Vector2();
|
|
65
74
|
|
|
@@ -74,6 +83,10 @@ export class CompositLayer {
|
|
|
74
83
|
* @type {number}
|
|
75
84
|
*/
|
|
76
85
|
this.__order = 0;
|
|
86
|
+
|
|
87
|
+
this.on = {
|
|
88
|
+
preRender: new Signal()
|
|
89
|
+
};
|
|
77
90
|
}
|
|
78
91
|
|
|
79
92
|
/**
|