@galacean/engine-core 1.3.25 → 1.3.27

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/main.js CHANGED
@@ -4073,6 +4073,28 @@ __decorate([
4073
4073
  */ Shader.find = function find(name) {
4074
4074
  return Shader._shaderMap[name];
4075
4075
  };
4076
+ /**
4077
+ * @internal
4078
+ */ Shader._clear = function _clear(engine) {
4079
+ var shaderMap = Shader._shaderMap;
4080
+ for(var key in shaderMap){
4081
+ var shader = shaderMap[key];
4082
+ var subShaders = shader._subShaders;
4083
+ for(var i = 0, n = subShaders.length; i < n; i++){
4084
+ var passes = subShaders[i].passes;
4085
+ for(var j = 0, m = passes.length; j < m; j++){
4086
+ var pass = passes[j];
4087
+ var passShaderProgramPools = pass._shaderProgramPools;
4088
+ for(var k = passShaderProgramPools.length - 1; k >= 0; k--){
4089
+ var shaderProgramPool = passShaderProgramPools[k];
4090
+ if (shaderProgramPool.engine !== engine) continue;
4091
+ shaderProgramPool._destroy();
4092
+ passShaderProgramPools.splice(k, 1);
4093
+ }
4094
+ }
4095
+ }
4096
+ }
4097
+ };
4076
4098
  Shader._applyConstRenderStates = function _applyConstRenderStates(renderState, key, value) {
4077
4099
  switch(key){
4078
4100
  case exports.RenderStateDataKey.BlendStateEnabled0:
@@ -8316,6 +8338,7 @@ var /**
8316
8338
  program.uploadUnGroupTextures();
8317
8339
  (pass._renderState || blitMaterial.renderState)._applyStates(engine, false, pass._renderStateDataMap, blitMaterial.shaderData);
8318
8340
  rhi.drawPrimitive(blitMesh._primitive, blitMesh.subMesh, program);
8341
+ rendererShaderData.setTexture(PipelineUtils._blitTextureProperty, null);
8319
8342
  };
8320
8343
  return PipelineUtils;
8321
8344
  }();
@@ -8663,6 +8686,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
8663
8686
  }
8664
8687
  this._renderPipeline.render(context, cubeFace, mipLevel, ignoreClearFlags);
8665
8688
  engine._renderCount++;
8689
+ context.camera = null;
8666
8690
  };
8667
8691
  _proto.setReplacementShader = function setReplacementShader(shader, replacementTag, failureStrategy) {
8668
8692
  if (failureStrategy === void 0) failureStrategy = exports.ReplacementFailureStrategy.KeepOriginalShader;
@@ -9412,17 +9436,20 @@ var ContextRendererUpdateFlag;
9412
9436
  _proto._drawMask = function _drawMask(context, pipelineStageTagValue, master) {
9413
9437
  var incrementMaskQueue = MaskManager.getMaskIncrementRenderQueue();
9414
9438
  incrementMaskQueue.renderQueueType = this.renderQueueType;
9415
- incrementMaskQueue.clear();
9416
9439
  var decrementMaskQueue = MaskManager.getMaskDecrementRenderQueue();
9417
9440
  decrementMaskQueue.renderQueueType = this.renderQueueType;
9418
- decrementMaskQueue.clear();
9419
9441
  var camera = context.camera;
9420
9442
  var engine = camera.engine;
9421
9443
  camera.scene._maskManager.buildMaskRenderElement(master, incrementMaskQueue, decrementMaskQueue);
9444
+ var primitiveChunkManagerMask = engine._batcherManager.primitiveChunkManagerMask;
9422
9445
  incrementMaskQueue._batch(engine._batcherManager);
9446
+ primitiveChunkManagerMask.uploadBuffer();
9423
9447
  incrementMaskQueue.render(context, pipelineStageTagValue, 1);
9448
+ incrementMaskQueue.clear();
9424
9449
  decrementMaskQueue._batch(engine._batcherManager);
9450
+ primitiveChunkManagerMask.uploadBuffer();
9425
9451
  decrementMaskQueue.render(context, pipelineStageTagValue, 2);
9452
+ decrementMaskQueue.clear();
9426
9453
  };
9427
9454
  RenderQueue.compareForOpaque = function compareForOpaque(a, b) {
9428
9455
  return a.priority - b.priority || a.distanceForSort - b.distanceForSort;
@@ -18763,6 +18790,7 @@ __decorate([
18763
18790
  * @internal
18764
18791
  */ var BasicResources = /*#__PURE__*/ function() {
18765
18792
  function BasicResources(engine) {
18793
+ this.engine = engine;
18766
18794
  // prettier-ignore
18767
18795
  var vertices = new Float32Array([
18768
18796
  -1,
@@ -18822,6 +18850,11 @@ __decorate([
18822
18850
  }
18823
18851
  }
18824
18852
  var _proto = BasicResources.prototype;
18853
+ /**
18854
+ * @internal
18855
+ */ _proto._getBlinnPhongMaterial = function _getBlinnPhongMaterial() {
18856
+ return this._blinnPhongMaterial || (this._blinnPhongMaterial = new BlinnPhongMaterial(this.engine));
18857
+ };
18825
18858
  _proto._createBlitMesh = function _createBlitMesh(engine, vertices) {
18826
18859
  var mesh = new ModelMesh(engine);
18827
18860
  mesh._addReferCount(1);
@@ -19577,12 +19610,24 @@ var AssetPromise = /*#__PURE__*/ function() {
19577
19610
  this._onCancelHandler && this._onCancelHandler();
19578
19611
  return this;
19579
19612
  };
19580
- /**
19581
- * Return a new resource Promise through the provided asset promise collection.
19582
- * The resolved of the new AssetPromise will be triggered when all the Promises in the provided set are completed.
19583
- * @param - Promise Collection
19584
- * @returns AssetPromise
19585
- */ AssetPromise.all = function all(promises) {
19613
+ AssetPromise.resolve = function resolve(value) {
19614
+ if (value === undefined) {
19615
+ return new AssetPromise(function(resolve) {
19616
+ return resolve();
19617
+ });
19618
+ } else if (_instanceof(value, AssetPromise) || _instanceof(value, Promise)) {
19619
+ return new AssetPromise(function(resolve, reject) {
19620
+ value.then(function(resolved) {
19621
+ return resolve(resolved);
19622
+ }, reject);
19623
+ });
19624
+ } else {
19625
+ return new AssetPromise(function(resolve) {
19626
+ return resolve(value);
19627
+ });
19628
+ }
19629
+ };
19630
+ AssetPromise.all = function all(values) {
19586
19631
  return new AssetPromise(function(resolve, reject, setTaskCompleteProgress) {
19587
19632
  var onComplete = function onComplete(index, resultValue) {
19588
19633
  completed++;
@@ -19593,7 +19638,7 @@ var AssetPromise = /*#__PURE__*/ function() {
19593
19638
  }
19594
19639
  };
19595
19640
  var onProgress = function onProgress(promise, index) {
19596
- if (_instanceof(promise, Promise) || _instanceof(promise, AssetPromise)) {
19641
+ if (_instanceof(promise, AssetPromise) || _instanceof(promise, Promise)) {
19597
19642
  promise.then(function(value) {
19598
19643
  onComplete(index, value);
19599
19644
  }, reject);
@@ -19603,14 +19648,14 @@ var AssetPromise = /*#__PURE__*/ function() {
19603
19648
  });
19604
19649
  }
19605
19650
  };
19606
- var count = promises.length;
19651
+ var count = Array.from(values).length;
19607
19652
  var results = new Array(count);
19608
19653
  var completed = 0;
19609
19654
  if (count === 0) {
19610
19655
  return resolve(results);
19611
19656
  }
19612
19657
  for(var i = 0; i < count; i++){
19613
- onProgress(promises[i], i);
19658
+ onProgress(values[i], i);
19614
19659
  }
19615
19660
  });
19616
19661
  };
@@ -20192,12 +20237,12 @@ var MultiExecutor = /*#__PURE__*/ function() {
20192
20237
  var obj = this._objectPool[refId];
20193
20238
  var promise;
20194
20239
  if (obj) {
20195
- promise = Promise.resolve(obj);
20240
+ promise = AssetPromise.resolve(obj);
20196
20241
  } else {
20197
20242
  var resourceConfig = this._editorResourceConfig[refId];
20198
20243
  if (!resourceConfig) {
20199
- Logger.warn("refId:" + refId + " is not find in this._editorResourceConfig.");
20200
- return Promise.resolve(null);
20244
+ Logger.warn("refId:" + refId + " is not find in this._idResourceMap.");
20245
+ return AssetPromise.resolve(null);
20201
20246
  }
20202
20247
  var url = resourceConfig.virtualPath;
20203
20248
  if (key) {
@@ -21153,16 +21198,24 @@ var Collision = function Collision() {
21153
21198
  }
21154
21199
  return shape.collider.entity.layer & layerMask && shape.isSceneQuery;
21155
21200
  };
21201
+ var outIDX;
21202
+ var outDistance;
21203
+ var outPosition;
21204
+ var outNormal;
21156
21205
  if (hitResult != undefined) {
21157
21206
  var result = this._nativePhysicsScene.raycast(ray, distance, onRaycast, function(idx, distance, position, normal) {
21158
- var hitShape = _this._scene.engine._physicalObjectsMap[idx];
21159
- hitResult.entity = hitShape._collider.entity;
21160
- hitResult.shape = hitShape;
21161
- hitResult.distance = distance;
21162
- hitResult.normal.copyFrom(normal);
21163
- hitResult.point.copyFrom(position);
21207
+ outIDX = idx;
21208
+ outDistance = distance;
21209
+ outPosition = position;
21210
+ outNormal = normal;
21164
21211
  });
21165
21212
  if (result) {
21213
+ var hitShape = this._scene.engine._physicalObjectsMap[outIDX];
21214
+ hitResult.entity = hitShape._collider.entity;
21215
+ hitResult.shape = hitShape;
21216
+ hitResult.distance = outDistance;
21217
+ hitResult.point.copyFrom(outPosition);
21218
+ hitResult.normal.copyFrom(outNormal);
21166
21219
  return true;
21167
21220
  } else {
21168
21221
  hitResult.entity = null;
@@ -23886,21 +23939,15 @@ ShaderPool.init();
23886
23939
  var _this_xrManager;
23887
23940
  this._sceneManager._destroyAllScene();
23888
23941
  this._resourceManager._destroy();
23889
- this._textDefaultFont = null;
23890
- this._fontMap = null;
23891
23942
  this.inputManager._destroy();
23892
23943
  this._batcherManager.destroy();
23893
23944
  (_this_xrManager = this.xrManager) == null ? void 0 : _this_xrManager._destroy();
23894
23945
  this.dispatch("shutdown", this);
23895
23946
  // Cancel animation
23896
23947
  this.pause();
23948
+ Shader._clear(this);
23897
23949
  this._hardwareRenderer.destroy();
23898
23950
  this.removeAllEventListeners();
23899
- this._animate = null;
23900
- this._sceneManager = null;
23901
- this._resourceManager = null;
23902
- this._canvas = null;
23903
- this._time = null;
23904
23951
  this._waitingDestroy = false;
23905
23952
  this._destroyed = true;
23906
23953
  };
@@ -24068,6 +24115,7 @@ ShaderPool.init();
24068
24115
  this._hardwareRenderer.resetState();
24069
24116
  this._lastRenderState = new RenderState();
24070
24117
  // Clear shader pools
24118
+ Shader._clear(this);
24071
24119
  this._shaderProgramPools.length = 0;
24072
24120
  var resourceManager = this.resourceManager;
24073
24121
  // Restore graphic resources
@@ -27187,11 +27235,13 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
27187
27235
  * @param time - The time to sample an animation
27188
27236
  */ _proto._sampleAnimation = function _sampleAnimation(entity, time) {
27189
27237
  var _this = this, curveBindings = _this._curveBindings;
27238
+ var components = AnimationCurveOwner._components;
27190
27239
  for(var i = curveBindings.length - 1; i >= 0; i--){
27191
27240
  var curve = curveBindings[i];
27192
27241
  var targetEntity = entity.findByPath(curve.relativePath);
27193
27242
  if (targetEntity) {
27194
- var component = curve.typeIndex > 0 ? targetEntity.getComponents(curve.type, AnimationCurveOwner._components)[curve.typeIndex] : targetEntity.getComponent(curve.type);
27243
+ var component = curve.typeIndex > 0 ? targetEntity.getComponents(curve.type, components)[curve.typeIndex] : targetEntity.getComponent(curve.type);
27244
+ components.length = 0;
27195
27245
  if (!component) {
27196
27246
  continue;
27197
27247
  }
@@ -28806,13 +28856,15 @@ exports.AnimatorLayerBlendingMode = void 0;
28806
28856
  var curveLayerOwner = animatorStateData.curveLayerOwner;
28807
28857
  var _animatorState_clip = animatorState.clip, curves = _animatorState_clip._curveBindings;
28808
28858
  var layerCurveOwnerPool = animatorLayerData.curveOwnerPool;
28859
+ var components = AnimationCurveOwner._components;
28809
28860
  for(var i = curves.length - 1; i >= 0; i--){
28810
28861
  var curve = curves[i];
28811
28862
  var relativePath = curve.relativePath;
28812
28863
  var targetEntity = curve.relativePath === "" ? entity : entity.findByPath(curve.relativePath);
28813
28864
  if (targetEntity) {
28814
28865
  var _curveOwnerPool, _instanceId, _propertyOwners, _property, _layerCurveOwnerPool, _instanceId1, _layerPropertyOwners, _property1;
28815
- var component = curve.typeIndex > 0 ? targetEntity.getComponents(curve.type, AnimationCurveOwner._components)[curve.typeIndex] : targetEntity.getComponent(curve.type);
28866
+ var component = curve.typeIndex > 0 ? targetEntity.getComponents(curve.type, components)[curve.typeIndex] : targetEntity.getComponent(curve.type);
28867
+ components.length = 0;
28816
28868
  if (!component) {
28817
28869
  continue;
28818
28870
  }