@galacean/engine 1.1.0-beta.39 → 1.1.0-beta.43

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
@@ -16615,7 +16615,7 @@
16615
16615
  var theta = thetaStart + u * thetaRange;
16616
16616
  var sinTheta = Math.sin(theta);
16617
16617
  var cosTheta = Math.cos(theta);
16618
- var curRadius = radius - y * radius;
16618
+ var curRadius = radius - v * radius;
16619
16619
  var posX = curRadius * sinTheta;
16620
16620
  var posY = y * unitHeight - halfHeight;
16621
16621
  var posZ = curRadius * cosTheta;
@@ -16749,8 +16749,8 @@
16749
16749
  indices[indicesOffset++] = d;
16750
16750
  indices[indicesOffset++] = c;
16751
16751
  }
16752
- PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, thetaRange, torsoVertexCount, 1, vertices, indices, indicesOffset);
16753
- PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, -thetaRange, torsoVertexCount + capVertexCount, -1, vertices, indices, indicesOffset + 6 * capRectangleCount);
16752
+ PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, thetaStart, thetaRange, torsoVertexCount, 1, vertices, indices, indicesOffset);
16753
+ PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, thetaStart, -thetaRange, torsoVertexCount + capVertexCount, -1, vertices, indices, indicesOffset + 6 * capRectangleCount);
16754
16754
  if (!isRestoreMode) {
16755
16755
  var bounds = capsuleMesh.bounds;
16756
16756
  bounds.min.set(-radius, -radius - halfHeight, -radius);
@@ -16791,7 +16791,7 @@
16791
16791
  }
16792
16792
  return indices;
16793
16793
  };
