@galacean/engine 1.4.12 → 1.4.13

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
@@ -10812,6 +10812,7 @@
10812
10812
  }
10813
10813
  this._renderPipeline.render(context, cubeFace, mipLevel, ignoreClearFlags);
10814
10814
  engine._renderCount++;
10815
+ context.camera = null;
10815
10816
  };
10816
10817
  _proto.setReplacementShader = function setReplacementShader(shader, replacementTag, failureStrategy) {
10817
10818
  if (failureStrategy === void 0) failureStrategy = ReplacementFailureStrategy.KeepOriginalShader;
@@ -13312,6 +13313,28 @@
13312
13313
  */ Shader.find = function find(name) {
13313
13314
  return Shader._shaderMap[name];
13314
13315
  };
13316
+ /**
13317
+ * @internal
13318
+ */ Shader._clear = function _clear(engine) {
13319
+ var shaderMap = Shader._shaderMap;
13320
+ for(var key in shaderMap){
13321
+ var shader = shaderMap[key];
13322
+ var subShaders = shader._subShaders;
13323
+ for(var i = 0, n = subShaders.length; i < n; i++){
13324
+ var passes = subShaders[i].passes;
13325
+ for(var j = 0, m = passes.length; j < m; j++){
13326
+ var pass = passes[j];
13327
+ var passShaderProgramPools = pass._shaderProgramPools;
13328
+ for(var k = passShaderProgramPools.length - 1; k >= 0; k--){
13329
+ var shaderProgramPool = passShaderProgramPools[k];
13330
+ if (shaderProgramPool.engine !== engine) continue;
13331
+ shaderProgramPool._destroy();
13332
+ passShaderProgramPools.splice(k, 1);
13333
+ }
13334
+ }
13335
+ }
13336
+ }
13337
+ };
13315
13338
  Shader._applyConstRenderStates = function _applyConstRenderStates(renderState, key, value) {
13316
13339
  switch(key){
13317
13340
  case RenderStateElementKey.BlendStateEnabled0:
@@ -13756,6 +13779,7 @@
13756
13779
  program.uploadUnGroupTextures();
13757
13780
  (pass._renderState || blitMaterial.renderState)._applyStates(engine, false, pass._renderStateDataMap, blitMaterial.shaderData);
13758
13781
  rhi.drawPrimitive(blitMesh._primitive, blitMesh.subMesh, program);
13782
+ rendererShaderData.setTexture(Blitter._blitTextureProperty, null);
13759
13783
  };
13760
13784
  return Blitter;
13761
13785
  }();
@@ -15748,7 +15772,6 @@
15748
15772
  * @internal
15749
15773
  */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
15750
15774
  Renderer.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
15751
- target._assembler.resetData(target);
15752
15775
  target.sprite = this._sprite;
15753
15776
  target.drawMode = this._drawMode;
15754
15777
  };
@@ -16102,7 +16125,7 @@
16102
16125
  ignoreClone
16103
16126
  ], SpriteRenderer.prototype, "_drawMode", void 0);
16104
16127
  __decorate$1([
16105
- assignmentClone
16128
+ ignoreClone
16106
16129
  ], SpriteRenderer.prototype, "_assembler", void 0);
