@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.
Files changed (74) hide show
  1. package/core/bvh2/binary/IndexedBinaryBVH.js +1 -1
  2. package/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +5 -1
  3. package/core/bvh2/traversal/__detailed_box_volume_intersection.js +22 -5
  4. package/core/collection/array/binarySearchHighIndex.js +1 -1
  5. package/core/collection/array/copyArray.js +2 -2
  6. package/core/geom/3d/normal/hemioct/unit_hemioct.spec.js +1 -1
  7. package/core/geom/3d/shape/AbstractShape3D.js +9 -0
  8. package/core/geom/3d/shape/CompositeShape.js +188 -8
  9. package/core/geom/3d/shape/TransformedShape3D.js +58 -2
  10. package/core/geom/3d/shape/UnitCubeShape3D.js +11 -0
  11. package/core/geom/3d/shape/UnitSphereShape3D.js +8 -0
  12. package/core/geom/3d/shape/util/shape_to_visual_entity.js +159 -0
  13. package/core/geom/random/randomPointInSphere.js +3 -2
  14. package/core/json/resolvePathByArray.js +2 -2
  15. package/{engine/graphics/render/forward_plus/materials → core/primitives/strings}/insert_after.js +3 -0
  16. package/core/primitives/strings/insert_after_or_replace.js +27 -0
  17. package/editor/process/symbolic/makeHelperBoxGeometry.js +44 -0
  18. package/editor/view/ecs/EntityEditor.js +2 -2
  19. package/editor/view/ecs/components/particles/ParticleEmitterController.js +2 -2
  20. package/engine/EngineHarness.js +1 -0
  21. package/engine/animation/AnimationUtils.js +5 -5
  22. package/engine/ecs/EntityBuilder.js +25 -5
  23. package/engine/ecs/attachment/AttachmentBinding.js +8 -0
  24. package/engine/ecs/attachment/AttachmentSystem.js +4 -0
  25. package/engine/ecs/attachment/TransformAttachmentBinding.js +14 -44
  26. package/engine/ecs/components/Tag.js +27 -6
  27. package/engine/ecs/fow/FogOfWar.js +4 -0
  28. package/engine/ecs/fow/FogOfWarSystem.js +2 -0
  29. package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +2 -0
  30. package/engine/ecs/system/AbstractContextSystem.js +1 -1
  31. package/engine/ecs/systems/TagSystem.js +17 -0
  32. package/engine/ecs/transform/Transform.js +19 -6
  33. package/engine/graphics/GraphicsEngine.js +11 -6
  34. package/engine/graphics/composit/CompositLayer.js +17 -4
  35. package/engine/graphics/composit/CompositingStages.js +8 -0
  36. package/engine/graphics/composit/LayerCompositer.js +35 -6
  37. package/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +11 -7
  38. package/engine/graphics/ecs/light/Light.js +2 -0
  39. package/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +5 -1
  40. package/engine/graphics/ecs/mesh-v2/DrawMode.js +5 -0
  41. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +32 -18
  42. package/engine/graphics/particles/ParticleEmitterLibrary.js +3 -0
  43. package/engine/graphics/particles/ecs/{ParticleEmitterSystem2.js → ParticleEmitterSystem.js} +17 -9
  44. package/engine/graphics/particles/particular/engine/ParticularEngine.js +8 -2
  45. package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +14 -25
  46. package/engine/graphics/particles/particular/engine/emitter/ParticleEmitterFlag.js +5 -0
  47. package/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +90 -2
  48. package/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +7 -7
  49. package/engine/graphics/particles/particular/engine/renderers/billboard/BILLBOARD_PARTICLE_SPECIFICATION.js +15 -12
  50. package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +262 -51
  51. package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +80 -46
  52. package/engine/graphics/particles/particular/engine/shader/debugAtlas.js +14 -0
  53. package/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +141 -0
  54. package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +148 -54
  55. package/engine/graphics/particles/particular/engine/utils/volume/lut_to_sampler.js +27 -0
  56. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +542 -165
  57. package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +12 -6
  58. package/engine/graphics/render/forward_plus/materials/FP_INJECTION_POINT_ACCUMULATION.js +1 -0
  59. package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_ACCUMULATION.js +32 -0
  60. package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_DECODE_PARS.js +51 -0
  61. package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_PREAMBLE.js +25 -0
  62. package/engine/graphics/render/forward_plus/materials/fp_build_fragment_shader.js +31 -120
  63. package/engine/graphics/render/forward_plus/materials/fp_build_vertex_lighting_shared.js +35 -0
  64. package/engine/graphics/render/forward_plus/materials/fp_build_vertex_shader.js +4 -5
  65. package/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +10 -3
  66. package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +588 -53
  67. package/engine/graphics/render/forward_plus/prototypeLightManager.js +29 -4
  68. package/engine/graphics/shaders/TerrainShader.js +4 -5
  69. package/engine/graphics/util/composeMatrix4.js +33 -23
  70. package/engine/graphics/util/decompose_matrix_4_array.js +61 -0
  71. package/engine/intelligence/behavior/ecs/BehaviorComponent.js +30 -14
  72. package/engine/knowledge/database/StaticKnowledgeDataTable.js +6 -1
  73. package/engine/navigation/ecs/components/Path.js +0 -5
  74. package/package.json +1 -1