16794
- PrimitiveMesh._createCapsuleCap = function _createCapsuleCap(radius, height, radialSegments, capAlphaRange, offset, posIndex, vertices, indices, indicesOffset) {
16794
+ PrimitiveMesh._createCapsuleCap = function _createCapsuleCap(radius, height, radialSegments, thetaStart, thetaRange, offset, posIndex, vertices, indices, indicesOffset) {
16795
16795
  var radialCount = radialSegments + 1;
16796
16796
  var halfHeight = height * 0.5 * posIndex;
16797
16797
  var capVertexCount = radialCount * radialCount;
@@ -16804,12 +16804,12 @@
16804
16804
  var y = i * radialCountReciprocal | 0;
16805
16805
  var u = x * radialSegmentsReciprocal;
16806
16806
  var v = y * radialSegmentsReciprocal;
16807
- var alphaDelta = u * capAlphaRange;
16808
- var thetaDelta = v * Math.PI / 2;
16809
- var sinTheta = Math.sin(thetaDelta);
16810
- var posX = -radius * Math.cos(alphaDelta) * sinTheta;
16811
- var posY = radius * Math.cos(thetaDelta) * posIndex + halfHeight;
16812
- var posZ = radius * Math.sin(alphaDelta) * sinTheta;
16807
+ var theta = thetaStart + u * thetaRange;
16808
+ var alpha = v * Math.PI * 0.5;
16809
+ var sinAlpha = Math.sin(alpha);
16810
+ var posX = radius * Math.sin(theta) * sinAlpha;
16811
+ var posY = radius * Math.cos(alpha) * posIndex + halfHeight;
16812
+ var posZ = radius * Math.cos(theta) * sinAlpha;
16813
16813
  var index = (i + offset) * vertexFloatCount;
16814
16814
  // Position
16815
16815
  vertices[index++] = posX;
@@ -17329,7 +17329,9 @@
17329
17329
  this._batchedQueue = null;
17330
17330
  var _this = this, meshes = _this._meshes, vertexBuffers = _this._vertexBuffers, indiceBuffers = _this._indiceBuffers;
17331
17331
  for(var i = 0, n = meshes.length; i < n; ++i){
17332
- meshes[i].destroy();
17332
+ var mesh = meshes[i];
17333
+ mesh._addReferCount(-1);
17334
+ mesh.destroy();
17333
17335
  }
17334
17336
  this._meshes = null;
17335
17337
  for(var i1 = 0, n1 = vertexBuffers.length; i1 < n1; ++i1){
@@ -17352,7 +17354,7 @@
17352
17354
  _proto._createMesh = function _createMesh(engine, index) {
17353
17355
  var MAX_VERTEX_COUNT = Basic2DBatcher.MAX_VERTEX_COUNT;
17354
17356
  var mesh = new BufferMesh(engine, "BufferMesh" + index);
17355
- mesh.isGCIgnored = true;
17357
+ mesh._addReferCount(1);
17356
17358
  var vertexElements = [];
17357
17359
  var vertexStride = this.createVertexElements(vertexElements);
17358
17360
  // vertices
@@ -24318,6 +24320,46 @@
24318
24320
  (function() {
24319
24321
  /** @internal Conversion of space units to pixel units for 2D. */ Engine._pixelsPerUnit = 100;
24320
24322
  })();
24323
+ /**
24324
+ * Canvas.
24325
+ */ var Canvas = /*#__PURE__*/ function() {
24326
+ var Canvas = function Canvas() {
24327
+ /* @internal */ this._sizeUpdateFlagManager = new UpdateFlagManager();
24328
+ };
24329
+ _create_class$3(Canvas, [
24330
+ {
24331
+ key: "width",
24332
+ get: /**
24333
+ * The width of the canvas.
24334
+ */ function get() {
24335
+ return this._width;
24336
+ },
24337
+ set: function set(value) {
24338
+ if (this._width !== value) {
24339
+ this._width = value;
24340
+ this._sizeUpdateFlagManager.dispatch();
24341
+ this._onSizeChanged(value, this._width);
24342
+ }
24343
+ }
24344
+ },
24345
+ {
24346
+ key: "height",
24347
+ get: /**
24348
+ *The height of the canvas.
24349
+ */ function get() {
24350
+ return this._height;
24351
+ },
24352
+ set: function set(value) {
24353
+ if (this._height !== value) {
24354
+ this._height = value;
24355
+ this._sizeUpdateFlagManager.dispatch();
24356
+ this._onSizeChanged(this._width, value);
24357
+ }
24358
+ }
24359
+ }
24360
+ ]);
24361
+ return Canvas;
24362
+ }();
24321
24363
  /**
24322
24364
  * The Background mode enumeration.
24323
24365
  */ exports.BackgroundMode = void 0;
@@ -27894,7 +27936,6 @@
27894
27936
  _this._viewport = new Vector4(0, 0, 1, 1);
27895
27937
  _this._pixelViewport = new Rect(0, 0, 0, 0);
27896
27938
  _this._inverseProjectionMatrix = new Matrix();
27897
- _this._lastAspectSize = new Vector2(0, 0);
27898
27939
  _this._invViewProjMat = new Matrix();
27899
27940
  var transform = _this.entity.transform;
27900
27941
  _this._transform = transform;
@@ -27904,6 +27945,10 @@
27904
27945
  _this._renderPipeline = new BasicRenderPipeline(_assert_this_initialized(_this));
27905
27946
  _this.shaderData._addReferCount(1);
27906
27947
  _this._updatePixelViewport();
27948
+ _this._onPixelViewportChanged = _this._onPixelViewportChanged.bind(_assert_this_initialized(_this));
27949
+ //@ts-ignore
27950
+ _this._viewport._onValueChanged = _this._onPixelViewportChanged;
27951
+ _this.engine.canvas._sizeUpdateFlagManager.addListener(_this._onPixelViewportChanged);
27907
27952
  return _this;
27908
27953
  };
27909
27954
  _inherits$2(Camera1, Component1);
@@ -28093,6 +28138,9 @@
28093
28138
  this._isInvViewProjDirty.destroy();
28094
28139
  this._isViewMatrixDirty.destroy();
28095
28140
  this.shaderData._addReferCount(-1);
28141
+ //@ts-ignore
28142
+ this._viewport._onValueChanged = null;
28143
+ this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged);
28096
28144
  this._entity = null;
28097
28145
  this._globalShaderMacro = null;
28098
28146
  this._frustum = null;
@@ -28105,16 +28153,20 @@
28105
28153
  this._isInvViewProjDirty = null;
28106
28154
  this._viewport = null;
28107
28155
  this._inverseProjectionMatrix = null;
28108
- this._lastAspectSize = null;
28109
28156
  this._invViewProjMat = null;
28110
28157
  };
28111
28158
  _proto._updatePixelViewport = function _updatePixelViewport() {
28112
- var _this__renderTarget, _this__renderTarget1;
28159
+ var width, height;
28160
+ var renderTarget = this._renderTarget;
28161
+ if (renderTarget) {
28162
+ width = renderTarget.width;
28163
+ height = renderTarget.height;
28164
+ } else {
28165
+ var canvas = this.engine.canvas;
28166
+ width = canvas.width;
28167
+ height = canvas.height;
28168
+ }
28113
28169
  var viewport = this._viewport;
28114
- var _this__renderTarget_width;
28115
- var width = (_this__renderTarget_width = (_this__renderTarget = this._renderTarget) == null ? void 0 : _this__renderTarget.width) != null ? _this__renderTarget_width : this.engine.canvas.width;
28116
- var _this__renderTarget_height;
28117
- var height = (_this__renderTarget_height = (_this__renderTarget1 = this._renderTarget) == null ? void 0 : _this__renderTarget1.height) != null ? _this__renderTarget_height : this.engine.canvas.height;
28118
28170
  this._pixelViewport.set(viewport.x * width, viewport.y * height, viewport.z * width, viewport.w * height);
28119
28171
  };
28120
28172
  _proto._projMatChange = function _projMatChange() {
@@ -28161,6 +28213,11 @@
28161
28213
  }
28162
28214
  return this._inverseProjectionMatrix;
28163
28215
  };
