@galacean/effects-plugin-editor-gizmo 2.7.3 → 2.8.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3,11 +3,11 @@
3
3
  * Description: Galacean Effects player editor gizmo plugin
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 茂安,旻诺
6
- * Version: v2.7.3
6
+ * Version: v2.8.0-alpha.0
7
7
  */
8
8
 
9
9
  import * as EFFECTS from '@galacean/effects';
10
- import { math, DestroyOptions, glContext, GLSLVersion, Material, Mesh, GLGeometry, Texture, noop, Geometry, Transform, serialize, effectsClass, RendererComponent, ParticleSystemRenderer, assertExist, HitTestType, spec, removeItem, RenderPass, RenderPassPriorityPostprocess, TextureLoadAction, RenderPassPriorityPrepare, AbstractPlugin, registerPlugin, VFXItem, logger } from '@galacean/effects';
10
+ import { glContext, Texture, noop, math, Geometry, Transform, Mesh, Material, DestroyOptions, GLSLVersion, GLGeometry, serialize, effectsClass, RendererComponent, ParticleSystemRenderer, assertExist, RenderPass, RenderPassPriorityPostprocess, TextureLoadAction, RenderPassPriorityPrepare, HitTestType, spec, AbstractPlugin, registerPlugin, VFXItem, logger } from '@galacean/effects';
11
11
 
12
12
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
13
13
  try {
@@ -201,228 +201,6 @@ typeof SuppressedError === "function" ? SuppressedError : function _SuppressedEr
201
201
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
202
202
  };
203
203
 
204
- var GizmoVFXItemType = "gizmo";
205
- var GizmoSubType;
206
- (function(GizmoSubType) {
207
- GizmoSubType[GizmoSubType["particleEmitter"] = 1] = "particleEmitter";
208
- GizmoSubType[GizmoSubType["modelWireframe"] = 2] = "modelWireframe";
209
- GizmoSubType[GizmoSubType["box"] = 3] = "box";
210
- GizmoSubType[GizmoSubType["sphere"] = 4] = "sphere";
211
- GizmoSubType[GizmoSubType["cylinder"] = 5] = "cylinder";
212
- GizmoSubType[GizmoSubType["cone"] = 6] = "cone";
213
- GizmoSubType[GizmoSubType["torus"] = 7] = "torus";
214
- GizmoSubType[GizmoSubType["sprite"] = 8] = "sprite";
215
- GizmoSubType[GizmoSubType["plane"] = 9] = "plane";
216
- GizmoSubType[GizmoSubType["rotation"] = 10] = "rotation";
217
- GizmoSubType[GizmoSubType["translation"] = 11] = "translation";
218
- GizmoSubType[GizmoSubType["scale"] = 12] = "scale";
219
- GizmoSubType[GizmoSubType["viewHelper"] = 13] = "viewHelper";
220
- GizmoSubType[GizmoSubType["camera"] = 14] = "camera";
221
- GizmoSubType[GizmoSubType["frustum"] = 15] = "frustum";
222
- GizmoSubType[GizmoSubType["light"] = 16] = "light";
223
- GizmoSubType[GizmoSubType["directionLight"] = 17] = "directionLight";
224
- GizmoSubType[GizmoSubType["pointLight"] = 18] = "pointLight";
225
- GizmoSubType[GizmoSubType["spotLight"] = 19] = "spotLight";
226
- GizmoSubType[GizmoSubType["boundingBox"] = 20] = "boundingBox";
227
- GizmoSubType[GizmoSubType["floorGrid"] = 21] = "floorGrid";
228
- })(GizmoSubType || (GizmoSubType = {}));
229
-
230
- function _extends() {
231
- _extends = Object.assign || function assign(target) {
232
- for(var i = 1; i < arguments.length; i++){
233
- var source = arguments[i];
234
- for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
235
- }
236
- return target;
237
- };
238
- return _extends.apply(this, arguments);
239
- }
240
-
241
- var Vector4 = math.Vector4;
242
- var WireframeGeometryType;
243
- (function(WireframeGeometryType) {
244
- WireframeGeometryType[WireframeGeometryType["triangle"] = 0] = "triangle";
245
- WireframeGeometryType[WireframeGeometryType["quad"] = 1] = "quad";
246
- })(WireframeGeometryType || (WireframeGeometryType = {}));
247
- function destroyWireframeMesh(mesh) {
248
- var _mesh_geometry;
249
- (_mesh_geometry = mesh.geometry) == null ? void 0 : _mesh_geometry.dispose();
250
- mesh.dispose({
251
- geometries: DestroyOptions.keep
252
- });
253
- }
254
- function updateWireframeMesh(originGeometry, originMaterial, wireframe, type) {
255
- wireframe.material.cloneUniforms(originMaterial);
256
- var geometry = originGeometry;
257
- var wireframeGeometry = wireframe.firstGeometry();
258
- for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(originMaterial.enabledMacros)), _step; !(_step = _iterator()).done;){
259
- var macro = _step.value;
260
- wireframe.material.enableMacro(macro, originMaterial.enabledMacros[macro]);
261
- }
262
- if (type === 0) {
263
- // 线框模式不绘制模型的时候,drawCount 为负数
264
- var drawCount = Math.abs(geometry.getDrawCount());
265
- if (drawCount !== 0) {
266
- if (drawCount !== wireframeGeometry.getDrawCount() / 2) {
267
- var indexData = geometry.getIndexData();
268
- var data = indexData ? getTriangleIndexData(indexData) : getTriangleIndexDataByCount(drawCount);
269
- wireframeGeometry.setIndexData(data);
270
- wireframeGeometry.setDrawCount(data.length);
271
- }
272
- }
273
- } else if (type === 1) {
274
- if (geometry.getDrawCount() / 6 !== wireframeGeometry.getDrawCount() / 8) {
275
- var data1 = getQuadIndexData(geometry.getDrawCount() / 6, geometry.getIndexData());
276
- wireframeGeometry.setIndexData(data1);
277
- wireframeGeometry.setDrawCount(data1.length);
278
- }
279
- }
280
- return wireframe;
281
- }
282
- function getQuadIndexData(faceCount, oid) {
283
- var indexData = new Uint16Array(faceCount * 8);
284
- for(var i = 0; i < faceCount; i++){
285
- var idx = i * 8;
286
- var base = i * 4;
287
- indexData[idx] = base;
288
- indexData[idx + 1] = 1 + base;
289
- indexData[idx + 2] = 1 + base;
290
- indexData[idx + 3] = 3 + base;
291
- indexData[idx + 4] = 3 + base;
292
- indexData[idx + 5] = 2 + base;
293
- indexData[idx + 6] = 2 + base;
294
- indexData[idx + 7] = base;
295
- }
296
- return indexData;
297
- }
298
- function createModeWireframe(engine, mesh, color) {
299
- var geometry = new SharedGeometry(engine, {
300
- geometry: mesh.firstGeometry(),
301
- mode: glContext.LINES,
302
- index: {
303
- data: new Uint32Array(0)
304
- }
305
- });
306
- var _mesh_material_shader_shaderData = mesh.material.shader.shaderData, vertex = _mesh_material_shader_shaderData.vertex, fragment = _mesh_material_shader_shaderData.fragment;
307
- var materialOptions = _extends({}, mesh.material.props);
308
- var newMacros = [
309
- [
310
- "PREVIEW_BORDER",
311
- 1
312
- ]
313
- ];
314
- var _mesh_name;
315
- materialOptions.shader = {
316
- vertex: vertex,
317
- fragment: fragment,
318
- macros: newMacros,
319
- shared: true,
320
- name: ((_mesh_name = mesh.name) != null ? _mesh_name : "unamedmesh") + "_wireframe",
321
- glslVersion: engine.gpuCapability.level === 2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1
322
- };
323
- var material = Material.create(engine, materialOptions);
324
- material.depthTest = true;
325
- material.setVector4("uPreviewColor", new Vector4(color[0], color[1], color[2], 1));
326
- return updateWireframeMesh(mesh.geometry, mesh.material, Mesh.create(engine, {
327
- geometry: geometry,
328
- material: material,
329
- priority: 3000,
330
- name: materialOptions.shader.name
331
- }), 0);
332
- }
333
- function getTriangleIndexDataByCount(drawCount) {
334
- var faceCount = drawCount / 3;
335
- var indexData = new Uint32Array(faceCount * 6);
336
- for(var i = 0; i < faceCount; i++){
337
- var idx = i * 6;
338
- var p0 = i * 3;
339
- var p1 = p0 + 1;
340
- var p2 = p0 + 2;
341
- indexData[idx] = p0;
342
- indexData[idx + 1] = p1;
343
- indexData[idx + 2] = p1;
344
- indexData[idx + 3] = p2;
345
- indexData[idx + 4] = p2;
346
- indexData[idx + 5] = p0;
347
- }
348
- return indexData;
349
- }
350
- function getTriangleIndexData(oid) {
351
- var faceCount = oid.length / 3;
352
- var indexData = new Uint32Array(faceCount * 6);
353
- for(var i = 0; i < faceCount; i++){
354
- var idx = i * 6;
355
- var base = i * 3;
356
- var p0 = oid[base];
357
- var p1 = oid[base + 1];
358
- var p2 = oid[base + 2];
359
- indexData[idx] = p0;
360
- indexData[idx + 1] = p1;
361
- indexData[idx + 2] = p1;
362
- indexData[idx + 3] = p2;
363
- indexData[idx + 4] = p2;
364
- indexData[idx + 5] = p0;
365
- }
366
- return indexData;
367
- }
368
- var SharedGeometry = /*#__PURE__*/ function(GLGeometry) {
369
- _inherits(SharedGeometry, GLGeometry);
370
- function SharedGeometry(engine, options) {
371
- var _this;
372
- _this = GLGeometry.call(this, engine, _extends({
373
- attributes: {}
374
- }, options)) || this;
375
- var indexData = options.index ? options.index.data : options.geometry.getIndexData();
376
- if (indexData) {
377
- //@ts-expect-error safe to assign
378
- indexData = new indexData.constructor(indexData);
379
- }
380
- _this.indices = indexData;
381
- _this.source = options.geometry;
382
- _this.drawCount = options.drawCount || 0;
383
- _this.drawStart = options.drawStart || 0;
384
- _this.mode = options.mode || 0;
385
- for(var name in _this.source.attributes){
386
- _this.attributes[name] = _extends({}, _this.source.attributes[name]);
387
- }
388
- return _this;
389
- }
390
- var _proto = SharedGeometry.prototype;
391
- _proto.initialize = function initialize() {
392
- if (!this.isInitialized) {
393
- var geometry = this.source;
394
- geometry.initialize();
395
- //this.indicesBuffer = this._source.indicesBuffer;
396
- this.buffers = this.source.buffers;
397
- this.bufferProps = this.source.bufferProps;
398
- //this.dirtyFlags = this._source.dirtyFlags;
399
- //this.vaos = this._source.vaos;
400
- //创建ibo
401
- if (this.indices) {
402
- this.indicesBuffer = this.createIndicesBuffer(this.indices);
403
- }
404
- this.flush();
405
- this.initialized = true;
406
- }
407
- };
408
- _proto.getAttributeNames = function getAttributeNames() {
409
- return this.source.getAttributeNames();
410
- };
411
- _proto.flush = function flush() {
412
- this.source.flush();
413
- GLGeometry.prototype.flush.call(this);
414
- };
415
- _proto.dispose = function dispose() {
416
- // from source geometry
417
- this.buffers = {};
418
- this.bufferProps = {};
419
- GLGeometry.prototype.dispose.call(this);
420
- // @ts-expect-error
421
- this.source = null;
422
- };
423
- return SharedGeometry;
424
- }(GLGeometry);
425
-
426
204
  // 坐标轴默认颜色
