Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: gizmo rendering problem #58

Merged
merged 5 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/effects-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/effects-core",
"version": "1.1.1",
"version": "1.1.1-alpha.1",
"description": "Galacean Effects runtime core for the web",
"module": "./dist/index.mjs",
"main": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/effects-helper/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/effects-helper",
"version": "1.1.1",
"version": "1.1.1-alpha.1",
"description": "Galacean Effects runtime helper for the web",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/effects-threejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/effects-threejs",
"version": "1.1.1",
"version": "1.1.1-alpha.1",
"description": "Galacean Effects runtime threejs plugin for the web",
"module": "./dist/index.mjs",
"main": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/effects-webgl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/effects-webgl",
"version": "1.1.1",
"version": "1.1.1-alpha.1",
"description": "Galacean Effects runtime webgl for the web",
"types": "./dist/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/effects/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/effects",
"version": "1.1.1",
"version": "1.1.1-alpha.1",
"description": "Galacean Effects runtime player for the web",
"module": "./dist/index.mjs",
"main": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion plugin-packages/alipay-downgrade/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/effects-plugin-alipay-downgrade",
"version": "1.1.1",
"version": "1.1.1-alpha.1",
"description": "Galacean Effects player downgrade plugin for Alipay",
"module": "./dist/index.mjs",
"main": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion plugin-packages/editor-gizmo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/effects-plugin-editor-gizmo",
"version": "1.1.1",
"version": "1.1.1-alpha.2",
"description": "Galacean Effects player editor gizmo plugin",
"module": "./dist/index.mjs",
"main": "./dist/index.js",
Expand Down
18 changes: 14 additions & 4 deletions plugin-packages/editor-gizmo/src/gizmo-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,21 @@ export class EditorGizmoPlugin extends AbstractPlugin {
}
}
}
const wireframeMesh = gizmoVFXItem.wireframeMesh;

if (wireframeMesh && !wireframeMesh.isDestroyed) {
destroyWireframeMesh(wireframeMesh);
this.getEditorRenderPass(composition.renderFrame).removeMesh(wireframeMesh);
if (gizmoVFXItem.wireframeMeshes.length > 0) {
gizmoVFXItem.wireframeMeshes.forEach(mesh => {
if (!mesh.isDestroyed) {
destroyWireframeMesh(mesh);
this.getEditorRenderPass(composition.renderFrame).removeMesh(mesh);
}
});
} else {
const wireframeMesh = gizmoVFXItem.wireframeMesh;

if (wireframeMesh && !wireframeMesh.isDestroyed) {
destroyWireframeMesh(wireframeMesh);
this.getEditorRenderPass(composition.renderFrame).removeMesh(wireframeMesh);
}
}

const arr: GizmoVFXItem[] = composition.loaderData.gizmoItems;
Expand Down
10 changes: 8 additions & 2 deletions plugin-packages/editor-gizmo/src/gizmo-vfx-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export class GizmoVFXItem extends VFXItem<Mesh | undefined> {
hitBounding?: { key: string, position: Vector3 };
mat = Matrix4.fromIdentity();
wireframeMesh?: Mesh;
wireframeMeshes: Mesh[] = [];
spriteMesh?: SpriteMesh;

private engine: Engine;
Expand Down Expand Up @@ -197,9 +198,12 @@ export class GizmoVFXItem extends VFXItem<Mesh | undefined> {

if (ms) {
this.targetItem = item;
this.wireframeMeshes = [];
ms.forEach(m => {
const mesh = this.wireframeMesh = createModeWireframe(engine, m, this.color);

this.wireframeMeshes.push(mesh);

meshesToAdd.push(mesh);
});
}
Expand Down Expand Up @@ -326,10 +330,12 @@ export class GizmoVFXItem extends VFXItem<Mesh | undefined> {
} else if (this.subType === GizmoSubType.modelWireframe) { // 模型线框
if (this.wireframeMesh && this.targetItem) {
const meshes = this.targetItem.content.mriMeshs as Mesh[];
const wireframeMesh = this.wireframeMesh;
const wireframeMeshes = this.wireframeMeshes;

if (meshes?.length > 0) {
meshes.forEach(mesh => updateWireframeMesh(mesh, wireframeMesh, WireframeGeometryType.triangle));
for (let i = 0;i < meshes.length;i++) {
updateWireframeMesh(meshes[i], wireframeMeshes[i], WireframeGeometryType.triangle);
}
}
}
} else { // 几何体模型
Expand Down
11 changes: 8 additions & 3 deletions plugin-packages/editor-gizmo/src/wireframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export enum WireframeGeometryType {
}

export function destroyWireframeMesh (mesh: Mesh) {
//mesh.geometry?.destroy();
mesh.geometry?.dispose();
mesh.dispose({ material: { textures: DestroyOptions.keep }, geometries: DestroyOptions.keep });
}

Expand Down Expand Up @@ -122,7 +122,7 @@ export function createModeWireframe (engine: Engine, mesh: Mesh, color: spec.vec
materialOptions.shader = {
vertex: createGizmoShader(newMarcos, vertex, ShaderType.vertex, level),
fragment: createGizmoShader(newMarcos, fragment, ShaderType.fragment, level),
shared: true,
shared: false,
name: (mesh.name ?? 'unamedmesh') + '_wireframe',
glslVersion: engine.gpuCapability.level === 2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1,
};
Expand Down Expand Up @@ -244,8 +244,13 @@ export class SharedGeometry extends GLGeometry {
super.flush();
}

destroy () {
override dispose () {
// from source geometry
this.buffers = {};
this.bufferProps = {};
super.dispose();
// @ts-expect-error
this.source = null;
}
}

Expand Down
2 changes: 1 addition & 1 deletion plugin-packages/model/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/effects-plugin-model",
"version": "1.1.1",
"version": "1.1.1-alpha.1",
"description": "Galacean Effects player model plugin",
"module": "./dist/index.mjs",
"main": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion plugin-packages/orientation-transformer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/effects-plugin-orientation-transformer",
"version": "1.1.1",
"version": "1.1.1-alpha.1",
"description": "Galacean Effects player orientation transformer plugin",
"module": "./dist/index.mjs",
"main": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion plugin-packages/spine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacean/effects-plugin-spine",
"version": "1.1.1",
"version": "1.1.1-alpha.1",
"description": "Galacean Effects player spine plugin",
"module": "./dist/index.mjs",
"main": "./dist/index.js",
Expand Down
Loading