@galacean/effects-plugin-editor-gizmo 2.0.0-alpha.24 → 2.0.0-alpha.26
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
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.0.0-alpha.
|
|
6
|
+
* Version: v2.0.0-alpha.26
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as EFFECTS from '@galacean/effects';
|
|
10
|
-
import { math, DestroyOptions, glContext, ShaderType, GLSLVersion, Material, Mesh, GLGeometry, createShaderWithMacros, Texture, noop, Geometry, Transform, effectsClass, ParticleSystemRenderer, RendererComponent, assertExist, ItemBehaviour, HitTestType, spec, removeItem, RenderPass, RenderPassPriorityPostprocess, TextureLoadAction, RenderPassPriorityPrepare, AbstractPlugin, registerPlugin, VFXItem, logger } from '@galacean/effects';
|
|
10
|
+
import { math, DestroyOptions, glContext, ShaderType, GLSLVersion, Material, Mesh, GLGeometry, createShaderWithMacros, Texture, noop, Geometry, Transform, serialize, effectsClass, ParticleSystemRenderer, RendererComponent, assertExist, ItemBehaviour, HitTestType, spec, removeItem, RenderPass, RenderPassPriorityPostprocess, TextureLoadAction, RenderPassPriorityPrepare, AbstractPlugin, registerPlugin, VFXItem, logger } from '@galacean/effects';
|
|
11
11
|
|
|
12
12
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
13
13
|
try {
|
|
@@ -258,10 +258,14 @@ function destroyWireframeMesh(mesh) {
|
|
|
258
258
|
geometries: DestroyOptions.keep
|
|
259
259
|
});
|
|
260
260
|
}
|
|
261
|
-
function updateWireframeMesh(
|
|
262
|
-
wireframe.material.cloneUniforms(
|
|
263
|
-
var geometry =
|
|
261
|
+
function updateWireframeMesh(originGeometry, originMaterial, wireframe, type) {
|
|
262
|
+
wireframe.material.cloneUniforms(originMaterial);
|
|
263
|
+
var geometry = originGeometry;
|
|
264
264
|
var wireframeGeometry = wireframe.firstGeometry();
|
|
265
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(originMaterial.enabledMacros)), _step; !(_step = _iterator()).done;){
|
|
266
|
+
var macro = _step.value;
|
|
267
|
+
wireframe.material.enableMacro(macro, originMaterial.enabledMacros[macro]);
|
|
268
|
+
}
|
|
265
269
|
if (type === 0) {
|
|
266
270
|
// 线框模式不绘制模型的时候,drawCount 为负数
|
|
267
271
|
var drawCount = Math.abs(geometry.getDrawCount());
|
|
@@ -307,14 +311,14 @@ function createModeWireframe(engine, mesh, color) {
|
|
|
307
311
|
data: new Uint32Array(0)
|
|
308
312
|
}
|
|
309
313
|
});
|
|
310
|
-
var
|
|
314
|
+
var _mesh_material_shader_shaderData = mesh.material.shader.shaderData, vertex = _mesh_material_shader_shaderData.vertex, fragment = _mesh_material_shader_shaderData.fragment;
|
|
311
315
|
var materialOptions = _extends({}, mesh.material.props);
|
|
312
|
-
var newMacros = [
|
|
316
|
+
var newMacros = [
|
|
313
317
|
[
|
|
314
318
|
"PREVIEW_BORDER",
|
|
315
319
|
1
|
|
316
320
|
]
|
|
317
|
-
]
|
|
321
|
+
];
|
|
318
322
|
var _mesh_name;
|
|
319
323
|
materialOptions.shader = {
|
|
320
324
|
vertex: createGizmoShader(newMacros, vertex, ShaderType.vertex, level),
|
|
@@ -324,9 +328,9 @@ function createModeWireframe(engine, mesh, color) {
|
|
|
324
328
|
glslVersion: engine.gpuCapability.level === 2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1
|
|
325
329
|
};
|
|
326
330
|
var material = Material.create(engine, materialOptions);
|
|
327
|
-
material.depthTest =
|
|
331
|
+
material.depthTest = true;
|
|
328
332
|
material.setVector4("uPreviewColor", new Vector4(color[0], color[1], color[2], 1));
|
|
329
|
-
return updateWireframeMesh(mesh, Mesh.create(engine, {
|
|
333
|
+
return updateWireframeMesh(mesh.geometry, mesh.material, Mesh.create(engine, {
|
|
330
334
|
geometry: geometry,
|
|
331
335
|
material: material,
|
|
332
336
|
priority: 3000,
|
|
@@ -2807,6 +2811,7 @@ var GizmoComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
|
2807
2811
|
var _this;
|
|
2808
2812
|
_this = ItemBehaviour.apply(this, arguments) || this;
|
|
2809
2813
|
_this.boundingMap = new Map();
|
|
2814
|
+
_this.coordinateSpace = 0;
|
|
2810
2815
|
_this.mat = Matrix4.fromIdentity();
|
|
2811
2816
|
_this.wireframeMeshes = [];
|
|
2812
2817
|
/**
|
|
@@ -3039,6 +3044,7 @@ var GizmoComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
|
3039
3044
|
break;
|
|
3040
3045
|
case GizmoSubType.modelWireframe:
|
|
3041
3046
|
this.needCreateModelContent = true;
|
|
3047
|
+
this.createModelContent(targetItem, gizmoPlugin.meshToAdd);
|
|
3042
3048
|
break;
|
|
3043
3049
|
case GizmoSubType.box:
|
|
3044
3050
|
case GizmoSubType.sphere:
|
|
@@ -3092,20 +3098,18 @@ var GizmoComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
|
3092
3098
|
if (this.wireframeMesh && this.targetItem) {
|
|
3093
3099
|
var particle = this.targetItem.getComponent(ParticleSystemRenderer);
|
|
3094
3100
|
if (particle) {
|
|
3095
|
-
updateWireframeMesh(particle.particleMesh.mesh, this.wireframeMesh, WireframeGeometryType.quad);
|
|
3101
|
+
updateWireframeMesh(particle.particleMesh.mesh.geometry, particle.particleMesh.mesh.material, this.wireframeMesh, WireframeGeometryType.quad);
|
|
3096
3102
|
this.wireframeMesh.worldMatrix = particle.particleMesh.mesh.worldMatrix;
|
|
3097
3103
|
}
|
|
3098
3104
|
}
|
|
3099
3105
|
} else if (gizmoSubType === GizmoSubType.modelWireframe) {
|
|
3100
3106
|
if (this.wireframeMesh && this.targetItem) {
|
|
3101
3107
|
var _this_targetItem_getComponent;
|
|
3102
|
-
//@ts-expect-error
|
|
3103
|
-
var meshes = (_this_targetItem_getComponent = this.targetItem.getComponent(RendererComponent)) == null ? void 0 : _this_targetItem_getComponent.content.
|
|
3108
|
+
//@ts-expect-error TODO 和 3D 类型解耦
|
|
3109
|
+
var meshes = (_this_targetItem_getComponent = this.targetItem.getComponent(RendererComponent)) == null ? void 0 : _this_targetItem_getComponent.content.subMeshes;
|
|
3104
3110
|
var wireframeMeshes = this.wireframeMeshes;
|
|
3105
3111
|
if ((meshes == null ? void 0 : meshes.length) > 0) {
|
|
3106
|
-
|
|
3107
|
-
updateWireframeMesh(meshes[i], wireframeMeshes[i], WireframeGeometryType.triangle);
|
|
3108
|
-
}
|
|
3112
|
+
updateWireframeMesh(meshes[0].geometry.geometry, meshes[0].material.effectMaterial, wireframeMeshes[0], WireframeGeometryType.triangle);
|
|
3109
3113
|
}
|
|
3110
3114
|
}
|
|
3111
3115
|
} else {
|
|
@@ -3115,7 +3119,12 @@ var GizmoComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
|
3115
3119
|
var worldPos = new Vector3();
|
|
3116
3120
|
var worldQuat = new Quaternion();
|
|
3117
3121
|
var worldScale = new Vector3(1, 1, 1);
|
|
3118
|
-
|
|
3122
|
+
// Scale Gizmo 没有世界空间
|
|
3123
|
+
if (this.coordinateSpace == 0 || gizmoSubType === GizmoSubType.scale) {
|
|
3124
|
+
this.targetItem.transform.assignWorldTRS(worldPos, worldQuat);
|
|
3125
|
+
} else {
|
|
3126
|
+
this.targetItem.transform.assignWorldTRS(worldPos);
|
|
3127
|
+
}
|
|
3119
3128
|
var targetTransform = new Transform({
|
|
3120
3129
|
position: worldPos,
|
|
3121
3130
|
quat: worldQuat,
|
|
@@ -3278,21 +3287,23 @@ var GizmoComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
|
3278
3287
|
return result;
|
|
3279
3288
|
};
|
|
3280
3289
|
_proto.createModelContent = function createModelContent(item, meshesToAdd) {
|
|
3281
|
-
var _this = this;
|
|
3282
3290
|
var _item_composition;
|
|
3283
3291
|
var modelComponent = item.getComponent(RendererComponent);
|
|
3284
|
-
//@ts-expect-error
|
|
3285
|
-
var
|
|
3292
|
+
//@ts-expect-error TODO 和 3D 类型解耦
|
|
3293
|
+
var psubMesh = modelComponent.content.subMeshes[0];
|
|
3286
3294
|
var engine = (_item_composition = item.composition) == null ? void 0 : _item_composition.renderer.engine;
|
|
3287
3295
|
assertExist(engine);
|
|
3288
|
-
if (
|
|
3296
|
+
if (psubMesh) {
|
|
3289
3297
|
this.targetItem = item;
|
|
3290
3298
|
this.wireframeMeshes = [];
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3299
|
+
var originMesh = Mesh.create(engine, {
|
|
3300
|
+
geometry: psubMesh.geometry.geometry,
|
|
3301
|
+
material: psubMesh.material.effectMaterial,
|
|
3302
|
+
priority: 3000
|
|
3295
3303
|
});
|
|
3304
|
+
var mesh = this.wireframeMesh = createModeWireframe(engine, originMesh, this.color);
|
|
3305
|
+
this.wireframeMeshes.push(mesh);
|
|
3306
|
+
meshesToAdd.push(mesh);
|
|
3296
3307
|
}
|
|
3297
3308
|
};
|
|
3298
3309
|
_proto.createParticleContent = function createParticleContent(item, meshesToAdd) {
|
|
@@ -3401,9 +3412,17 @@ var GizmoComponent = /*#__PURE__*/ function(ItemBehaviour) {
|
|
|
3401
3412
|
};
|
|
3402
3413
|
return GizmoComponent;
|
|
3403
3414
|
}(ItemBehaviour);
|
|
3415
|
+
__decorate([
|
|
3416
|
+
serialize()
|
|
3417
|
+
], GizmoComponent.prototype, "coordinateSpace", void 0);
|
|
3404
3418
|
GizmoComponent = __decorate([
|
|
3405
3419
|
effectsClass("GizmoComponent")
|
|
3406
3420
|
], GizmoComponent);
|
|
3421
|
+
var CoordinateSpace;
|
|
3422
|
+
(function(CoordinateSpace) {
|
|
3423
|
+
CoordinateSpace[CoordinateSpace["Local"] = 0] = "Local";
|
|
3424
|
+
CoordinateSpace[CoordinateSpace["World"] = 1] = "World";
|
|
3425
|
+
})(CoordinateSpace || (CoordinateSpace = {}));
|
|
3407
3426
|
|
|
3408
3427
|
var editorRenderPassName = "editor-gizmo";
|
|
3409
3428
|
var frontRenderPassName = "front-gizmo";
|
|
@@ -3672,7 +3691,7 @@ var EditorGizmoPlugin = /*#__PURE__*/ function(AbstractPlugin) {
|
|
|
3672
3691
|
}(AbstractPlugin);
|
|
3673
3692
|
|
|
3674
3693
|
registerPlugin("editor-gizmo", EditorGizmoPlugin, VFXItem);
|
|
3675
|
-
var version = "2.0.0-alpha.
|
|
3694
|
+
var version = "2.0.0-alpha.26";
|
|
3676
3695
|
logger.info("Plugin editor gizmo version: " + version + ".");
|
|
3677
3696
|
if (version !== EFFECTS.version) {
|
|
3678
3697
|
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!");
|