@galacean/effects-threejs 2.6.7 → 2.6.8

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.6.7
6
+ * Version: v2.6.8
7
7
  */
8
8
 
9
9
  'use strict';
@@ -4167,6 +4167,1027 @@ var Blender = /*#__PURE__*/ function() {
4167
4167
  Blender.normalBlendFunction = new NormalBlend();
4168
4168
  Blender.additiveBlendFunction = new AdditiveBlend();
4169
4169
 
4170
+ /**
4171
+ * 四维向量
4172
+ */ var Vector4 = /*#__PURE__*/ function() {
4173
+ function Vector4(x, y, z, w) {
4174
+ if (x === void 0) x = 0;
4175
+ if (y === void 0) y = 0;
4176
+ if (z === void 0) z = 0;
4177
+ if (w === void 0) w = 0;
4178
+ this.x = x;
4179
+ this.y = y;
4180
+ this.z = z;
4181
+ this.w = w;
4182
+ }
4183
+ var _proto = Vector4.prototype;
4184
+ /**
4185
+ * 设置向量
4186
+ * @param x - x 轴分量
4187
+ * @param y - y 轴分量
4188
+ * @param z - z 轴分量
4189
+ * @param w - w 轴分量
4190
+ * @returns
4191
+ */ _proto.set = function set(x, y, z, w) {
4192
+ this.x = x;
4193
+ this.y = y;
4194
+ this.z = z;
4195
+ this.w = w;
4196
+ return this;
4197
+ };
4198
+ /**
4199
+ * 设置零向量
4200
+ * @returns 向量
4201
+ */ _proto.setZero = function setZero() {
4202
+ this.x = 0;
4203
+ this.y = 0;
4204
+ this.z = 0;
4205
+ this.w = 0;
4206
+ return this;
4207
+ };
4208
+ /**
4209
+ * 通过标量数值设置向量
4210
+ * @param num - 数值
4211
+ * @returns 向量
4212
+ */ _proto.setFromNumber = function setFromNumber(num) {
4213
+ this.x = num;
4214
+ this.y = num;
4215
+ this.z = num;
4216
+ this.w = num;
4217
+ return this;
4218
+ };
4219
+ /**
4220
+ * 通过数组创建向量
4221
+ * @param array - 数组
4222
+ * @param [offset=0] - 起始偏移值
4223
+ * @returns 向量
4224
+ */ _proto.setFromArray = function setFromArray(array, offset) {
4225
+ if (offset === void 0) offset = 0;
4226
+ var _array_offset;
4227
+ this.x = (_array_offset = array[offset]) != null ? _array_offset : 0;
4228
+ var _array_;
4229
+ this.y = (_array_ = array[offset + 1]) != null ? _array_ : 0;
4230
+ var _array_1;
4231
+ this.z = (_array_1 = array[offset + 2]) != null ? _array_1 : 0;
4232
+ var _array_2;
4233
+ this.w = (_array_2 = array[offset + 3]) != null ? _array_2 : 0;
4234
+ return this;
4235
+ };
4236
+ /**
4237
+ * 拷贝向量
4238
+ * @param v - 复制对象
4239
+ * @returns 拷贝结果
4240
+ */ _proto.copyFrom = function copyFrom(v) {
4241
+ this.x = v.x;
4242
+ this.y = v.y;
4243
+ this.z = v.z;
4244
+ this.w = v.w;
4245
+ return this;
4246
+ };
4247
+ /**
4248
+ * 克隆向量
4249
+ * @returns 克隆结果
4250
+ */ _proto.clone = function clone() {
4251
+ return new Vector4(this.x, this.y, this.z, this.w);
4252
+ };
4253
+ /**
4254
+ * 根据下标设置向量分量
4255
+ * @param index - 下标值
4256
+ * @param value - 分量值
4257
+ * @returns 向量
4258
+ */ _proto.setElement = function setElement(index, value) {
4259
+ switch(index){
4260
+ case 0:
4261
+ this.x = value;
4262
+ break;
4263
+ case 1:
4264
+ this.y = value;
4265
+ break;
4266
+ case 2:
4267
+ this.z = value;
4268
+ break;
4269
+ case 3:
4270
+ this.w = value;
4271
+ break;
4272
+ default:
4273
+ console.error("index is out of range: " + index);
4274
+ }
4275
+ return this;
4276
+ };
4277
+ /**
4278
+ * 根据下标获取向量分量
4279
+ * @param index - 下标
4280
+ * @returns 分量值
4281
+ */ _proto.getElement = function getElement(index) {
4282
+ switch(index){
4283
+ case 0:
4284
+ return this.x;
4285
+ case 1:
4286
+ return this.y;
4287
+ case 2:
4288
+ return this.z;
4289
+ case 3:
4290
+ return this.w;
4291
+ default:
4292
+ console.error("index is out of range: " + index);
4293
+ }
4294
+ return 0;
4295
+ };
4296
+ /**
4297
+ * 向量相加
4298
+ * @param right - 相加对象,向量 | 数字
4299
+ * @returns 相加结果
4300
+ */ _proto.add = function add(right) {
4301
+ if (typeof right === "number") {
4302
+ this.x += right;
4303
+ this.y += right;
4304
+ this.z += right;
4305
+ this.w += right;
4306
+ } else if (_instanceof1(right, Array)) {
4307
+ this.x += right[0];
4308
+ this.y += right[1];
4309
+ this.z += right[2];
4310
+ this.w += right[3];
4311
+ } else {
4312
+ this.x += right.x;
4313
+ this.y += right.y;
4314
+ this.z += right.z;
4315
+ this.w += right.w;
4316
+ }
4317
+ return this;
4318
+ };
4319
+ /**
4320
+ * 向量相加
4321
+ * @param left - 向量
4322
+ * @param right - 向量
4323
+ * @returns 求和结果
4324
+ */ _proto.addVectors = function addVectors(left, right) {
4325
+ this.x = left.x + right.x;
4326
+ this.y = left.y + right.y;
4327
+ this.z = left.z + right.z;
4328
+ this.w = left.w + right.w;
4329
+ return this;
4330
+ };
4331
+ /**
4332
+ * 向量比例缩放后相加
4333
+ * @param right - 向量
4334
+ * @param s - 比例
4335
+ * @returns 求和结果
4336
+ */ _proto.addScaledVector = function addScaledVector(right, s) {
4337
+ this.x += right.x * s;
4338
+ this.y += right.y * s;
4339
+ this.z += right.z * s;
4340
+ this.w += right.w * s;
4341
+ return this;
4342
+ };
4343
+ /**
4344
+ * 向量相减
4345
+ * @param right - 相减对象,向量 | 数字
4346
+ * @returns 相减结果
4347
+ */ _proto.subtract = function subtract(right) {
4348
+ if (typeof right === "number") {
4349
+ this.x -= right;
4350
+ this.y -= right;
4351
+ this.z -= right;
4352
+ this.w -= right;
4353
+ } else if (_instanceof1(right, Array)) {
4354
+ this.x -= right[0];
4355
+ this.y -= right[1];
4356
+ this.z -= right[2];
4357
+ this.w -= right[3];
4358
+ } else {
4359
+ this.x -= right.x;
4360
+ this.y -= right.y;
4361
+ this.z -= right.z;
4362
+ this.w -= right.w;
4363
+ }
4364
+ return this;
4365
+ };
4366
+ /**
4367
+ * 向量相减
4368
+ * @param left - 向量
4369
+ * @param right - 向量
4370
+ * @returns 向量
4371
+ */ _proto.subtractVectors = function subtractVectors(left, right) {
4372
+ this.x = left.x - right.x;
4373
+ this.y = left.y - right.y;
4374
+ this.z = left.z - right.z;
4375
+ this.w = left.w - right.w;
4376
+ return this;
4377
+ };
4378
+ /**
4379
+ * 向量相乘
4380
+ * @param right - 相乘对象,对象 | 数字
4381
+ * @returns 向量
4382
+ */ _proto.multiply = function multiply(right) {
4383
+ if (typeof right === "number") {
4384
+ this.x *= right;
4385
+ this.y *= right;
4386
+ this.z *= right;
4387
+ this.w *= right;
4388
+ } else if (_instanceof1(right, Array)) {
4389
+ this.x *= right[0];
4390
+ this.y *= right[1];
4391
+ this.z *= right[2];
4392
+ this.w *= right[3];
4393
+ } else {
4394
+ this.x *= right.x;
4395
+ this.y *= right.y;
4396
+ this.z *= right.z;
4397
+ this.w *= right.w;
4398
+ }
4399
+ return this;
4400
+ };
4401
+ /**
4402
+ * 向量相乘
4403
+ * @param left - 向量
4404
+ * @param right - 向量
4405
+ * @returns 向量
4406
+ */ _proto.multiplyVectors = function multiplyVectors(left, right) {
4407
+ this.x = left.x * right.x;
4408
+ this.y = left.y * right.y;
4409
+ this.z = left.z * right.z;
4410
+ this.w = left.w * right.w;
4411
+ return this;
4412
+ };
4413
+ /**
4414
+ * 向量相除
4415
+ * @param right - 相除对象,对象 | 数字
4416
+ * @returns 向量
4417
+ */ _proto.divide = function divide(right) {
4418
+ if (typeof right === "number") {
4419
+ this.x /= right;
4420
+ this.y /= right;
4421
+ this.z /= right;
4422
+ this.w /= right;
4423
+ } else if (_instanceof1(right, Array)) {
4424
+ this.x /= right[0];
4425
+ this.y /= right[1];
4426
+ this.z /= right[2];
4427
+ this.w /= right[3];
4428
+ } else {
4429
+ this.x /= right.x;
4430
+ this.y /= right.y;
4431
+ this.z /= right.z;
4432
+ this.w /= right.w;
4433
+ }
4434
+ return this;
4435
+ };
4436
+ /**
4437
+ * 向量缩放
4438
+ * @param v - 数字
4439
+ * @returns 缩放结果
4440
+ */ _proto.scale = function scale(v) {
4441
+ this.x *= v;
4442
+ this.y *= v;
4443
+ this.z *= v;
4444
+ this.w *= v;
4445
+ return this;
4446
+ };
4447
+ /**
4448
+ * 分量求和
4449
+ * @returns 求和结果
4450
+ */ _proto.sum = function sum() {
4451
+ return this.x + this.y + this.z + this.w;
4452
+ };
4453
+ /**
4454
+ * 向量求最小值
4455
+ * @param v - 向量或数值
4456
+ * @returns 最小值
4457
+ */ _proto.min = function min(v) {
4458
+ if (typeof v === "number") {
4459
+ this.x = Math.min(this.x, v);
4460
+ this.y = Math.min(this.y, v);
4461
+ this.z = Math.min(this.z, v);
4462
+ this.w = Math.min(this.w, v);
4463
+ } else {
4464
+ this.x = Math.min(this.x, v.x);
4465
+ this.y = Math.min(this.y, v.y);
4466
+ this.z = Math.min(this.z, v.z);
4467
+ this.w = Math.min(this.w, v.w);
4468
+ }
4469
+ return this;
4470
+ };
4471
+ /**
4472
+ * 向量求最大值
4473
+ * @param v - 向量或数值
4474
+ * @returns 最大值
4475
+ */ _proto.max = function max(v) {
4476
+ if (typeof v === "number") {
4477
+ this.x = Math.max(this.x, v);
4478
+ this.y = Math.max(this.y, v);
4479
+ this.z = Math.max(this.z, v);
4480
+ this.w = Math.max(this.w, v);
4481
+ } else {
4482
+ this.x = Math.max(this.x, v.x);
4483
+ this.y = Math.max(this.y, v.y);
4484
+ this.z = Math.max(this.z, v.z);
4485
+ this.w = Math.max(this.w, v.w);
4486
+ }
4487
+ return this;
4488
+ };
4489
+ /**
4490
+ * 向量阈值约束
4491
+ * @param min - 最小值
4492
+ * @param max - 最大值
4493
+ * @returns 向量
4494
+ */ _proto.clamp = function clamp(min, max) {
4495
+ return this.max(min).min(max);
4496
+ };
4497
+ /**
4498
+ * 向量向下取整
4499
+ * @returns 取整结果
4500
+ */ _proto.floor = function floor() {
4501
+ this.x = Math.floor(this.x);
4502
+ this.y = Math.floor(this.y);
4503
+ this.z = Math.floor(this.z);
4504
+ this.w = Math.floor(this.w);
4505
+ return this;
4506
+ };
4507
+ /**
4508
+ * 向量向上取整
4509
+ * @returns 取整结果
4510
+ */ _proto.ceil = function ceil() {
4511
+ this.x = Math.ceil(this.x);
4512
+ this.y = Math.ceil(this.y);
4513
+ this.z = Math.ceil(this.z);
4514
+ this.w = Math.ceil(this.w);
4515
+ return this;
4516
+ };
4517
+ /**
4518
+ * 向量四舍五入
4519
+ * @returns 求值结果
4520
+ */ _proto.round = function round() {
4521
+ this.x = Math.round(this.x);
4522
+ this.y = Math.round(this.y);
4523
+ this.z = Math.round(this.z);
4524
+ this.w = Math.round(this.w);
4525
+ return this;
4526
+ };
4527
+ /**
4528
+ * 向量取绝对值
4529
+ * @returns 向量
4530
+ */ _proto.abs = function abs() {
4531
+ this.x = Math.abs(this.x);
4532
+ this.y = Math.abs(this.y);
4533
+ this.z = Math.abs(this.z);
4534
+ this.w = Math.abs(this.w);
4535
+ return this;
4536
+ };
4537
+ /**
4538
+ * 向量取反
4539
+ * @returns 取反结果
4540
+ */ _proto.negate = function negate() {
4541
+ this.x = -this.x;
4542
+ this.y = -this.y;
4543
+ this.z = -this.z;
4544
+ this.w = -this.w;
4545
+ return this;
4546
+ };
4547
+ /**
4548
+ * 向量长度平方
4549
+ * @returns 长度平方
4550
+ */ _proto.lengthSquared = function lengthSquared() {
4551
+ return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
4552
+ };
4553
+ /**
4554
+ * 向量长度
4555
+ * @returns 长度
4556
+ */ _proto.length = function length() {
4557
+ return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
4558
+ };
4559
+ /**
4560
+ * 向量归一化
4561
+ * @returns 归一化结果
4562
+ */ _proto.normalize = function normalize() {
4563
+ return this.divide(this.length() || 1);
4564
+ };
4565
+ /**
4566
+ * 设置向量长度
4567
+ * @param length - 长度
4568
+ * @returns 向量
4569
+ */ _proto.setLength = function setLength(length) {
4570
+ return this.normalize().multiply(length);
4571
+ };
4572
+ /**
4573
+ * 向量求线性插值
4574
+ * @param v - 向量
4575
+ * @param alpha - 插值比例
4576
+ * @returns 插值结果
4577
+ */ _proto.lerp = function lerp(v, alpha) {
4578
+ this.x += (v.x - this.x) * alpha;
4579
+ this.y += (v.y - this.y) * alpha;
4580
+ this.z += (v.z - this.z) * alpha;
4581
+ this.w += (v.w - this.w) * alpha;
4582
+ return this;
4583
+ };
4584
+ /**
4585
+ * 两向量求线性插值
4586
+ * @param v1 - 第一个向量
4587
+ * @param v2 - 第二个向量
4588
+ * @param alpha - 插值比例
4589
+ * @returns 插值结果
4590
+ */ _proto.lerpVectors = function lerpVectors(v1, v2, alpha) {
4591
+ this.x = v1.x + (v2.x - v1.x) * alpha;
4592
+ this.y = v1.y + (v2.y - v1.y) * alpha;
4593
+ this.z = v1.z + (v2.z - v1.z) * alpha;
4594
+ this.w = v1.w + (v2.w - v1.w) * alpha;
4595
+ return this;
4596
+ };
4597
+ /**
4598
+ * 向量求点积
4599
+ * @param v - 向量
4600
+ * @returns 点积结果
4601
+ */ _proto.dot = function dot(v) {
4602
+ return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
4603
+ };
4604
+ /**
4605
+ * 向量判等
4606
+ * @param v - 向量
4607
+ * @returns 判等结果
4608
+ */ _proto.equals = function equals(v) {
4609
+ return v.x === this.x && v.y === this.y && v.z === this.z && v.w === this.w;
4610
+ };
4611
+ /**
4612
+ * 是否零向量
4613
+ * @returns 是否零向量
4614
+ */ _proto.isZero = function isZero() {
4615
+ var eps = NumberEpsilon;
4616
+ var _this = this, x = _this.x, y = _this.y, z = _this.z, w = _this.w;
4617
+ return Math.abs(x) <= eps && Math.abs(y) <= eps && Math.abs(z) <= eps && Math.abs(w) <= eps;
4618
+ };
4619
+ /**
4620
+ * 向量转数组
4621
+ * @returns 数组
4622
+ */ _proto.toArray = function toArray() {
4623
+ return [
4624
+ this.x,
4625
+ this.y,
4626
+ this.z,
4627
+ this.w
4628
+ ];
4629
+ };
4630
+ _proto.toVector3 = function toVector3() {
4631
+ return new Vector3(this.x, this.y, this.z);
4632
+ };
4633
+ _proto.fill = function fill(array, offset) {
4634
+ if (offset === void 0) offset = 0;
4635
+ array[offset] = this.x;
4636
+ array[offset + 1] = this.y;
4637
+ array[offset + 2] = this.z;
4638
+ array[offset + 3] = this.w;
4639
+ };
4640
+ /**
4641
+ * 生成随机向量
4642
+ * @returns 向量
4643
+ */ _proto.random = function random() {
4644
+ this.x = Math.random();
4645
+ this.y = Math.random();
4646
+ this.z = Math.random();
4647
+ this.w = Math.random();
4648
+ return this;
4649
+ };
4650
+ /**
4651
+ * 变换矩阵作用于向量
4652
+ * @param m - 变换矩阵
4653
+ * @param [out] - 输出结果,如果没有设置就直接覆盖当前值
4654
+ * @returns 向量
4655
+ */ _proto.applyMatrix = function applyMatrix(m, out) {
4656
+ return m.transformVector4(this, out);
4657
+ };
4658
+ /**
4659
+ * 通过标量数值创建向量
4660
+ * @param num - 数值
4661
+ * @returns 向量
4662
+ */ Vector4.fromNumber = function fromNumber(num) {
4663
+ return new Vector4().setFromNumber(num);
4664
+ };
4665
+ /**
4666
+ * 通过数组创建向量
4667
+ * @param array - 数组
4668
+ * @param [offset=0] - 起始偏移值
4669
+ * @returns 向量
4670
+ */ Vector4.fromArray = function fromArray(array, offset) {
4671
+ if (offset === void 0) offset = 0;
4672
+ return new Vector4().setFromArray(array, offset);
4673
+ };
4674
+ return Vector4;
4675
+ }();
4676
+ /**
4677
+ * 四维向量的常量
4678
+ */ Vector4.ONE = new Vector4(1.0, 1.0, 1.0, 1.0);
4679
+ Vector4.ZERO = new Vector4(0.0, 0.0, 0.0, 0.0);
4680
+
4681
+ var Color = /*#__PURE__*/ function() {
4682
+ function Color(r, g, b, a) {
4683
+ if (r === void 0) r = 0;
4684
+ if (g === void 0) g = 0;
4685
+ if (b === void 0) b = 0;
4686
+ if (a === void 0) a = 0;
4687
+ this.r = r;
4688
+ this.g = g;
4689
+ this.b = b;
4690
+ this.a = a;
4691
+ }
4692
+ var _proto = Color.prototype;
4693
+ /**
4694
+ * 设置颜色
4695
+ * @param r - r 分量
4696
+ * @param g - g 分量
4697
+ * @param b - b 分量
4698
+ * @param a - a 分量
4699
+ * @returns
4700
+ */ _proto.set = function set(r, g, b, a) {
4701
+ this.r = r;
4702
+ this.g = g;
4703
+ this.b = b;
4704
+ this.a = a;
4705
+ return this;
4706
+ };
4707
+ /**
4708
+ * 设置零颜色
4709
+ * @returns
4710
+ */ _proto.setZero = function setZero() {
4711
+ this.r = 0;
4712
+ this.g = 0;
4713
+ this.b = 0;
4714
+ this.a = 0;
4715
+ return this;
4716
+ };
4717
+ /**
4718
+ * 通过标量数值设置颜色
4719
+ * @param num - 数值
4720
+ * @returns
4721
+ */ _proto.setFromNumber = function setFromNumber(num) {
4722
+ this.r = num;
4723
+ this.g = num;
4724
+ this.b = num;
4725
+ this.a = num;
4726
+ return this;
4727
+ };
4728
+ /**
4729
+ * 通过Vector4创建颜色
4730
+ * @param v - Vector4
4731
+ * @returns
4732
+ */ _proto.setFromVector4 = function setFromVector4(v) {
4733
+ this.r = v.x;
4734
+ this.g = v.y;
4735
+ this.b = v.z;
4736
+ this.a = v.w;
4737
+ return this;
4738
+ };
4739
+ /**
4740
+ * 通过数组创建颜色
4741
+ * @param array - 数组
4742
+ * @param [offset=0] - 起始偏移值
4743
+ * @returns
4744
+ */ _proto.setFromArray = function setFromArray(array, offset) {
4745
+ if (offset === void 0) offset = 0;
4746
+ var _array_offset;
4747
+ this.r = (_array_offset = array[offset]) != null ? _array_offset : 0;
4748
+ var _array_;
4749
+ this.g = (_array_ = array[offset + 1]) != null ? _array_ : 0;
4750
+ var _array_1;
4751
+ this.b = (_array_1 = array[offset + 2]) != null ? _array_1 : 0;
4752
+ var _array_2;
4753
+ this.a = (_array_2 = array[offset + 3]) != null ? _array_2 : 0;
4754
+ return this;
4755
+ };
4756
+ _proto.setFromHSV = function setFromHSV(hue, saturation, value, alpha) {
4757
+ if (alpha === void 0) alpha = 1;
4758
+ var chroma = value * saturation;
4759
+ var h = hue / 60;
4760
+ var x = chroma * (1 - Math.abs(h % 2 - 1));
4761
+ var r = 0;
4762
+ var g = 0;
4763
+ var b = 0;
4764
+ if (h >= 0 && h <= 1) {
4765
+ r = chroma;
4766
+ g = x;
4767
+ } else if (h >= 1 && h <= 2) {
4768
+ r = x;
4769
+ g = chroma;
4770
+ } else if (h >= 2 && h <= 3) {
4771
+ g = chroma;
4772
+ b = x;
4773
+ } else if (h >= 3 && h <= 4) {
4774
+ g = x;
4775
+ b = chroma;
4776
+ } else if (h >= 4 && h <= 5) {
4777
+ r = x;
4778
+ b = chroma;
4779
+ } else if (h >= 5 && h <= 6) {
4780
+ r = chroma;
4781
+ b = x;
4782
+ }
4783
+ var m = value - chroma;
4784
+ return this.set(r + m, g + m, b + m, alpha);
4785
+ };
4786
+ _proto.setFromHexString = function setFromHexString(hex) {
4787
+ if (hex.substring(0, 1) !== "#" || hex.length !== 9 && hex.length !== 7) {
4788
+ return this;
4789
+ }
4790
+ var r = parseInt(hex.substring(1, 3), 16) / 255.0;
4791
+ var g = parseInt(hex.substring(3, 5), 16) / 255.0;
4792
+ var b = parseInt(hex.substring(5, 7), 16) / 255.0;
4793
+ var a = hex.length === 9 ? parseInt(hex.substring(7, 9), 16) / 255.0 : 1.0;
4794
+ return this.set(r, g, b, a);
4795
+ };
4796
+ /**
4797
+ * 拷贝颜色
4798
+ * @param v - 复制对象
4799
+ * @returns 拷贝结果
4800
+ */ _proto.copyFrom = function copyFrom(v) {
4801
+ this.r = v.r;
4802
+ this.g = v.g;
4803
+ this.b = v.b;
4804
+ this.a = v.a;
4805
+ return this;
4806
+ };
4807
+ /**
4808
+ * 克隆颜色
4809
+ * @returns 克隆结果
4810
+ */ _proto.clone = function clone() {
4811
+ return new Color(this.r, this.g, this.b, this.a);
4812
+ };
4813
+ /**
4814
+ * 根据下标设置颜色分量
4815
+ * @param index - 下标值
4816
+ * @param value - 分量值
4817
+ * @returns
4818
+ */ _proto.setElement = function setElement(index, value) {
4819
+ switch(index){
4820
+ case 0:
4821
+ this.r = value;
4822
+ break;
4823
+ case 1:
4824
+ this.g = value;
4825
+ break;
4826
+ case 2:
4827
+ this.b = value;
4828
+ break;
4829
+ case 3:
4830
+ this.a = value;
4831
+ break;
4832
+ default:
4833
+ console.error("index is out of range: " + index);
4834
+ }
4835
+ return this;
4836
+ };
4837
+ /**
4838
+ * 根据下标获取颜色分量
4839
+ * @param index - 下标
4840
+ * @returns 分量值
4841
+ */ _proto.getElement = function getElement(index) {
4842
+ switch(index){
4843
+ case 0:
4844
+ return this.r;
4845
+ case 1:
4846
+ return this.g;
4847
+ case 2:
4848
+ return this.b;
4849
+ case 3:
4850
+ return this.a;
4851
+ default:
4852
+ console.error("index is out of range: " + index);
4853
+ }
4854
+ return 0;
4855
+ };
4856
+ /**
4857
+ * 颜色相加
4858
+ * @param right - 相加对象,颜色 | 数字
4859
+ * @returns 相加结果
4860
+ */ _proto.add = function add(right) {
4861
+ if (typeof right === "number") {
4862
+ this.r += right;
4863
+ this.g += right;
4864
+ this.b += right;
4865
+ this.a += right;
4866
+ } else if (_instanceof1(right, Array)) {
4867
+ this.r += right[0];
4868
+ this.g += right[1];
4869
+ this.b += right[2];
4870
+ this.a += right[3];
4871
+ } else {
4872
+ this.r += right.r;
4873
+ this.g += right.g;
4874
+ this.b += right.b;
4875
+ this.a += right.a;
4876
+ }
4877
+ return this;
4878
+ };
4879
+ /**
4880
+ * 颜色相减
4881
+ * @param right - 相减对象,颜色 | 数字
4882
+ * @returns 相减结果
4883
+ */ _proto.subtract = function subtract(right) {
4884
+ if (typeof right === "number") {
4885
+ this.r -= right;
4886
+ this.g -= right;
4887
+ this.b -= right;
4888
+ this.a -= right;
4889
+ } else if (_instanceof1(right, Array)) {
4890
+ this.r -= right[0];
4891
+ this.g -= right[1];
4892
+ this.b -= right[2];
4893
+ this.a -= right[3];
4894
+ } else {
4895
+ this.r -= right.r;
4896
+ this.g -= right.g;
4897
+ this.b -= right.b;
4898
+ this.a -= right.a;
4899
+ }
4900
+ return this;
4901
+ };
4902
+ /**
4903
+ * 颜色相乘
4904
+ * @param right - 相乘对象,对象 | 数字
4905
+ * @returns 颜色
4906
+ */ _proto.multiply = function multiply(right) {
4907
+ if (typeof right === "number") {
4908
+ this.r *= right;
4909
+ this.g *= right;
4910
+ this.b *= right;
4911
+ this.a *= right;
4912
+ } else if (_instanceof1(right, Array)) {
4913
+ this.r *= right[0];
4914
+ this.g *= right[1];
4915
+ this.b *= right[2];
4916
+ this.a *= right[3];
4917
+ } else {
4918
+ this.r *= right.r;
4919
+ this.g *= right.g;
4920
+ this.b *= right.b;
4921
+ this.a *= right.a;
4922
+ }
4923
+ return this;
4924
+ };
4925
+ /**
4926
+ * 颜色相除
4927
+ * @param right - 相除对象,对象 | 数字
4928
+ * @returns 颜色
4929
+ */ _proto.divide = function divide(right) {
4930
+ if (typeof right === "number") {
4931
+ this.r /= right;
4932
+ this.g /= right;
4933
+ this.b /= right;
4934
+ this.a /= right;
4935
+ } else if (_instanceof1(right, Array)) {
4936
+ this.r /= right[0];
4937
+ this.g /= right[1];
4938
+ this.b /= right[2];
4939
+ this.a /= right[3];
4940
+ } else {
4941
+ this.r /= right.r;
4942
+ this.g /= right.g;
4943
+ this.b /= right.b;
4944
+ this.a /= right.a;
4945
+ }
4946
+ return this;
4947
+ };
4948
+ /**
4949
+ * 颜色缩放
4950
+ * @param v - 数字
4951
+ * @returns 缩放结果
4952
+ */ _proto.scale = function scale(v) {
4953
+ this.r *= v;
4954
+ this.g *= v;
4955
+ this.b *= v;
4956
+ this.a *= v;
4957
+ return this;
4958
+ };
4959
+ /**
4960
+ * 颜色求最小值
4961
+ * @param v - 颜色或数值
4962
+ * @returns 最小值
4963
+ */ _proto.min = function min(v) {
4964
+ if (typeof v === "number") {
4965
+ this.r = Math.min(this.r, v);
4966
+ this.g = Math.min(this.g, v);
4967
+ this.b = Math.min(this.b, v);
4968
+ this.a = Math.min(this.a, v);
4969
+ } else {
4970
+ this.r = Math.min(this.r, v.r);
4971
+ this.g = Math.min(this.g, v.g);
4972
+ this.b = Math.min(this.b, v.b);
4973
+ this.a = Math.min(this.a, v.a);
4974
+ }
4975
+ return this;
4976
+ };
4977
+ /**
4978
+ * 颜色求最大值
4979
+ * @param v - 颜色或数值
4980
+ * @returns 最大值
4981
+ */ _proto.max = function max(v) {
4982
+ if (typeof v === "number") {
4983
+ this.r = Math.max(this.r, v);
4984
+ this.g = Math.max(this.g, v);
4985
+ this.b = Math.max(this.b, v);
4986
+ this.a = Math.max(this.a, v);
4987
+ } else {
4988
+ this.r = Math.max(this.r, v.r);
4989
+ this.g = Math.max(this.g, v.g);
4990
+ this.b = Math.max(this.b, v.b);
4991
+ this.a = Math.max(this.a, v.a);
4992
+ }
4993
+ return this;
4994
+ };
4995
+ /**
4996
+ * 颜色阈值约束
4997
+ * @param min - 最小值
4998
+ * @param max - 最大值
4999
+ * @returns 颜色
5000
+ */ _proto.clamp = function clamp(min, max) {
5001
+ return this.max(min).min(max);
5002
+ };
5003
+ /**
5004
+ * 颜色求线性插值
5005
+ * @param v - 颜色
5006
+ * @param alpha - 插值比例
5007
+ * @returns 插值结果
5008
+ */ _proto.lerp = function lerp(v, alpha) {
5009
+ this.r += (v.r - this.r) * alpha;
5010
+ this.g += (v.g - this.g) * alpha;
5011
+ this.b += (v.b - this.b) * alpha;
5012
+ this.a += (v.a - this.a) * alpha;
5013
+ return this;
5014
+ };
5015
+ /**
5016
+ * 计算颜色亮度值
5017
+ * @returns 亮度值
5018
+ */ _proto.luminance = function luminance() {
5019
+ return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
5020
+ };
5021
+ /**
5022
+ * 颜色判等
5023
+ * @param v - 颜色
5024
+ * @returns 判等结果
5025
+ */ _proto.equals = function equals(v) {
5026
+ return v.r === this.r && v.g === this.g && v.b === this.b && v.a === this.a;
5027
+ };
5028
+ _proto.toLinear = function toLinear() {
5029
+ this.r = Color.gammaToLinear(this.r);
5030
+ this.g = Color.gammaToLinear(this.g);
5031
+ this.b = Color.gammaToLinear(this.b);
5032
+ return this;
5033
+ };
5034
+ _proto.toGamma = function toGamma() {
5035
+ this.r = Color.linearToGamma(this.r);
5036
+ this.g = Color.linearToGamma(this.g);
5037
+ this.b = Color.linearToGamma(this.b);
5038
+ return this;
5039
+ };
5040
+ /**
5041
+ * 颜色转数组
5042
+ * @returns 数组
5043
+ */ _proto.toArray = function toArray() {
5044
+ return [
5045
+ this.r,
5046
+ this.g,
5047
+ this.b,
5048
+ this.a
5049
+ ];
5050
+ };
5051
+ _proto.toVector4 = function toVector4() {
5052
+ return new Vector4(this.r, this.g, this.b, this.a);
5053
+ };
5054
+ /**
5055
+ * RGB 颜色空间转 HSV
5056
+ * @param result HSV 值
5057
+ */ _proto.toHSV = function toHSV() {
5058
+ var _this = this, r = _this.r, g = _this.g, b = _this.b, a = _this.a;
5059
+ var max = Math.max(r, g, b);
5060
+ var min = Math.min(r, g, b);
5061
+ var v = max;
5062
+ var dm = max - min;
5063
+ var h = 0;
5064
+ var s = 0;
5065
+ if (max !== 0) {
5066
+ s = dm / max;
5067
+ }
5068
+ if (max != min) {
5069
+ if (max == r) {
5070
+ h = (g - b) / dm;
5071
+ if (g < b) {
5072
+ h += 6;
5073
+ }
5074
+ } else if (max == g) {
5075
+ h = (b - r) / dm + 2;
5076
+ } else if (max == b) {
5077
+ h = (r - g) / dm + 4;
5078
+ }
5079
+ h *= 60;
5080
+ }
5081
+ return new Color(h, s, v, a);
5082
+ };
5083
+ _proto.toHexString = function toHexString(includeAlpha) {
5084
+ if (includeAlpha === void 0) includeAlpha = true;
5085
+ var R = Color.ToHex(Math.round(this.r * 255));
5086
+ var G = Color.ToHex(Math.round(this.g * 255));
5087
+ var B = Color.ToHex(Math.round(this.b * 255));
5088
+ var A = Color.ToHex(Math.round(this.a * 255));
5089
+ if (includeAlpha) {
5090
+ return "#" + R + G + B + A;
5091
+ } else {
5092
+ return "#" + R + G + B;
5093
+ }
5094
+ };
5095
+ _proto.fill = function fill(array, offset) {
5096
+ if (offset === void 0) offset = 0;
5097
+ array[offset] = this.r;
5098
+ array[offset + 1] = this.g;
5099
+ array[offset + 2] = this.b;
5100
+ array[offset + 3] = this.a;
5101
+ };
5102
+ /**
5103
+ * 通过标量数值创建颜色
5104
+ * @param num - 数值
5105
+ * @returns
5106
+ */ Color.fromNumber = function fromNumber(num) {
5107
+ return new Color().setFromNumber(num);
5108
+ };
5109
+ /**
5110
+ * 通过数组创建颜色
5111
+ * @param array - 数组
5112
+ * @param [offset=0] - 起始偏移值
5113
+ * @returns
5114
+ */ Color.fromArray = function fromArray(array, offset) {
5115
+ if (offset === void 0) offset = 0;
5116
+ return new Color().setFromArray(array, offset);
5117
+ };
5118
+ /**
5119
+ * 通过 hex 字符串创建颜色
5120
+ * @param hex - hex 字符串
5121
+ * @returns
5122
+ */ Color.fromHexString = function fromHexString(hex) {
5123
+ return new Color().setFromHexString(hex);
5124
+ };
5125
+ Color.fromHSV = function fromHSV(hue, saturation, value, alpha) {
5126
+ if (alpha === void 0) alpha = 1;
5127
+ return new Color().setFromHSV(hue, saturation, value, alpha);
5128
+ };
5129
+ /**
5130
+ * 颜色值从 Gamma 空间转到线性空间
5131
+ * @param v - Gamma 空间颜色值
5132
+ * @returns 线性空间颜色值
5133
+ */ Color.gammaToLinear = function gammaToLinear(v) {
5134
+ if (v <= 0.0) {
5135
+ return 0.0;
5136
+ } else if (v <= 0.04045) {
5137
+ return v / 12.92;
5138
+ } else if (v < 1.0) {
5139
+ return Math.pow((v + 0.055) / 1.055, 2.4);
5140
+ } else {
5141
+ return Math.pow(v, 2.4);
5142
+ }
5143
+ };
5144
+ /**
5145
+ * 颜色值从线性空间转到 Gamma 空间
5146
+ * @param value - 线性空间颜色值
5147
+ * @returns Gamma 空间颜色值
5148
+ */ Color.linearToGamma = function linearToGamma(value) {
5149
+ if (value <= 0.0) {
5150
+ return 0.0;
5151
+ } else if (value < 0.0031308) {
5152
+ return 12.92 * value;
5153
+ } else if (value < 1.0) {
5154
+ return 1.055 * Math.pow(value, 0.41666) - 0.055;
5155
+ } else {
5156
+ return Math.pow(value, 0.41666);
5157
+ }
5158
+ };
5159
+ Color.ToHex = function ToHex(i) {
5160
+ var str = i.toString(16);
5161
+ if (i <= 15) {
5162
+ return ("0" + str).toUpperCase();
5163
+ }
5164
+ return str.toUpperCase();
5165
+ };
5166
+ return Color;
5167
+ }();
5168
+ /**
5169
+ * 颜色的常量
5170
+ */ Color.BLACK = new Color(0, 0, 0, 1) // 纯黑色
5171
+ ;
5172
+ Color.BLUE = new Color(0, 0, 1, 1) // 纯蓝色
5173
+ ;
5174
+ Color.CLEAR = new Color(0, 0, 0, 0) // 完全透明
5175
+ ;
5176
+ Color.CYAN = new Color(0, 1, 1, 1) // 青色
5177
+ ;
5178
+ Color.GRAY = new Color(0.5, 0.5, 0.5, 1) // 灰色
5179
+ ;
5180
+ Color.GREEN = new Color(0, 1, 0, 1) // 纯绿色
5181
+ ;
5182
+ Color.MAGENTA = new Color(1, 0, 1, 1) // 洋红色
5183
+ ;
5184
+ Color.RED = new Color(1, 0, 0, 1) // 纯红色
5185
+ ;
5186
+ Color.WHITE = new Color(1, 1, 1, 1) // 纯白色
5187
+ ;
5188
+ Color.YELLOW = new Color(1, 0.92, 0.016, 1) // 黄色
5189
+ ;
5190
+
4170
5191
  var NodeTransform = /*#__PURE__*/ function() {
4171
5192
  function NodeTransform(transform) {
4172
5193
  this.position = new Vector3();
@@ -4206,7 +5227,7 @@ var Pose = /*#__PURE__*/ function() {
4206
5227
  }
4207
5228
  for(var _iterator2 = _create_for_of_iterator_helper_loose(skeleton.defaultColorPropertyValues), _step2; !(_step2 = _iterator2()).done;){
4208
5229
  var defaultColor = _step2.value;
4209
- this.colorPropertyValues.push(defaultColor);
5230
+ this.colorPropertyValues.push(new Color().copyFrom(defaultColor));
4210
5231
  }
4211
5232
  }
4212
5233
  var _proto = Pose.prototype;
@@ -5622,1059 +6643,548 @@ var Skeleton = /*#__PURE__*/ function() {
5622
6643
  }
5623
6644
  var targetBone = this.findTarget(path);
5624
6645
  if (!targetBone) {
5625
- return;
5626
- }
5627
- this.parentSpaceTransforms.push(new NodeTransform(targetBone.transform));
5628
- this.animatedTransforms.push(targetBone.transform);
5629
- this.pathToBoneIndex.set(path, this.parentSpaceTransforms.length - 1);
5630
- };
5631
- _proto.addRecordedProperty = function addRecordedProperty(path, className, property, type) {
5632
- var totalPath = path + className + property;
5633
- if (this.pathToObjectIndex.get(totalPath) !== undefined) {
5634
- return;
5635
- }
5636
- var targetBone = this.findTarget(path);
5637
- if (!targetBone) {
5638
- return;
5639
- }
5640
- var animatedComponentOrItem;
5641
- // Find target component or VFXItem
5642
- if (className === VFXItemType) {
5643
- animatedComponentOrItem = targetBone;
5644
- } else {
5645
- animatedComponentOrItem = targetBone.getComponent(getClass(className));
5646
- }
5647
- if (!animatedComponentOrItem) {
5648
- console.error("The " + className + " Component was not found.");
5649
- }
5650
- // Find last animated object by path
5651
- var propertyNames = property.split(".");
5652
- var lastPropertyName = propertyNames[propertyNames.length - 1];
5653
- var target = animatedComponentOrItem;
5654
- for(var i = 0; i < propertyNames.length - 1; i++){
5655
- var _$property = target[propertyNames[i]];
5656
- if (_$property === undefined) {
5657
- console.error("The " + propertyNames[i] + " property of " + target + " was not found.");
5658
- }
5659
- target = _$property;
5660
- }
5661
- var animatedObject = {
5662
- target: target,
5663
- property: lastPropertyName
5664
- };
5665
- switch(type){
5666
- case 0:
5667
- this.floatAnimatedObjects.push(animatedObject);
5668
- this.defaultFloatPropertyValues.push(target[lastPropertyName]);
5669
- this.pathToObjectIndex.set(totalPath, this.floatAnimatedObjects.length - 1);
5670
- break;
5671
- case 1:
5672
- this.colorAnimatedObjects.push(animatedObject);
5673
- this.defaultColorPropertyValues.push(target[lastPropertyName]);
5674
- this.pathToObjectIndex.set(totalPath, this.colorAnimatedObjects.length - 1);
5675
- }
5676
- };
5677
- _proto.findTarget = function findTarget(boneName) {
5678
- if (boneName === "") {
5679
- return this.rootBone;
5680
- }
5681
- var itemNames = boneName.split("/");
5682
- var currentItem = this.rootBone;
5683
- for(var _iterator = _create_for_of_iterator_helper_loose(itemNames), _step; !(_step = _iterator()).done;){
5684
- var itemName = _step.value;
5685
- var target = currentItem.find(itemName);
5686
- if (!target) {
5687
- return null;
5688
- }
5689
- currentItem = target;
5690
- }
5691
- return currentItem;
5692
- };
5693
- return Skeleton;
5694
- }();
5695
-
5696
- var GraphInstance = /*#__PURE__*/ function() {
5697
- function GraphInstance(graphAsset, rootBone) {
5698
- this.graphAsset = graphAsset;
5699
- this.nodes = [];
5700
- this.context = new GraphContext();
5701
- // Initialize skeleton
5702
- var recordProperties = {
5703
- position: [],
5704
- scale: [],
5705
- rotation: [],
5706
- euler: [],
5707
- floats: [],
5708
- colors: []
5709
- };
5710
- for(var _iterator = _create_for_of_iterator_helper_loose(graphAsset.graphDataSet.resources), _step; !(_step = _iterator()).done;){
5711
- var animationClip = _step.value;
5712
- if (!animationClip) {
5713
- continue;
5714
- }
5715
- for(var _iterator1 = _create_for_of_iterator_helper_loose(animationClip.positionCurves), _step1; !(_step1 = _iterator1()).done;){
5716
- var positionCurve = _step1.value;
5717
- recordProperties.position.push(positionCurve.path);
5718
- }
5719
- for(var _iterator2 = _create_for_of_iterator_helper_loose(animationClip.rotationCurves), _step2; !(_step2 = _iterator2()).done;){
5720
- var rotationCurve = _step2.value;
5721
- recordProperties.rotation.push(rotationCurve.path);
5722
- }
5723
- for(var _iterator3 = _create_for_of_iterator_helper_loose(animationClip.scaleCurves), _step3; !(_step3 = _iterator3()).done;){
5724
- var scaleCurve = _step3.value;
5725
- recordProperties.scale.push(scaleCurve.path);
5726
- }
5727
- for(var _iterator4 = _create_for_of_iterator_helper_loose(animationClip.eulerCurves), _step4; !(_step4 = _iterator4()).done;){
5728
- var eulerCurve = _step4.value;
5729
- recordProperties.euler.push(eulerCurve.path);
5730
- }
5731
- for(var _iterator5 = _create_for_of_iterator_helper_loose(animationClip.floatCurves), _step5; !(_step5 = _iterator5()).done;){
5732
- var floatCurve = _step5.value;
5733
- recordProperties.floats.push(floatCurve);
5734
- }
5735
- for(var _iterator6 = _create_for_of_iterator_helper_loose(animationClip.colorCurves), _step6; !(_step6 = _iterator6()).done;){
5736
- var colorCurve = _step6.value;
5737
- recordProperties.colors.push(colorCurve);
5738
- }
5739
- }
5740
- this.skeleton = new Skeleton(rootBone, recordProperties);
5741
- // create PoseResult
5742
- this.result = new PoseResult(this.skeleton);
5743
- this.context.skeleton = this.skeleton;
5744
- // instantiate graph nodes
5745
- var instantiationContext = new InstantiationContext();
5746
- instantiationContext.nodes = this.nodes;
5747
- instantiationContext.nodeDatas = graphAsset.nodeDatas;
5748
- instantiationContext.dataSet = graphAsset.graphDataSet;
5749
- for(var i = 0; i < graphAsset.nodeDatas.length; i++){
5750
- if (!instantiationContext.nodes[i]) {
5751
- graphAsset.nodeDatas[i].instantiate(instantiationContext);
5752
- }
5753
- }
5754
- this.rootNode = this.nodes[graphAsset.rootNodeIndex];
5755
- }
5756
- var _proto = GraphInstance.prototype;
5757
- _proto.evaluateGraph = function evaluateGraph(deltaTime) {
5758
- this.context.update(deltaTime);
5759
- if (!this.rootNode.isInitialized()) {
5760
- this.resetGraphState();
5761
- }
5762
- // Evaluate the entire animation graph starting from the rootNode
5763
- if (this.rootNode) {
5764
- this.result = this.rootNode.evaluate(this.context, this.result);
5765
- }
5766
- // Reset trigger nodes
5767
- for(var i = 0; i < this.getNumControlParameters(); i++){
5768
- var controlParameterNode = this.nodes[i];
5769
- if (_instanceof1(controlParameterNode, ControlParameterTriggerNode)) {
5770
- controlParameterNode.setValue(false);
5771
- }
5772
- }
5773
- return this.result;
5774
- };
5775
- _proto.isInitialized = function isInitialized() {
5776
- return this.rootNode && this.rootNode.isInitialized();
5777
- };
5778
- // General Node Info
5779
- //-------------------------------------------------------------------------
5780
- _proto.isNodeActive = function isNodeActive(nodeIdx) {
5781
- return this.isControlParameter(nodeIdx) || this.nodes[nodeIdx].isNodeActive(this.context.updateID);
5782
- };
5783
- // Graph State
5784
- //-------------------------------------------------------------------------
5785
- _proto.resetGraphState = function resetGraphState() {
5786
- if (this.rootNode.isInitialized()) {
5787
- this.rootNode.shutdown(this.context);
5788
- }
5789
- this.context.updateID++; // Bump the update ID to ensure that any initialization code that relies on it is dirtied.
5790
- this.rootNode.initialize(this.context);
5791
- };
5792
- // Control Parameters
5793
- //-------------------------------------------------------------------------
5794
- _proto.getNumControlParameters = function getNumControlParameters() {
5795
- return this.graphAsset.controlParameterIDs.length;
5796
- };
5797
- _proto.getControlParameterIndex = function getControlParameterIndex(parameterID) {
5798
- var parameterLookupMap = this.graphAsset.parameterLookupMap;
5799
- var res = parameterLookupMap.get(parameterID);
5800
- if (res !== undefined) {
5801
- return res;
5802
- }
5803
- console.warn("Parameter '" + parameterID + "' does not exist.");
5804
- return InvalidIndex;
5805
- };
5806
- _proto.getControlParameterID = function getControlParameterID(parameterNodeIndex) {
5807
- return this.graphAsset.controlParameterIDs[parameterNodeIndex];
5808
- };
5809
- _proto.setBool = function setBool(name, value) {
5810
- this.setControlParameterValue(name, value);
5811
- };
5812
- _proto.setFloat = function setFloat(name, value) {
5813
- this.setControlParameterValue(name, value);
5814
- };
5815
- _proto.setTrigger = function setTrigger(name) {
5816
- this.setControlParameterValue(name, true);
5817
- };
5818
- _proto.resetTrigger = function resetTrigger(name) {
5819
- this.setControlParameterValue(name, false);
5820
- };
5821
- // Debug Information
5822
- //-------------------------------------------------------------------------
5823
- _proto.getPoseNodeDebugInfo = function getPoseNodeDebugInfo(nodeIdx) {
5824
- var node = this.nodes[nodeIdx];
5825
- return node.getDebugInfo();
5826
- };
5827
- _proto.getRuntimeNodeDebugValue = function getRuntimeNodeDebugValue(nodeIdx) {
5828
- var valueNode = this.nodes[nodeIdx];
5829
- return valueNode.getValue(this.context);
5830
- };
5831
- _proto.getNodeDebugInstance = function getNodeDebugInstance(nodeIdx) {
5832
- return this.nodes[nodeIdx];
5833
- };
5834
- _proto.isControlParameter = function isControlParameter(nodeIdx) {
5835
- return nodeIdx < this.getNumControlParameters();
5836
- };
5837
- _proto.setControlParameterValue = function setControlParameterValue(name, value) {
5838
- var index = this.getControlParameterIndex(name);
5839
- if (index !== InvalidIndex) {
5840
- this.nodes[index].setValue(value);
5841
- }
5842
- };
5843
- return GraphInstance;
5844
- }();
5845
-
5846
- function _defineProperties(target, props) {
5847
- for(var i = 0; i < props.length; i++){
5848
- var descriptor = props[i];
5849
- descriptor.enumerable = descriptor.enumerable || false;
5850
- descriptor.configurable = true;
5851
- if ("value" in descriptor) descriptor.writable = true;
5852
- Object.defineProperty(target, descriptor.key, descriptor);
5853
- }
5854
- }
5855
- function _create_class(Constructor, protoProps, staticProps) {
5856
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
5857
- if (staticProps) _defineProperties(Constructor, staticProps);
5858
- return Constructor;
5859
- }
5860
-
5861
- /**
5862
- * @since 2.0.0
5863
- */ var Component = /*#__PURE__*/ function(EffectsObject) {
5864
- _inherits(Component, EffectsObject);
5865
- function Component() {
5866
- var _this;
5867
- _this = EffectsObject.apply(this, arguments) || this;
5868
- _this.isAwakeCalled = false;
5869
- _this.isStartCalled = false;
5870
- _this.isEnableCalled = false;
5871
- _this._enabled = true;
5872
- return _this;
5873
- }
5874
- var _proto = Component.prototype;
5875
- /**
5876
- * 生命周期函数,初始化后调用,生命周期内只调用一次
5877
- */ _proto.onAwake = function onAwake() {
5878
- // OVERRIDE
5879
- };
5880
- /**
5881
- * 在 enabled 变为 true 时触发
5882
- */ _proto.onEnable = function onEnable() {
5883
- // OVERRIDE
5884
- };
5885
- /**
5886
- * 在 enabled 变为 false 时触发
5887
- */ _proto.onDisable = function onDisable() {
5888
- // OVERRIDE
5889
- };
5890
- /**
5891
- * 生命周期函数,在第一次 update 前调用,生命周期内只调用一次
5892
- */ _proto.onStart = function onStart() {
5893
- // OVERRIDE
5894
- };
5895
- /**
5896
- * 生命周期函数,每帧调用一次
5897
- */ _proto.onUpdate = function onUpdate(dt) {
5898
- // OVERRIDE
5899
- };
5900
- /**
5901
- * 生命周期函数,每帧调用一次,在 update 之后调用
5902
- */ _proto.onLateUpdate = function onLateUpdate(dt) {
5903
- // OVERRIDE
5904
- };
5905
- /**
5906
- * 生命周期函数,在组件销毁时调用
5907
- */ _proto.onDestroy = function onDestroy() {
5908
- // OVERRIDE
5909
- };
5910
- /**
5911
- * @internal
5912
- */ _proto.enable = function enable() {
5913
- if (this.item.composition) {
5914
- this.item.composition.sceneTicking.addComponent(this);
5915
- this.isEnableCalled = true;
5916
- }
5917
- this.onEnable();
5918
- };
5919
- /**
5920
- * @internal
5921
- */ _proto.disable = function disable() {
5922
- this.onDisable();
5923
- if (this.item.composition) {
5924
- this.isEnableCalled = false;
5925
- this.item.composition.sceneTicking.removeComponent(this);
5926
- }
5927
- };
5928
- _proto.setVFXItem = function setVFXItem(item) {
5929
- this.item = item;
5930
- if (item.isDuringPlay) {
5931
- if (!this.isAwakeCalled) {
5932
- this.onAwake();
5933
- this.isAwakeCalled = true;
5934
- }
5935
- if (item.isActive && this.enabled) {
5936
- this.start();
5937
- this.enable();
5938
- }
5939
- }
5940
- };
5941
- _proto.fromData = function fromData(data) {
5942
- EffectsObject.prototype.fromData.call(this, data);
5943
- };
5944
- _proto.dispose = function dispose() {
5945
- if (this.isEnableCalled) {
5946
- this.disable();
5947
- }
5948
- if (this.isAwakeCalled) {
5949
- this.isAwakeCalled = false;
5950
- this.onDestroy();
5951
- }
5952
- if (this.item) {
5953
- removeItem(this.item.components, this);
5954
- }
5955
- };
5956
- _proto.start = function start() {
5957
- if (this.isStartCalled) {
5958
- return;
5959
- }
5960
- this.isStartCalled = true;
5961
- this.onStart();
5962
- };
5963
- _create_class(Component, [
5964
- {
5965
- key: "transform",
5966
- get: /**
5967
- * 附加到的 VFXItem 对象 Transform 组件
5968
- */ function get() {
5969
- return this.item.transform;
5970
- }
5971
- },
5972
- {
5973
- key: "isActiveAndEnabled",
5974
- get: /**
5975
- * 组件是否可以更新,true 更新,false 不更新
5976
- */ function get() {
5977
- return this.item.isActive && this.enabled;
5978
- }
5979
- },
5980
- {
5981
- key: "enabled",
5982
- get: function get() {
5983
- return this._enabled;
5984
- },
5985
- set: function set(value) {
5986
- if (this.enabled !== value) {
5987
- this._enabled = value;
5988
- if (value) {
5989
- if (this.isActiveAndEnabled) {
5990
- this.enable();
5991
- if (!this.isStartCalled) {
5992
- this.onStart();
5993
- this.isStartCalled = true;
5994
- }
5995
- }
5996
- } else {
5997
- if (this.isEnableCalled) {
5998
- this.disable();
5999
- }
6000
- }
6001
- }
6002
- }
6003
- }
6004
- ]);
6005
- return Component;
6006
- }(EffectsObject);
6007
- __decorate([
6008
- serialize()
6009
- ], Component.prototype, "item", void 0);
6010
- __decorate([
6011
- serialize()
6012
- ], Component.prototype, "_enabled", void 0);
6013
- /**
6014
- * @since 2.0.0
6015
- * @deprecated 2.4.0 Please use Component instead
6016
- */ var Behaviour = /*#__PURE__*/ function(Component) {
6017
- _inherits(Behaviour, Component);
6018
- function Behaviour() {
6019
- return Component.apply(this, arguments);
6020
- }
6021
- var _proto = Behaviour.prototype;
6022
- _proto.setVFXItem = function setVFXItem(item) {
6023
- Component.prototype.setVFXItem.call(this, item);
6024
- };
6025
- _proto.dispose = function dispose() {
6026
- Component.prototype.dispose.call(this);
6027
- };
6028
- return Behaviour;
6029
- }(Component);
6030
-
6031
- exports.Animator = /*#__PURE__*/ function(Component) {
6032
- _inherits(Animator, Component);
6033
- function Animator() {
6034
- var _this;
6035
- _this = Component.apply(this, arguments) || this;
6036
- /**
6037
- * @internal
6038
- */ _this.graph = null;
6039
- _this.graphAsset = null;
6040
- return _this;
6041
- }
6042
- var _proto = Animator.prototype;
6043
- _proto.setBool = function setBool(name, value) {
6044
- if (this.graph) {
6045
- this.graph.setBool(name, value);
6046
- }
6047
- };
6048
- _proto.setFloat = function setFloat(name, value) {
6049
- if (this.graph) {
6050
- this.graph.setFloat(name, value);
6051
- }
6052
- };
6053
- _proto.setTrigger = function setTrigger(name) {
6054
- if (this.graph) {
6055
- this.graph.setTrigger(name);
6056
- }
6057
- };
6058
- _proto.resetTrigger = function resetTrigger(name) {
6059
- if (this.graph) {
6060
- this.graph.resetTrigger(name);
6646
+ return;
6061
6647
  }
6648
+ this.parentSpaceTransforms.push(new NodeTransform(targetBone.transform));
6649
+ this.animatedTransforms.push(targetBone.transform);
6650
+ this.pathToBoneIndex.set(path, this.parentSpaceTransforms.length - 1);
6062
6651
  };
6063
- _proto.onStart = function onStart() {
6064
- if (this.graphAsset) {
6065
- this.graph = new GraphInstance(this.graphAsset, this.item);
6652
+ _proto.addRecordedProperty = function addRecordedProperty(path, className, property, type) {
6653
+ var totalPath = path + className + property;
6654
+ if (this.pathToObjectIndex.get(totalPath) !== undefined) {
6655
+ return;
6066
6656
  }
6067
- };
6068
- _proto.onUpdate = function onUpdate(dt) {
6069
- if (!this.graph) {
6657
+ var targetBone = this.findTarget(path);
6658
+ if (!targetBone) {
6070
6659
  return;
6071
6660
  }
6072
- var result = this.graph.evaluateGraph(dt / 1000);
6073
- // Apply transform animation
6074
- //-------------------------------------------------------------------------
6075
- var animatedTransforms = this.graph.skeleton.animatedTransforms;
6076
- for(var i = 0; i < animatedTransforms.length; i++){
6077
- var position = result.pose.parentSpaceTransforms[i].position;
6078
- var rotation = result.pose.parentSpaceTransforms[i].rotation;
6079
- var scale = result.pose.parentSpaceTransforms[i].scale;
6080
- var euler = result.pose.parentSpaceTransforms[i].euler;
6081
- animatedTransforms[i].setPosition(position.x, position.y, position.z);
6082
- animatedTransforms[i].setScale(scale.x, scale.y, scale.z);
6083
- if (this.graph.skeleton.useEuler) {
6084
- animatedTransforms[i].setRotation(euler.x, euler.y, euler.z);
6085
- } else {
6086
- animatedTransforms[i].setQuaternion(rotation.x, rotation.y, rotation.z, rotation.w);
6087
- }
6661
+ var animatedComponentOrItem;
6662
+ // Find target component or VFXItem
6663
+ if (className === VFXItemType) {
6664
+ animatedComponentOrItem = targetBone;
6665
+ } else {
6666
+ animatedComponentOrItem = targetBone.getComponent(getClass(className));
6088
6667
  }
6089
- // Apply property animation
6090
- //-------------------------------------------------------------------------
6091
- var floatAnimatedObjects = this.graph.skeleton.floatAnimatedObjects;
6092
- for(var i1 = 0; i1 < floatAnimatedObjects.length; i1++){
6093
- var animatedObject = floatAnimatedObjects[i1];
6094
- var property = animatedObject.property;
6095
- animatedObject.target[property] = result.pose.floatPropertyValues[i1];
6668
+ if (!animatedComponentOrItem) {
6669
+ console.error("The " + className + " Component was not found.");
6096
6670
  }
6097
- var colorAnimatedObjects = this.graph.skeleton.colorAnimatedObjects;
6098
- for(var i2 = 0; i2 < colorAnimatedObjects.length; i2++){
6099
- var animatedObject1 = colorAnimatedObjects[i2];
6100
- var property1 = animatedObject1.property;
6101
- animatedObject1.target[property1] = result.pose.colorPropertyValues[i2];
6671
+ // Find last animated object by path
6672
+ var propertyNames = property.split(".");
6673
+ var lastPropertyName = propertyNames[propertyNames.length - 1];
6674
+ var target = animatedComponentOrItem;
6675
+ for(var i = 0; i < propertyNames.length - 1; i++){
6676
+ var _$property = target[propertyNames[i]];
6677
+ if (_$property === undefined) {
6678
+ console.error("The " + propertyNames[i] + " property of " + target + " was not found.");
6679
+ }
6680
+ target = _$property;
6681
+ }
6682
+ var animatedObject = {
6683
+ target: target,
6684
+ property: lastPropertyName
6685
+ };
6686
+ switch(type){
6687
+ case 0:
6688
+ this.floatAnimatedObjects.push(animatedObject);
6689
+ this.defaultFloatPropertyValues.push(target[lastPropertyName]);
6690
+ this.pathToObjectIndex.set(totalPath, this.floatAnimatedObjects.length - 1);
6691
+ break;
6692
+ case 1:
6693
+ this.colorAnimatedObjects.push(animatedObject);
6694
+ this.defaultColorPropertyValues.push(new Color().copyFrom(target[lastPropertyName]));
6695
+ this.pathToObjectIndex.set(totalPath, this.colorAnimatedObjects.length - 1);
6102
6696
  }
6103
6697
  };
6104
- _proto.fromData = function fromData(data) {
6105
- this.graphAsset = this.engine.findObject(data.graphAsset);
6698
+ _proto.findTarget = function findTarget(boneName) {
6699
+ if (boneName === "") {
6700
+ return this.rootBone;
6701
+ }
6702
+ var itemNames = boneName.split("/");
6703
+ var currentItem = this.rootBone;
6704
+ for(var _iterator = _create_for_of_iterator_helper_loose(itemNames), _step; !(_step = _iterator()).done;){
6705
+ var itemName = _step.value;
6706
+ var target = currentItem.find(itemName);
6707
+ if (!target) {
6708
+ return null;
6709
+ }
6710
+ currentItem = target;
6711
+ }
6712
+ return currentItem;
6106
6713
  };
6107
- return Animator;
6108
- }(Component);
6109
- exports.Animator = __decorate([
6110
- effectsClass("Animator")
6111
- ], exports.Animator);
6714
+ return Skeleton;
6715
+ }();
6112
6716
 
6113
- /**
6114
- * 所有渲染组件的基类
6115
- * @since 2.0.0
6116
- */ var RendererComponent = /*#__PURE__*/ function(Component) {
6117
- _inherits(RendererComponent, Component);
6118
- function RendererComponent() {
6119
- var _this;
6120
- _this = Component.apply(this, arguments) || this;
6121
- _this.materials = [];
6122
- _this._priority = 0;
6123
- return _this;
6124
- }
6125
- var _proto = RendererComponent.prototype;
6126
- _proto.render = function render(renderer) {};
6127
- _proto.onEnable = function onEnable() {
6128
- var _this_item_composition;
6129
- (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.renderFrame.addMeshToDefaultRenderPass(this);
6130
- };
6131
- _proto.onDisable = function onDisable() {
6132
- var _this_item_composition;
6133
- (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.renderFrame.removeMeshFromDefaultRenderPass(this);
6134
- };
6135
- _create_class(RendererComponent, [
6136
- {
6137
- key: "priority",
6138
- get: function get() {
6139
- return this._priority;
6140
- },
6141
- set: function set(value) {
6142
- this._priority = value;
6717
+ var GraphInstance = /*#__PURE__*/ function() {
6718
+ function GraphInstance(graphAsset, rootBone) {
6719
+ this.graphAsset = graphAsset;
6720
+ this.nodes = [];
6721
+ this.context = new GraphContext();
6722
+ // Initialize skeleton
6723
+ var recordProperties = {
6724
+ position: [],
6725
+ scale: [],
6726
+ rotation: [],
6727
+ euler: [],
6728
+ floats: [],
6729
+ colors: []
6730
+ };
6731
+ for(var _iterator = _create_for_of_iterator_helper_loose(graphAsset.graphDataSet.resources), _step; !(_step = _iterator()).done;){
6732
+ var animationClip = _step.value;
6733
+ if (!animationClip) {
6734
+ continue;
6143
6735
  }
6144
- },
6145
- {
6146
- key: "material",
6147
- get: function get() {
6148
- return this.materials[0];
6149
- },
6150
- set: function set(material) {
6151
- if (this.materials.length === 0) {
6152
- this.materials.push(material);
6153
- } else {
6154
- this.materials[0] = material;
6155
- }
6736
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(animationClip.positionCurves), _step1; !(_step1 = _iterator1()).done;){
6737
+ var positionCurve = _step1.value;
6738
+ recordProperties.position.push(positionCurve.path);
6739
+ }
6740
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(animationClip.rotationCurves), _step2; !(_step2 = _iterator2()).done;){
6741
+ var rotationCurve = _step2.value;
6742
+ recordProperties.rotation.push(rotationCurve.path);
6743
+ }
6744
+ for(var _iterator3 = _create_for_of_iterator_helper_loose(animationClip.scaleCurves), _step3; !(_step3 = _iterator3()).done;){
6745
+ var scaleCurve = _step3.value;
6746
+ recordProperties.scale.push(scaleCurve.path);
6747
+ }
6748
+ for(var _iterator4 = _create_for_of_iterator_helper_loose(animationClip.eulerCurves), _step4; !(_step4 = _iterator4()).done;){
6749
+ var eulerCurve = _step4.value;
6750
+ recordProperties.euler.push(eulerCurve.path);
6751
+ }
6752
+ for(var _iterator5 = _create_for_of_iterator_helper_loose(animationClip.floatCurves), _step5; !(_step5 = _iterator5()).done;){
6753
+ var floatCurve = _step5.value;
6754
+ recordProperties.floats.push(floatCurve);
6755
+ }
6756
+ for(var _iterator6 = _create_for_of_iterator_helper_loose(animationClip.colorCurves), _step6; !(_step6 = _iterator6()).done;){
6757
+ var colorCurve = _step6.value;
6758
+ recordProperties.colors.push(colorCurve);
6156
6759
  }
6157
6760
  }
6158
- ]);
6159
- return RendererComponent;
6160
- }(Component);
6161
- __decorate([
6162
- serialize()
6163
- ], RendererComponent.prototype, "materials", void 0);
6164
- __decorate([
6165
- serialize()
6166
- ], RendererComponent.prototype, "_priority", void 0);
6167
-
6168
- /**
6169
- * 四维向量
6170
- */ var Vector4 = /*#__PURE__*/ function() {
6171
- function Vector4(x, y, z, w) {
6172
- if (x === void 0) x = 0;
6173
- if (y === void 0) y = 0;
6174
- if (z === void 0) z = 0;
6175
- if (w === void 0) w = 0;
6176
- this.x = x;
6177
- this.y = y;
6178
- this.z = z;
6179
- this.w = w;
6761
+ this.skeleton = new Skeleton(rootBone, recordProperties);
6762
+ // create PoseResult
6763
+ this.result = new PoseResult(this.skeleton);
6764
+ this.context.skeleton = this.skeleton;
6765
+ // instantiate graph nodes
6766
+ var instantiationContext = new InstantiationContext();
6767
+ instantiationContext.nodes = this.nodes;
6768
+ instantiationContext.nodeDatas = graphAsset.nodeDatas;
6769
+ instantiationContext.dataSet = graphAsset.graphDataSet;
6770
+ for(var i = 0; i < graphAsset.nodeDatas.length; i++){
6771
+ if (!instantiationContext.nodes[i]) {
6772
+ graphAsset.nodeDatas[i].instantiate(instantiationContext);
6773
+ }
6774
+ }
6775
+ this.rootNode = this.nodes[graphAsset.rootNodeIndex];
6180
6776
  }
6181
- var _proto = Vector4.prototype;
6182
- /**
6183
- * 设置向量
6184
- * @param x - x 轴分量
6185
- * @param y - y 轴分量
6186
- * @param z - z 轴分量
6187
- * @param w - w 轴分量
6188
- * @returns
6189
- */ _proto.set = function set(x, y, z, w) {
6190
- this.x = x;
6191
- this.y = y;
6192
- this.z = z;
6193
- this.w = w;
6194
- return this;
6195
- };
6196
- /**
6197
- * 设置零向量
6198
- * @returns 向量
6199
- */ _proto.setZero = function setZero() {
6200
- this.x = 0;
6201
- this.y = 0;
6202
- this.z = 0;
6203
- this.w = 0;
6204
- return this;
6205
- };
6206
- /**
6207
- * 通过标量数值设置向量
6208
- * @param num - 数值
6209
- * @returns 向量
6210
- */ _proto.setFromNumber = function setFromNumber(num) {
6211
- this.x = num;
6212
- this.y = num;
6213
- this.z = num;
6214
- this.w = num;
6215
- return this;
6216
- };
6217
- /**
6218
- * 通过数组创建向量
6219
- * @param array - 数组
6220
- * @param [offset=0] - 起始偏移值
6221
- * @returns 向量
6222
- */ _proto.setFromArray = function setFromArray(array, offset) {
6223
- if (offset === void 0) offset = 0;
6224
- var _array_offset;
6225
- this.x = (_array_offset = array[offset]) != null ? _array_offset : 0;
6226
- var _array_;
6227
- this.y = (_array_ = array[offset + 1]) != null ? _array_ : 0;
6228
- var _array_1;
6229
- this.z = (_array_1 = array[offset + 2]) != null ? _array_1 : 0;
6230
- var _array_2;
6231
- this.w = (_array_2 = array[offset + 3]) != null ? _array_2 : 0;
6232
- return this;
6777
+ var _proto = GraphInstance.prototype;
6778
+ _proto.evaluateGraph = function evaluateGraph(deltaTime) {
6779
+ this.context.update(deltaTime);
6780
+ if (!this.rootNode.isInitialized()) {
6781
+ this.resetGraphState();
6782
+ }
6783
+ // Evaluate the entire animation graph starting from the rootNode
6784
+ if (this.rootNode) {
6785
+ this.result = this.rootNode.evaluate(this.context, this.result);
6786
+ }
6787
+ // Reset trigger nodes
6788
+ for(var i = 0; i < this.getNumControlParameters(); i++){
6789
+ var controlParameterNode = this.nodes[i];
6790
+ if (_instanceof1(controlParameterNode, ControlParameterTriggerNode)) {
6791
+ controlParameterNode.setValue(false);
6792
+ }
6793
+ }
6794
+ return this.result;
6233
6795
  };
6234
- /**
6235
- * 拷贝向量
6236
- * @param v - 复制对象
6237
- * @returns 拷贝结果
6238
- */ _proto.copyFrom = function copyFrom(v) {
6239
- this.x = v.x;
6240
- this.y = v.y;
6241
- this.z = v.z;
6242
- this.w = v.w;
6243
- return this;
6796
+ _proto.isInitialized = function isInitialized() {
6797
+ return this.rootNode && this.rootNode.isInitialized();
6244
6798
  };
6245
- /**
6246
- * 克隆向量
6247
- * @returns 克隆结果
6248
- */ _proto.clone = function clone() {
6249
- return new Vector4(this.x, this.y, this.z, this.w);
6799
+ // General Node Info
6800
+ //-------------------------------------------------------------------------
6801
+ _proto.isNodeActive = function isNodeActive(nodeIdx) {
6802
+ return this.isControlParameter(nodeIdx) || this.nodes[nodeIdx].isNodeActive(this.context.updateID);
6250
6803
  };
6251
- /**
6252
- * 根据下标设置向量分量
6253
- * @param index - 下标值
6254
- * @param value - 分量值
6255
- * @returns 向量
6256
- */ _proto.setElement = function setElement(index, value) {
6257
- switch(index){
6258
- case 0:
6259
- this.x = value;
6260
- break;
6261
- case 1:
6262
- this.y = value;
6263
- break;
6264
- case 2:
6265
- this.z = value;
6266
- break;
6267
- case 3:
6268
- this.w = value;
6269
- break;
6270
- default:
6271
- console.error("index is out of range: " + index);
6804
+ // Graph State
6805
+ //-------------------------------------------------------------------------
6806
+ _proto.resetGraphState = function resetGraphState() {
6807
+ if (this.rootNode.isInitialized()) {
6808
+ this.rootNode.shutdown(this.context);
6272
6809
  }
6273
- return this;
6810
+ this.context.updateID++; // Bump the update ID to ensure that any initialization code that relies on it is dirtied.
6811
+ this.rootNode.initialize(this.context);
6274
6812
  };
6275
- /**
6276
- * 根据下标获取向量分量
6277
- * @param index - 下标
6278
- * @returns 分量值
6279
- */ _proto.getElement = function getElement(index) {
6280
- switch(index){
6281
- case 0:
6282
- return this.x;
6283
- case 1:
6284
- return this.y;
6285
- case 2:
6286
- return this.z;
6287
- case 3:
6288
- return this.w;
6289
- default:
6290
- console.error("index is out of range: " + index);
6291
- }
6292
- return 0;
6813
+ // Control Parameters
6814
+ //-------------------------------------------------------------------------
6815
+ _proto.getNumControlParameters = function getNumControlParameters() {
6816
+ return this.graphAsset.controlParameterIDs.length;
6293
6817
  };
6294
- /**
6295
- * 向量相加
6296
- * @param right - 相加对象,向量 | 数字
6297
- * @returns 相加结果
6298
- */ _proto.add = function add(right) {
6299
- if (typeof right === "number") {
6300
- this.x += right;
6301
- this.y += right;
6302
- this.z += right;
6303
- this.w += right;
6304
- } else if (_instanceof1(right, Array)) {
6305
- this.x += right[0];
6306
- this.y += right[1];
6307
- this.z += right[2];
6308
- this.w += right[3];
6309
- } else {
6310
- this.x += right.x;
6311
- this.y += right.y;
6312
- this.z += right.z;
6313
- this.w += right.w;
6818
+ _proto.getControlParameterIndex = function getControlParameterIndex(parameterID) {
6819
+ var parameterLookupMap = this.graphAsset.parameterLookupMap;
6820
+ var res = parameterLookupMap.get(parameterID);
6821
+ if (res !== undefined) {
6822
+ return res;
6314
6823
  }
6315
- return this;
6316
- };
6317
- /**
6318
- * 向量相加
6319
- * @param left - 向量
6320
- * @param right - 向量
6321
- * @returns 求和结果
6322
- */ _proto.addVectors = function addVectors(left, right) {
6323
- this.x = left.x + right.x;
6324
- this.y = left.y + right.y;
6325
- this.z = left.z + right.z;
6326
- this.w = left.w + right.w;
6327
- return this;
6824
+ console.warn("Parameter '" + parameterID + "' does not exist.");
6825
+ return InvalidIndex;
6328
6826
  };
6329
- /**
6330
- * 向量比例缩放后相加
6331
- * @param right - 向量
6332
- * @param s - 比例
6333
- * @returns 求和结果
6334
- */ _proto.addScaledVector = function addScaledVector(right, s) {
6335
- this.x += right.x * s;
6336
- this.y += right.y * s;
6337
- this.z += right.z * s;
6338
- this.w += right.w * s;
6339
- return this;
6827
+ _proto.getControlParameterID = function getControlParameterID(parameterNodeIndex) {
6828
+ return this.graphAsset.controlParameterIDs[parameterNodeIndex];
6340
6829
  };
6341
- /**
6342
- * 向量相减
6343
- * @param right - 相减对象,向量 | 数字
6344
- * @returns 相减结果
6345
- */ _proto.subtract = function subtract(right) {
6346
- if (typeof right === "number") {
6347
- this.x -= right;
6348
- this.y -= right;
6349
- this.z -= right;
6350
- this.w -= right;
6351
- } else if (_instanceof1(right, Array)) {
6352
- this.x -= right[0];
6353
- this.y -= right[1];
6354
- this.z -= right[2];
6355
- this.w -= right[3];
6356
- } else {
6357
- this.x -= right.x;
6358
- this.y -= right.y;
6359
- this.z -= right.z;
6360
- this.w -= right.w;
6361
- }
6362
- return this;
6830
+ _proto.setBool = function setBool(name, value) {
6831
+ this.setControlParameterValue(name, value);
6363
6832
  };
6364
- /**
6365
- * 向量相减
6366
- * @param left - 向量
6367
- * @param right - 向量
6368
- * @returns 向量
6369
- */ _proto.subtractVectors = function subtractVectors(left, right) {
6370
- this.x = left.x - right.x;
6371
- this.y = left.y - right.y;
6372
- this.z = left.z - right.z;
6373
- this.w = left.w - right.w;
6374
- return this;
6833
+ _proto.setFloat = function setFloat(name, value) {
6834
+ this.setControlParameterValue(name, value);
6375
6835
  };
6376
- /**
6377
- * 向量相乘
6378
- * @param right - 相乘对象,对象 | 数字
6379
- * @returns 向量
6380
- */ _proto.multiply = function multiply(right) {
6381
- if (typeof right === "number") {
6382
- this.x *= right;
6383
- this.y *= right;
6384
- this.z *= right;
6385
- this.w *= right;
6386
- } else if (_instanceof1(right, Array)) {
6387
- this.x *= right[0];
6388
- this.y *= right[1];
6389
- this.z *= right[2];
6390
- this.w *= right[3];
6391
- } else {
6392
- this.x *= right.x;
6393
- this.y *= right.y;
6394
- this.z *= right.z;
6395
- this.w *= right.w;
6396
- }
6397
- return this;
6836
+ _proto.setTrigger = function setTrigger(name) {
6837
+ this.setControlParameterValue(name, true);
6398
6838
  };
6399
- /**
6400
- * 向量相乘
6401
- * @param left - 向量
6402
- * @param right - 向量
6403
- * @returns 向量
6404
- */ _proto.multiplyVectors = function multiplyVectors(left, right) {
6405
- this.x = left.x * right.x;
6406
- this.y = left.y * right.y;
6407
- this.z = left.z * right.z;
6408
- this.w = left.w * right.w;
6409
- return this;
6839
+ _proto.resetTrigger = function resetTrigger(name) {
6840
+ this.setControlParameterValue(name, false);
6410
6841
  };
6411
- /**
6412
- * 向量相除
6413
- * @param right - 相除对象,对象 | 数字
6414
- * @returns 向量
6415
- */ _proto.divide = function divide(right) {
6416
- if (typeof right === "number") {
6417
- this.x /= right;
6418
- this.y /= right;
6419
- this.z /= right;
6420
- this.w /= right;
6421
- } else if (_instanceof1(right, Array)) {
6422
- this.x /= right[0];
6423
- this.y /= right[1];
6424
- this.z /= right[2];
6425
- this.w /= right[3];
6426
- } else {
6427
- this.x /= right.x;
6428
- this.y /= right.y;
6429
- this.z /= right.z;
6430
- this.w /= right.w;
6431
- }
6432
- return this;
6842
+ // Debug Information
6843
+ //-------------------------------------------------------------------------
6844
+ _proto.getPoseNodeDebugInfo = function getPoseNodeDebugInfo(nodeIdx) {
6845
+ var node = this.nodes[nodeIdx];
6846
+ return node.getDebugInfo();
6433
6847
  };
6434
- /**
6435
- * 向量缩放
6436
- * @param v - 数字
6437
- * @returns 缩放结果
6438
- */ _proto.scale = function scale(v) {
6439
- this.x *= v;
6440
- this.y *= v;
6441
- this.z *= v;
6442
- this.w *= v;
6443
- return this;
6848
+ _proto.getRuntimeNodeDebugValue = function getRuntimeNodeDebugValue(nodeIdx) {
6849
+ var valueNode = this.nodes[nodeIdx];
6850
+ return valueNode.getValue(this.context);
6444
6851
  };
6445
- /**
6446
- * 分量求和
6447
- * @returns 求和结果
6448
- */ _proto.sum = function sum() {
6449
- return this.x + this.y + this.z + this.w;
6852
+ _proto.getNodeDebugInstance = function getNodeDebugInstance(nodeIdx) {
6853
+ return this.nodes[nodeIdx];
6450
6854
  };
6451
- /**
6452
- * 向量求最小值
6453
- * @param v - 向量或数值
6454
- * @returns 最小值
6455
- */ _proto.min = function min(v) {
6456
- if (typeof v === "number") {
6457
- this.x = Math.min(this.x, v);
6458
- this.y = Math.min(this.y, v);
6459
- this.z = Math.min(this.z, v);
6460
- this.w = Math.min(this.w, v);
6461
- } else {
6462
- this.x = Math.min(this.x, v.x);
6463
- this.y = Math.min(this.y, v.y);
6464
- this.z = Math.min(this.z, v.z);
6465
- this.w = Math.min(this.w, v.w);
6466
- }
6467
- return this;
6855
+ _proto.isControlParameter = function isControlParameter(nodeIdx) {
6856
+ return nodeIdx < this.getNumControlParameters();
6468
6857
  };
6469
- /**
6470
- * 向量求最大值
6471
- * @param v - 向量或数值
6472
- * @returns 最大值
6473
- */ _proto.max = function max(v) {
6474
- if (typeof v === "number") {
6475
- this.x = Math.max(this.x, v);
6476
- this.y = Math.max(this.y, v);
6477
- this.z = Math.max(this.z, v);
6478
- this.w = Math.max(this.w, v);
6479
- } else {
6480
- this.x = Math.max(this.x, v.x);
6481
- this.y = Math.max(this.y, v.y);
6482
- this.z = Math.max(this.z, v.z);
6483
- this.w = Math.max(this.w, v.w);
6858
+ _proto.setControlParameterValue = function setControlParameterValue(name, value) {
6859
+ var index = this.getControlParameterIndex(name);
6860
+ if (index !== InvalidIndex) {
6861
+ this.nodes[index].setValue(value);
6484
6862
  }
6485
- return this;
6486
6863
  };
6864
+ return GraphInstance;
6865
+ }();
6866
+
6867
+ function _defineProperties(target, props) {
6868
+ for(var i = 0; i < props.length; i++){
6869
+ var descriptor = props[i];
6870
+ descriptor.enumerable = descriptor.enumerable || false;
6871
+ descriptor.configurable = true;
6872
+ if ("value" in descriptor) descriptor.writable = true;
6873
+ Object.defineProperty(target, descriptor.key, descriptor);
6874
+ }
6875
+ }
6876
+ function _create_class(Constructor, protoProps, staticProps) {
6877
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
6878
+ if (staticProps) _defineProperties(Constructor, staticProps);
6879
+ return Constructor;
6880
+ }
6881
+
6882
+ /**
6883
+ * @since 2.0.0
6884
+ */ var Component = /*#__PURE__*/ function(EffectsObject) {
6885
+ _inherits(Component, EffectsObject);
6886
+ function Component() {
6887
+ var _this;
6888
+ _this = EffectsObject.apply(this, arguments) || this;
6889
+ _this.isAwakeCalled = false;
6890
+ _this.isStartCalled = false;
6891
+ _this.isEnableCalled = false;
6892
+ _this._enabled = true;
6893
+ return _this;
6894
+ }
6895
+ var _proto = Component.prototype;
6487
6896
  /**
6488
- * 向量阈值约束
6489
- * @param min - 最小值
6490
- * @param max - 最大值
6491
- * @returns 向量
6492
- */ _proto.clamp = function clamp(min, max) {
6493
- return this.max(min).min(max);
6897
+ * 生命周期函数,初始化后调用,生命周期内只调用一次
6898
+ */ _proto.onAwake = function onAwake() {
6899
+ // OVERRIDE
6494
6900
  };
6495
6901
  /**
6496
- * 向量向下取整
6497
- * @returns 取整结果
6498
- */ _proto.floor = function floor() {
6499
- this.x = Math.floor(this.x);
6500
- this.y = Math.floor(this.y);
6501
- this.z = Math.floor(this.z);
6502
- this.w = Math.floor(this.w);
6503
- return this;
6902
+ * 在 enabled 变为 true 时触发
6903
+ */ _proto.onEnable = function onEnable() {
6904
+ // OVERRIDE
6504
6905
  };
6505
6906
  /**
6506
- * 向量向上取整
6507
- * @returns 取整结果
6508
- */ _proto.ceil = function ceil() {
6509
- this.x = Math.ceil(this.x);
6510
- this.y = Math.ceil(this.y);
6511
- this.z = Math.ceil(this.z);
6512
- this.w = Math.ceil(this.w);
6513
- return this;
6907
+ * 在 enabled 变为 false 时触发
6908
+ */ _proto.onDisable = function onDisable() {
6909
+ // OVERRIDE
6514
6910
  };
6515
6911
  /**
6516
- * 向量四舍五入
6517
- * @returns 求值结果
6518
- */ _proto.round = function round() {
6519
- this.x = Math.round(this.x);
6520
- this.y = Math.round(this.y);
6521
- this.z = Math.round(this.z);
6522
- this.w = Math.round(this.w);
6523
- return this;
6912
+ * 生命周期函数,在第一次 update 前调用,生命周期内只调用一次
6913
+ */ _proto.onStart = function onStart() {
6914
+ // OVERRIDE
6524
6915
  };
6525
6916
  /**
6526
- * 向量取绝对值
6527
- * @returns 向量
6528
- */ _proto.abs = function abs() {
6529
- this.x = Math.abs(this.x);
6530
- this.y = Math.abs(this.y);
6531
- this.z = Math.abs(this.z);
6532
- this.w = Math.abs(this.w);
6533
- return this;
6917
+ * 生命周期函数,每帧调用一次
6918
+ */ _proto.onUpdate = function onUpdate(dt) {
6919
+ // OVERRIDE
6534
6920
  };
6535
6921
  /**
6536
- * 向量取反
6537
- * @returns 取反结果
6538
- */ _proto.negate = function negate() {
6539
- this.x = -this.x;
6540
- this.y = -this.y;
6541
- this.z = -this.z;
6542
- this.w = -this.w;
6543
- return this;
6922
+ * 生命周期函数,每帧调用一次,在 update 之后调用
6923
+ */ _proto.onLateUpdate = function onLateUpdate(dt) {
6924
+ // OVERRIDE
6544
6925
  };
6545
6926
  /**
6546
- * 向量长度平方
6547
- * @returns 长度平方
6548
- */ _proto.lengthSquared = function lengthSquared() {
6549
- return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
6927
+ * 生命周期函数,在组件销毁时调用
6928
+ */ _proto.onDestroy = function onDestroy() {
6929
+ // OVERRIDE
6550
6930
  };
6551
6931
  /**
6552
- * 向量长度
6553
- * @returns 长度
6554
- */ _proto.length = function length() {
6555
- return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
6932
+ * @internal
6933
+ */ _proto.enable = function enable() {
6934
+ if (this.item.composition) {
6935
+ this.item.composition.sceneTicking.addComponent(this);
6936
+ this.isEnableCalled = true;
6937
+ }
6938
+ this.onEnable();
6556
6939
  };
6557
6940
  /**
6558
- * 向量归一化
6559
- * @returns 归一化结果
6560
- */ _proto.normalize = function normalize() {
6561
- return this.divide(this.length() || 1);
6941
+ * @internal
6942
+ */ _proto.disable = function disable() {
6943
+ this.onDisable();
6944
+ if (this.item.composition) {
6945
+ this.isEnableCalled = false;
6946
+ this.item.composition.sceneTicking.removeComponent(this);
6947
+ }
6562
6948
  };
6563
- /**
6564
- * 设置向量长度
6565
- * @param length - 长度
6566
- * @returns 向量
6567
- */ _proto.setLength = function setLength(length) {
6568
- return this.normalize().multiply(length);
6949
+ _proto.setVFXItem = function setVFXItem(item) {
6950
+ this.item = item;
6951
+ if (item.isDuringPlay) {
6952
+ if (!this.isAwakeCalled) {
6953
+ this.onAwake();
6954
+ this.isAwakeCalled = true;
6955
+ }
6956
+ if (item.isActive && this.enabled) {
6957
+ this.start();
6958
+ this.enable();
6959
+ }
6960
+ }
6569
6961
  };
6570
- /**
6571
- * 向量求线性插值
6572
- * @param v - 向量
6573
- * @param alpha - 插值比例
6574
- * @returns 插值结果
6575
- */ _proto.lerp = function lerp(v, alpha) {
6576
- this.x += (v.x - this.x) * alpha;
6577
- this.y += (v.y - this.y) * alpha;
6578
- this.z += (v.z - this.z) * alpha;
6579
- this.w += (v.w - this.w) * alpha;
6580
- return this;
6962
+ _proto.fromData = function fromData(data) {
6963
+ EffectsObject.prototype.fromData.call(this, data);
6581
6964
  };
6582
- /**
6583
- * 两向量求线性插值
6584
- * @param v1 - 第一个向量
6585
- * @param v2 - 第二个向量
6586
- * @param alpha - 插值比例
6587
- * @returns 插值结果
6588
- */ _proto.lerpVectors = function lerpVectors(v1, v2, alpha) {
6589
- this.x = v1.x + (v2.x - v1.x) * alpha;
6590
- this.y = v1.y + (v2.y - v1.y) * alpha;
6591
- this.z = v1.z + (v2.z - v1.z) * alpha;
6592
- this.w = v1.w + (v2.w - v1.w) * alpha;
6593
- return this;
6965
+ _proto.dispose = function dispose() {
6966
+ if (this.isEnableCalled) {
6967
+ this.disable();
6968
+ }
6969
+ if (this.isAwakeCalled) {
6970
+ this.isAwakeCalled = false;
6971
+ this.onDestroy();
6972
+ }
6973
+ if (this.item) {
6974
+ removeItem(this.item.components, this);
6975
+ }
6594
6976
  };
6595
- /**
6596
- * 向量求点积
6597
- * @param v - 向量
6598
- * @returns 点积结果
6599
- */ _proto.dot = function dot(v) {
6600
- return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
6977
+ _proto.start = function start() {
6978
+ if (this.isStartCalled) {
6979
+ return;
6980
+ }
6981
+ this.isStartCalled = true;
6982
+ this.onStart();
6601
6983
  };
6602
- /**
6603
- * 向量判等
6604
- * @param v - 向量
6605
- * @returns 判等结果
6606
- */ _proto.equals = function equals(v) {
6607
- return v.x === this.x && v.y === this.y && v.z === this.z && v.w === this.w;
6984
+ _create_class(Component, [
6985
+ {
6986
+ key: "transform",
6987
+ get: /**
6988
+ * 附加到的 VFXItem 对象 Transform 组件
6989
+ */ function get() {
6990
+ return this.item.transform;
6991
+ }
6992
+ },
6993
+ {
6994
+ key: "isActiveAndEnabled",
6995
+ get: /**
6996
+ * 组件是否可以更新,true 更新,false 不更新
6997
+ */ function get() {
6998
+ return this.item.isActive && this.enabled;
6999
+ }
7000
+ },
7001
+ {
7002
+ key: "enabled",
7003
+ get: function get() {
7004
+ return this._enabled;
7005
+ },
7006
+ set: function set(value) {
7007
+ if (this.enabled !== value) {
7008
+ this._enabled = value;
7009
+ if (value) {
7010
+ if (this.isActiveAndEnabled) {
7011
+ this.enable();
7012
+ if (!this.isStartCalled) {
7013
+ this.onStart();
7014
+ this.isStartCalled = true;
7015
+ }
7016
+ }
7017
+ } else {
7018
+ if (this.isEnableCalled) {
7019
+ this.disable();
7020
+ }
7021
+ }
7022
+ }
7023
+ }
7024
+ }
7025
+ ]);
7026
+ return Component;
7027
+ }(EffectsObject);
7028
+ __decorate([
7029
+ serialize()
7030
+ ], Component.prototype, "item", void 0);
7031
+ __decorate([
7032
+ serialize()
7033
+ ], Component.prototype, "_enabled", void 0);
7034
+ /**
7035
+ * @since 2.0.0
7036
+ * @deprecated 2.4.0 Please use Component instead
7037
+ */ var Behaviour = /*#__PURE__*/ function(Component) {
7038
+ _inherits(Behaviour, Component);
7039
+ function Behaviour() {
7040
+ return Component.apply(this, arguments);
7041
+ }
7042
+ var _proto = Behaviour.prototype;
7043
+ _proto.setVFXItem = function setVFXItem(item) {
7044
+ Component.prototype.setVFXItem.call(this, item);
6608
7045
  };
6609
- /**
6610
- * 是否零向量
6611
- * @returns 是否零向量
6612
- */ _proto.isZero = function isZero() {
6613
- var eps = NumberEpsilon;
6614
- var _this = this, x = _this.x, y = _this.y, z = _this.z, w = _this.w;
6615
- return Math.abs(x) <= eps && Math.abs(y) <= eps && Math.abs(z) <= eps && Math.abs(w) <= eps;
7046
+ _proto.dispose = function dispose() {
7047
+ Component.prototype.dispose.call(this);
6616
7048
  };
6617
- /**
6618
- * 向量转数组
6619
- * @returns 数组
6620
- */ _proto.toArray = function toArray() {
6621
- return [
6622
- this.x,
6623
- this.y,
6624
- this.z,
6625
- this.w
6626
- ];
7049
+ return Behaviour;
7050
+ }(Component);
7051
+
7052
+ exports.Animator = /*#__PURE__*/ function(Component) {
7053
+ _inherits(Animator, Component);
7054
+ function Animator() {
7055
+ var _this;
7056
+ _this = Component.apply(this, arguments) || this;
7057
+ /**
7058
+ * @internal
7059
+ */ _this.graph = null;
7060
+ _this.graphAsset = null;
7061
+ return _this;
7062
+ }
7063
+ var _proto = Animator.prototype;
7064
+ _proto.setBool = function setBool(name, value) {
7065
+ if (this.graph) {
7066
+ this.graph.setBool(name, value);
7067
+ }
6627
7068
  };
6628
- _proto.toVector3 = function toVector3() {
6629
- return new Vector3(this.x, this.y, this.z);
7069
+ _proto.setFloat = function setFloat(name, value) {
7070
+ if (this.graph) {
7071
+ this.graph.setFloat(name, value);
7072
+ }
6630
7073
  };
6631
- _proto.fill = function fill(array, offset) {
6632
- if (offset === void 0) offset = 0;
6633
- array[offset] = this.x;
6634
- array[offset + 1] = this.y;
6635
- array[offset + 2] = this.z;
6636
- array[offset + 3] = this.w;
7074
+ _proto.setTrigger = function setTrigger(name) {
7075
+ if (this.graph) {
7076
+ this.graph.setTrigger(name);
7077
+ }
6637
7078
  };
6638
- /**
6639
- * 生成随机向量
6640
- * @returns 向量
6641
- */ _proto.random = function random() {
6642
- this.x = Math.random();
6643
- this.y = Math.random();
6644
- this.z = Math.random();
6645
- this.w = Math.random();
6646
- return this;
7079
+ _proto.resetTrigger = function resetTrigger(name) {
7080
+ if (this.graph) {
7081
+ this.graph.resetTrigger(name);
7082
+ }
6647
7083
  };
6648
- /**
6649
- * 变换矩阵作用于向量
6650
- * @param m - 变换矩阵
6651
- * @param [out] - 输出结果,如果没有设置就直接覆盖当前值
6652
- * @returns 向量
6653
- */ _proto.applyMatrix = function applyMatrix(m, out) {
6654
- return m.transformVector4(this, out);
7084
+ _proto.onStart = function onStart() {
7085
+ if (this.graphAsset) {
7086
+ this.graph = new GraphInstance(this.graphAsset, this.item);
7087
+ }
6655
7088
  };
6656
- /**
6657
- * 通过标量数值创建向量
6658
- * @param num - 数值
6659
- * @returns 向量
6660
- */ Vector4.fromNumber = function fromNumber(num) {
6661
- return new Vector4().setFromNumber(num);
7089
+ _proto.onUpdate = function onUpdate(dt) {
7090
+ if (!this.graph) {
7091
+ return;
7092
+ }
7093
+ var result = this.graph.evaluateGraph(dt / 1000);
7094
+ // Apply transform animation
7095
+ //-------------------------------------------------------------------------
7096
+ var animatedTransforms = this.graph.skeleton.animatedTransforms;
7097
+ for(var i = 0; i < animatedTransforms.length; i++){
7098
+ var position = result.pose.parentSpaceTransforms[i].position;
7099
+ var rotation = result.pose.parentSpaceTransforms[i].rotation;
7100
+ var scale = result.pose.parentSpaceTransforms[i].scale;
7101
+ var euler = result.pose.parentSpaceTransforms[i].euler;
7102
+ animatedTransforms[i].setPosition(position.x, position.y, position.z);
7103
+ animatedTransforms[i].setScale(scale.x, scale.y, scale.z);
7104
+ if (this.graph.skeleton.useEuler) {
7105
+ animatedTransforms[i].setRotation(euler.x, euler.y, euler.z);
7106
+ } else {
7107
+ animatedTransforms[i].setQuaternion(rotation.x, rotation.y, rotation.z, rotation.w);
7108
+ }
7109
+ }
7110
+ // Apply property animation
7111
+ //-------------------------------------------------------------------------
7112
+ var floatAnimatedObjects = this.graph.skeleton.floatAnimatedObjects;
7113
+ for(var i1 = 0; i1 < floatAnimatedObjects.length; i1++){
7114
+ var animatedObject = floatAnimatedObjects[i1];
7115
+ var property = animatedObject.property;
7116
+ animatedObject.target[property] = result.pose.floatPropertyValues[i1];
7117
+ }
7118
+ var colorAnimatedObjects = this.graph.skeleton.colorAnimatedObjects;
7119
+ for(var i2 = 0; i2 < colorAnimatedObjects.length; i2++){
7120
+ var animatedObject1 = colorAnimatedObjects[i2];
7121
+ var property1 = animatedObject1.property;
7122
+ animatedObject1.target[property1] = result.pose.colorPropertyValues[i2];
7123
+ }
6662
7124
  };
6663
- /**
6664
- * 通过数组创建向量
6665
- * @param array - 数组
6666
- * @param [offset=0] - 起始偏移值
6667
- * @returns 向量
6668
- */ Vector4.fromArray = function fromArray(array, offset) {
6669
- if (offset === void 0) offset = 0;
6670
- return new Vector4().setFromArray(array, offset);
7125
+ _proto.fromData = function fromData(data) {
7126
+ this.graphAsset = this.engine.findObject(data.graphAsset);
6671
7127
  };
6672
- return Vector4;
6673
- }();
7128
+ return Animator;
7129
+ }(Component);
7130
+ exports.Animator = __decorate([
7131
+ effectsClass("Animator")
7132
+ ], exports.Animator);
7133
+
6674
7134
  /**
6675
- * 四维向量的常量
6676
- */ Vector4.ONE = new Vector4(1.0, 1.0, 1.0, 1.0);
6677
- Vector4.ZERO = new Vector4(0.0, 0.0, 0.0, 0.0);
7135
+ * 所有渲染组件的基类
7136
+ * @since 2.0.0
7137
+ */ var RendererComponent = /*#__PURE__*/ function(Component) {
7138
+ _inherits(RendererComponent, Component);
7139
+ function RendererComponent() {
7140
+ var _this;
7141
+ _this = Component.apply(this, arguments) || this;
7142
+ _this.materials = [];
7143
+ _this._priority = 0;
7144
+ return _this;
7145
+ }
7146
+ var _proto = RendererComponent.prototype;
7147
+ _proto.render = function render(renderer) {};
7148
+ _proto.onEnable = function onEnable() {
7149
+ var _this_item_composition;
7150
+ (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.renderFrame.addMeshToDefaultRenderPass(this);
7151
+ };
7152
+ _proto.onDisable = function onDisable() {
7153
+ var _this_item_composition;
7154
+ (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.renderFrame.removeMeshFromDefaultRenderPass(this);
7155
+ };
7156
+ _create_class(RendererComponent, [
7157
+ {
7158
+ key: "priority",
7159
+ get: function get() {
7160
+ return this._priority;
7161
+ },
7162
+ set: function set(value) {
7163
+ this._priority = value;
7164
+ }
7165
+ },
7166
+ {
7167
+ key: "material",
7168
+ get: function get() {
7169
+ return this.materials[0];
7170
+ },
7171
+ set: function set(material) {
7172
+ if (this.materials.length === 0) {
7173
+ this.materials.push(material);
7174
+ } else {
7175
+ this.materials[0] = material;
7176
+ }
7177
+ }
7178
+ }
7179
+ ]);
7180
+ return RendererComponent;
7181
+ }(Component);
7182
+ __decorate([
7183
+ serialize()
7184
+ ], RendererComponent.prototype, "materials", void 0);
7185
+ __decorate([
7186
+ serialize()
7187
+ ], RendererComponent.prototype, "_priority", void 0);
6678
7188
 
6679
7189
  /**
6680
7190
  * Mesh 组件
@@ -6803,516 +7313,6 @@ exports.PostProcessVolume = __decorate([
6803
7313
  effectsClass(DataType.PostProcessVolume)
6804
7314
  ], exports.PostProcessVolume);
6805
7315
 
6806
- var Color = /*#__PURE__*/ function() {
6807
- function Color(r, g, b, a) {
6808
- if (r === void 0) r = 0;
6809
- if (g === void 0) g = 0;
6810
- if (b === void 0) b = 0;
6811
- if (a === void 0) a = 0;
6812
- this.r = r;
6813
- this.g = g;
6814
- this.b = b;
6815
- this.a = a;
6816
- }
6817
- var _proto = Color.prototype;
6818
- /**
6819
- * 设置颜色
6820
- * @param r - r 分量
6821
- * @param g - g 分量
6822
- * @param b - b 分量
6823
- * @param a - a 分量
6824
- * @returns
6825
- */ _proto.set = function set(r, g, b, a) {
6826
- this.r = r;
6827
- this.g = g;
6828
- this.b = b;
6829
- this.a = a;
6830
- return this;
6831
- };
6832
- /**
6833
- * 设置零颜色
6834
- * @returns
6835
- */ _proto.setZero = function setZero() {
6836
- this.r = 0;
6837
- this.g = 0;
6838
- this.b = 0;
6839
- this.a = 0;
6840
- return this;
6841
- };
6842
- /**
6843
- * 通过标量数值设置颜色
6844
- * @param num - 数值
6845
- * @returns
6846
- */ _proto.setFromNumber = function setFromNumber(num) {
6847
- this.r = num;
6848
- this.g = num;
6849
- this.b = num;
6850
- this.a = num;
6851
- return this;
6852
- };
6853
- /**
6854
- * 通过Vector4创建颜色
6855
- * @param v - Vector4
6856
- * @returns
6857
- */ _proto.setFromVector4 = function setFromVector4(v) {
6858
- this.r = v.x;
6859
- this.g = v.y;
6860
- this.b = v.z;
6861
- this.a = v.w;
6862
- return this;
6863
- };
6864
- /**
6865
- * 通过数组创建颜色
6866
- * @param array - 数组
6867
- * @param [offset=0] - 起始偏移值
6868
- * @returns
6869
- */ _proto.setFromArray = function setFromArray(array, offset) {
6870
- if (offset === void 0) offset = 0;
6871
- var _array_offset;
6872
- this.r = (_array_offset = array[offset]) != null ? _array_offset : 0;
6873
- var _array_;
6874
- this.g = (_array_ = array[offset + 1]) != null ? _array_ : 0;
6875
- var _array_1;
6876
- this.b = (_array_1 = array[offset + 2]) != null ? _array_1 : 0;
6877
- var _array_2;
6878
- this.a = (_array_2 = array[offset + 3]) != null ? _array_2 : 0;
6879
- return this;
6880
- };
6881
- _proto.setFromHSV = function setFromHSV(hue, saturation, value, alpha) {
6882
- if (alpha === void 0) alpha = 1;
6883
- var chroma = value * saturation;
6884
- var h = hue / 60;
6885
- var x = chroma * (1 - Math.abs(h % 2 - 1));
6886
- var r = 0;
6887
- var g = 0;
6888
- var b = 0;
6889
- if (h >= 0 && h <= 1) {
6890
- r = chroma;
6891
- g = x;
6892
- } else if (h >= 1 && h <= 2) {
6893
- r = x;
6894
- g = chroma;
6895
- } else if (h >= 2 && h <= 3) {
6896
- g = chroma;
6897
- b = x;
6898
- } else if (h >= 3 && h <= 4) {
6899
- g = x;
6900
- b = chroma;
6901
- } else if (h >= 4 && h <= 5) {
6902
- r = x;
6903
- b = chroma;
6904
- } else if (h >= 5 && h <= 6) {
6905
- r = chroma;
6906
- b = x;
6907
- }
6908
- var m = value - chroma;
6909
- return this.set(r + m, g + m, b + m, alpha);
6910
- };
6911
- _proto.setFromHexString = function setFromHexString(hex) {
6912
- if (hex.substring(0, 1) !== "#" || hex.length !== 9 && hex.length !== 7) {
6913
- return this;
6914
- }
6915
- var r = parseInt(hex.substring(1, 3), 16) / 255.0;
6916
- var g = parseInt(hex.substring(3, 5), 16) / 255.0;
6917
- var b = parseInt(hex.substring(5, 7), 16) / 255.0;
6918
- var a = hex.length === 9 ? parseInt(hex.substring(7, 9), 16) / 255.0 : 1.0;
6919
- return this.set(r, g, b, a);
6920
- };
6921
- /**
6922
- * 拷贝颜色
6923
- * @param v - 复制对象
6924
- * @returns 拷贝结果
6925
- */ _proto.copyFrom = function copyFrom(v) {
6926
- this.r = v.r;
6927
- this.g = v.g;
6928
- this.b = v.b;
6929
- this.a = v.a;
6930
- return this;
6931
- };
6932
- /**
6933
- * 克隆颜色
6934
- * @returns 克隆结果
6935
- */ _proto.clone = function clone() {
6936
- return new Color(this.r, this.g, this.b, this.a);
6937
- };
6938
- /**
6939
- * 根据下标设置颜色分量
6940
- * @param index - 下标值
6941
- * @param value - 分量值
6942
- * @returns
6943
- */ _proto.setElement = function setElement(index, value) {
6944
- switch(index){
6945
- case 0:
6946
- this.r = value;
6947
- break;
6948
- case 1:
6949
- this.g = value;
6950
- break;
6951
- case 2:
6952
- this.b = value;
6953
- break;
6954
- case 3:
6955
- this.a = value;
6956
- break;
6957
- default:
6958
- console.error("index is out of range: " + index);
6959
- }
6960
- return this;
6961
- };
6962
- /**
6963
- * 根据下标获取颜色分量
6964
- * @param index - 下标
6965
- * @returns 分量值
6966
- */ _proto.getElement = function getElement(index) {
6967
- switch(index){
6968
- case 0:
6969
- return this.r;
6970
- case 1:
6971
- return this.g;
6972
- case 2:
6973
- return this.b;
6974
- case 3:
6975
- return this.a;
6976
- default:
6977
- console.error("index is out of range: " + index);
6978
- }
6979
- return 0;
6980
- };
6981
- /**
6982
- * 颜色相加
6983
- * @param right - 相加对象,颜色 | 数字
6984
- * @returns 相加结果
6985
- */ _proto.add = function add(right) {
6986
- if (typeof right === "number") {
6987
- this.r += right;
6988
- this.g += right;
6989
- this.b += right;
6990
- this.a += right;
6991
- } else if (_instanceof1(right, Array)) {
6992
- this.r += right[0];
6993
- this.g += right[1];
6994
- this.b += right[2];
6995
- this.a += right[3];
6996
- } else {
6997
- this.r += right.r;
6998
- this.g += right.g;
6999
- this.b += right.b;
7000
- this.a += right.a;
7001
- }
7002
- return this;
7003
- };
7004
- /**
7005
- * 颜色相减
7006
- * @param right - 相减对象,颜色 | 数字
7007
- * @returns 相减结果
7008
- */ _proto.subtract = function subtract(right) {
7009
- if (typeof right === "number") {
7010
- this.r -= right;
7011
- this.g -= right;
7012
- this.b -= right;
7013
- this.a -= right;
7014
- } else if (_instanceof1(right, Array)) {
7015
- this.r -= right[0];
7016
- this.g -= right[1];
7017
- this.b -= right[2];
7018
- this.a -= right[3];
7019
- } else {
7020
- this.r -= right.r;
7021
- this.g -= right.g;
7022
- this.b -= right.b;
7023
- this.a -= right.a;
7024
- }
7025
- return this;
7026
- };
7027
- /**
7028
- * 颜色相乘
7029
- * @param right - 相乘对象,对象 | 数字
7030
- * @returns 颜色
7031
- */ _proto.multiply = function multiply(right) {
7032
- if (typeof right === "number") {
7033
- this.r *= right;
7034
- this.g *= right;
7035
- this.b *= right;
7036
- this.a *= right;
7037
- } else if (_instanceof1(right, Array)) {
7038
- this.r *= right[0];
7039
- this.g *= right[1];
7040
- this.b *= right[2];
7041
- this.a *= right[3];
7042
- } else {
7043
- this.r *= right.r;
7044
- this.g *= right.g;
7045
- this.b *= right.b;
7046
- this.a *= right.a;
7047
- }
7048
- return this;
7049
- };
7050
- /**
7051
- * 颜色相除
7052
- * @param right - 相除对象,对象 | 数字
7053
- * @returns 颜色
7054
- */ _proto.divide = function divide(right) {
7055
- if (typeof right === "number") {
7056
- this.r /= right;
7057
- this.g /= right;
7058
- this.b /= right;
7059
- this.a /= right;
7060
- } else if (_instanceof1(right, Array)) {
7061
- this.r /= right[0];
7062
- this.g /= right[1];
7063
- this.b /= right[2];
7064
- this.a /= right[3];
7065
- } else {
7066
- this.r /= right.r;
7067
- this.g /= right.g;
7068
- this.b /= right.b;
7069
- this.a /= right.a;
7070
- }
7071
- return this;
7072
- };
7073
- /**
7074
- * 颜色缩放
7075
- * @param v - 数字
7076
- * @returns 缩放结果
7077
- */ _proto.scale = function scale(v) {
7078
- this.r *= v;
7079
- this.g *= v;
7080
- this.b *= v;
7081
- this.a *= v;
7082
- return this;
7083
- };
7084
- /**
7085
- * 颜色求最小值
7086
- * @param v - 颜色或数值
7087
- * @returns 最小值
7088
- */ _proto.min = function min(v) {
7089
- if (typeof v === "number") {
7090
- this.r = Math.min(this.r, v);
7091
- this.g = Math.min(this.g, v);
7092
- this.b = Math.min(this.b, v);
7093
- this.a = Math.min(this.a, v);
7094
- } else {
7095
- this.r = Math.min(this.r, v.r);
7096
- this.g = Math.min(this.g, v.g);
7097
- this.b = Math.min(this.b, v.b);
7098
- this.a = Math.min(this.a, v.a);
7099
- }
7100
- return this;
7101
- };
7102
- /**
7103
- * 颜色求最大值
7104
- * @param v - 颜色或数值
7105
- * @returns 最大值
7106
- */ _proto.max = function max(v) {
7107
- if (typeof v === "number") {
7108
- this.r = Math.max(this.r, v);
7109
- this.g = Math.max(this.g, v);
7110
- this.b = Math.max(this.b, v);
7111
- this.a = Math.max(this.a, v);
7112
- } else {
7113
- this.r = Math.max(this.r, v.r);
7114
- this.g = Math.max(this.g, v.g);
7115
- this.b = Math.max(this.b, v.b);
7116
- this.a = Math.max(this.a, v.a);
7117
- }
7118
- return this;
7119
- };
7120
- /**
7121
- * 颜色阈值约束
7122
- * @param min - 最小值
7123
- * @param max - 最大值
7124
- * @returns 颜色
7125
- */ _proto.clamp = function clamp(min, max) {
7126
- return this.max(min).min(max);
7127
- };
7128
- /**
7129
- * 颜色求线性插值
7130
- * @param v - 颜色
7131
- * @param alpha - 插值比例
7132
- * @returns 插值结果
7133
- */ _proto.lerp = function lerp(v, alpha) {
7134
- this.r += (v.r - this.r) * alpha;
7135
- this.g += (v.g - this.g) * alpha;
7136
- this.b += (v.b - this.b) * alpha;
7137
- this.a += (v.a - this.a) * alpha;
7138
- return this;
7139
- };
7140
- /**
7141
- * 计算颜色亮度值
7142
- * @returns 亮度值
7143
- */ _proto.luminance = function luminance() {
7144
- return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
7145
- };
7146
- /**
7147
- * 颜色判等
7148
- * @param v - 颜色
7149
- * @returns 判等结果
7150
- */ _proto.equals = function equals(v) {
7151
- return v.r === this.r && v.g === this.g && v.b === this.b && v.a === this.a;
7152
- };
7153
- _proto.toLinear = function toLinear() {
7154
- this.r = Color.gammaToLinear(this.r);
7155
- this.g = Color.gammaToLinear(this.g);
7156
- this.b = Color.gammaToLinear(this.b);
7157
- return this;
7158
- };
7159
- _proto.toGamma = function toGamma() {
7160
- this.r = Color.linearToGamma(this.r);
7161
- this.g = Color.linearToGamma(this.g);
7162
- this.b = Color.linearToGamma(this.b);
7163
- return this;
7164
- };
7165
- /**
7166
- * 颜色转数组
7167
- * @returns 数组
7168
- */ _proto.toArray = function toArray() {
7169
- return [
7170
- this.r,
7171
- this.g,
7172
- this.b,
7173
- this.a
7174
- ];
7175
- };
7176
- _proto.toVector4 = function toVector4() {
7177
- return new Vector4(this.r, this.g, this.b, this.a);
7178
- };
7179
- /**
7180
- * RGB 颜色空间转 HSV
7181
- * @param result HSV 值
7182
- */ _proto.toHSV = function toHSV() {
7183
- var _this = this, r = _this.r, g = _this.g, b = _this.b, a = _this.a;
7184
- var max = Math.max(r, g, b);
7185
- var min = Math.min(r, g, b);
7186
- var v = max;
7187
- var dm = max - min;
7188
- var h = 0;
7189
- var s = 0;
7190
- if (max !== 0) {
7191
- s = dm / max;
7192
- }
7193
- if (max != min) {
7194
- if (max == r) {
7195
- h = (g - b) / dm;
7196
- if (g < b) {
7197
- h += 6;
7198
- }
7199
- } else if (max == g) {
7200
- h = (b - r) / dm + 2;
7201
- } else if (max == b) {
7202
- h = (r - g) / dm + 4;
7203
- }
7204
- h *= 60;
7205
- }
7206
- return new Color(h, s, v, a);
7207
- };
7208
- _proto.toHexString = function toHexString(includeAlpha) {
7209
- if (includeAlpha === void 0) includeAlpha = true;
7210
- var R = Color.ToHex(Math.round(this.r * 255));
7211
- var G = Color.ToHex(Math.round(this.g * 255));
7212
- var B = Color.ToHex(Math.round(this.b * 255));
7213
- var A = Color.ToHex(Math.round(this.a * 255));
7214
- if (includeAlpha) {
7215
- return "#" + R + G + B + A;
7216
- } else {
7217
- return "#" + R + G + B;
7218
- }
7219
- };
7220
- _proto.fill = function fill(array, offset) {
7221
- if (offset === void 0) offset = 0;
7222
- array[offset] = this.r;
7223
- array[offset + 1] = this.g;
7224
- array[offset + 2] = this.b;
7225
- array[offset + 3] = this.a;
7226
- };
7227
- /**
7228
- * 通过标量数值创建颜色
7229
- * @param num - 数值
7230
- * @returns
7231
- */ Color.fromNumber = function fromNumber(num) {
7232
- return new Color().setFromNumber(num);
7233
- };
7234
- /**
7235
- * 通过数组创建颜色
7236
- * @param array - 数组
7237
- * @param [offset=0] - 起始偏移值
7238
- * @returns
7239
- */ Color.fromArray = function fromArray(array, offset) {
7240
- if (offset === void 0) offset = 0;
7241
- return new Color().setFromArray(array, offset);
7242
- };
7243
- /**
7244
- * 通过 hex 字符串创建颜色
7245
- * @param hex - hex 字符串
7246
- * @returns
7247
- */ Color.fromHexString = function fromHexString(hex) {
7248
- return new Color().setFromHexString(hex);
7249
- };
7250
- Color.fromHSV = function fromHSV(hue, saturation, value, alpha) {
7251
- if (alpha === void 0) alpha = 1;
7252
- return new Color().setFromHSV(hue, saturation, value, alpha);
7253
- };
7254
- /**
7255
- * 颜色值从 Gamma 空间转到线性空间
7256
- * @param v - Gamma 空间颜色值
7257
- * @returns 线性空间颜色值
7258
- */ Color.gammaToLinear = function gammaToLinear(v) {
7259
- if (v <= 0.0) {
7260
- return 0.0;
7261
- } else if (v <= 0.04045) {
7262
- return v / 12.92;
7263
- } else if (v < 1.0) {
7264
- return Math.pow((v + 0.055) / 1.055, 2.4);
7265
- } else {
7266
- return Math.pow(v, 2.4);
7267
- }
7268
- };
7269
- /**
7270
- * 颜色值从线性空间转到 Gamma 空间
7271
- * @param value - 线性空间颜色值
7272
- * @returns Gamma 空间颜色值
7273
- */ Color.linearToGamma = function linearToGamma(value) {
7274
- if (value <= 0.0) {
7275
- return 0.0;
7276
- } else if (value < 0.0031308) {
7277
- return 12.92 * value;
7278
- } else if (value < 1.0) {
7279
- return 1.055 * Math.pow(value, 0.41666) - 0.055;
7280
- } else {
7281
- return Math.pow(value, 0.41666);
7282
- }
7283
- };
7284
- Color.ToHex = function ToHex(i) {
7285
- var str = i.toString(16);
7286
- if (i <= 15) {
7287
- return ("0" + str).toUpperCase();
7288
- }
7289
- return str.toUpperCase();
7290
- };
7291
- return Color;
7292
- }();
7293
- /**
7294
- * 颜色的常量
7295
- */ Color.BLACK = new Color(0, 0, 0, 1) // 纯黑色
7296
- ;
7297
- Color.BLUE = new Color(0, 0, 1, 1) // 纯蓝色
7298
- ;
7299
- Color.CLEAR = new Color(0, 0, 0, 0) // 完全透明
7300
- ;
7301
- Color.CYAN = new Color(0, 1, 1, 1) // 青色
7302
- ;
7303
- Color.GRAY = new Color(0.5, 0.5, 0.5, 1) // 灰色
7304
- ;
7305
- Color.GREEN = new Color(0, 1, 0, 1) // 纯绿色
7306
- ;
7307
- Color.MAGENTA = new Color(1, 0, 1, 1) // 洋红色
7308
- ;
7309
- Color.RED = new Color(1, 0, 0, 1) // 纯红色
7310
- ;
7311
- Color.WHITE = new Color(1, 1, 1, 1) // 纯白色
7312
- ;
7313
- Color.YELLOW = new Color(1, 0.92, 0.016, 1) // 黄色
7314
- ;
7315
-
7316
7316
  /**
7317
7317
  * 四阶矩阵(列优先矩阵)
7318
7318
  */ var Matrix4 = /*#__PURE__*/ function() {
@@ -24323,7 +24323,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24323
24323
  return (_this_renderer = this.renderer) == null ? void 0 : _this_renderer.engine;
24324
24324
  };
24325
24325
  /**
24326
- * Item 求交测试,返回求交结果列表,x 和 y 是归一化到[-1, 1]区间的值,原点在左上角
24326
+ * Item 求交测试,返回求交结果列表,x 和 y 是归一化到[-1, 1]区间的值,x 向右,y 向上
24327
24327
  * @param x - 鼠标或触点的 x,已经归一化到[-1, 1]
24328
24328
  * @param y - 鼠标或触点的 y,已经归一化到[-1, 1]
24329
24329
  * @param force - 是否强制求交,没有交互信息的 Item 也要进行求交测试
@@ -31169,7 +31169,7 @@ function getStandardSpriteContent(sprite, transform) {
31169
31169
  return ret;
31170
31170
  }
31171
31171
 
31172
- var version$2 = "2.6.7";
31172
+ var version$2 = "2.6.8";
31173
31173
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
31174
31174
  var standardVersion = /^(\d+)\.(\d+)$/;
31175
31175
  var reverseParticle = false;
@@ -34423,7 +34423,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
34423
34423
  registerPlugin("particle", ParticleLoader, exports.VFXItem);
34424
34424
  registerPlugin("cal", CalculateLoader, exports.VFXItem);
34425
34425
  registerPlugin("interact", InteractLoader, exports.VFXItem);
34426
- var version$1 = "2.6.7";
34426
+ var version$1 = "2.6.8";
34427
34427
  logger.info("Core version: " + version$1 + ".");
34428
34428
 
34429
34429
  var _obj;
@@ -36028,7 +36028,7 @@ setMaxSpriteMeshItemCount(8);
36028
36028
  */ Mesh.create = function(engine, props) {
36029
36029
  return new ThreeMesh(engine, props);
36030
36030
  };
36031
- var version = "2.6.7";
36031
+ var version = "2.6.8";
36032
36032
  logger.info("THREEJS plugin version: " + version + ".");
36033
36033
 
36034
36034
  exports.AbstractPlugin = AbstractPlugin;