@galacean/engine 1.4.0-beta.1 → 1.4.0

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/dist/browser.js CHANGED
@@ -10868,8 +10868,6 @@
10868
10868
  //@ts-ignore
10869
10869
  this._viewport._onValueChanged = null;
10870
10870
  this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged);
10871
- this._updateFlagManager = null;
10872
- this._entity = null;
10873
10871
  this._globalShaderMacro = null;
10874
10872
  this._frustum = null;
10875
10873
  this._renderPipeline = null;
@@ -15137,7 +15135,6 @@
15137
15135
  var material = materials[i];
15138
15136
  material && this._addResourceReferCount(material, -1);
15139
15137
  }
15140
- this._entity = null;
15141
15138
  this._globalShaderMacro = null;
15142
15139
  this._bounds = null;
15143
15140
  this._materials = null;
@@ -22443,7 +22440,6 @@
22443
22440
  this._setParent(null);
22444
22441
  }
22445
22442
  this.isActive = false;
22446
- this._updateFlagManager = null;
22447
22443
  };
22448
22444
  /**
22449
22445
  * @internal
@@ -25558,7 +25554,7 @@
25558
25554
  * Describes a contact point where the collision occurs.
25559
25555
  */ var ContactPoint = function ContactPoint() {
25560
25556
  /** The position of the contact point between the shapes, in world space. */ this.position = new Vector3();
25561
- /** The normal of the contacting surfaces at the contact point. The normal direction points from the second shape to the first shape. */ this.normal = new Vector3();
25557
+ /** The normal of the contacting surfaces at the contact point. The normal direction points from the other shape to the self shape. */ this.normal = new Vector3();
25562
25558
  /** The impulse applied at the contact point, in world space. Divide by the simulation time step to get a force value. */ this.impulse = new Vector3();
25563
25559
  };