427
205
  var color = {
428
206
  xAxisColor: [
@@ -493,18 +271,133 @@ function _createImage() {
493
271
  }
494
272
  return texture;
495
273
  }
496
- /**
497
- * 移动到距离目标点指定距离的位置
498
- * @param targetPos - 目标点
499
- * @param currentPos - 当前点
500
- * @returns 指定点
501
- */ function moveToPointWidthFixDistance(targetPos, currentPos) {
502
- var vecCameraItem = currentPos.clone().subtract(targetPos);
503
- var normalVecCameraItem = vecCameraItem.clone().normalize();
504
- var scalerVecCameraItem = normalVecCameraItem.clone().multiply(20);
505
- var vecScalerItem = vecCameraItem.clone().subtract(scalerVecCameraItem);
506
- var vecItemScaler = vecScalerItem.clone().multiply(-1);
507
- return currentPos.clone().add(vecItemScaler);
274
+ /**
275
+ * 移动到距离目标点指定距离的位置
276
+ * @param targetPos - 目标点
277
+ * @param currentPos - 当前点
278
+ * @returns 指定点
279
+ */ function moveToPointWidthFixDistance(targetPos, currentPos) {
280
+ var vecCameraItem = currentPos.clone().subtract(targetPos);
281
+ var normalVecCameraItem = vecCameraItem.clone().normalize();
282
+ var scalerVecCameraItem = normalVecCameraItem.clone().multiply(20);
283
+ var vecScalerItem = vecCameraItem.clone().subtract(scalerVecCameraItem);
284
+ var vecItemScaler = vecScalerItem.clone().multiply(-1);
285
+ return currentPos.clone().add(vecItemScaler);
286
+ }
287
+
288
+ var GizmoSubType;
289
+ (function(GizmoSubType) {
290
+ GizmoSubType[GizmoSubType["particleEmitter"] = 1] = "particleEmitter";
291
+ GizmoSubType[GizmoSubType["modelWireframe"] = 2] = "modelWireframe";
292
+ GizmoSubType[GizmoSubType["box"] = 3] = "box";
293
+ GizmoSubType[GizmoSubType["sphere"] = 4] = "sphere";
294
+ GizmoSubType[GizmoSubType["cylinder"] = 5] = "cylinder";
295
+ GizmoSubType[GizmoSubType["cone"] = 6] = "cone";
296
+ GizmoSubType[GizmoSubType["torus"] = 7] = "torus";
297
+ GizmoSubType[GizmoSubType["sprite"] = 8] = "sprite";
298
+ GizmoSubType[GizmoSubType["plane"] = 9] = "plane";
299
+ GizmoSubType[GizmoSubType["rotation"] = 10] = "rotation";
300
+ GizmoSubType[GizmoSubType["translation"] = 11] = "translation";
301
+ GizmoSubType[GizmoSubType["scale"] = 12] = "scale";
302
+ GizmoSubType[GizmoSubType["viewHelper"] = 13] = "viewHelper";
303
+ GizmoSubType[GizmoSubType["camera"] = 14] = "camera";
304
+ GizmoSubType[GizmoSubType["frustum"] = 15] = "frustum";
305
+ GizmoSubType[GizmoSubType["light"] = 16] = "light";
306
+ GizmoSubType[GizmoSubType["directionLight"] = 17] = "directionLight";
307
+ GizmoSubType[GizmoSubType["pointLight"] = 18] = "pointLight";
308
+ GizmoSubType[GizmoSubType["spotLight"] = 19] = "spotLight";
309
+ GizmoSubType[GizmoSubType["boundingBox"] = 20] = "boundingBox";
310
+ GizmoSubType[GizmoSubType["floorGrid"] = 21] = "floorGrid";
311
+ })(GizmoSubType || (GizmoSubType = {}));
312
+
313
+ math.Vector3; math.Ray;
314
+ var BoundingType;
315
+ (function(BoundingType) {
316
+ BoundingType[BoundingType["box"] = 0] = "box";
317
+ BoundingType[BoundingType["sphere"] = 1] = "sphere";
318
+ BoundingType[BoundingType["triangle"] = 2] = "triangle";
319
+ BoundingType[BoundingType["line"] = 3] = "line";
320
+ })(BoundingType || (BoundingType = {}));
321
+
322
+ var Matrix4$5 = math.Matrix4, Vector2$2 = math.Vector2;
323
+ function distanceOfPointAndLine(point, line) {
324
+ //三角形三个边长
325
+ var AC = new Vector2$2();
326
+ var BC = new Vector2$2();
327
+ var AB = new Vector2$2();
328
+ AC.subtractVectors(point, line[0]);
329
+ BC.subtractVectors(point, line[1]);
330
+ AB.subtractVectors(line[1], line[0]);
331
+ var lengthAC = AC.length();
332
+ var lengthBC = BC.length();
333
+ var lengthAB = AB.length();
334
+ //利用海伦公式计算三角形面积
335
+ //周长的一半
336
+ var P = (lengthAC + lengthBC + lengthAB) / 2;
337
+ var allArea = Math.abs(Math.sqrt(P * (P - lengthAC) * (P - lengthBC) * (P - lengthAB)));
338
+ //普通公式计算三角形面积反推点到线的垂直距离
339
+ var distance = 2 * allArea / lengthAB;
340
+ var l1 = Math.sqrt(Math.pow(lengthAC, 2) - Math.pow(distance, 2));
341
+ var l2 = Math.sqrt(Math.pow(lengthBC, 2) - Math.pow(distance, 2));
342
+ var isInLine = false;
343
+ if (l1 <= lengthAB && l2 <= lengthAB) {
344
+ isInLine = true;
345
+ }
346
+ return {
347
+ distance: distance,
348
+ isInLine: isInLine
349
+ };
350
+ }
351
+ function projectionOfPointAndLine(point, line) {
352
+ var AC = new Vector2$2();
353
+ var BC = new Vector2$2();
354
+ var AB = new Vector2$2();
355
+ var line0 = line[0].toVector2();
356
+ var line1 = line[1].toVector2();
357
+ AC.subtractVectors(point, line0);
358
+ BC.subtractVectors(point, line1);
359
+ AB.subtractVectors(line1, line0);
360
+ var lengthAC = AC.length();
361
+ var lengthBC = BC.length();
362
+ var lengthAB = AB.length();
363
+ //利用海伦公式计算三角形面积
364
+ //周长的一半
365
+ var P = (lengthAC + lengthBC + lengthAB) / 2;
366
+ var allArea = Math.abs(Math.sqrt(P * (P - lengthAC) * (P - lengthBC) * (P - lengthAB)));
367
+ //普通公式计算三角形面积反推点到线的垂直距离
368
+ var distance = 2 * allArea / lengthAB;
369
+ var l1 = Math.sqrt(Math.pow(lengthAC, 2) - Math.pow(distance, 2));
370
+ var l2 = Math.sqrt(Math.pow(lengthBC, 2) - Math.pow(distance, 2));
371
+ var worldAB = line[1].clone().subtract(line[0]);
372
+ var worldAP = worldAB.clone().multiply(l1 / (l1 + l2));
373
+ var worldP = line[0].clone().add(worldAP);
374
+ return worldP;
375
+ }
376
+ function computeOrthographicOffCenter(left, right, bottom, top, near, far) {
377
+ var a = 1.0 / (right - left);
378
+ var b = 1.0 / (top - bottom);
379
+ var c = 1.0 / (far - near);
380
+ var tx = -(right + left) * a;
381
+ var ty = -(top + bottom) * b;
382
+ var tz = -(far + near) * c;
383
+ a *= 2.0;
384
+ b *= 2.0;
385
+ c *= -2.0;
386
+ return new Matrix4$5(a, 0.0, 0.0, 0.0, //
387
+ 0.0, b, 0.0, 0.0, //
388
+ 0.0, 0.0, c, 0.0, //
389
+ tx, ty, tz, 1.0);
390
+ }
391
+
392
+ function _extends() {
393
+ _extends = Object.assign || function assign(target) {
394
+ for(var i = 1; i < arguments.length; i++){
395
+ var source = arguments[i];
396
+ for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
397
+ }
398
+ return target;
399
+ };
400
+ return _extends.apply(this, arguments);
508
401
  }
509
402
 
510
403
  /**
@@ -921,7 +814,7 @@ var Vector3$5 = math.Vector3;
921
814
  return PlaneGeometryData;
922
815
  }(GeometryData);
923
816
 
924
- var Euler$1 = math.Euler, Vector3$4 = math.Vector3, Matrix4$5 = math.Matrix4;
817
+ var Euler$1 = math.Euler, Vector3$4 = math.Vector3, Matrix4$4 = math.Matrix4;
925
818
  /**
926
819
  *
927
820
  */ var FrustumGeometryData = /*#__PURE__*/ function(GeometryData) {
@@ -938,7 +831,7 @@ var Euler$1 = math.Euler, Vector3$4 = math.Vector3, Matrix4$5 = math.Matrix4;
938
831
  var point2 = new Vector3$4(-halfX, halfY, far);
939
832
  var point3 = new Vector3$4(-halfX, -halfY, far);
940
833
  var point4 = new Vector3$4(halfX, -halfY, far);
941
- var matrix = Euler$1.fromArray(rotation).toMatrix4(new Matrix4$5());
834
+ var matrix = Euler$1.fromArray(rotation).toMatrix4(new Matrix4$4());
942
835
  var result1 = matrix.transformPoint(point1).add(position);
943
836
  var result2 = matrix.transformPoint(point2).add(position);
944
837
  var result3 = matrix.transformPoint(point3).add(position);
@@ -1161,85 +1054,6 @@ var GeometryType;
1161
1054
  return result;
1162
1055
  }
1163
1056
 
1164
- math.Vector3; math.Ray;
1165
- var BoundingType;
1166
- (function(BoundingType) {
1167
- BoundingType[BoundingType["box"] = 0] = "box";
1168
- BoundingType[BoundingType["sphere"] = 1] = "sphere";
1169
- BoundingType[BoundingType["triangle"] = 2] = "triangle";
1170
- BoundingType[BoundingType["line"] = 3] = "line";
1171
- })(BoundingType || (BoundingType = {}));
1172
-
1173
- var Matrix4$4 = math.Matrix4, Vector2$2 = math.Vector2;
1174
- function distanceOfPointAndLine(point, line) {
1175
- //三角形三个边长
1176
- var AC = new Vector2$2();
1177
- var BC = new Vector2$2();
1178
- var AB = new Vector2$2();
1179
- AC.subtractVectors(point, line[0]);
1180
- BC.subtractVectors(point, line[1]);
1181
- AB.subtractVectors(line[1], line[0]);
1182
- var lengthAC = AC.length();
1183
- var lengthBC = BC.length();
1184
- var lengthAB = AB.length();
1185
- //利用海伦公式计算三角形面积
1186
- //周长的一半
1187
- var P = (lengthAC + lengthBC + lengthAB) / 2;
1188
- var allArea = Math.abs(Math.sqrt(P * (P - lengthAC) * (P - lengthBC) * (P - lengthAB)));
1189
- //普通公式计算三角形面积反推点到线的垂直距离
1190
- var distance = 2 * allArea / lengthAB;
1191
- var l1 = Math.sqrt(Math.pow(lengthAC, 2) - Math.pow(distance, 2));
1192
- var l2 = Math.sqrt(Math.pow(lengthBC, 2) - Math.pow(distance, 2));
1193
- var isInLine = false;
1194
- if (l1 <= lengthAB && l2 <= lengthAB) {
1195
- isInLine = true;
1196
- }
1197
- return {
1198
- distance: distance,
1199
- isInLine: isInLine
1200
- };
1201
- }
1202
- function projectionOfPointAndLine(point, line) {
1203
- var AC = new Vector2$2();
1204
- var BC = new Vector2$2();
1205
- var AB = new Vector2$2();
1206
- var line0 = line[0].toVector2();
1207
- var line1 = line[1].toVector2();
1208
- AC.subtractVectors(point, line0);
1209
- BC.subtractVectors(point, line1);
1210
- AB.subtractVectors(line1, line0);
1211
- var lengthAC = AC.length();
1212
- var lengthBC = BC.length();
1213
- var lengthAB = AB.length();
1214
- //利用海伦公式计算三角形面积
1215
- //周长的一半
1216
- var P = (lengthAC + lengthBC + lengthAB) / 2;
1217
- var allArea = Math.abs(Math.sqrt(P * (P - lengthAC) * (P - lengthBC) * (P - lengthAB)));
1218
- //普通公式计算三角形面积反推点到线的垂直距离
1219
- var distance = 2 * allArea / lengthAB;
1220
- var l1 = Math.sqrt(Math.pow(lengthAC, 2) - Math.pow(distance, 2));
1221
- var l2 = Math.sqrt(Math.pow(lengthBC, 2) - Math.pow(distance, 2));
1222
- var worldAB = line[1].clone().subtract(line[0]);
1223
- var worldAP = worldAB.clone().multiply(l1 / (l1 + l2));
1224
- var worldP = line[0].clone().add(worldAP);
1225
- return worldP;
1226
- }
1227
- function computeOrthographicOffCenter(left, right, bottom, top, near, far) {
1228
- var a = 1.0 / (right - left);
1229
- var b = 1.0 / (top - bottom);
1230
- var c = 1.0 / (far - near);
1231
- var tx = -(right + left) * a;
1232
- var ty = -(top + bottom) * b;
1233
- var tz = -(far + near) * c;
1234
- a *= 2.0;
1235
- b *= 2.0;
1236
- c *= -2.0;
1237
- return new Matrix4$4(a, 0.0, 0.0, 0.0, //
1238
- 0.0, b, 0.0, 0.0, //
1239
- 0.0, 0.0, c, 0.0, //
1240
- tx, ty, tz, 1.0);
1241
- }
1242
-
1243
1057
  var Vector2$1 = math.Vector2, Vector3$3 = math.Vector3, Matrix4$3 = math.Matrix4;
1244
1058
  /**
1245
1059
  * 根据 gizmoSubType 类型创建几何体 Mesh
@@ -2747,21 +2561,209 @@ function createMesh(engine, points, indices, color, depthTest, name) {
2747
2561
  size: 3,
2748
2562
  data: points
2749
2563
  }
2750
- },
2751
- indices: {
2752
- data: indices
2753
- },
2754
- mode: glContext.LINES,
2755
- drawCount: indices.length
2756
- });
2757
- return Mesh.create(engine, {
2758
- name: name,
2759
- geometry: geometry,
2760
- material: material,
2761
- priority: 3000
2762
- });
2763
- }
2564
+ },
2565
+ indices: {
2566
+ data: indices
2567
+ },
2568
+ mode: glContext.LINES,
2569
+ drawCount: indices.length
2570
+ });
2571
+ return Mesh.create(engine, {
2572
+ name: name,
2573
+ geometry: geometry,
2574
+ material: material,
2575
+ priority: 3000
2576
+ });
2577
+ }
2578
+
2579
+ var Vector4 = math.Vector4;
2580
+ var WireframeGeometryType;
2581
+ (function(WireframeGeometryType) {
2582
+ WireframeGeometryType[WireframeGeometryType["triangle"] = 0] = "triangle";
2583
+ WireframeGeometryType[WireframeGeometryType["quad"] = 1] = "quad";
2584
+ })(WireframeGeometryType || (WireframeGeometryType = {}));
2585
+ function destroyWireframeMesh(mesh) {
2586
+ var _mesh_geometry;
2587
+ (_mesh_geometry = mesh.geometry) == null ? void 0 : _mesh_geometry.dispose();
2588
+ mesh.dispose({
2589
+ geometries: DestroyOptions.keep
2590
+ });
2591
+ }
2592
+ function updateWireframeMesh(originGeometry, originMaterial, wireframe, type) {
2593
+ wireframe.material.cloneUniforms(originMaterial);
2594
+ var geometry = originGeometry;
2595
+ var wireframeGeometry = wireframe.firstGeometry();
2596
+ for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(originMaterial.enabledMacros)), _step; !(_step = _iterator()).done;){
2597
+ var macro = _step.value;
2598
+ wireframe.material.enableMacro(macro, originMaterial.enabledMacros[macro]);
2599
+ }
2600
+ if (type === 0) {
2601
+ // 线框模式不绘制模型的时候,drawCount 为负数
2602
+ var drawCount = Math.abs(geometry.getDrawCount());
2603
+ if (drawCount !== 0) {
2604
+ if (drawCount !== wireframeGeometry.getDrawCount() / 2) {
2605
+ var indexData = geometry.getIndexData();
2606
+ var data = indexData ? getTriangleIndexData(indexData) : getTriangleIndexDataByCount(drawCount);
2607
+ wireframeGeometry.setIndexData(data);
2608
+ wireframeGeometry.setDrawCount(data.length);
2609
+ }
2610
+ }
2611
+ } else if (type === 1) {
2612
+ if (geometry.getDrawCount() / 6 !== wireframeGeometry.getDrawCount() / 8) {
2613
+ var data1 = getQuadIndexData(geometry.getDrawCount() / 6, geometry.getIndexData());
2614
+ wireframeGeometry.setIndexData(data1);
2615
+ wireframeGeometry.setDrawCount(data1.length);
2616
+ }
2617
+ }
2618
+ return wireframe;
2619
+ }
2620
+ function getQuadIndexData(faceCount, oid) {
2621
+ var indexData = new Uint16Array(faceCount * 8);
2622
+ for(var i = 0; i < faceCount; i++){
2623
+ var idx = i * 8;
2624
+ var base = i * 4;
2625
+ indexData[idx] = base;
2626
+ indexData[idx + 1] = 1 + base;
2627
+ indexData[idx + 2] = 1 + base;
2628
+ indexData[idx + 3] = 3 + base;
2629
+ indexData[idx + 4] = 3 + base;
2630
+ indexData[idx + 5] = 2 + base;
2631
+ indexData[idx + 6] = 2 + base;
2632
+ indexData[idx + 7] = base;
2633
+ }
2634
+ return indexData;
2635
+ }
2636
+ function createModeWireframe(engine, mesh, color) {
2637
+ var geometry = new SharedGeometry(engine, {
2638
+ geometry: mesh.firstGeometry(),
2639
+ mode: glContext.LINES,
2640
+ index: {
2641
+ data: new Uint32Array(0)
2642
+ }
2643
+ });
2644
+ var _mesh_material_shader_shaderData = mesh.material.shader.shaderData, vertex = _mesh_material_shader_shaderData.vertex, fragment = _mesh_material_shader_shaderData.fragment;
2645
+ var materialOptions = _extends({}, mesh.material.props);
2646
+ var newMacros = [
2647
+ [
2648
+ "PREVIEW_BORDER",
2649
+ 1
2650
+ ]
2651
+ ];
2652
+ var _mesh_name;
2653
+ materialOptions.shader = {
2654
+ vertex: vertex,
2655
+ fragment: fragment,
2656
+ macros: newMacros,
2657
+ shared: true,
2658
+ name: ((_mesh_name = mesh.name) != null ? _mesh_name : "unamedmesh") + "_wireframe",
2659
+ glslVersion: engine.gpuCapability.level === 2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1
2660
+ };
2661
+ var material = Material.create(engine, materialOptions);
2662
+ material.depthTest = true;
2663
+ material.setVector4("uPreviewColor", new Vector4(color[0], color[1], color[2], 1));
2664
+ return updateWireframeMesh(mesh.geometry, mesh.material, Mesh.create(engine, {
2665
+ geometry: geometry,
2666
+ material: material,
2667
+ priority: 3000,
2668
+ name: materialOptions.shader.name
2669
+ }), 0);
2670
+ }
2671
+ function getTriangleIndexDataByCount(drawCount) {
2672
+ var faceCount = drawCount / 3;
2673
+ var indexData = new Uint32Array(faceCount * 6);
2674
+ for(var i = 0; i < faceCount; i++){
2675
+ var idx = i * 6;
2676
+ var p0 = i * 3;
2677
+ var p1 = p0 + 1;
2678
+ var p2 = p0 + 2;
2679
+ indexData[idx] = p0;
2680
+ indexData[idx + 1] = p1;
2681
+ indexData[idx + 2] = p1;
2682
+ indexData[idx + 3] = p2;
2683
+ indexData[idx + 4] = p2;
2684
+ indexData[idx + 5] = p0;
2685
+ }
2686
+ return indexData;
2687
+ }
2688
+ function getTriangleIndexData(oid) {
2689
+ var faceCount = oid.length / 3;
2690
+ var indexData = new Uint32Array(faceCount * 6);
2691
+ for(var i = 0; i < faceCount; i++){
2692
+ var idx = i * 6;
2693
+ var base = i * 3;
2694
+ var p0 = oid[base];
2695
+ var p1 = oid[base + 1];
2696
+ var p2 = oid[base + 2];
2697
+ indexData[idx] = p0;
2698
+ indexData[idx + 1] = p1;
2699
+ indexData[idx + 2] = p1;
2700
+ indexData[idx + 3] = p2;
2701
+ indexData[idx + 4] = p2;
2702
+ indexData[idx + 5] = p0;
2703
+ }
2704
+ return indexData;
2705
+ }
2706
+ var SharedGeometry = /*#__PURE__*/ function(GLGeometry) {
2707
+ _inherits(SharedGeometry, GLGeometry);
2708
+ function SharedGeometry(engine, options) {
2709
+ var _this;
2710
+ _this = GLGeometry.call(this, engine, _extends({
2711
+ attributes: {}
2712
+ }, options)) || this;
2713
+ var indexData = options.index ? options.index.data : options.geometry.getIndexData();
2714
+ if (indexData) {
2715
+ //@ts-expect-error safe to assign
2716
+ indexData = new indexData.constructor(indexData);
2717
+ }
2718
+ _this.indices = indexData;
2719
+ _this.source = options.geometry;
2720
+ _this.drawCount = options.drawCount || 0;
2721
+ _this.drawStart = options.drawStart || 0;
2722
+ _this.mode = options.mode || 0;
2723
+ for(var name in _this.source.attributes){
2724
+ _this.attributes[name] = _extends({}, _this.source.attributes[name]);
2725
+ }
2726
+ return _this;
2727
+ }
2728
+ var _proto = SharedGeometry.prototype;
2729
+ _proto.initialize = function initialize() {
2730
+ if (!this.isInitialized) {
2731
+ var geometry = this.source;
2732
+ geometry.initialize();
2733
+ //this.indicesBuffer = this._source.indicesBuffer;
2734
+ this.buffers = this.source.buffers;
2735
+ this.bufferProps = this.source.bufferProps;
2736
+ //this.dirtyFlags = this._source.dirtyFlags;
2737
+ //this.vaos = this._source.vaos;
2738
+ //创建ibo
2739
+ if (this.indices) {
2740
+ this.indicesBuffer = this.createIndicesBuffer(this.indices);
2741
+ }
2742
+ this.flush();
2743
+ this.initialized = true;
2744
+ }
2745
+ };
2746
+ _proto.getAttributeNames = function getAttributeNames() {
2747
+ return this.source.getAttributeNames();
2748
+ };
2749
+ _proto.flush = function flush() {
2750
+ this.source.flush();
2751
+ GLGeometry.prototype.flush.call(this);
2752
+ };
2753
+ _proto.dispose = function dispose() {
2754
+ // from source geometry
2755
+ this.buffers = {};
2756
+ this.bufferProps = {};
2757
+ GLGeometry.prototype.dispose.call(this);
2758
+ // @ts-expect-error
2759
+ this.source = null;
2760
+ };
2761
+ return SharedGeometry;
2762
+ }(GLGeometry);
2764
2763
 
2764
+ var editorRenderPassName = "editor-gizmo";
2765
+ var frontRenderPassName = "front-gizmo";
2766
+ var behindRenderPassName = "behind-gizmo";
2765
2767
  var Vector2 = math.Vector2, Vector3 = math.Vector3, Matrix4 = math.Matrix4, Quaternion = math.Quaternion;
2766
2768
  var constants = glContext;
2767
2769
  var GizmoComponent = /*#__PURE__*/ function(RendererComponent1) {
@@ -2773,6 +2775,7 @@ var GizmoComponent = /*#__PURE__*/ function(RendererComponent1) {
2773
2775
  _this.coordinateSpace = 0;
2774
2776
  _this.mat = Matrix4.fromIdentity();
2775
2777
  _this.wireframeMeshes = [];
2778
+ _this.meshes = [];
2776
2779
  _this.mesh = null;
2777
2780
  /**
2778
2781
  * 射线检测算法
@@ -3007,11 +3010,11 @@ var GizmoComponent = /*#__PURE__*/ function(RendererComponent1) {
3007
3010
  var gizmoSubType = this.subType;
3008
3011
  switch(gizmoSubType){
3009
3012
  case GizmoSubType.particleEmitter:
3010
- this.createParticleContent(targetItem, gizmoPlugin.meshToAdd);
3013
+ this.createParticleContent(targetItem);
3011
3014
  break;
3012
3015
  case GizmoSubType.modelWireframe:
3013
3016
  this.needCreateModelContent = true;
3014
- this.createModelContent(targetItem, gizmoPlugin.meshToAdd);
3017
+ this.createModelContent(targetItem);
3015
3018
  break;
3016
3019
  case GizmoSubType.box:
3017
3020
  case GizmoSubType.sphere:
@@ -3024,29 +3027,111 @@ var GizmoComponent = /*#__PURE__*/ function(RendererComponent1) {
3024
3027
  case GizmoSubType.pointLight:
3025
3028
  case GizmoSubType.spotLight:
3026
3029
  case GizmoSubType.floorGrid:
3027
- this.createBasicContent(targetItem, gizmoPlugin.meshToAdd, gizmoSubType);
3030
+ this.createBasicContent(targetItem, gizmoSubType);
3028
3031
  break;
3029
3032
  case GizmoSubType.camera:
3030
3033
  case GizmoSubType.light:
3031
- this.createBasicContent(targetItem, gizmoPlugin.meshToAdd, gizmoSubType, iconTextures);
3034
+ this.createBasicContent(targetItem, gizmoSubType, iconTextures);
3032
3035
  break;
3033
3036
  case GizmoSubType.rotation:
3034
3037
  case GizmoSubType.scale:
3035
3038
  case GizmoSubType.translation:
3036
- this.createCombinationContent(targetItem, gizmoPlugin.meshToAdd, gizmoSubType);
3039
+ this.createCombinationContent(targetItem, gizmoSubType);
3037
3040
  break;
3038
3041
  case GizmoSubType.viewHelper:
3039
- this.createCombinationContent(targetItem, gizmoPlugin.meshToAdd, gizmoSubType, iconTextures);
3042
+ this.createCombinationContent(targetItem, gizmoSubType, iconTextures);
3040
3043
  break;
3041
3044
  case GizmoSubType.boundingBox:
3042
- this.createBoundingBoxContent(targetItem, gizmoPlugin.meshToAdd);
3045
+ this.createBoundingBoxContent(targetItem);
3043
3046
  break;
3044
3047
  }
3045
3048
  composition == null ? void 0 : composition.loaderData.gizmoItems.push(this.item);
3046
3049
  };
3050
+ _proto.onEnable = function onEnable() {
3051
+ RendererComponent1.prototype.onEnable.call(this);
3052
+ if (!this.item.composition) {
3053
+ return;
3054
+ }
3055
+ var renderFrame = this.item.composition.renderFrame;
3056
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.meshes), _step; !(_step = _iterator()).done;){
3057
+ var mesh = _step.value;
3058
+ if (mesh.name === GeometryType.FloorGrid.toString() || mesh.name === "Box") {
3059
+ this.getFrontRenderPass(renderFrame).addMesh(mesh);
3060
+ } else if (mesh.name === "translation" || mesh.name === "scale" || mesh.name === "rotation") {
3061
+ this.getBehindRenderPass(renderFrame).addMesh(mesh);
3062
+ } else {
3063
+ this.getEditorRenderPass(renderFrame).addMesh(mesh);
3064
+ }
3065
+ }
3066
+ };
3067
+ _proto.onDisable = function onDisable() {
3068
+ RendererComponent1.prototype.onDisable.call(this);
3069
+ if (!this.item.composition) {
3070
+ return;
3071
+ }
3072
+ var renderFrame = this.item.composition.renderFrame;
3073
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.meshes), _step; !(_step = _iterator()).done;){
3074
+ var mesh = _step.value;
3075
+ if (mesh.name === GeometryType.FloorGrid.toString() || mesh.name === "Box") {
3076
+ this.getFrontRenderPass(renderFrame).removeMesh(mesh);
3077
+ } else if (mesh.name === "translation" || mesh.name === "scale" || mesh.name === "rotation") {
3078
+ this.getBehindRenderPass(renderFrame).removeMesh(mesh);
3079
+ } else {
3080
+ this.getEditorRenderPass(renderFrame).removeMesh(mesh);
3081
+ }
3082
+ }
3083
+ };
3047
3084
  _proto.onUpdate = function onUpdate(dt) {
3048
3085
  this.updateRenderData();
3049
3086
  };
3087
+ _proto.onDestroy = function onDestroy() {
3088
+ var _this = this;
3089
+ var gizmoMesh = this.mesh;
3090
+ var composition = this.item.composition;
3091
+ if (!composition) {
3092
+ return;
3093
+ }
3094
+ if (gizmoMesh && !gizmoMesh.isDestroyed) {
3095
+ gizmoMesh.dispose();
3096
+ if (gizmoMesh.name === GeometryType.FloorGrid.toString() || gizmoMesh.name === "Box") {
3097
+ this.getFrontRenderPass(composition.renderFrame).removeMesh(gizmoMesh);
3098
+ } else {
3099
+ this.getEditorRenderPass(composition.renderFrame).removeMesh(gizmoMesh);
3100
+ }
3101
+ }
3102
+ if (this.contents) {
3103
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.contents), _step; !(_step = _iterator()).done;){
3104
+ var _step_value = _step.value, mesh = _step_value[0];
3105
+ if (!mesh.isDestroyed) {
3106
+ mesh.dispose();
3107
+ if (mesh.name === "translation" || mesh.name === "scale" || mesh.name === "rotation") {
3108
+ this.getBehindRenderPass(composition.renderFrame).removeMesh(mesh);
3109
+ } else {
3110
+ this.getEditorRenderPass(composition.renderFrame).removeMesh(mesh);
3111
+ }
3112
+ }
3113
+ }
3114
+ }
3115
+ if (this && this.wireframeMeshes.length > 0) {
3116
+ this.wireframeMeshes.forEach(function(mesh) {
3117
+ if (!mesh.isDestroyed) {
3118
+ destroyWireframeMesh(mesh);
3119
+ _this.getEditorRenderPass(composition.renderFrame).removeMesh(mesh);
3120
+ }
3121
+ });
3122
+ } else {
3123
+ var wireframeMesh = this.wireframeMesh;
3124
+ if (wireframeMesh && !wireframeMesh.isDestroyed) {
3125
+ destroyWireframeMesh(wireframeMesh);
3126
+ this.getEditorRenderPass(composition.renderFrame).removeMesh(wireframeMesh);
3127
+ }
3128
+ }
3129
+ var arr = composition.loaderData.gizmoItems;
3130
+ var index = arr.indexOf(this.item);
3131
+ if (index > -1) {
3132
+ arr.splice(index, 1);
3133
+ }
3134
+ };
3050
3135
  _proto.render = function render(renderer) {
3051
3136
  // The material of the 3D plugin is updated during the render phase. In order to obtain the correct value, it is kept consistent here.
3052
3137
  if (this.subType === GizmoSubType.modelWireframe) {
@@ -3251,7 +3336,7 @@ var GizmoComponent = /*#__PURE__*/ function(RendererComponent1) {
3251
3336
  }
3252
3337
  return result;
3253
3338
  };
3254
- _proto.createModelContent = function createModelContent(item, meshesToAdd) {
3339
+ _proto.createModelContent = function createModelContent(item) {
3255
3340
  var _item_composition;
3256
3341
  var modelComponent = item.getComponent(RendererComponent);
3257
3342
  //@ts-expect-error TODO 和 3D 类型解耦
@@ -3268,10 +3353,10 @@ var GizmoComponent = /*#__PURE__*/ function(RendererComponent1) {
3268
3353
  });
3269
3354
  var mesh = this.wireframeMesh = createModeWireframe(engine, originMesh, this.color);
3270
3355
  this.wireframeMeshes.push(mesh);
3271
- meshesToAdd.push(mesh);
3356
+ this.meshes.push(mesh);
3272
3357
  }
3273
3358
  };