16107
16130
  __decorate$1([
16108
16131
  assignmentClone
@@ -22472,7 +22495,7 @@
22472
22495
  if (oldParent != null) {
22473
22496
  Entity._removeFromChildren(oldParent._children, this);
22474
22497
  this._parent = null;
22475
- this._dispatchModify(EntityModifyFlags.Child, oldParent);
22498
+ oldParent._dispatchModify(EntityModifyFlags.Child, oldParent);
22476
22499
  }
22477
22500
  };
22478
22501
  /**
@@ -22526,6 +22549,7 @@
22526
22549
  this._removeFromParent();
22527
22550
  this._parent = parent;
22528
22551
  if (parent) {
22552
+ this._isRoot = false;
22529
22553
  parent._addToChildrenList(siblingIndex, this);
22530
22554
  var oldScene = this._scene;
22531
22555
  var parentScene = parent._scene;
@@ -22637,7 +22661,6 @@
22637
22661
  }
22638
22662
  }
22639
22663
  }
22640
- this._dispatchModify(EntityModifyFlags.Child, this);
22641
22664
  };
22642
22665
  /**
22643
22666
  * @deprecated
@@ -22822,7 +22845,13 @@
22822
22845
  if (this._siblingIndex === -1) {
22823
22846
  throw "The entity " + this.name + " is not in the hierarchy";
22824
22847
  }
22825
- this._setSiblingIndex(this._isRoot ? this._scene._rootEntities : this._parent._children, value);
22848
+ if (this._isRoot) {
22849
+ this._setSiblingIndex(this._scene._rootEntities, value);
22850
+ } else {
22851
+ var parent = this._parent;
22852
+ this._setSiblingIndex(parent._children, value);
22853
+ parent._dispatchModify(EntityModifyFlags.Child, parent);
22854
+ }
22826
22855
  }
22827
22856
  }
22828
22857
  ]);
@@ -23299,6 +23328,11 @@
23299
23328
  var _proto = BasicResources.prototype;
23300
23329
  /**
23301
23330
  * @internal
23331
+ */ _proto._getBlinnPhongMaterial = function _getBlinnPhongMaterial() {
23332
+ return this._blinnPhongMaterial || (this._blinnPhongMaterial = new BlinnPhongMaterial(this.engine));
23333
+ };
23334
+ /**
23335
+ * @internal
23302
23336
  */ _proto._initialize = function _initialize() {
23303
23337
  var _this = this;
23304
23338
  return new Promise(function(resolve, reject) {
@@ -24595,7 +24629,6 @@
24595
24629
  };
24596
24630
  _proto._loadSingleItem = function _loadSingleItem(itemOrURL) {
24597
24631
  var _this = this;
24598
- var _this__virtualPathResourceMap_assetBaseURL;
24599
24632
  var item = this._assignDefaultOptions(typeof itemOrURL === "string" ? {
24600
24633
  url: itemOrURL
24601
24634
  } : itemOrURL);
@@ -24605,9 +24638,10 @@
24605
24638
  // Parse url
24606
24639
  var _this__parseURL = this._parseURL(url), assetBaseURL = _this__parseURL.assetBaseURL, queryPath = _this__parseURL.queryPath;
24607
24640
  var paths = queryPath ? this._parseQueryPath(queryPath) : [];
24608
- var _this__virtualPathResourceMap_assetBaseURL_path;
24609
24641
  // Get remote asset base url
24610
- var remoteAssetBaseURL = (_this__virtualPathResourceMap_assetBaseURL_path = (_this__virtualPathResourceMap_assetBaseURL = this._virtualPathResourceMap[assetBaseURL]) == null ? void 0 : _this__virtualPathResourceMap_assetBaseURL.path) != null ? _this__virtualPathResourceMap_assetBaseURL_path : assetBaseURL;
24642
+ var remoteConfig = this._virtualPathResourceMap[assetBaseURL];
24643
+ var _remoteConfig_path;
24644
+ var remoteAssetBaseURL = (_remoteConfig_path = remoteConfig == null ? void 0 : remoteConfig.path) != null ? _remoteConfig_path : assetBaseURL;
24611
24645
  // Check cache
24612
24646
  var cacheObject = this._assetUrlPool[remoteAssetBaseURL];
24613
24647
  if (cacheObject) {
@@ -24641,15 +24675,20 @@
24641
24675
  if (!loader) {
24642
24676
  throw "loader not found: " + item.type;
24643
24677
  }
24678
+ var subpackageName = remoteConfig == null ? void 0 : remoteConfig.subpackageName;
24644
24679
  // Check sub asset
24645
24680
  if (queryPath) {
24646
24681
  // Check whether load main asset
24647
- var mainPromise = loadingPromises[remoteAssetBaseURL] || this._loadMainAsset(loader, item, remoteAssetBaseURL, assetBaseURL);
24682
+ var mainPromise = loadingPromises[remoteAssetBaseURL] || this._loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL, assetBaseURL, subpackageName);
24648
24683
  mainPromise.catch(function(e) {
24649
24684
  _this._onSubAssetFail(remoteAssetBaseURL, queryPath, e);
24650
24685
  });
24651
24686
  return this._createSubAssetPromiseCallback(remoteAssetBaseURL, remoteAssetURL, queryPath);
24652
24687
  }
24688
+ return this._loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL, assetBaseURL, subpackageName);
24689
+ };
24690
+ // For adapter mini-game platform
24691
+ _proto._loadSubpackageAndMainAsset = function _loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL, assetBaseURL, subpackageName) {
24653
24692
  return this._loadMainAsset(loader, item, remoteAssetBaseURL, assetBaseURL);
24654
24693
  };
24655
24694
  _proto._loadMainAsset = function _loadMainAsset(loader, item, remoteAssetBaseURL, assetBaseURL) {
@@ -25770,16 +25809,24 @@
25770
25809
  }
25771
25810
  return shape.collider.entity.layer & layerMask && shape.isSceneQuery;
25772
25811
  };
