@galacean/effects-threejs 2.10.0-alpha.5 → 2.10.1

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 threejs plugin for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.10.0-alpha.5
6
+ * Version: v2.10.1
7
7
  */
8
8
 
9
9
  'use strict';
@@ -2259,10 +2259,10 @@ var Color = /*#__PURE__*/ function() {
2259
2259
  };
2260
2260
  _proto.toHexString = function toHexString(includeAlpha) {
2261
2261
  if (includeAlpha === void 0) includeAlpha = true;
2262
- var R = Color.ToHex(Math.round(this.r * 255));
2263
- var G = Color.ToHex(Math.round(this.g * 255));
2264
- var B = Color.ToHex(Math.round(this.b * 255));
2265
- var A = Color.ToHex(Math.round(this.a * 255));
2262
+ var R = Color.ToHex(Math.round(Math.min(Math.max(this.r, 0), 1) * 255));
2263
+ var G = Color.ToHex(Math.round(Math.min(Math.max(this.g, 0), 1) * 255));
2264
+ var B = Color.ToHex(Math.round(Math.min(Math.max(this.b, 0), 1) * 255));
2265
+ var A = Color.ToHex(Math.round(Math.min(Math.max(this.a, 0), 1) * 255));
2266
2266
  if (includeAlpha) {
2267
2267
  return "#" + R + G + B + A;
2268
2268
  } else {
@@ -2308,30 +2308,14 @@ var Color = /*#__PURE__*/ function() {
2308
2308
  * @param v - Gamma 空间颜色值
2309
2309
  * @returns 线性空间颜色值
2310
2310
  */ Color.gammaToLinear = function gammaToLinear(v) {
2311
- if (v <= 0.0) {
2312
- return 0.0;
2313
- } else if (v <= 0.04045) {
2314
- return v / 12.92;
2315
- } else if (v < 1.0) {
2316
- return Math.pow((v + 0.055) / 1.055, 2.4);
2317
- } else {
2318
- return Math.pow(v, 2.4);
2319
- }
2311
+ return v < 0.04045 ? v * 0.0773993808 : Math.pow(v * 0.9478672986 + 0.0521327014, 2.4);
2320
2312
  };
2321
2313
  /**
2322
2314
  * 颜色值从线性空间转到 Gamma 空间
2323
2315
  * @param value - 线性空间颜色值
2324
2316
  * @returns Gamma 空间颜色值
2325
2317
  */ Color.linearToGamma = function linearToGamma(value) {
2326
- if (value <= 0.0) {
2327
- return 0.0;
2328
- } else if (value < 0.0031308) {
2329
- return 12.92 * value;
2330
- } else if (value < 1.0) {
2331
- return 1.055 * Math.pow(value, 0.41666) - 0.055;
2332
- } else {
2333
- return Math.pow(value, 0.41666);
2334
- }
2318
+ return value < 0.0031308 ? value * 12.92 : 1.055 * Math.pow(value, 0.41666) - 0.055;
2335
2319
  };
2336
2320
  Color.ToHex = function ToHex(i) {
2337
2321
  var str = i.toString(16);
@@ -3129,7 +3113,8 @@ function _inherits(subClass, superClass) {
3129
3113
  JSONSceneVersion["3_5"] = "3.5";
3130
3114
  JSONSceneVersion["3_6"] = "3.6";
3131
3115
  JSONSceneVersion["3_7"] = "3.7";
3132
- JSONSceneVersion["LATEST"] = "3.7";
3116
+ JSONSceneVersion["3_8"] = "3.8";
3117
+ JSONSceneVersion["LATEST"] = "3.8";
3133
3118
  })(JSONSceneVersion || (JSONSceneVersion = {}));
3134
3119
 
3135
3120
  /*********************************************/ /* 元素属性参数类型 */ /*********************************************/ /**
@@ -3525,6 +3510,9 @@ var CameraClipMode;
3525
3510
  /**
3526
3511
  * Vector3 曲线
3527
3512
  */ ValueType[ValueType["VECTOR3_CURVE"] = 27] = "VECTOR3_CURVE";
3513
+ /**
3514
+ * 对象引用阶梯曲线(不插值)
3515
+ */ ValueType[ValueType["REFERENCE_CURVE"] = 28] = "REFERENCE_CURVE";
3528
3516
  })(ValueType || (ValueType = {}));
3529
3517
  /**
3530
3518
  * 关键帧类型
@@ -3768,6 +3756,15 @@ var BuiltinObjectGUID = {
3768
3756
  UnlitShader: "unlit000000000000000000000000000"
3769
3757
  };
3770
3758
 
3759
+ /**
3760
+ * Sprite UV 旋转方式。序列化为整数(兼容老 splits 的 flip 0/1)。
3761
+ * None 不旋转、Rotate90 将 UV 顺时针旋转 90°(width/height 互换)。
3762
+ */ var SpriteRotation;
3763
+ (function(SpriteRotation) {
3764
+ /** 不旋转 */ SpriteRotation[SpriteRotation["None"] = 0] = "None";
3765
+ /** UV 旋转 90°(对应老 splits flip=1) */ SpriteRotation[SpriteRotation["Rotate90"] = 1] = "Rotate90";
3766
+ })(SpriteRotation || (SpriteRotation = {}));
3767
+
3771
3768
  var FillType;
3772
3769
  (function(FillType) {
3773
3770
  FillType[FillType["Solid"] = 0] = "Solid";
@@ -3879,6 +3876,7 @@ var DataType;
3879
3876
  DataType["Image"] = "Image";
3880
3877
  DataType["AnimationClip"] = "AnimationClip";
3881
3878
  DataType["BinaryAsset"] = "BinaryAsset";
3879
+ DataType["Sprite"] = "Sprite";
3882
3880
  // Timeline
3883
3881
  DataType["TrackAsset"] = "TrackAsset";
3884
3882
  DataType["TimelineAsset"] = "TimelineAsset";
@@ -3892,6 +3890,7 @@ var DataType;
3892
3890
  DataType["Vector2PropertyTrack"] = "Vector2PropertyTrack";
3893
3891
  DataType["Vector3PropertyTrack"] = "Vector3PropertyTrack";
3894
3892
  DataType["Vector4PropertyTrack"] = "Vector4PropertyTrack";
3893
+ DataType["SpritePropertyTrack"] = "SpritePropertyTrack";
3895
3894
  DataType["TransformPlayableAsset"] = "TransformPlayableAsset";
3896
3895
  DataType["SpriteColorPlayableAsset"] = "SpriteColorPlayableAsset";
3897
3896
  DataType["ActivationPlayableAsset"] = "ActivationPlayableAsset";
@@ -3901,6 +3900,7 @@ var DataType;
3901
3900
  DataType["Vector2PropertyPlayableAsset"] = "Vector2PropertyPlayableAsset";
3902
3901
  DataType["Vector3PropertyPlayableAsset"] = "Vector3PropertyPlayableAsset";
3903
3902
  DataType["Vector4PropertyPlayableAsset"] = "Vector4PropertyPlayableAsset";
3903
+ DataType["SpritePropertyPlayableAsset"] = "SpritePropertyPlayableAsset";
3904
3904
  // Components
3905
3905
  DataType["MeshComponent"] = "MeshComponent";
3906
3906
  DataType["SkyboxComponent"] = "SkyboxComponent";
@@ -3927,6 +3927,42 @@ var DataType;
3927
3927
  DataType["FFDComponent"] = "FFDComponent";
3928
3928
  DataType["FrameComponent"] = "FrameComponent";
3929
3929
  DataType["Animator"] = "Animator";
3930
+ DataType["DomContentComponent"] = "DomContentComponent";
3931
+ DataType["UIControl"] = "UIControl";
3932
+ // GUI Controls
3933
+ DataType["Control"] = "Control";
3934
+ DataType["Container"] = "Container";
3935
+ DataType["HBoxContainer"] = "HBoxContainer";
3936
+ DataType["VBoxContainer"] = "VBoxContainer";
3937
+ DataType["GridContainer"] = "GridContainer";
3938
+ DataType["PanelContainer"] = "PanelContainer";
3939
+ DataType["MarginContainer"] = "MarginContainer";
3940
+ DataType["CenterContainer"] = "CenterContainer";
3941
+ DataType["AspectRatioContainer"] = "AspectRatioContainer";
3942
+ DataType["ScrollContainer"] = "ScrollContainer";
3943
+ DataType["HScrollBar"] = "HScrollBar";
3944
+ DataType["VScrollBar"] = "VScrollBar";
3945
+ DataType["HSeparator"] = "HSeparator";
3946
+ DataType["VSeparator"] = "VSeparator";
3947
+ DataType["Label"] = "Label";
3948
+ DataType["LineEdit"] = "LineEdit";
3949
+ DataType["TextEdit"] = "TextEdit";
3950
+ DataType["PopupPanel"] = "PopupPanel";
3951
+ DataType["PopupMenu"] = "PopupMenu";
3952
+ DataType["MenuButton"] = "MenuButton";
3953
+ DataType["OptionButton"] = "OptionButton";
3954
+ DataType["ColorPicker"] = "ColorPicker";
3955
+ DataType["ColorPickerButton"] = "ColorPickerButton";
3956
+ DataType["TextureRect"] = "TextureRect";
3957
+ DataType["NinePatchRect"] = "NinePatchRect";
3958
+ DataType["ColorRect"] = "ColorRect";
3959
+ DataType["Panel"] = "Panel";
3960
+ DataType["ProgressBar"] = "ProgressBar";
3961
+ DataType["Button"] = "Button";
3962
+ DataType["Checkbox"] = "Checkbox";
3963
+ DataType["CheckButton"] = "CheckButton";
3964
+ DataType["HSlider"] = "HSlider";
3965
+ DataType["VSlider"] = "VSlider";
3930
3966
  // Non-EffectObject
3931
3967
  DataType["TimelineClip"] = "TimelineClip";
3932
3968
  })(DataType || (DataType = {}));
@@ -4065,6 +4101,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
4065
4101
  get TextWeight () { return TextWeight; },
4066
4102
  get FontStyle () { return FontStyle; },
4067
4103
  BuiltinObjectGUID: BuiltinObjectGUID,
4104
+ get SpriteRotation () { return SpriteRotation; },
4068
4105
  get FillType () { return FillType; },
4069
4106
  get TexturePaintScaleMode () { return TexturePaintScaleMode; },
4070
4107
  get ShapePrimitiveType () { return ShapePrimitiveType; },
@@ -9241,7 +9278,7 @@ function isUniformStructArray(value) {
9241
9278
  return v.set(this.elements[i * 4], this.elements[i * 4 + 1], this.elements[i * 4 + 2], this.elements[i * 4 + 3]);
9242
9279
  };
9243
9280
  /**
9244
- * 设置相机矩阵
9281
+ * 设置矩阵的朝向旋转部分
9245
9282
  * @param eye - 相机位置
9246
9283
  * @param target - 目标位置
9247
9284
  * @param up - 相机方向
@@ -9251,27 +9288,32 @@ function isUniformStructArray(value) {
9251
9288
  var vY = Matrix4.tempVec1;
9252
9289
  var vZ = Matrix4.tempVec2;
9253
9290
  vZ.subtractVectors(eye, target);
9291
+ if (vZ.lengthSquared() === 0) {
9292
+ vZ.z = 1;
9293
+ }
9254
9294
  vZ.normalize();
9255
9295
  vX.crossVectors(up, vZ);
9296
+ if (vX.lengthSquared() === 0) {
9297
+ if (Math.abs(up.z) === 1) {
9298
+ vZ.x += 0.0001;
9299
+ } else {
9300
+ vZ.z += 0.0001;
9301
+ }
9302
+ vZ.normalize();
9303
+ vX.crossVectors(up, vZ);
9304
+ }
9256
9305
  vX.normalize();
9257
9306
  vY.crossVectors(vZ, vX);
9258
9307
  var te = this.elements;
9259
9308
  te[0] = vX.x;
9260
- te[1] = vY.x;
9261
- te[2] = vZ.x;
9262
- te[3] = 0;
9263
- te[4] = vX.y;
9309
+ te[4] = vY.x;
9310
+ te[8] = vZ.x;
9311
+ te[1] = vX.y;
9264
9312
  te[5] = vY.y;
9265
- te[6] = vZ.y;
9266
- te[7] = 0;
9267
- te[8] = vX.z;
9268
- te[9] = vY.z;
9313
+ te[9] = vZ.y;
9314
+ te[2] = vX.z;
9315
+ te[6] = vY.z;
9269
9316
  te[10] = vZ.z;
9270
- te[11] = 0;
9271
- te[12] = -vX.dot(eye);
9272
- te[13] = -vY.dot(eye);
9273
- te[14] = -vZ.dot(eye);
9274
- te[15] = 1;
9275
9317
  return this;
9276
9318
  };
9277
9319
  /**
@@ -9497,6 +9539,7 @@ function isUniformStructArray(value) {
9497
9539
  te[12] = l * te[0] + m * te[4] + n * te[8] - l + translation.x;
9498
9540
  te[13] = l * te[1] + m * te[5] + n * te[9] - m + translation.y;
9499
9541
  te[14] = l * te[2] + m * te[6] + n * te[10] - n + translation.z;
9542
+ te[15] = 1;
9500
9543
  return this;
9501
9544
  };
9502
9545
  /**
@@ -9788,7 +9831,7 @@ function isUniformStructArray(value) {
9788
9831
  return new Matrix4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
9789
9832
  };
9790
9833
  /**
9791
- * 创建相机矩阵
9834
+ * 创建朝向旋转矩阵
9792
9835
  * @param eye - 相机位置
9793
9836
  * @param target - 目标位置
9794
9837
  * @param up - 相机方向
@@ -11003,6 +11046,9 @@ Euler.tempMat0 = new Matrix4();
11003
11046
  * @param [out] - 交点
11004
11047
  * @returns
11005
11048
  */ _proto.intersectSphere = function intersectSphere(sphere, out) {
11049
+ if (sphere.radius < 0) {
11050
+ return;
11051
+ }
11006
11052
  var center = sphere.center;
11007
11053
  var vector = Ray.tempVec0.subtractVectors(center, this.origin);
11008
11054
  var tca = vector.dot(this.direction);
@@ -11329,7 +11375,7 @@ Ray.tempVec3 = new Vector3();
11329
11375
  * @returns
11330
11376
  */ _proto.intersectsSphere = function intersectsSphere(sphere) {
11331
11377
  // Find the point on the AABB closest to the sphere center.
11332
- var vector = new Vector3();
11378
+ var vector = Box3.tempVec0;
11333
11379
  this.clampPoint(sphere.center, vector);
11334
11380
  // If that point is inside the sphere, the AABB and sphere intersect.
11335
11381
  return vector.distanceSquared(sphere.center) <= sphere.radius * sphere.radius;
@@ -11415,9 +11461,11 @@ Ray.tempVec3 = new Vector3();
11415
11461
  * @param target
11416
11462
  * @returns
11417
11463
  */ _proto.getBoundingSphere = function getBoundingSphere(target) {
11464
+ if (this.isEmpty()) {
11465
+ return target.makeEmpty();
11466
+ }
11418
11467
  this.getCenter(target.center);
11419
- var vector = new Vector3();
11420
- target.radius = this.getSize(vector).length() * 0.5;
11468
+ target.radius = this.getSize(Box3.tempVec0).length() * 0.5;
11421
11469
  return target;
11422
11470
  };
11423
11471
  /**
@@ -11438,6 +11486,7 @@ Ray.tempVec3 = new Vector3();
11438
11486
  };
11439
11487
  return Box3;
11440
11488
  }();
11489
+ Box3.tempVec0 = new Vector3();
11441
11490
 
11442
11491
  /**
11443
11492
  * 球
@@ -11468,16 +11517,15 @@ Ray.tempVec3 = new Vector3();
11468
11517
  var center = this.center;
11469
11518
  if (optionalCenter !== undefined) {
11470
11519
  center.copyFrom(optionalCenter);
11471
- var maxRadiusSq = 0;
11472
- for(var i = 0; i < points.length; i++){
11473
- maxRadiusSq = Math.max(maxRadiusSq, center.distanceSquared(points[i]));
11474
- }
11475
- this.radius = Math.sqrt(maxRadiusSq);
11476
11520
  } else {
11477
- var box = new Box3().setFromPoints(points);
11521
+ var box = Sphere.tempBox.setFromPoints(points);
11478
11522
  box.getCenter(center);
11479
- this.radius = box.getSize().length() / 2;
11480
11523
  }
11524
+ var maxRadiusSq = 0;
11525
+ for(var i = 0; i < points.length; i++){
11526
+ maxRadiusSq = Math.max(maxRadiusSq, center.distanceSquared(points[i]));
11527
+ }
11528
+ this.radius = Math.sqrt(maxRadiusSq);
11481
11529
  return this;
11482
11530
  };
11483
11531
  /**
@@ -11594,7 +11642,10 @@ Ray.tempVec3 = new Vector3();
11594
11642
  * @param point - 扩展点
11595
11643
  * @returns 扩展结果
11596
11644
  */ _proto.expandByPoint = function expandByPoint(point) {
11597
- var vector = new Vector3().subtractVectors(point, this.center);
11645
+ if (this.isEmpty()) {
11646
+ return this.set(point, 0);
11647
+ }
11648
+ var vector = Sphere.tempVec0.subtractVectors(point, this.center);
11598
11649
  var lengthSquared = vector.lengthSquared();
11599
11650
  if (lengthSquared > this.radius * this.radius) {
11600
11651
  var length = Math.sqrt(lengthSquared);
@@ -11612,30 +11663,42 @@ Ray.tempVec3 = new Vector3();
11612
11663
  * @param sphere - 包围球
11613
11664
  * @returns 求并结果
11614
11665
  */ _proto.union = function union(sphere) {
11615
- // To enclose another sphere into this sphere, we only need to enclose two points:
11616
- // 1) Enclose the farthest point on the other sphere into this sphere.
11617
- // 2) Enclose the opposite point of the farthest point into this sphere.
11618
- var v1 = new Vector3();
11619
- var toFarthestPoint = new Vector3();
11620
- toFarthestPoint.subtractVectors(sphere.center, this.center).normalize().multiply(sphere.radius);
11621
- this.expandByPoint(v1.copyFrom(sphere.center).add(toFarthestPoint));
11622
- this.expandByPoint(v1.copyFrom(sphere.center).subtract(toFarthestPoint));
11666
+ if (sphere.isEmpty()) {
11667
+ return this;
11668
+ }
11669
+ if (this.isEmpty()) {
11670
+ return this.copyFrom(sphere);
11671
+ }
11672
+ if (this.center.equals(sphere.center)) {
11673
+ this.radius = Math.max(this.radius, sphere.radius);
11674
+ } else {
11675
+ var point = Sphere.tempVec0;
11676
+ var offset = Sphere.tempVec1.subtractVectors(sphere.center, this.center).setLength(sphere.radius);
11677
+ this.expandByPoint(point.copyFrom(sphere.center).add(offset));
11678
+ this.expandByPoint(point.copyFrom(sphere.center).subtract(offset));
11679
+ }
11623
11680
  return this;
11624
11681
  };
11625
11682
  /**
11626
- * 包围球求交集
11683
+ * 获取两个包围球交集的保守包围球。部分重叠时,真实交集为透镜形,
11684
+ * 因此结果取两个输入中较小的包围球,并不精确表示交集。
11627
11685
  * @param other - 其它包围球
11628
11686
  * @returns 求交结果
11629
11687
  */ _proto.intersect = function intersect(other) {
11630
- var vector = new Vector3().subtractVectors(this.center, other.center);
11631
- var distance = vector.length();
11632
- var radiusSum = this.radius + other.radius;
11633
- if (distance > radiusSum) {
11688
+ if (this.isEmpty() || other.isEmpty()) {
11634
11689
  return this.makeEmpty();
11635
11690
  }
11636
- this.center = this.center.add(vector.normalize().multiply(distance / 2));
11637
- this.radius = this.radius + other.radius - distance;
11638
- return this;
11691
+ var distance = this.center.distance(other.center);
11692
+ if (distance > this.radius + other.radius) {
11693
+ return this.makeEmpty();
11694
+ }
11695
+ if (this.radius >= distance + other.radius) {
11696
+ return this.copyFrom(other);
11697
+ }
11698
+ if (other.radius >= distance + this.radius) {
11699
+ return this;
11700
+ }
11701
+ return this.radius <= other.radius ? this : this.copyFrom(other);
11639
11702
  };
11640
11703
  /**
11641
11704
  * 包围球判等
@@ -11652,6 +11715,9 @@ Ray.tempVec3 = new Vector3();
11652
11715
  };
11653
11716
  return Sphere;
11654
11717
  }();
11718
+ Sphere$1.tempBox = new Box3();
11719
+ Sphere$1.tempVec0 = new Vector3();
11720
+ Sphere$1.tempVec1 = new Vector3();
11655
11721
 
11656
11722
  var index = /*#__PURE__*/Object.freeze({
11657
11723
  __proto__: null,
@@ -22855,7 +22921,7 @@ var canvasPool = new CanvasPool();
22855
22921
  ctx.textBaseline = "alphabetic";
22856
22922
  ctx.fillStyle = "#ffffff";
22857
22923
  this.paddingPx = GLYPH_PADDING * resolution;
22858
- this.italicScale = fontStyle === "italic" ? 2 : 1;
22924
+ this.italicScale = fontStyle === "italic" || fontStyle === "oblique" ? 2 : 1;
22859
22925
  // ascent/descent 由探针 '|ÉqÅM' 测得 actualBoundingBox(重音字已抬高 ink 顶),
22860
22926
  // 两者内部保持浮点,仅 cell 高做一次外层 ceil — 与 padding 共同保证 cell 内不裁切
22861
22927
  var fontHeightPx = ascentPx + descentPx;
@@ -37815,7 +37881,7 @@ function getStandardSpriteContent(sprite, transform) {
37815
37881
  return ret;
37816
37882
  }
37817
37883
 
37818
- var version$2 = "2.10.0-alpha.5";
37884
+ var version$2 = "2.10.1";
37819
37885
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
37820
37886
  var standardVersion = /^(\d+)\.(\d+)$/;
37821
37887
  var reverseParticle = false;
@@ -42213,6 +42279,8 @@ var DEFAULT_FPS = 60;
42213
42279
  _this.canvas = canvas;
42214
42280
  var _options_env;
42215
42281
  _this.env = (_options_env = options == null ? void 0 : options.env) != null ? _options_env : "";
42282
+ var _options_ownsCanvas;
42283
+ _this.ownsCanvas = (_options_ownsCanvas = options == null ? void 0 : options.ownsCanvas) != null ? _options_ownsCanvas : true;
42216
42284
  var _options_doNotHandleContextLost;
42217
42285
  _this.doNotHandleContextLost = (_options_doNotHandleContextLost = options == null ? void 0 : options.doNotHandleContextLost) != null ? _options_doNotHandleContextLost : true;
42218
42286
  var _options_name;
@@ -43044,7 +43112,7 @@ registerPlugin("text", TextLoader);
43044
43112
  registerPlugin("sprite", SpriteLoader);
43045
43113
  registerPlugin("particle", ParticleLoader);
43046
43114
  registerPlugin("interact", InteractLoader);
43047
- var version$1 = "2.10.0-alpha.5";
43115
+ var version$1 = "2.10.1";
43048
43116
  logger.info("Core version: " + version$1 + ".");
43049
43117
 
43050
43118
  var _obj;
@@ -44537,7 +44605,7 @@ applyMixins(exports.ThreeTextComponent, [
44537
44605
  */ Mesh.create = function(engine, props) {
44538
44606
  return new ThreeMesh(engine, props);
44539
44607
  };
44540
- var version = "2.10.0-alpha.5";
44608
+ var version = "2.10.1";
44541
44609
  logger.info("THREEJS plugin version: " + version + ".");
44542
44610
 
44543
44611
  exports.ATLAS_SIZE = ATLAS_SIZE;