25564
25560
  /**
@@ -25575,7 +25571,8 @@
25575
25571
  * You need to obtain the actual number of contact points from the function's return value.
25576
25572
  */ _proto.getContacts = function getContacts(outContacts) {
25577
25573
  var nativeCollision = this._nativeCollision;
25578
- var factor = nativeCollision.shape0Id < nativeCollision.shape1Id ? 1 : -1;
25574
+ var smallerShapeId = Math.min(nativeCollision.shape0Id, nativeCollision.shape1Id);
25575
+ var factor = this.shape.id === smallerShapeId ? 1 : -1;
25579
25576
  var nativeContactPoints = nativeCollision.getContacts();
25580
25577
  var length = nativeContactPoints.size();
25581
25578
  for(var i = 0; i < length; i++){
@@ -28131,6 +28128,8 @@
28131
28128
  var currY = (latestEvent.clientY - top) * heightPixelRatio;
28132
28129
  pointer.deltaPosition.set(currX - position.x, currY - position.y);
28133
28130
  position.set(currX, currY);
28131
+ pointer.button = _pointerDec2BinMap[latestEvent.button] || PointerButton.None;
28132
+ pointer.pressedButtons = latestEvent.buttons;
28134
28133
  for(var i = 0; i < length; i++){
28135
28134
  var event = events[i];
28136
28135
  switch(event.type){
@@ -29298,11 +29297,16 @@
29298
29297
  }();
29299
29298
  var UIUtils = /*#__PURE__*/ function() {
29300
29299
  function UIUtils() {}
29301
- UIUtils.renderOverlay = function renderOverlay(engine, uiCanvases) {
29300
+ UIUtils.renderOverlay = function renderOverlay(engine, scene, uiCanvases) {
29301
+ var canvas = engine.canvas, rhi = engine._hardwareRenderer, renderContext = engine._renderContext, batcherManager = engine._batcherManager;
29302
29302
  var uiRenderQueue = this._renderQueue || (this._renderQueue = new RenderQueue(RenderQueueType.Transparent));
29303
29303
  var virtualCamera = this._virtualCamera || (this._virtualCamera = new VirtualCamera());
29304
29304
  var viewport = this._viewport || (this._viewport = new Vector4(0, 0, 1, 1));
29305
- var canvas = engine.canvas, rhi = engine._hardwareRenderer, renderContext = engine._renderContext, batcherManager = engine._batcherManager;
29305
+ // @ts-ignore
29306
+ var camera = this._overlayCamera || (this._overlayCamera = new OverlayCamera());
29307
+ camera.engine = engine;
29308
+ camera.scene = scene;
29309
+ renderContext.camera = camera;
29306
29310
  var _virtualCamera_projectionMatrix = virtualCamera.projectionMatrix, projectE = _virtualCamera_projectionMatrix.elements;
29307
29311
  var _virtualCamera_viewMatrix = virtualCamera.viewMatrix, viewE = _virtualCamera_viewMatrix.elements;
29308
29312
  projectE[0] = 2 / canvas.width, projectE[5] = 2 / canvas.height, projectE[10] = 0;
@@ -29310,8 +29314,8 @@
29310
29314
  for(var i = 0, n = uiCanvases.length; i < n; i++){
29311
29315
  var uiCanvas = uiCanvases.get(i);
29312
29316
  if (uiCanvas) {
29313
- var transform = uiCanvas.entity.transform;
29314
- viewE[12] = -transform.position.x, viewE[13] = -transform.position.y;
29317
+ var position = uiCanvas.entity.transform.position;
29318
+ viewE[12] = -position.x, viewE[13] = -position.y;
29315
29319
  Matrix.multiply(virtualCamera.projectionMatrix, virtualCamera.viewMatrix, virtualCamera.viewProjectionMatrix);
29316
29320
  renderContext.applyVirtualCamera(virtualCamera, false);
29317
29321
  renderContext.rendererUpdateFlag |= ContextRendererUpdateFlag.ProjectionMatrix;
@@ -29327,6 +29331,14 @@
29327
29331
  };
29328
29332
  return UIUtils;
29329
29333
  }();
29334
+ var OverlayCamera = function OverlayCamera() {
29335
+ // @ts-ignore
29336
+ this.instanceId = ++EngineObject._instanceIdCounter;
29337
+ this.shaderData = new ShaderData(ShaderDataGroup.Camera);
29338
+ this.enableFrustumCulling = true;
29339
+ this.cullingMask = Layer.Everything;
29340
+ this._globalShaderMacro = new ShaderMacroCollection();
29341
+ };
29330
29342
  /**
29331
29343
  * XRManager located in the main package, its implementation logic is XRManagerExtended in the sub-package engine-xr.
29332
29344
  */ var XRManager = /*#__PURE__*/ function() {
@@ -29651,25 +29663,25 @@
29651
29663
  var cameras = componentsManager._activeCameras;
29652
29664
  if (cameras.length === 0) {
29653
29665
  Logger.debug("No active camera in scene.");
29654
- return "continue";
29655
- }
29656
- cameras.forEach(function(camera) {
29657
- componentsManager.callCameraOnBeginRender(camera);
29658
- // Update post process manager
29659
- scene.postProcessManager._update(camera);
29660
- camera.render();
29661
- componentsManager.callCameraOnEndRender(camera);
29662
- // Temp solution for webgl implement bug
29663
- if (_this1._hardwareRenderer._options._forceFlush) {
29664
- _this1._hardwareRenderer.flush();
29665
- }
29666
- }, function(camera, index) {
29667
- camera._cameraIndex = index;
29668
- });
29666
+ } else {
29667
+ cameras.forEach(function(camera) {
29668
+ componentsManager.callCameraOnBeginRender(camera);
29669
+ // Update post process manager
29670
+ scene.postProcessManager._update(camera);
29671
+ camera.render();
29672
+ componentsManager.callCameraOnEndRender(camera);
29673
+ // Temp solution for webgl implement bug
29674
+ if (_this1._hardwareRenderer._options._forceFlush) {
29675
+ _this1._hardwareRenderer.flush();
29676
+ }
29677
+ }, function(camera, index) {
29678
+ camera._cameraIndex = index;
29679
+ });
29680
+ }
29669
29681
  var uiCanvas = componentsManager._overlayCanvases;
29670
29682
  if (uiCanvas.length > 0) {
29671
29683
  componentsManager.sortOverlayUICanvases();
29672
- UIUtils.renderOverlay(_this, uiCanvas);
29684
+ UIUtils.renderOverlay(_this, scene, uiCanvas);
29673
29685
  }
29674
29686
  };
29675
29687
  var _this1 = this;
@@ -34782,11 +34794,7 @@
34782
34794
  if (transition.mute) continue;
34783
34795
  if (transitionCollection.isSoloMode && !transition.solo) continue;
34784
34796
  if (this._checkConditions(transition)) {
34785
- if (this._applyTransition(layerData, transition, aniUpdate)) {
34786
- return transition;
34787
- } else {
34788
- return null;
34789
- }
34797
+ return this._applyTransition(layerData, transition, aniUpdate);
34790
34798
  }
34791
34799
  }
34792
34800
  };
@@ -34806,13 +34814,11 @@
34806
34814
  return true;
34807
34815
  };
34808
34816
  _proto._applyTransition = function _applyTransition(layerData, transition, aniUpdate) {
34809
- // Need prepare first, it should crossFade when to exit
34810
- var success = this._prepareCrossFadeByTransition(transition, layerData.layerIndex);
34811
34817
  if (transition.isExit) {
34812
34818
  this._checkAnyAndEntryState(layerData, 0, aniUpdate);
34813
- return transition;
34819
+ return null;
34814
34820
  }
34815
- return success ? transition : null;
34821
+ return this._prepareCrossFadeByTransition(transition, layerData.layerIndex) ? transition : null;
34816
34822
  };
34817
34823
  _proto._checkConditions = function _checkConditions(transition) {
34818
34824
  var conditions = transition.conditions;
@@ -43434,10 +43440,16 @@
43434
43440
  return this._getEntityByConfig(entityConfig).then(function(entity) {
43435
43441
  var _entityConfig_isActive;
43436
43442
  entity.isActive = (_entityConfig_isActive = entityConfig.isActive) != null ? _entityConfig_isActive : true;
43437
- var position = entityConfig.position, rotation = entityConfig.rotation, scale = entityConfig.scale;
43438
- if (position) entity.transform.position.copyFrom(position);
43439
- if (rotation) entity.transform.rotation.copyFrom(rotation);
43440
- if (scale) entity.transform.scale.copyFrom(scale);
43443
+ var transform = entity.transform;
43444
+ var transformConfig = entityConfig.transform;
43445
+ if (transformConfig) {
43446
+ _this.parsePropsAndMethods(transform, transformConfig);
43447
+ } else {
43448
+ var position = entityConfig.position, rotation = entityConfig.rotation, scale = entityConfig.scale;
43449
+ if (position) transform.position.copyFrom(position);
43450
+ if (rotation) transform.rotation.copyFrom(rotation);
43451
+ if (scale) transform.scale.copyFrom(scale);
43452
+ }
43441
43453
  var _entityConfig_layer;
43442
43454
  entity.layer = (_entityConfig_layer = entityConfig.layer) != null ? _entityConfig_layer : entity.layer;
43443
43455
  // @ts-ignore
@@ -43578,7 +43590,8 @@
43578
43590
  return entity;
43579
43591
  });
43580
43592
  } else {
43581
- var entity = new Entity(engine, entityConfig.name);
43593
+ var transform = entityConfig.transform;
43594
+ var entity = new Entity(engine, entityConfig.name, transform ? Loader.getClass(transform.class) : Transform);
43582
43595
  return Promise.resolve(entity);
43583
43596
  }
43584
43597
  };
@@ -44071,7 +44084,8 @@
44071
44084
  });