@@ -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 { ParticleEmitterSystem2 } from "../../../engine/graphics/particles/ecs/ParticleEmitterSystem2.js";
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(ParticleEmitterSystem2);
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 {ParticleEmitterSystem2} system
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 {ParticleEmitterSystem2} particleEmitterSystem
64
+ * @param {ParticleEmitterSystem} particleEmitterSystem
65
65
  * @constructor
66
66
  */
67
67
  constructor(particleEmitterSystem) {
@@ -367,6 +367,7 @@ export class EngineHarness {
367
367
  sensitivity
368
368
  });
369
369
 
370
+ eb.add(Tag.fromJSON(['CameraController']));
370
371
  eb.add(SerializationMetadata.Transient);
371
372
 
372
373
  eb.build(ecd);
@@ -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 { ParticleEmitterSystem2 } from "../graphics/particles/ecs/ParticleEmitterSystem2.js";
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 {ParticleEmitterSystem2}
140
+ * @type {ParticleEmitterSystem}
141
141
  */
142
- const sPE = entityManager.getSystem(ParticleEmitterSystem2);
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 {ParticleEmitterSystem2}
217
+ * @type {ParticleEmitterSystem}
218
218
  */
219
- const sPE = engine.entityManager.getSystem(ParticleEmitterSystem2);
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
- name: eventName,
242
- listener: listener,
243
- context
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
  /**
@@ -30,6 +30,14 @@ export class AttachmentBinding {
30
30
  this.attachment = null;
31
31
  }
32
32
 
33
+ link() {
34
+
35
+ }
36
+
37
+ unlink() {
38
+
39
+ }
40
+
33
41
  update() {
34
42
 
35
43
  }
@@ -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 Quaternion from "../../../core/geom/Quaternion.js";
2
+ import { mat4 } from "gl-matrix";
5
3
 
6
- const socketM4 = new Matrix4();
7
-
8
- const threeQuaternion = new ThreeQuaternion();
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
- if (Number.isNaN(threeQuaternion.x)) {
53
- t.rotation.copy(Quaternion.identity);
54
- } else {
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
- t.scale.copy(pScale);
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
- t.position.copy(pPosition);
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
- const valueCount = values.length;
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
- const values1 = this.values;
131
- const tagCount = values1.length;
139
+ let i = 0, j = 0;
132
140
 
133
- main: for (let i = 0; i < valueCount; i++) {
141
+ main: for (; i < search_value_count; i++) {
134
142
  const v = values[i];
135
143
 
136
- for (let j = 0; j < tagCount; j++) {
137
- const tag = values1[j];
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
  *
@@ -75,6 +75,10 @@ export class FogOfWar {
75
75
  */
76
76
  this.texture = null;
77
77
 
78
+ /**
79
+ * Resolution scale of FoW versus terrain resolution, higher number makes FoW more detailed
80
+ * @type {Vector1}
81
+ */
78
82
  this.scale = new Vector1(1);
79
83
 
80
84
  /**
@@ -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;
@@ -38,7 +38,7 @@ export class AbstractContextSystem extends System {
38
38
  // TODO
39
39
  },
40
40
  (ctx) => {
41
- ctx.unlink();
41
+ //ctx.unlink();
42
42
  }
43
43
  );
44
44
 
@@ -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 { Quaternion as ThreeQuaternion } from "three";
9
- import { composeMatrix4 } from "../../graphics/util/composeMatrix4.js";
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
- matrix.decompose(this.position, threeQuaternion, this.scale);
168
+ this.fromMatrix4(matrix.elements);
169
+ }
170
170
 
171
- this.rotation.copy(threeQuaternion);
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
- composeMatrix4(matrix, this.position, this.rotation, this.scale);
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("renderer-engine-render-canvas");
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.on.preComposite.send3(renderer, camera, scene);
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({ renderTarget, blending, renderTargetScale = 1 }) {
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
- const material = this.buildMaterial();
65
+ this.object = new Mesh(FULL_SCREEN_TRIANGLE_GEOMETRY, this.buildMaterial());
61
66
 
62
- this.object = new Mesh(FULL_SCREEN_TRIANGLE_GEOMETRY, material);
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
  /**
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @readonly
3
+ * @enum {number}
4
+ */
5
+ export const CompositingStages = {
6
+ POST_OPAQUE: 1,
7
+ POST_TRANSPARENT: 0
8
+ }