25812
+ var outIDX;
25813
+ var outDistance;
25814
+ var outPosition;
25815
+ var outNormal;
25773
25816
  if (hitResult != undefined) {
25774
25817
  var result = this._nativePhysicsScene.raycast(ray, distance, onRaycast, function(idx, distance, position, normal) {
25775
- var hitShape = Engine._physicalObjectsMap[idx];
25776
- hitResult.entity = hitShape._collider.entity;
25777
- hitResult.shape = hitShape;
25778
- hitResult.distance = distance;
25779
- hitResult.normal.copyFrom(normal);
25780
- hitResult.point.copyFrom(position);
25818
+ outIDX = idx;
25819
+ outDistance = distance;
25820
+ outPosition = position;
25821
+ outNormal = normal;
25781
25822
  });
25782
25823
  if (result) {
25824
+ var hitShape = Engine._physicalObjectsMap[outIDX];
25825
+ hitResult.entity = hitShape._collider.entity;
25826
+ hitResult.shape = hitShape;
25827
+ hitResult.distance = outDistance;
25828
+ hitResult.point.copyFrom(outPosition);
25829
+ hitResult.normal.copyFrom(outNormal);
25783
25830
  return true;
25784
25831
  } else {
25785
25832
  hitResult.entity = null;
@@ -28069,7 +28116,7 @@
28069
28116
  }
28070
28117
  pointer = pointerPool[j];
28071
28118
  if (!pointer) {
28072
- pointer = new Pointer(j);
28119
+ pointer = pointerPool[j] = new Pointer(j);
28073
28120
  engine._physicsInitialized && pointer._addEmitters(PhysicsPointerEventEmitter, eventPool);
28074
28121
  PointerManager._pointerEventEmitters.forEach(function(emitter) {
28075
28122
  pointer._addEmitters(emitter, eventPool);
@@ -29382,15 +29429,16 @@
29382
29429
  Matrix.multiply(virtualCamera.projectionMatrix, virtualCamera.viewMatrix, virtualCamera.viewProjectionMatrix);
29383
29430
  renderContext.applyVirtualCamera(virtualCamera, false);
29384
29431
  renderContext.rendererUpdateFlag |= ContextRendererUpdateFlag.ProjectionMatrix;
29385
- uiRenderQueue.clear();
29386
29432
  uiCanvas._prepareRender(renderContext);
29387
29433
  uiRenderQueue.pushRenderElement(uiCanvas._renderElement);
29388
29434
  uiRenderQueue.batch(batcherManager);
29389
29435
  batcherManager.uploadBuffer();
29390
29436
  uiRenderQueue.render(renderContext, "Forward");
29437
+ uiRenderQueue.clear();
29391
29438
  engine._renderCount++;
29392
29439
  }
29393
29440
  }
29441
+ renderContext.camera = null;
29394
29442
  };
29395
29443
  return UIUtils;
29396
29444
  }();
@@ -29669,21 +29717,15 @@
29669
29717
  var _this_xrManager;
29670
29718
  this._sceneManager._destroyAllScene();
29671
29719
  this._resourceManager._destroy();
29672
- this._textDefaultFont = null;
29673
- this._fontMap = null;
29674
29720
  this.inputManager._destroy();
29675
29721
  this._batcherManager.destroy();
29676
29722
  (_this_xrManager = this.xrManager) == null ? void 0 : _this_xrManager._destroy();
29677
29723
  this.dispatch("shutdown", this);
29678
29724
  // Cancel animation
29679
29725
  this.pause();
