@woosh/meep-engine 2.85.1 → 2.85.3

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.
@@ -89211,22 +89211,24 @@ function configureThreeRenderer(webGLRenderer) {
89211
89211
  //turn off automatic info reset, we use multi-pass rendering, so we manually reset the render info
89212
89212
  webGLRenderer.info.autoReset = false;
89213
89213
 
89214
- if (ENV_PRODUCTION) {
89215
- //disable shader error checking in production build
89216
- webGLRenderer.debug.checkShaderErrors = false;
89217
- } else {
89218
- webGLRenderer.debug.checkShaderErrors = true;
89219
- }
89220
89214
  }
89221
89215
 
89222
89216
 
89223
89217
  class GraphicsEngine {
89218
+ #debug = false;
89219
+
89224
89220
  /**
89225
89221
  *
89226
89222
  * @param {Camera} camera
89223
+ * @param {boolean} [debug]
89227
89224
  * @constructor
89228
89225
  */
89229
- constructor(camera) {
89226
+ constructor({
89227
+ camera,
89228
+ debug = false
89229
+ }) {
89230
+ this.#debug = debug;
89231
+
89230
89232
  const self = this;
89231
89233
 
89232
89234
  /**
@@ -89385,6 +89387,7 @@ class GraphicsEngine {
89385
89387
  return intersectObject;
89386
89388
  })();
89387
89389
  }
89390
+
89388
89391
  /**
89389
89392
  *
89390
89393
  * @returns {MaterialManager}
@@ -89468,7 +89471,7 @@ class GraphicsEngine {
89468
89471
 
89469
89472
  start() {
89470
89473
  const canvas = document.createElement("canvas");
89471
- const context = canvas.getContext("webgl2", {antialias: false});
89474
+ const context = canvas.getContext("webgl2", { antialias: false });
89472
89475
 
89473
89476
  const rendererParameters = {
89474
89477
  antialias: true,
@@ -89510,6 +89513,9 @@ class GraphicsEngine {
89510
89513
 
89511
89514
  configureThreeRenderer(webGLRenderer);
89512
89515
 
89516
+ //disable shader error checking in production build
89517
+ webGLRenderer.debug.checkShaderErrors = this.#debug;
89518
+
89513
89519
  this.enableExtensions();
89514
89520
 
89515
89521
  this.initializeFrameBuffers();
@@ -89665,6 +89671,10 @@ class GraphicsEngine {
89665
89671
  // TODO designate opaque output buffer
89666
89672
  const frameBuffer = buffers.getById(StandardFrameBuffers.ColorAndDepth);
89667
89673
 
89674
+ if (frameBuffer === undefined) {
89675
+ throw new Error(`No color-depth frame buffer`);
89676
+ }
89677
+
89668
89678
  renderTextureToScreenQuad(frameBuffer.renderTarget.texture, renderer);
89669
89679
 
89670
89680
  this.on.postOpaquePass.send0();
@@ -103180,14 +103190,14 @@ class Engine {
103180
103190
  * @param {EntityManager} [entityManager]
103181
103191
  * @param {boolean} [enableGraphics]
103182
103192
  * @param {boolean} [enableAudio]
103183
- * @param {boolean} [validation]
103193
+ * @param {boolean} [debug]
103184
103194
  * @constructor
103185
103195
  */
103186
103196
  constructor(platform, {
103187
103197
  entityManager,
103188
103198
  enableGraphics = true,
103189
103199
  enableAudio = true,
103190
- validation = true
103200
+ debug = true
103191
103201
  } = {}) {
103192
103202
 
103193
103203
  /**
@@ -103201,7 +103211,7 @@ class Engine {
103201
103211
  * @type {StaticKnowledgeDatabase}
103202
103212
  */
103203
103213
  this.staticKnowledge = new StaticKnowledgeDatabase();
103204
- this.staticKnowledge.validation_enabled = validation;
103214
+ this.staticKnowledge.validation_enabled = debug;
103205
103215
 
103206
103216
  /**
103207
103217
  *
@@ -103352,7 +103362,10 @@ class Engine {
103352
103362
 
103353
103363
  if (enableGraphics !== false) {
103354
103364
 
103355
- const graphicsEngine = new GraphicsEngine(this.camera);
103365
+ const graphicsEngine = new GraphicsEngine({
103366
+ camera: this.camera,
103367
+ debug
103368
+ });
103356
103369
 
103357
103370
  /**
103358
103371
  *
@@ -103363,7 +103376,7 @@ class Engine {
103363
103376
  try {
103364
103377
  graphicsEngine.start();
103365
103378
  } catch (e) {
103366
- logger.info("Failed to start GraphicEngine: ", e);
103379
+ logger.error(`Failed to start GraphicEngine: ${e}`);
103367
103380
  }
103368
103381
 
103369
103382
  } else {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.85.1",
8
+ "version": "2.85.3",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -15,7 +15,7 @@ export interface IEngineInitializationOptions {
15
15
  entityManager?: EntityManager,
16
16
  enableAudio?: boolean
17
17
  enableGraphics?: boolean
18
- validation?:boolean
18
+ debug?:boolean
19
19
  }
20
20
 
21
21
  export default class Engine {
@@ -54,14 +54,14 @@ class Engine {
54
54
  * @param {EntityManager} [entityManager]
55
55
  * @param {boolean} [enableGraphics]
56
56
  * @param {boolean} [enableAudio]
57
- * @param {boolean} [validation]
57
+ * @param {boolean} [debug]
58
58
  * @constructor
59
59
  */
60
60
  constructor(platform, {
61
61
  entityManager,
62
62
  enableGraphics = true,
63
63
  enableAudio = true,
64
- validation = true
64
+ debug = true
65
65
  } = {}) {
66
66
  assert.defined(platform, 'platform');
67
67
 
@@ -76,7 +76,7 @@ class Engine {
76
76
  * @type {StaticKnowledgeDatabase}
77
77
  */
78
78
  this.staticKnowledge = new StaticKnowledgeDatabase();
79
- this.staticKnowledge.validation_enabled = validation;
79
+ this.staticKnowledge.validation_enabled = debug;
80
80
 
81
81
  /**
82
82
  *
@@ -159,7 +159,7 @@ class Engine {
159
159
 
160
160
  if (!this.__using_external_entity_manager) {
161
161
  // subscribe simulator to common ticker
162
- this.ticker.subscribe(timeDelta => {
162
+ this.ticker.onTick.add(timeDelta => {
163
163
  const t0 = performance.now();
164
164
  this.entityManager.simulate(timeDelta);
165
165
 
@@ -227,7 +227,10 @@ class Engine {
227
227
 
228
228
  if (enableGraphics !== false) {
229
229
 
230
- const graphicsEngine = new GraphicsEngine(this.camera);
230
+ const graphicsEngine = new GraphicsEngine({
231
+ camera: this.camera,
232
+ debug
233
+ });
231
234
 
232
235
  /**
233
236
  *
@@ -238,7 +241,7 @@ class Engine {
238
241
  try {
239
242
  graphicsEngine.start();
240
243
  } catch (e) {
241
- logger.info("Failed to start GraphicEngine: ", e);
244
+ logger.error(`Failed to start GraphicEngine: ${e}`);
242
245
  }
243
246
 
244
247
  } else {
@@ -58,22 +58,24 @@ function configureThreeRenderer(webGLRenderer) {
58
58
  //turn off automatic info reset, we use multi-pass rendering, so we manually reset the render info
59
59
  webGLRenderer.info.autoReset = false;
60
60
 
61
- if (ENV_PRODUCTION) {
62
- //disable shader error checking in production build
63
- webGLRenderer.debug.checkShaderErrors = false;
64
- } else {
65
- webGLRenderer.debug.checkShaderErrors = true;
66
- }
67
61
  }
68
62
 
69
63
 
70
64
  export class GraphicsEngine {
65
+ #debug = false;
66
+
71
67
  /**
72
68
  *
73
69
  * @param {Camera} camera
70
+ * @param {boolean} [debug]
74
71
  * @constructor
75
72
  */
76
- constructor(camera) {
73
+ constructor({
74
+ camera,
75
+ debug = false
76
+ }) {
77
+ this.#debug = debug;
78
+
77
79
  const self = this;
78
80
 
79
81
  /**
@@ -232,6 +234,7 @@ export class GraphicsEngine {
232
234
  return intersectObject;
233
235
  })();
234
236
  }
237
+
235
238
  /**
236
239
  *
237
240
  * @returns {MaterialManager}
@@ -315,7 +318,7 @@ export class GraphicsEngine {
315
318
 
316
319
  start() {
317
320
  const canvas = document.createElement("canvas");
318
- const context = canvas.getContext("webgl2", {antialias: false});
321
+ const context = canvas.getContext("webgl2", { antialias: false });
319
322
 
320
323
  const rendererParameters = {
321
324
  antialias: true,
@@ -362,6 +365,9 @@ export class GraphicsEngine {
362
365
 
363
366
  configureThreeRenderer(webGLRenderer);
364
367
 
368
+ //disable shader error checking in production build
369
+ webGLRenderer.debug.checkShaderErrors = this.#debug;
370
+
365
371
  this.enableExtensions();
366
372
 
367
373
  this.initializeFrameBuffers();
@@ -519,6 +525,10 @@ export class GraphicsEngine {
519
525
  // TODO designate opaque output buffer
520
526
  const frameBuffer = buffers.getById(StandardFrameBuffers.ColorAndDepth);
521
527
 
528
+ if (frameBuffer === undefined) {
529
+ throw new Error(`No color-depth frame buffer`);
530
+ }
531
+
522
532
  renderTextureToScreenQuad(frameBuffer.renderTarget.texture, renderer);
523
533
 
524
534
  this.on.postOpaquePass.send0();