3274
- _proto.createParticleContent = function createParticleContent(item, meshesToAdd) {
3359
+ _proto.createParticleContent = function createParticleContent(item) {
3275
3360
  var _this_item_composition;
3276
3361
  var shape = item.props.content.shape;
3277
3362
  var engine = (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.renderer.engine;
@@ -3281,14 +3366,13 @@ var GizmoComponent = /*#__PURE__*/ function(RendererComponent1) {
3281
3366
  var mesh = this.mesh = createMeshFromShape(engine, shape, {
3282
3367
  color: this.color
3283
3368
  });
3284
- meshesToAdd.push(mesh);
3369
+ this.meshes.push(mesh);
3285
3370
  }
3286
3371
  };
3287
3372
  /**
3288
3373
  * 创建 BoundingBox 几何体模型
3289
3374
  * @param item - VFXItem
3290
- * @param meshesToAdd - 插件缓存的 Mesh 数组
3291
- */ _proto.createBoundingBoxContent = function createBoundingBoxContent(item, meshesToAdd) {
3375
+ */ _proto.createBoundingBoxContent = function createBoundingBoxContent(item) {
3292
3376
  var _gizmoItem_composition;
3293
3377
  var gizmoItem = this.item;
3294
3378
  var shape = {
@@ -3306,15 +3390,14 @@ var GizmoComponent = /*#__PURE__*/ function(RendererComponent1) {
3306
3390
  color: this.color,
3307
3391
  depthTest: this.depthTest
3308
3392
  });
3309
- meshesToAdd.push(mesh);
3393
+ this.meshes.push(mesh);
3310
3394
  }
3311
3395
  };
3312
3396
  /**
3313
3397
  * 创建基础几何体模型
3314
3398
  * @param item - VFXItem
3315
- * @param meshesToAdd - 插件缓存的 Mesh 数组
3316
3399
  * @param subType - GizmoSubType 类型
3317
- */ _proto.createBasicContent = function createBasicContent(item, meshesToAdd, subType, iconTextures) {
3400
+ */ _proto.createBasicContent = function createBasicContent(item, subType, iconTextures) {
3318
3401
  var _gizmoItem_composition;
3319
3402
  var gizmoItem = this.item;
3320
3403
  var options = {
@@ -3327,15 +3410,14 @@ var GizmoComponent = /*#__PURE__*/ function(RendererComponent1) {
3327
3410
  assertExist(engine);
3328
3411
  var mesh = this.mesh = createMeshFromSubType(engine, subType, this.boundingMap, iconTextures, options);
3329
3412
  this.targetItem = item;
3330
- meshesToAdd.push(mesh);
3413
+ this.meshes.push(mesh);
3331
3414
  };
3332
3415
  /**
3333
3416
  * 创建组合几何体模型
3334
3417
  * @param item - VFXItem
3335
- * @param meshesToAdd - 插件缓存的 Mesh 数组
3336
3418
  * @param subType - GizmoSubType 类型
3337
3419
  * @param iconTextures - XYZ 图标纹理(viewHelper 专用)
3338
- */ _proto.createCombinationContent = function createCombinationContent(item, meshesToAdd, subType, iconTextures) {
3420
+ */ _proto.createCombinationContent = function createCombinationContent(item, subType, iconTextures) {
3339
3421
  var _gizmoItem_composition;
3340
3422
  var gizmoItem = this.item;
3341
3423
  var options = {
@@ -3347,7 +3429,7 @@ var GizmoComponent = /*#__PURE__*/ function(RendererComponent1) {
3347
3429
  this.contents = createMeshFromSubType(engine, subType, this.boundingMap, iconTextures, options);
3348
3430
  for(var _iterator = _create_for_of_iterator_helper_loose(this.contents.keys()), _step; !(_step = _iterator()).done;){
3349
3431
  var mesh = _step.value;
3350
- meshesToAdd.push(mesh);
3432
+ this.meshes.push(mesh);
3351
3433
  }
3352
3434
  this.targetItem = item;
3353
3435
  };
@@ -3375,6 +3457,48 @@ var GizmoComponent = /*#__PURE__*/ function(RendererComponent1) {
3375
3457
  item.transform = new Transform(data.transform);
3376
3458
  }
3377
3459
  };
3460
+ _proto.getBehindRenderPass = function getBehindRenderPass(pipeline) {
3461
+ var rp = pipeline.renderPasses.find(function(renderPass) {
3462
+ return renderPass.name === behindRenderPassName;
3463
+ });
3464
+ if (!rp) {
3465
+ rp = new RenderPass(pipeline.renderer, {
3466
+ name: behindRenderPassName,
3467
+ priority: RenderPassPriorityPostprocess + RenderPassPriorityPostprocess,
3468
+ clearAction: {
3469
+ depthAction: TextureLoadAction.clear
3470
+ }
3471
+ });
3472
+ pipeline.addRenderPass(rp);
3473
+ }
3474
+ return rp;
3475
+ };
3476
+ _proto.getEditorRenderPass = function getEditorRenderPass(pipeline) {
3477
+ var rp = pipeline.renderPasses.find(function(renderPass) {
3478
+ return renderPass.name === editorRenderPassName;
3479
+ });
3480
+ if (!rp) {
3481
+ rp = new RenderPass(pipeline.renderer, {
3482
+ name: editorRenderPassName,
3483
+ priority: RenderPassPriorityPostprocess + 2
3484
+ });
3485
+ pipeline.addRenderPass(rp);
3486
+ }
3487
+ return rp;
3488
+ };
3489
+ _proto.getFrontRenderPass = function getFrontRenderPass(pipeline) {
3490
+ var rp = pipeline.renderPasses.find(function(renderPass) {
3491
+ return renderPass.name === frontRenderPassName;
3492
+ });
3493
+ if (!rp) {
3494
+ rp = new RenderPass(pipeline.renderer, {
3495
+ name: frontRenderPassName,
3496
+ priority: RenderPassPriorityPrepare + 2
3497
+ });
3498
+ pipeline.addRenderPass(rp);
3499
+ }
3500
+ return rp;
3501
+ };
3378
3502
  return GizmoComponent;
3379
3503
  }(RendererComponent);
3380
3504
  __decorate([
@@ -3389,9 +3513,6 @@ var CoordinateSpace;
3389
3513
  CoordinateSpace[CoordinateSpace["World"] = 1] = "World";
3390
3514
  })(CoordinateSpace || (CoordinateSpace = {}));
3391
3515
 
3392
- var editorRenderPassName = "editor-gizmo";
3393
- var frontRenderPassName = "front-gizmo";
3394
- var behindRenderPassName = "behind-gizmo";
3395
3516
  var iconImages = new Map();
3396
3517
  var iconTextures = new Map();
3397
3518
  var EditorGizmoPlugin = /*#__PURE__*/ function(AbstractPlugin) {
@@ -3399,8 +3520,6 @@ var EditorGizmoPlugin = /*#__PURE__*/ function(AbstractPlugin) {
3399
3520
  function EditorGizmoPlugin() {
3400
3521
  var _this;
3401
3522
  _this = AbstractPlugin.apply(this, arguments) || this;
3402
- _this.meshToAdd = [];
3403
- _this.meshToRemove = [];
3404
3523
  _this.order = 1001;
3405
3524
  return _this;
3406
3525
  }
@@ -3429,182 +3548,6 @@ var EditorGizmoPlugin = /*#__PURE__*/ function(AbstractPlugin) {
3429
3548
  composition.loaderData.gizmoTarget = targetMap;
3430
3549
  composition.loaderData.gizmoItems = [];
3431
3550
  };
3432
- // override onCompositionItemLifeBegin (composition: Composition, item: VFXItem<any>) {
3433
- // if (item.type === '7') {
3434
- // return;
3435
- // }
3436
- // const gizmoVFXItemList: GizmoVFXItem[] = composition.loaderData.gizmoTarget[item.id];
3437
- // if (gizmoVFXItemList && gizmoVFXItemList.length > 0) {
3438
- // for (const gizmoVFXItem of gizmoVFXItemList) {
3439
- // switch (gizmoVFXItem.subType) {
3440
- // case GizmoSubType.particleEmitter:
3441
- // gizmoVFXItem.createParticleContent(item, this.meshToAdd);
3442
- // break;
3443
- // case GizmoSubType.modelWireframe:
3444
- // gizmoVFXItem.createModelContent(item, this.meshToAdd);
3445
- // break;
3446
- // case GizmoSubType.box:
3447
- // case GizmoSubType.sphere:
3448
- // case GizmoSubType.cylinder:
3449
- // case GizmoSubType.cone:
3450
- // case GizmoSubType.torus:
3451
- // case GizmoSubType.sprite:
3452
- // case GizmoSubType.frustum:
3453
- // case GizmoSubType.directionLight:
3454
- // case GizmoSubType.pointLight:
3455
- // case GizmoSubType.spotLight:
3456
- // case GizmoSubType.floorGrid:
3457
- // gizmoVFXItem.createBasicContent(item, this.meshToAdd, gizmoVFXItem.subType);
3458
- // break;
3459
- // case GizmoSubType.camera:
3460
- // case GizmoSubType.light:
3461
- // gizmoVFXItem.createBasicContent(item, this.meshToAdd, gizmoVFXItem.subType, iconTextures);
3462
- // break;
3463
- // case GizmoSubType.rotation:
3464
- // case GizmoSubType.scale:
3465
- // case GizmoSubType.translation:
3466
- // gizmoVFXItem.createCombinationContent(item, this.meshToAdd, gizmoVFXItem.subType);
3467
- // break;
3468
- // case GizmoSubType.viewHelper:
3469
- // gizmoVFXItem.createCombinationContent(item, this.meshToAdd, gizmoVFXItem.subType, iconTextures);
3470
- // break;
3471
- // case GizmoSubType.boundingBox:
3472
- // gizmoVFXItem.createBoundingBoxContent(item, this.meshToAdd);
3473
- // break;
3474
- // default:
3475
- // break;
3476
- // }
3477
- // }
3478
- // }
3479
- // if (item.type === GizmoVFXItemType) {
3480
- // composition.loaderData.gizmoItems.push(item);
3481
- // }
3482
- // }
3483
- _proto.onCompositionItemRemoved = function onCompositionItemRemoved(composition, item) {
3484
- var _this = this;
3485
- if (item.type === GizmoVFXItemType) {
3486
- this.removeGizmoItem(composition, item);
3487
- } else {
3488
- var gizmoVFXItemList = composition.loaderData.gizmoTarget[item.id];
3489
- if (gizmoVFXItemList && gizmoVFXItemList.length > 0) {
3490
- gizmoVFXItemList.forEach(function(gizmoVFXItem) {
3491
- _this.removeGizmoItem(composition, gizmoVFXItem);
3492
- });
3493
- }
3494
- }
3495
- };
3496
- _proto.removeGizmoItem = function removeGizmoItem(composition, gizmoVFXItem) {
3497
- var _this = this;
3498
- var gizmoMesh = gizmoVFXItem.getComponent(GizmoComponent).mesh;
3499
- if (gizmoMesh && !gizmoMesh.isDestroyed) {
3500
- gizmoMesh.dispose();
3501
- if (gizmoMesh.name === GeometryType.FloorGrid.toString() || gizmoMesh.name === "Box") {
3502
- this.getFrontRenderPass(composition.renderFrame).removeMesh(gizmoMesh);
3503
- } else {
3504
- this.getEditorRenderPass(composition.renderFrame).removeMesh(gizmoMesh);
3505
- }
3506
- }
3507
- if (gizmoVFXItem.getComponent(GizmoComponent).contents) {
3508
- for(var _iterator = _create_for_of_iterator_helper_loose(gizmoVFXItem.getComponent(GizmoComponent).contents), _step; !(_step = _iterator()).done;){
3509
- var _step_value = _step.value, mesh = _step_value[0];
3510
- if (!mesh.isDestroyed) {
3511
- mesh.dispose();
3512
- if (mesh.name === "translation" || mesh.name === "scale" || mesh.name === "rotation") {
3513
- this.getBehindRenderPass(composition.renderFrame).removeMesh(mesh);
3514
- } else {
3515
- this.getEditorRenderPass(composition.renderFrame).removeMesh(mesh);
3516
- }
3517
- }
3518
- }
3519
- }
3520
- var gizmoComponent = gizmoVFXItem.getComponent(GizmoComponent);
3521
- if (gizmoComponent && gizmoComponent.wireframeMeshes.length > 0) {
3522
- gizmoComponent.wireframeMeshes.forEach(function(mesh) {
3523
- if (!mesh.isDestroyed) {
3524
- destroyWireframeMesh(mesh);
3525
- _this.getEditorRenderPass(composition.renderFrame).removeMesh(mesh);
3526
- }
3527
- });
3528
- } else {
3529
- var wireframeMesh = gizmoVFXItem.getComponent(GizmoComponent).wireframeMesh;
3530
- if (wireframeMesh && !wireframeMesh.isDestroyed) {
3531
- destroyWireframeMesh(wireframeMesh);
3532
- this.getEditorRenderPass(composition.renderFrame).removeMesh(wireframeMesh);
3533
- }
3534
- }
3535
- var arr = composition.loaderData.gizmoItems;
3536
- var index = arr.indexOf(gizmoVFXItem);
3537
- if (index > -1) {
3538
- arr.splice(index, 1);
3539
- }
3540
- };
3541
- _proto.prepareRenderFrame = function prepareRenderFrame(composition, renderFrame) {
3542
- var _this = this;
3543
- this.meshToAdd.forEach(function(mesh) {
3544
- if (mesh.name === GeometryType.FloorGrid.toString() || mesh.name === "Box") {
3545
- _this.getFrontRenderPass(renderFrame).addMesh(mesh);
3546
- } else if (mesh.name === "translation" || mesh.name === "scale" || mesh.name === "rotation") {
3547
- _this.getBehindRenderPass(renderFrame).addMesh(mesh);
3548
- } else {
3549
- _this.getEditorRenderPass(renderFrame).addMesh(mesh);
3550
- }
3551
- });
3552
- this.meshToRemove.forEach(function(mesh) {
3553
- if (mesh.name === GeometryType.FloorGrid.toString() || mesh.name === "Box") {
3554
- _this.getFrontRenderPass(renderFrame).removeMesh(mesh);
3555
- } else if (mesh.name === "translation" || mesh.name === "scale" || mesh.name === "rotation") {
3556
- _this.getBehindRenderPass(renderFrame).removeMesh(mesh);
3557
- } else {
3558
- _this.getEditorRenderPass(renderFrame).removeMesh(mesh);
3559
- }
3560
- removeItem(_this.meshToAdd, mesh);
3561
- });
3562
- this.meshToRemove.length = 0;
3563
- // composition.loaderData.gizmoItems.forEach((item: GizmoVFXItem) => item.updateRenderData());
3564
- return false;
3565
- };
3566
- _proto.getBehindRenderPass = function getBehindRenderPass(pipeline) {
3567
- var rp = pipeline.renderPasses.find(function(renderPass) {
3568
- return renderPass.name === behindRenderPassName;
3569
- });
3570
- if (!rp) {
3571
- rp = new RenderPass(pipeline.renderer, {
3572
- name: behindRenderPassName,
3573
- priority: RenderPassPriorityPostprocess + RenderPassPriorityPostprocess,
3574
- clearAction: {
3575
- depthAction: TextureLoadAction.clear
3576
- }
3577
- });
3578
- pipeline.addRenderPass(rp);
3579
- }
3580
- return rp;
3581
- };
3582
- _proto.getEditorRenderPass = function getEditorRenderPass(pipeline) {
3583
- var rp = pipeline.renderPasses.find(function(renderPass) {
3584
- return renderPass.name === editorRenderPassName;
3585
- });
3586
- if (!rp) {
3587
- rp = new RenderPass(pipeline.renderer, {
3588
- name: editorRenderPassName,
3589
- priority: RenderPassPriorityPostprocess + 2
3590
- });
3591
- pipeline.addRenderPass(rp);
3592
- }
3593
- return rp;
3594
- };
3595
- _proto.getFrontRenderPass = function getFrontRenderPass(pipeline) {
3596
- var rp = pipeline.renderPasses.find(function(renderPass) {
3597
- return renderPass.name === frontRenderPassName;
3598
- });
3599
- if (!rp) {
3600
- rp = new RenderPass(pipeline.renderer, {
3601
- name: frontRenderPassName,
3602
- priority: RenderPassPriorityPrepare + 2
3603
- });
3604
- pipeline.addRenderPass(rp);
3605
- }
3606
- return rp;
3607
- };
3608
3551
  EditorGizmoPlugin.prepareResource = function prepareResource(scene) {
3609
3552
  return _async_to_generator(function() {
3610
3553
  var _iterator, _step, _step_value, name, data, _, _tmp;
@@ -3656,7 +3599,7 @@ var EditorGizmoPlugin = /*#__PURE__*/ function(AbstractPlugin) {
3656
3599
  registerPlugin("editor-gizmo", EditorGizmoPlugin, VFXItem);
3657
3600
  /**
3658
3601
  * 插件版本号
3659
- */ var version = "2.7.3";
3602
+ */ var version = "2.8.0-alpha.0";
3660
3603
  logger.info("Plugin editor gizmo version: " + version + ".");
3661
3604
  if (version !== EFFECTS.version) {
3662
3605
  console.error("注意:请统一 Editor Gizmo 插件与 Player 版本,不统一的版本混用会有不可预知的后果!", "\nAttention: Please ensure the Editor Gizmo plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!");