@galacean/engine 1.5.14 → 1.6.0-alpha.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
@@ -5599,6 +5599,7 @@
5599
5599
  /** RGB compressed format, 4 bits per pixel. */ TextureFormat[TextureFormat["BC1"] = 10] = "BC1";
5600
5600
  /** RGBA compressed format, 8 bits per pixel. */ TextureFormat[TextureFormat["BC3"] = 11] = "BC3";
5601
5601
  /** RGB(A) compressed format, 128 bits per 4x4 pixel block. */ TextureFormat[TextureFormat["BC7"] = 12] = "BC7";
5602
+ /** RGB HDR compressed format, 8 bits per pixel. */ TextureFormat[TextureFormat["BC6H"] = 100] = "BC6H";
5602
5603
  /** RGB compressed format, 4 bits per pixel. */ TextureFormat[TextureFormat["ETC1_RGB"] = 13] = "ETC1_RGB";
5603
5604
  /** RGB compressed format, 4 bits per pixel. */ TextureFormat[TextureFormat["ETC2_RGB"] = 14] = "ETC2_RGB";
5604
5605
  /** RGBA compressed format, 5 bits per pixel, 4 bit in RGB, 1 bit in A. */ TextureFormat[TextureFormat["ETC2_RGBA5"] = 15] = "ETC2_RGBA5";
@@ -5767,6 +5768,7 @@
5767
5768
  GLCapabilityType["fragDepth"] = "EXT_frag_depth";
5768
5769
  GLCapabilityType["astc"] = "WEBGL_compressed_texture_astc";
5769
5770
  GLCapabilityType["astc_webkit"] = "WEBKIT_WEBGL_compressed_texture_astc";
5771
+ GLCapabilityType["astc_hdr"] = "WEBGL_compressed_texture_astc_hdr";
5770
5772
  GLCapabilityType["etc"] = "WEBGL_compressed_texture_etc";
5771
5773
  GLCapabilityType["etc_webkit"] = "WEBKIT_WEBGL_compressed_texture_etc";
5772
5774
  GLCapabilityType["etc1"] = "WEBGL_compressed_texture_etc1";
@@ -5882,12 +5884,19 @@
5882
5884
  });
5883
5885
  };
5884
5886
  /**
5885
- * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
5886
- * resolved value cannot be modified from the callback.
5887
- * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
5888
- * @returns A Promise for the completion of the callback.
5887
+ * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected).
5888
+ * The callback result is ignored and the original value/reason is preserved per Promise spec.
5889
+ * Returns an AssetPromise to keep chainability with AssetPromise methods.
5890
+ * @param onFinally - The callback to execute when the Promise is settled.
5891
+ * @returns An AssetPromise for the completion of the callback.
5889
5892
  */ _proto.finally = function _finally(onFinally) {
5890
- return this._promise.finally(onFinally);
5893
+ return this.then(function(value) {
5894
+ onFinally == null ? void 0 : onFinally();
5895
+ return value;
5896
+ }, function(reason) {
5897
+ onFinally == null ? void 0 : onFinally();
5898
+ throw reason;
5899
+ });
5891
5900
  };