28216
+ _proto._onPixelViewportChanged = function _onPixelViewportChanged() {
28217
+ this._updatePixelViewport();
28218
+ var _this__customAspectRatio;
28219
+ (_this__customAspectRatio = this._customAspectRatio) != null ? _this__customAspectRatio : this._projMatChange();
28220
+ };
28164
28221
  _create_class$3(Camera1, [
28165
28222
  {
28166
28223
  key: "shaderData",
@@ -28234,8 +28291,6 @@
28234
28291
  if (value !== this._viewport) {
28235
28292
  this._viewport.copyFrom(value);
28236
28293
  }
28237
- this._projMatChange();
28238
- this._updatePixelViewport();
28239
28294
  }
28240
28295
  },
28241
28296
  {
@@ -28308,13 +28363,10 @@
28308
28363
  get: function get() {
28309
28364
  var virtualCamera = this._virtualCamera;
28310
28365
  var projectionMatrix = virtualCamera.projectionMatrix;
28311
- var canvas = this._entity.engine.canvas;
28312
- if ((!this._isProjectionDirty || this._isProjMatSetting) && this._lastAspectSize.x === canvas.width && this._lastAspectSize.y === canvas.height) {
28366
+ if (!this._isProjectionDirty || this._isProjMatSetting) {
28313
28367
  return projectionMatrix;
28314
28368
  }
28315
28369
  this._isProjectionDirty = false;
28316
- this._lastAspectSize.x = canvas.width;
28317
- this._lastAspectSize.y = canvas.height;
28318
28370
  var aspectRatio = this.aspectRatio;
28319
28371
  if (!virtualCamera.isOrthographic) {
28320
28372
  Matrix.perspective(MathUtil$1.degreeToRadian(this._fieldOfView), aspectRatio, this._nearClipPlane, this._farClipPlane, projectionMatrix);
@@ -28360,7 +28412,7 @@
28360
28412
  (_value = value) == null ? void 0 : _value._addReferCount(1);
28361
28413
  (_this__renderTarget = this._renderTarget) == null ? void 0 : _this__renderTarget._addReferCount(-1);
28362
28414
  this._renderTarget = value;
28363
- this._updatePixelViewport();
28415
+ this._onPixelViewportChanged();
28364
28416
  }
28365
28417
  }
28366
28418
  }
@@ -28409,12 +28461,12 @@
28409
28461
  __decorate$1([
28410
28462
  deepClone
28411
28463
  ], exports.Camera.prototype, "_inverseProjectionMatrix", void 0);
28412
- __decorate$1([
28413
- deepClone
28414
- ], exports.Camera.prototype, "_lastAspectSize", void 0);
28415
28464
  __decorate$1([
28416
28465
  deepClone
28417
28466
  ], exports.Camera.prototype, "_invViewProjMat", void 0);
28467
+ __decorate$1([
28468
+ ignoreClone
28469
+ ], exports.Camera.prototype, "_onPixelViewportChanged", null);
28418
28470
  exports.Camera = __decorate$1([
28419
28471
  dependentComponents(Transform, exports.DependentMode.CheckOnly)
28420
28472
  ], exports.Camera);
@@ -35459,6 +35511,7 @@
35459
35511
  Burst: Burst,
35460
35512
  get Camera () { return exports.Camera; },
35461
35513
  get CameraClearFlags () { return exports.CameraClearFlags; },
35514
+ Canvas: Canvas,
35462
35515
  CapsuleColliderShape: CapsuleColliderShape,
35463
35516
  CharacterController: CharacterController,
35464
35517
  CircleShape: CircleShape,
@@ -35716,6 +35769,26 @@
35716
35769
  if (staticProps) _defineProperties$2(Constructor, staticProps);
35717
35770
  return Constructor;
35718
35771
  }
35772
+ function _set_prototype_of$1(o, p) {
35773
+ _set_prototype_of$1 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
35774
+ o.__proto__ = p;
35775
+ return o;
35776
+ };
35777
+ return _set_prototype_of$1(o, p);
35778
+ }
35779
+ function _inherits$1(subClass, superClass) {
35780
+ if (typeof superClass !== "function" && superClass !== null) {
35781
+ throw new TypeError("Super expression must either be null or a function");
35782
+ }
35783
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
35784
+ constructor: {
35785
+ value: subClass,
35786
+ writable: true,
35787
+ configurable: true
35788
+ }
35789
+ });
35790
+ if (superClass) _set_prototype_of$1(subClass, superClass);
35791
+ }
35719
35792
  function _instanceof1$1(left, right) {
35720
35793
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
35721
35794
  return !!right[Symbol.hasInstance](left);
@@ -35723,15 +35796,19 @@
35723
35796
  }