29726
+ Shader._clear(this);
29680
29727
  this._hardwareRenderer.destroy();
29681
29728
  this.removeAllEventListeners();
29682
- this._animate = null;
29683
- this._sceneManager = null;
29684
- this._resourceManager = null;
29685
- this._canvas = null;
29686
- this._time = null;
29687
29729
  this._waitingDestroy = false;
29688
29730
  this._destroyed = true;
29689
29731
  };
@@ -29807,6 +29849,7 @@
29807
29849
  this._hardwareRenderer.resetState();
29808
29850
  this._lastRenderState = new RenderState();
29809
29851
  // Clear shader pools
29852
+ Shader._clear(this);
29810
29853
  this._shaderProgramPools.length = 0;
29811
29854
  var resourceManager = this.resourceManager;
29812
29855
  // Restore graphic resources
@@ -30500,24 +30543,23 @@
30500
30543
  };
30501
30544
  _proto.drawMask = function drawMask(context, pipelineStageTagValue, maskLayer) {
30502
30545
  var incrementMaskQueue = MaskManager.getMaskIncrementRenderQueue();
30503
- incrementMaskQueue.clear();
30504
30546
  var decrementMaskQueue = MaskManager.getMaskDecrementRenderQueue();
30505
- decrementMaskQueue.clear();
30506
30547
  this._buildMaskRenderElement(maskLayer, incrementMaskQueue, decrementMaskQueue);
30507
30548
  var batcherManager = context.camera.engine._batcherManager;
30508
30549
  incrementMaskQueue.batch(batcherManager);
30509
30550
  batcherManager.uploadBuffer();
30510
30551
  incrementMaskQueue.render(context, pipelineStageTagValue, RenderQueueMaskType.Increment);
30552
+ incrementMaskQueue.clear();
30511
30553
  decrementMaskQueue.batch(batcherManager);
30512
30554
  batcherManager.uploadBuffer();
30513
30555
  decrementMaskQueue.render(context, pipelineStageTagValue, RenderQueueMaskType.Decrement);
30556
+ decrementMaskQueue.clear();
30514
30557
  };
