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