44072
44085
  };
44073
44086
  _proto._parseEntity = function _parseEntity(entityConfig, engine) {
44074
- var entity = new Entity(engine, entityConfig.name);
44087
+ var transform = entityConfig.transform;
44088
+ var entity = new Entity(engine, entityConfig.name, transform ? Loader.getClass(transform.class) : Transform);
44075
44089
  if (!entityConfig.parent) this.context.rootIds.push(entityConfig.id);
44076
44090
  return Promise.resolve(entity);
44077
44091
  };
@@ -44131,11 +44145,17 @@
44131
44145
  entity.isActive = (_entityConfig_isActive = entityConfig.isActive) != null ? _entityConfig_isActive : entity.isActive;
44132
44146
  var _entityConfig_name;
44133
44147
  entity.name = (_entityConfig_name = entityConfig.name) != null ? _entityConfig_name : entity.name;
44134
- var position = entityConfig.position, rotation = entityConfig.rotation, scale = entityConfig.scale, layer = entityConfig.layer;
44135
- if (position) entity.transform.position.copyFrom(position);
44136
- if (rotation) entity.transform.rotation.copyFrom(rotation);
44137
- if (scale) entity.transform.scale.copyFrom(scale);
44138
- if (layer) entity.layer = layer;
44148
+ var transform = entity.transform;
44149
+ var transformConfig = entityConfig.transform;
44150
+ if (transformConfig) {
44151
+ this._reflectionParser.parsePropsAndMethods(transform, transformConfig);
44152
+ } else {
44153
+ var position = entityConfig.position, rotation = entityConfig.rotation, scale = entityConfig.scale;
44154
+ if (position) transform.position.copyFrom(position);
44155
+ if (rotation) transform.rotation.copyFrom(rotation);
44156
+ if (scale) transform.scale.copyFrom(scale);
44157
+ }
44158
+ if (entityConfig.layer) entity.layer = entityConfig.layer;
44139
44159
  return entity;
44140
44160
  };
44141
44161
  _proto._generateInstanceContext = function _generateInstanceContext(entity, context, path) {
@@ -49937,7 +49957,7 @@
49937
49957
  ], EXT_texture_webp);
49938
49958
 
49939
49959
  //@ts-ignore
49940
- var version = "1.4.0-beta.1";
49960
+ var version = "1.4.0";
49941
49961
  console.log("Galacean engine version: " + version);
49942
49962
  for(var key in CoreObjects){
49943
49963
  Loader.registerClass(key, CoreObjects[key]);