5892
5901
  /**
5893
5902
  * Cancel promise request.
@@ -10301,7 +10310,6 @@
10301
10310
  // Create program and link shader
10302
10311
  var program = gl.createProgram();
10303
10312
  if (!program) {
10304
- console.warn("Context lost while create program.");
10305
10313
  return null;
10306
10314
  }
10307
10315
  gl.attachShader(program, vertexShader);
@@ -10321,7 +10329,6 @@
10321
10329
  var gl = this._gl;
10322
10330
  var shader = gl.createShader(shaderType);
10323
10331
  if (!shader) {
10324
- console.warn("Context lost while create shader.");
10325
10332
  return null;
10326
10333
  }
10327
10334
  gl.shaderSource(shader, shaderSource);
@@ -10489,7 +10496,9 @@
10489
10496
  _proto._getUniformInfos = function _getUniformInfos() {
10490
10497
  var gl = this._gl;
10491
10498
  var program = this._glProgram;
10492
- var uniformCount = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
10499
+ var _gl_getProgramParameter;
10500
+ // uniformCount is `null` when context lost.
10501
+ var uniformCount = (_gl_getProgramParameter = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS)) != null ? _gl_getProgramParameter : 0;
10493
10502
  var uniformInfos = new Array(uniformCount);
10494
10503
  for(var i = 0; i < uniformCount; ++i){
10495
10504
  var info = gl.getActiveUniform(program, i);
@@ -10501,7 +10510,9 @@
10501
10510
  var gl = this._gl;
10502
10511
  var program = this._glProgram;
10503
10512
  var attributeInfos = new Array();
10504
- var attributeCount = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
10513
+ var _gl_getProgramParameter;
10514
+ // attributeCount is `null` when context lost.
10515
+ var attributeCount = (_gl_getProgramParameter = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES)) != null ? _gl_getProgramParameter : 0;
10505
10516
  for(var i = 0; i < attributeCount; ++i){
10506
10517
  var info = gl.getActiveAttrib(program, i);
10507
10518
  attributeInfos[i] = info;
@@ -12728,22 +12739,59 @@
12728
12739
  target._rotation.copyFrom(this.rotation);
12729
12740
  target._scale.copyFrom(this.scale);
12730
12741
  };
12731
- _proto._onDestroy = function _onDestroy() {
12732
- Component.prototype._onDestroy.call(this);
12733
- //@ts-ignore
12734
- this._worldPosition._onValueChanged = null;
12735
- //@ts-ignore
12736
- this._rotation._onValueChanged = null;
12737
- //@ts-ignore
12738
- this._worldRotation._onValueChanged = null;
12739
- //@ts-ignore
12740
- this._rotationQuaternion._onValueChanged = null;
12741
- //@ts-ignore
12742
- this._worldRotationQuaternion._onValueChanged = null;
12743
- //@ts-ignore
12744
- this._position._onValueChanged = null;
12745
- //@ts-ignore
12746
- this._scale._onValueChanged = null;
12742
+ _proto._onWorldMatrixChange = function _onWorldMatrixChange() {
12743
+ this._setDirtyFlagFalse(128);
12744
+ };
12745
+ _proto._isContainDirtyFlags = function _isContainDirtyFlags(targetDirtyFlags) {
12746
+ return (this._dirtyFlag & targetDirtyFlags) === targetDirtyFlags;
12747
+ };
12748
+ _proto._isContainDirtyFlag = function _isContainDirtyFlag(type) {
12749
+ return (this._dirtyFlag & type) != 0;
12750
+ };
12751
+ _proto._setDirtyFlagTrue = function _setDirtyFlagTrue(type) {
12752
+ this._dirtyFlag |= type;
12753
+ };
12754
+ _proto._setDirtyFlagFalse = function _setDirtyFlagFalse(type) {
12755
+ this._dirtyFlag &= ~type;
12756
+ };
12757
+ _proto._worldAssociatedChange = function _worldAssociatedChange(type) {
12758
+ var dispatchFlags = type & ~this._dirtyFlag;
12759
+ this._dirtyFlag |= type;
12760
+ this._entity._updateFlagManager.dispatch(dispatchFlags);
12761
+ };
12762
+ _proto._getParentTransform = function _getParentTransform() {
12763
+ if (!this._isParentDirty) {
12764
+ return this._parentTransformCache;
12765
+ }
12766
+ var parentCache = null;
12767
+ var parent = this._entity.parent;
12768
+ while(parent){
12769
+ var transform = parent.transform;
12770
+ if (transform) {
12771
+ parentCache = transform;
12772
+ break;
12773
+ } else {
12774
+ parent = parent.parent;
12775
+ }
12776
+ }
12777
+ this._parentTransformCache = parentCache;
12778
+ this._isParentDirty = false;
12779
+ return parentCache;
12780
+ };
12781
+ _proto._onPositionChanged = function _onPositionChanged() {
12782
+ this._setDirtyFlagTrue(64);
12783
+ this._updateWorldPositionFlag();
12784
+ };
12785
+ _proto._onWorldPositionChanged = function _onWorldPositionChanged() {
12786
+ var worldPosition = this._worldPosition;
12787
+ var parent = this._getParentTransform();
12788
+ if (parent) {
12789
+ Matrix.invert(parent.worldMatrix, Transform._tempMat41);
12790
+ Vector3.transformCoordinate(worldPosition, Transform._tempMat41, this._position);
12791
+ } else {
12792
+ this._position.copyFrom(worldPosition);
12793
+ }
12794
+ this._setDirtyFlagFalse(4);
12747
12795
  };
12748
12796
  /**
12749
12797
  * Get worldMatrix: Will trigger the worldMatrix update of itself and all parent entities.
@@ -12845,25 +12893,6 @@
12845
12893
  }
12846
12894
  }
12847
12895
  };
12848
- _proto._getParentTransform = function _getParentTransform() {
12849
- if (!this._isParentDirty) {
12850
- return this._parentTransformCache;
12851
- }
12852
- var parentCache = null;
12853
- var parent = this._entity.parent;
12854
- while(parent){
12855
- var transform = parent.transform;
12856
- if (transform) {
12857
- parentCache = transform;
12858
- break;
12859
- } else {
12860
- parent = parent.parent;
12861
- }
12862
- }
12863
- this._parentTransformCache = parentCache;
12864
- this._isParentDirty = false;
12865
- return parentCache;
12866
- };
12867
12896
  _proto._getScaleMatrix = function _getScaleMatrix() {
12868
12897
  var invRotation = Transform._tempQuat0;
12869
12898
  var invRotationMat = Transform._tempMat30;
@@ -12875,22 +12904,6 @@
12875
12904
  Matrix3x3.multiply(invRotationMat, worldRotScaMat, scaMat);
12876
12905
  return scaMat;
12877
12906
  };
12878
- _proto._isContainDirtyFlags = function _isContainDirtyFlags(targetDirtyFlags) {
12879
- return (this._dirtyFlag & targetDirtyFlags) === targetDirtyFlags;
12880
- };
12881
- _proto._isContainDirtyFlag = function _isContainDirtyFlag(type) {
12882
- return (this._dirtyFlag & type) != 0;
12883
- };
12884
- _proto._setDirtyFlagTrue = function _setDirtyFlagTrue(type) {
12885
- this._dirtyFlag |= type;
12886
- };
12887
- _proto._setDirtyFlagFalse = function _setDirtyFlagFalse(type) {
12888
- this._dirtyFlag &= ~type;
12889
- };
12890
- _proto._worldAssociatedChange = function _worldAssociatedChange(type) {
12891
- this._dirtyFlag |= type;
12892
- this._entity._updateFlagManager.dispatch(type);
12893
- };
12894
12907
  _proto._rotateByQuat = function _rotateByQuat(rotateQuat, relativeToLocal) {
12895
12908
  if (relativeToLocal) {
12896
12909
  Quaternion.multiply(this.rotationQuaternion, rotateQuat, this._rotationQuaternion);
@@ -12915,21 +12928,6 @@
12915
12928
  Quaternion.rotationEuler(x * radFactor, y * radFactor, z * radFactor, rotQuat);
12916
12929
  this._rotateByQuat(rotQuat, relativeToLocal);
12917
12930
  };
12918
- _proto._onPositionChanged = function _onPositionChanged() {
12919
- this._setDirtyFlagTrue(64);
12920
- this._updateWorldPositionFlag();
12921
- };
12922
- _proto._onWorldPositionChanged = function _onWorldPositionChanged() {
12923
- var worldPosition = this._worldPosition;
12924
- var parent = this._getParentTransform();
12925
- if (parent) {
12926
- Matrix.invert(parent.worldMatrix, Transform._tempMat41);
12927
- Vector3.transformCoordinate(worldPosition, Transform._tempMat41, this._position);
12928
- } else {
12929
- this._position.copyFrom(worldPosition);
12930
- }
12931
- this._setDirtyFlagFalse(4);
12932
- };
12933
12931
  _proto._onRotationChanged = function _onRotationChanged() {
12934
12932
  this._setDirtyFlagTrue(64 | 2);
12935
12933
  this._setDirtyFlagFalse(1);
@@ -13190,15 +13188,16 @@
13190
13188
  var _this = this, position = _this._position, rotationQuaternion = _this._rotationQuaternion, scale = _this._scale;
13191
13189
  // @ts-ignore
13192
13190
  position._onValueChanged = rotationQuaternion._onValueChanged = scale._onValueChanged = null;
13193
- this._localMatrix.decompose(position, rotationQuaternion, scale);
13191
+ value.decompose(position, rotationQuaternion, scale);
13192
+ this._onLocalMatrixChanging == null ? void 0 : this._onLocalMatrixChanging.call(this);
13193
+ this._setDirtyFlagTrue(1);
13194
+ this._setDirtyFlagFalse(64 | 2);
13194
13195
  // @ts-ignore
13195
13196
  position._onValueChanged = this._onPositionChanged;
13196
13197
  // @ts-ignore
13197
13198
  rotationQuaternion._onValueChanged = this._onRotationQuaternionChanged;
13198
13199
  // @ts-ignore
13199
13200
  scale._onValueChanged = this._onScaleChanged;
13200
- this._setDirtyFlagTrue(1);
13201
- this._setDirtyFlagFalse(64 | 2);
13202
13201
  var localUniformScaling = scale.x === scale.y && scale.y === scale.z;
13203
13202
  if (this._localUniformScaling !== localUniformScaling) {
13204
13203
  this._localUniformScaling = localUniformScaling;
@@ -13237,7 +13236,7 @@
13237
13236
  this._localMatrix.copyFrom(value);
13238
13237
  }
13239
13238
  this.localMatrix = this._localMatrix;
13240
- this._setDirtyFlagFalse(128);
13239
+ this._onWorldMatrixChange();
13241
13240
  }
13242
13241
  },
13243
13242
  {
@@ -13358,7 +13357,7 @@
13358
13357
  ignoreClone
13359
13358
  ], Transform.prototype, "_onScaleChanged", null);
13360
13359
  /**
13361
- * @internal
13360
+ * Dirty flag of transform.
13362
13361
  */ var TransformModifyFlags = /*#__PURE__*/ function(TransformModifyFlags) {
13363
13362
  TransformModifyFlags[TransformModifyFlags["LocalEuler"] = 1] = "LocalEuler";
13364
13363
  TransformModifyFlags[TransformModifyFlags["LocalQuat"] = 2] = "LocalQuat";
@@ -15844,43 +15843,130 @@
15844
15843
  if (outHitResult) {
15845
15844
  hitResult = outHitResult;
15846
15845
  }
15847
- var onRaycast = function onRaycast(obj) {
15848
- var shape = Engine._physicalObjectsMap[obj];
15849
- if (!shape) {
15850
- return false;
15851
- }
15852
- return shape.collider.entity.layer & layerMask && shape.isSceneQuery;
15853
- };
15854
- var outIDX;
15855
- var outDistance;
15856
- var outPosition;
15857
- var outNormal;
15858
- if (hitResult != undefined) {
15859
- var result = this._nativePhysicsScene.raycast(ray, distance, onRaycast, function(idx, distance, position, normal) {
15860
- outIDX = idx;
15861
- outDistance = distance;
15862
- outPosition = position;
15863
- outNormal = normal;
15864
- });
15865
- if (result) {
15866
- var hitShape = Engine._physicalObjectsMap[outIDX];
15867
- hitResult.entity = hitShape._collider.entity;
15868
- hitResult.shape = hitShape;
15869
- hitResult.distance = outDistance;
15870
- hitResult.point.copyFrom(outPosition);
15871
- hitResult.normal.copyFrom(outNormal);
15872
- return true;
15873
- } else {
15874
- hitResult.entity = null;
15875
- hitResult.shape = null;
15876
- hitResult.distance = 0;
15877
- hitResult.point.set(0, 0, 0);
15878
- hitResult.normal.set(0, 0, 0);
15879
- return false;
15880
- }
15881
- } else {
15882
- return this._nativePhysicsScene.raycast(ray, distance, onRaycast);
15846
+ var preFilter = this._createPreFilter(layerMask);
15847
+ var result = this._nativePhysicsScene.raycast(ray, distance, preFilter, hitResult ? this._createHitCallback(hitResult) : undefined);
15848
+ if (!result && hitResult) {
15849
+ this._clearHitResult(hitResult);
15850
+ }
15851
+ return result;
15852
+ };
15853
+ /**
15854
+ * Casts a box through the Scene and returns true if there is any hit.
15855
+ * @param center - The center of the box
15856
+ * @param halfExtents - Half the size of the box in each dimension
15857
+ * @param direction - The direction to sweep along
15858
+ * @param orientation - The rotation of the box. @defaultValue `Quaternion(0, 0, 0, 1)`
15859
+ * @param distance - The max distance to sweep. @defaultValue `Number.MAX_VALUE`
15860
+ * @param layerMask - Layer mask that is used to selectively ignore Colliders when sweeping. @defaultValue `Layer.Everything`
15861
+ * @param outHitResult - Optional HitResult object to store detailed hit information
15862
+ * @returns Returns true if the box intersects with any collider, otherwise false
15863
+ */ _proto.boxCast = function boxCast(center, halfExtents, direction, orientation, distance, layerMask, outHitResult) {
15864
+ if (orientation === void 0) orientation = PhysicsScene._identityQuaternion;
15865
+ if (distance === void 0) distance = Number.MAX_VALUE;
15866
+ if (layerMask === void 0) layerMask = Layer.Everything;
15867
+ var preFilter = this._createPreFilter(layerMask);
15868
+ var result = this._nativePhysicsScene.boxCast(center, orientation, halfExtents, direction, distance, preFilter, outHitResult ? this._createHitCallback(outHitResult) : undefined);
15869
+ if (!result && outHitResult) {
15870
+ this._clearHitResult(outHitResult);
15871
+ }
15872
+ return result;
15873
+ };
15874
+ /**
15875
+ * Casts a sphere through the Scene and returns true if there is any hit.
15876
+ * @param center - The center of the sphere
15877
+ * @param radius - The radius of the sphere
15878
+ * @param direction - The direction to sweep along
15879
+ * @param distance - The max distance to sweep. @defaultValue `Number.MAX_VALUE`
15880
+ * @param layerMask - Layer mask that is used to selectively ignore Colliders when sweeping. @defaultValue `Layer.Everything`
15881
+ * @param outHitResult - If true is returned, outHitResult will contain more detailed collision information
15882
+ * @returns Returns True if the sphere intersects with any collider, otherwise false
15883
+ */ _proto.sphereCast = function sphereCast(center, radius, direction, distance, layerMask, outHitResult) {
15884
+ if (distance === void 0) distance = Number.MAX_VALUE;
15885
+ if (layerMask === void 0) layerMask = Layer.Everything;
15886
+ var preFilter = this._createPreFilter(layerMask);
15887
+ var result = this._nativePhysicsScene.sphereCast(center, radius, direction, distance, preFilter, outHitResult ? this._createHitCallback(outHitResult) : undefined);
15888
+ if (!result && outHitResult) {
15889
+ this._clearHitResult(outHitResult);
15883
15890
  }
15891
+ return result;
15892
+ };
15893
+ /**
15894
+ * Casts a capsule through the Scene and returns true if there is any hit.
15895
+ * @param center - The center of the capsule
15896
+ * @param radius - The radius of the capsule
15897
+ * @param height - The height of the capsule
15898
+ * @param direction - The direction to sweep along
15899
+ * @param orientation - The rotation of the capsule. @defaultValue `Quaternion(0, 0, 0, 1)`
15900
+ * @param distance - The max distance to sweep. @defaultValue `Number.MAX_VALUE`
15901
+ * @param layerMask - Layer mask that is used to selectively ignore Colliders when sweeping. @defaultValue `Layer.Everything`
15902
+ * @param outHitResult - If true is returned, outHitResult will contain more detailed collision information
15903
+ * @returns Returns True if the capsule intersects with any collider, otherwise false
15904
+ */ _proto.capsuleCast = function capsuleCast(center, radius, height, direction, orientation, distance, layerMask, outHitResult) {
15905
+ if (orientation === void 0) orientation = PhysicsScene._identityQuaternion;
15906
+ if (distance === void 0) distance = Number.MAX_VALUE;
15907
+ if (layerMask === void 0) layerMask = Layer.Everything;
15908
+ var preFilter = this._createPreFilter(layerMask);
15909
+ var result = this._nativePhysicsScene.capsuleCast(center, radius, height, orientation, direction, distance, preFilter, outHitResult ? this._createHitCallback(outHitResult) : undefined);
15910
+ if (!result && outHitResult) {
15911
+ this._clearHitResult(outHitResult);
15912
+ }
15913
+ return result;
15914
+ };
15915
+ /**
15916
+ * Get all colliders that overlap with a box in the scene.
15917
+ * @param center - The center of the box
15918
+ * @param halfExtents - Half the size of the box in each dimension
15919
+ * @param orientation - The rotation of the box. @defaultValue `Quaternion(0, 0, 0, 1)`
15920
+ * @param layerMask - Layer mask that is used to selectively filter colliders. @defaultValue `Layer.Everything`
15921
+ * @param shapes - Array to store overlapping collider shapes. @defaultValue `[]`
15922
+ * @returns The collider shapes overlapping with the box
15923
+ */ _proto.overlapBoxAll = function overlapBoxAll(center, halfExtents, orientation, layerMask, shapes) {
15924
+ if (orientation === void 0) orientation = PhysicsScene._identityQuaternion;
15925
+ if (layerMask === void 0) layerMask = Layer.Everything;
15926
+ if (shapes === void 0) shapes = [];
15927
+ var ids = this._nativePhysicsScene.overlapBoxAll(center, orientation, halfExtents, this._createPreFilter(layerMask));
15928
+ shapes.length = 0;
15929
+ for(var i = 0, n = ids.length; i < n; i++){
15930
+ shapes.push(Engine._physicalObjectsMap[ids[i]]);
15931
+ }
15932
+ return shapes;
15933
+ };
15934
+ /**
15935
+ * Get all colliders that overlap with a sphere in the scene.
15936
+ * @param center - The center of the sphere
15937
+ * @param radius - The radius of the sphere
15938
+ * @param layerMask - Layer mask that is used to selectively filter colliders. @defaultValue `Layer.Everything`
15939
+ * @param shapes - Array to store overlapping collider shapes. @defaultValue `[]`
15940
+ * @returns The collider shapes overlapping with the sphere
15941
+ */ _proto.overlapSphereAll = function overlapSphereAll(center, radius, layerMask, shapes) {
15942
+ if (layerMask === void 0) layerMask = Layer.Everything;
15943
+ if (shapes === void 0) shapes = [];
15944
+ var ids = this._nativePhysicsScene.overlapSphereAll(center, radius, this._createPreFilter(layerMask));
15945
+ shapes.length = 0;
15946
+ for(var i = 0; i < ids.length; i++){
15947
+ shapes.push(Engine._physicalObjectsMap[ids[i]]);
15948
+ }
15949
+ return shapes;
15950
+ };
15951
+ /**
15952
+ * Get all colliders that overlap with a capsule in the scene.
15953
+ * @param center - The center of the capsule
15954
+ * @param radius - The radius of the capsule
15955
+ * @param height - The height of the capsule
15956
+ * @param orientation - The rotation of the capsule. @defaultValue `Quaternion(0, 0, 0, 1)`
15957
+ * @param layerMask - Layer mask that is used to selectively filter colliders. @defaultValue `Layer.Everything`
15958
+ * @param shapes - Array to store overlapping collider shapes. @defaultValue `[]`
15959
+ * @returns The collider shapes overlapping with the capsule
15960
+ */ _proto.overlapCapsuleAll = function overlapCapsuleAll(center, radius, height, orientation, layerMask, shapes) {
15961
+ if (orientation === void 0) orientation = PhysicsScene._identityQuaternion;
15962
+ if (layerMask === void 0) layerMask = Layer.Everything;
15963
+ if (shapes === void 0) shapes = [];
15964
+ var ids = this._nativePhysicsScene.overlapCapsuleAll(center, radius, height, orientation, this._createPreFilter(layerMask));
15965
+ shapes.length = 0;
15966
+ for(var i = 0; i < ids.length; i++){
15967
+ shapes.push(Engine._physicalObjectsMap[ids[i]]);
15968
+ }
15969
+ return shapes;
15884
15970
  };
15885
15971
  /**
15886
15972
  * Call on every frame to update pose of objects.
@@ -15970,6 +16056,31 @@
15970
16056
  _proto._setGravity = function _setGravity() {
15971
16057
  this._nativePhysicsScene.setGravity(this._gravity);
15972
16058
  };
16059
+ _proto._createPreFilter = function _createPreFilter(mask) {
16060
+ return function(obj) {
16061
+ var shape = Engine._physicalObjectsMap[obj];
16062
+ if (!shape) {
16063
+ return false;
16064
+ }
16065
+ return shape.collider.entity.layer & mask && shape.isSceneQuery;
16066
+ };
16067
+ };
16068
+ _proto._createHitCallback = function _createHitCallback(outHitResult) {
16069
+ return function(shapeUniqueID, distance, position, normal) {
16070
+ outHitResult.entity = Engine._physicalObjectsMap[shapeUniqueID].collider.entity;
16071
+ outHitResult.shape = Engine._physicalObjectsMap[shapeUniqueID];
16072
+ outHitResult.distance = distance;
16073
+ outHitResult.point.copyFrom(position);
16074
+ outHitResult.normal.copyFrom(normal);
16075
+ };
16076
+ };
16077
+ _proto._clearHitResult = function _clearHitResult(hitResult) {
16078
+ hitResult.entity = null;
16079
+ hitResult.shape = null;
16080
+ hitResult.distance = 0;
16081
+ hitResult.point.set(0, 0, 0);
16082
+ hitResult.normal.set(0, 0, 0);
16083
+ };
15973
16084
  _create_class$2(PhysicsScene, [
15974
16085
  {
15975
16086
  key: "gravity",
@@ -16000,6 +16111,7 @@
16000
16111
  return PhysicsScene;
16001
16112
  }();
16002
16113
  PhysicsScene._collision = new Collision();
16114
+ PhysicsScene._identityQuaternion = new Quaternion(0, 0, 0, 1);
16003
16115
  /**
16004
16116
  * A static collider component that will not move.
16005
16117
  * @remarks Mostly used for object which always stays at the same place and never moves around.
@@ -18036,35 +18148,85 @@
18036
18148
  return TextureCoordinate;
18037
18149
  }({});
18038
18150
  /**
18039
- * PBR (Physically-Based Rendering) Material.
18040
- */ var PBRBaseMaterial = /*#__PURE__*/ function(BaseMaterial) {
18041
- _inherits$2(PBRBaseMaterial, BaseMaterial);
18042
- function PBRBaseMaterial(engine, shader) {
18151
+ * Refraction mode.
18152
+ */ var RefractionMode = /*#__PURE__*/ function(RefractionMode) {
18153
+ /** Use the sphere refraction model when light passes through the surface. */ RefractionMode[RefractionMode["Sphere"] = 0] = "Sphere";
18154
+ /** Use the planar refraction model when light passes through the surface. */ RefractionMode[RefractionMode["Planar"] = 1] = "Planar";
18155
+ return RefractionMode;
18156
+ }({});
18157
+ /**
18158
+ * PBR (Metallic-Roughness Workflow) Material.
18159
+ */ var PBRMaterial = /*#__PURE__*/ function(BaseMaterial1) {
18160
+ _inherits$2(PBRMaterial, BaseMaterial1);
18161
+ function PBRMaterial(engine) {
18043
18162
  var _this;
18044
- _this = BaseMaterial.call(this, engine, shader) || this;
18163
+ _this = BaseMaterial1.call(this, engine, Shader.find("pbr")) || this, _this._anisotropyRotation = 0, _this._iridescenceRange = new Vector2(100, 400), _this._sheenEnabled = false;
18045
18164
  var shaderData = _this.shaderData;
18046
18165
  shaderData.enableMacro("MATERIAL_NEED_WORLD_POS");
18047
18166
  shaderData.enableMacro("MATERIAL_NEED_TILING_OFFSET");
18048
- shaderData.setColor(PBRBaseMaterial._baseColorProp, new Color(1, 1, 1, 1));
18049
- shaderData.setColor(PBRBaseMaterial._emissiveColorProp, new Color(0, 0, 0, 1));
18050
- shaderData.setVector4(PBRBaseMaterial._tilingOffsetProp, new Vector4(1, 1, 0, 0));
18051
- shaderData.setFloat(PBRBaseMaterial._normalIntensityProp, 1);
18052
- shaderData.setFloat(PBRBaseMaterial._occlusionTextureIntensityProp, 1);
18053
- shaderData.setFloat(PBRBaseMaterial._occlusionTextureCoordProp, TextureCoordinate.UV0);
18054
- shaderData.setFloat(PBRBaseMaterial._clearCoatProp, 0);
18055
- shaderData.setFloat(PBRBaseMaterial._clearCoatRoughnessProp, 0);
18167
+ shaderData.setColor(PBRMaterial._baseColorProp, new Color(1, 1, 1, 1));
18168
+ shaderData.setColor(PBRMaterial._emissiveColorProp, new Color(0, 0, 0, 1));
18169
+ shaderData.setVector4(PBRMaterial._tilingOffsetProp, new Vector4(1, 1, 0, 0));
18170
+ shaderData.setFloat(PBRMaterial._normalIntensityProp, 1);
18171
+ shaderData.setFloat(PBRMaterial._occlusionTextureIntensityProp, 1);
18172
+ shaderData.setFloat(PBRMaterial._occlusionTextureCoordProp, TextureCoordinate.UV0);
18173
+ shaderData.setFloat(PBRMaterial._clearCoatProp, 0);
18174
+ shaderData.setFloat(PBRMaterial._clearCoatRoughnessProp, 0);
18175
+ shaderData.setFloat(PBRMaterial._metallicProp, 1);
18176
+ shaderData.setFloat(PBRMaterial._roughnessProp, 1);
18177
+ shaderData.setFloat(PBRMaterial._iorProp, 1.5);
18178
+ shaderData.setVector3(PBRMaterial._anisotropyInfoProp, new Vector3(1, 0, 0));
18179
+ shaderData.setVector4(PBRMaterial._iridescenceInfoProp, new Vector4(0, 1.3, 100, 400));
18180
+ var sheenColor = new Color(0, 0, 0);
18181
+ shaderData.setColor(PBRMaterial._sheenColorProp, sheenColor);
18182
+ _this.refractionMode = RefractionMode.Planar;
18183
+ shaderData.setFloat(PBRMaterial._transmissionProp, 0);
18184
+ shaderData.setFloat(PBRMaterial._thicknessProp, 0);
18185
+ shaderData.setFloat(PBRMaterial._attenuationDistanceProp, Infinity);
18186
+ shaderData.setColor(PBRMaterial._attenuationColorProp, new Color(1, 1, 1));
18187
+ shaderData.setFloat(PBRMaterial._specularIntensityProp, 1);
18188
+ shaderData.setColor(PBRMaterial._specularColorProp, new Color(1, 1, 1));
18189
+ // @ts-ignore
18190
+ _this._iridescenceRange._onValueChanged = _this._onIridescenceRangeChanged.bind(_this);
18191
+ // @ts-ignore
18192
+ sheenColor._onValueChanged = _this._onSheenColorChanged.bind(_this);
18056
18193
  return _this;
18057
18194
  }
18058
- _create_class$2(PBRBaseMaterial, [
18195
+ var _proto = PBRMaterial.prototype;
18196
+ /**
18197
+ * @inheritdoc
18198
+ */ _proto.clone = function clone() {
18199
+ var dest = new PBRMaterial(this._engine);
18200
+ this._cloneToAndModifyName(dest);
18201
+ return dest;
18202
+ };
18203
+ _proto._onIridescenceRangeChanged = function _onIridescenceRangeChanged() {
18204
+ var iridescenceInfo = this.shaderData.getVector4(PBRMaterial._iridescenceInfoProp);
18205
+ iridescenceInfo.z = this._iridescenceRange.x;
18206
+ iridescenceInfo.w = this._iridescenceRange.y;
18207
+ };
18208
+ _proto._onSheenColorChanged = function _onSheenColorChanged() {
18209
+ var sheenColor = this.sheenColor;
18210
+ var enableSheen = sheenColor.r + sheenColor.g + sheenColor.b > 0;
18211
+ if (enableSheen !== this._sheenEnabled) {
18212
+ this._sheenEnabled = enableSheen;
18213
+ if (enableSheen) {
18214
+ this.shaderData.enableMacro("MATERIAL_ENABLE_SHEEN");
18215
+ } else {
18216
+ this.shaderData.disableMacro("MATERIAL_ENABLE_SHEEN");
18217
+ }
18218
+ }
18219
+ };
18220
+ _create_class$2(PBRMaterial, [
18059
18221
  {
18060
18222
  key: "baseColor",
18061
18223
  get: /**
18062
18224
  * Base color.
18063
18225
  */ function get() {
18064
- return this.shaderData.getColor(PBRBaseMaterial._baseColorProp);
18226
+ return this.shaderData.getColor(PBRMaterial._baseColorProp);
18065
18227
  },
18066
18228
  set: function set(value) {
18067
- var baseColor = this.shaderData.getColor(PBRBaseMaterial._baseColorProp);
18229
+ var baseColor = this.shaderData.getColor(PBRMaterial._baseColorProp);
18068
18230
  if (value !== baseColor) {
18069
18231
  baseColor.copyFrom(value);
18070
18232
  }
@@ -18075,14 +18237,14 @@
18075
18237
  get: /**
18076
18238
  * Base texture.
18077
18239
  */ function get() {
18078
- return this.shaderData.getTexture(PBRBaseMaterial._baseTextureProp);
18240
+ return this.shaderData.getTexture(PBRMaterial._baseTextureProp);
18079
18241
  },
18080
18242
  set: function set(value) {
18081
- this.shaderData.setTexture(PBRBaseMaterial._baseTextureProp, value);
18243
+ this.shaderData.setTexture(PBRMaterial._baseTextureProp, value);
18082
18244
  if (value) {
18083
- this.shaderData.enableMacro(PBRBaseMaterial._baseTextureMacro);
18245
+ this.shaderData.enableMacro(PBRMaterial._baseTextureMacro);
18084
18246
  } else {
18085
- this.shaderData.disableMacro(PBRBaseMaterial._baseTextureMacro);
18247
+ this.shaderData.disableMacro(PBRMaterial._baseTextureMacro);
18086
18248
  }
18087
18249
  }
18088
18250
  },
@@ -18091,14 +18253,14 @@
18091
18253
  get: /**
18092
18254
  * Normal texture.
18093
18255
  */ function get() {
18094
- return this.shaderData.getTexture(PBRBaseMaterial._normalTextureProp);
18256
+ return this.shaderData.getTexture(PBRMaterial._normalTextureProp);
18095
18257
  },
18096
18258
  set: function set(value) {
18097
- this.shaderData.setTexture(PBRBaseMaterial._normalTextureProp, value);
18259
+ this.shaderData.setTexture(PBRMaterial._normalTextureProp, value);
18098
18260
  if (value) {
18099
- this.shaderData.enableMacro(PBRBaseMaterial._normalTextureMacro);
18261
+ this.shaderData.enableMacro(PBRMaterial._normalTextureMacro);
18100
18262
  } else {
18101
- this.shaderData.disableMacro(PBRBaseMaterial._normalTextureMacro);
18263
+ this.shaderData.disableMacro(PBRMaterial._normalTextureMacro);
18102
18264
  }
18103
18265
  }
18104
18266
  },
@@ -18107,10 +18269,10 @@
18107
18269
  get: /**
18108
18270
  * Normal texture intensity.
18109
18271
  */ function get() {
18110
- return this.shaderData.getFloat(PBRBaseMaterial._normalIntensityProp);
18272
+ return this.shaderData.getFloat(PBRMaterial._normalIntensityProp);
18111
18273
  },
18112
18274
  set: function set(value) {
18113
- this.shaderData.setFloat(PBRBaseMaterial._normalIntensityProp, value);
18275
+ this.shaderData.setFloat(PBRMaterial._normalIntensityProp, value);
18114
18276
  }
18115
18277
  },
18116
18278
  {
@@ -18118,10 +18280,10 @@
18118
18280
  get: /**
18119
18281
  * Emissive color.
18120
18282
  */ function get() {
18121
- return this.shaderData.getColor(PBRBaseMaterial._emissiveColorProp);
18283
+ return this.shaderData.getColor(PBRMaterial._emissiveColorProp);
18122
18284
  },
18123
18285
  set: function set(value) {
18124
- var emissiveColor = this.shaderData.getColor(PBRBaseMaterial._emissiveColorProp);
18286
+ var emissiveColor = this.shaderData.getColor(PBRMaterial._emissiveColorProp);
18125
18287
  if (value !== emissiveColor) {
18126
18288
  emissiveColor.copyFrom(value);
18127
18289
  }
@@ -18132,14 +18294,14 @@
18132
18294
  get: /**
18133
18295
  * Emissive texture.
18134
18296
  */ function get() {
18135
- return this.shaderData.getTexture(PBRBaseMaterial._emissiveTextureProp);
18297
+ return this.shaderData.getTexture(PBRMaterial._emissiveTextureProp);
18136
18298
  },
18137
18299
  set: function set(value) {
18138
- this.shaderData.setTexture(PBRBaseMaterial._emissiveTextureProp, value);
18300
+ this.shaderData.setTexture(PBRMaterial._emissiveTextureProp, value);
18139
18301
  if (value) {
18140
- this.shaderData.enableMacro(PBRBaseMaterial._emissiveTextureMacro);
18302
+ this.shaderData.enableMacro(PBRMaterial._emissiveTextureMacro);
18141
18303
  } else {
18142
- this.shaderData.disableMacro(PBRBaseMaterial._emissiveTextureMacro);
18304
+ this.shaderData.disableMacro(PBRMaterial._emissiveTextureMacro);
18143
18305
  }
18144
18306
  }
18145
18307
  },
@@ -18148,10 +18310,10 @@
18148
18310
  get: /**
18149
18311
  * Occlusion texture.
18150
18312
  */ function get() {
18151
- return this.shaderData.getTexture(PBRBaseMaterial._occlusionTextureProp);
18313
+ return this.shaderData.getTexture(PBRMaterial._occlusionTextureProp);
18152
18314
  },
18153
18315
  set: function set(value) {
18154
- this.shaderData.setTexture(PBRBaseMaterial._occlusionTextureProp, value);
18316
+ this.shaderData.setTexture(PBRMaterial._occlusionTextureProp, value);
18155
18317
  if (value) {
18156
18318
  this.shaderData.enableMacro("MATERIAL_HAS_OCCLUSION_TEXTURE");
18157
18319
  } else {
@@ -18164,10 +18326,10 @@
18164
18326
  get: /**
18165
18327
  * Occlusion texture intensity.
18166
18328
  */ function get() {
18167
- return this.shaderData.getFloat(PBRBaseMaterial._occlusionTextureIntensityProp);
18329
+ return this.shaderData.getFloat(PBRMaterial._occlusionTextureIntensityProp);
18168
18330
  },
18169
18331
  set: function set(value) {
18170
- this.shaderData.setFloat(PBRBaseMaterial._occlusionTextureIntensityProp, value);
18332
+ this.shaderData.setFloat(PBRMaterial._occlusionTextureIntensityProp, value);
18171
18333
  }
18172
18334
  },
18173
18335
  {
@@ -18176,13 +18338,13 @@
18176
18338
  * Occlusion texture uv coordinate.
18177
18339
  * @remarks Must be UV0 or UV1.
18178
18340
  */ function get() {
18179
- return this.shaderData.getFloat(PBRBaseMaterial._occlusionTextureCoordProp);
18341
+ return this.shaderData.getFloat(PBRMaterial._occlusionTextureCoordProp);
18180
18342
  },
18181
18343
  set: function set(value) {
18182
18344
  if (value > TextureCoordinate.UV1) {
18183
18345
  Logger.warn("Occlusion texture uv coordinate must be UV0 or UV1.");
18184
18346
  }
18185
- this.shaderData.setFloat(PBRBaseMaterial._occlusionTextureCoordProp, value);
18347
+ this.shaderData.setFloat(PBRMaterial._occlusionTextureCoordProp, value);
18186
18348
  }
18187
18349
  },
18188
18350
  {
@@ -18190,10 +18352,10 @@
18190
18352
  get: /**
18191
18353
  * Tiling and offset of main textures.
18192
18354
  */ function get() {
18193
- return this.shaderData.getVector4(PBRBaseMaterial._tilingOffsetProp);
18355
+ return this.shaderData.getVector4(PBRMaterial._tilingOffsetProp);
18194
18356
  },
18195
18357
  set: function set(value) {
18196
- var tilingOffset = this.shaderData.getVector4(PBRBaseMaterial._tilingOffsetProp);
18358
+ var tilingOffset = this.shaderData.getVector4(PBRMaterial._tilingOffsetProp);
18197
18359
  if (value !== tilingOffset) {
18198
18360
  tilingOffset.copyFrom(value);
18199
18361
  }
@@ -18204,17 +18366,17 @@
18204
18366
  get: /**
18205
18367
  * The clearCoat layer intensity, default 0.
18206
18368
  */ function get() {
18207
- return this.shaderData.getFloat(PBRBaseMaterial._clearCoatProp);
18369
+ return this.shaderData.getFloat(PBRMaterial._clearCoatProp);
18208
18370
  },
18209
18371
  set: function set(value) {
18210
- if (!!this.shaderData.getFloat(PBRBaseMaterial._clearCoatProp) !== !!value) {
18372
+ if (!!this.shaderData.getFloat(PBRMaterial._clearCoatProp) !== !!value) {
18211
18373
  if (value === 0) {
18212
18374
  this.shaderData.disableMacro("MATERIAL_ENABLE_CLEAR_COAT");
18213
18375
  } else {
18214
18376
  this.shaderData.enableMacro("MATERIAL_ENABLE_CLEAR_COAT");
18215
18377
  }
18216
18378
  }
18217
- this.shaderData.setFloat(PBRBaseMaterial._clearCoatProp, value);
18379
+ this.shaderData.setFloat(PBRMaterial._clearCoatProp, value);
18218
18380
  }
18219
18381
  },
18220
18382
  {
@@ -18222,10 +18384,10 @@
18222
18384
  get: /**
18223
18385
  * The clearCoat layer intensity texture.
18224
18386
  */ function get() {
18225
- return this.shaderData.getTexture(PBRBaseMaterial._clearCoatTextureProp);
18387
+ return this.shaderData.getTexture(PBRMaterial._clearCoatTextureProp);
18226
18388
  },
18227
18389
  set: function set(value) {
18228
- this.shaderData.setTexture(PBRBaseMaterial._clearCoatTextureProp, value);
18390
+ this.shaderData.setTexture(PBRMaterial._clearCoatTextureProp, value);
18229
18391
  if (value) {
18230
18392
  this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_TEXTURE");
18231
18393
  } else {
@@ -18238,10 +18400,10 @@
18238
18400
  get: /**
18239
18401
  * The clearCoat layer roughness, default 0.
18240
18402
  */ function get() {
18241
- return this.shaderData.getFloat(PBRBaseMaterial._clearCoatRoughnessProp);
18403
+ return this.shaderData.getFloat(PBRMaterial._clearCoatRoughnessProp);
18242
18404
  },
18243
18405
  set: function set(value) {
18244
- this.shaderData.setFloat(PBRBaseMaterial._clearCoatRoughnessProp, value);
18406
+ this.shaderData.setFloat(PBRMaterial._clearCoatRoughnessProp, value);
18245
18407
  }
18246
18408
  },
18247
18409
  {
@@ -18249,10 +18411,10 @@
18249
18411
  get: /**
18250
18412
  * The clearCoat layer roughness texture.
18251
18413
  */ function get() {
18252
- return this.shaderData.getTexture(PBRBaseMaterial._clearCoatRoughnessTextureProp);
18414
+ return this.shaderData.getTexture(PBRMaterial._clearCoatRoughnessTextureProp);
18253
18415
  },
18254
18416
  set: function set(value) {
18255
- this.shaderData.setTexture(PBRBaseMaterial._clearCoatRoughnessTextureProp, value);
18417
+ this.shaderData.setTexture(PBRMaterial._clearCoatRoughnessTextureProp, value);
18256
18418
  if (value) {
18257
18419
  this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE");
18258
18420
  } else {
@@ -18265,88 +18427,17 @@
18265
18427
  get: /**
18266
18428
  * The clearCoat normal map texture.
18267
18429
  */ function get() {
18268
- return this.shaderData.getTexture(PBRBaseMaterial._clearCoatNormalTextureProp);
18430
+ return this.shaderData.getTexture(PBRMaterial._clearCoatNormalTextureProp);
18269
18431
  },
18270
18432
  set: function set(value) {
18271
- this.shaderData.setTexture(PBRBaseMaterial._clearCoatNormalTextureProp, value);
18433
+ this.shaderData.setTexture(PBRMaterial._clearCoatNormalTextureProp, value);
18272
18434
  if (value) {
18273
18435
  this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE");
18274
18436
  } else {
18275
18437
  this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE");
18276
18438
  }
18277
18439
  }
18278
- }
18279
- ]);
18280
- return PBRBaseMaterial;
18281
- }(BaseMaterial);
18282
- PBRBaseMaterial._occlusionTextureIntensityProp = ShaderProperty.getByName("material_OcclusionIntensity");
18283
- PBRBaseMaterial._occlusionTextureCoordProp = ShaderProperty.getByName("material_OcclusionTextureCoord");
18284
- PBRBaseMaterial._occlusionTextureProp = ShaderProperty.getByName("material_OcclusionTexture");
18285
- PBRBaseMaterial._clearCoatProp = ShaderProperty.getByName("material_ClearCoat");
18286
- PBRBaseMaterial._clearCoatTextureProp = ShaderProperty.getByName("material_ClearCoatTexture");
18287
- PBRBaseMaterial._clearCoatRoughnessProp = ShaderProperty.getByName("material_ClearCoatRoughness");
18288
- PBRBaseMaterial._clearCoatRoughnessTextureProp = ShaderProperty.getByName("material_ClearCoatRoughnessTexture");
18289
- PBRBaseMaterial._clearCoatNormalTextureProp = ShaderProperty.getByName("material_ClearCoatNormalTexture");
18290
- /**
18291
- * Refraction mode.
18292
- */ var RefractionMode = /*#__PURE__*/ function(RefractionMode) {
18293
- /** Use the sphere refraction model when light passes through the surface. */ RefractionMode[RefractionMode["Sphere"] = 0] = "Sphere";
18294
- /** Use the planar refraction model when light passes through the surface. */ RefractionMode[RefractionMode["Planar"] = 1] = "Planar";
18295
- return RefractionMode;
18296
- }({});
18297
- /**
18298
- * PBR (Metallic-Roughness Workflow) Material.
18299
- */ var PBRMaterial = /*#__PURE__*/ function(PBRBaseMaterial) {
18300
- _inherits$2(PBRMaterial, PBRBaseMaterial);
18301
- function PBRMaterial(engine) {
18302
- var _this;
18303
- _this = PBRBaseMaterial.call(this, engine, Shader.find("pbr")) || this, _this._anisotropyRotation = 0, _this._iridescenceRange = new Vector2(100, 400), _this._sheenEnabled = false;
18304
- var shaderData = _this.shaderData;
18305
- shaderData.setFloat(PBRMaterial._metallicProp, 1);
18306
- shaderData.setFloat(PBRMaterial._roughnessProp, 1);
18307
- shaderData.setFloat(PBRMaterial._iorProp, 1.5);
18308
- shaderData.setVector3(PBRMaterial._anisotropyInfoProp, new Vector3(1, 0, 0));
18309
- shaderData.setVector4(PBRMaterial._iridescenceInfoProp, new Vector4(0, 1.3, 100, 400));
18310
- var sheenColor = new Color(0, 0, 0);
18311
- shaderData.setColor(PBRMaterial._sheenColorProp, sheenColor);
18312
- _this.refractionMode = RefractionMode.Planar;
18313
- shaderData.setFloat(PBRMaterial._transmissionProp, 0);
18314
- shaderData.setFloat(PBRMaterial._thicknessProp, 0);
18315
- shaderData.setFloat(PBRMaterial._attenuationDistanceProp, Infinity);
18316
- var attenuationColor = new Color(1, 1, 1);
18317
- shaderData.setColor(PBRMaterial._attenuationColorProp, attenuationColor);
18318
- // @ts-ignore
18319
- _this._iridescenceRange._onValueChanged = _this._onIridescenceRangeChanged.bind(_this);
18320
- // @ts-ignore
18321
- sheenColor._onValueChanged = _this._onSheenColorChanged.bind(_this);
18322
- return _this;
18323
- }
18324
- var _proto = PBRMaterial.prototype;
18325
- /**
18326
- * @inheritdoc
18327
- */ _proto.clone = function clone() {
18328
- var dest = new PBRMaterial(this._engine);
18329
- this._cloneToAndModifyName(dest);
18330
- return dest;
18331
- };
18332
- _proto._onIridescenceRangeChanged = function _onIridescenceRangeChanged() {
18333
- var iridescenceInfo = this.shaderData.getVector4(PBRMaterial._iridescenceInfoProp);
18334
- iridescenceInfo.z = this._iridescenceRange.x;
18335
- iridescenceInfo.w = this._iridescenceRange.y;
18336
- };
18337
- _proto._onSheenColorChanged = function _onSheenColorChanged() {
18338
- var sheenColor = this.sheenColor;
18339
- var enableSheen = sheenColor.r + sheenColor.g + sheenColor.b > 0;
18340
- if (enableSheen !== this._sheenEnabled) {
18341
- this._sheenEnabled = enableSheen;
18342
- if (enableSheen) {
18343
- this.shaderData.enableMacro("MATERIAL_ENABLE_SHEEN");
18344
- } else {
18345
- this.shaderData.disableMacro("MATERIAL_ENABLE_SHEEN");
18346
- }
18347
- }
18348
- };
18349
- _create_class$2(PBRMaterial, [
18440
+ },
18350
18441
  {
18351
18442
  key: "ior",
18352
18443
  get: /**
@@ -18356,7 +18447,7 @@
18356
18447
  return this.shaderData.getFloat(PBRMaterial._iorProp);
18357
18448
  },
18358
18449
  set: function set(v) {
18359
- this.shaderData.setFloat(PBRMaterial._iorProp, Math.max(v, 0));
18450
+ this.shaderData.setFloat(PBRMaterial._iorProp, Math.min(Math.max(v, 0), 5));
18360
18451
  }
18361
18452
  },
18362
18453
  {
@@ -18748,102 +18839,106 @@
18748
18839
  this.shaderData.disableMacro(PBRMaterial._thicknessTextureMacro);
18749
18840
  }
18750
18841
  }
18751
- }
18752
- ]);
18753
- return PBRMaterial;
18754
- }(PBRBaseMaterial);
18755
- PBRMaterial._metallicProp = ShaderProperty.getByName("material_Metal");
18756
- PBRMaterial._roughnessProp = ShaderProperty.getByName("material_Roughness");
18757
- PBRMaterial._roughnessMetallicTextureProp = ShaderProperty.getByName("material_RoughnessMetallicTexture");
18758
- PBRMaterial._iorProp = ShaderProperty.getByName("material_IOR");
18759
- PBRMaterial._anisotropyInfoProp = ShaderProperty.getByName("material_AnisotropyInfo");
18760
- PBRMaterial._anisotropyTextureProp = ShaderProperty.getByName("material_AnisotropyTexture");
18761
- PBRMaterial._iridescenceInfoProp = ShaderProperty.getByName("material_IridescenceInfo");
18762
- PBRMaterial._iridescenceThicknessTextureProp = ShaderProperty.getByName("material_IridescenceThicknessTexture");
18763
- PBRMaterial._iridescenceTextureProp = ShaderProperty.getByName("material_IridescenceTexture");
18764
- PBRMaterial._sheenColorProp = ShaderProperty.getByName("material_SheenColor");
18765
- PBRMaterial._sheenRoughnessProp = ShaderProperty.getByName("material_SheenRoughness");
18766
- PBRMaterial._sheenTextureProp = ShaderProperty.getByName("material_SheenTexture");
18767
- PBRMaterial._sheenRoughnessTextureProp = ShaderProperty.getByName("material_SheenRoughnessTexture");
18768
- PBRMaterial._transmissionMacro = ShaderMacro.getByName("MATERIAL_ENABLE_TRANSMISSION");
18769
- PBRMaterial._thicknessMacro = ShaderMacro.getByName("MATERIAL_HAS_THICKNESS");
18770
- PBRMaterial._thicknessTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_THICKNESS_TEXTURE");
18771
- PBRMaterial._transmissionTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_TRANSMISSION_TEXTURE");
18772
- PBRMaterial._transmissionProp = ShaderProperty.getByName("material_Transmission");
18773
- PBRMaterial._transmissionTextureProp = ShaderProperty.getByName("material_TransmissionTexture");
18774
- PBRMaterial._attenuationColorProp = ShaderProperty.getByName("material_AttenuationColor");
18775
- PBRMaterial._attenuationDistanceProp = ShaderProperty.getByName("material_AttenuationDistance");
18776
- PBRMaterial._thicknessProp = ShaderProperty.getByName("material_Thickness");
18777
- PBRMaterial._thicknessTextureProp = ShaderProperty.getByName("material_ThicknessTexture");
18778
- /**
18779
- * PBR (Specular-Glossiness Workflow) Material.
18780
- */ var PBRSpecularMaterial = /*#__PURE__*/ function(PBRBaseMaterial) {
18781
- _inherits$2(PBRSpecularMaterial, PBRBaseMaterial);
18782
- function PBRSpecularMaterial(engine) {
18783
- var _this;
18784
- _this = PBRBaseMaterial.call(this, engine, Shader.find("pbr-specular")) || this;
18785
- _this.shaderData.setColor(PBRSpecularMaterial._specularColorProp, new Color(1, 1, 1, 1));
18786
- _this.shaderData.setFloat(PBRSpecularMaterial._glossinessProp, 1.0);
18787
- return _this;
18788
- }
18789
- var _proto = PBRSpecularMaterial.prototype;
18790
- /**
18791
- * @inheritdoc
18792
- */ _proto.clone = function clone() {
18793
- var dest = new PBRSpecularMaterial(this._engine);
18794
- this._cloneToAndModifyName(dest);
18795
- return dest;
18796
- };
18797
- _create_class$2(PBRSpecularMaterial, [
18842
+ },
18843
+ {
18844
+ key: "specularIntensity",
18845
+ get: /**
18846
+ * The intensity of the specular reflection.
18847
+ * @defaultValue `1.0`
18848
+ */ function get() {
18849
+ return this.shaderData.getFloat(PBRMaterial._specularIntensityProp);
18850
+ },
18851
+ set: function set(value) {
18852
+ this.shaderData.setFloat(PBRMaterial._specularIntensityProp, Math.min(Math.max(value, 0), 2));
18853
+ }
18854
+ },
18798
18855
  {
18799
18856
  key: "specularColor",
18800
18857
  get: /**
18801
- * Specular color.
18858
+ * The F0 color of the specular reflection.
18859
+ * @defaultValue `[1,1,1]`
18802
18860
  */ function get() {
18803
- return this.shaderData.getColor(PBRSpecularMaterial._specularColorProp);
18861
+ return this.shaderData.getColor(PBRMaterial._specularColorProp);
18804
18862
  },
18805
18863
  set: function set(value) {
18806
- var specularColor = this.shaderData.getColor(PBRSpecularMaterial._specularColorProp);
18864
+ var specularColor = this.shaderData.getColor(PBRMaterial._specularColorProp);
18807
18865
  if (value !== specularColor) {
18808
18866
  specularColor.copyFrom(value);
18809
18867
  }
18810
18868
  }
18811
18869
  },
18812
18870
  {
18813
- key: "glossiness",
18871
+ key: "specularIntensityTexture",
18814
18872
  get: /**
18815
- * Glossiness.
18873
+ * The intensity of the specular reflection, stored in alpha(A) channel. This will be multiplied by `specularIntensity`.
18816
18874
  */ function get() {
18817
- return this.shaderData.getFloat(PBRSpecularMaterial._glossinessProp);
18875
+ return this.shaderData.getTexture(PBRMaterial._specularIntensityTextureProp);
18818
18876
  },
18819
18877
  set: function set(value) {
18820
- this.shaderData.setFloat(PBRSpecularMaterial._glossinessProp, value);
18878
+ this.shaderData.setTexture(PBRMaterial._specularIntensityTextureProp, value);
18879
+ if (value) {
18880
+ this.shaderData.enableMacro(PBRMaterial._specularTextureMacro);
18881
+ } else {
18882
+ this.shaderData.disableMacro(PBRMaterial._specularTextureMacro);
18883
+ }
18821
18884
  }
18822
18885
  },
18823
18886
  {
18824
- key: "specularGlossinessTexture",
18887
+ key: "specularColorTexture",
18825
18888
  get: /**
18826
- * Specular glossiness texture.
18827
- * @remarks RGB is specular, A is glossiness
18889
+ * The F0 color of the specular reflection, stored in the RGB channels. This will be multiplied by `specularColor`.
18828
18890
  */ function get() {
18829
- return this.shaderData.getTexture(PBRSpecularMaterial._specularGlossinessTextureProp);
18891
+ return this.shaderData.getTexture(PBRMaterial._specularColorTextureProp);
18830
18892
  },
18831
18893
  set: function set(value) {
18832
- this.shaderData.setTexture(PBRSpecularMaterial._specularGlossinessTextureProp, value);
18894
+ this.shaderData.setTexture(PBRMaterial._specularColorTextureProp, value);
18833
18895
  if (value) {
18834
- this.shaderData.enableMacro(PBRSpecularMaterial._specularGlossinessTextureMacro);
18896
+ this.shaderData.enableMacro(PBRMaterial._specularColorTextureMacro);
18835
18897
  } else {
18836
- this.shaderData.disableMacro(PBRSpecularMaterial._specularGlossinessTextureMacro);
18898
+ this.shaderData.disableMacro(PBRMaterial._specularColorTextureMacro);
18837
18899
  }
18838
18900
  }
18839
18901
  }
18840
18902
  ]);
18841
- return PBRSpecularMaterial;
18842
- }(PBRBaseMaterial);
18843
- PBRSpecularMaterial._specularColorProp = ShaderProperty.getByName("material_PBRSpecularColor");
18844
- PBRSpecularMaterial._glossinessProp = ShaderProperty.getByName("material_Glossiness");
18845
- PBRSpecularMaterial._specularGlossinessTextureProp = ShaderProperty.getByName("material_SpecularGlossinessTexture");
18846
- PBRSpecularMaterial._specularGlossinessTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");
18903
+ return PBRMaterial;
18904
+ }(BaseMaterial);
18905
+ PBRMaterial._occlusionTextureIntensityProp = ShaderProperty.getByName("material_OcclusionIntensity");
18906
+ PBRMaterial._occlusionTextureCoordProp = ShaderProperty.getByName("material_OcclusionTextureCoord");
18907
+ PBRMaterial._occlusionTextureProp = ShaderProperty.getByName("material_OcclusionTexture");
18908
+ PBRMaterial._clearCoatProp = ShaderProperty.getByName("material_ClearCoat");
18909
+ PBRMaterial._clearCoatTextureProp = ShaderProperty.getByName("material_ClearCoatTexture");
18910
+ PBRMaterial._clearCoatRoughnessProp = ShaderProperty.getByName("material_ClearCoatRoughness");
18911
+ PBRMaterial._clearCoatRoughnessTextureProp = ShaderProperty.getByName("material_ClearCoatRoughnessTexture");
18912
+ PBRMaterial._clearCoatNormalTextureProp = ShaderProperty.getByName("material_ClearCoatNormalTexture");
18913
+ PBRMaterial._metallicProp = ShaderProperty.getByName("material_Metal");
18914
+ PBRMaterial._roughnessProp = ShaderProperty.getByName("material_Roughness");
18915
+ PBRMaterial._roughnessMetallicTextureProp = ShaderProperty.getByName("material_RoughnessMetallicTexture");
18916
+ PBRMaterial._iorProp = ShaderProperty.getByName("material_IOR");
18917
+ PBRMaterial._anisotropyInfoProp = ShaderProperty.getByName("material_AnisotropyInfo");
18918
+ PBRMaterial._anisotropyTextureProp = ShaderProperty.getByName("material_AnisotropyTexture");
18919
+ PBRMaterial._iridescenceInfoProp = ShaderProperty.getByName("material_IridescenceInfo");
18920
+ PBRMaterial._iridescenceThicknessTextureProp = ShaderProperty.getByName("material_IridescenceThicknessTexture");
18921
+ PBRMaterial._iridescenceTextureProp = ShaderProperty.getByName("material_IridescenceTexture");
18922
+ PBRMaterial._sheenColorProp = ShaderProperty.getByName("material_SheenColor");
18923
+ PBRMaterial._sheenRoughnessProp = ShaderProperty.getByName("material_SheenRoughness");
18924
+ PBRMaterial._sheenTextureProp = ShaderProperty.getByName("material_SheenTexture");
18925
+ PBRMaterial._sheenRoughnessTextureProp = ShaderProperty.getByName("material_SheenRoughnessTexture");
18926
+ PBRMaterial._transmissionMacro = ShaderMacro.getByName("MATERIAL_ENABLE_TRANSMISSION");
18927
+ PBRMaterial._thicknessMacro = ShaderMacro.getByName("MATERIAL_HAS_THICKNESS");
18928
+ PBRMaterial._thicknessTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_THICKNESS_TEXTURE");
18929
+ PBRMaterial._transmissionTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_TRANSMISSION_TEXTURE");
18930
+ PBRMaterial._transmissionProp = ShaderProperty.getByName("material_Transmission");
18931
+ PBRMaterial._transmissionTextureProp = ShaderProperty.getByName("material_TransmissionTexture");
18932
+ PBRMaterial._attenuationColorProp = ShaderProperty.getByName("material_AttenuationColor");
18933
+ PBRMaterial._attenuationDistanceProp = ShaderProperty.getByName("material_AttenuationDistance");
18934
+ PBRMaterial._thicknessProp = ShaderProperty.getByName("material_Thickness");
18935
+ PBRMaterial._thicknessTextureProp = ShaderProperty.getByName("material_ThicknessTexture");
18936
+ PBRMaterial._specularTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_SPECULAR_TEXTURE");
18937
+ PBRMaterial._specularColorTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_SPECULAR_COLOR_TEXTURE");
18938
+ PBRMaterial._specularIntensityProp = ShaderProperty.getByName("material_SpecularIntensity");
18939
+ PBRMaterial._specularColorProp = ShaderProperty.getByName("material_SpecularColor");
18940
+ PBRMaterial._specularIntensityTextureProp = ShaderProperty.getByName("material_SpecularIntensityTexture");
18941
+ PBRMaterial._specularColorTextureProp = ShaderProperty.getByName("material_SpecularColorTexture");
18847
18942
  /**
18848
18943
  * Unlit Material.
18849
18944
  */ var UnlitMaterial = /*#__PURE__*/ function(BaseMaterial) {
@@ -30505,7 +30600,7 @@
30505
30600
  _inherits$2(Engine, EventDispatcher);
30506
30601
  function Engine(canvas, hardwareRenderer, configuration) {
30507
30602
  var _this;
30508
- _this = EventDispatcher.call(this) || this, /** @internal */ _this._physicsInitialized = false, /* @internal */ _this._lastRenderState = new RenderState(), /* @internal */ _this._renderElementPool = new ClearableObjectPool(RenderElement), /* @internal */ _this._subRenderElementPool = new ClearableObjectPool(SubRenderElement), /* @internal */ _this._textSubRenderElementPool = new ClearableObjectPool(SubRenderElement), /* @internal */ _this._charRenderInfoPool = new ReturnableObjectPool(CharRenderInfo, 50), /* @internal */ _this._renderContext = new RenderContext(), /* @internal */ _this._renderCount = 0, /* @internal */ _this._shaderProgramPools = [], /** @internal */ _this._fontMap = {}, /** @internal */ _this._macroCollection = new ShaderMacroCollection(), /** @internal */ _this._postProcessPassNeedRefresh = false, _this._settings = {}, _this._resourceManager = new ResourceManager(_this), _this._sceneManager = new SceneManager(_this), _this._vSyncCount = 1, _this._targetFrameRate = 60, _this._time = new Time(), _this._isPaused = true, _this._vSyncCounter = 1, _this._targetFrameInterval = 1000 / 60, _this._destroyed = false, _this._frameInProcess = false, _this._waitingDestroy = false, _this._isDeviceLost = false, _this._waitingGC = false, _this._postProcessPasses = new Array(), _this._activePostProcessPasses = new Array(), _this._animate = function() {
30603
+ _this = EventDispatcher.call(this) || this, /** @internal */ _this._physicsInitialized = false, /* @internal */ _this._lastRenderState = new RenderState(), /* @internal */ _this._renderElementPool = new ClearableObjectPool(RenderElement), /* @internal */ _this._subRenderElementPool = new ClearableObjectPool(SubRenderElement), /* @internal */ _this._textSubRenderElementPool = new ClearableObjectPool(SubRenderElement), /* @internal */ _this._charRenderInfoPool = new ReturnableObjectPool(CharRenderInfo, 50), /* @internal */ _this._renderContext = new RenderContext(), /* @internal */ _this._renderCount = 0, /* @internal */ _this._shaderProgramPools = [], /** @internal */ _this._fontMap = {}, /** @internal */ _this._macroCollection = new ShaderMacroCollection(), /** @internal */ _this._postProcessPassNeedRefresh = false, _this._settings = {}, _this._resourceManager = new ResourceManager(_this), _this._sceneManager = new SceneManager(_this), _this._vSyncCount = 1, _this._targetFrameRate = 60, _this._time = new Time(), _this._isPaused = true, _this._vSyncCounter = 1, _this._targetFrameInterval = 1000 / 60, _this._destroyed = false, _this._frameInProcess = false, _this._waitingDestroy = false, _this._waitingGC = false, _this._postProcessPasses = new Array(), _this._activePostProcessPasses = new Array(), _this._animate = function() {
30509
30604
  if (_this._vSyncCount) {
30510
30605
  var _this_xrManager;
30511
30606
  var raf = ((_this_xrManager = _this.xrManager) == null ? void 0 : _this_xrManager._getRequestAnimationFrame()) || requestAnimationFrame;
@@ -30640,7 +30735,7 @@
30640
30735
  scene4._componentsManager.callScriptOnLateUpdate(deltaTime);
30641
30736
  }
30642
30737
  // Render scene and fire `onBeginRender` and `onEndRender`
30643
- if (!this._isDeviceLost) {
30738
+ if (!this._hardwareRenderer.isContextLost()) {
30644
30739
  this._render(scenes);
30645
30740
  }
30646
30741
  if (this._waitingDestroy) {
@@ -30863,7 +30958,6 @@
30863
30958
  });
30864
30959
  };
30865
30960
  _proto._onDeviceLost = function _onDeviceLost() {
30866
- this._isDeviceLost = true;
30867
30961
  // Lose graphic resources
30868
30962
  this.resourceManager._lostGraphicResources();
30869
30963
  console.log("Device lost.");
@@ -30884,7 +30978,6 @@
30884
30978
  resourceManager._restoreResourcesContent().then(function() {
30885
30979
  console.log("Graphic resource content restored.\n\n" + "Device restored.");
30886
30980
  _this.dispatch("devicerestored", _this);
30887
- _this._isDeviceLost = false;
30888
30981
  }).catch(function(error) {
30889
30982
  console.error(error);
30890
30983
  });
@@ -41288,6 +41381,7 @@
41288
41381
  Polyfill._registerMatchAll();
41289
41382
  Polyfill._registerAudioContext();
41290
41383
  Polyfill._registerTextMetrics();
41384
+ Polyfill._registerPromiseFinally();
41291
41385
  };
41292
41386
  Polyfill._registerMatchAll = function _registerMatchAll() {
41293
41387
  if (!String.prototype.matchAll) {
@@ -41385,6 +41479,24 @@
41385
41479
  });
41386
41480
  }
41387
41481
  };
41482
+ Polyfill._registerPromiseFinally = function _registerPromiseFinally() {
41483
+ // iOS Safari 10.0-10.2 and older versions do not support Promise.prototype.finally
41484
+ // Examples: iPhone 6s and below devices without system upgrade
41485
+ if (!Promise.prototype.finally) {
41486
+ Logger.info("Polyfill Promise.prototype.finally");
41487
+ Promise.prototype.finally = function(onFinally) {
41488
+ return this.then(function(value) {
41489
+ return Promise.resolve(onFinally == null ? void 0 : onFinally()).then(function() {
41490
+ return value;
41491
+ });
41492
+ }, function(reason) {
41493
+ return Promise.resolve(onFinally == null ? void 0 : onFinally()).then(function() {
41494
+ throw reason;
41495
+ });
41496
+ });
41497
+ };
41498
+ }
41499
+ };
41388
41500
  return Polyfill;
41389
41501
  }();
41390
41502
  Polyfill.registerPolyfill();
@@ -41530,9 +41642,7 @@
41530
41642
  MeshTopology: MeshTopology,
41531
41643
  ModelMesh: ModelMesh,
41532
41644
  OverflowMode: OverflowMode,
41533
- PBRBaseMaterial: PBRBaseMaterial,
41534
41645
  PBRMaterial: PBRMaterial,
41535
- PBRSpecularMaterial: PBRSpecularMaterial,
41536
41646
  ParticleCompositeCurve: ParticleCompositeCurve,
41537
41647
  ParticleCompositeGradient: ParticleCompositeGradient,
41538
41648
  ParticleCurve: ParticleCurve,
@@ -41671,6 +41781,7 @@
41671
41781
  TrailMaterial: TrailMaterial,
41672
41782
  TrailRenderer: TrailRenderer,
41673
41783
  Transform: Transform,
41784
+ TransformModifyFlags: TransformModifyFlags,
41674
41785
  UnlitMaterial: UnlitMaterial,
41675
41786
  Utils: Utils,
41676
41787
  VelocityOverLifetimeModule: VelocityOverLifetimeModule,
@@ -42021,7 +42132,7 @@
42021
42132
  var cap = this.capabilityList;
42022
42133
  var isWebGL2 = this.rhi.isWebGL2;
42023
42134
  var requireExtension = this.rhi.requireExtension.bind(this.rhi);
42024
- var shaderVertexID = GLCapabilityType.shaderVertexID, standardDerivatives = GLCapabilityType.standardDerivatives, shaderTextureLod = GLCapabilityType.shaderTextureLod, elementIndexUint = GLCapabilityType.elementIndexUint, depthTexture = GLCapabilityType.depthTexture, vertexArrayObject = GLCapabilityType.vertexArrayObject, instancedArrays = GLCapabilityType.instancedArrays, multipleSample = GLCapabilityType.multipleSample, drawBuffers = GLCapabilityType.drawBuffers, blendMinMax = GLCapabilityType.blendMinMax, astc = GLCapabilityType.astc, astc_webkit = GLCapabilityType.astc_webkit, etc = GLCapabilityType.etc, etc_webkit = GLCapabilityType.etc_webkit, etc1 = GLCapabilityType.etc1, etc1_webkit = GLCapabilityType.etc1_webkit, pvrtc = GLCapabilityType.pvrtc, pvrtc_webkit = GLCapabilityType.pvrtc_webkit, s3tc = GLCapabilityType.s3tc, s3tc_webkit = GLCapabilityType.s3tc_webkit, bptc = GLCapabilityType.bptc, s3tc_srgb = GLCapabilityType.s3tc_srgb, textureFloat = GLCapabilityType.textureFloat, textureHalfFloat = GLCapabilityType.textureHalfFloat, textureFloatLinear = GLCapabilityType.textureFloatLinear, textureHalfFloatLinear = GLCapabilityType.textureHalfFloatLinear, WEBGL_colorBufferFloat = GLCapabilityType.WEBGL_colorBufferFloat, colorBufferFloat = GLCapabilityType.colorBufferFloat, colorBufferHalfFloat = GLCapabilityType.colorBufferHalfFloat, textureFilterAnisotropic = GLCapabilityType.textureFilterAnisotropic, fragDepth = GLCapabilityType.fragDepth, sRGB = GLCapabilityType.sRGB;
42135
+ var shaderVertexID = GLCapabilityType.shaderVertexID, standardDerivatives = GLCapabilityType.standardDerivatives, shaderTextureLod = GLCapabilityType.shaderTextureLod, elementIndexUint = GLCapabilityType.elementIndexUint, depthTexture = GLCapabilityType.depthTexture, vertexArrayObject = GLCapabilityType.vertexArrayObject, instancedArrays = GLCapabilityType.instancedArrays, multipleSample = GLCapabilityType.multipleSample, drawBuffers = GLCapabilityType.drawBuffers, blendMinMax = GLCapabilityType.blendMinMax, astc = GLCapabilityType.astc, astc_webkit = GLCapabilityType.astc_webkit, astc_hdr = GLCapabilityType.astc_hdr, etc = GLCapabilityType.etc, etc_webkit = GLCapabilityType.etc_webkit, etc1 = GLCapabilityType.etc1, etc1_webkit = GLCapabilityType.etc1_webkit, pvrtc = GLCapabilityType.pvrtc, pvrtc_webkit = GLCapabilityType.pvrtc_webkit, s3tc = GLCapabilityType.s3tc, s3tc_webkit = GLCapabilityType.s3tc_webkit, bptc = GLCapabilityType.bptc, s3tc_srgb = GLCapabilityType.s3tc_srgb, textureFloat = GLCapabilityType.textureFloat, textureHalfFloat = GLCapabilityType.textureHalfFloat, textureFloatLinear = GLCapabilityType.textureFloatLinear, textureHalfFloatLinear = GLCapabilityType.textureHalfFloatLinear, WEBGL_colorBufferFloat = GLCapabilityType.WEBGL_colorBufferFloat, colorBufferFloat = GLCapabilityType.colorBufferFloat, colorBufferHalfFloat = GLCapabilityType.colorBufferHalfFloat, textureFilterAnisotropic = GLCapabilityType.textureFilterAnisotropic, fragDepth = GLCapabilityType.fragDepth, sRGB = GLCapabilityType.sRGB;
42025
42136
  cap.set(shaderVertexID, isWebGL2);
42026
42137
  cap.set(standardDerivatives, isWebGL2 || !!requireExtension(standardDerivatives));
42027
42138
  cap.set(shaderTextureLod, isWebGL2 || !!requireExtension(shaderTextureLod));
@@ -42040,13 +42151,15 @@
42040
42151
  cap.set(colorBufferHalfFloat, isWebGL2 && !!requireExtension(colorBufferFloat) || !!requireExtension(colorBufferHalfFloat));
42041
42152
  cap.set(textureFilterAnisotropic, !!requireExtension(textureFilterAnisotropic));
42042
42153
  cap.set(fragDepth, isWebGL2 || !!requireExtension(fragDepth));
42043
- cap.set(astc, !!(requireExtension(astc) || requireExtension(astc_webkit)));
42044
42154
  cap.set(etc, !!(requireExtension(etc) || requireExtension(etc_webkit)));
42045
42155
  cap.set(etc1, !!(requireExtension(etc1) || requireExtension(etc1_webkit)));
42046
42156
  cap.set(pvrtc, !!(requireExtension(pvrtc) || requireExtension(pvrtc_webkit)));
42047
42157
  cap.set(s3tc, !!(requireExtension(s3tc) || requireExtension(s3tc_webkit)));
42048
42158
  cap.set(s3tc_srgb, !!requireExtension(s3tc_srgb));
42049
42159
  cap.set(bptc, !!requireExtension(bptc));
42160
+ var astcExtension = requireExtension(astc) || requireExtension(astc_webkit);
42161
+ cap.set(astc, !!astcExtension);
42162
+ cap.set(astc_hdr, !!(astcExtension == null ? void 0 : astcExtension.getSupportedProfiles().includes("hdr")));
42050
42163
  cap.set(sRGB, isWebGL2 || !!requireExtension(sRGB));
42051
42164
  };
42052
42165
  /**
@@ -42681,6 +42794,11 @@
42681
42794
  internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB_ALPHA_BPTC_UNORM_EXT : GLCompressedTextureInternalFormat.RGBA_BPTC_UNORM_EXT,
42682
42795
  isCompressed: true
42683
42796
  };
42797
+ case TextureFormat.BC6H:
42798
+ return {
42799
+ internalFormat: GLCompressedTextureInternalFormat.RGB_BPTC_UNSIGNED_FLOAT_EXT,
42800
+ isCompressed: true
42801
+ };
42684
42802
  case TextureFormat.ETC1_RGB:
42685
42803
  return {
42686
42804
  internalFormat: GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL,
@@ -43774,6 +43892,12 @@
43774
43892
  var extension = this.requireExtension(GLCapabilityType.WEBGL_lose_context);
43775
43893
  extension.restoreContext();
43776
43894
  };
43895
+ /**
43896
+ * @remarks
43897
+ * WebGL context loss and restore can happen at any GPU execution point. refs to: https://www.khronos.org/webgl/wiki/HandlingContextLost
43898
+ */ _proto.isContextLost = function isContextLost() {
43899
+ return this.gl.isContextLost();
43900
+ };
43777
43901
  _proto.resetState = function resetState() {
43778
43902
  this._readFrameBuffer = null;
43779
43903
  this._enableGlobalDepthBias = false;
@@ -44576,6 +44700,9 @@
44576
44700
  this.componentConfigMap = new Map();
44577
44701
  this.rootIds = [];
44578
44702
  this.strippedIds = [];
44703
+ this._tasks = new Set();
44704
+ this._loaded = 0;
44705
+ this._total = 0;
44579
44706
  this.resourceManager = engine.resourceManager;
44580
44707
  }
44581
44708
  var _proto = ParserContext.prototype;
@@ -44587,6 +44714,17 @@
44587
44714
  this.rootIds.length = 0;
44588
44715
  this.strippedIds.length = 0;
44589
44716
  };
44717
+ /** @internal */ _proto._addDependentAsset = function _addDependentAsset(refID, promise) {
44718
+ var _this = this;
44719
+ var tasks = this._tasks;
44720
+ if (tasks.has(refID)) return;
44721
+ ++this._total;
44722
+ tasks.add(refID);
44723
+ promise.finally(function() {
44724
+ ++_this._loaded;
44725
+ _this._setTaskCompleteProgress(_this._loaded, _this._total);
44726
+ });
44727
+ };
44590
44728
  return ParserContext;
44591
44729
  }();
44592
44730
  var ReflectionParser = /*#__PURE__*/ function() {
@@ -45273,6 +45411,22 @@
45273
45411
  };
45274
45412
  return EditorTexture2DContentRestorer;
45275
45413
  }(ContentRestorer);
45414
+ var MaterialLoaderType = /*#__PURE__*/ function(MaterialLoaderType) {
45415
+ MaterialLoaderType["Vector2"] = "Vector2";
45416
+ MaterialLoaderType["Vector3"] = "Vector3";
45417
+ MaterialLoaderType["Vector4"] = "Vector4";
45418
+ MaterialLoaderType["Color"] = "Color";
45419
+ MaterialLoaderType["Float"] = "Float";
45420
+ MaterialLoaderType["Texture"] = "Texture";
45421
+ MaterialLoaderType["Boolean"] = "Boolean";
45422
+ MaterialLoaderType["Integer"] = "Integer";
45423
+ return MaterialLoaderType;
45424
+ }({});
45425
+ var SpecularMode = /*#__PURE__*/ function(SpecularMode) {
45426
+ SpecularMode["Sky"] = "Sky";
45427
+ SpecularMode["Custom"] = "Custom";
45428
+ return SpecularMode;
45429
+ }({});
45276
45430
  /** @Internal */ var SceneParser = /*#__PURE__*/ function(HierarchyParser) {
45277
45431
  _inherits(SceneParser, HierarchyParser);
45278
45432
  function SceneParser(data, context, scene) {
@@ -45281,6 +45435,43 @@
45281
45435
  return _this;
45282
45436
  }
45283
45437
  var _proto = SceneParser.prototype;
45438
+ /**
45439
+ * @internal
45440
+ */ _proto._collectDependentAssets = function _collectDependentAssets(data) {
45441
+ var context = this.context;
45442
+ var resourceManager = context.resourceManager;
45443
+ this._parseDependentAssets(data);
45444
+ var scene = data.scene;
45445
+ var ambient = scene.ambient;
45446
+ if (ambient) {
45447
+ var useCustomAmbient = ambient.specularMode === SpecularMode.Custom;
45448
+ var useSH = ambient.diffuseMode === DiffuseMode.SphericalHarmonics;
45449
+ var customAmbientLight = ambient.customAmbientLight, ambientLight = ambient.ambientLight;
45450
+ if (useCustomAmbient && customAmbientLight) {
45451
+ // @ts-ignore
45452
+ context._addDependentAsset(customAmbientLight.refId, resourceManager.getResourceByRef(customAmbientLight));
45453
+ }
45454
+ if (ambientLight && (!useCustomAmbient || useSH)) {
45455
+ // @ts-ignore
45456
+ context._addDependentAsset(ambientLight.refId, resourceManager.getResourceByRef(ambientLight));
45457
+ }
45458
+ }
45459
+ var background = scene.background;
45460
+ var backgroundMode = background.mode;
45461
+ if (backgroundMode === BackgroundMode.Texture) {
45462
+ var texture = background.texture;
45463
+ // @ts-ignore
45464
+ texture && context._addDependentAsset(texture.refId, resourceManager.getResourceByRef(texture));
45465
+ } else if (backgroundMode === BackgroundMode.Sky) {
45466
+ var skyMesh = background.skyMesh, skyMaterial = background.skyMaterial;
45467
+ if (skyMesh && skyMaterial) {
45468
+ // @ts-ignore
45469
+ context._addDependentAsset(skyMesh.refId, resourceManager.getResourceByRef(skyMesh));
45470
+ // @ts-ignore
45471
+ context._addDependentAsset(skyMaterial.refId, resourceManager.getResourceByRef(skyMaterial));
45472
+ }
45473
+ }
45474
+ };
45284
45475
  _proto._handleRootEntity = function _handleRootEntity(id) {
45285
45476
  var entityMap = this.context.entityMap;
45286
45477
  this.scene.addRootEntity(entityMap.get(id));
@@ -45289,38 +45480,50 @@
45289
45480
  this.context.clear();
45290
45481
  return this.scene;
45291
45482
  };
45292
- /**
45293
- * Parse scene data.
45294
- * @param engine - the engine of the parser context
45295
- * @param sceneData - scene data which is exported by editor
45296
- * @returns a promise of scene
45297
- */ SceneParser.parse = function parse(engine, sceneData) {
45298
- var scene = new Scene(engine);
45299
- var context = new ParserContext(engine, ParserType.Scene, scene);
45300
- var parser = new SceneParser(sceneData, context, scene);
45301
- parser.start();
45302
- return parser.promise.then(function() {
45303
- return scene;
45304
- });
45483
+ _proto._parseDependentAssets = function _parseDependentAssets(file) {
45484
+ var entities = file.entities;
45485
+ for(var i = 0, n = entities.length; i < n; i++){
45486
+ var entity = entities[i];
45487
+ if (!!entity.assetRefId) {
45488
+ var context = this.context;
45489
+ var refId = entity.assetRefId, key = entity.key;
45490
+ // @ts-ignore
45491
+ context._addDependentAsset(refId, context.resourceManager.getResourceByRef({
45492
+ refId: refId,
45493
+ key: key
45494
+ }));
45495
+ } else if (entity.strippedId) {
45496
+ continue;
45497
+ } else {
45498
+ var components = entity.components;
45499
+ for(var j = 0, m = components.length; j < m; j++){
45500
+ var component = components[j];
45501
+ this._searchDependentAssets(component.methods);
45502
+ this._searchDependentAssets(component.props);
45503
+ }
45504
+ }
45505
+ }
45506
+ };
45507
+ _proto._searchDependentAssets = function _searchDependentAssets(value) {
45508
+ if (Array.isArray(value)) {
45509
+ for(var i = 0, n = value.length; i < n; i++){
45510
+ this._searchDependentAssets(value[i]);
45511
+ }
45512
+ } else if (!!value && (typeof value === "undefined" ? "undefined" : _type_of1(value)) === "object") {
45513
+ // @ts-ignore
45514
+ if (ReflectionParser._isAssetRef(value)) {
45515
+ var context = this.context;
45516
+ // @ts-ignore
45517
+ context._addDependentAsset(value.refId, context.resourceManager.getResourceByRef(value));
45518
+ } else {
45519
+ for(var key in value){
45520
+ this._searchDependentAssets(value[key]);
45521
+ }
45522
+ }
45523
+ }
45305
45524
  };
45306
45525
  return SceneParser;
45307
45526
  }(HierarchyParser);
45308
- var MaterialLoaderType = /*#__PURE__*/ function(MaterialLoaderType) {
45309
- MaterialLoaderType["Vector2"] = "Vector2";
45310
- MaterialLoaderType["Vector3"] = "Vector3";
45311
- MaterialLoaderType["Vector4"] = "Vector4";
45312
- MaterialLoaderType["Color"] = "Color";
45313
- MaterialLoaderType["Float"] = "Float";
45314
- MaterialLoaderType["Texture"] = "Texture";
45315
- MaterialLoaderType["Boolean"] = "Boolean";
45316
- MaterialLoaderType["Integer"] = "Integer";
45317
- return MaterialLoaderType;
45318
- }({});
45319
- var SpecularMode = /*#__PURE__*/ function(SpecularMode) {
45320
- SpecularMode["Sky"] = "Sky";
45321
- SpecularMode["Custom"] = "Custom";
45322
- return SpecularMode;
45323
- }({});
45324
45527
  /**
45325
45528
  * Decode engine binary resource.
45326
45529
  * @param arrayBuffer - array buffer of decode binary file
@@ -46225,9 +46428,11 @@
46225
46428
  var _this = this;
46226
46429
  var task = this._progress.taskComplete;
46227
46430
  task.total += 1;
46228
- taskPromise.then(function() {
46431
+ taskPromise.finally(function() {
46229
46432
  _this._setTaskCompleteProgress(++task.loaded, task.total);
46230
- }, function() {});
46433
+ }).catch(function(e) {
46434
+ // Need catch to avoid unhandled rejection
46435
+ });
46231
46436
  };
46232
46437
  _proto._handleSubAsset = function _handleSubAsset(resource, type, index) {
46233
46438
  var _this = this;
@@ -46293,8 +46498,8 @@
46293
46498
  GLTFParserType[GLTFParserType["AnimatorController"] = 11] = "AnimatorController";
46294
46499
  return GLTFParserType;
46295
46500
  }({});
46296
- var _obj$3;
46297
- var glTFSchemaMap = (_obj$3 = {}, _obj$3[2] = "scenes", _obj$3[3] = "buffers", _obj$3[5] = "textures", _obj$3[6] = "materials", _obj$3[7] = "meshes", _obj$3[8] = "nodes", _obj$3[9] = "skins", _obj$3[10] = "animations", _obj$3[4] = "bufferViews", _obj$3);
46501
+ var _obj$2;
46502
+ var glTFSchemaMap = (_obj$2 = {}, _obj$2[2] = "scenes", _obj$2[3] = "buffers", _obj$2[5] = "textures", _obj$2[6] = "materials", _obj$2[7] = "meshes", _obj$2[8] = "nodes", _obj$2[9] = "skins", _obj$2[10] = "animations", _obj$2[4] = "bufferViews", _obj$2);
46298
46503
  var _obj1$1;
46299
46504
  var glTFResourceMap = (_obj1$1 = {}, _obj1$1[2] = "_sceneRoots", _obj1$1[5] = "textures", _obj1$1[6] = "materials", _obj1$1[7] = "meshes", _obj1$1[8] = "entities", _obj1$1[9] = "skins", _obj1$1[10] = "animations", _obj1$1[11] = "animatorController", _obj1$1);
46300
46505
  function registerGLTFParser(pipeline) {
@@ -46694,12 +46899,11 @@
46694
46899
  DFDTransferFunction[DFDTransferFunction["sRGB"] = 2] = "sRGB";
46695
46900
  return DFDTransferFunction;
46696
46901
  }({});
46697
- var SupercompressionScheme = /*#__PURE__*/ function(SupercompressionScheme) {
46698
- SupercompressionScheme[SupercompressionScheme["None"] = 0] = "None";
46699
- SupercompressionScheme[SupercompressionScheme["BasisLZ"] = 1] = "BasisLZ";
46700
- SupercompressionScheme[SupercompressionScheme["Zstd"] = 2] = "Zstd";
46701
- SupercompressionScheme[SupercompressionScheme["ZLib"] = 3] = "ZLib";
46702
- return SupercompressionScheme;
46902
+ var ColorModel = /*#__PURE__*/ function(ColorModel) {
46903
+ ColorModel[ColorModel["ETC1S"] = 163] = "ETC1S";
46904
+ ColorModel[ColorModel["UASTC_LDR_4X4"] = 166] = "UASTC_LDR_4X4";
46905
+ ColorModel[ColorModel["UASTC_HDR_4X4"] = 167] = "UASTC_HDR_4X4";
46906
+ return ColorModel;
46703
46907
  }({});
46704
46908
  /** @internal */ var KTX2Container = /*#__PURE__*/ function() {
46705
46909
  function KTX2Container(buffer) {
@@ -46859,9 +47063,9 @@
46859
47063
  }
46860
47064
  },
46861
47065
  {
46862
- key: "isUASTC",
47066
+ key: "colorModel",
46863
47067
  get: function get() {
46864
- return this.dataFormatDescriptor.colorModel === 166;
47068
+ return this.dataFormatDescriptor.colorModel;
46865
47069
  }
46866
47070
  }
46867
47071
  ]);
@@ -46878,6 +47082,9 @@
46878
47082
  /** R format, 8 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["R8"] = 5] = "R8";
46879
47083
  /** RG format, 16 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["R8G8"] = 6] = "R8G8";
46880
47084
  /** RGBA format, 32 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["R8G8B8A8"] = 7] = "R8G8B8A8";
47085
+ /** RGB HDR compressed format, 8 bits per pixel. */ KTX2TargetFormat[KTX2TargetFormat["BC6H"] = 8] = "BC6H";
47086
+ /** HDR RGB(A) compressed format, 128 bits per 4x4 pixel block (currently UASTC HDR 4x4 encoders are only RGB). */ KTX2TargetFormat[KTX2TargetFormat["ASTC_HDR_4x4"] = 9] = "ASTC_HDR_4x4";
47087
+ /** RGBA format, 16 bits per channel. */ KTX2TargetFormat[KTX2TargetFormat["R16G16B16A16"] = 10] = "R16G16B16A16";
46881
47088
  return KTX2TargetFormat;
46882
47089
  }({});
46883
47090
  /**
@@ -47020,7 +47227,7 @@
47020
47227
  };
47021
47228
  return AbstractTranscoder;
47022
47229
  }();
47023
- /** @internal */ function TranscodeWorkerCode$1() {
47230
+ /** @internal */ function TranscodeWorkerCode() {
47024
47231
  var initPromise;
47025
47232
  var init = function init(wasmBinary) {
47026
47233
  if (!initPromise) {
@@ -47104,6 +47311,12 @@
47104
47311
  return 10;
47105
47312
  case 1:
47106
47313
  return 7;
47314
+ case 8:
47315
+ return 22;
47316
+ case 9:
47317
+ return 23;
47318
+ case 10:
47319
+ return 25;
47107
47320
  }
47108
47321
  }
47109
47322
  function concat(arrays) {
@@ -47160,6 +47373,9 @@
47160
47373
  }
47161
47374
  var dst = new Uint8Array(ktx2File.getImageTranscodedSizeInBytes(mip, layer, 0, format));
47162
47375
  var status = ktx2File.transcodeImage(dst, mip, layer, face, format, 0, -1, -1);
47376
+ if (targetFormat === 10) {
47377
+ dst = new Uint16Array(dst.buffer, dst.byteOffset, dst.byteLength / Uint16Array.BYTES_PER_ELEMENT);
47378
+ }
47163
47379
  if (!status) {
47164
47380
  cleanup();
47165
47381
  throw new Error("transcodeImage failed.");
@@ -47220,7 +47436,7 @@
47220
47436
  };
47221
47437
  });
47222
47438
  } else {
47223
- var funcCode = TranscodeWorkerCode$1.toString();
47439
+ var funcCode = TranscodeWorkerCode.toString();
47224
47440
  var transcodeString = funcCode.substring(funcCode.indexOf("{"), funcCode.lastIndexOf("}") + 1);
47225
47441
  var workerCode = "\n " + jsCode + "\n " + transcode.toString() + "\n " + transcodeString + "\n ";
47226
47442
  var workerURL = URL.createObjectURL(new Blob([
@@ -47247,209 +47463,6 @@
47247
47463
  };
47248
47464
  return BinomialLLCTranscoder;
47249
47465
  }(AbstractTranscoder);
47250
- function TranscodeWorkerCode() {
47251
- var wasmPromise;
47252
- /**
47253
- * ZSTD (Zstandard) decoder.
47254
- */ var ZSTDDecoder = /*#__PURE__*/ function() {
47255
- function ZSTDDecoder() {}
47256
- var _proto = ZSTDDecoder.prototype;
47257
- _proto.init = function init() {
47258
- if (!this._initPromise) {
47259
- this._initPromise = fetch(ZSTDDecoder.WasmModuleURL).then(function(response) {
47260
- if (response.ok) {
47261
- return response.arrayBuffer();
47262
- }
47263
- throw new Error("Could not fetch the wasm component for the Zstandard decompression lib: " + response.status + " - " + response.statusText);
47264
- }).then(function(arrayBuffer) {
47265
- return WebAssembly.instantiate(arrayBuffer, ZSTDDecoder.IMPORT_OBJECT);
47266
- }).then(this._init);
47267
- }
47268
- return this._initPromise;
47269
- };
47270
- _proto._init = function _init(result) {
47271
- ZSTDDecoder.instance = result.instance;
47272
- ZSTDDecoder.IMPORT_OBJECT.env.emscripten_notify_memory_growth(); // initialize heap.
47273
- };
47274
- _proto.decode = function decode(array, uncompressedSize) {
47275
- if (uncompressedSize === void 0) uncompressedSize = 0;
47276
- if (!ZSTDDecoder.instance) {
47277
- throw new Error("ZSTDDecoder: Await .init() before decoding.");
47278
- }
47279
- var exports = ZSTDDecoder.instance.exports;
47280
- // Write compressed data into WASM memory
47281
- var compressedSize = array.byteLength;
47282
- var compressedPtr = exports.malloc(compressedSize);
47283
- ZSTDDecoder.heap.set(array, compressedPtr);
47284
- // Decompress into WASM memory
47285
- uncompressedSize = uncompressedSize || Number(exports.ZSTD_findDecompressedSize(compressedPtr, compressedSize));
47286
- var uncompressedPtr = exports.malloc(uncompressedSize);
47287
- var actualSize = exports.ZSTD_decompress(uncompressedPtr, uncompressedSize, compressedPtr, compressedSize);
47288
- // Read decompressed data and free WASM memory
47289
- var dec = ZSTDDecoder.heap.slice(uncompressedPtr, uncompressedPtr + actualSize);
47290
- exports.free(compressedPtr);
47291
- exports.free(uncompressedPtr);
47292
- return dec;
47293
- };
47294
- return ZSTDDecoder;
47295
- }();
47296
- ZSTDDecoder.IMPORT_OBJECT = {
47297
- env: {
47298
- emscripten_notify_memory_growth: function emscripten_notify_memory_growth() {
47299
- ZSTDDecoder.heap = new Uint8Array(ZSTDDecoder.instance.exports.memory.buffer);
47300
- }
47301
- }
47302
- };
47303
- ZSTDDecoder.WasmModuleURL = "https://mdn.alipayobjects.com/rms/afts/file/A*awNJR7KqIAEAAAAAAAAAAAAAARQnAQ/zstddec.wasm";
47304
- function transcodeASTCAndBC7(wasmTranscoder, compressedData, width, height) {
47305
- var nBlocks = (width + 3 >> 2) * (height + 3 >> 2);
47306
- var texMemoryPages = nBlocks * 16 + 65535 >> 16;
47307
- var memory = wasmTranscoder.memory;
47308
- var delta = texMemoryPages + 1 - (memory.buffer.byteLength >> 16);
47309
- if (delta > 0) memory.grow(delta);
47310
- var textureView = new Uint8Array(memory.buffer, 65536, nBlocks * 16);
47311
- textureView.set(compressedData);
47312
- return wasmTranscoder.transcode(nBlocks) === 0 ? textureView : null;
47313
- }
47314
- function initWasm(buffer) {
47315
- wasmPromise = WebAssembly.instantiate(buffer, {
47316
- env: {
47317
- memory: new WebAssembly.Memory({
47318
- initial: 16
47319
- })
47320
- }
47321
- }).then(function(moduleWrapper) {
47322
- return moduleWrapper.instance.exports;
47323
- });
47324
- return wasmPromise;
47325
- }
47326
- var zstdDecoder = new ZSTDDecoder();
47327
- function transcode(data, needZstd, wasmModule) {
47328
- var faceCount = data.length;
47329
- var result = new Array(faceCount);
47330
- var promise = Promise.resolve();
47331
- if (needZstd) {
47332
- zstdDecoder.init();
47333
- promise = zstdDecoder._initPromise;
47334
- }
47335
- return promise.then(function() {
47336
- for(var faceIndex = 0; faceIndex < faceCount; faceIndex++){
47337
- var mipmapCount = data[faceIndex].length;
47338
- var decodedData = new Array(mipmapCount);
47339
- for(var i = 0; i < mipmapCount; i++){
47340
- var _data_faceIndex_i = data[faceIndex][i], buffer = _data_faceIndex_i.buffer, levelHeight = _data_faceIndex_i.levelHeight, levelWidth = _data_faceIndex_i.levelWidth, uncompressedByteLength = _data_faceIndex_i.uncompressedByteLength;
47341
- if (needZstd) buffer = zstdDecoder.decode(buffer.slice(), uncompressedByteLength);
47342
- var faceByteLength = buffer.byteLength / faceCount;
47343
- var originByteOffset = buffer.byteOffset;
47344
- var decodedBuffer = transcodeASTCAndBC7(wasmModule, new Uint8Array(buffer.buffer, originByteOffset + faceIndex * faceByteLength, faceByteLength), levelWidth, levelHeight);
47345
- if (decodedBuffer) {
47346
- decodedData[i] = {
47347
- // use wasm memory as buffer, should slice to avoid duplicate
47348
- data: decodedBuffer.slice(),
47349
- width: levelWidth,
47350
- height: levelHeight
47351
- };
47352
- } else {
47353
- throw "buffer decoded error";
47354
- }
47355
- }
47356
- result[faceIndex] = decodedData;
47357
- }
47358
- return result;
47359
- });
47360
- }
47361
- self.onmessage = function onmessage(event) {
47362
- var message = event.data;
47363
- switch(message.type){
47364
- case "init":
47365
- initWasm(message.transcoderWasm).then(function() {
47366
- self.postMessage("init-completed");
47367
- }).catch(function(e) {
47368
- self.postMessage({
47369
- error: e
47370
- });
47371
- });
47372
- break;
47373
- case "transcode":
47374
- wasmPromise.then(function(module) {
47375
- transcode(message.data, message.needZstd, module).then(function(decodedData) {
47376
- self.postMessage(decodedData);
47377
- }).catch(function(e) {
47378
- return self.postMessage({
47379
- error: e
47380
- });
47381
- });
47382
- });
47383
- break;
47384
- }
47385
- };
47386
- }
47387
- /** @internal */ var KhronosTranscoder = /*#__PURE__*/ function(AbstractTranscoder) {
47388
- _inherits(KhronosTranscoder, AbstractTranscoder);
47389
- function KhronosTranscoder(workerLimitCount, type) {
47390
- var _this;
47391
- _this = AbstractTranscoder.call(this, workerLimitCount) || this, _this.type = type;
47392
- return _this;
47393
- }
47394
- var _proto = KhronosTranscoder.prototype;
47395
- _proto._initTranscodeWorkerPool = function _initTranscodeWorkerPool() {
47396
- var _this = this;
47397
- return fetch(KhronosTranscoder.transcoderMap[this.type]).then(function(res) {
47398
- return res.arrayBuffer();
47399
- }).then(function(wasmBuffer) {
47400
- var funcCode = TranscodeWorkerCode.toString();
47401
- var workerURL = URL.createObjectURL(new Blob([
47402
- funcCode.substring(funcCode.indexOf("{") + 1, funcCode.lastIndexOf("}"))
47403
- ], {
47404
- type: "application/javascript"
47405
- }));
47406
- return _this._createTranscodePool(workerURL, wasmBuffer);
47407
- });
47408
- };
47409
- _proto.transcode = function transcode(ktx2Container) {
47410
- var needZstd = ktx2Container.supercompressionScheme === SupercompressionScheme.Zstd;
47411
- var levelCount = ktx2Container.levels.length;
47412
- var faceCount = ktx2Container.faceCount;
47413
- var decodedData = {
47414
- width: ktx2Container.pixelWidth,
47415
- height: ktx2Container.pixelHeight,
47416
- mipmaps: null
47417
- };
47418
- var postMessageData = {
47419
- type: "transcode",
47420
- format: 0,
47421
- needZstd: needZstd,
47422
- data: new Array(faceCount)
47423
- };
47424
- var messageData = postMessageData.data;
47425
- for(var faceIndex = 0; faceIndex < faceCount; faceIndex++){
47426
- var mipmapData = new Array(levelCount);
47427
- for(var mipmapIndex = 0; mipmapIndex < levelCount; mipmapIndex++){
47428
- var level = ktx2Container.levels[mipmapIndex];
47429
- var levelWidth = Math.floor(ktx2Container.pixelWidth / (1 << mipmapIndex)) || 1;
47430
- var levelHeight = Math.floor(ktx2Container.pixelHeight / (1 << mipmapIndex)) || 1;
47431
- var originBuffer = level.levelData.buffer;
47432
- var originOffset = level.levelData.byteOffset;
47433
- var originByteLength = level.levelData.byteLength;
47434
- mipmapData[mipmapIndex] = {
47435
- buffer: new Uint8Array(originBuffer, originOffset, originByteLength),
47436
- levelWidth: levelWidth,
47437
- levelHeight: levelHeight,
47438
- uncompressedByteLength: level.uncompressedByteLength
47439
- };
47440
- }
47441
- messageData[faceIndex] = mipmapData;
47442
- }
47443
- return this._transcodeWorkerPool.postMessage(postMessageData).then(function(data) {
47444
- decodedData.faces = data;
47445
- decodedData.hasAlpha = true;
47446
- return decodedData;
47447
- });
47448
- };
47449
- return KhronosTranscoder;
47450
- }(AbstractTranscoder);
47451
- var _obj$2;
47452
- KhronosTranscoder.transcoderMap = (_obj$2 = {}, _obj$2[KTX2TargetFormat.ASTC] = "https://mdn.alipayobjects.com/rms/afts/file/A*0jiKRK6D1-kAAAAAAAAAAAAAARQnAQ/uastc_astc.wasm", _obj$2);
47453
47466
  exports.KTX2Loader = /*#__PURE__*/ function(Loader) {
47454
47467
  _inherits(KTX2Loader, Loader);
47455
47468
  function KTX2Loader() {
@@ -47463,11 +47476,7 @@
47463
47476
  KTX2Loader._priorityFormats["etc1s"] = options.priorityFormats;
47464
47477
  KTX2Loader._priorityFormats["uastc"] = options.priorityFormats;
47465
47478
  }
47466
- if (options.transcoder === 1) {
47467
- return KTX2Loader._getKhronosTranscoder(options.workerCount).init();
47468
- } else {
47469
- return KTX2Loader._getBinomialLLCTranscoder(options.workerCount).init();
47470
- }
47479
+ return KTX2Loader._getBinomialLLCTranscoder(options.workerCount).init();
47471
47480
  }
47472
47481
  };
47473
47482
  /**
@@ -47495,29 +47504,17 @@
47495
47504
  * @remarks If use loader after releasing, we should release again.
47496
47505
  */ KTX2Loader.release = function release() {
47497
47506
  if (this._binomialLLCTranscoder) this._binomialLLCTranscoder.destroy();
47498
- if (this._khronosTranscoder) this._khronosTranscoder.destroy();
47499
47507
  this._binomialLLCTranscoder = null;
47500
- this._khronosTranscoder = null;
47501
- this._isBinomialInit = false;
47502
47508
  };
47503
47509
  /** @internal */ KTX2Loader._parseBuffer = function _parseBuffer(buffer, engine, params) {
47504
47510
  var ktx2Container = new KTX2Container(buffer);
47505
47511
  var _params_priorityFormats;
47506
- var formatPriorities = (_params_priorityFormats = params == null ? void 0 : params.priorityFormats) != null ? _params_priorityFormats : KTX2Loader._priorityFormats[ktx2Container.isUASTC ? "uastc" : "etc1s"];
47512
+ var formatPriorities = (_params_priorityFormats = params == null ? void 0 : params.priorityFormats) != null ? _params_priorityFormats : KTX2Loader._priorityFormats[ktx2Container.colorModel];
47507
47513
  var targetFormat = KTX2Loader._decideTargetFormat(engine, ktx2Container, formatPriorities);
47508
- var transcodeResultPromise;
47509
- if (KTX2Loader._isBinomialInit || !KhronosTranscoder.transcoderMap[targetFormat] || !ktx2Container.isUASTC) {
47510
- var binomialLLCWorker = KTX2Loader._getBinomialLLCTranscoder();
47511
- transcodeResultPromise = binomialLLCWorker.init().then(function() {
47512
- return binomialLLCWorker.transcode(buffer, targetFormat);
47513
- });
47514
- } else {
47515
- var khronosWorker = KTX2Loader._getKhronosTranscoder();
47516
- transcodeResultPromise = khronosWorker.init().then(function() {
47517
- return khronosWorker.transcode(ktx2Container);
47518
- });
47519
- }
47520
- return transcodeResultPromise.then(function(result) {
47514
+ var binomialLLCWorker = KTX2Loader._getBinomialLLCTranscoder();
47515
+ return binomialLLCWorker.init().then(function() {
47516
+ return binomialLLCWorker.transcode(buffer, targetFormat);
47517
+ }).then(function(result) {
47521
47518
  return {
47522
47519
  ktx2Container: ktx2Container,
47523
47520
  engine: engine,
@@ -47596,15 +47593,9 @@
47596
47593
  };
47597
47594
  KTX2Loader._getBinomialLLCTranscoder = function _getBinomialLLCTranscoder(workerCount) {
47598
47595
  if (workerCount === void 0) workerCount = 4;
47599
- KTX2Loader._isBinomialInit = true;
47600
47596
  var _this__binomialLLCTranscoder;
47601
47597
  return (_this__binomialLLCTranscoder = this._binomialLLCTranscoder) != null ? _this__binomialLLCTranscoder : this._binomialLLCTranscoder = new BinomialLLCTranscoder(workerCount);
47602
47598
  };
47603
- KTX2Loader._getKhronosTranscoder = function _getKhronosTranscoder(workerCount) {
47604
- if (workerCount === void 0) workerCount = 4;
47605
- var _this__khronosTranscoder;
47606
- return (_this__khronosTranscoder = this._khronosTranscoder) != null ? _this__khronosTranscoder : this._khronosTranscoder = new KhronosTranscoder(workerCount, KTX2TargetFormat.ASTC);
47607
- };
47608
47599
  KTX2Loader._getEngineTextureFormat = function _getEngineTextureFormat(basisFormat, transcodeResult) {
47609
47600
  var hasAlpha = transcodeResult.hasAlpha;
47610
47601
  switch(basisFormat){
@@ -47620,52 +47611,65 @@
47620
47611
  return hasAlpha ? TextureFormat.PVRTC_RGBA4 : TextureFormat.PVRTC_RGB4;
47621
47612
  case KTX2TargetFormat.R8G8B8A8:
47622
47613
  return TextureFormat.R8G8B8A8;
47614
+ case KTX2TargetFormat.BC6H:
47615
+ return TextureFormat.BC6H;
47616
+ case KTX2TargetFormat.ASTC_HDR_4x4:
47617
+ return TextureFormat.ASTC_4x4;
47618
+ case KTX2TargetFormat.R16G16B16A16:
47619
+ return TextureFormat.R16G16B16A16;
47623
47620
  }
47624
47621
  };
47625
47622
  return KTX2Loader;
47626
47623
  }(Loader);
47627
- exports.KTX2Loader._isBinomialInit = false;
47628
- exports.KTX2Loader._priorityFormats = {
47629
- etc1s: [
47630
- KTX2TargetFormat.ETC,
47631
- KTX2TargetFormat.BC7,
47632
- KTX2TargetFormat.ASTC,
47633
- KTX2TargetFormat.BC1_BC3,
47634
- KTX2TargetFormat.PVRTC
47635
- ],
47636
- uastc: [
47637
- KTX2TargetFormat.ASTC,
47638
- KTX2TargetFormat.BC7,
47639
- KTX2TargetFormat.ETC,
47640
- KTX2TargetFormat.BC1_BC3,
47641
- KTX2TargetFormat.PVRTC
47642
- ]
47643
- };
47644
- var _obj$1, _obj1, _obj2, _obj3, _obj4, _obj5;
47645
- exports.KTX2Loader._capabilityMap = (_obj5 = {}, _obj5[KTX2TargetFormat.ASTC] = (_obj$1 = {}, _obj$1[DFDTransferFunction.linear] = [
47624
+ var _obj$1;
47625
+ exports.KTX2Loader._priorityFormats = (_obj$1 = {}, _obj$1[ColorModel.ETC1S] = [
47626
+ KTX2TargetFormat.ETC,
47627
+ KTX2TargetFormat.BC7,
47628
+ KTX2TargetFormat.ASTC,
47629
+ KTX2TargetFormat.BC1_BC3,
47630
+ KTX2TargetFormat.PVRTC
47631
+ ], _obj$1[ColorModel.UASTC_LDR_4X4] = [
47632
+ KTX2TargetFormat.ASTC,
47633
+ KTX2TargetFormat.BC7,
47634
+ KTX2TargetFormat.ETC,
47635
+ KTX2TargetFormat.BC1_BC3,
47636
+ KTX2TargetFormat.PVRTC
47637
+ ], _obj$1[ColorModel.UASTC_HDR_4X4] = [
47638
+ KTX2TargetFormat.ASTC_HDR_4x4,
47639
+ KTX2TargetFormat.BC6H,
47640
+ KTX2TargetFormat.R16G16B16A16
47641
+ ], _obj$1);
47642
+ var _obj1, _obj2, _obj3, _obj4, _obj5, _obj6, _obj7, _obj8, _obj9;
47643
+ exports.KTX2Loader._capabilityMap = (_obj9 = {}, _obj9[KTX2TargetFormat.ASTC] = (_obj1 = {}, _obj1[DFDTransferFunction.linear] = [
47646
47644
  GLCapabilityType.astc,
47647
47645
  GLCapabilityType.astc_webkit
47648
- ], _obj$1[DFDTransferFunction.sRGB] = [
47646
+ ], _obj1[DFDTransferFunction.sRGB] = [
47649
47647
  GLCapabilityType.astc,
47650
47648
  GLCapabilityType.astc_webkit
47651
- ], _obj$1), _obj5[KTX2TargetFormat.ETC] = (_obj1 = {}, _obj1[DFDTransferFunction.linear] = [
47649
+ ], _obj1), _obj9[KTX2TargetFormat.ETC] = (_obj2 = {}, _obj2[DFDTransferFunction.linear] = [
47652
47650
  GLCapabilityType.etc,
47653
47651
  GLCapabilityType.etc_webkit
47654
- ], _obj1[DFDTransferFunction.sRGB] = [
47652
+ ], _obj2[DFDTransferFunction.sRGB] = [
47655
47653
  GLCapabilityType.etc,
47656
47654
  GLCapabilityType.etc_webkit
47657
- ], _obj1), _obj5[KTX2TargetFormat.BC7] = (_obj2 = {}, _obj2[DFDTransferFunction.linear] = [
47655
+ ], _obj2), _obj9[KTX2TargetFormat.BC7] = (_obj3 = {}, _obj3[DFDTransferFunction.linear] = [
47658
47656
  GLCapabilityType.bptc
47659
- ], _obj2[DFDTransferFunction.sRGB] = [
47657
+ ], _obj3[DFDTransferFunction.sRGB] = [
47660
47658
  GLCapabilityType.bptc
47661
- ], _obj2), _obj5[KTX2TargetFormat.BC1_BC3] = (_obj3 = {}, _obj3[DFDTransferFunction.linear] = [
47659
+ ], _obj3), _obj9[KTX2TargetFormat.BC1_BC3] = (_obj4 = {}, _obj4[DFDTransferFunction.linear] = [
47662
47660
  GLCapabilityType.s3tc
47663
- ], _obj3[DFDTransferFunction.sRGB] = [
47661
+ ], _obj4[DFDTransferFunction.sRGB] = [
47664
47662
  GLCapabilityType.s3tc_srgb
47665
- ], _obj3), _obj5[KTX2TargetFormat.PVRTC] = (_obj4 = {}, _obj4[DFDTransferFunction.linear] = [
47663
+ ], _obj4), _obj9[KTX2TargetFormat.BC6H] = (_obj5 = {}, _obj5[DFDTransferFunction.linear] = [
47664
+ GLCapabilityType.bptc
47665
+ ], _obj5), _obj9[KTX2TargetFormat.ASTC_HDR_4x4] = (_obj6 = {}, _obj6[DFDTransferFunction.linear] = [
47666
+ GLCapabilityType.astc_hdr
47667
+ ], _obj6), _obj9[KTX2TargetFormat.R16G16B16A16] = (_obj7 = {}, _obj7[DFDTransferFunction.linear] = [
47668
+ GLCapabilityType.textureHalfFloat
47669
+ ], _obj7), _obj9[KTX2TargetFormat.PVRTC] = (_obj8 = {}, _obj8[DFDTransferFunction.linear] = [
47666
47670
  GLCapabilityType.pvrtc,
47667
47671
  GLCapabilityType.pvrtc_webkit
47668
- ], _obj4), _obj5);
47672
+ ], _obj8), _obj9);
47669
47673
  exports.KTX2Loader = __decorate([
47670
47674
  resourceLoader(AssetType.KTX2, [
47671
47675
  "ktx2"
@@ -47695,11 +47699,6 @@
47695
47699
  };
47696
47700
  return KTX2ContentRestorer;
47697
47701
  }(ContentRestorer);
47698
- /** Used for initialize KTX2 transcoder. */ var KTX2Transcoder = /*#__PURE__*/ function(KTX2Transcoder) {
47699
- /** BinomialLLC transcoder. */ KTX2Transcoder[KTX2Transcoder["BinomialLLC"] = 0] = "BinomialLLC";
47700
- /** Khronos transcoder. */ KTX2Transcoder[KTX2Transcoder["Khronos"] = 1] = "Khronos";
47701
- return KTX2Transcoder;
47702
- }({});
47703
47702
  /**
47704
47703
  * @internal
47705
47704
  */ var GLTFContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
@@ -48431,7 +48430,7 @@
48431
48430
  }
48432
48431
  }
48433
48432
  }
48434
- if (material.constructor === PBRMaterial || material.constructor === PBRSpecularMaterial) {
48433
+ if (material.constructor === PBRMaterial) {
48435
48434
  if (emissiveTexture) {
48436
48435
  GLTFMaterialParser._checkOtherTextureTransform(emissiveTexture, "Emissive");
48437
48436
  context.get(GLTFParserType.Texture, emissiveTexture.index).then(function(texture) {
@@ -48990,7 +48989,7 @@
48990
48989
  };
48991
48990
  _proto._isSRGBColorSpace = function _isSRGBColorSpace(textureIndex, materials) {
48992
48991
  return materials == null ? void 0 : materials.some(function(material) {
48993
- var _material_emissiveTexture, _material_pbrMetallicRoughness_baseColorTexture, _material_pbrMetallicRoughness, _material_extensions_KHR_materials_sheen_sheenColorTexture, _material_extensions_KHR_materials_sheen, _material_extensions, _material_extensions_KHR_materials_pbrSpecularGlossiness_diffuseTexture, _material_extensions_KHR_materials_pbrSpecularGlossiness, _material_extensions1, _material_extensions_KHR_materials_pbrSpecularGlossiness_specularGlossinessTexture, _material_extensions_KHR_materials_pbrSpecularGlossiness1, _material_extensions2;
48992
+ var _material_emissiveTexture, _material_pbrMetallicRoughness_baseColorTexture, _material_pbrMetallicRoughness, _material_extensions_KHR_materials_sheen_sheenColorTexture, _material_extensions_KHR_materials_sheen, _material_extensions, _material_extensions_KHR_materials_specular_specularColorTexture, _material_extensions_KHR_materials_specular, _material_extensions1;
48994
48993
  if (((_material_emissiveTexture = material.emissiveTexture) == null ? void 0 : _material_emissiveTexture.index) === textureIndex) {
48995
48994
  return true;
48996
48995
  }
@@ -49000,10 +48999,7 @@
49000
48999
  if (((_material_extensions = material.extensions) == null ? void 0 : (_material_extensions_KHR_materials_sheen = _material_extensions.KHR_materials_sheen) == null ? void 0 : (_material_extensions_KHR_materials_sheen_sheenColorTexture = _material_extensions_KHR_materials_sheen.sheenColorTexture) == null ? void 0 : _material_extensions_KHR_materials_sheen_sheenColorTexture.index) === textureIndex) {
49001
49000
  return true;
49002
49001
  }
49003
- if (((_material_extensions1 = material.extensions) == null ? void 0 : (_material_extensions_KHR_materials_pbrSpecularGlossiness = _material_extensions1.KHR_materials_pbrSpecularGlossiness) == null ? void 0 : (_material_extensions_KHR_materials_pbrSpecularGlossiness_diffuseTexture = _material_extensions_KHR_materials_pbrSpecularGlossiness.diffuseTexture) == null ? void 0 : _material_extensions_KHR_materials_pbrSpecularGlossiness_diffuseTexture.index) === textureIndex) {
49004
- return true;
49005
- }
49006
- if (((_material_extensions2 = material.extensions) == null ? void 0 : (_material_extensions_KHR_materials_pbrSpecularGlossiness1 = _material_extensions2.KHR_materials_pbrSpecularGlossiness) == null ? void 0 : (_material_extensions_KHR_materials_pbrSpecularGlossiness_specularGlossinessTexture = _material_extensions_KHR_materials_pbrSpecularGlossiness1.specularGlossinessTexture) == null ? void 0 : _material_extensions_KHR_materials_pbrSpecularGlossiness_specularGlossinessTexture.index) === textureIndex) {
49002
+ if (((_material_extensions1 = material.extensions) == null ? void 0 : (_material_extensions_KHR_materials_specular = _material_extensions1.KHR_materials_specular) == null ? void 0 : (_material_extensions_KHR_materials_specular_specularColorTexture = _material_extensions_KHR_materials_specular.specularColorTexture) == null ? void 0 : _material_extensions_KHR_materials_specular_specularColorTexture.index) === textureIndex) {
49007
49003
  return true;
49008
49004
  }
49009
49005
  });
@@ -50092,7 +50088,7 @@
50092
50088
  var _proto = ProjectLoader.prototype;
50093
50089
  _proto.load = function load(item, resourceManager) {
50094
50090
  var engine = resourceManager.engine;
50095
- return new AssetPromise(function(resolve, reject) {
50091
+ return new AssetPromise(function(resolve, reject, onTaskCompeteProgress) {
50096
50092
  resourceManager // @ts-ignore
50097
50093
  ._request(item.url, _extends({}, item, {
50098
50094
  type: "json"
@@ -50102,7 +50098,7 @@
50102
50098
  return resourceManager.load({
50103
50099
  type: AssetType.Scene,
50104
50100
  url: data.scene
50105
- }).then(function(scene) {
50101
+ }).onProgress(onTaskCompeteProgress).then(function(scene) {
50106
50102
  engine.sceneManager.activeScene = scene;
50107
50103
  resolve();
50108
50104
  });
@@ -50607,12 +50603,18 @@
50607
50603
  var _proto = SceneLoader.prototype;
50608
50604
  _proto.load = function load(item, resourceManager) {
50609
50605
  var engine = resourceManager.engine;
50610
- return new AssetPromise(function(resolve, reject) {
50606
+ return new AssetPromise(function(resolve, reject, setTaskCompleteProgress) {
50611
50607
  resourceManager // @ts-ignore
50612
50608
  ._request(item.url, _extends({}, item, {
50613
50609
  type: "json"
50614
50610
  })).then(function(data) {
50615
- return SceneParser.parse(engine, data).then(function(scene) {
50611
+ var scene = new Scene(engine);
50612
+ var context = new ParserContext(engine, ParserType.Scene, scene);
50613
+ var parser = new SceneParser(data, context, scene);
50614
+ parser._collectDependentAssets(data);
50615
+ context._setTaskCompleteProgress = setTaskCompleteProgress;
50616
+ parser.start();
50617
+ return parser.promise.then(function() {
50616
50618
  var promises = [];
50617
50619
  // parse ambient light
50618
50620
  var ambient = data.scene.ambient;
@@ -50828,50 +50830,6 @@
50828
50830
  KHR_materials_ior = __decorate([
50829
50831
  registerGLTFExtension("KHR_materials_ior", GLTFExtensionMode.AdditiveParse)
50830
50832
  ], KHR_materials_ior);
50831
- var KHR_materials_pbrSpecularGlossiness = /*#__PURE__*/ function(GLTFExtensionParser) {
50832
- _inherits(KHR_materials_pbrSpecularGlossiness, GLTFExtensionParser);
50833
- function KHR_materials_pbrSpecularGlossiness() {
50834
- return GLTFExtensionParser.apply(this, arguments) || this;
50835
- }
50836
- var _proto = KHR_materials_pbrSpecularGlossiness.prototype;
50837
- _proto.createAndParse = function createAndParse(context, schema, ownerSchema) {
50838
- var engine = context.glTFResource.engine;
50839
- var material = new PBRSpecularMaterial(engine);
50840
- var diffuseFactor = schema.diffuseFactor, diffuseTexture = schema.diffuseTexture, specularFactor = schema.specularFactor, glossinessFactor = schema.glossinessFactor, specularGlossinessTexture = schema.specularGlossinessTexture;
50841
- if (diffuseFactor) {
50842
- material.baseColor.copyFromArray(diffuseFactor);
50843
- }
50844
- if (diffuseTexture) {
50845
- context.get(GLTFParserType.Texture, diffuseTexture.index).then(function(texture) {
50846
- material.baseTexture = texture;
50847
- GLTFParser.executeExtensionsAdditiveAndParse(diffuseTexture.extensions, context, material, diffuseTexture);
50848
- }).catch(function(e) {
50849
- Logger.error("KHR_materials_pbrSpecularGlossiness: diffuse texture error", e);
50850
- });
50851
- }
50852
- if (specularFactor) {
50853
- material.specularColor.set(specularFactor[0], specularFactor[1], specularFactor[2], 1.0);
50854
- }
50855
- if (glossinessFactor !== undefined) {
50856
- material.glossiness = glossinessFactor;
50857
- }
50858
- if (specularGlossinessTexture) {
50859
- exports.GLTFMaterialParser._checkOtherTextureTransform(specularGlossinessTexture, "Specular glossiness");
50860
- context.get(GLTFParserType.Texture, specularGlossinessTexture.index).then(function(texture) {
50861
- material.specularGlossinessTexture = texture;
50862
- }).catch(function(e) {
50863
- Logger.error("KHR_materials_pbrSpecularGlossiness: specular glossiness texture error", e);
50864
- });
50865
- }
50866
- material.name = ownerSchema.name;
50867
- exports.GLTFMaterialParser._parseStandardProperty(context, material, ownerSchema);
50868
- return material;
50869
- };
50870
- return KHR_materials_pbrSpecularGlossiness;
50871
- }(GLTFExtensionParser);
50872
- KHR_materials_pbrSpecularGlossiness = __decorate([
50873
- registerGLTFExtension("KHR_materials_pbrSpecularGlossiness", GLTFExtensionMode.CreateAndParse)
50874
- ], KHR_materials_pbrSpecularGlossiness);
50875
50833
  var KHR_materials_sheen = /*#__PURE__*/ function(GLTFExtensionParser) {
50876
50834
  _inherits(KHR_materials_sheen, GLTFExtensionParser);
50877
50835
  function KHR_materials_sheen() {
@@ -51218,6 +51176,40 @@
51218
51176
  KHR_materials_iridescence = __decorate([
51219
51177
  registerGLTFExtension("KHR_materials_iridescence", GLTFExtensionMode.AdditiveParse)
51220
51178
  ], KHR_materials_iridescence);
51179
+ var KHR_materials_specular = /*#__PURE__*/ function(GLTFExtensionParser) {
51180
+ _inherits(KHR_materials_specular, GLTFExtensionParser);
51181
+ function KHR_materials_specular() {
51182
+ return GLTFExtensionParser.apply(this, arguments) || this;
51183
+ }
51184
+ var _proto = KHR_materials_specular.prototype;
51185
+ _proto.additiveParse = function additiveParse(context, material, schema) {
51186
+ var _schema_specularFactor = schema.specularFactor, specularFactor = _schema_specularFactor === void 0 ? 1 : _schema_specularFactor, specularTexture = schema.specularTexture, specularColorFactor = schema.specularColorFactor, specularColorTexture = schema.specularColorTexture;
51187
+ material.specularIntensity = specularFactor;
51188
+ if (specularColorFactor) {
51189
+ material.specularColor.set(specularColorFactor[0], specularColorFactor[1], specularColorFactor[2], undefined);
51190
+ }
51191
+ if (specularTexture) {
51192
+ exports.GLTFMaterialParser._checkOtherTextureTransform(specularTexture, "Specular intensity texture");
51193
+ context.get(GLTFParserType.Texture, specularTexture.index).then(function(texture) {
51194
+ material.specularIntensityTexture = texture;
51195
+ }).catch(function(e) {
51196
+ Logger.error("KHR_materials_specular: specularTexture error", e);
51197
+ });
51198
+ }
51199
+ if (specularColorTexture) {
51200
+ exports.GLTFMaterialParser._checkOtherTextureTransform(specularColorTexture, "Specular color texture");
51201
+ context.get(GLTFParserType.Texture, specularColorTexture.index).then(function(texture) {
51202
+ material.specularColorTexture = texture;
51203
+ }).catch(function(e) {
51204
+ Logger.error("KHR_materials_specular: SpecularColorTexture error", e);
51205
+ });
51206
+ }
51207
+ };
51208
+ return KHR_materials_specular;
51209
+ }(GLTFExtensionParser);
51210
+ KHR_materials_specular = __decorate([
51211
+ registerGLTFExtension("KHR_materials_specular", GLTFExtensionMode.AdditiveParse)
51212
+ ], KHR_materials_specular);
51221
51213
  var EXT_texture_webp = /*#__PURE__*/ function(GLTFExtensionParser) {
51222
51214
  _inherits(EXT_texture_webp, GLTFExtensionParser);
51223
51215
  function EXT_texture_webp() {
@@ -51238,7 +51230,7 @@
51238
51230
  ], EXT_texture_webp);
51239
51231
 
51240
51232
  //@ts-ignore
51241
- var version = "1.5.14";
51233
+ var version = "1.6.0-alpha.0";
51242
51234
  console.log("Galacean Engine Version: " + version);
51243
51235
  for(var key in CoreObjects){
51244
51236
  Loader.registerClass(key, CoreObjects[key]);
@@ -51374,7 +51366,6 @@
51374
51366
  exports.JointLimits = JointLimits;
51375
51367
  exports.JointMotor = JointMotor;
51376
51368
  exports.KTX2TargetFormat = KTX2TargetFormat;
51377
- exports.KTX2Transcoder = KTX2Transcoder;
51378
51369
  exports.Keyframe = Keyframe;
51379
51370
  exports.Keys = Keys;
51380
51371
  exports.Layer = Layer;
@@ -51395,9 +51386,7 @@
51395
51386
  exports.MeshTopology = MeshTopology;
51396
51387
  exports.ModelMesh = ModelMesh;
51397
51388
  exports.OverflowMode = OverflowMode;
51398
- exports.PBRBaseMaterial = PBRBaseMaterial;
51399
51389
  exports.PBRMaterial = PBRMaterial;
51400
- exports.PBRSpecularMaterial = PBRSpecularMaterial;
51401
51390
  exports.ParserContext = ParserContext;
51402
51391
  exports.ParserType = ParserType;
51403
51392
  exports.ParticleCompositeCurve = ParticleCompositeCurve;
@@ -51545,6 +51534,7 @@
51545
51534
  exports.TrailMaterial = TrailMaterial;
51546
51535
  exports.TrailRenderer = TrailRenderer;
51547
51536
  exports.Transform = Transform;
51537
+ exports.TransformModifyFlags = TransformModifyFlags;
51548
51538
  exports.UnlitMaterial = UnlitMaterial;
51549
51539
  exports.Utils = Utils;
51550
51540
  exports.Vector2 = Vector2;