35724
35797
  /**
35725
35798
  * The canvas used on the web, which can support HTMLCanvasElement and OffscreenCanvas.
35726
- */ var WebCanvas = /*#__PURE__*/ function() {
35799
+ */ var WebCanvas = /*#__PURE__*/ function(Canvas1) {
35727
35800
  var WebCanvas = function WebCanvas(webCanvas) {
35728
- this._scale = new Vector2();
35801
+ var _this;
35802
+ _this = Canvas1.call(this) || this;
35803
+ _this._scale = new Vector2();
35729
35804
  var width = webCanvas.width;
35730
35805
  var height = webCanvas.height;
35731
- this._webCanvas = webCanvas;
35732
- this._width = width;
35733
- this._height = height;
35806
+ _this._webCanvas = webCanvas;
35807
+ _this.width = width;
35808
+ _this.height = height;
35809
+ return _this;
35734
35810
  };
35811
+ _inherits$1(WebCanvas, Canvas1);
35735
35812
  var _proto = WebCanvas.prototype;
35736
35813
  /**
35737
35814
  * Resize the rendering size according to the clientWidth and clientHeight of the canvas.
@@ -35752,35 +35829,11 @@
35752
35829
  this._scale.set(x, y);
35753
35830
  this.scale = this._scale;
35754
35831
  };
35832
+ _proto._onSizeChanged = function _onSizeChanged(width, height) {
35833
+ this._webCanvas.width = width;
35834
+ this._webCanvas.height = height;
35835
+ };
35755
35836
  _create_class$2(WebCanvas, [
35756
- {
35757
- key: "width",
35758
- get: /**
35759
- * @inheritdoc
35760
- */ function get() {
35761
- return this._width;
35762
- },
35763
- set: function set(value) {
35764
- if (this._width !== value) {
35765
- this._webCanvas.width = value;
35766
- this._width = value;
35767
- }
35768
- }
35769
- },
35770
- {
35771
- key: "height",
35772
- get: /**
35773
- * @inheritdoc
35774
- */ function get() {
35775
- return this._height;
35776
- },
35777
- set: function set(value) {
35778
- if (this._height !== value) {
35779
- this._webCanvas.height = value;
35780
- this._height = value;
35781
- }
35782
- }
35783
- },
35784
35837
  {
35785
35838
  key: "scale",
35786
35839
  get: /**
@@ -35803,27 +35856,7 @@
35803
35856
  }
35804
35857
  ]);
35805
35858
  return WebCanvas;
35806
- }();
35807
- function _set_prototype_of$1(o, p) {
35808
- _set_prototype_of$1 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
35809
- o.__proto__ = p;
35810
- return o;
35811
- };
35812
- return _set_prototype_of$1(o, p);
35813
- }
35814
- function _inherits$1(subClass, superClass) {
35815
- if (typeof superClass !== "function" && superClass !== null) {
35816
- throw new TypeError("Super expression must either be null or a function");
35817
- }
35818
- subClass.prototype = Object.create(superClass && superClass.prototype, {
35819
- constructor: {
35820
- value: subClass,
35821
- writable: true,
35822
- configurable: true
35823
- }
35824
- });
35825
- if (superClass) _set_prototype_of$1(subClass, superClass);
35826
- }
35859
+ }(Canvas);
35827
35860
  /**
35828
35861
  * WebGL platform engine,support includes WebGL1.0 and WebGL2.0.
35829
35862
  */ var WebGLEngine = /*#__PURE__*/ function(Engine1) {
@@ -44045,7 +44078,7 @@
44045
44078
  ], GALACEAN_animation_event);
44046
44079
 
44047
44080
  //@ts-ignore
44048
- var version = "1.1.0-beta.39";
44081
+ var version = "1.1.0-beta.43";
44049
44082
  console.log("Galacean engine version: " + version);
44050
44083
  for(var key in CoreObjects){
44051
44084
  Loader.registerClass(key, CoreObjects[key]);
@@ -44081,6 +44114,7 @@
44081
44114
  exports.BufferMesh = BufferMesh;
44082
44115
  exports.BufferUtil = BufferUtil;
44083
44116
  exports.Burst = Burst;
44117
+ exports.Canvas = Canvas;
44084
44118
  exports.CapsuleColliderShape = CapsuleColliderShape;
44085
44119
  exports.CharacterController = CharacterController;
44086
44120
  exports.CircleShape = CircleShape;