@galacean/effects-plugin-editor-gizmo 2.0.0-alpha.23 → 2.0.0-alpha.25
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/gizmo-component.d.ts +7 -1
- package/dist/index.js +44 -25
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +45 -26
- package/dist/index.mjs.map +1 -1
- package/dist/wireframe.d.ts +2 -2
- package/package.json +3 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { GeometryDrawMode,
|
|
1
|
+
import type { GeometryDrawMode, Texture, VFXItem } from '@galacean/effects';
|
|
2
|
+
import { Mesh } from '@galacean/effects';
|
|
2
3
|
import { ItemBehaviour, Transform, math, spec } from '@galacean/effects';
|
|
3
4
|
import { GizmoSubType } from './define';
|
|
4
5
|
import { type EditorGizmoPlugin } from './gizmo-loader';
|
|
@@ -19,6 +20,7 @@ export declare class GizmoComponent extends ItemBehaviour {
|
|
|
19
20
|
position: Vector3;
|
|
20
21
|
};
|
|
21
22
|
wireframeMesh: Mesh;
|
|
23
|
+
coordinateSpace: CoordinateSpace;
|
|
22
24
|
color: spec.vec3;
|
|
23
25
|
renderMode: GeometryDrawMode;
|
|
24
26
|
depthTest?: boolean;
|
|
@@ -68,4 +70,8 @@ export declare class GizmoComponent extends ItemBehaviour {
|
|
|
68
70
|
*/
|
|
69
71
|
private getHitTestParams;
|
|
70
72
|
}
|
|
73
|
+
export declare enum CoordinateSpace {
|
|
74
|
+
Local = 0,
|
|
75
|
+
World = 1
|
|
76
|
+
}
|
|
71
77
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects player editor gizmo plugin
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 茂安,旻诺
|
|
6
|
-
* Version: v2.0.0-alpha.
|
|
6
|
+
* Version: v2.0.0-alpha.25
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -281,10 +281,14 @@ function destroyWireframeMesh(mesh) {
|
|
|
281
281
|
geometries: EFFECTS.DestroyOptions.keep
|
|
282
282
|
});
|
|
283
283
|
}
|
|
284
|
-
function updateWireframeMesh(
|
|
285
|
-
wireframe.material.cloneUniforms(
|
|
286
|
-
var geometry =
|
|
284
|
+
function updateWireframeMesh(originGeometry, originMaterial, wireframe, type) {
|
|
285
|
+
wireframe.material.cloneUniforms(originMaterial);
|
|
286
|
+
var geometry = originGeometry;
|
|
287
287
|
var wireframeGeometry = wireframe.firstGeometry();
|
|
288
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(originMaterial.enabledMacros)), _step; !(_step = _iterator()).done;){
|
|
289
|
+
var macro = _step.value;
|
|
290
|
+
wireframe.material.enableMacro(macro, originMaterial.enabledMacros[macro]);
|
|
291
|
+
}
|
|
288
292
|
if (type === 0) {
|
|
289
293
|
// 线框模式不绘制模型的时候,drawCount 为负数
|
|
290
294
|
var drawCount = Math.abs(geometry.getDrawCount());
|
|
@@ -330,14 +334,14 @@ function createModeWireframe(engine, mesh, color) {
|
|
|
330
334
|
data: new Uint32Array(0)
|
|
331
335
|
}
|
|
332
336
|
});
|
|
333
|
-
var
|
|
337
|
+
var _mesh_material_shader_shaderData = mesh.material.shader.shaderData, vertex = _mesh_material_shader_shaderData.vertex, fragment = _mesh_material_shader_shaderData.fragment;
|
|
334
338
|
var materialOptions = _extends({}, mesh.material.props);
|
|
335
|
-
var newMacros = [
|
|
339
|
+
var newMacros = [
|
|
336
340
|
[
|
|
337
341
|
"PREVIEW_BORDER",
|
|
338
342
|
1
|
|
339
343
|
]
|
|
340
|
-
]
|
|
344
|
+
];
|
|
341
345
|
var _mesh_name;
|
|
342
346
|
materialOptions.shader = {
|
|
343
347
|
vertex: createGizmoShader(newMacros, vertex, EFFECTS.ShaderType.vertex, level),
|
|
@@ -347,9 +351,9 @@ function createModeWireframe(engine, mesh, color) {
|
|
|
347
351
|
glslVersion: engine.gpuCapability.level === 2 ? EFFECTS.GLSLVersion.GLSL3 : EFFECTS.GLSLVersion.GLSL1
|
|
348
352
|
};
|
|
349
353
|
var material = EFFECTS.Material.create(engine, materialOptions);
|
|
350
|
-
material.depthTest =
|
|
354
|
+
material.depthTest = true;
|
|
351
355
|
material.setVector4("uPreviewColor", new Vector4(color[0], color[1], color[2], 1));
|
|
352
|
-
return updateWireframeMesh(mesh, EFFECTS.Mesh.create(engine, {
|
|
356
|
+
return updateWireframeMesh(mesh.geometry, mesh.material, EFFECTS.Mesh.create(engine, {
|
|
353
357
|
geometry: geometry,
|
|
354
358
|
material: material,
|
|
355
359
|
priority: 3000,
|
|
@@ -2830,6 +2834,7 @@ exports.GizmoComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
|
2830
2834
|
var _this;
|
|
2831
2835
|
_this = ItemBehaviour.apply(this, arguments) || this;
|
|
2832
2836
|
_this.boundingMap = new Map();
|
|
2837
|
+
_this.coordinateSpace = 0;
|
|
2833
2838
|
_this.mat = Matrix4.fromIdentity();
|
|
2834
2839
|
_this.wireframeMeshes = [];
|
|
2835
2840
|
/**
|
|
@@ -3062,6 +3067,7 @@ exports.GizmoComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
|
3062
3067
|
break;
|
|
3063
3068
|
case exports.GizmoSubType.modelWireframe:
|
|
3064
3069
|
this.needCreateModelContent = true;
|
|
3070
|
+
this.createModelContent(targetItem, gizmoPlugin.meshToAdd);
|
|
3065
3071
|
break;
|
|
3066
3072
|
case exports.GizmoSubType.box:
|
|
3067
3073
|
case exports.GizmoSubType.sphere:
|
|
@@ -3115,20 +3121,18 @@ exports.GizmoComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
|
3115
3121
|
if (this.wireframeMesh && this.targetItem) {
|
|
3116
3122
|
var particle = this.targetItem.getComponent(EFFECTS.ParticleSystemRenderer);
|
|
3117
3123
|
if (particle) {
|
|
3118
|
-
updateWireframeMesh(particle.particleMesh.mesh, this.wireframeMesh, WireframeGeometryType.quad);
|
|
3124
|
+
updateWireframeMesh(particle.particleMesh.mesh.geometry, particle.particleMesh.mesh.material, this.wireframeMesh, WireframeGeometryType.quad);
|
|
3119
3125
|
this.wireframeMesh.worldMatrix = particle.particleMesh.mesh.worldMatrix;
|
|
3120
3126
|
}
|
|
3121
3127
|
}
|
|
3122
3128
|
} else if (gizmoSubType === exports.GizmoSubType.modelWireframe) {
|
|
3123
3129
|
if (this.wireframeMesh && this.targetItem) {
|
|
3124
3130
|
var _this_targetItem_getComponent;
|
|
3125
|
-
//@ts-expect-error
|
|
3126
|
-
var meshes = (_this_targetItem_getComponent = this.targetItem.getComponent(EFFECTS.RendererComponent)) == null ? void 0 : _this_targetItem_getComponent.content.
|
|
3131
|
+
//@ts-expect-error TODO 和 3D 类型解耦
|
|
3132
|
+
var meshes = (_this_targetItem_getComponent = this.targetItem.getComponent(EFFECTS.RendererComponent)) == null ? void 0 : _this_targetItem_getComponent.content.subMeshes;
|
|
3127
3133
|
var wireframeMeshes = this.wireframeMeshes;
|
|
3128
3134
|
if ((meshes == null ? void 0 : meshes.length) > 0) {
|
|
3129
|
-
|
|
3130
|
-
updateWireframeMesh(meshes[i], wireframeMeshes[i], WireframeGeometryType.triangle);
|
|
3131
|
-
}
|
|
3135
|
+
updateWireframeMesh(meshes[0].geometry.geometry, meshes[0].material.effectMaterial, wireframeMeshes[0], WireframeGeometryType.triangle);
|
|
3132
3136
|
}
|
|
3133
3137
|
}
|
|
3134
3138
|
} else {
|
|
@@ -3138,7 +3142,12 @@ exports.GizmoComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
|
3138
3142
|
var worldPos = new Vector3();
|
|
3139
3143
|
var worldQuat = new Quaternion();
|
|
3140
3144
|
var worldScale = new Vector3(1, 1, 1);
|
|
3141
|
-
|
|
3145
|
+
// Scale Gizmo 没有世界空间
|
|
3146
|
+
if (this.coordinateSpace == 0 || gizmoSubType === exports.GizmoSubType.scale) {
|
|
3147
|
+
this.targetItem.transform.assignWorldTRS(worldPos, worldQuat);
|
|
3148
|
+
} else {
|
|
3149
|
+
this.targetItem.transform.assignWorldTRS(worldPos);
|
|
3150
|
+
}
|
|
3142
3151
|
var targetTransform = new EFFECTS.Transform({
|
|
3143
3152
|
position: worldPos,
|
|
3144
3153
|
quat: worldQuat,
|
|
@@ -3301,21 +3310,23 @@ exports.GizmoComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
|
3301
3310
|
return result;
|
|
3302
3311
|
};
|
|
3303
3312
|
_proto.createModelContent = function createModelContent(item, meshesToAdd) {
|
|
3304
|
-
var _this = this;
|
|
3305
3313
|
var _item_composition;
|
|
3306
3314
|
var modelComponent = item.getComponent(EFFECTS.RendererComponent);
|
|
3307
|
-
//@ts-expect-error
|
|
3308
|
-
var
|
|
3315
|
+
//@ts-expect-error TODO 和 3D 类型解耦
|
|
3316
|
+
var psubMesh = modelComponent.content.subMeshes[0];
|
|
3309
3317
|
var engine = (_item_composition = item.composition) == null ? void 0 : _item_composition.renderer.engine;
|
|
3310
3318
|
EFFECTS.assertExist(engine);
|
|
3311
|
-
if (
|
|
3319
|
+
if (psubMesh) {
|
|
3312
3320
|
this.targetItem = item;
|
|
3313
3321
|
this.wireframeMeshes = [];
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3322
|
+
var originMesh = EFFECTS.Mesh.create(engine, {
|
|
3323
|
+
geometry: psubMesh.geometry.geometry,
|
|
3324
|
+
material: psubMesh.material.effectMaterial,
|
|
3325
|
+
priority: 3000
|
|
3318
3326
|
});
|
|
3327
|
+
var mesh = this.wireframeMesh = createModeWireframe(engine, originMesh, this.color);
|
|
3328
|
+
this.wireframeMeshes.push(mesh);
|
|
3329
|
+
meshesToAdd.push(mesh);
|
|
3319
3330
|
}
|
|
3320
3331
|
};
|
|
3321
3332
|
_proto.createParticleContent = function createParticleContent(item, meshesToAdd) {
|
|
@@ -3424,9 +3435,17 @@ exports.GizmoComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
|
3424
3435
|
};
|
|
3425
3436
|
return GizmoComponent;
|
|
3426
3437
|
}(EFFECTS.ItemBehaviour);
|
|
3438
|
+
__decorate([
|
|
3439
|
+
EFFECTS.serialize()
|
|
3440
|
+
], exports.GizmoComponent.prototype, "coordinateSpace", void 0);
|
|
3427
3441
|
exports.GizmoComponent = __decorate([
|
|
3428
3442
|
EFFECTS.effectsClass("GizmoComponent")
|
|
3429
3443
|
], exports.GizmoComponent);
|
|
3444
|
+
var CoordinateSpace;
|
|
3445
|
+
(function(CoordinateSpace) {
|
|
3446
|
+
CoordinateSpace[CoordinateSpace["Local"] = 0] = "Local";
|
|
3447
|
+
CoordinateSpace[CoordinateSpace["World"] = 1] = "World";
|
|
3448
|
+
})(CoordinateSpace || (CoordinateSpace = {}));
|
|
3430
3449
|
|
|
3431
3450
|
var editorRenderPassName = "editor-gizmo";
|
|
3432
3451
|
var frontRenderPassName = "front-gizmo";
|
|
@@ -3695,7 +3714,7 @@ var EditorGizmoPlugin = /*#__PURE__*/ function(AbstractPlugin) {
|
|
|
3695
3714
|
}(EFFECTS.AbstractPlugin);
|
|
3696
3715
|
|
|
3697
3716
|
EFFECTS.registerPlugin("editor-gizmo", EditorGizmoPlugin, EFFECTS.VFXItem);
|
|
3698
|
-
var version = "2.0.0-alpha.
|
|
3717
|
+
var version = "2.0.0-alpha.25";
|
|
3699
3718
|
EFFECTS.logger.info("Plugin editor gizmo version: " + version + ".");
|
|
3700
3719
|
if (version !== EFFECTS__namespace.version) {
|
|
3701
3720
|
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!");
|