@galacean/effects-core 2.10.0-alpha.5 → 2.10.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/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.10.0-alpha.5
6
+ * Version: v2.10.0
7
7
  */
8
8
 
9
9
  'use strict';
@@ -2232,10 +2232,10 @@ var Color = /*#__PURE__*/ function() {
2232
2232
  };
2233
2233
  _proto.toHexString = function toHexString(includeAlpha) {
2234
2234
  if (includeAlpha === void 0) includeAlpha = true;
2235
- var R = Color.ToHex(Math.round(this.r * 255));
2236
- var G = Color.ToHex(Math.round(this.g * 255));
2237
- var B = Color.ToHex(Math.round(this.b * 255));
2238
- var A = Color.ToHex(Math.round(this.a * 255));
2235
+ var R = Color.ToHex(Math.round(Math.min(Math.max(this.r, 0), 1) * 255));
2236
+ var G = Color.ToHex(Math.round(Math.min(Math.max(this.g, 0), 1) * 255));
2237
+ var B = Color.ToHex(Math.round(Math.min(Math.max(this.b, 0), 1) * 255));
2238
+ var A = Color.ToHex(Math.round(Math.min(Math.max(this.a, 0), 1) * 255));
2239
2239
  if (includeAlpha) {
2240
2240
  return "#" + R + G + B + A;
2241
2241
  } else {
@@ -2281,30 +2281,14 @@ var Color = /*#__PURE__*/ function() {
2281
2281
  * @param v - Gamma 空间颜色值
2282
2282
  * @returns 线性空间颜色值
2283
2283
  */ Color.gammaToLinear = function gammaToLinear(v) {
2284
- if (v <= 0.0) {
2285
- return 0.0;
2286
- } else if (v <= 0.04045) {
2287
- return v / 12.92;
2288
- } else if (v < 1.0) {
2289
- return Math.pow((v + 0.055) / 1.055, 2.4);
2290
- } else {
2291
- return Math.pow(v, 2.4);
2292
- }
2284
+ return v < 0.04045 ? v * 0.0773993808 : Math.pow(v * 0.9478672986 + 0.0521327014, 2.4);
2293
2285
  };
2294
2286
  /**
2295
2287
  * 颜色值从线性空间转到 Gamma 空间
2296
2288
  * @param value - 线性空间颜色值
2297
2289
  * @returns Gamma 空间颜色值
2298
2290
  */ Color.linearToGamma = function linearToGamma(value) {
2299
- if (value <= 0.0) {
2300
- return 0.0;
2301
- } else if (value < 0.0031308) {
2302
- return 12.92 * value;
2303
- } else if (value < 1.0) {
2304
- return 1.055 * Math.pow(value, 0.41666) - 0.055;
2305
- } else {
2306
- return Math.pow(value, 0.41666);
2307
- }
2291
+ return value < 0.0031308 ? value * 12.92 : 1.055 * Math.pow(value, 0.41666) - 0.055;
2308
2292
  };
2309
2293
  Color.ToHex = function ToHex(i) {
2310
2294
  var str = i.toString(16);
@@ -3102,7 +3086,8 @@ function _inherits(subClass, superClass) {
3102
3086
  JSONSceneVersion["3_5"] = "3.5";
3103
3087
  JSONSceneVersion["3_6"] = "3.6";
3104
3088
  JSONSceneVersion["3_7"] = "3.7";
3105
- JSONSceneVersion["LATEST"] = "3.7";
3089
+ JSONSceneVersion["3_8"] = "3.8";
3090
+ JSONSceneVersion["LATEST"] = "3.8";
3106
3091
  })(JSONSceneVersion || (JSONSceneVersion = {}));
3107
3092
 
3108
3093
  /*********************************************/ /* 元素属性参数类型 */ /*********************************************/ /**
@@ -3498,6 +3483,9 @@ var CameraClipMode;
3498
3483
  /**
3499
3484
  * Vector3 曲线
3500
3485
  */ ValueType[ValueType["VECTOR3_CURVE"] = 27] = "VECTOR3_CURVE";
3486
+ /**
3487
+ * 对象引用阶梯曲线(不插值)
3488
+ */ ValueType[ValueType["REFERENCE_CURVE"] = 28] = "REFERENCE_CURVE";
3501
3489
  })(ValueType || (ValueType = {}));
3502
3490
  /**
3503
3491
  * 关键帧类型
@@ -3741,6 +3729,15 @@ var BuiltinObjectGUID = {
3741
3729
  UnlitShader: "unlit000000000000000000000000000"
3742
3730
  };
3743
3731
 
3732
+ /**
3733
+ * Sprite UV 旋转方式。序列化为整数(兼容老 splits 的 flip 0/1)。
3734
+ * None 不旋转、Rotate90 将 UV 顺时针旋转 90°(width/height 互换)。
3735
+ */ var SpriteRotation;
3736
+ (function(SpriteRotation) {
3737
+ /** 不旋转 */ SpriteRotation[SpriteRotation["None"] = 0] = "None";
3738
+ /** UV 旋转 90°(对应老 splits flip=1) */ SpriteRotation[SpriteRotation["Rotate90"] = 1] = "Rotate90";
3739
+ })(SpriteRotation || (SpriteRotation = {}));
3740
+
3744
3741
  var FillType;
3745
3742
  (function(FillType) {
3746
3743
  FillType[FillType["Solid"] = 0] = "Solid";
@@ -3852,6 +3849,7 @@ var DataType;
3852
3849
  DataType["Image"] = "Image";
3853
3850
  DataType["AnimationClip"] = "AnimationClip";
3854
3851
  DataType["BinaryAsset"] = "BinaryAsset";
3852
+ DataType["Sprite"] = "Sprite";
3855
3853
  // Timeline
3856
3854
  DataType["TrackAsset"] = "TrackAsset";
3857
3855
  DataType["TimelineAsset"] = "TimelineAsset";
@@ -3865,6 +3863,7 @@ var DataType;
3865
3863
  DataType["Vector2PropertyTrack"] = "Vector2PropertyTrack";
3866
3864
  DataType["Vector3PropertyTrack"] = "Vector3PropertyTrack";
3867
3865
  DataType["Vector4PropertyTrack"] = "Vector4PropertyTrack";
3866
+ DataType["SpritePropertyTrack"] = "SpritePropertyTrack";
3868
3867
  DataType["TransformPlayableAsset"] = "TransformPlayableAsset";
3869
3868
  DataType["SpriteColorPlayableAsset"] = "SpriteColorPlayableAsset";
3870
3869
  DataType["ActivationPlayableAsset"] = "ActivationPlayableAsset";
@@ -3874,6 +3873,7 @@ var DataType;
3874
3873
  DataType["Vector2PropertyPlayableAsset"] = "Vector2PropertyPlayableAsset";
3875
3874
  DataType["Vector3PropertyPlayableAsset"] = "Vector3PropertyPlayableAsset";
3876
3875
  DataType["Vector4PropertyPlayableAsset"] = "Vector4PropertyPlayableAsset";
3876
+ DataType["SpritePropertyPlayableAsset"] = "SpritePropertyPlayableAsset";
3877
3877
  // Components
3878
3878
  DataType["MeshComponent"] = "MeshComponent";
3879
3879
  DataType["SkyboxComponent"] = "SkyboxComponent";
@@ -3900,6 +3900,42 @@ var DataType;
3900
3900
  DataType["FFDComponent"] = "FFDComponent";
3901
3901
  DataType["FrameComponent"] = "FrameComponent";
3902
3902
  DataType["Animator"] = "Animator";
3903
+ DataType["DomContentComponent"] = "DomContentComponent";
3904
+ DataType["UIControl"] = "UIControl";
3905
+ // GUI Controls
3906
+ DataType["Control"] = "Control";
3907
+ DataType["Container"] = "Container";
3908
+ DataType["HBoxContainer"] = "HBoxContainer";
3909
+ DataType["VBoxContainer"] = "VBoxContainer";
3910
+ DataType["GridContainer"] = "GridContainer";
3911
+ DataType["PanelContainer"] = "PanelContainer";
3912
+ DataType["MarginContainer"] = "MarginContainer";
3913
+ DataType["CenterContainer"] = "CenterContainer";
3914
+ DataType["AspectRatioContainer"] = "AspectRatioContainer";
3915
+ DataType["ScrollContainer"] = "ScrollContainer";
3916
+ DataType["HScrollBar"] = "HScrollBar";
3917
+ DataType["VScrollBar"] = "VScrollBar";
3918
+ DataType["HSeparator"] = "HSeparator";
3919
+ DataType["VSeparator"] = "VSeparator";
3920
+ DataType["Label"] = "Label";
3921
+ DataType["LineEdit"] = "LineEdit";
3922
+ DataType["TextEdit"] = "TextEdit";
3923
+ DataType["PopupPanel"] = "PopupPanel";
3924
+ DataType["PopupMenu"] = "PopupMenu";
3925
+ DataType["MenuButton"] = "MenuButton";
3926
+ DataType["OptionButton"] = "OptionButton";
3927
+ DataType["ColorPicker"] = "ColorPicker";
3928
+ DataType["ColorPickerButton"] = "ColorPickerButton";
3929
+ DataType["TextureRect"] = "TextureRect";
3930
+ DataType["NinePatchRect"] = "NinePatchRect";
3931
+ DataType["ColorRect"] = "ColorRect";
3932
+ DataType["Panel"] = "Panel";
3933
+ DataType["ProgressBar"] = "ProgressBar";
3934
+ DataType["Button"] = "Button";
3935
+ DataType["Checkbox"] = "Checkbox";
3936
+ DataType["CheckButton"] = "CheckButton";
3937
+ DataType["HSlider"] = "HSlider";
3938
+ DataType["VSlider"] = "VSlider";
3903
3939
  // Non-EffectObject
3904
3940
  DataType["TimelineClip"] = "TimelineClip";
3905
3941
  })(DataType || (DataType = {}));
@@ -4038,6 +4074,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
4038
4074
  get TextWeight () { return TextWeight; },
4039
4075
  get FontStyle () { return FontStyle; },
4040
4076
  BuiltinObjectGUID: BuiltinObjectGUID,
4077
+ get SpriteRotation () { return SpriteRotation; },
4041
4078
  get FillType () { return FillType; },
4042
4079
  get TexturePaintScaleMode () { return TexturePaintScaleMode; },
4043
4080
  get ShapePrimitiveType () { return ShapePrimitiveType; },
@@ -9214,7 +9251,7 @@ function isUniformStructArray(value) {
9214
9251
  return v.set(this.elements[i * 4], this.elements[i * 4 + 1], this.elements[i * 4 + 2], this.elements[i * 4 + 3]);
9215
9252
  };
9216
9253
  /**
9217
- * 设置相机矩阵
9254
+ * 设置矩阵的朝向旋转部分
9218
9255
  * @param eye - 相机位置
9219
9256
  * @param target - 目标位置
9220
9257
  * @param up - 相机方向
@@ -9224,27 +9261,32 @@ function isUniformStructArray(value) {
9224
9261
  var vY = Matrix4.tempVec1;
9225
9262
  var vZ = Matrix4.tempVec2;
9226
9263
  vZ.subtractVectors(eye, target);
9264
+ if (vZ.lengthSquared() === 0) {
9265
+ vZ.z = 1;
9266
+ }
9227
9267
  vZ.normalize();
9228
9268
  vX.crossVectors(up, vZ);
9269
+ if (vX.lengthSquared() === 0) {
9270
+ if (Math.abs(up.z) === 1) {
9271
+ vZ.x += 0.0001;
9272
+ } else {
9273
+ vZ.z += 0.0001;
9274
+ }
9275
+ vZ.normalize();
9276
+ vX.crossVectors(up, vZ);
9277
+ }
9229
9278
  vX.normalize();
9230
9279
  vY.crossVectors(vZ, vX);
9231
9280
  var te = this.elements;
9232
9281
  te[0] = vX.x;
9233
- te[1] = vY.x;
9234
- te[2] = vZ.x;
9235
- te[3] = 0;
9236
- te[4] = vX.y;
9282
+ te[4] = vY.x;
9283
+ te[8] = vZ.x;
9284
+ te[1] = vX.y;
9237
9285
  te[5] = vY.y;
9238
- te[6] = vZ.y;
9239
- te[7] = 0;
9240
- te[8] = vX.z;
9241
- te[9] = vY.z;
9286
+ te[9] = vZ.y;
9287
+ te[2] = vX.z;
9288
+ te[6] = vY.z;
9242
9289
  te[10] = vZ.z;
9243
- te[11] = 0;
9244
- te[12] = -vX.dot(eye);
9245
- te[13] = -vY.dot(eye);
9246
- te[14] = -vZ.dot(eye);
9247
- te[15] = 1;
9248
9290
  return this;
9249
9291
  };
9250
9292
  /**
@@ -9470,6 +9512,7 @@ function isUniformStructArray(value) {
9470
9512
  te[12] = l * te[0] + m * te[4] + n * te[8] - l + translation.x;
9471
9513
  te[13] = l * te[1] + m * te[5] + n * te[9] - m + translation.y;
9472
9514
  te[14] = l * te[2] + m * te[6] + n * te[10] - n + translation.z;
9515
+ te[15] = 1;
9473
9516
  return this;
9474
9517
  };
9475
9518
  /**
@@ -9761,7 +9804,7 @@ function isUniformStructArray(value) {
9761
9804
  return new Matrix4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
9762
9805
  };
9763
9806
  /**
9764
- * 创建相机矩阵
9807
+ * 创建朝向旋转矩阵
9765
9808
  * @param eye - 相机位置
9766
9809
  * @param target - 目标位置
9767
9810
  * @param up - 相机方向
@@ -10976,6 +11019,9 @@ Euler.tempMat0 = new Matrix4();
10976
11019
  * @param [out] - 交点
10977
11020
  * @returns
10978
11021
  */ _proto.intersectSphere = function intersectSphere(sphere, out) {
11022
+ if (sphere.radius < 0) {
11023
+ return;
11024
+ }
10979
11025
  var center = sphere.center;
10980
11026
  var vector = Ray.tempVec0.subtractVectors(center, this.origin);
10981
11027
  var tca = vector.dot(this.direction);
@@ -11302,7 +11348,7 @@ Ray.tempVec3 = new Vector3();
11302
11348
  * @returns
11303
11349
  */ _proto.intersectsSphere = function intersectsSphere(sphere) {
11304
11350
  // Find the point on the AABB closest to the sphere center.
11305
- var vector = new Vector3();
11351
+ var vector = Box3.tempVec0;
11306
11352
  this.clampPoint(sphere.center, vector);
11307
11353
  // If that point is inside the sphere, the AABB and sphere intersect.
11308
11354
  return vector.distanceSquared(sphere.center) <= sphere.radius * sphere.radius;
@@ -11388,9 +11434,11 @@ Ray.tempVec3 = new Vector3();
11388
11434
  * @param target
11389
11435
  * @returns
11390
11436
  */ _proto.getBoundingSphere = function getBoundingSphere(target) {
11437
+ if (this.isEmpty()) {
11438
+ return target.makeEmpty();
11439
+ }
11391
11440
  this.getCenter(target.center);
11392
- var vector = new Vector3();
11393
- target.radius = this.getSize(vector).length() * 0.5;
11441
+ target.radius = this.getSize(Box3.tempVec0).length() * 0.5;
11394
11442
  return target;
11395
11443
  };
11396
11444
  /**
@@ -11411,6 +11459,7 @@ Ray.tempVec3 = new Vector3();
11411
11459
  };
11412
11460
  return Box3;
11413
11461
  }();
11462
+ Box3.tempVec0 = new Vector3();
11414
11463
 
11415
11464
  /**
11416
11465
  * 球
@@ -11441,16 +11490,15 @@ Ray.tempVec3 = new Vector3();
11441
11490
  var center = this.center;
11442
11491
  if (optionalCenter !== undefined) {
11443
11492
  center.copyFrom(optionalCenter);
11444
- var maxRadiusSq = 0;
11445
- for(var i = 0; i < points.length; i++){
11446
- maxRadiusSq = Math.max(maxRadiusSq, center.distanceSquared(points[i]));
11447
- }
11448
- this.radius = Math.sqrt(maxRadiusSq);
11449
11493
  } else {
11450
- var box = new Box3().setFromPoints(points);
11494
+ var box = Sphere.tempBox.setFromPoints(points);
11451
11495
  box.getCenter(center);
11452
- this.radius = box.getSize().length() / 2;
11453
11496
  }
11497
+ var maxRadiusSq = 0;
11498
+ for(var i = 0; i < points.length; i++){
11499
+ maxRadiusSq = Math.max(maxRadiusSq, center.distanceSquared(points[i]));
11500
+ }
11501
+ this.radius = Math.sqrt(maxRadiusSq);
11454
11502
  return this;
11455
11503
  };
11456
11504
  /**
@@ -11567,7 +11615,10 @@ Ray.tempVec3 = new Vector3();
11567
11615
  * @param point - 扩展点
11568
11616
  * @returns 扩展结果
11569
11617
  */ _proto.expandByPoint = function expandByPoint(point) {
11570
- var vector = new Vector3().subtractVectors(point, this.center);
11618
+ if (this.isEmpty()) {
11619
+ return this.set(point, 0);
11620
+ }
11621
+ var vector = Sphere.tempVec0.subtractVectors(point, this.center);
11571
11622
  var lengthSquared = vector.lengthSquared();
11572
11623
  if (lengthSquared > this.radius * this.radius) {
11573
11624
  var length = Math.sqrt(lengthSquared);
@@ -11585,30 +11636,42 @@ Ray.tempVec3 = new Vector3();
11585
11636
  * @param sphere - 包围球
11586
11637
  * @returns 求并结果
11587
11638
  */ _proto.union = function union(sphere) {
11588
- // To enclose another sphere into this sphere, we only need to enclose two points:
11589
- // 1) Enclose the farthest point on the other sphere into this sphere.
11590
- // 2) Enclose the opposite point of the farthest point into this sphere.
11591
- var v1 = new Vector3();
11592
- var toFarthestPoint = new Vector3();
11593
- toFarthestPoint.subtractVectors(sphere.center, this.center).normalize().multiply(sphere.radius);
11594
- this.expandByPoint(v1.copyFrom(sphere.center).add(toFarthestPoint));
11595
- this.expandByPoint(v1.copyFrom(sphere.center).subtract(toFarthestPoint));
11639
+ if (sphere.isEmpty()) {
11640
+ return this;
11641
+ }
11642
+ if (this.isEmpty()) {
11643
+ return this.copyFrom(sphere);
11644
+ }
11645
+ if (this.center.equals(sphere.center)) {
11646
+ this.radius = Math.max(this.radius, sphere.radius);
11647
+ } else {
11648
+ var point = Sphere.tempVec0;
11649
+ var offset = Sphere.tempVec1.subtractVectors(sphere.center, this.center).setLength(sphere.radius);
11650
+ this.expandByPoint(point.copyFrom(sphere.center).add(offset));
11651
+ this.expandByPoint(point.copyFrom(sphere.center).subtract(offset));
11652
+ }
11596
11653
  return this;
11597
11654
  };
11598
11655
  /**
11599
- * 包围球求交集
11656
+ * 获取两个包围球交集的保守包围球。部分重叠时,真实交集为透镜形,
11657
+ * 因此结果取两个输入中较小的包围球,并不精确表示交集。
11600
11658
  * @param other - 其它包围球
11601
11659
  * @returns 求交结果
11602
11660
  */ _proto.intersect = function intersect(other) {
11603
- var vector = new Vector3().subtractVectors(this.center, other.center);
11604
- var distance = vector.length();
11605
- var radiusSum = this.radius + other.radius;
11606
- if (distance > radiusSum) {
11661
+ if (this.isEmpty() || other.isEmpty()) {
11607
11662
  return this.makeEmpty();
11608
11663
  }
11609
- this.center = this.center.add(vector.normalize().multiply(distance / 2));
11610
- this.radius = this.radius + other.radius - distance;
11611
- return this;
11664
+ var distance = this.center.distance(other.center);
11665
+ if (distance > this.radius + other.radius) {
11666
+ return this.makeEmpty();
11667
+ }
11668
+ if (this.radius >= distance + other.radius) {
11669
+ return this.copyFrom(other);
11670
+ }
11671
+ if (other.radius >= distance + this.radius) {
11672
+ return this;
11673
+ }
11674
+ return this.radius <= other.radius ? this : this.copyFrom(other);
11612
11675
  };
11613
11676
  /**
11614
11677
  * 包围球判等
@@ -11625,6 +11688,9 @@ Ray.tempVec3 = new Vector3();
11625
11688
  };
11626
11689
  return Sphere;
11627
11690
  }();
11691
+ Sphere$1.tempBox = new Box3();
11692
+ Sphere$1.tempVec0 = new Vector3();
11693
+ Sphere$1.tempVec1 = new Vector3();
11628
11694
 
11629
11695
  var index = /*#__PURE__*/Object.freeze({
11630
11696
  __proto__: null,
@@ -22828,7 +22894,7 @@ var canvasPool = new CanvasPool();
22828
22894
  ctx.textBaseline = "alphabetic";
22829
22895
  ctx.fillStyle = "#ffffff";
22830
22896
  this.paddingPx = GLYPH_PADDING * resolution;
22831
- this.italicScale = fontStyle === "italic" ? 2 : 1;
22897
+ this.italicScale = fontStyle === "italic" || fontStyle === "oblique" ? 2 : 1;
22832
22898
  // ascent/descent 由探针 '|ÉqÅM' 测得 actualBoundingBox(重音字已抬高 ink 顶),
22833
22899
  // 两者内部保持浮点,仅 cell 高做一次外层 ceil — 与 padding 共同保证 cell 内不裁切
22834
22900
  var fontHeightPx = ascentPx + descentPx;
@@ -37788,7 +37854,7 @@ function getStandardSpriteContent(sprite, transform) {
37788
37854
  return ret;
37789
37855
  }
37790
37856
 
37791
- var version$1 = "2.10.0-alpha.5";
37857
+ var version$1 = "2.10.0";
37792
37858
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
37793
37859
  var standardVersion = /^(\d+)\.(\d+)$/;
37794
37860
  var reverseParticle = false;
@@ -43017,7 +43083,7 @@ registerPlugin("text", TextLoader);
43017
43083
  registerPlugin("sprite", SpriteLoader);
43018
43084
  registerPlugin("particle", ParticleLoader);
43019
43085
  registerPlugin("interact", InteractLoader);
43020
- var version = "2.10.0-alpha.5";
43086
+ var version = "2.10.0";
43021
43087
  logger.info("Core version: " + version + ".");
43022
43088
 
43023
43089
  exports.ATLAS_SIZE = ATLAS_SIZE;