elation-engine 0.9.117 → 0.9.118

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "elation-engine",
3
3
  "description": "WebGL/WebVR engine written in Javascript",
4
- "version": "0.9.117",
4
+ "version": "0.9.118",
5
5
  "main": "",
6
6
  "author": "James Baicoianu",
7
7
  "license": "MIT",
@@ -15405,6 +15405,7 @@
15405
15405
  const _flatCamera = /*@__PURE__*/ new OrthographicCamera();
15406
15406
  const _clearColor = /*@__PURE__*/ new Color();
15407
15407
  let _oldTarget = null;
15408
+ let _oldXrEnabled = false;
15408
15409
 
15409
15410
  // Golden Ratio
15410
15411
  const PHI = ( 1 + Math.sqrt( 5 ) ) / 2;
@@ -15470,6 +15471,9 @@
15470
15471
  fromScene( scene, sigma = 0, near = 0.1, far = 100 ) {
15471
15472
 
15472
15473
  _oldTarget = this._renderer.getRenderTarget();
15474
+ _oldXrEnabled = this._renderer.xr.enabled;
15475
+
15476
+ this._renderer.xr.enabled = false;
15473
15477
 
15474
15478
  this._setSize( 256 );
15475
15479
 
@@ -15583,6 +15587,8 @@
15583
15587
  _cleanup( outputTarget ) {
15584
15588
 
15585
15589
  this._renderer.setRenderTarget( _oldTarget );
15590
+ this._renderer.xr.enabled = _oldXrEnabled;
15591
+
15586
15592
  outputTarget.scissorTest = false;
15587
15593
  _setViewport( outputTarget, 0, 0, outputTarget.width, outputTarget.height );
15588
15594
 
@@ -15601,6 +15607,9 @@
15601
15607
  }
15602
15608
 
15603
15609
  _oldTarget = this._renderer.getRenderTarget();
15610
+ _oldXrEnabled = this._renderer.xr.enabled;
15611
+
15612
+ this._renderer.xr.enabled = false;
15604
15613
 
15605
15614
  const cubeUVRenderTarget = renderTarget || this._allocateTargets();
15606
15615
  this._textureToCubeUV( texture, cubeUVRenderTarget );
package/scripts/math.js CHANGED
@@ -58,3 +58,9 @@ EulerDegrees.prototype.clone = function () {
58
58
  EulerDegrees.prototype.toArray = function() {
59
59
  return [this.x, this.y, this.z, this.radians.order];
60
60
  };
61
+ EulerDegrees.prototype.equals = function(other) {
62
+ return ( this.epsilonEquals(other.x, this.x) ) && ( this.epsilonEquals(other.y, this.y) ) && ( this.epsilonEquals(other.z, this.z) ) && ( other.order == this.order );
63
+ };
64
+ EulerDegrees.prototype.epsilonEquals = function(v1, v2, epsilon=1e-5) {
65
+ return Math.abs(v1 - v2) < epsilon;
66
+ };
@@ -99,7 +99,7 @@ elation.require([
99
99
  this.renderer.toneMappingWhitePoint = 1;
100
100
  */
101
101
 
102
- this.renderer.debug.checkShaderErrors = true;
102
+ this.renderer.debug.checkShaderErrors = false;
103
103
 
104
104
  this.lastframetime = 0;
105
105
 
@@ -337,6 +337,7 @@ elation.require([
337
337
  this.canvas.style.height = '100%';
338
338
  }
339
339
  elation.events.add(window, "resize", this);
340
+ elation.events.add(window, "orientationchange", ev => this.resize(true));
340
341
  elation.events.add(document.body, "mouseenter,mouseleave", this);
341
342
  elation.events.add(this.canvas, "mouseover,mousedown,mousemove,mouseup,click", this);
342
343
  elation.events.add(this.canvas, "mousewheel,touchstart,touchmove,touchend", this);
@@ -416,13 +417,15 @@ elation.require([
416
417
  this.rendertarget.depthTexture.type = THREE.UnsignedInt248Type;
417
418
  this.rendertarget.depthTexture.format = THREE.DepthStencilFormat;
418
419
  //this.composer = this.createRenderPath(['clear', /*'portals', 'masktest',*/ this.rendermode, 'fxaa'/*, 'msaa'*/, 'bloom', 'maskclear', 'recording'], this.rendertarget);
419
- this.composer = this.createRenderPath(['clear', this.rendermode,/* 'tonemapping',*/ 'unrealbloom', 'fxaa', 'gamma'], this.rendertarget);
420
- //this.composer = this.createRenderPath(['clear', this.rendermode, 'fxaa'/*, 'msaa'*/, 'bloom', 'maskclear'], this.rendertarget);
421
- //this.effects['msaa'].enabled = false;
422
- //this.composer = this.createRenderPath([this.rendermode, 'ssao', 'recording']);
423
- if (this.showstats) {
424
- // FIXME - not smart!
425
- elation.events.add(this.composer.passes[3], 'render', elation.bind(this, this.updateRenderStats));
420
+ if (this.enablepostprocessing) {
421
+ this.composer = this.createRenderPath(['clear', this.rendermode,/* 'tonemapping',*/ 'unrealbloom', 'fxaa', 'gamma'], this.rendertarget);
422
+ //this.composer = this.createRenderPath(['clear', this.rendermode, 'fxaa'/*, 'msaa'*/, 'bloom', 'maskclear'], this.rendertarget);
423
+ //this.effects['msaa'].enabled = false;
424
+ //this.composer = this.createRenderPath([this.rendermode, 'ssao', 'recording']);
425
+ if (this.showstats) {
426
+ // FIXME - not smart!
427
+ elation.events.add(this.composer.passes[3], 'render', elation.bind(this, this.updateRenderStats));
428
+ }
426
429
  }
427
430
 
428
431
  this.getsize();
@@ -695,7 +698,7 @@ console.log('toggle render mode: ' + this.rendermode + ' => ' + mode, passidx, l
695
698
  await this.rendersystem.renderer.xr.setSession(session);
696
699
  this.rendersystem.renderer.xr.enabled = true;
697
700
 
698
- this.rendersystem.renderer.outputEncoding = THREE.sRGBEncoding;
701
+ this.rendersystem.renderer.outputEncoding = THREE.LinearEncoding;
699
702
  this.xrlayer = this.getXRBaseLayer(session);
700
703
  if (false && !this.xrscene) {
701
704
  // Set up a scene with an ortho camera to clone our XR framebuffer to, for display on the main screen
@@ -831,7 +834,6 @@ console.log('toggle render mode: ' + this.rendermode + ' => ' + mode, passidx, l
831
834
  //this.scene.overrideMaterial = null;
832
835
  //this.rendersystem.renderer.render(this.scene, this.actualcamera);
833
836
 
834
- this.effects[this.rendermode].camera = this.actualcamera;
835
837
 
836
838
  let colliderscene = this.engine.systems.world.scene['colliders'],
837
839
  worldscene = this.engine.systems.world.scene['world-3d'];
@@ -843,6 +845,7 @@ console.log('toggle render mode: ' + this.rendermode + ' => ' + mode, passidx, l
843
845
  worldscene.remove(colliderscene);
844
846
  }
845
847
  if (this.enablepostprocessing) {
848
+ this.effects[this.rendermode].camera = this.actualcamera;
846
849
  this.composer.render(delta);
847
850
  } else {
848
851
  if (this.xrsession) {
@@ -1113,6 +1116,8 @@ console.log('toggle render mode: ' + this.rendermode + ' => ' + mode, passidx, l
1113
1116
  this.size = [s.w, s.h];
1114
1117
  this.setrendersize(this.size[0], this.size[1]);
1115
1118
  }
1119
+ this.actualcamera.zoom = (Math.abs(window.orientation) == 90 ? 2 : 1);
1120
+ this.actualcamera.updateProjectionMatrix();
1116
1121
  this.rendersystem.setdirty();
1117
1122
 
1118
1123
  return this.size;
@@ -78,6 +78,9 @@ elation.require([ ], function() {
78
78
  elation.events.fire({type: 'mute', element: this});
79
79
  }
80
80
  }
81
+ this.unmute = function() {
82
+ this.mute(false);
83
+ }
81
84
  this.toggleMute = function() {
82
85
  this.mute(this.enabled);
83
86
  }
@@ -1475,10 +1475,18 @@ elation.component.add("engine.things.generic", function() {
1475
1475
  elation.events.fire({type: 'thing_change_queued', element: this});
1476
1476
  }
1477
1477
  this.applyChanges = function() {
1478
- var s = this.scale;
1479
- if (s && this.objects['3d']) {
1480
- this.objects['3d'].visible = this.visible && !(s.x == 0 || s.y == 0 || s.z == 0);
1478
+
1479
+ const s = this.scale, o = this.objects['3d'], ov = o.visible, v = this.visible;
1480
+ if (s && o) {
1481
+ //this.objects['3d'].visible = this.visible && !(s.x == 0 || s.y == 0 || s.z == 0);
1482
+ let scaleMult = s.x * s.y * s.z;
1483
+ if (ov && (!this.visible || scaleMult == 0)) {
1484
+ o.visible = false;
1485
+ } else if (!ov && (this.visible && scaleMult != 0)) {
1486
+ o.visible = true;
1487
+ }
1481
1488
  }
1489
+
1482
1490
  if (this.colliders) {
1483
1491
  this.colliders.position.copy(this.properties.position);
1484
1492
  this.colliders.quaternion.copy(this.properties.orientation);