@galacean/effects-plugin-editor-gizmo 1.2.3 → 2.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects player editor gizmo plugin
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 茂安,旻诺
6
- * Version: v1.2.3
6
+ * Version: v2.0.0-alpha.1
7
7
  */
8
8
 
9
9
  'use strict';
@@ -342,341 +342,175 @@ function createGizmoShader(marcos, shader, shaderType, level) {
342
342
  return effects.createShaderWithMarcos(marcos, newShader, shaderType, level);
343
343
  }
344
344
 
345
- var Euler$1 = effects.math.Euler, Vector3$7 = effects.math.Vector3, Matrix4$5 = effects.math.Matrix4;
346
- var rectSize = 0.04;
347
- var DEG2RAD = Math.PI / 180;
348
- function arcPath(radius, arc, options) {
349
- if (options === void 0) { options = {}; }
350
- var plane = options.plane, _a = options.translate, translate = _a === void 0 ? [0, 0, 0] : _a, _b = options.rotate, rotate = _b === void 0 ? [0, 0, 0] : _b;
351
- var rotMat4 = Euler$1.fromArray(rotate).negate().toMatrix4(new Matrix4$5());
352
- var points = [];
353
- var indices = [];
354
- addPoint(radius, 0);
355
- var i = 1;
356
- for (; i <= arc; i++) {
357
- var angle = i * DEG2RAD;
358
- indices.push(i - 1, i);
359
- addPoint(Math.cos(angle) * radius, Math.sin(angle) * radius);
345
+ var Matrix4$5 = effects.math.Matrix4, Vector2$2 = effects.math.Vector2;
346
+ function distanceOfPointAndLine(point, line) {
347
+ //三角形三个边长
348
+ var AC = new Vector2$2();
349
+ var BC = new Vector2$2();
350
+ var AB = new Vector2$2();
351
+ AC.subtractVectors(point, line[0]);
352
+ BC.subtractVectors(point, line[1]);
353
+ AB.subtractVectors(line[1], line[0]);
354
+ var lengthAC = AC.length();
355
+ var lengthBC = BC.length();
356
+ var lengthAB = AB.length();
357
+ //利用海伦公式计算三角形面积
358
+ //周长的一半
359
+ var P = (lengthAC + lengthBC + lengthAB) / 2;
360
+ var allArea = Math.abs(Math.sqrt(P * (P - lengthAC) * (P - lengthBC) * (P - lengthAB)));
361
+ //普通公式计算三角形面积反推点到线的垂直距离
362
+ var distance = (2 * allArea) / lengthAB;
363
+ var l1 = Math.sqrt(Math.pow(lengthAC, 2) - Math.pow(distance, 2));
364
+ var l2 = Math.sqrt(Math.pow(lengthBC, 2) - Math.pow(distance, 2));
365
+ var isInLine = false;
366
+ if (l1 <= lengthAB && l2 <= lengthAB) {
367
+ isInLine = true;
360
368
  }
361
369
  return {
362
- points: points,
363
- indices: indices,
370
+ distance: distance,
371
+ isInLine: isInLine,
364
372
  };
365
- function addPoint(cos, sin) {
366
- var point = new Vector3$7();
367
- if (plane === 'xz') {
368
- point.set(cos, 0, sin);
369
- }
370
- else if (plane === 'yz') {
371
- point.set(0, cos, sin);
372
- }
373
- else {
374
- point.set(cos, sin, 0);
375
- }
376
- rotMat4.transformNormal(point);
377
- points.push(point.add(translate));
378
- }
379
373
  }
380
- function line(p0, p1) {
381
- return {
382
- points: [
383
- Vector3$7.fromArray(p0),
384
- Vector3$7.fromArray(p1),
385
- ],
386
- indices: [0, 1],
387
- };
374
+ function projectionOfPointAndLine(point, line) {
375
+ var AC = new Vector2$2();
376
+ var BC = new Vector2$2();
377
+ var AB = new Vector2$2();
378
+ var line0 = line[0].toVector2();
379
+ var line1 = line[1].toVector2();
380
+ AC.subtractVectors(point, line0);
381
+ BC.subtractVectors(point, line1);
382
+ AB.subtractVectors(line1, line0);
383
+ var lengthAC = AC.length();
384
+ var lengthBC = BC.length();
385
+ var lengthAB = AB.length();
386
+ //利用海伦公式计算三角形面积
387
+ //周长的一半
388
+ var P = (lengthAC + lengthBC + lengthAB) / 2;
389
+ var allArea = Math.abs(Math.sqrt(P * (P - lengthAC) * (P - lengthBC) * (P - lengthAB)));
390
+ //普通公式计算三角形面积反推点到线的垂直距离
391
+ var distance = (2 * allArea) / lengthAB;
392
+ var l1 = Math.sqrt(Math.pow(lengthAC, 2) - Math.pow(distance, 2));
393
+ var l2 = Math.sqrt(Math.pow(lengthBC, 2) - Math.pow(distance, 2));
394
+ var worldAB = line[1].clone().subtract(line[0]);
395
+ var worldAP = worldAB.clone().multiply(l1 / (l1 + l2));
396
+ var worldP = line[0].clone().add(worldAP);
397
+ return worldP;
388
398
  }
389
- function box(width, height, depth, center) {
390
- var w = width / 2;
391
- var h = height / 2;
392
- var d = depth / 2;
393
- var myCenter = center !== null && center !== void 0 ? center : [0, 0, 0];
394
- var points = [
395
- [-w, h, -d], [-w, -h, -d], [-w, h, d], [-w, -h, d],
396
- [w, h, -d], [w, -h, -d], [w, h, d], [w, -h, d],
397
- ].map(function (item) {
398
- return new Vector3$7(item[0] + myCenter[0], item[1] + myCenter[1], item[2] + myCenter[2]);
399
- });
400
- return {
401
- points: points,
402
- indices: [
403
- 0, 1, 1, 3, 3, 2, 2, 0,
404
- 4, 5, 5, 7, 7, 6, 6, 4,
405
- 0, 4, 2, 6, 3, 7, 1, 5,
406
- ],
407
- };
399
+ function computeOrthographicOffCenter(left, right, bottom, top, near, far) {
400
+ var a = 1.0 / (right - left);
401
+ var b = 1.0 / (top - bottom);
402
+ var c = 1.0 / (far - near);
403
+ var tx = -(right + left) * a;
404
+ var ty = -(top + bottom) * b;
405
+ var tz = -(far + near) * c;
406
+ a *= 2.0;
407
+ b *= 2.0;
408
+ c *= -2.0;
409
+ return new Matrix4$5(a, 0.0, 0.0, 0.0,
410
+ //
411
+ 0.0, b, 0.0, 0.0,
412
+ //
413
+ 0.0, 0.0, c, 0.0,
414
+ //
415
+ tx, ty, tz, 1.0);
408
416
  }
409
- function rect(width, height, pos) {
410
- var w = width / 2;
411
- var h = height / 2;
412
- var points = [
413
- new Vector3$7(-w, h, 0),
414
- new Vector3$7(w, h, 0),
415
- new Vector3$7(w, -h, 0),
416
- new Vector3$7(-w, -h, 0),
417
- ];
418
- if (pos) {
419
- points.forEach(function (vec) {
420
- vec.add(pos);
417
+
418
+ /**
419
+ * 下载图片
420
+ * @param imageUrl - 图片url
421
+ * @returns 图片对象
422
+ */
423
+ function createImage(imageUrl) {
424
+ return __awaiter(this, void 0, void 0, function () {
425
+ var image;
426
+ return __generator(this, function (_a) {
427
+ image = new Image();
428
+ image.src = imageUrl;
429
+ return [2 /*return*/, new Promise(function (resolve, reject) {
430
+ image.onload = function () {
431
+ resolve(image);
432
+ };
433
+ image.onerror = reject;
434
+ })];
421
435
  });
422
- }
423
- return {
424
- points: points,
425
- indices: [
426
- 0, 1, 1, 2, 2, 3, 3, 0,
427
- ],
428
- };
436
+ });
429
437
  }
430
- function combineGeometries(geometries) {
431
- var points = [];
432
- var indices = [];
433
- var _loop_1 = function (i, indicesBase) {
434
- var geometry = geometries[i];
435
- if (geometry) {
436
- geometry.points.forEach(function (point) {
437
- points.push(point.x, point.y, point.z);
438
- });
439
- geometry.indices.forEach(function (index) { return indices.push(index + indicesBase); });
440
- indicesBase += geometry.points.length;
441
- }
442
- out_indicesBase_1 = indicesBase;
443
- };
444
- var out_indicesBase_1;
445
- for (var i = 0, indicesBase = 0; i < geometries.length; i++) {
446
- _loop_1(i, indicesBase);
447
- indicesBase = out_indicesBase_1;
438
+ /**
439
+ * 创建 Texture 对象
440
+ * @param engine - engine 对象
441
+ * @param image - 图片对象
442
+ * @returns 纹理
443
+ */
444
+ function createTexture(engine, image, hookDestroy) {
445
+ var texture = effects.Texture.create(engine, { image: image });
446
+ if (hookDestroy) {
447
+ texture.dispose = effects.noop;
448
448
  }
449
- return {
450
- points: new Float32Array(points),
451
- indices: new Uint16Array(indices),
452
- };
449
+ return texture;
453
450
  }
454
- var Shapes = {
455
- Texture: function (arg) {
456
- var ret = [];
457
- if (arg.detail) {
458
- var anchors = arg.detail.anchors;
459
- var block = arg.detail.block;
460
- var width = arg.width;
461
- var height = arg.height;
462
- for (var i = 0; i < anchors.length; i += 2) {
463
- ret.push(rect(block[0] * width, block[1] * height, [
464
- width * (anchors[i] - 0.5),
465
- height * (anchors[i + 1] - 0.5),
466
- 0,
467
- ]));
468
- }
451
+ /**
452
+ * 移动到距离目标点指定距离的位置
453
+ * @param targetPos - 目标点
454
+ * @param currentPos - 当前点
455
+ * @returns 指定点
456
+ */
457
+ function moveToPointWidthFixDistance(targetPos, currentPos) {
458
+ var vecCameraItem = currentPos.clone().subtract(targetPos);
459
+ var normalVecCameraItem = vecCameraItem.clone().normalize();
460
+ var scalerVecCameraItem = normalVecCameraItem.clone().multiply(20);
461
+ var vecScalerItem = vecCameraItem.clone().subtract(scalerVecCameraItem);
462
+ var vecItemScaler = vecScalerItem.clone().multiply(-1);
463
+ return currentPos.clone().add(vecItemScaler);
464
+ }
465
+
466
+ /**
467
+ * 基础几何数据[抽象类,不可以直接用来初始化]
468
+ */
469
+ var GeometryData = /** @class */ (function () {
470
+ function GeometryData() {
471
+ this.points = [];
472
+ this.uvs = [];
473
+ this.normals = [];
474
+ this.indices = [];
475
+ }
476
+ /**
477
+ * 构件 XY 平面圆(圆心为(0, 0, z))
478
+ * @param radius - 圆半径
479
+ * @param z - z 值
480
+ * @param segments - 圆精度
481
+ * @param thetaStart - 起始弧度
482
+ * @param thetaLength - 终止弧度
483
+ * @param startIndex - 索引起始值
484
+ * @param points - 点数据
485
+ * @param indices - 索引数据
486
+ */
487
+ GeometryData.prototype.createXYPlaneCircle = function (radius, z, segments, thetaStart, thetaLength, startIndex, points, indices) {
488
+ for (var i = 0; i < segments; i++) {
489
+ var theta = thetaStart + i * thetaLength / segments;
490
+ var x = radius * Math.cos(theta);
491
+ var y = radius * Math.sin(theta);
492
+ points.push(x, y, z);
493
+ indices.push(startIndex + i, startIndex + (i + 1) % segments);
469
494
  }
470
- else {
471
- ret.unshift(Shapes.Rectangle(arg)[0]);
472
- }
473
- return ret;
474
- },
475
- Circle: function (arg) {
476
- var radius = arg.radius, arc = arg.arc;
477
- return [
478
- arcPath(radius, arc),
479
- arc !== 360 && line([0, 0, 0], [radius, 0, 0]),
480
- arc !== 360 && line([0, 0, 0], [Math.cos(arc * DEG2RAD) * radius, Math.sin(arc * DEG2RAD) * radius, 0]),
481
- ];
482
- },
483
- Box: function (arg) {
484
- var width = arg.width, height = arg.height, depth = arg.depth, center = arg.center;
485
- var data = box(width, height, depth, center);
486
- return [data];
487
- },
488
- Sphere: function (arg) {
489
- var radius = arg.radius, arc = arg.arc;
490
- var ret = [
491
- line([0, 0, -radius], [0, 0, radius]),
492
- arcPath(radius, arc > 180 ? 360 : 180, { plane: 'xz', rotate: [0, 90, 0] }),
493
- arcPath(radius, arc, { plane: 'xy' }),
494
- arcPath(radius, 180, { plane: 'xz', rotate: [0, 90, arc] }),
495
- ];
496
- if (arc > 90) {
497
- ret.push(arcPath(radius, arc > 270 ? 360 : 180, { plane: 'yz', rotate: [-90, 0, 0] }));
498
- }
499
- return ret;
500
- },
501
- Hemisphere: function (arg) {
502
- var radius = arg.radius, arc = arg.arc;
503
- var ret = [
504
- line([0, 0, radius], [0, 0, 0]),
505
- line([arc > 180 ? -radius : 0, 0, 0], [radius, 0, 0]),
506
- arg > 90 && line([0, arc > 270 ? -radius : 0, 0], [0, radius, 0]),
507
- arcPath(radius, (arc > 180 ? 360 : 180) / 2, { plane: 'xz' }),
508
- arcPath(radius, arc, { plane: 'xy' }),
509
- arcPath(radius, 90, { plane: 'xz', rotate: [0, 0, arc] }),
510
- line([0, 0, 0], [Math.cos(arc * DEG2RAD) * radius, Math.sin(arc * DEG2RAD) * radius, 0]),
511
- ];
512
- if (arc > 90) {
513
- ret.push(arcPath(radius, arc > 270 ? 180 : 90, { plane: 'yz' }));
514
- }
515
- return ret;
516
- },
517
- Cone: function (arg) {
518
- var radius = arg.radius, arc = arg.arc;
519
- var outerRadius = radius * Math.tan(arg.angle * DEG2RAD) + radius;
520
- return [
521
- arcPath(outerRadius, arc, { translate: [0, 0, radius] }),
522
- line([radius, 0, 0], [outerRadius, 0, radius]),
523
- arc > 90 && line([0, radius, 0], [0, outerRadius, radius]),
524
- arc > 180 && line([-radius, 0, 0], [-outerRadius, 0, radius]),
525
- arc > 270 && line([0, -radius, 0], [0, -outerRadius, radius]),
526
- line([Math.cos(arc * DEG2RAD) * radius, Math.sin(arc * DEG2RAD) * radius, 0], [Math.cos(arc * DEG2RAD) * outerRadius, Math.sin(arc * DEG2RAD) * outerRadius, radius]),
527
- ].concat(Shapes.Circle(arg));
528
- },
529
- Edge: function (arg) {
530
- var hw = arg.width / 2;
531
- return [
532
- line([-hw, 0, 0], [hw, 0, 0]),
533
- ];
534
- },
535
- Rectangle: function (arg) {
536
- return [
537
- rect(arg.width, arg.height),
538
- ];
539
- },
540
- RectangleEdge: function (arg) {
541
- return [
542
- rect(arg.width, arg.height),
543
- ];
544
- },
545
- Donut: function (arg) {
546
- var arc = arg.arc, radius = arg.radius, donutRadius = arg.donutRadius;
547
- return [
548
- arcPath(donutRadius, 360, { translate: [radius, 0, 0], rotate: [90, 0, 0] }),
549
- arcPath(radius - donutRadius, arc),
550
- arcPath(radius + donutRadius, arc),
551
- arcPath(radius, arc, { translate: [0, 0, donutRadius] }),
552
- arcPath(radius, arc, { translate: [0, 0, -donutRadius] }),
553
- arc % 360 === 0 ? arcPath(donutRadius, 360, {
554
- translate: [-radius, 0, 0],
555
- rotate: [90, 0, 0],
556
- }) : arcPath(donutRadius, 360, {
557
- translate: [Math.cos(arc * DEG2RAD) * radius, Math.sin(arc * DEG2RAD) * radius, 0],
558
- rotate: [90, 0, arc],
559
- }),
560
- ];
561
- },
562
- path: function (arg) {
563
- var positions = arg.keys;
564
- var ret = [];
565
- for (var i = 0; i < positions.length - 1; i++) {
566
- ret.push(rect(rectSize, rectSize, positions[i]));
567
- ret.push(line(positions[i], positions[i + 1]));
568
- }
569
- ret.push(rect(rectSize, rectSize, positions[positions.length - 1]));
570
- return ret;
571
- },
572
- };
573
- Shapes['0'] = Shapes.None;
574
- Shapes['1'] = Shapes.Sphere;
575
- Shapes['2'] = Shapes.Cone;
576
- Shapes['3'] = Shapes.Hemisphere;
577
- Shapes['4'] = Shapes.Circle;
578
- Shapes['5'] = Shapes.Donut;
579
- Shapes['6'] = Shapes.Rectangle;
580
- Shapes['7'] = Shapes.RectangleEdge;
581
- Shapes['8'] = Shapes.Edge;
582
- Shapes['9'] = Shapes.Texture;
583
- function createMeshFromShape(engine, args, options) {
584
- var ret = Shapes[args.type || args.shape](args);
585
- var geo = combineGeometries(ret);
586
- return createMesh(engine, geo.points, geo.indices, options.color || [1, 0, 0], options.depthTest, args.shape);
587
- }
588
- function createMesh(engine, points, indices, color, depthTest, name) {
589
- if (depthTest === void 0) { depthTest = false; }
590
- var material = effects.Material.create(engine, {
591
- uniformValues: {
592
- u_color: new Float32Array(color),
593
- u_model: new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]),
594
- },
595
- uniformSemantics: {
596
- u_vp: 'VIEWPROJECTION',
597
- u_et: 'EDITOR_TRANSFORM',
598
- },
599
- shader: {
600
- shared: true,
601
- fragment: "\n precision mediump float;\n\n uniform vec3 u_color;\n\n void main(){\n gl_FragColor = vec4(u_color,1.0);\n }",
602
- vertex: "precision highp float;\n\n attribute vec3 a_Position;\n\n uniform mat4 u_model;\n uniform mat4 effects_MatrixVP;\n uniform vec4 uEditorTransform;\n void main(){\n gl_Position = effects_MatrixVP * u_model * vec4(a_Position,1.0);\n gl_Position = vec4(gl_Position.xy * uEditorTransform.xy + uEditorTransform.zw * gl_Position.w,gl_Position.zw);\n }",
603
- },
604
- });
605
- material.setVector3('u_color', Vector3$7.fromArray(color));
606
- material.setMatrix('u_model', Matrix4$5.IDENTITY);
607
- material.depthTest = depthTest;
608
- material.stencilTest = false;
609
- material.blending = false;
610
- material.depthMask = true;
611
- var geometry = effects.Geometry.create(engine, {
612
- attributes: {
613
- a_Position: {
614
- size: 3,
615
- data: points,
616
- },
617
- },
618
- indices: {
619
- data: indices,
620
- },
621
- mode: effects.glContext.LINES,
622
- drawCount: indices.length,
623
- });
624
- return effects.Mesh.create(engine, {
625
- name: name,
626
- geometry: geometry,
627
- material: material,
628
- priority: 3000,
629
- });
630
- }
631
-
632
- /**
633
- * 基础几何数据[抽象类,不可以直接用来初始化]
634
- */
635
- var GeometryData = /** @class */ (function () {
636
- function GeometryData() {
637
- this.points = [];
638
- this.uvs = [];
639
- this.normals = [];
640
- this.indices = [];
641
- }
642
- /**
643
- * 构件 XY 平面圆(圆心为(0, 0, z))
644
- * @param radius - 圆半径
645
- * @param z - z 值
646
- * @param segments - 圆精度
647
- * @param thetaStart - 起始弧度
648
- * @param thetaLength - 终止弧度
649
- * @param startIndex - 索引起始值
650
- * @param points - 点数据
651
- * @param indices - 索引数据
652
- */
653
- GeometryData.prototype.createXYPlaneCircle = function (radius, z, segments, thetaStart, thetaLength, startIndex, points, indices) {
654
- for (var i = 0; i < segments; i++) {
655
- var theta = thetaStart + i * thetaLength / segments;
656
- var x = radius * Math.cos(theta);
657
- var y = radius * Math.sin(theta);
658
- points.push(x, y, z);
659
- indices.push(startIndex + i, startIndex + (i + 1) % segments);
660
- }
661
- };
662
- /**
663
- * 构件 XZ 平面圆(圆心为(0, y, 0))
664
- * @param radius - 圆半径
665
- * @param y - y 值
666
- * @param segments - 圆精度
667
- * @param thetaStart - 起始弧度
668
- * @param thetaLength - 终止弧度
669
- * @param startIndex - 索引起始值
670
- * @param points - 点数据
671
- * @param indices - 索引数据
672
- */
673
- GeometryData.prototype.createXZPlaneCircle = function (radius, y, segments, thetaStart, thetaLength, startIndex, points, indices) {
674
- for (var i = 0; i < segments; i++) {
675
- var theta = thetaStart + i * thetaLength / segments;
676
- var x = radius * Math.cos(theta);
677
- var z = radius * Math.sin(theta);
678
- points.push(x, y, z);
679
- indices.push(startIndex + i, startIndex + (i + 1) % segments);
495
+ };
496
+ /**
497
+ * 构件 XZ 平面圆(圆心为(0, y, 0))
498
+ * @param radius - 圆半径
499
+ * @param y - y 值
500
+ * @param segments - 圆精度
501
+ * @param thetaStart - 起始弧度
502
+ * @param thetaLength - 终止弧度
503
+ * @param startIndex - 索引起始值
504
+ * @param points - 点数据
505
+ * @param indices - 索引数据
506
+ */
507
+ GeometryData.prototype.createXZPlaneCircle = function (radius, y, segments, thetaStart, thetaLength, startIndex, points, indices) {
508
+ for (var i = 0; i < segments; i++) {
509
+ var theta = thetaStart + i * thetaLength / segments;
510
+ var x = radius * Math.cos(theta);
511
+ var z = radius * Math.sin(theta);
512
+ points.push(x, y, z);
513
+ indices.push(startIndex + i, startIndex + (i + 1) % segments);
680
514
  }
681
515
  };
682
516
  /**
@@ -702,7 +536,7 @@ var GeometryData = /** @class */ (function () {
702
536
  return GeometryData;
703
537
  }());
704
538
 
705
- var Vector3$6 = effects.math.Vector3;
539
+ var Vector3$8 = effects.math.Vector3;
706
540
  /**
707
541
  *
708
542
  */
@@ -752,7 +586,7 @@ var SphereGeometryData = /** @class */ (function (_super) {
752
586
  var z = radius * Math.sin(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength);
753
587
  _this.points.push(x, y, z);
754
588
  // normal
755
- var normal = new Vector3$6(x, y, z).normalize();
589
+ var normal = new Vector3$8(x, y, z).normalize();
756
590
  (_a = _this.normals).push.apply(_a, __spreadArray([], __read(normal.toArray()), false));
757
591
  // uv
758
592
  _this.uvs.push(u + uOffset, 1 - v);
@@ -841,7 +675,7 @@ var BoxGeometryData = /** @class */ (function (_super) {
841
675
  return BoxGeometryData;
842
676
  }(GeometryData));
843
677
 
844
- var Vector3$5 = effects.math.Vector3;
678
+ var Vector3$7 = effects.math.Vector3;
845
679
  /**
846
680
  *
847
681
  */
@@ -898,7 +732,7 @@ var CylinderGeometryData = /** @class */ (function (_super) {
898
732
  var py = -v * height + halfHeight;
899
733
  var pz = radius * cosTheta;
900
734
  points.push(px, py, pz);
901
- var normal = new Vector3$5(sinTheta, slope, cosTheta).normalize();
735
+ var normal = new Vector3$7(sinTheta, slope, cosTheta).normalize();
902
736
  normals.push.apply(normals, __spreadArray([], __read(normal.toArray()), false));
903
737
  uvs.push(u, 1 - v);
904
738
  indexRow.push(index++);
@@ -986,7 +820,7 @@ var ConeGeometryData = /** @class */ (function (_super) {
986
820
  return ConeGeometryData;
987
821
  }(CylinderGeometryData));
988
822
 
989
- var Vector3$4 = effects.math.Vector3;
823
+ var Vector3$6 = effects.math.Vector3;
990
824
  /**
991
825
  *
992
826
  */
@@ -1020,8 +854,8 @@ var TorusGeometryData = /** @class */ (function (_super) {
1020
854
  _this.points.push(px, py, pz);
1021
855
  var cx = radius * Math.cos(u);
1022
856
  var cy = radius * Math.sin(u);
1023
- var p = new Vector3$4(px, py, pz);
1024
- var c = new Vector3$4(cx, cy, 0);
857
+ var p = new Vector3$6(px, py, pz);
858
+ var c = new Vector3$6(cx, cy, 0);
1025
859
  var normal = p.subtract(c).normalize();
1026
860
  (_a = _this.normals).push.apply(_a, __spreadArray([], __read(normal.toArray()), false));
1027
861
  _this.uvs.push(i / tubularSegments);
@@ -1094,7 +928,7 @@ var PlaneGeometryData = /** @class */ (function (_super) {
1094
928
  return PlaneGeometryData;
1095
929
  }(GeometryData));
1096
930
 
1097
- var Euler = effects.math.Euler, Vector3$3 = effects.math.Vector3, Matrix4$4 = effects.math.Matrix4;
931
+ var Euler$1 = effects.math.Euler, Vector3$5 = effects.math.Vector3, Matrix4$4 = effects.math.Matrix4;
1098
932
  /**
1099
933
  *
1100
934
  */
@@ -1116,11 +950,11 @@ var FrustumGeometryData = /** @class */ (function (_super) {
1116
950
  var ratio = aspect;
1117
951
  var halfY = far * Math.tan(fovY / 2);
1118
952
  var halfX = halfY * ratio;
1119
- var point1 = new Vector3$3(halfX, halfY, far);
1120
- var point2 = new Vector3$3(-halfX, halfY, far);
1121
- var point3 = new Vector3$3(-halfX, -halfY, far);
1122
- var point4 = new Vector3$3(halfX, -halfY, far);
1123
- var matrix = Euler.fromArray(rotation).toMatrix4(new Matrix4$4());
953
+ var point1 = new Vector3$5(halfX, halfY, far);
954
+ var point2 = new Vector3$5(-halfX, halfY, far);
955
+ var point3 = new Vector3$5(-halfX, -halfY, far);
956
+ var point4 = new Vector3$5(halfX, -halfY, far);
957
+ var matrix = Euler$1.fromArray(rotation).toMatrix4(new Matrix4$4());
1124
958
  var result1 = matrix.transformPoint(point1).add(position);
1125
959
  var result2 = matrix.transformPoint(point2).add(position);
1126
960
  var result3 = matrix.transformPoint(point3).add(position);
@@ -1395,7 +1229,7 @@ axisIconMap.set('negX', "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABmC
1395
1229
  axisIconMap.set('negY', "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGYAAABmCAYAAAFO2NT0AAABYWlDQ1BrQ0dDb2xvcl\n NwYWNlRGlzcGxheVAzAAAokWNgYFJJLCjIYWFgYMjNKykKcndSiIiMUmB/yMAOhLwMYgwKicnFBY4BAT5AJQwwGhV8u8bACKI\n v64LMOiU1tUm1XsDXYqbw1YuvRJsw1aMArpTU4mQg/QeIU5MLikoYGBhTgGzl8pICELsDyBYpAjoKyJ4DYqdD2BtA7CQI+whY\n TUiQM5B9A8hWSM5IBJrB+API1klCEk9HYkPtBQFul8zigpzESoUAYwKuJQOUpFaUgGjn/ILKosz0jBIFR2AopSp45iXr6SgYG\n RiaMzCAwhyi+nMgOCwZxc4gxJrvMzDY7v////9uhJjXfgaGjUCdXDsRYhoWDAyC3AwMJ3YWJBYlgoWYgZgpLY2B4dNyBgbeSA\n YG4QtAPdHFacZGYHlGHicGBtZ7//9/VmNgYJ/MwPB3wv//vxf9//93MVDzHQaGA3kAFSFl7jXH0fsAAAA4ZVhJZk1NACoAAAA\n IAAGHaQAEAAAAAQAAABoAAAAAAAKgAgAEAAAAAQAAAGagAwAEAAAAAQAAAGYAAAAAoo8/3AAAFixJREFUeAHtXQ2YVcV5nplz\n 7y7Ln7J7NyFYq7U8u/yJQWuraVoVGvwrWlGpUh8jIIXdjfiIWK1p2lWTaqomsYZliUESIcHwE42lRiUK0iiJKbUqyC6o+CgNk\n L27gBBgd++Z6TuHncM5c+ace+7du7sX3PM8u3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HVxM/eCcm/mlq0QXWCyJep9aegfsImW6v0end50adxBy3sVStoCg7znJ2oaTdNU/KLfmRD+eRDAyWnGA\n 7O8pp9+JrFzbvOX+C04Qa/gq1ghJu3VHbnTXMm+h9r+YRNeLT+m1f8HYf5GcPkbuHswruaxGMtDGDmigUqRxSI1A71moMzDpB\n IfhPtBzIR+r1plKMqH81/jWepLVvRlk1mVFCUOD1RVISaJntb8FRAQWciX3/zNDOvHvxsVADdsMw9MRJEmTCFmYXs6Bk/FgvF\n 21NSzTPhU8aNlPodfP76hq6/l5Yku86QoxGZidXtuLl5+6MSA0YGOpsHG1zbMxzBV7YN9VO+K/uxLk12WmigkjMnVbcMnYZbz\n adzVw1tZjH45sArPdIRRKsAwgRjG0m4bLAW3Ypb36IqBpp9Fx548TN0oJI7l9YtV47tv5Y+So+oYGCUf6rpuBucOzVJKDOAYy\n PGhS8zjseg8zmmGHMfJw4j8XdHIdx16RObNav7+a1xZK8H/PxR1Mkje1IZfAAAAAElFTkSuQmCC");
1397
1231
 
1398
- var Vector2$2 = effects.math.Vector2, Vector3$2 = effects.math.Vector3, Matrix4$3 = effects.math.Matrix4;
1232
+ var Vector2$1 = effects.math.Vector2, Vector3$4 = effects.math.Vector3, Matrix4$3 = effects.math.Matrix4;
1399
1233
  /**
1400
1234
  * 根据 gizmoSubType 类型创建几何体 Mesh
1401
1235
  * @param subType - gizmoSubType 类型
@@ -1548,9 +1382,9 @@ function getTriangle(geometry, transform) {
1548
1382
  var i0 = indices[i] * 3;
1549
1383
  var i1 = indices[i + 1] * 3;
1550
1384
  var i2 = indices[i + 2] * 3;
1551
- var p0 = new Vector3$2(points[i0], points[i0 + 1], points[i0 + 2]);
1552
- var p1 = new Vector3$2(points[i1], points[i1 + 1], points[i1 + 2]);
1553
- var p2 = new Vector3$2(points[i2], points[i2 + 1], points[i2 + 2]);
1385
+ var p0 = new Vector3$4(points[i0], points[i0 + 1], points[i0 + 2]);
1386
+ var p1 = new Vector3$4(points[i1], points[i1 + 1], points[i1 + 2]);
1387
+ var p2 = new Vector3$4(points[i2], points[i2 + 1], points[i2 + 2]);
1554
1388
  result.push({
1555
1389
  p0: mat4.projectPoint(p0),
1556
1390
  p1: mat4.projectPoint(p1),
@@ -1781,7 +1615,7 @@ function createScaleMesh(engine, options, boundingMap) {
1781
1615
  createAxisBounding({ width: boxSize.width * 1.2, length: axisSize.width + boxSize.width / 2 }, boundingMap);
1782
1616
  boundingMap.set('center', {
1783
1617
  type: BoundingType.sphere,
1784
- center: new Vector3$2(),
1618
+ center: new Vector3$4(),
1785
1619
  radius: Math.pow(Math.pow(centerBoxSize.width, 2) + Math.pow(centerBoxSize.height, 2) + Math.pow(centerBoxSize.depth, 2), 0.5) / 2,
1786
1620
  });
1787
1621
  return result;
@@ -2047,7 +1881,7 @@ function createSpriteMesh(engine, options, texture, boundingMap) {
2047
1881
  * @returns 纯色材质,无光照,无透明
2048
1882
  */
2049
1883
  function createMaterial(engine, color, depthTest) {
2050
- var myColor = color ? Vector3$2.fromArray(color) : new Vector3$2(255, 255, 255);
1884
+ var myColor = color ? Vector3$4.fromArray(color) : new Vector3$4(255, 255, 255);
2051
1885
  var myDepthTest = depthTest ? depthTest : false;
2052
1886
  var material = effects.Material.create(engine, {
2053
1887
  uniformValues: {
@@ -2082,7 +1916,7 @@ function createMaterial(engine, color, depthTest) {
2082
1916
  * @returns
2083
1917
  */
2084
1918
  function createHideBackMaterial(engine, color, depthTest) {
2085
- var myColor = color ? Vector3$2.fromArray(color) : new Vector3$2(255, 255, 255);
1919
+ var myColor = color ? Vector3$4.fromArray(color) : new Vector3$4(255, 255, 255);
2086
1920
  var myDepthTest = depthTest ? depthTest : false;
2087
1921
  var material = effects.Material.create(engine, {
2088
1922
  uniformValues: {
@@ -2105,8 +1939,8 @@ function createHideBackMaterial(engine, color, depthTest) {
2105
1939
  });
2106
1940
  material.setVector3('u_color', myColor);
2107
1941
  material.setMatrix('u_model', Matrix4$3.IDENTITY);
2108
- material.setVector3('u_cameraPos', Vector3$2.ZERO);
2109
- material.setVector3('u_center', Vector3$2.ZERO);
1942
+ material.setVector3('u_cameraPos', Vector3$4.ZERO);
1943
+ material.setVector3('u_center', Vector3$4.ZERO);
2110
1944
  material.depthTest = myDepthTest;
2111
1945
  material.stencilTest = false;
2112
1946
  material.blending = false;
@@ -2122,7 +1956,7 @@ function createHideBackMaterial(engine, color, depthTest) {
2122
1956
  * @returns
2123
1957
  */
2124
1958
  function createBlendMaterial(engine, color, depthTest, alpha) {
2125
- var myColor = color ? Vector3$2.fromArray(color) : new Vector3$2(255, 255, 255);
1959
+ var myColor = color ? Vector3$4.fromArray(color) : new Vector3$4(255, 255, 255);
2126
1960
  var myDepthTest = depthTest ? depthTest : false;
2127
1961
  var myAlpha = alpha ? alpha : 1;
2128
1962
  var material = effects.Material.create(engine, {
@@ -2144,7 +1978,7 @@ function createBlendMaterial(engine, color, depthTest, alpha) {
2144
1978
  },
2145
1979
  });
2146
1980
  material.setVector3('u_color', myColor);
2147
- material.setVector2('u_alpha', new Vector2$2(myAlpha, 0));
1981
+ material.setVector2('u_alpha', new Vector2$1(myAlpha, 0));
2148
1982
  material.setMatrix('u_model', Matrix4$3.IDENTITY);
2149
1983
  material.depthTest = myDepthTest;
2150
1984
  material.stencilTest = false;
@@ -2175,7 +2009,7 @@ function createSpriteMaterial(engine, data, depthTest) {
2175
2009
  },
2176
2010
  });
2177
2011
  material.setMatrix('u_model', Matrix4$3.IDENTITY);
2178
- material.setVector2('u_alpha', new Vector2$2(1, 0));
2012
+ material.setVector2('u_alpha', new Vector2$1(1, 0));
2179
2013
  if (data instanceof effects.Texture) {
2180
2014
  material.setTexture('u_iconTex', data);
2181
2015
  // uniformValues.u_iconTex = data;
@@ -2183,10 +2017,10 @@ function createSpriteMaterial(engine, data, depthTest) {
2183
2017
  else {
2184
2018
  var color_1;
2185
2019
  if (data === undefined) {
2186
- color_1 = new Vector3$2(255, 255, 255);
2020
+ color_1 = new Vector3$4(255, 255, 255);
2187
2021
  }
2188
2022
  else {
2189
- color_1 = Vector3$2.fromArray(data);
2023
+ color_1 = Vector3$4.fromArray(data);
2190
2024
  }
2191
2025
  material.setVector3('u_color', color_1);
2192
2026
  // uniformValues.u_color = new Float32Array(color);
@@ -2207,238 +2041,578 @@ function createSpriteMaterial(engine, data, depthTest) {
2207
2041
  function createAxisBounding(size, boundingMap) {
2208
2042
  boundingMap.set('xAxis', {
2209
2043
  type: BoundingType.line,
2210
- points: [new Vector3$2(0, 0, 0), new Vector3$2(size.length, 0, 0)],
2044
+ points: [new Vector3$4(0, 0, 0), new Vector3$4(size.length, 0, 0)],
2211
2045
  width: size.width,
2212
2046
  });
2213
2047
  boundingMap.set('yAxis', {
2214
2048
  type: BoundingType.line,
2215
- points: [new Vector3$2(0, 0, 0), new Vector3$2(0, size.length, 0)],
2049
+ points: [new Vector3$4(0, 0, 0), new Vector3$4(0, size.length, 0)],
2216
2050
  width: size.width,
2217
2051
  });
2218
2052
  boundingMap.set('zAxis', {
2219
2053
  type: BoundingType.line,
2220
- points: [new Vector3$2(0, 0, 0), new Vector3$2(0, 0, size.length)],
2054
+ points: [new Vector3$4(0, 0, 0), new Vector3$4(0, 0, size.length)],
2221
2055
  width: size.width,
2222
2056
  });
2223
2057
  }
2224
2058
 
2225
- var Matrix4$2 = effects.math.Matrix4, Vector2$1 = effects.math.Vector2;
2226
- function distanceOfPointAndLine(point, line) {
2227
- //三角形三个边长
2228
- var AC = new Vector2$1();
2229
- var BC = new Vector2$1();
2230
- var AB = new Vector2$1();
2231
- AC.subtractVectors(point, line[0]);
2232
- BC.subtractVectors(point, line[1]);
2233
- AB.subtractVectors(line[1], line[0]);
2234
- var lengthAC = AC.length();
2235
- var lengthBC = BC.length();
2236
- var lengthAB = AB.length();
2237
- //利用海伦公式计算三角形面积
2238
- //周长的一半
2239
- var P = (lengthAC + lengthBC + lengthAB) / 2;
2240
- var allArea = Math.abs(Math.sqrt(P * (P - lengthAC) * (P - lengthBC) * (P - lengthAB)));
2241
- //普通公式计算三角形面积反推点到线的垂直距离
2242
- var distance = (2 * allArea) / lengthAB;
2243
- var l1 = Math.sqrt(Math.pow(lengthAC, 2) - Math.pow(distance, 2));
2244
- var l2 = Math.sqrt(Math.pow(lengthBC, 2) - Math.pow(distance, 2));
2245
- var isInLine = false;
2246
- if (l1 <= lengthAB && l2 <= lengthAB) {
2247
- isInLine = true;
2059
+ var Euler = effects.math.Euler, Vector3$3 = effects.math.Vector3, Matrix4$2 = effects.math.Matrix4;
2060
+ var rectSize = 0.04;
2061
+ var DEG2RAD = Math.PI / 180;
2062
+ function arcPath(radius, arc, options) {
2063
+ if (options === void 0) { options = {}; }
2064
+ var plane = options.plane, _a = options.translate, translate = _a === void 0 ? [0, 0, 0] : _a, _b = options.rotate, rotate = _b === void 0 ? [0, 0, 0] : _b;
2065
+ var rotMat4 = Euler.fromArray(rotate).negate().toMatrix4(new Matrix4$2());
2066
+ var points = [];
2067
+ var indices = [];
2068
+ addPoint(radius, 0);
2069
+ var i = 1;
2070
+ for (; i <= arc; i++) {
2071
+ var angle = i * DEG2RAD;
2072
+ indices.push(i - 1, i);
2073
+ addPoint(Math.cos(angle) * radius, Math.sin(angle) * radius);
2248
2074
  }
2249
2075
  return {
2250
- distance: distance,
2251
- isInLine: isInLine,
2076
+ points: points,
2077
+ indices: indices,
2252
2078
  };
2079
+ function addPoint(cos, sin) {
2080
+ var point = new Vector3$3();
2081
+ if (plane === 'xz') {
2082
+ point.set(cos, 0, sin);
2083
+ }
2084
+ else if (plane === 'yz') {
2085
+ point.set(0, cos, sin);
2086
+ }
2087
+ else {
2088
+ point.set(cos, sin, 0);
2089
+ }
2090
+ rotMat4.transformNormal(point);
2091
+ points.push(point.add(translate));
2092
+ }
2253
2093
  }
2254
- function projectionOfPointAndLine(point, line) {
2255
- var AC = new Vector2$1();
2256
- var BC = new Vector2$1();
2257
- var AB = new Vector2$1();
2258
- var line0 = line[0].toVector2();
2259
- var line1 = line[1].toVector2();
2260
- AC.subtractVectors(point, line0);
2261
- BC.subtractVectors(point, line1);
2262
- AB.subtractVectors(line1, line0);
2263
- var lengthAC = AC.length();
2264
- var lengthBC = BC.length();
2265
- var lengthAB = AB.length();
2266
- //利用海伦公式计算三角形面积
2267
- //周长的一半
2268
- var P = (lengthAC + lengthBC + lengthAB) / 2;
2269
- var allArea = Math.abs(Math.sqrt(P * (P - lengthAC) * (P - lengthBC) * (P - lengthAB)));
2270
- //普通公式计算三角形面积反推点到线的垂直距离
2271
- var distance = (2 * allArea) / lengthAB;
2272
- var l1 = Math.sqrt(Math.pow(lengthAC, 2) - Math.pow(distance, 2));
2273
- var l2 = Math.sqrt(Math.pow(lengthBC, 2) - Math.pow(distance, 2));
2274
- var worldAB = line[1].clone().subtract(line[0]);
2275
- var worldAP = worldAB.clone().multiply(l1 / (l1 + l2));
2276
- var worldP = line[0].clone().add(worldAP);
2277
- return worldP;
2278
- }
2279
- function computeOrthographicOffCenter(left, right, bottom, top, near, far) {
2280
- var a = 1.0 / (right - left);
2281
- var b = 1.0 / (top - bottom);
2282
- var c = 1.0 / (far - near);
2283
- var tx = -(right + left) * a;
2284
- var ty = -(top + bottom) * b;
2285
- var tz = -(far + near) * c;
2286
- a *= 2.0;
2287
- b *= 2.0;
2288
- c *= -2.0;
2289
- return new Matrix4$2(a, 0.0, 0.0, 0.0,
2290
- //
2291
- 0.0, b, 0.0, 0.0,
2292
- //
2293
- 0.0, 0.0, c, 0.0,
2294
- //
2295
- tx, ty, tz, 1.0);
2094
+ function line(p0, p1) {
2095
+ return {
2096
+ points: [
2097
+ Vector3$3.fromArray(p0),
2098
+ Vector3$3.fromArray(p1),
2099
+ ],
2100
+ indices: [0, 1],
2101
+ };
2296
2102
  }
2297
-
2298
- var Matrix4$1 = effects.math.Matrix4; effects.math.Vector2; var Vector3$1 = effects.math.Vector3;
2299
- /**
2300
- * 线条包围盒射线检测算法
2301
- * @param out - 射线与包围盒交点位置
2302
- * @param pointInCanvas - 归一化的画布交互点坐标
2303
- * @param points - 线条包围盒两端点位置
2304
- * @param radius - 线条包围盒辐射半径
2305
- * @param camera - 相机对象
2306
- * @returns 射线与包围盒交点位置 | undefined
2307
- */
2308
- function intersectRayLine(out, pointInCanvas, points, radius, worldMat4, camera) {
2309
- // 构造一个辐射半径边缘的点 radiusPoint
2310
- var up = new Vector3$1(worldMat4.elements[1], worldMat4.elements[5], worldMat4.elements[9]).normalize();
2311
- var radiusPoint = up.clone().multiply(radius);
2312
- radiusPoint.add(points[0]);
2313
- // 计算 start、end、radius 在屏幕空间上的投影
2314
- var mvpMat4 = camera.getModelViewProjection(new Matrix4$1(), worldMat4);
2315
- var screenStart = mvpMat4.projectPoint(points[0], new Vector3$1());
2316
- var screenEnd = mvpMat4.projectPoint(points[1], new Vector3$1());
2317
- var screenRadiusPoint = mvpMat4.projectPoint(radiusPoint, new Vector3$1());
2318
- var screenRadiusVector = screenRadiusPoint.clone().subtract(screenStart);
2319
- var screenRadius = screenRadiusVector.length();
2320
- // 计算屏幕交互点与线条的距离
2321
- var _a = distanceOfPointAndLine(pointInCanvas, [screenStart.toVector2(), screenEnd.toVector2()]), distance = _a.distance, isInLine = _a.isInLine;
2322
- if (distance <= screenRadius && isInLine) { // 距离小于阈值且交互点在线条上的投影位于线段内
2323
- // 计算交互点在线条上的投影并转换为世界坐标
2324
- var screenPosition = projectionOfPointAndLine(pointInCanvas, [screenStart, screenEnd]);
2325
- var inverseViewProjection = camera.getInverseViewProjectionMatrix();
2326
- inverseViewProjection.projectPoint(screenPosition, out);
2327
- return out;
2328
- }
2103
+ function box(width, height, depth, center) {
2104
+ var w = width / 2;
2105
+ var h = height / 2;
2106
+ var d = depth / 2;
2107
+ var myCenter = center !== null && center !== void 0 ? center : [0, 0, 0];
2108
+ var points = [
2109
+ [-w, h, -d], [-w, -h, -d], [-w, h, d], [-w, -h, d],
2110
+ [w, h, -d], [w, -h, -d], [w, h, d], [w, -h, d],
2111
+ ].map(function (item) {
2112
+ return new Vector3$3(item[0] + myCenter[0], item[1] + myCenter[1], item[2] + myCenter[2]);
2113
+ });
2114
+ return {
2115
+ points: points,
2116
+ indices: [
2117
+ 0, 1, 1, 3, 3, 2, 2, 0,
2118
+ 4, 5, 5, 7, 7, 6, 6, 4,
2119
+ 0, 4, 2, 6, 3, 7, 1, 5,
2120
+ ],
2121
+ };
2329
2122
  }
2330
-
2331
- /**
2332
- * 下载图片
2333
- * @param imageUrl - 图片url
2334
- * @returns 图片对象
2335
- */
2336
- function createImage(imageUrl) {
2337
- return __awaiter(this, void 0, void 0, function () {
2338
- var image;
2339
- return __generator(this, function (_a) {
2340
- image = new Image();
2341
- image.src = imageUrl;
2342
- return [2 /*return*/, new Promise(function (resolve, reject) {
2343
- image.onload = function () {
2344
- resolve(image);
2345
- };
2346
- image.onerror = reject;
2347
- })];
2123
+ function rect(width, height, pos) {
2124
+ var w = width / 2;
2125
+ var h = height / 2;
2126
+ var points = [
2127
+ new Vector3$3(-w, h, 0),
2128
+ new Vector3$3(w, h, 0),
2129
+ new Vector3$3(w, -h, 0),
2130
+ new Vector3$3(-w, -h, 0),
2131
+ ];
2132
+ if (pos) {
2133
+ points.forEach(function (vec) {
2134
+ vec.add(pos);
2348
2135
  });
2349
- });
2136
+ }
2137
+ return {
2138
+ points: points,
2139
+ indices: [
2140
+ 0, 1, 1, 2, 2, 3, 3, 0,
2141
+ ],
2142
+ };
2350
2143
  }
2351
- /**
2352
- * 创建 Texture 对象
2353
- * @param engine - engine 对象
2354
- * @param image - 图片对象
2355
- * @returns 纹理
2356
- */
2357
- function createTexture(engine, image, hookDestroy) {
2358
- var texture = effects.Texture.create(engine, { image: image });
2359
- if (hookDestroy) {
2360
- texture.dispose = effects.noop;
2144
+ function combineGeometries(geometries) {
2145
+ var points = [];
2146
+ var indices = [];
2147
+ var _loop_1 = function (i, indicesBase) {
2148
+ var geometry = geometries[i];
2149
+ if (geometry) {
2150
+ geometry.points.forEach(function (point) {
2151
+ points.push(point.x, point.y, point.z);
2152
+ });
2153
+ geometry.indices.forEach(function (index) { return indices.push(index + indicesBase); });
2154
+ indicesBase += geometry.points.length;
2155
+ }
2156
+ out_indicesBase_1 = indicesBase;
2157
+ };
2158
+ var out_indicesBase_1;
2159
+ for (var i = 0, indicesBase = 0; i < geometries.length; i++) {
2160
+ _loop_1(i, indicesBase);
2161
+ indicesBase = out_indicesBase_1;
2361
2162
  }
2362
- return texture;
2163
+ return {
2164
+ points: new Float32Array(points),
2165
+ indices: new Uint16Array(indices),
2166
+ };
2167
+ }
2168
+ var Shapes = {
2169
+ Texture: function (arg) {
2170
+ var ret = [];
2171
+ if (arg.detail) {
2172
+ var anchors = arg.detail.anchors;
2173
+ var block = arg.detail.block;
2174
+ var width = arg.width;
2175
+ var height = arg.height;
2176
+ for (var i = 0; i < anchors.length; i += 2) {
2177
+ ret.push(rect(block[0] * width, block[1] * height, [
2178
+ width * (anchors[i] - 0.5),
2179
+ height * (anchors[i + 1] - 0.5),
2180
+ 0,
2181
+ ]));
2182
+ }
2183
+ }
2184
+ else {
2185
+ ret.unshift(Shapes.Rectangle(arg)[0]);
2186
+ }
2187
+ return ret;
2188
+ },
2189
+ Circle: function (arg) {
2190
+ var radius = arg.radius, arc = arg.arc;
2191
+ return [
2192
+ arcPath(radius, arc),
2193
+ arc !== 360 && line([0, 0, 0], [radius, 0, 0]),
2194
+ arc !== 360 && line([0, 0, 0], [Math.cos(arc * DEG2RAD) * radius, Math.sin(arc * DEG2RAD) * radius, 0]),
2195
+ ];
2196
+ },
2197
+ Box: function (arg) {
2198
+ var width = arg.width, height = arg.height, depth = arg.depth, center = arg.center;
2199
+ var data = box(width, height, depth, center);
2200
+ return [data];
2201
+ },
2202
+ Sphere: function (arg) {
2203
+ var radius = arg.radius, arc = arg.arc;
2204
+ var ret = [
2205
+ line([0, 0, -radius], [0, 0, radius]),
2206
+ arcPath(radius, arc > 180 ? 360 : 180, { plane: 'xz', rotate: [0, 90, 0] }),
2207
+ arcPath(radius, arc, { plane: 'xy' }),
2208
+ arcPath(radius, 180, { plane: 'xz', rotate: [0, 90, arc] }),
2209
+ ];
2210
+ if (arc > 90) {
2211
+ ret.push(arcPath(radius, arc > 270 ? 360 : 180, { plane: 'yz', rotate: [-90, 0, 0] }));
2212
+ }
2213
+ return ret;
2214
+ },
2215
+ Hemisphere: function (arg) {
2216
+ var radius = arg.radius, arc = arg.arc;
2217
+ var ret = [
2218
+ line([0, 0, radius], [0, 0, 0]),
2219
+ line([arc > 180 ? -radius : 0, 0, 0], [radius, 0, 0]),
2220
+ arg > 90 && line([0, arc > 270 ? -radius : 0, 0], [0, radius, 0]),
2221
+ arcPath(radius, (arc > 180 ? 360 : 180) / 2, { plane: 'xz' }),
2222
+ arcPath(radius, arc, { plane: 'xy' }),
2223
+ arcPath(radius, 90, { plane: 'xz', rotate: [0, 0, arc] }),
2224
+ line([0, 0, 0], [Math.cos(arc * DEG2RAD) * radius, Math.sin(arc * DEG2RAD) * radius, 0]),
2225
+ ];
2226
+ if (arc > 90) {
2227
+ ret.push(arcPath(radius, arc > 270 ? 180 : 90, { plane: 'yz' }));
2228
+ }
2229
+ return ret;
2230
+ },
2231
+ Cone: function (arg) {
2232
+ var radius = arg.radius, arc = arg.arc;
2233
+ var outerRadius = radius * Math.tan(arg.angle * DEG2RAD) + radius;
2234
+ return [
2235
+ arcPath(outerRadius, arc, { translate: [0, 0, radius] }),
2236
+ line([radius, 0, 0], [outerRadius, 0, radius]),
2237
+ arc > 90 && line([0, radius, 0], [0, outerRadius, radius]),
2238
+ arc > 180 && line([-radius, 0, 0], [-outerRadius, 0, radius]),
2239
+ arc > 270 && line([0, -radius, 0], [0, -outerRadius, radius]),
2240
+ line([Math.cos(arc * DEG2RAD) * radius, Math.sin(arc * DEG2RAD) * radius, 0], [Math.cos(arc * DEG2RAD) * outerRadius, Math.sin(arc * DEG2RAD) * outerRadius, radius]),
2241
+ ].concat(Shapes.Circle(arg));
2242
+ },
2243
+ Edge: function (arg) {
2244
+ var hw = arg.width / 2;
2245
+ return [
2246
+ line([-hw, 0, 0], [hw, 0, 0]),
2247
+ ];
2248
+ },
2249
+ Rectangle: function (arg) {
2250
+ return [
2251
+ rect(arg.width, arg.height),
2252
+ ];
2253
+ },
2254
+ RectangleEdge: function (arg) {
2255
+ return [
2256
+ rect(arg.width, arg.height),
2257
+ ];
2258
+ },
2259
+ Donut: function (arg) {
2260
+ var arc = arg.arc, radius = arg.radius, donutRadius = arg.donutRadius;
2261
+ return [
2262
+ arcPath(donutRadius, 360, { translate: [radius, 0, 0], rotate: [90, 0, 0] }),
2263
+ arcPath(radius - donutRadius, arc),
2264
+ arcPath(radius + donutRadius, arc),
2265
+ arcPath(radius, arc, { translate: [0, 0, donutRadius] }),
2266
+ arcPath(radius, arc, { translate: [0, 0, -donutRadius] }),
2267
+ arc % 360 === 0 ? arcPath(donutRadius, 360, {
2268
+ translate: [-radius, 0, 0],
2269
+ rotate: [90, 0, 0],
2270
+ }) : arcPath(donutRadius, 360, {
2271
+ translate: [Math.cos(arc * DEG2RAD) * radius, Math.sin(arc * DEG2RAD) * radius, 0],
2272
+ rotate: [90, 0, arc],
2273
+ }),
2274
+ ];
2275
+ },
2276
+ path: function (arg) {
2277
+ var positions = arg.keys;
2278
+ var ret = [];
2279
+ for (var i = 0; i < positions.length - 1; i++) {
2280
+ ret.push(rect(rectSize, rectSize, positions[i]));
2281
+ ret.push(line(positions[i], positions[i + 1]));
2282
+ }
2283
+ ret.push(rect(rectSize, rectSize, positions[positions.length - 1]));
2284
+ return ret;
2285
+ },
2286
+ };
2287
+ Shapes['0'] = Shapes.None;
2288
+ Shapes['1'] = Shapes.Sphere;
2289
+ Shapes['2'] = Shapes.Cone;
2290
+ Shapes['3'] = Shapes.Hemisphere;
2291
+ Shapes['4'] = Shapes.Circle;
2292
+ Shapes['5'] = Shapes.Donut;
2293
+ Shapes['6'] = Shapes.Rectangle;
2294
+ Shapes['7'] = Shapes.RectangleEdge;
2295
+ Shapes['8'] = Shapes.Edge;
2296
+ Shapes['9'] = Shapes.Texture;
2297
+ function createMeshFromShape(engine, args, options) {
2298
+ var ret = Shapes[args.type || args.shape](args);
2299
+ var geo = combineGeometries(ret);
2300
+ return createMesh(engine, geo.points, geo.indices, options.color || [1, 0, 0], options.depthTest, args.shape);
2363
2301
  }
2364
- /**
2365
- * 移动到距离目标点指定距离的位置
2366
- * @param targetPos - 目标点
2367
- * @param currentPos - 当前点
2368
- * @returns 指定点
2369
- */
2370
- function moveToPointWidthFixDistance(targetPos, currentPos) {
2371
- var vecCameraItem = currentPos.clone().subtract(targetPos);
2372
- var normalVecCameraItem = vecCameraItem.clone().normalize();
2373
- var scalerVecCameraItem = normalVecCameraItem.clone().multiply(20);
2374
- var vecScalerItem = vecCameraItem.clone().subtract(scalerVecCameraItem);
2375
- var vecItemScaler = vecScalerItem.clone().multiply(-1);
2376
- return currentPos.clone().add(vecItemScaler);
2302
+ function createMesh(engine, points, indices, color, depthTest, name) {
2303
+ if (depthTest === void 0) { depthTest = false; }
2304
+ var material = effects.Material.create(engine, {
2305
+ uniformValues: {
2306
+ u_color: new Float32Array(color),
2307
+ u_model: new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]),
2308
+ },
2309
+ uniformSemantics: {
2310
+ u_vp: 'VIEWPROJECTION',
2311
+ u_et: 'EDITOR_TRANSFORM',
2312
+ },
2313
+ shader: {
2314
+ shared: true,
2315
+ fragment: "\n precision mediump float;\n\n uniform vec3 u_color;\n\n void main(){\n gl_FragColor = vec4(u_color,1.0);\n }",
2316
+ vertex: "precision highp float;\n\n attribute vec3 a_Position;\n\n uniform mat4 u_model;\n uniform mat4 effects_MatrixVP;\n uniform vec4 uEditorTransform;\n void main(){\n gl_Position = effects_MatrixVP * u_model * vec4(a_Position,1.0);\n gl_Position = vec4(gl_Position.xy * uEditorTransform.xy + uEditorTransform.zw * gl_Position.w,gl_Position.zw);\n }",
2317
+ },
2318
+ });
2319
+ material.setVector3('u_color', Vector3$3.fromArray(color));
2320
+ material.setMatrix('u_model', Matrix4$2.IDENTITY);
2321
+ material.depthTest = depthTest;
2322
+ material.stencilTest = false;
2323
+ material.blending = false;
2324
+ material.depthMask = true;
2325
+ var geometry = effects.Geometry.create(engine, {
2326
+ attributes: {
2327
+ a_Position: {
2328
+ size: 3,
2329
+ data: points,
2330
+ },
2331
+ },
2332
+ indices: {
2333
+ data: indices,
2334
+ },
2335
+ mode: effects.glContext.LINES,
2336
+ drawCount: indices.length,
2337
+ });
2338
+ return effects.Mesh.create(engine, {
2339
+ name: name,
2340
+ geometry: geometry,
2341
+ material: material,
2342
+ priority: 3000,
2343
+ });
2377
2344
  }
2378
2345
 
2346
+ var Vector2 = effects.math.Vector2, Vector3$2 = effects.math.Vector3, Matrix4$1 = effects.math.Matrix4, Quaternion$1 = effects.math.Quaternion;
2379
2347
  var constants = effects.glContext;
2380
- var Vector2 = effects.math.Vector2, Vector3 = effects.math.Vector3, Matrix4 = effects.math.Matrix4; effects.math.Ray; var Quaternion = effects.math.Quaternion;
2381
- /**
2382
- * 包围盒类型
2383
- */
2384
- var BoundingType;
2385
- (function (BoundingType) {
2386
- BoundingType[BoundingType["box"] = 0] = "box";
2387
- BoundingType[BoundingType["sphere"] = 1] = "sphere";
2388
- BoundingType[BoundingType["triangle"] = 2] = "triangle";
2389
- BoundingType[BoundingType["line"] = 3] = "line";
2390
- })(BoundingType || (BoundingType = {}));
2391
- /**
2392
- *
2393
- */
2394
- var GizmoVFXItem = /** @class */ (function (_super) {
2395
- __extends(GizmoVFXItem, _super);
2396
- function GizmoVFXItem() {
2348
+ var GizmoComponent = /** @class */ (function (_super) {
2349
+ __extends(GizmoComponent, _super);
2350
+ function GizmoComponent() {
2397
2351
  var _this = _super !== null && _super.apply(this, arguments) || this;
2398
- _this.boundingMap = new Map();
2399
- _this.mat = Matrix4.fromIdentity();
2352
+ _this.mat = Matrix4$1.fromIdentity();
2400
2353
  _this.wireframeMeshes = [];
2401
2354
  return _this;
2402
2355
  }
2403
- Object.defineProperty(GizmoVFXItem.prototype, "type", {
2404
- get: function () {
2405
- return GizmoVFXItemType;
2406
- },
2407
- set: function (t) {
2408
- },
2409
- enumerable: false,
2410
- configurable: true
2411
- });
2412
- Object.defineProperty(GizmoVFXItem.prototype, "content", {
2413
- get: function () {
2414
- return this._content;
2415
- },
2416
- set: function (content) {
2417
- },
2418
- enumerable: false,
2419
- configurable: true
2420
- });
2421
- GizmoVFXItem.prototype.onConstructed = function (options) {
2422
- this.duration = 999;
2423
- var opt = options.content.options;
2424
- this.target = opt.target;
2425
- this.subType = opt.subType;
2426
- this.renderMode = opt.renderMode || this.getDefaultRenderMode();
2427
- this.size = opt.size || this.getDefaultSize();
2428
- this.depthTest = opt.depthTest;
2429
- var c = (opt.color || [255, 255, 255]);
2430
- this.color = [c[0] / 255, c[1] / 255, c[2] / 255];
2431
- if (options.content) {
2432
- this.transform = new effects.Transform(options.content.transform);
2356
+ GizmoComponent.prototype.start = function () {
2357
+ var e_1, _a, e_2, _b, e_3, _c;
2358
+ try {
2359
+ for (var _d = __values(this.item.composition.items), _e = _d.next(); !_e.done; _e = _d.next()) {
2360
+ var item = _e.value;
2361
+ if (item.id === this.item.target.toString()) {
2362
+ this.targetItem = item;
2363
+ }
2364
+ }
2365
+ }
2366
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2367
+ finally {
2368
+ try {
2369
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
2370
+ }
2371
+ finally { if (e_1) throw e_1.error; }
2372
+ }
2373
+ var targetItem = this.targetItem;
2374
+ if (!targetItem) {
2375
+ return;
2376
+ }
2377
+ var composition = this.item.composition;
2378
+ try {
2379
+ for (var _f = __values(composition.pluginSystem.plugins), _g = _f.next(); !_g.done; _g = _f.next()) {
2380
+ var plugin = _g.value;
2381
+ if (plugin.name === 'editor-gizmo') {
2382
+ this.gizmoPlugin = plugin;
2383
+ }
2384
+ }
2385
+ }
2386
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
2387
+ finally {
2388
+ try {
2389
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
2390
+ }
2391
+ finally { if (e_2) throw e_2.error; }
2392
+ }
2393
+ var gizmoPlugin = this.gizmoPlugin;
2394
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
2395
+ if (targetItem.type === '7' || !gizmoPlugin) {
2396
+ return;
2397
+ }
2398
+ var gizmoVFXItemList = composition.loaderData.gizmoTarget[targetItem.id];
2399
+ if (gizmoVFXItemList && gizmoVFXItemList.length > 0) {
2400
+ try {
2401
+ for (var gizmoVFXItemList_1 = __values(gizmoVFXItemList), gizmoVFXItemList_1_1 = gizmoVFXItemList_1.next(); !gizmoVFXItemList_1_1.done; gizmoVFXItemList_1_1 = gizmoVFXItemList_1.next()) {
2402
+ var gizmoVFXItem = gizmoVFXItemList_1_1.value;
2403
+ switch (gizmoVFXItem.subType) {
2404
+ case exports.GizmoSubType.particleEmitter:
2405
+ this.createParticleContent(targetItem, gizmoPlugin.meshToAdd);
2406
+ break;
2407
+ case exports.GizmoSubType.modelWireframe:
2408
+ this.needCreateModelContent = true;
2409
+ // gizmoVFXItem.createModelContent(targetItem, gizmoPlugin.meshToAdd);
2410
+ break;
2411
+ case exports.GizmoSubType.box:
2412
+ case exports.GizmoSubType.sphere:
2413
+ case exports.GizmoSubType.cylinder:
2414
+ case exports.GizmoSubType.cone:
2415
+ case exports.GizmoSubType.torus:
2416
+ case exports.GizmoSubType.sprite:
2417
+ case exports.GizmoSubType.frustum:
2418
+ case exports.GizmoSubType.directionLight:
2419
+ case exports.GizmoSubType.pointLight:
2420
+ case exports.GizmoSubType.spotLight:
2421
+ case exports.GizmoSubType.floorGrid:
2422
+ this.createBasicContent(targetItem, gizmoPlugin.meshToAdd, gizmoVFXItem.subType);
2423
+ break;
2424
+ case exports.GizmoSubType.camera:
2425
+ case exports.GizmoSubType.light:
2426
+ this.createBasicContent(targetItem, gizmoPlugin.meshToAdd, gizmoVFXItem.subType, iconTextures);
2427
+ break;
2428
+ case exports.GizmoSubType.rotation:
2429
+ case exports.GizmoSubType.scale:
2430
+ case exports.GizmoSubType.translation:
2431
+ this.createCombinationContent(targetItem, gizmoPlugin.meshToAdd, gizmoVFXItem.subType);
2432
+ break;
2433
+ case exports.GizmoSubType.viewHelper:
2434
+ this.createCombinationContent(targetItem, gizmoPlugin.meshToAdd, gizmoVFXItem.subType, iconTextures);
2435
+ break;
2436
+ case exports.GizmoSubType.boundingBox:
2437
+ this.createBoundingBoxContent(targetItem, gizmoPlugin.meshToAdd);
2438
+ break;
2439
+ default:
2440
+ break;
2441
+ }
2442
+ }
2443
+ }
2444
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
2445
+ finally {
2446
+ try {
2447
+ if (gizmoVFXItemList_1_1 && !gizmoVFXItemList_1_1.done && (_c = gizmoVFXItemList_1.return)) _c.call(gizmoVFXItemList_1);
2448
+ }
2449
+ finally { if (e_3) throw e_3.error; }
2450
+ }
2451
+ }
2452
+ composition.loaderData.gizmoItems.push(this.item);
2453
+ };
2454
+ GizmoComponent.prototype.update = function (dt) {
2455
+ this.updateRenderData();
2456
+ };
2457
+ GizmoComponent.prototype.lateUpdate = function (dt) {
2458
+ if (this.needCreateModelContent) {
2459
+ this.createModelContent(this.targetItem, this.gizmoPlugin.meshToAdd);
2460
+ this.needCreateModelContent = false;
2461
+ }
2462
+ };
2463
+ GizmoComponent.prototype.updateRenderData = function () {
2464
+ var e_4, _a;
2465
+ var _b;
2466
+ var item = this.item;
2467
+ if (item.subType === exports.GizmoSubType.particleEmitter) { // 粒子发射器
2468
+ if (this.targetItem && item.content) {
2469
+ this.mat = this.targetItem.transform.getWorldMatrix();
2470
+ item.content.material.setMatrix('u_model', this.mat);
2471
+ }
2472
+ if (item.wireframeMesh && this.targetItem) {
2473
+ var particle = this.targetItem.content;
2474
+ if (particle) {
2475
+ updateWireframeMesh(particle.particleMesh.mesh, item.wireframeMesh, WireframeGeometryType.quad);
2476
+ item.wireframeMesh.worldMatrix = particle.particleMesh.mesh.worldMatrix;
2477
+ }
2478
+ }
2479
+ }
2480
+ else if (item.subType === exports.GizmoSubType.modelWireframe) { // 模型线框
2481
+ if (item.wireframeMesh && this.targetItem) {
2482
+ // @ts-expect-error
2483
+ var meshes = (_b = this.targetItem.getComponent(effects.RendererComponent)) === null || _b === void 0 ? void 0 : _b.content.mriMeshs;
2484
+ var wireframeMeshes = this.wireframeMeshes;
2485
+ if ((meshes === null || meshes === void 0 ? void 0 : meshes.length) > 0) {
2486
+ for (var i = 0; i < meshes.length; i++) {
2487
+ updateWireframeMesh(meshes[i], wireframeMeshes[i], WireframeGeometryType.triangle);
2488
+ }
2489
+ }
2490
+ }
2491
+ }
2492
+ else { // 几何体模型
2493
+ if (this.targetItem) {
2494
+ if (item.contents) { // 组合几何体
2495
+ // const targetTransform = this.targetItem.transform.clone();
2496
+ var worldPos = new Vector3$2();
2497
+ var worldQuat = new Quaternion$1();
2498
+ var worldScale = new Vector3$2(1, 1, 1);
2499
+ this.targetItem.transform.assignWorldTRS(worldPos, worldQuat);
2500
+ var targetTransform = new effects.Transform({
2501
+ position: worldPos,
2502
+ quat: worldQuat,
2503
+ scale: worldScale,
2504
+ valid: true,
2505
+ });
2506
+ // 移动\旋转\缩放gizmo去除近大远小
2507
+ if (item.subType === exports.GizmoSubType.rotation || item.subType === exports.GizmoSubType.scale || item.subType === exports.GizmoSubType.translation) {
2508
+ var camera = item.composition.camera;
2509
+ var cameraPos = camera.position || new Vector3$2();
2510
+ var itemPos = targetTransform.position;
2511
+ var newPos = moveToPointWidthFixDistance(cameraPos, itemPos);
2512
+ targetTransform.setPosition(newPos.x, newPos.y, newPos.z);
2513
+ }
2514
+ this.mat = targetTransform.getWorldMatrix();
2515
+ var center = targetTransform.position;
2516
+ try {
2517
+ for (var _c = __values(item.contents), _d = _c.next(); !_d.done; _d = _c.next()) {
2518
+ var _e = __read(_d.value, 2), mesh = _e[0], transform = _e[1];
2519
+ var worldMat4 = void 0;
2520
+ transform.parentTransform = targetTransform;
2521
+ var position = new Vector3$2();
2522
+ transform.assignWorldTRS(position);
2523
+ // 物体和中心点在屏幕空间上投影的距离
2524
+ var distanceToCneter = 100;
2525
+ var theta = 1;
2526
+ if (item.subType === exports.GizmoSubType.viewHelper) {
2527
+ // 正交投影只需要计算物体在XY平面上的投影与中心点的距离
2528
+ if (mesh.name === 'sprite') {
2529
+ distanceToCneter = position.toVector2().distance(center.toVector2());
2530
+ theta = item.boundingMap.get('posX').radius;
2531
+ }
2532
+ // 将物体挂到相机的transform上
2533
+ var fov = 30; // 指定fov角度
2534
+ var screenWidth = item.composition.renderer.getWidth();
2535
+ var screenHeight = item.composition.renderer.getHeight();
2536
+ var distance = 16; // 指定物体与相机的距离
2537
+ var width = 2 * Math.tan(fov * Math.PI / 360) * distance;
2538
+ var aspect = screenWidth / screenHeight;
2539
+ var height = width / aspect;
2540
+ var cameraModelMat4 = item.composition.camera.getInverseViewMatrix();
2541
+ var padding = item.size.padding || 1; // 指定viewHelper与屏幕右上角的边距
2542
+ var localMat = void 0;
2543
+ localMat = transform.getWorldMatrix();
2544
+ var worldTransform = new effects.Transform({
2545
+ valid: true,
2546
+ });
2547
+ worldTransform.cloneFromMatrix(localMat);
2548
+ worldTransform.setPosition((position.x + width / 2) - padding, (position.y + height / 2) - padding, position.z);
2549
+ localMat = worldTransform.getWorldMatrix();
2550
+ worldMat4 = cameraModelMat4.clone().multiply(localMat);
2551
+ // 正交投影到屏幕上
2552
+ var proMat5 = computeOrthographicOffCenter(-width / 2, width / 2, -height / 2, height / 2, -distance, distance);
2553
+ mesh.material.setMatrix('_MatrixP', proMat5);
2554
+ }
2555
+ else {
2556
+ if (item.subType === exports.GizmoSubType.rotation) {
2557
+ var cameraPos = item.composition.camera.position || [0, 0, 0];
2558
+ mesh.material.setVector3('u_cameraPos', cameraPos);
2559
+ mesh.material.setVector3('u_center', center);
2560
+ }
2561
+ worldMat4 = transform.getWorldMatrix();
2562
+ // TODO 计算物体和中心点在屏幕空间上投影的距离 distanceToCneter
2563
+ }
2564
+ mesh.material.setMatrix('u_model', worldMat4);
2565
+ // 使用distanceToCneter处理坐标轴旋转到中心点附近时的遮挡问题
2566
+ if (distanceToCneter < theta) {
2567
+ if (distanceToCneter < theta * 0.5) {
2568
+ mesh.material.setVector2('u_alpha', new Vector2(0, 0));
2569
+ }
2570
+ else {
2571
+ mesh.material.setVector2('u_alpha', new Vector2((2 / theta) * distanceToCneter - 1, 0));
2572
+ }
2573
+ }
2574
+ }
2575
+ }
2576
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
2577
+ finally {
2578
+ try {
2579
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
2580
+ }
2581
+ finally { if (e_4) throw e_4.error; }
2582
+ }
2583
+ }
2584
+ if (item.content) { // 基础几何体
2585
+ var worldPos = new Vector3$2();
2586
+ var worldQuat = new Quaternion$1();
2587
+ var worldSca = new Vector3$2(1, 1, 1);
2588
+ this.targetItem.transform.assignWorldTRS(worldPos, worldQuat);
2589
+ var targetTransform = new effects.Transform({
2590
+ position: worldPos,
2591
+ quat: worldQuat,
2592
+ scale: worldSca,
2593
+ valid: true,
2594
+ });
2595
+ if (item.subType === exports.GizmoSubType.light || item.subType === exports.GizmoSubType.camera) {
2596
+ var camera = item.composition.camera;
2597
+ var cameraPos = camera.position || new Vector3$2(0, 0, 0);
2598
+ var itemPos = targetTransform.position;
2599
+ var newPos = moveToPointWidthFixDistance(cameraPos, itemPos);
2600
+ targetTransform.setPosition(newPos.x, newPos.y, newPos.z);
2601
+ }
2602
+ this.mat = targetTransform.getWorldMatrix();
2603
+ item.content.material.setMatrix('u_model', targetTransform.getWorldMatrix());
2604
+ }
2605
+ }
2433
2606
  }
2434
2607
  };
2435
2608
  /**
2436
2609
  * 获取默认绘制模式
2437
2610
  * @returns 绘制模式常量
2438
2611
  */
2439
- GizmoVFXItem.prototype.getDefaultRenderMode = function () {
2612
+ GizmoComponent.prototype.getDefaultRenderMode = function () {
2440
2613
  var result;
2441
- switch (this.subType) {
2614
+ var item = this.item;
2615
+ switch (item.subType) {
2442
2616
  case exports.GizmoSubType.particleEmitter:
2443
2617
  case exports.GizmoSubType.modelWireframe:
2444
2618
  case exports.GizmoSubType.frustum:
@@ -2458,9 +2632,10 @@ var GizmoVFXItem = /** @class */ (function (_super) {
2458
2632
  * 获取默认尺寸
2459
2633
  * @returns 几何体尺寸
2460
2634
  */
2461
- GizmoVFXItem.prototype.getDefaultSize = function () {
2635
+ GizmoComponent.prototype.getDefaultSize = function () {
2462
2636
  var result = {};
2463
- switch (this.subType) {
2637
+ var item = this.item;
2638
+ switch (item.subType) {
2464
2639
  case exports.GizmoSubType.box:
2465
2640
  result = { width: 1, height: 1, depth: 1 };
2466
2641
  break;
@@ -2479,62 +2654,55 @@ var GizmoVFXItem = /** @class */ (function (_super) {
2479
2654
  }
2480
2655
  return result;
2481
2656
  };
2482
- GizmoVFXItem.prototype.createModelContent = function (item, meshesToAdd) {
2657
+ GizmoComponent.prototype.createModelContent = function (item, meshesToAdd) {
2483
2658
  var _this = this;
2484
2659
  var _a;
2485
- var ms = item.content.mriMeshs;
2486
- var engine = (_a = this.composition) === null || _a === void 0 ? void 0 : _a.renderer.engine;
2660
+ var modelComponent = item.getComponent(effects.RendererComponent);
2661
+ // @ts-expect-error
2662
+ var ms = modelComponent.content.mriMeshs;
2663
+ var engine = (_a = item.composition) === null || _a === void 0 ? void 0 : _a.renderer.engine;
2487
2664
  effects.assertExist(engine);
2488
2665
  if (ms) {
2489
2666
  this.targetItem = item;
2490
2667
  this.wireframeMeshes = [];
2491
2668
  ms.forEach(function (m) {
2492
- var mesh = _this.wireframeMesh = createModeWireframe(engine, m, _this.color);
2669
+ var mesh = _this.item.wireframeMesh = createModeWireframe(engine, m, _this.color);
2493
2670
  _this.wireframeMeshes.push(mesh);
2494
2671
  meshesToAdd.push(mesh);
2495
2672
  });
2496
2673
  }
2497
2674
  };
2498
- GizmoVFXItem.prototype.createParticleContent = function (item, meshesToAdd) {
2499
- var _a, _b;
2500
- var shape = (_a = item.particle) === null || _a === void 0 ? void 0 : _a.shape;
2501
- var engine = (_b = this.composition) === null || _b === void 0 ? void 0 : _b.renderer.engine;
2675
+ GizmoComponent.prototype.createParticleContent = function (item, meshesToAdd) {
2676
+ var _a;
2677
+ var shape = item.props.content.shape;
2678
+ var engine = (_a = this.item.composition) === null || _a === void 0 ? void 0 : _a.renderer.engine;
2502
2679
  effects.assertExist(engine);
2503
2680
  this.targetItem = item;
2504
2681
  if (shape && shape.type) {
2505
- var mesh = this._content = createMeshFromShape(engine, shape, { color: this.color });
2682
+ var mesh = this.item._content = createMeshFromShape(engine, shape, { color: this.color });
2506
2683
  meshesToAdd.push(mesh);
2507
2684
  }
2508
- // if (item.content?.particleMesh) {
2509
- // const mesh = this.wireframeMesh = createParticleWireframe(engine, item.content.particleMesh.mesh, this.color);
2510
- // meshesToAdd.push(mesh);
2511
- // }
2512
- if (effects.VFXItem.isSprite(item) || effects.VFXItem.isFilterSprite(item)) {
2513
- var color = this.color.slice();
2514
- var mesh = this.spriteMesh = item.createWireframeMesh(item.content, color);
2515
- this.wireframeMesh = mesh.mesh;
2516
- meshesToAdd.push(mesh.mesh);
2517
- }
2518
2685
  };
2519
2686
  /**
2520
2687
  * 创建 BoundingBox 几何体模型
2521
2688
  * @param item - VFXItem
2522
2689
  * @param meshesToAdd - 插件缓存的 Mesh 数组
2523
2690
  */
2524
- GizmoVFXItem.prototype.createBoundingBoxContent = function (item, meshesToAdd) {
2691
+ GizmoComponent.prototype.createBoundingBoxContent = function (item, meshesToAdd) {
2525
2692
  var _a;
2693
+ var gizmoItem = this.item;
2526
2694
  var shape = {
2527
2695
  shape: 'Box',
2528
- width: this.size.width,
2529
- height: this.size.height,
2530
- depth: this.size.depth,
2531
- center: this.size.center,
2696
+ width: gizmoItem.size.width,
2697
+ height: gizmoItem.size.height,
2698
+ depth: gizmoItem.size.depth,
2699
+ center: gizmoItem.size.center,
2532
2700
  };
2533
- var engine = (_a = this.composition) === null || _a === void 0 ? void 0 : _a.renderer.engine;
2701
+ var engine = (_a = gizmoItem.composition) === null || _a === void 0 ? void 0 : _a.renderer.engine;
2534
2702
  effects.assertExist(engine);
2535
2703
  this.targetItem = item;
2536
2704
  if (shape) {
2537
- var mesh = this._content = createMeshFromShape(engine, shape, { color: this.color, depthTest: this.depthTest });
2705
+ var mesh = gizmoItem._content = createMeshFromShape(engine, shape, { color: this.color, depthTest: this.depthTest });
2538
2706
  meshesToAdd.push(mesh);
2539
2707
  }
2540
2708
  };
@@ -2544,17 +2712,18 @@ var GizmoVFXItem = /** @class */ (function (_super) {
2544
2712
  * @param meshesToAdd - 插件缓存的 Mesh 数组
2545
2713
  * @param subType - GizmoSubType 类型
2546
2714
  */
2547
- GizmoVFXItem.prototype.createBasicContent = function (item, meshesToAdd, subType, iconTextures) {
2715
+ GizmoComponent.prototype.createBasicContent = function (item, meshesToAdd, subType, iconTextures) {
2548
2716
  var _a;
2717
+ var gizmoItem = this.item;
2549
2718
  var options = {
2550
- size: this.size,
2719
+ size: gizmoItem.size,
2551
2720
  color: this.color,
2552
2721
  renderMode: this.renderMode,
2553
2722
  depthTest: this.depthTest,
2554
2723
  };
2555
- var engine = (_a = this.composition) === null || _a === void 0 ? void 0 : _a.renderer.engine;
2724
+ var engine = (_a = gizmoItem.composition) === null || _a === void 0 ? void 0 : _a.renderer.engine;
2556
2725
  effects.assertExist(engine);
2557
- var mesh = this._content = createMeshFromSubType(engine, subType, this.boundingMap, iconTextures, options);
2726
+ var mesh = gizmoItem._content = createMeshFromSubType(engine, subType, gizmoItem.boundingMap, iconTextures, options);
2558
2727
  this.targetItem = item;
2559
2728
  meshesToAdd.push(mesh);
2560
2729
  };
@@ -2565,178 +2734,120 @@ var GizmoVFXItem = /** @class */ (function (_super) {
2565
2734
  * @param subType - GizmoSubType 类型
2566
2735
  * @param iconTextures - XYZ 图标纹理(viewHelper 专用)
2567
2736
  */
2568
- GizmoVFXItem.prototype.createCombinationContent = function (item, meshesToAdd, subType, iconTextures) {
2569
- var e_1, _a;
2737
+ GizmoComponent.prototype.createCombinationContent = function (item, meshesToAdd, subType, iconTextures) {
2738
+ var e_5, _a;
2570
2739
  var _b;
2740
+ var gizmoItem = this.item;
2571
2741
  var options = {
2572
- size: this.size,
2742
+ size: gizmoItem.size,
2573
2743
  renderMode: this.renderMode,
2574
2744
  };
2575
- var engine = (_b = this.composition) === null || _b === void 0 ? void 0 : _b.renderer.engine;
2745
+ var engine = (_b = gizmoItem.composition) === null || _b === void 0 ? void 0 : _b.renderer.engine;
2576
2746
  effects.assertExist(engine);
2577
- this.contents = createMeshFromSubType(engine, subType, this.boundingMap, iconTextures, options);
2747
+ gizmoItem.contents = createMeshFromSubType(engine, subType, gizmoItem.boundingMap, iconTextures, options);
2578
2748
  try {
2579
- for (var _c = __values(this.contents.keys()), _d = _c.next(); !_d.done; _d = _c.next()) {
2749
+ for (var _c = __values(gizmoItem.contents.keys()), _d = _c.next(); !_d.done; _d = _c.next()) {
2580
2750
  var mesh = _d.value;
2581
2751
  meshesToAdd.push(mesh);
2582
2752
  }
2583
2753
  }
2584
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2754
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
2585
2755
  finally {
2586
2756
  try {
2587
2757
  if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
2588
2758
  }
2589
- finally { if (e_1) throw e_1.error; }
2759
+ finally { if (e_5) throw e_5.error; }
2590
2760
  }
2591
2761
  this.targetItem = item;
2592
2762
  };
2593
- GizmoVFXItem.prototype.onItemUpdate = function () {
2594
- };
2595
- GizmoVFXItem.prototype.updateRenderData = function () {
2596
- var e_2, _a;
2597
- if (this.subType === exports.GizmoSubType.particleEmitter) { // 粒子发射器
2598
- if (this.targetItem && this.content) {
2599
- this.mat = this.targetItem.transform.getWorldMatrix();
2600
- this.content.material.setMatrix('u_model', this.mat);
2601
- }
2602
- if (this.spriteMesh) {
2603
- this.spriteMesh.updateItem(this.targetItem.content);
2604
- }
2605
- else if (this.wireframeMesh && this.targetItem) {
2606
- var particle = this.targetItem.content;
2607
- if (particle) {
2608
- updateWireframeMesh(particle.particleMesh.mesh, this.wireframeMesh, WireframeGeometryType.quad);
2609
- this.wireframeMesh.worldMatrix = particle.particleMesh.mesh.worldMatrix;
2610
- }
2611
- }
2612
- }
2613
- else if (this.subType === exports.GizmoSubType.modelWireframe) { // 模型线框
2614
- if (this.wireframeMesh && this.targetItem) {
2615
- var meshes = this.targetItem.content.mriMeshs;
2616
- var wireframeMeshes = this.wireframeMeshes;
2617
- if ((meshes === null || meshes === void 0 ? void 0 : meshes.length) > 0) {
2618
- for (var i = 0; i < meshes.length; i++) {
2619
- updateWireframeMesh(meshes[i], wireframeMeshes[i], WireframeGeometryType.triangle);
2620
- }
2621
- }
2622
- }
2623
- }
2624
- else { // 几何体模型
2625
- if (this.targetItem) {
2626
- if (this.contents) { // 组合几何体
2627
- // const targetTransform = this.targetItem.transform.clone();
2628
- var worldPos = new Vector3();
2629
- var worldQuat = new Quaternion();
2630
- var worldScale = new Vector3(1, 1, 1);
2631
- this.targetItem.transform.assignWorldTRS(worldPos, worldQuat);
2632
- var targetTransform = new effects.Transform({
2633
- position: worldPos,
2634
- quat: worldQuat,
2635
- scale: worldScale,
2636
- valid: true,
2637
- });
2638
- // 移动\旋转\缩放gizmo去除近大远小
2639
- if (this.subType === exports.GizmoSubType.rotation || this.subType === exports.GizmoSubType.scale || this.subType === exports.GizmoSubType.translation) {
2640
- var camera = this.composition.camera;
2641
- var cameraPos = camera.position || new Vector3();
2642
- var itemPos = targetTransform.position;
2643
- var newPos = moveToPointWidthFixDistance(cameraPos, itemPos);
2644
- targetTransform.setPosition(newPos.x, newPos.y, newPos.z);
2645
- }
2646
- this.mat = targetTransform.getWorldMatrix();
2647
- var center = targetTransform.position;
2648
- try {
2649
- for (var _b = __values(this.contents), _c = _b.next(); !_c.done; _c = _b.next()) {
2650
- var _d = __read(_c.value, 2), mesh = _d[0], transform = _d[1];
2651
- var worldMat4 = void 0;
2652
- transform.parentTransform = targetTransform;
2653
- var position = new Vector3();
2654
- transform.assignWorldTRS(position);
2655
- // 物体和中心点在屏幕空间上投影的距离
2656
- var distanceToCneter = 100;
2657
- var theta = 1;
2658
- if (this.subType === exports.GizmoSubType.viewHelper) {
2659
- // 正交投影只需要计算物体在XY平面上的投影与中心点的距离
2660
- if (mesh.name === 'sprite') {
2661
- distanceToCneter = position.toVector2().distance(center.toVector2());
2662
- theta = this.boundingMap.get('posX').radius;
2663
- }
2664
- // 将物体挂到相机的transform上
2665
- var fov = 30; // 指定fov角度
2666
- var screenWidth = this.composition.renderer.getWidth();
2667
- var screenHeight = this.composition.renderer.getHeight();
2668
- var distance = 16; // 指定物体与相机的距离
2669
- var width = 2 * Math.tan(fov * Math.PI / 360) * distance;
2670
- var aspect = screenWidth / screenHeight;
2671
- var height = width / aspect;
2672
- var cameraModelMat4 = this.composition.camera.getInverseViewMatrix();
2673
- var padding = this.size.padding || 1; // 指定viewHelper与屏幕右上角的边距
2674
- var localMat = void 0;
2675
- localMat = transform.getWorldMatrix();
2676
- var worldTransform = new effects.Transform({
2677
- valid: true,
2678
- });
2679
- worldTransform.cloneFromMatrix(localMat);
2680
- worldTransform.setPosition((position.x + width / 2) - padding, (position.y + height / 2) - padding, position.z);
2681
- localMat = worldTransform.getWorldMatrix();
2682
- worldMat4 = cameraModelMat4.clone().multiply(localMat);
2683
- // 正交投影到屏幕上
2684
- var proMat5 = computeOrthographicOffCenter(-width / 2, width / 2, -height / 2, height / 2, -distance, distance);
2685
- mesh.material.setMatrix('_MatrixP', proMat5);
2686
- }
2687
- else {
2688
- if (this.subType === exports.GizmoSubType.rotation) {
2689
- var cameraPos = this.composition.camera.position || [0, 0, 0];
2690
- mesh.material.setVector3('u_cameraPos', cameraPos);
2691
- mesh.material.setVector3('u_center', center);
2692
- }
2693
- worldMat4 = transform.getWorldMatrix();
2694
- // TODO 计算物体和中心点在屏幕空间上投影的距离 distanceToCneter
2695
- }
2696
- mesh.material.setMatrix('u_model', worldMat4);
2697
- // 使用distanceToCneter处理坐标轴旋转到中心点附近时的遮挡问题
2698
- if (distanceToCneter < theta) {
2699
- if (distanceToCneter < theta * 0.5) {
2700
- mesh.material.setVector2('u_alpha', new Vector2(0, 0));
2701
- }
2702
- else {
2703
- mesh.material.setVector2('u_alpha', new Vector2((2 / theta) * distanceToCneter - 1, 0));
2704
- }
2705
- }
2706
- }
2707
- }
2708
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
2709
- finally {
2710
- try {
2711
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2712
- }
2713
- finally { if (e_2) throw e_2.error; }
2714
- }
2715
- }
2716
- if (this.content) { // 基础几何体
2717
- var worldPos = new Vector3();
2718
- var worldQuat = new Quaternion();
2719
- var worldSca = new Vector3(1, 1, 1);
2720
- this.targetItem.transform.assignWorldTRS(worldPos, worldQuat);
2721
- var targetTransform = new effects.Transform({
2722
- position: worldPos,
2723
- quat: worldQuat,
2724
- scale: worldSca,
2725
- valid: true,
2726
- });
2727
- if (this.subType === exports.GizmoSubType.light || this.subType === exports.GizmoSubType.camera) {
2728
- var camera = this.composition.camera;
2729
- var cameraPos = camera.position || new Vector3(0, 0, 0);
2730
- var itemPos = targetTransform.position;
2731
- var newPos = moveToPointWidthFixDistance(cameraPos, itemPos);
2732
- targetTransform.setPosition(newPos.x, newPos.y, newPos.z);
2733
- }
2734
- this.mat = targetTransform.getWorldMatrix();
2735
- this.content.material.setMatrix('u_model', targetTransform.getWorldMatrix());
2736
- }
2737
- }
2763
+ GizmoComponent.prototype.fromData = function (data) {
2764
+ _super.prototype.fromData.call(this, data);
2765
+ var item = this.item;
2766
+ var options = data;
2767
+ item.duration = 999;
2768
+ var opt = options.content.options;
2769
+ item.target = opt.target;
2770
+ item.subType = opt.subType;
2771
+ this.renderMode = opt.renderMode || this.getDefaultRenderMode();
2772
+ item.size = opt.size || this.getDefaultSize();
2773
+ this.depthTest = opt.depthTest;
2774
+ var c = (opt.color || [255, 255, 255]);
2775
+ this.color = [c[0] / 255, c[1] / 255, c[2] / 255];
2776
+ //@ts-expect-error
2777
+ if (options.content) {
2778
+ item.transform = new effects.Transform(options.content.transform);
2738
2779
  }
2739
2780
  };
2781
+ return GizmoComponent;
2782
+ }(effects.ItemBehaviour));
2783
+
2784
+ var Matrix4 = effects.math.Matrix4; effects.math.Vector2; var Vector3$1 = effects.math.Vector3;
2785
+ /**
2786
+ * 线条包围盒射线检测算法
2787
+ * @param out - 射线与包围盒交点位置
2788
+ * @param pointInCanvas - 归一化的画布交互点坐标
2789
+ * @param points - 线条包围盒两端点位置
2790
+ * @param radius - 线条包围盒辐射半径
2791
+ * @param camera - 相机对象
2792
+ * @returns 射线与包围盒交点位置 | undefined
2793
+ */
2794
+ function intersectRayLine(out, pointInCanvas, points, radius, worldMat4, camera) {
2795
+ // 构造一个辐射半径边缘的点 radiusPoint
2796
+ var up = new Vector3$1(worldMat4.elements[1], worldMat4.elements[5], worldMat4.elements[9]).normalize();
2797
+ var radiusPoint = up.clone().multiply(radius);
2798
+ radiusPoint.add(points[0]);
2799
+ // 计算 start、end、radius 在屏幕空间上的投影
2800
+ var mvpMat4 = camera.getModelViewProjection(new Matrix4(), worldMat4);
2801
+ var screenStart = mvpMat4.projectPoint(points[0], new Vector3$1());
2802
+ var screenEnd = mvpMat4.projectPoint(points[1], new Vector3$1());
2803
+ var screenRadiusPoint = mvpMat4.projectPoint(radiusPoint, new Vector3$1());
2804
+ var screenRadiusVector = screenRadiusPoint.clone().subtract(screenStart);
2805
+ var screenRadius = screenRadiusVector.length();
2806
+ // 计算屏幕交互点与线条的距离
2807
+ var _a = distanceOfPointAndLine(pointInCanvas, [screenStart.toVector2(), screenEnd.toVector2()]), distance = _a.distance, isInLine = _a.isInLine;
2808
+ if (distance <= screenRadius && isInLine) { // 距离小于阈值且交互点在线条上的投影位于线段内
2809
+ // 计算交互点在线条上的投影并转换为世界坐标
2810
+ var screenPosition = projectionOfPointAndLine(pointInCanvas, [screenStart, screenEnd]);
2811
+ var inverseViewProjection = camera.getInverseViewProjectionMatrix();
2812
+ inverseViewProjection.projectPoint(screenPosition, out);
2813
+ return out;
2814
+ }
2815
+ }
2816
+
2817
+ effects.math.Vector2; var Vector3 = effects.math.Vector3; effects.math.Matrix4; effects.math.Ray; var Quaternion = effects.math.Quaternion;
2818
+ /**
2819
+ * 包围盒类型
2820
+ */
2821
+ var BoundingType;
2822
+ (function (BoundingType) {
2823
+ BoundingType[BoundingType["box"] = 0] = "box";
2824
+ BoundingType[BoundingType["sphere"] = 1] = "sphere";
2825
+ BoundingType[BoundingType["triangle"] = 2] = "triangle";
2826
+ BoundingType[BoundingType["line"] = 3] = "line";
2827
+ })(BoundingType || (BoundingType = {}));
2828
+ /**
2829
+ *
2830
+ */
2831
+ var GizmoVFXItem = /** @class */ (function (_super) {
2832
+ __extends(GizmoVFXItem, _super);
2833
+ function GizmoVFXItem(engine, props) {
2834
+ var _this = _super.call(this, engine, props) || this;
2835
+ _this.boundingMap = new Map();
2836
+ var gizmoComponent = _this.addComponent(GizmoComponent);
2837
+ if (props) {
2838
+ gizmoComponent.fromData(props);
2839
+ }
2840
+ return _this;
2841
+ }
2842
+ Object.defineProperty(GizmoVFXItem.prototype, "content", {
2843
+ get: function () {
2844
+ return this._content;
2845
+ },
2846
+ set: function (content) {
2847
+ },
2848
+ enumerable: false,
2849
+ configurable: true
2850
+ });
2740
2851
  /**
2741
2852
  * 射线检测算法
2742
2853
  * @returns 包含射线检测算法回调方法的参数
@@ -2787,7 +2898,7 @@ var GizmoVFXItem = /** @class */ (function (_super) {
2787
2898
  * @returns
2788
2899
  */
2789
2900
  collect: function (ray, pointInCanvas) {
2790
- var e_3, _a;
2901
+ var e_1, _a;
2791
2902
  var hitPositions = [];
2792
2903
  self_1.hitBounding = undefined;
2793
2904
  var _loop_1 = function (key) {
@@ -2921,12 +3032,12 @@ var GizmoVFXItem = /** @class */ (function (_super) {
2921
3032
  _loop_1(key);
2922
3033
  }
2923
3034
  }
2924
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
3035
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2925
3036
  finally {
2926
3037
  try {
2927
3038
  if (boundingKeys_2_1 && !boundingKeys_2_1.done && (_a = boundingKeys_2.return)) _a.call(boundingKeys_2);
2928
3039
  }
2929
- finally { if (e_3) throw e_3.error; }
3040
+ finally { if (e_1) throw e_1.error; }
2930
3041
  }
2931
3042
  if (hitPositions.length === 0) {
2932
3043
  self_1.hitBounding = undefined;
@@ -3020,68 +3131,57 @@ var EditorGizmoPlugin = /** @class */ (function (_super) {
3020
3131
  composition.loaderData.gizmoTarget = targetMap;
3021
3132
  composition.loaderData.gizmoItems = [];
3022
3133
  };
3023
- EditorGizmoPlugin.prototype.onCompositionItemLifeBegin = function (composition, item) {
3024
- var e_2, _a;
3025
- if (item.type === '7') {
3026
- return;
3027
- }
3028
- var gizmoVFXItemList = composition.loaderData.gizmoTarget[item.id];
3029
- if (gizmoVFXItemList && gizmoVFXItemList.length > 0) {
3030
- try {
3031
- for (var gizmoVFXItemList_1 = __values(gizmoVFXItemList), gizmoVFXItemList_1_1 = gizmoVFXItemList_1.next(); !gizmoVFXItemList_1_1.done; gizmoVFXItemList_1_1 = gizmoVFXItemList_1.next()) {
3032
- var gizmoVFXItem = gizmoVFXItemList_1_1.value;
3033
- switch (gizmoVFXItem.subType) {
3034
- case exports.GizmoSubType.particleEmitter:
3035
- gizmoVFXItem.createParticleContent(item, this.meshToAdd);
3036
- break;
3037
- case exports.GizmoSubType.modelWireframe:
3038
- gizmoVFXItem.createModelContent(item, this.meshToAdd);
3039
- break;
3040
- case exports.GizmoSubType.box:
3041
- case exports.GizmoSubType.sphere:
3042
- case exports.GizmoSubType.cylinder:
3043
- case exports.GizmoSubType.cone:
3044
- case exports.GizmoSubType.torus:
3045
- case exports.GizmoSubType.sprite:
3046
- case exports.GizmoSubType.frustum:
3047
- case exports.GizmoSubType.directionLight:
3048
- case exports.GizmoSubType.pointLight:
3049
- case exports.GizmoSubType.spotLight:
3050
- case exports.GizmoSubType.floorGrid:
3051
- gizmoVFXItem.createBasicContent(item, this.meshToAdd, gizmoVFXItem.subType);
3052
- break;
3053
- case exports.GizmoSubType.camera:
3054
- case exports.GizmoSubType.light:
3055
- gizmoVFXItem.createBasicContent(item, this.meshToAdd, gizmoVFXItem.subType, iconTextures);
3056
- break;
3057
- case exports.GizmoSubType.rotation:
3058
- case exports.GizmoSubType.scale:
3059
- case exports.GizmoSubType.translation:
3060
- gizmoVFXItem.createCombinationContent(item, this.meshToAdd, gizmoVFXItem.subType);
3061
- break;
3062
- case exports.GizmoSubType.viewHelper:
3063
- gizmoVFXItem.createCombinationContent(item, this.meshToAdd, gizmoVFXItem.subType, iconTextures);
3064
- break;
3065
- case exports.GizmoSubType.boundingBox:
3066
- gizmoVFXItem.createBoundingBoxContent(item, this.meshToAdd);
3067
- break;
3068
- default:
3069
- break;
3070
- }
3071
- }
3072
- }
3073
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
3074
- finally {
3075
- try {
3076
- if (gizmoVFXItemList_1_1 && !gizmoVFXItemList_1_1.done && (_a = gizmoVFXItemList_1.return)) _a.call(gizmoVFXItemList_1);
3077
- }
3078
- finally { if (e_2) throw e_2.error; }
3079
- }
3080
- }
3081
- if (item.type === GizmoVFXItemType) {
3082
- composition.loaderData.gizmoItems.push(item);
3083
- }
3084
- };
3134
+ // override onCompositionItemLifeBegin (composition: Composition, item: VFXItem<any>) {
3135
+ // if (item.type === '7') {
3136
+ // return;
3137
+ // }
3138
+ // const gizmoVFXItemList: GizmoVFXItem[] = composition.loaderData.gizmoTarget[item.id];
3139
+ // if (gizmoVFXItemList && gizmoVFXItemList.length > 0) {
3140
+ // for (const gizmoVFXItem of gizmoVFXItemList) {
3141
+ // switch (gizmoVFXItem.subType) {
3142
+ // case GizmoSubType.particleEmitter:
3143
+ // gizmoVFXItem.createParticleContent(item, this.meshToAdd);
3144
+ // break;
3145
+ // case GizmoSubType.modelWireframe:
3146
+ // gizmoVFXItem.createModelContent(item, this.meshToAdd);
3147
+ // break;
3148
+ // case GizmoSubType.box:
3149
+ // case GizmoSubType.sphere:
3150
+ // case GizmoSubType.cylinder:
3151
+ // case GizmoSubType.cone:
3152
+ // case GizmoSubType.torus:
3153
+ // case GizmoSubType.sprite:
3154
+ // case GizmoSubType.frustum:
3155
+ // case GizmoSubType.directionLight:
3156
+ // case GizmoSubType.pointLight:
3157
+ // case GizmoSubType.spotLight:
3158
+ // case GizmoSubType.floorGrid:
3159
+ // gizmoVFXItem.createBasicContent(item, this.meshToAdd, gizmoVFXItem.subType);
3160
+ // break;
3161
+ // case GizmoSubType.camera:
3162
+ // case GizmoSubType.light:
3163
+ // gizmoVFXItem.createBasicContent(item, this.meshToAdd, gizmoVFXItem.subType, iconTextures);
3164
+ // break;
3165
+ // case GizmoSubType.rotation:
3166
+ // case GizmoSubType.scale:
3167
+ // case GizmoSubType.translation:
3168
+ // gizmoVFXItem.createCombinationContent(item, this.meshToAdd, gizmoVFXItem.subType);
3169
+ // break;
3170
+ // case GizmoSubType.viewHelper:
3171
+ // gizmoVFXItem.createCombinationContent(item, this.meshToAdd, gizmoVFXItem.subType, iconTextures);
3172
+ // break;
3173
+ // case GizmoSubType.boundingBox:
3174
+ // gizmoVFXItem.createBoundingBoxContent(item, this.meshToAdd);
3175
+ // break;
3176
+ // default:
3177
+ // break;
3178
+ // }
3179
+ // }
3180
+ // }
3181
+ // if (item.type === GizmoVFXItemType) {
3182
+ // composition.loaderData.gizmoItems.push(item);
3183
+ // }
3184
+ // }
3085
3185
  EditorGizmoPlugin.prototype.onCompositionItemRemoved = function (composition, item) {
3086
3186
  var _this = this;
3087
3187
  if (item.type === GizmoVFXItemType) {
@@ -3097,7 +3197,7 @@ var EditorGizmoPlugin = /** @class */ (function (_super) {
3097
3197
  }
3098
3198
  };
3099
3199
  EditorGizmoPlugin.prototype.removeGizmoItem = function (composition, gizmoVFXItem) {
3100
- var e_3, _a;
3200
+ var e_2, _a;
3101
3201
  var _this = this;
3102
3202
  if (gizmoVFXItem.content && !gizmoVFXItem.content.isDestroyed) {
3103
3203
  gizmoVFXItem.content.dispose();
@@ -3123,16 +3223,17 @@ var EditorGizmoPlugin = /** @class */ (function (_super) {
3123
3223
  }
3124
3224
  }
3125
3225
  }
3126
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
3226
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
3127
3227
  finally {
3128
3228
  try {
3129
3229
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3130
3230
  }
3131
- finally { if (e_3) throw e_3.error; }
3231
+ finally { if (e_2) throw e_2.error; }
3132
3232
  }
3133
3233
  }
3134
- if (gizmoVFXItem.wireframeMeshes.length > 0) {
3135
- gizmoVFXItem.wireframeMeshes.forEach(function (mesh) {
3234
+ var gizmoComponent = gizmoVFXItem.getComponent(GizmoComponent);
3235
+ if (gizmoComponent && gizmoComponent.wireframeMeshes.length > 0) {
3236
+ gizmoComponent.wireframeMeshes.forEach(function (mesh) {
3136
3237
  if (!mesh.isDestroyed) {
3137
3238
  destroyWireframeMesh(mesh);
3138
3239
  _this.getEditorRenderPass(composition.renderFrame).removeMesh(mesh);
@@ -3175,9 +3276,10 @@ var EditorGizmoPlugin = /** @class */ (function (_super) {
3175
3276
  else {
3176
3277
  _this.getEditorRenderPass(renderFrame).removeMesh(mesh);
3177
3278
  }
3279
+ effects.removeItem(_this.meshToAdd, mesh);
3178
3280
  });
3179
- this.meshToAdd.length = this.meshToRemove.length = 0;
3180
- composition.loaderData.gizmoItems.forEach(function (item) { return item.updateRenderData(); });
3281
+ this.meshToRemove.length = 0;
3282
+ // composition.loaderData.gizmoItems.forEach((item: GizmoVFXItem) => item.updateRenderData());
3181
3283
  return false;
3182
3284
  };
3183
3285
  EditorGizmoPlugin.prototype.getBehindRenderPass = function (pipeline) {
@@ -3220,7 +3322,7 @@ var EditorGizmoPlugin = /** @class */ (function (_super) {
3220
3322
  }(effects.AbstractPlugin));
3221
3323
 
3222
3324
  effects.registerPlugin('editor-gizmo', EditorGizmoPlugin, GizmoVFXItem);
3223
- var version = "1.2.3";
3325
+ var version = "2.0.0-alpha.1";
3224
3326
  effects.logger.info('plugin editor gizmo version: ' + version);
3225
3327
 
3226
3328
  exports.DirectionLightData = DirectionLightData;