30515
30558
  _proto.clearMask = function clearMask(context, pipelineStageTagValue) {
30516
30559
  var preMaskLayer = this._preMaskLayer;
30517
30560
  if (preMaskLayer !== SpriteMaskLayer.Nothing) {
30518
30561
  if (this.hasStencilWritten) {
30519
30562
  var decrementMaskQueue = MaskManager.getMaskDecrementRenderQueue();
30520
- decrementMaskQueue.clear();
30521
30563
  var masks = this._allSpriteMasks;
30522
30564
  for(var i = 0, n = masks.length; i < n; i++){
30523
30565
  var mask = masks.get(i);
@@ -30527,6 +30569,7 @@
30527
30569
  decrementMaskQueue.batch(batcherManager);
30528
30570
  batcherManager.uploadBuffer();
30529
30571
  decrementMaskQueue.render(context, pipelineStageTagValue, RenderQueueMaskType.Decrement);
30572
+ decrementMaskQueue.clear();
30530
30573
  } else {
30531
30574
  var engine = context.camera.engine;
30532
30575
  engine._hardwareRenderer.clearRenderTarget(engine, CameraClearFlags.Stencil, null);
@@ -32738,11 +32781,13 @@
32738
32781
  * @param time - The time to sample an animation
32739
32782
  */ _proto._sampleAnimation = function _sampleAnimation(entity, time) {
32740
32783
  var _this = this, curveBindings = _this._curveBindings;
32784
+ var components = AnimationCurveOwner._components;
32741
32785
  for(var i = curveBindings.length - 1; i >= 0; i--){
32742
32786
  var curve = curveBindings[i];
32743
32787
  var targetEntity = entity.findByPath(curve.relativePath);
32744
32788
  if (targetEntity) {
32745
- var component = curve.typeIndex > 0 ? targetEntity.getComponents(curve.type, AnimationCurveOwner._components)[curve.typeIndex] : targetEntity.getComponent(curve.type);
32789
+ var component = curve.typeIndex > 0 ? targetEntity.getComponents(curve.type, components)[curve.typeIndex] : targetEntity.getComponent(curve.type);
32790
+ components.length = 0;
32746
32791
  if (!component) {
32747
32792
  continue;
32748
32793
  }
@@ -34345,13 +34390,15 @@
34345
34390
  var curveLayerOwner = animatorStateData.curveLayerOwner;
34346
34391
  var _animatorState_clip = animatorState.clip, curves = _animatorState_clip._curveBindings;
34347
34392
  var layerCurveOwnerPool = animatorLayerData.curveOwnerPool;
34393
+ var components = AnimationCurveOwner._components;
34348
34394
  for(var i = curves.length - 1; i >= 0; i--){
34349
34395
  var curve = curves[i];
34350
34396
  var relativePath = curve.relativePath;
34351
34397
  var targetEntity = curve.relativePath === "" ? entity : entity.findByPath(curve.relativePath);
34352
34398
  if (targetEntity) {
34353
34399
  var _curveOwnerPool, _instanceId, _propertyOwners, _property, _layerCurveOwnerPool, _instanceId1, _layerPropertyOwners, _property1;
34354
- var component = curve.typeIndex > 0 ? targetEntity.getComponents(curve.type, AnimationCurveOwner._components)[curve.typeIndex] : targetEntity.getComponent(curve.type);
34400
+ var component = curve.typeIndex > 0 ? targetEntity.getComponents(curve.type, components)[curve.typeIndex] : targetEntity.getComponent(curve.type);
34401
+ components.length = 0;
34355
34402
  if (!component) {
34356
34403
  continue;
34357
34404
  }
@@ -47125,17 +47172,14 @@
47125
47172
  GLTFMaterialParser._parseStandardProperty(context, material, materialInfo);
47126
47173
  }
47127
47174
  return Promise.resolve(material).then(function(material) {
47128
- material || (material = GLTFMaterialParser._getDefaultMaterial(engine));
47175
+ // @ts-ignore
47176
+ material || (material = engine._basicResources._getBlinnPhongMaterial());
47129
47177
  GLTFParser.executeExtensionsAdditiveAndParse(materialInfo.extensions, context, material, materialInfo);
47130
47178
  // @ts-ignore
47131
47179
  material._associationSuperResource(glTFResource);
47132
47180
  return material;
47133
47181
  });
47134
47182
  };
47135
- /** @internal */ GLTFMaterialParser._getDefaultMaterial = function _getDefaultMaterial(engine) {
47136
- var _GLTFMaterialParser;
47137
- return (_GLTFMaterialParser = GLTFMaterialParser)._defaultMaterial || (_GLTFMaterialParser._defaultMaterial = new BlinnPhongMaterial(engine));
47138
- };
47139
47183
  /**
47140
47184
  * @internal
47141
47185
  */ GLTFMaterialParser._checkOtherTextureTransform = function _checkOtherTextureTransform(texture, textureName) {
@@ -47547,7 +47591,7 @@
47547
47591
  Promise.all(materialPromises)
47548
47592
  ]).then(function(param) {
47549
47593
  var _loop = function _loop(i) {
47550
- var material = materials[i] || exports.GLTFMaterialParser._getDefaultMaterial(context.glTFResource.engine);
47594
+ var material = materials[i] || basicResources._getBlinnPhongMaterial();
47551
47595
  var glTFPrimitive = glTFMeshPrimitives[i];
47552
47596
  var mesh = meshes[i];
47553
47597
  var renderer = void 0;
@@ -47576,6 +47620,8 @@
47576
47620
  GLTFParser.executeExtensionsAdditiveAndParse(glTFPrimitive.extensions, context, renderer, glTFPrimitive);
47577
47621
  };
47578
47622
  var meshes = param[0], skin = param[1], materials = param[2];
47623
+ // @ts-ignore
47624
+ var basicResources = context.glTFResource.engine._basicResources;
47579
47625
  for(var i = 0; i < rendererCount; i++)_loop(i);
47580
47626
  });
47581
47627
  };
@@ -50053,7 +50099,7 @@
50053
50099
  ], EXT_texture_webp);
50054
50100
 
50055
50101
  //@ts-ignore
50056
- var version = "1.4.12";
50102
+ var version = "1.4.13";
50057
50103
  console.log("Galacean Engine Version: " + version);
50058
50104
  for(var key in CoreObjects){
50059
50105
  Loader.registerClass(key, CoreObjects[key]);