From 8f684d5fdf819e00df865ac3924cc3e1b4893525 Mon Sep 17 00:00:00 2001 From: Zheeeng Date: Wed, 6 Dec 2023 16:32:36 +0800 Subject: [PATCH 01/25] chore: auto tigger bot review for specific branches --- .coderabbit.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .coderabbit.yaml diff --git a/.coderabbit.yaml b/.coderabbit.yaml new file mode 100644 index 000000000..9cbbc6146 --- /dev/null +++ b/.coderabbit.yaml @@ -0,0 +1,11 @@ +reviews: + auto_review: + enabled: true + drafts: true + base_branches: + - "main" + - "hotfix" + - "dev" + - "feat/*" +chat: + auto_reply: true \ No newline at end of file From 0df5ccb505278491633e131bc6262d683255d47a Mon Sep 17 00:00:00 2001 From: RGCHN Date: Wed, 6 Dec 2023 11:29:57 +0800 Subject: [PATCH 02/25] fix: correct the mean of visible --- .../src/plugins/cal/calculate-item.ts | 2 +- .../src/plugins/particle/particle-system.ts | 2 +- .../src/plugins/particle/particle-vfx-item.ts | 4 ++-- .../src/plugins/sprite/sprite-item.ts | 2 +- .../src/plugins/sprite/sprite-mesh.ts | 6 +++--- .../src/plugins/sprite/sprite-vfx-item.ts | 8 -------- .../src/plugins/text/text-item.ts | 4 +--- .../src/plugins/text/text-loader.ts | 11 ++++++++-- .../src/plugins/text/text-vfx-item.ts | 16 ++++++--------- packages/effects-core/src/render/mesh.ts | 2 +- packages/effects-core/src/vfx-item.ts | 6 ++++-- packages/effects-threejs/src/three-mesh.ts | 4 ++-- packages/effects-webgl/src/gl-renderer.ts | 2 +- plugin-packages/spine/src/spine-vfx-item.ts | 18 +++++++++-------- .../effects-core/composition/plugin.spec.ts | 20 +++++++++---------- 15 files changed, 51 insertions(+), 56 deletions(-) diff --git a/packages/effects-core/src/plugins/cal/calculate-item.ts b/packages/effects-core/src/plugins/cal/calculate-item.ts index bfd46c736..b276cdee0 100644 --- a/packages/effects-core/src/plugins/cal/calculate-item.ts +++ b/packages/effects-core/src/plugins/cal/calculate-item.ts @@ -88,7 +88,7 @@ export class CalculateItem { constructor ( props: spec.NullContent, - vfxItem: VFXItem, + protected vfxItem: VFXItem, ) { this.transform = vfxItem.transform; const scale = this.transform.scale; diff --git a/packages/effects-core/src/plugins/particle/particle-system.ts b/packages/effects-core/src/plugins/particle/particle-system.ts index e6963c19c..a6ed090b9 100644 --- a/packages/effects-core/src/plugins/particle/particle-system.ts +++ b/packages/effects-core/src/plugins/particle/particle-system.ts @@ -460,7 +460,7 @@ export class ParticleSystem { } this.meshes = meshes; this.reusable = vfxItem.reusable; - this.setVisible(vfxItem.getVisible()); + this.setVisible(vfxItem.contentVisible); const interaction = props.interaction; if (interaction) { diff --git a/packages/effects-core/src/plugins/particle/particle-vfx-item.ts b/packages/effects-core/src/plugins/particle/particle-vfx-item.ts index f499d6648..1700c6fb2 100644 --- a/packages/effects-core/src/plugins/particle/particle-vfx-item.ts +++ b/packages/effects-core/src/plugins/particle/particle-vfx-item.ts @@ -54,9 +54,9 @@ export class ParticleVFXItem extends VFXItem { } } if (hide) { - this.content.setVisible(true); - } else { this.content.setVisible(false); + } else { + this.content.setVisible(true); this.content.onUpdate(dt); } diff --git a/packages/effects-core/src/plugins/sprite/sprite-item.ts b/packages/effects-core/src/plugins/sprite/sprite-item.ts index e1237986a..589f05dcb 100644 --- a/packages/effects-core/src/plugins/sprite/sprite-item.ts +++ b/packages/effects-core/src/plugins/sprite/sprite-item.ts @@ -289,7 +289,7 @@ export class SpriteItem extends CalculateItem { } else if (init) { ret.texOffset = [0, 0, 1, 1]; } - ret.visible = this.visible; + ret.visible = this.vfxItem.contentVisible; // 图层元素作为父节点时,除了k的大小变换,自身的尺寸也需要传递给子元素,子元素可以通过startSize读取 ret.startSize = this.startSize; diff --git a/packages/effects-core/src/plugins/sprite/sprite-mesh.ts b/packages/effects-core/src/plugins/sprite/sprite-mesh.ts index f8ead6e03..5caedd896 100644 --- a/packages/effects-core/src/plugins/sprite/sprite-mesh.ts +++ b/packages/effects-core/src/plugins/sprite/sprite-mesh.ts @@ -91,7 +91,7 @@ export class SpriteMesh { let pointCount = 0; if (!items.length) { - this.mesh.setVisible(true); + this.mesh.setVisible(false); return true; } @@ -157,7 +157,7 @@ export class SpriteMesh { geometry.setIndexData(indexData); geometry.setAttributeData('aPoint', bundle.aPoint); geometry.setDrawCount(indexLen); - this.mesh.setVisible(!geometry.getDrawCount()); + this.mesh.setVisible(!!geometry.getDrawCount()); this.mesh.priority = items[0].listIndex; for (let i = 0; i < textures.length; i++) { const texture = textures[i]; @@ -195,7 +195,7 @@ export class SpriteMesh { const uQuatStart = start + 8; const uColorStart = start + 12; - if (!selfData.visible) { + if (!selfData.visible && !init) { mainDataArray[uSizeStart + 2] = -1; return; diff --git a/packages/effects-core/src/plugins/sprite/sprite-vfx-item.ts b/packages/effects-core/src/plugins/sprite/sprite-vfx-item.ts index b0a8125e4..349d1d5df 100644 --- a/packages/effects-core/src/plugins/sprite/sprite-vfx-item.ts +++ b/packages/effects-core/src/plugins/sprite/sprite-vfx-item.ts @@ -25,24 +25,16 @@ export class SpriteVFXItem extends VFXItem { } override onLifetimeBegin (composition: Composition, content: SpriteItem) { - this._contentVisible = true; content.active = true; } override onItemRemoved (composition: Composition, content?: SpriteItem) { - this._contentVisible = false; if (content) { delete content.mesh; composition.destroyTextures(content.getTextures()); } } - override handleVisibleChanged (visible: boolean) { - if (this.content) { - this.content.visible = visible; - } - } - override onItemUpdate (dt: number, lifetime: number) { this.content?.updateTime(this.time); } diff --git a/packages/effects-core/src/plugins/text/text-item.ts b/packages/effects-core/src/plugins/text/text-item.ts index 5cd383077..6c7b8425b 100644 --- a/packages/effects-core/src/plugins/text/text-item.ts +++ b/packages/effects-core/src/plugins/text/text-item.ts @@ -63,8 +63,6 @@ export class TextItem extends SpriteItem { // Text this.mesh = new TextMesh(this.engine, this.renderInfo, vfxItem.composition) as unknown as SpriteMesh; - this.mesh.setItems([this]); - this.updateTexture(); } /** @@ -285,7 +283,7 @@ export class TextItem extends SpriteItem { const fontSize = style.fontSize * fontScale; const lineHeight = layout.lineHeight * fontScale; - this.char = this.text.split(''); + this.char = (this.text || '').split(''); this.canvas.width = width ; this.canvas.height = height; diff --git a/packages/effects-core/src/plugins/text/text-loader.ts b/packages/effects-core/src/plugins/text/text-loader.ts index 5949c8f46..cfc2042bc 100644 --- a/packages/effects-core/src/plugins/text/text-loader.ts +++ b/packages/effects-core/src/plugins/text/text-loader.ts @@ -10,7 +10,7 @@ export class TextLoader extends AbstractPlugin { override name = 'text'; addItems: TextVFXItem[] = []; removeItems: TextVFXItem[] = []; - public readonly meshes: Mesh[] = []; // meshSplits对应的mesh数组 每次diff后更新 + public readonly meshes: Mesh[] = []; override onCompositionDestroyed (composition: Composition) { if (composition.reusable) { @@ -26,11 +26,18 @@ export class TextLoader extends AbstractPlugin { override onCompositionUpdate (composition: Composition, dt: number): void { this.addItems.forEach(item => { + if (!item.contentVisible) { + item.content.mesh?.mesh.setVisible(false); + + return; + } else { + item.content.mesh?.mesh.setVisible(true); + } item.content.updateTexture(); if (!item.content.ended && item.content.mesh) { item.content.mesh.updateItem(item.content); + item.content.mesh?.applyChange(); } - item.content.mesh?.applyChange(); }); } diff --git a/packages/effects-core/src/plugins/text/text-vfx-item.ts b/packages/effects-core/src/plugins/text/text-vfx-item.ts index c30f8ee62..4167a057a 100644 --- a/packages/effects-core/src/plugins/text/text-vfx-item.ts +++ b/packages/effects-core/src/plugins/text/text-vfx-item.ts @@ -23,27 +23,22 @@ export class TextVFXItem extends VFXItem { } override onLifetimeBegin (composition: Composition, content: TextItem) { - this._contentVisible = true; content.active = true; - + this.content?.mesh!.setItems([this.content]); + this.content.updateTexture(); } override onItemRemoved (composition: Composition, content?: TextItem) { - this._contentVisible = false; - if (content) { delete content.mesh; composition.destroyTextures(content.getTextures()); } } - override handleVisibleChanged (visible: boolean) { - if (this.content) { - this.content.visible = visible; - } - } - override onItemUpdate (dt: number, lifetime: number) { + if (!this.content) { + return ; + } this.content?.updateTime(this.time); } @@ -112,6 +107,7 @@ export class TextVFXItem extends VFXItem { createWireframeMesh (item: TextItem, color: spec.vec4): TextMesh { const spMesh = new TextMesh(this.composition.getEngine(), { wireframe: true, ...item.renderInfo }, this.composition); + spMesh.mesh.setVisible(true); spMesh.setItems([item]); spMesh.mesh.material.setVector3('uFrameColor', Vector3.fromArray(color)); spMesh.mesh.priority = 999; diff --git a/packages/effects-core/src/render/mesh.ts b/packages/effects-core/src/render/mesh.ts index 2749b737b..0b6d149b1 100644 --- a/packages/effects-core/src/render/mesh.ts +++ b/packages/effects-core/src/render/mesh.ts @@ -54,7 +54,7 @@ export class Mesh implements Disposable { // 各引擎独立实现 priority,重写 getter/setter private _priority: number; - private visible = false; + private visible = true; /** * 创建一个新的 Mesh 对象。 diff --git a/packages/effects-core/src/vfx-item.ts b/packages/effects-core/src/vfx-item.ts index 6fbce2fc6..1c165c5f0 100644 --- a/packages/effects-core/src/vfx-item.ts +++ b/packages/effects-core/src/vfx-item.ts @@ -36,7 +36,7 @@ export type VFXItemProps = } ; -/** +/* * 所有元素的继承的抽象类 */ export abstract class VFXItem implements Disposable { @@ -357,6 +357,7 @@ export abstract class VFXItem implements Disposable { this.transform.setValid(true); this.createContent(); + this._contentVisible = true; this.onLifetimeBegin(this.composition, this.content); this.composition.itemLifetimeEvent(this, true); } @@ -400,7 +401,7 @@ export abstract class VFXItem implements Disposable { this.endBehavior = spec.END_BEHAVIOR_FORWARD; } } else if (this.endBehavior === spec.END_BEHAVIOR_DESTROY) { - this.setVisible(false); + this._contentVisible = false; } lifetime = Math.min(lifetime, 1); } else { @@ -653,6 +654,7 @@ export abstract class VFXItem implements Disposable { if (this.composition) { this.onItemRemoved(this.composition, this._content); this._content = undefined; + this._contentVisible = false; } this.started = false; } diff --git a/packages/effects-threejs/src/three-mesh.ts b/packages/effects-threejs/src/three-mesh.ts index a394176dd..355fb1342 100644 --- a/packages/effects-threejs/src/three-mesh.ts +++ b/packages/effects-threejs/src/three-mesh.ts @@ -70,7 +70,7 @@ export class ThreeMesh extends Mesh implements Sortable { * @param val - 可见性开关 */ override setVisible (val: boolean): void { - this.mesh.visible = !val; + this.mesh.visible = val; } /** @@ -79,7 +79,7 @@ export class ThreeMesh extends Mesh implements Sortable { * @returns */ override getVisible (): boolean { - return !this.mesh.visible; + return this.mesh.visible; } /** diff --git a/packages/effects-webgl/src/gl-renderer.ts b/packages/effects-webgl/src/gl-renderer.ts index 2905308f1..b787606ef 100644 --- a/packages/effects-webgl/src/gl-renderer.ts +++ b/packages/effects-webgl/src/gl-renderer.ts @@ -136,7 +136,7 @@ export class GLRenderer extends Renderer implements Disposable { // console.error(`mesh ${mesh.name} destroyed`, mesh); continue; } - if (mesh.getVisible()) { + if (!mesh.getVisible()) { continue; } if (!mesh.material) { diff --git a/plugin-packages/spine/src/spine-vfx-item.ts b/plugin-packages/spine/src/spine-vfx-item.ts index a8574ab1c..691d3eafd 100644 --- a/plugin-packages/spine/src/spine-vfx-item.ts +++ b/plugin-packages/spine/src/spine-vfx-item.ts @@ -140,19 +140,21 @@ export class SpineVFXItem extends VFXItem { } override onItemUpdate (dt: number, lifetime: number) { - if (lifetime < 0) { - // 还未开始 隐藏一下 - this.setVisible(false); + if (!this.content || !this.content.meshGroups.length) { + return ; + } + const visible = this.contentVisible; - return; + this.content.meshGroups.map((mesh: SpineMesh) => { + mesh.mesh.setVisible(visible); + }); + if (visible) { + this.updateState(dt / 1000); } - this.setVisible(true); - this.updateState(dt / 1000); } override onEnd () { - if (this.endBehavior === spec.END_BEHAVIOR_DESTROY) { - this.setVisible(false); + if (this.endBehavior === spec.END_BEHAVIOR_DESTROY && this.state) { this.state.clearListeners(); this.state.clearTracks(); } diff --git a/web-packages/test/unit/src/effects-core/composition/plugin.spec.ts b/web-packages/test/unit/src/effects-core/composition/plugin.spec.ts index 41d5d53a5..689f0eb30 100644 --- a/web-packages/test/unit/src/effects-core/composition/plugin.spec.ts +++ b/web-packages/test/unit/src/effects-core/composition/plugin.spec.ts @@ -283,22 +283,20 @@ describe('plugin', () => { reusable: true, }); - player.gotoAndStop(1.4); - const item = comp.getItemByName('t2'); - expect(item).to.exist; - expect(item.reusable).to.be.true; - expect(item.visible).to.be.false; - expect(remove).not.to.has.been.called; + comp.gotoAndStop(0.3); + expect(item.contentVisible).to.be.true; + + item.setVisible(false); expect(hide).to.has.been.called.with(false); expect(hide).to.has.been.called.once; - const sp2 = item.handleVisibleChanged = chai.spy('hide2'); - comp.gotoAndStop(0.3); - expect(item.visible).to.be.true; - expect(sp2).to.has.been.called.with(true); - expect(sp2).to.has.been.called.once; + comp.gotoAndStop(1.4); + expect(item).to.exist; + expect(item.reusable).to.be.true; + expect(item.contentVisible).to.be.false; + expect(remove).not.to.has.been.called; comp.dispose(); }); From dd10e77e71bba34e6442dff4880638f87d61cd5b Mon Sep 17 00:00:00 2001 From: RGCHN Date: Wed, 6 Dec 2023 12:03:26 +0800 Subject: [PATCH 03/25] fix: destroyed spine item is visible when clicked in editor --- plugin-packages/spine/src/spine-loader.ts | 2 +- plugin-packages/spine/src/spine-vfx-item.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/plugin-packages/spine/src/spine-loader.ts b/plugin-packages/spine/src/spine-loader.ts index 150621cac..7217aa02e 100644 --- a/plugin-packages/spine/src/spine-loader.ts +++ b/plugin-packages/spine/src/spine-loader.ts @@ -189,7 +189,7 @@ export class SpineLoader extends AbstractPlugin { this.slotGroups.length && this.slotGroups.map(slotGroup => { if (slotGroup) { slotGroup.meshToAdd.forEach(mesh => { - renderFrame.addMeshToDefaultRenderPass(mesh); + mesh.getVisible() && renderFrame.addMeshToDefaultRenderPass(mesh); }); slotGroup.resetMeshes(); } diff --git a/plugin-packages/spine/src/spine-vfx-item.ts b/plugin-packages/spine/src/spine-vfx-item.ts index 691d3eafd..e9aa080e0 100644 --- a/plugin-packages/spine/src/spine-vfx-item.ts +++ b/plugin-packages/spine/src/spine-vfx-item.ts @@ -135,7 +135,6 @@ export class SpineVFXItem extends VFXItem { } this.state.apply(this.skeleton); this.resize(); - this._contentVisible = true; this.updateState(0); } @@ -379,7 +378,7 @@ export class SpineVFXItem extends VFXItem { } getBounds (): BoundsData | undefined { - if (!(this.state && this.skeleton)) { + if (!(this.state && this.skeleton && this.contentVisible)) { return; } this.skeleton.updateWorldTransform(); From 4a5cffd999f376cb83186c8272e50cf527038549 Mon Sep 17 00:00:00 2001 From: RGCHN Date: Wed, 6 Dec 2023 14:14:22 +0800 Subject: [PATCH 04/25] =?UTF-8?q?feat:=20add=20setRotation=E3=80=81setScal?= =?UTF-8?q?e=20and=20setPosition=20method=20in=20class=20Composition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/effects-core/src/composition.ts | 28 +++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/packages/effects-core/src/composition.ts b/packages/effects-core/src/composition.ts index 85f3d6408..67475a9be 100644 --- a/packages/effects-core/src/composition.ts +++ b/packages/effects-core/src/composition.ts @@ -804,24 +804,46 @@ export class Composition implements Disposable, LostHandler { } /** - * 设置合成在 3D 坐标轴上相对移动 + * 设置合成在 3D 坐标轴上相对当前的位移 */ translate (x: number, y: number, z: number) { this.content.translate(x, y, z); } + /** - * 设置合成在 3D 坐标轴上相对旋转(角度) + * 设置合成在 3D 坐标轴上的位移 + */ + setPosition (x: number, y: number, z: number) { + this.content.setPosition(x, y, z); + } + + /** + * 设置合成在 3D 坐标轴上相对当前的旋转(角度) */ rotate (x: number, y: number, z: number) { this.content.rotate(x, y, z); } + /** - * 设置合成在 3D 坐标轴上相对缩放 + * 设置合成在 3D 坐标轴上的旋转(角度) + */ + setRotation (x: number, y: number, z: number) { + this.content.setRotation(x, y, z); + } + /** + * 设置合成在 3D 坐标轴上相对当前的缩放 */ scale (x: number, y: number, z: number) { this.content.scale(x, y, z); } + /** + * 设置合成在 3D 坐标轴上的缩放 + */ + setScale (x: number, y: number, z: number) { + this.content.setScale(x, y, z); + } + /** * 卸载贴图纹理方法,减少内存 */ From 54cd0714d1c5fb48cb50122291daf91c389047a7 Mon Sep 17 00:00:00 2001 From: RGCHN Date: Wed, 6 Dec 2023 14:15:16 +0800 Subject: [PATCH 05/25] fix: setScale error in spine item --- plugin-packages/spine/src/spine-vfx-item.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugin-packages/spine/src/spine-vfx-item.ts b/plugin-packages/spine/src/spine-vfx-item.ts index e9aa080e0..cbaa1240e 100644 --- a/plugin-packages/spine/src/spine-vfx-item.ts +++ b/plugin-packages/spine/src/spine-vfx-item.ts @@ -377,6 +377,12 @@ export class SpineVFXItem extends VFXItem { this.transform.setScale(this.startSize * scaleFactor, this.startSize * scaleFactor, scale.z); } + override setScale (x: number, y: number, z: number) { + const [sx, sy, sz] = this.transform.scale; + + this.transform.setScale(x * sx, y * sy, z * sz); + } + getBounds (): BoundsData | undefined { if (!(this.state && this.skeleton && this.contentVisible)) { return; From 4ae460fb00d0592ddb2cf56eb67fac3d5cc964e4 Mon Sep 17 00:00:00 2001 From: RGCHN Date: Wed, 6 Dec 2023 14:29:17 +0800 Subject: [PATCH 06/25] chore: detail annotation about setPosition method --- packages/effects-core/src/composition.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/effects-core/src/composition.ts b/packages/effects-core/src/composition.ts index 67475a9be..201c5e23e 100644 --- a/packages/effects-core/src/composition.ts +++ b/packages/effects-core/src/composition.ts @@ -811,7 +811,7 @@ export class Composition implements Disposable, LostHandler { } /** - * 设置合成在 3D 坐标轴上的位移 + * 设置合成在 3D 坐标轴上相对原点的位移 */ setPosition (x: number, y: number, z: number) { this.content.setPosition(x, y, z); @@ -825,7 +825,7 @@ export class Composition implements Disposable, LostHandler { } /** - * 设置合成在 3D 坐标轴上的旋转(角度) + * 设置合成在 3D 坐标轴上的相对原点的旋转(角度) */ setRotation (x: number, y: number, z: number) { this.content.setRotation(x, y, z); From a4e79b0dfd62e5dd2ecc3c29352c1d41e046a85b Mon Sep 17 00:00:00 2001 From: RGCHN Date: Thu, 7 Dec 2023 11:16:02 +0800 Subject: [PATCH 07/25] chore: modify annotation --- packages/effects-core/src/composition.ts | 5 ++-- .../src/plugins/text/text-item.ts | 30 +++++++++---------- .../src/plugins/text/text-loader.ts | 2 +- packages/effects-core/src/vfx-item.ts | 2 +- plugin-packages/spine/src/spine-vfx-item.ts | 4 +-- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/packages/effects-core/src/composition.ts b/packages/effects-core/src/composition.ts index 201c5e23e..a5dbca154 100644 --- a/packages/effects-core/src/composition.ts +++ b/packages/effects-core/src/composition.ts @@ -9,14 +9,15 @@ import { Transform } from './transform'; import type { VFXItem, VFXItemContent, VFXItemProps } from './vfx-item'; import type { ItemNode } from './comp-vfx-item'; import { CompVFXItem } from './comp-vfx-item'; -import type { InteractVFXItem, Plugin, EventSystem, Region } from './plugins'; +import type { InteractVFXItem, Plugin, EventSystem } from './plugins'; import type { PluginSystem } from './plugin-system'; import type { MeshRendererOptions, Renderer, GlobalVolume } from './render'; -import { RenderFrame } from './render'; import type { Texture } from './texture'; import { TextureSourceType } from './texture'; +import { RenderFrame } from './render'; import { Camera } from './camera'; import { setRayFromCamera } from './math'; +import type { Region } from './plugins'; import { CompositionSourceManager } from './composition-source-manager'; export interface CompositionStatistic { diff --git a/packages/effects-core/src/plugins/text/text-item.ts b/packages/effects-core/src/plugins/text/text-item.ts index 6c7b8425b..c1c245fed 100644 --- a/packages/effects-core/src/plugins/text/text-item.ts +++ b/packages/effects-core/src/plugins/text/text-item.ts @@ -1,5 +1,4 @@ import * as spec from '@galacean/effects-specification'; -import type { TextureDataType } from '../../texture'; import { Texture } from '../../texture'; import { TextMesh } from './text-mesh'; import type { TextVFXItem } from './text-vfx-item'; @@ -67,7 +66,7 @@ export class TextItem extends SpriteItem { /** * 设置字号大小 - * @param value 字号 + * @param value - 字号 * @returns */ setFontSize (value: number): void { @@ -83,7 +82,7 @@ export class TextItem extends SpriteItem { /** * 设置字重 - * @param value 字重类型 + * @param value - 字重类型 * @returns */ setFontWeight (value: spec.TextWeight): void { @@ -109,7 +108,7 @@ export class TextItem extends SpriteItem { /** * 设置文本 - * @param value 文本内容 + * @param value - 文本内容 * @returns */ setText (value: string): void { @@ -122,7 +121,7 @@ export class TextItem extends SpriteItem { /** * 设置文本水平布局 - * @param value 布局选项 + * @param value - 布局选项 * @returns */ setTextAlign (value: spec.TextAlignment): void { @@ -135,7 +134,7 @@ export class TextItem extends SpriteItem { /** * 设置文本垂直布局 - * @param value 布局选项 + * @param value - 布局选项 * @returns */ setTextBaseline (value: spec.TextBaseline): void { @@ -148,7 +147,7 @@ export class TextItem extends SpriteItem { /** * 设置文本颜色 - * @param value 颜色内容 + * @param value - 颜色内容 * @returns */ setTextColor (value: spec.RGBAColorValue): void { @@ -161,7 +160,7 @@ export class TextItem extends SpriteItem { /** * 设置文本字体 - * @param value 文本字体 + * @param value - 文本字体 * @returns */ setFontFamily (value: string): void { @@ -174,7 +173,7 @@ export class TextItem extends SpriteItem { /** * 设置外描边文本颜色 - * @param value 颜色内容 + * @param value - 颜色内容 * @returns */ setOutlineColor (value: spec.RGBAColorValue): void { @@ -187,7 +186,7 @@ export class TextItem extends SpriteItem { /** * 设置外描边文本宽度 - * @param value 外描边宽度 + * @param value - 外描边宽度 * @returns */ setOutlineWidth (value: number): void { @@ -200,7 +199,7 @@ export class TextItem extends SpriteItem { /** * 设置阴影模糊 - * @param value 阴影模糊强度 + * @param value - 阴影模糊强度 * @returns */ setShadowBlur (value: number): void { @@ -213,7 +212,7 @@ export class TextItem extends SpriteItem { /** * 设置阴影颜色 - * @param value 阴影颜色 + * @param value - 阴影颜色 * @returns */ setShadowColor (value: spec.RGBAColorValue): void { @@ -226,7 +225,7 @@ export class TextItem extends SpriteItem { /** * 设置阴影水平偏移距离 - * @param value 水平偏移距离 + * @param value - 水平偏移距离 * @returns */ setShadowOffsetX (value: number): void { @@ -239,7 +238,7 @@ export class TextItem extends SpriteItem { /** * 设置阴影水平偏移距离 - * @param value 水平偏移距离 + * @param value - 水平偏移距离 * @returns */ setShadowOffsetY (value: number): void { @@ -252,7 +251,7 @@ export class TextItem extends SpriteItem { /** * 设置字体清晰度 - * @param value 字体清晰度 + * @param value - 字体清晰度 * @returns */ setFontScale (value: number): void { @@ -433,5 +432,4 @@ export class TextItem extends SpriteItem { context!.shadowOffsetX = style.shadowOffsetX ; context!.shadowOffsetY = -style.shadowOffsetY ; } - } diff --git a/packages/effects-core/src/plugins/text/text-loader.ts b/packages/effects-core/src/plugins/text/text-loader.ts index cfc2042bc..469d30263 100644 --- a/packages/effects-core/src/plugins/text/text-loader.ts +++ b/packages/effects-core/src/plugins/text/text-loader.ts @@ -57,6 +57,7 @@ export class TextLoader extends AbstractPlugin { } override onCompositionItemRemoved (composition: Composition, item: VFXItem) { + // FIXME: 此处判断有问题,item 应该先判断 if (item instanceof TextVFXItem && item) { addItem(this.removeItems, item); if (this.addItems.includes(item)) { @@ -76,7 +77,6 @@ export class TextLoader extends AbstractPlugin { removeItem(this.addItems, item); item.content.mesh.mesh.dispose({ material: { textures: DestroyOptions.keep } }); item.dispose(); - } }); diff --git a/packages/effects-core/src/vfx-item.ts b/packages/effects-core/src/vfx-item.ts index 1c165c5f0..3c0691bc7 100644 --- a/packages/effects-core/src/vfx-item.ts +++ b/packages/effects-core/src/vfx-item.ts @@ -36,7 +36,7 @@ export type VFXItemProps = } ; -/* +/** * 所有元素的继承的抽象类 */ export abstract class VFXItem implements Disposable { diff --git a/plugin-packages/spine/src/spine-vfx-item.ts b/plugin-packages/spine/src/spine-vfx-item.ts index cbaa1240e..b8f906412 100644 --- a/plugin-packages/spine/src/spine-vfx-item.ts +++ b/plugin-packages/spine/src/spine-vfx-item.ts @@ -377,8 +377,8 @@ export class SpineVFXItem extends VFXItem { this.transform.setScale(this.startSize * scaleFactor, this.startSize * scaleFactor, scale.z); } - override setScale (x: number, y: number, z: number) { - const [sx, sy, sz] = this.transform.scale; + override setScale (sx: number, sy: number, sz: number) { + const { x, y, z } = this.transform.scale; this.transform.setScale(x * sx, y * sy, z * sz); } From be3a501ff054fe8db09d568aa35a3e462d4360f8 Mon Sep 17 00:00:00 2001 From: liuxi150 Date: Thu, 7 Dec 2023 14:00:32 +0800 Subject: [PATCH 08/25] test: fix case test problem --- web-packages/test/case/2d/src/common/utilities.ts | 12 +++++------- .../test/case/2d/src/inspire/inspire.spec.ts | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/web-packages/test/case/2d/src/common/utilities.ts b/web-packages/test/case/2d/src/common/utilities.ts index e6aeb1f47..8d28b476b 100644 --- a/web-packages/test/case/2d/src/common/utilities.ts +++ b/web-packages/test/case/2d/src/common/utilities.ts @@ -56,22 +56,20 @@ export class TestPlayer { } Math.seedrandom('mars-runtime'); - if (!this.player.oldVersion) { + if (this.oldVersion) { + this.scene = await this.player.loadSceneAsync(url, { ...loadOptions, timeout: 100 }); + Math.seedrandom('mars-runtime'); + this.composition = await this.player.play(this.scene, playerOptions ?? { pauseOnFirstFrame: true }); + } else { getDefaultTemplateCanvasPool().dispose(); const assetManager = new AssetManager(); const json = await assetManager.loadScene(url); compatibleCalculateItem(json.jsonScene.compositions[0]); - this.player.destroyCurrentCompositions(); Math.seedrandom('mars-runtime'); this.composition = this.scene = await this.player.loadScene(json, { ...loadOptions, timeout: 100, autoplay: false }); this.player.gotoAndStop(0); - } else { - // 旧版Mars调用 - this.scene = await this.player.loadSceneAsync(url, { ...loadOptions, timeout: 100 }); - Math.seedrandom('mars-runtime'); - this.composition = await this.player.play(this.scene, playerOptions ?? { pauseOnFirstFrame: true }); } } diff --git a/web-packages/test/case/2d/src/inspire/inspire.spec.ts b/web-packages/test/case/2d/src/inspire/inspire.spec.ts index 9b98abe1c..da22e1caa 100644 --- a/web-packages/test/case/2d/src/inspire/inspire.spec.ts +++ b/web-packages/test/case/2d/src/inspire/inspire.spec.ts @@ -72,7 +72,7 @@ async function checkScene (keyName, name, url) { console.info(`[Compare]: Begin ${name}, ${url}`); const { oldPlayer, newPlayer, renderFramework } = controller; - runtimePlayer.player.compositions.length = 0; + newPlayer.player.compositions.length = 0; await oldPlayer.initialize(url); await newPlayer.initialize(url); const imageCmp = new ImageComparator(pixelDiffThreshold); @@ -130,6 +130,6 @@ async function checkScene (keyName, name, url) { ); console.info(`[Compare]: End ${name}, ${url}`); - runtimePlayer.disposeScene(); + newPlayer.disposeScene(); }); } From 7a48aee9824f0e3fe00b8454d185347453f862ab Mon Sep 17 00:00:00 2001 From: liuxi150 Date: Thu, 7 Dec 2023 16:25:46 +0800 Subject: [PATCH 09/25] test: fix case test problem --- web-packages/test/case/2d/src/common/utilities.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web-packages/test/case/2d/src/common/utilities.ts b/web-packages/test/case/2d/src/common/utilities.ts index 8d28b476b..caa65fc25 100644 --- a/web-packages/test/case/2d/src/common/utilities.ts +++ b/web-packages/test/case/2d/src/common/utilities.ts @@ -62,13 +62,13 @@ export class TestPlayer { this.composition = await this.player.play(this.scene, playerOptions ?? { pauseOnFirstFrame: true }); } else { getDefaultTemplateCanvasPool().dispose(); - const assetManager = new AssetManager(); + const assetManager = new AssetManager({ ...loadOptions, timeout: 100, autoplay: false }); const json = await assetManager.loadScene(url); compatibleCalculateItem(json.jsonScene.compositions[0]); this.player.destroyCurrentCompositions(); - Math.seedrandom('mars-runtime'); this.composition = this.scene = await this.player.loadScene(json, { ...loadOptions, timeout: 100, autoplay: false }); + Math.seedrandom('mars-runtime'); this.player.gotoAndStop(0); } } @@ -120,7 +120,7 @@ export class TestPlayer { } duration () { - return this.composition.compositionSourceManager.totalTime; + return this.composition.content.duration; } isLoop () { From 26ad523a3303821133458b3b5fc4055dcbb6c5bd Mon Sep 17 00:00:00 2001 From: RGCHN Date: Thu, 7 Dec 2023 17:05:31 +0800 Subject: [PATCH 10/25] test: fix spine test case problem --- .../test/case/2d/src/common/utilities.ts | 19 ++++++++++--------- .../test/case/2d/src/inspire/inspire.spec.ts | 2 +- web-packages/test/case/spine/src/index.ts | 3 ++- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/web-packages/test/case/2d/src/common/utilities.ts b/web-packages/test/case/2d/src/common/utilities.ts index caa65fc25..f756c6478 100644 --- a/web-packages/test/case/2d/src/common/utilities.ts +++ b/web-packages/test/case/2d/src/common/utilities.ts @@ -73,22 +73,23 @@ export class TestPlayer { } } - gotoTime (time) { + gotoTime (newtime) { + + let time = newtime; + + // 兼容旧 Player 设置结束行为为重播时在第duration秒会回到第0帧 + if (this.composition.content.endBehavior === 5 && newtime === this.composition.content.duration) { + time -= 0.01; + } const deltaTime = time - this.lastTime; - this.lastTime = time; - // + this.lastTime = newtime; Math.seedrandom(`mars-runtime${time}`); if (this.player.gotoAndStop) { this.player.gotoAndStop(time); - const comp = this.player.getCompositions()[0]; - - if (comp.time === comp.duration && comp.content.endBehavior === 5) { - this.player.gotoAndStop(0); - } } else { this.composition.forwardTime(deltaTime); - this.player.tick(0); + this.player.doTick(0, true); } } diff --git a/web-packages/test/case/2d/src/inspire/inspire.spec.ts b/web-packages/test/case/2d/src/inspire/inspire.spec.ts index da22e1caa..8409cf966 100644 --- a/web-packages/test/case/2d/src/inspire/inspire.spec.ts +++ b/web-packages/test/case/2d/src/inspire/inspire.spec.ts @@ -9,7 +9,7 @@ const { expect } = chai; */ const accumRatioThreshold = 3e-4; const pixelDiffThreshold = 1; -const dumpImageForDebug = false; +const dumpImageForDebug = true; const canvasWidth = 512; const canvasHeight = 512; let controller, cmpStats; diff --git a/web-packages/test/case/spine/src/index.ts b/web-packages/test/case/spine/src/index.ts index 4cab60112..e56e53995 100644 --- a/web-packages/test/case/spine/src/index.ts +++ b/web-packages/test/case/spine/src/index.ts @@ -57,7 +57,8 @@ async function checkScene (keyName, name, url) { await newPlayer.initialize(url); const imageCmp = new ImageComparator(pixelDiffThreshold); const namePrefix = getCurrnetTimeStr(); - const duration = oldPlayer.composition.duration; + const duration = oldPlayer.duration(); + const timeList = [ 0, 0.045, 0.11, 0.13, 0.17, 0.22, 0.28, 0.3, 0.34, 0.38, 0.41, 0.45, 0.51, 0.57, 0.63, 0.65, 0.69, 0.74, 0.77, From 2830f9ca76114be3c581d572d6406b5440ddc062 Mon Sep 17 00:00:00 2001 From: liuxi150 Date: Thu, 7 Dec 2023 17:45:55 +0800 Subject: [PATCH 11/25] test: update case test time stamp --- web-packages/test/case/2d/src/inspire/inspire.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web-packages/test/case/2d/src/inspire/inspire.spec.ts b/web-packages/test/case/2d/src/inspire/inspire.spec.ts index 8409cf966..04a83e5dd 100644 --- a/web-packages/test/case/2d/src/inspire/inspire.spec.ts +++ b/web-packages/test/case/2d/src/inspire/inspire.spec.ts @@ -9,7 +9,7 @@ const { expect } = chai; */ const accumRatioThreshold = 3e-4; const pixelDiffThreshold = 1; -const dumpImageForDebug = true; +const dumpImageForDebug = false; const canvasWidth = 512; const canvasHeight = 512; let controller, cmpStats; @@ -78,9 +78,9 @@ async function checkScene (keyName, name, url) { const imageCmp = new ImageComparator(pixelDiffThreshold); const namePrefix = getCurrnetTimeStr(); const timeList = [ - 0, 0.11, 0.22, 0.34, 0.45, 0.57, 0.65, 0.71, 0.83, 0.96, 1.0, - 1.1, 1.2, 1.3, 1.4, 1.5, 1.7, 1.9, 2.0, 2.2, 2.5, 2.7, 3.0, 3.3, 3.8, - 4.1, 4.7, 5.2, 5.9, 6.8, 7.5, 8.6, 9.7, 9.99, 11.23, 12.5, 15.8, 18.9, + 0, 0.11, 0.22, 0.34, 0.45, 0.57, 0.71, 0.83, 0.96, + 1.1, 1.2, 1.4, 1.7, 1.9, 2.2, 2.5, 2.7, 3.3, 3.8, + 4.7, 5.2, 6.8, 7.5, 8.6, 9.7, 9.99, 12.5, 18.9, ]; let maxDiffValue = 0; From 41804376766b12f65ec68bd8c0889ba177343702 Mon Sep 17 00:00:00 2001 From: RGCHN Date: Thu, 7 Dec 2023 17:51:14 +0800 Subject: [PATCH 12/25] test: delete useless spine case --- web-packages/test/case/spine/src/scene-list.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web-packages/test/case/spine/src/scene-list.ts b/web-packages/test/case/spine/src/scene-list.ts index 546acf062..68a2a5650 100644 --- a/web-packages/test/case/spine/src/scene-list.ts +++ b/web-packages/test/case/spine/src/scene-list.ts @@ -1,8 +1,8 @@ export default { - spring: { - name: '找春天', - url: 'https://mdn.alipayobjects.com/mars/afts/file/A*DKH6SIWKIt4AAAAAAAAAAAAADlB4AQ', - }, + // spring: { + // name: '找春天', + // url: 'https://mdn.alipayobjects.com/mars/afts/file/A*DKH6SIWKIt4AAAAAAAAAAAAADlB4AQ', + // }, tiger: { name: '818理财', url: 'https://mdn.alipayobjects.com/mars/afts/file/A*JaLiQYyUqhoAAAAAAAAAAAAADlB4AQ', From ebe258e8509c770cb256f45712224222511a35b3 Mon Sep 17 00:00:00 2001 From: RGCHN Date: Thu, 7 Dec 2023 18:53:09 +0800 Subject: [PATCH 13/25] test: fix sprite unit test case --- .../effects-core/plugins/sprite/sprite-transform.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web-packages/test/unit/src/effects-core/plugins/sprite/sprite-transform.spec.ts b/web-packages/test/unit/src/effects-core/plugins/sprite/sprite-transform.spec.ts index d13ef38f3..ea683e203 100644 --- a/web-packages/test/unit/src/effects-core/plugins/sprite/sprite-transform.spec.ts +++ b/web-packages/test/unit/src/effects-core/plugins/sprite/sprite-transform.spec.ts @@ -24,14 +24,14 @@ describe('sprite transform', () => { const position = item.transform.getWorldPosition().toArray(); const rotation = item.transform.getWorldRotation().toArray(); - const scale = item.transform.getWorldScale().toArray(); + const scale = item.content.basicTransform.scale; expect(position).to.deep.equals([0, 1, 0], 'position'); expect(rotation[0]).to.eql(0); expect(rotation[1]).to.eql(90); expect(rotation[2] === 0).to.be.true; - expect(item.content.startSize[0]).to.be.closeTo(0.15, 0.0001); - expect(item.content.startSize[1]).to.be.closeTo(0.15, 0.0001); + expect(scale.x).to.be.closeTo(0.15, 0.0001); + expect(scale.y).to.be.closeTo(0.15, 0.0001); const spriteGroup = comp.loaderData.spriteGroup; const mesh = spriteGroup.meshes[0]; const data = mesh.material.getMatrixArray('uMainData'); From 37f07c9eb232babcf13ec029051e27b4851d51a2 Mon Sep 17 00:00:00 2001 From: liuxi150 Date: Thu, 7 Dec 2023 18:58:17 +0800 Subject: [PATCH 14/25] test: fix unit test problem --- .../src/effects-core/plugins/sprite/sprite-combine.spec.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/web-packages/test/unit/src/effects-core/plugins/sprite/sprite-combine.spec.ts b/web-packages/test/unit/src/effects-core/plugins/sprite/sprite-combine.spec.ts index c147d272c..59cbbdc83 100644 --- a/web-packages/test/unit/src/effects-core/plugins/sprite/sprite-combine.spec.ts +++ b/web-packages/test/unit/src/effects-core/plugins/sprite/sprite-combine.spec.ts @@ -61,10 +61,7 @@ describe('combine sprite meshes according to items', () => { // 粒子元素不参与合并 it('[getMeshSplits] combine composition items ignore invisible items and other type', async () => { - player = new Player({ - canvas: document.createElement('canvas'), - manualRender: true, - }); + const comp = await player.loadScene(generateSceneByOpts([ {}, { delay: 1 }, {}, { blending: 1, delay: 1 }, From 3985d945bca9ccd04cda1b511438b34f13ebf3d7 Mon Sep 17 00:00:00 2001 From: liuxi150 Date: Thu, 7 Dec 2023 20:00:07 +0800 Subject: [PATCH 15/25] fix: solve pre composition problem in 3D plugin --- .../model/src/utility/plugin-helper.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plugin-packages/model/src/utility/plugin-helper.ts b/plugin-packages/model/src/utility/plugin-helper.ts index ba6e22ce3..e1eee9ad5 100644 --- a/plugin-packages/model/src/utility/plugin-helper.ts +++ b/plugin-packages/model/src/utility/plugin-helper.ts @@ -760,16 +760,20 @@ export class PluginHelper { return; } - let compIndex = 0; - const jsonScene = scene.jsonScene; + const { jsonScene } = scene; + const compIndexSet: Set = new Set(); + + if (jsonScene.compositionId === undefined) { + compIndexSet.add(0); + } jsonScene.compositions.forEach((comp, index) => { - if (comp.id === jsonScene.compositionId) { - compIndex = index; + if (comp.id === jsonScene.compositionId || composition.refCompositionProps.has(comp.id)) { + compIndexSet.add(index); } }); - if (compIndex >= 0 && compIndex < jsonScene.compositions.length) { + compIndexSet.forEach(compIndex => { const sceneComp = jsonScene.compositions[compIndex]; sceneComp.items.forEach((item, itemId) => { @@ -863,7 +867,7 @@ export class PluginHelper { } } }); - } + }); } From f22c633b1b10ea422ec79a2cf721928bf5364213 Mon Sep 17 00:00:00 2001 From: liuxi150 Date: Fri, 8 Dec 2023 10:30:38 +0800 Subject: [PATCH 16/25] test: update plugin unit test --- plugin-packages/model/test/src/gesture.spec.ts | 2 +- plugin-packages/model/test/src/model-plugin.spec.ts | 8 +++++--- plugin-packages/model/test/src/tree.spec.ts | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugin-packages/model/test/src/gesture.spec.ts b/plugin-packages/model/test/src/gesture.spec.ts index 8bb6013cc..af1ed6725 100644 --- a/plugin-packages/model/test/src/gesture.spec.ts +++ b/plugin-packages/model/test/src/gesture.spec.ts @@ -163,7 +163,7 @@ describe('测试CameraGestureHandler对象接口', function () { }); it('测试其他功能', async function () { - const comp = await generateComposition({ pauseOnFirstFrame: true }); + const comp = await createComposition({ pauseOnFirstFrame: true }); const handler = new CameraGestureHandlerImp(comp); handler.onFocusPoint('extra-camera', [10, 20, 30]); diff --git a/plugin-packages/model/test/src/model-plugin.spec.ts b/plugin-packages/model/test/src/model-plugin.spec.ts index 139514062..13d00a7f0 100644 --- a/plugin-packages/model/test/src/model-plugin.spec.ts +++ b/plugin-packages/model/test/src/model-plugin.spec.ts @@ -1,6 +1,8 @@ /* eslint-disable @typescript-eslint/quotes */ // @ts-nocheck import { Player, HitTestType, spec, math } from '@galacean/effects'; +import { generateComposition } from './utilities'; + const { Vector3 } = math; const { expect } = chai; @@ -63,15 +65,15 @@ describe('mode plugin test', function () { "plugins": ["model"], "_imgs": { "1": [] }, }; - const comp = await generateComposition(player, scn, {}, { pauseOnFirstFrame: true }); + const comp = await generateComposition(player, scn, {}, { autoplay: false }); const cameraItem = comp.getItemByName('camera'); let pos = cameraItem.content.transform.getPosition(); expect(pos.toArray()).to.deep.equal([0, 0, 8]); expect(cameraItem.duration).to.eql(5); - comp.gotoAndPlay(1.9); - pos = cameraItem.content.transform.getPosition().toArray(); + comp.gotoAndStop(1.9); + pos = cameraItem.content.transform.getPosition(); const cp = new Vector3(); cameraItem.transform.assignWorldTRS(cp); diff --git a/plugin-packages/model/test/src/tree.spec.ts b/plugin-packages/model/test/src/tree.spec.ts index 4ccbb3da0..d0968a27c 100644 --- a/plugin-packages/model/test/src/tree.spec.ts +++ b/plugin-packages/model/test/src/tree.spec.ts @@ -1,6 +1,8 @@ // @ts-nocheck import { Player, math, spec } from '@galacean/effects'; import { ModelTreeVFXItem } from '@galacean/effects-plugin-model'; +import { generateComposition } from './utilities'; + const { Vector3 } = math; const { expect } = chai; From c0c487b7b40ba7fd5e0483f045ac4a1f7003e20d Mon Sep 17 00:00:00 2001 From: yiiqii Date: Sat, 9 Dec 2023 22:09:01 +0800 Subject: [PATCH 17/25] build: add vite legacy polyfill --- plugin-packages/alipay-downgrade/vite.config.js | 1 + plugin-packages/model/vite.config.js | 1 + plugin-packages/orientation-transformer/vite.config.js | 1 + plugin-packages/spine/vite.config.js | 1 + 4 files changed, 4 insertions(+) diff --git a/plugin-packages/alipay-downgrade/vite.config.js b/plugin-packages/alipay-downgrade/vite.config.js index 1b0bc81da..dc9e351f4 100644 --- a/plugin-packages/alipay-downgrade/vite.config.js +++ b/plugin-packages/alipay-downgrade/vite.config.js @@ -36,6 +36,7 @@ export default defineConfig(({ mode }) => { plugins: [ legacy({ targets: ['iOS >= 9'], + modernPolyfills: ['es/global-this'], }), glslInner(), tsconfigPaths(), diff --git a/plugin-packages/model/vite.config.js b/plugin-packages/model/vite.config.js index ce2c1cb29..34c3b56a0 100644 --- a/plugin-packages/model/vite.config.js +++ b/plugin-packages/model/vite.config.js @@ -35,6 +35,7 @@ export default defineConfig(({ mode }) => { plugins: [ legacy({ targets: ['iOS >= 9'], + modernPolyfills: ['es/global-this'], }), glslInner(), tsconfigPaths(), diff --git a/plugin-packages/orientation-transformer/vite.config.js b/plugin-packages/orientation-transformer/vite.config.js index 5b3ea19d5..7364adae0 100644 --- a/plugin-packages/orientation-transformer/vite.config.js +++ b/plugin-packages/orientation-transformer/vite.config.js @@ -35,6 +35,7 @@ export default defineConfig(({ mode }) => { plugins: [ legacy({ targets: ['iOS >= 9'], + modernPolyfills: ['es/global-this'], }), glslInner(), tsconfigPaths(), diff --git a/plugin-packages/spine/vite.config.js b/plugin-packages/spine/vite.config.js index 09f9dfb5e..464e12422 100644 --- a/plugin-packages/spine/vite.config.js +++ b/plugin-packages/spine/vite.config.js @@ -36,6 +36,7 @@ export default defineConfig(({ mode }) => { plugins: [ legacy({ targets: ['iOS >= 9'], + modernPolyfills: ['es/global-this'], }), glslInner(), tsconfigPaths(), From ffac3055b55662bcb27e18f7ff7773c1f469ed5d Mon Sep 17 00:00:00 2001 From: yiiqii Date: Mon, 11 Dec 2023 14:31:35 +0800 Subject: [PATCH 18/25] docs: changelog 1.1.0 --- CHANGELOG.md | 16 ++++++++++++++++ packages/effects-core/package.json | 2 +- packages/effects-helper/package.json | 2 +- packages/effects-threejs/package.json | 2 +- packages/effects-webgl/package.json | 2 +- packages/effects/package.json | 2 +- plugin-packages/alipay-downgrade/package.json | 2 +- plugin-packages/editor-gizmo/package.json | 2 +- plugin-packages/model/package.json | 2 +- .../orientation-transformer/package.json | 2 +- plugin-packages/spine/package.json | 2 +- scripts/print-changelog/utils.js | 2 +- 12 files changed, 27 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44a5dbc9f..d5d98db61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,22 @@ - 主版本号:含有破坏性更新和新特性,不在发布周期内。 --- +## 1.1.0 + +`2023-12-11` + +- Feat: Added support for direct parsing and playback of pre-compositions, and unified math library. [#3cd9c82](https://github.com/galacean/effects-runtime/commit/3cd9c8265013407f4aa9b52fe0c838e7ffecb66d) +- Fix: solve pre composition problem in 3D plugin. [#27](https://github.com/galacean/effects-runtime/pull/27) @liuxi150 +- Fix: errors about visible and transform when setting. [#25](https://github.com/galacean/effects-runtime/pull/25) @RGCHN +- Fix: hitTest bug in pre-composition. [#9](https://github.com/galacean/effects-runtime/pull/9) @RGCHN +- Fix: Resolved dragging issue. [#8](https://github.com/galacean/effects-runtime/pull/8) @liuxi150 +- Fix: add id and transform setting from pre-composition item. [#5](https://github.com/galacean/effects-runtime/pull/5) @RGCHN +- Chore: auto tigger bot review for specific branches. [#23](https://github.com/galacean/effects-runtime/pull/23) @zheeeng +- Test: fix plugin unit test. [#28](https://github.com/galacean/effects-runtime/pull/28) @liuxi150 +- Test: fix unit and case test problems. [#26](https://github.com/galacean/effects-runtime/pull/26) @liuxi150 +- Build: support CHANGELOG generation script. [#4](https://github.com/galacean/effects-runtime/pull/4) @yiiqii +- Build: add vite legacy polyfill. [#29](https://github.com/galacean/effects-runtime/pull/29) @yiiqii + ## 1.0.1 `2023-12-04` diff --git a/packages/effects-core/package.json b/packages/effects-core/package.json index 1d13e8028..212a4109a 100644 --- a/packages/effects-core/package.json +++ b/packages/effects-core/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-core", - "version": "1.0.1", + "version": "1.1.0", "description": "Galacean Effects runtime core for the web", "module": "./dist/index.mjs", "main": "./dist/index.js", diff --git a/packages/effects-helper/package.json b/packages/effects-helper/package.json index aa6fab963..b5dd79ec8 100644 --- a/packages/effects-helper/package.json +++ b/packages/effects-helper/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-helper", - "version": "1.0.1", + "version": "1.1.0", "description": "Galacean Effects runtime helper for the web", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", diff --git a/packages/effects-threejs/package.json b/packages/effects-threejs/package.json index 450a5d050..23f34e7a7 100644 --- a/packages/effects-threejs/package.json +++ b/packages/effects-threejs/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-threejs", - "version": "1.0.1", + "version": "1.1.0", "description": "Galacean Effects runtime threejs plugin for the web", "module": "./dist/index.mjs", "main": "./dist/index.js", diff --git a/packages/effects-webgl/package.json b/packages/effects-webgl/package.json index fad97a22d..764839a8b 100644 --- a/packages/effects-webgl/package.json +++ b/packages/effects-webgl/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-webgl", - "version": "1.0.1", + "version": "1.1.0", "description": "Galacean Effects runtime webgl for the web", "types": "./dist/index.d.ts", "files": [ diff --git a/packages/effects/package.json b/packages/effects/package.json index 8e79b6a9d..842dbcc6e 100644 --- a/packages/effects/package.json +++ b/packages/effects/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects", - "version": "1.0.1", + "version": "1.1.0", "description": "Galacean Effects runtime player for the web", "module": "./dist/index.mjs", "main": "./dist/index.js", diff --git a/plugin-packages/alipay-downgrade/package.json b/plugin-packages/alipay-downgrade/package.json index f490b5cff..e5e0f4776 100644 --- a/plugin-packages/alipay-downgrade/package.json +++ b/plugin-packages/alipay-downgrade/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-plugin-alipay-downgrade", - "version": "1.0.1", + "version": "1.1.0", "description": "Galacean Effects player downgrade plugin for Alipay", "module": "./dist/index.mjs", "main": "./dist/index.js", diff --git a/plugin-packages/editor-gizmo/package.json b/plugin-packages/editor-gizmo/package.json index ec37a0d93..45400cf67 100644 --- a/plugin-packages/editor-gizmo/package.json +++ b/plugin-packages/editor-gizmo/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-plugin-editor-gizmo", - "version": "1.0.1", + "version": "1.1.0", "description": "Galacean Effects player editor gizmo plugin", "module": "./dist/index.mjs", "main": "./dist/index.js", diff --git a/plugin-packages/model/package.json b/plugin-packages/model/package.json index 3a0688d4b..904c96b6c 100644 --- a/plugin-packages/model/package.json +++ b/plugin-packages/model/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-plugin-model", - "version": "1.0.1", + "version": "1.1.0", "description": "Galacean Effects player model plugin", "module": "./dist/index.mjs", "main": "./dist/index.js", diff --git a/plugin-packages/orientation-transformer/package.json b/plugin-packages/orientation-transformer/package.json index 6f5fad114..7431bf1ec 100644 --- a/plugin-packages/orientation-transformer/package.json +++ b/plugin-packages/orientation-transformer/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-plugin-orientation-transformer", - "version": "1.0.1", + "version": "1.1.0", "description": "Galacean Effects player orientation transformer plugin", "module": "./dist/index.mjs", "main": "./dist/index.js", diff --git a/plugin-packages/spine/package.json b/plugin-packages/spine/package.json index c7e385c23..a5a14c6d4 100644 --- a/plugin-packages/spine/package.json +++ b/plugin-packages/spine/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-plugin-spine", - "version": "1.0.1", + "version": "1.1.0", "description": "Galacean Effects player spine plugin", "module": "./dist/index.mjs", "main": "./dist/index.js", diff --git a/scripts/print-changelog/utils.js b/scripts/print-changelog/utils.js index fc9482ec4..98e5c0046 100644 --- a/scripts/print-changelog/utils.js +++ b/scripts/print-changelog/utils.js @@ -19,7 +19,7 @@ function printPR(prList) { const authorText = `@${author}`; const urlText = `[#${pr}](${url})`; - console.log(`- ${titleText}。${urlText} ${authorText}`); + console.log(`- ${titleText}. ${urlText} ${authorText}`); if (descriptions.length !== 0) { console.log(descriptions.map(desc => ` - ${desc}`).join('\n')); From 2322e9f62230d023919c5fe2ffc19b8080b7dfcc Mon Sep 17 00:00:00 2001 From: yiiqii Date: Mon, 11 Dec 2023 14:36:27 +0800 Subject: [PATCH 19/25] docs: update changelog --- CHANGELOG.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5d98db61..d1ebd91f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,16 +12,16 @@ `2023-12-11` - Feat: Added support for direct parsing and playback of pre-compositions, and unified math library. [#3cd9c82](https://github.com/galacean/effects-runtime/commit/3cd9c8265013407f4aa9b52fe0c838e7ffecb66d) -- Fix: solve pre composition problem in 3D plugin. [#27](https://github.com/galacean/effects-runtime/pull/27) @liuxi150 -- Fix: errors about visible and transform when setting. [#25](https://github.com/galacean/effects-runtime/pull/25) @RGCHN -- Fix: hitTest bug in pre-composition. [#9](https://github.com/galacean/effects-runtime/pull/9) @RGCHN +- Fix: Solve pre composition problem in 3D plugin. [#27](https://github.com/galacean/effects-runtime/pull/27) @liuxi150 +- Fix: Errors about visible and transform when setting. [#25](https://github.com/galacean/effects-runtime/pull/25) @RGCHN +- Fix: HitTest bug in pre-composition. [#9](https://github.com/galacean/effects-runtime/pull/9) @RGCHN - Fix: Resolved dragging issue. [#8](https://github.com/galacean/effects-runtime/pull/8) @liuxi150 -- Fix: add id and transform setting from pre-composition item. [#5](https://github.com/galacean/effects-runtime/pull/5) @RGCHN -- Chore: auto tigger bot review for specific branches. [#23](https://github.com/galacean/effects-runtime/pull/23) @zheeeng -- Test: fix plugin unit test. [#28](https://github.com/galacean/effects-runtime/pull/28) @liuxi150 -- Test: fix unit and case test problems. [#26](https://github.com/galacean/effects-runtime/pull/26) @liuxi150 -- Build: support CHANGELOG generation script. [#4](https://github.com/galacean/effects-runtime/pull/4) @yiiqii -- Build: add vite legacy polyfill. [#29](https://github.com/galacean/effects-runtime/pull/29) @yiiqii +- Fix: Add id and transform setting from pre-composition item. [#5](https://github.com/galacean/effects-runtime/pull/5) @RGCHN +- Chore: Auto tigger bot review for specific branches. [#23](https://github.com/galacean/effects-runtime/pull/23) @zheeeng +- Test: Fix plugin unit test. [#28](https://github.com/galacean/effects-runtime/pull/28) @liuxi150 +- Test: Fix unit and case test problems. [#26](https://github.com/galacean/effects-runtime/pull/26) @liuxi150 +- Build: Support CHANGELOG generation script. [#4](https://github.com/galacean/effects-runtime/pull/4) @yiiqii +- Build: Add vite legacy polyfill. [#29](https://github.com/galacean/effects-runtime/pull/29) @yiiqii ## 1.0.1 From e84718c0e9e109d3915d460741871db02f16778b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=84=8F=E7=BB=AE?= Date: Tue, 12 Dec 2023 10:10:53 +0800 Subject: [PATCH 20/25] Update packages/effects-core/src/plugins/text/text-vfx-item.ts Co-authored-by: Zheeeng --- packages/effects-core/src/plugins/text/text-vfx-item.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/effects-core/src/plugins/text/text-vfx-item.ts b/packages/effects-core/src/plugins/text/text-vfx-item.ts index 4167a057a..1226b7245 100644 --- a/packages/effects-core/src/plugins/text/text-vfx-item.ts +++ b/packages/effects-core/src/plugins/text/text-vfx-item.ts @@ -25,6 +25,7 @@ export class TextVFXItem extends VFXItem { override onLifetimeBegin (composition: Composition, content: TextItem) { content.active = true; this.content?.mesh!.setItems([this.content]); + this.content?.mesh?.setItems([this.content]); this.content.updateTexture(); } From 8e9ddacfb4e16cfeecae863a3c013fe969a6cc47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=84=8F=E7=BB=AE?= Date: Tue, 12 Dec 2023 10:18:51 +0800 Subject: [PATCH 21/25] Update packages/effects-core/src/plugins/text/text-vfx-item.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- packages/effects-core/src/plugins/text/text-vfx-item.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/effects-core/src/plugins/text/text-vfx-item.ts b/packages/effects-core/src/plugins/text/text-vfx-item.ts index 1226b7245..308903c59 100644 --- a/packages/effects-core/src/plugins/text/text-vfx-item.ts +++ b/packages/effects-core/src/plugins/text/text-vfx-item.ts @@ -24,7 +24,6 @@ export class TextVFXItem extends VFXItem { override onLifetimeBegin (composition: Composition, content: TextItem) { content.active = true; - this.content?.mesh!.setItems([this.content]); this.content?.mesh?.setItems([this.content]); this.content.updateTexture(); } From 5c0f2cd2da09ab5aba594c445b3c258a56187593 Mon Sep 17 00:00:00 2001 From: yiiqii Date: Wed, 13 Dec 2023 18:14:19 +0800 Subject: [PATCH 22/25] docs: update the README and provide the Chinese version --- README-zh_CN.md | 56 ++++++++++++++++++++++++++++ README.md | 91 ++++++++++++++++------------------------------ docs/developing.md | 81 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+), 60 deletions(-) create mode 100644 README-zh_CN.md create mode 100644 docs/developing.md diff --git a/README-zh_CN.md b/README-zh_CN.md new file mode 100644 index 000000000..214c0a9d4 --- /dev/null +++ b/README-zh_CN.md @@ -0,0 +1,56 @@ +
+ +

Galacean Effects

+ +加载并渲染酷炫的动效,通过 effects-core 提供的 APIs 也可以让你的引擎使用动效产物,快速的接入图层、粒子等动画效果。 + +![GitHub release (with filter)](https://img.shields.io/github/v/release/galacean/effects-runtime) +![GitHub License](https://img.shields.io/github/license/galacean/effects-runtime) +![GitHub top language](https://img.shields.io/github/languages/top/galacean/effects-runtime) + +[更新日志](./CHANGELOG.md) · [报告问题][github-issues-url] · [特性需求][github-issues-url] · [English](./README.md) · 中文 + +![](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png) + +[github-issues-url]: https://github.com/galacean/effects-runtime/issues +
+ +## 安装 + +``` bash +npm install @galacean/effects --save +``` + +``` bash +pnpm add @galacean/effects +``` + +## 示例 + +``` html +
+``` + +``` ts +import { Player } from '@galacean/effects'; + +// 1. 实例化一个播放器 +const player = new Player({ + container: document.getElementById('J-Container'), +}); + +// 2. 加载并播放动效资源 +player.loadScene('./demo.json'); +``` + +> 通过 [Galacean Effects](https://galacean.antgroup.com/effects/) 编辑器获取 `demo.json` 产物 + +## 相关文档 + +- [开发文档](https://galacean.antgroup.com/effects/#/user/dgmswcgk63yfngku) +- [接入指南](https://galacean.antgroup.com/effects/#/user/ti4f2yx1rot4hs1n) +- [API 文档](https://galacean.antgroup.com/effects/#/api) +- 其他链接: + - [本地开发](docs/developing.md) + + diff --git a/README.md b/README.md index d47046252..7a4bf968c 100644 --- a/README.md +++ b/README.md @@ -1,85 +1,56 @@ -# Galacean Effects Runtime +
+ +

Galacean Effects

+ +It can load and render cool animation effects, The APIs provided by effects-core allow your engine to quickly access animation data such as layer and particle animation. ![GitHub release (with filter)](https://img.shields.io/github/v/release/galacean/effects-runtime) ![GitHub License](https://img.shields.io/github/license/galacean/effects-runtime) ![GitHub top language](https://img.shields.io/github/languages/top/galacean/effects-runtime) -Galacean Effects runtime, It can load and render cool animation effects, The APIs provided by effects-core allow your engine to quickly access animation data such as layer and particle animation. - -## [Integration Guide](https://galacean.antgroup.com/effects/#/user/ti4f2yx1rot4hs1n) - -## [API Documentation](https://galacean.antgroup.com/effects/#/api) +[Changelog](./CHANGELOG.md) · [Report Bug][github-issues-url] · [Request Feature][github-issues-url] · English · [中文](./README-zh_CN.md) -## Development +![](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png) -### Environment Setup +[github-issues-url]: https://github.com/galacean/effects-runtime/issues +
-- Node.js `>= 16.0.0` -- [Pnpm](https://pnpm.io/) `latest` - - Install: - - `npm install -g pnpm` - - Upgrade: - - `pnpm install -g pnpm` - -### Getting Started +## Install ``` bash -# 1. Install dependencies (first time) -pnpm install -# 2. Start the demo -pnpm dev +npm install @galacean/effects ``` -> Open in browser: http://localhost:8080/ - -## Plugin Example - ``` bash -# demo -pnpm --filter @galacean/xxx dev +pnpm add @galacean/effects ``` -> Open in browser: http://localhost:8081/demo/ - -### Low-End Device Testing +## Usage -``` bash -# Run the legacy version of the demo -pnpm preview +``` html +
``` -## Testing +``` ts +import { Player } from '@galacean/effects'; -``` bash -pnpm test +// 1. Instantiate a player +const player = new Player({ + container: document.getElementById('J-Container'), +}); + +// 2. Load and play the animation resource +player.loadScene('./demo.json'); ``` -> Open in browser: http://localhost:9090/ +> Get the `demo.json` by using the [Galacean Effects](https://galacean.antgroup.com/effects/) editor. -### Installing Single Packages +## Documentation -``` bash -# Install to the root directory -pnpm add ajv@^6.5.3 -w -D -# Install to a specific package -pnpm add ajv@^6.5.3 --filter @galacean/effects-core -``` +- [Development Documentation](https://galacean.antgroup.com/effects/#/user/dgmswcgk63yfngku) +- [Integration Guide](https://galacean.antgroup.com/effects/#/user/ti4f2yx1rot4hs1n) +- [API Documentation](https://galacean.antgroup.com/effects/#/api) +- Useful Links: + - [Developing](docs/developing.md) -## Other Commands -``` bash -# lint -pnpm lint -# Type checking -pnpm check:ts -# Clean all ignore files -pnpm clean:all -# Build packages -pnpm build -# Build plugins -pnpm build:plugins -# Generate API documentation -pnpm build:docs -# Build a specific package -pnpm --filter @galacean/xxx build -``` diff --git a/docs/developing.md b/docs/developing.md new file mode 100644 index 000000000..7f4d6a46c --- /dev/null +++ b/docs/developing.md @@ -0,0 +1,81 @@ +# How to build Galacean Effects and the examples + +## Prerequisites + +- Node.js `>= 16.0.0` +- [Pnpm](https://pnpm.io/) `latest` + - Install: + - `npm install -g pnpm` + - Upgrade: + - `pnpm install -g pnpm` + +## Quick Start + +``` bash +# 1. clone from github +git clone https://github.com/galacean/effects-runtime \ + && cd effects-runtime +# 2. Install dependencies (first time) +pnpm install +# 3. Start the demo +pnpm dev +``` + +> Open in browser: http://localhost:8080/ + +## Build + +``` bash +# Build packages +pnpm build +# Build plugins +pnpm build:plugins +``` + +## Plugin Example + +``` bash +# demo +pnpm --filter @galacean/xxx dev +``` + +> Open in browser: http://localhost:8081/demo/ + +## Testing + +``` bash +pnpm test +``` + +> Open in browser: http://localhost:9090/ + +### Low-End Device Testing + +``` bash +# Run the legacy version of the demo +pnpm preview +``` + +## Other Commands + +``` bash +# lint +pnpm lint +# Type checking +pnpm check:ts +# Clean all ignore files +pnpm clean:all +# Generate API documentation +pnpm build:docs +# Build a specific package +pnpm --filter @galacean/xxx build +``` + +Installing Single Packages: + +``` bash +# Install to the root directory +pnpm add ajv@^6.5.3 -w -D +# Install to a specific package +pnpm add ajv@^6.5.3 --filter @galacean/effects-core +``` From 0fe839bd328a991c023d7adf9692d161344daaef Mon Sep 17 00:00:00 2001 From: RGCHN Date: Wed, 13 Dec 2023 16:12:46 +0800 Subject: [PATCH 23/25] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E9=A2=84?= =?UTF-8?q?=E5=90=88=E6=88=90=E5=85=83=E7=B4=A0=E7=9A=84=20delay=20?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/effects-core/src/comp-vfx-item.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/effects-core/src/comp-vfx-item.ts b/packages/effects-core/src/comp-vfx-item.ts index 243984539..c12f0453f 100644 --- a/packages/effects-core/src/comp-vfx-item.ts +++ b/packages/effects-core/src/comp-vfx-item.ts @@ -88,6 +88,7 @@ export class CompVFXItem extends VFXItem { item = new CompVFXItem({ ...props, refId, + delay: itemProps.delay, id: itemProps.id, name: itemProps.name, duration: itemProps.duration, From d4bcefa6dcb8ef375ae8a7257f1b811e3b2f20bc Mon Sep 17 00:00:00 2001 From: RGCHN Date: Wed, 13 Dec 2023 19:42:44 +0800 Subject: [PATCH 24/25] fix: destroyed pre-comp item won't disappear when setting reusable --- .../effects-core/src/plugins/particle/particle-vfx-item.ts | 7 ++----- packages/effects-core/src/vfx-item.ts | 7 +++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/effects-core/src/plugins/particle/particle-vfx-item.ts b/packages/effects-core/src/plugins/particle/particle-vfx-item.ts index 1700c6fb2..5e950aa56 100644 --- a/packages/effects-core/src/plugins/particle/particle-vfx-item.ts +++ b/packages/effects-core/src/plugins/particle/particle-vfx-item.ts @@ -18,10 +18,6 @@ export class ParticleVFXItem extends VFXItem { return spec.ItemType.particle; } - override get contentVisible () { - return !this.destroyed; - } - override onConstructed (props: spec.ParticleItem) { this.particle = props.content as unknown as ParticleSystemProps; } @@ -40,7 +36,8 @@ export class ParticleVFXItem extends VFXItem { override onItemUpdate (dt: number, lifetime: number) { if (this.content) { - let hide = !this.visible; + let hide = !this.contentVisible; + const parentItem = this.parentId && this.composition?.getItemByID(this.parentId); if (!hide && parentItem) { diff --git a/packages/effects-core/src/vfx-item.ts b/packages/effects-core/src/vfx-item.ts index 3c0691bc7..ab6bb9ed7 100644 --- a/packages/effects-core/src/vfx-item.ts +++ b/packages/effects-core/src/vfx-item.ts @@ -402,6 +402,12 @@ export abstract class VFXItem implements Disposable { } } else if (this.endBehavior === spec.END_BEHAVIOR_DESTROY) { this._contentVisible = false; + + // 预合成配置 reusable 且销毁时, 需要隐藏其中的元素 + if ((this.type as spec.ItemType) === spec.ItemType.composition) { + this.handleVisibleChanged(false); + this.onItemUpdate(0, lifetime); + } } lifetime = Math.min(lifetime, 1); } else { @@ -679,6 +685,7 @@ export abstract class VFXItem implements Disposable { this.reset(); this.onUpdate = () => -1; this.composition = null; + this._contentVisible = false; this.transform.setValid(false); } } From c6354d4fd27ef305398cd8cb00793165cb05eb6e Mon Sep 17 00:00:00 2001 From: yiiqii Date: Thu, 14 Dec 2023 14:47:33 +0800 Subject: [PATCH 25/25] docs: changelog 1.1.1 --- CHANGELOG.md | 6 ++++++ packages/effects-core/package.json | 2 +- packages/effects-helper/package.json | 2 +- packages/effects-threejs/package.json | 2 +- packages/effects-webgl/package.json | 2 +- packages/effects/package.json | 2 +- plugin-packages/alipay-downgrade/package.json | 2 +- plugin-packages/editor-gizmo/package.json | 2 +- plugin-packages/model/package.json | 2 +- plugin-packages/orientation-transformer/package.json | 2 +- plugin-packages/spine/package.json | 2 +- 11 files changed, 16 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1ebd91f9..638a0690b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ - 主版本号:含有破坏性更新和新特性,不在发布周期内。 --- +## 1.1.1 + +`2023-12-14` + +- Fix: Error about delay and disappear in pre-comp item. [#38](https://github.com/galacean/effects-runtime/pull/38) @RGCHN + ## 1.1.0 `2023-12-11` diff --git a/packages/effects-core/package.json b/packages/effects-core/package.json index 212a4109a..7b0e8cf14 100644 --- a/packages/effects-core/package.json +++ b/packages/effects-core/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-core", - "version": "1.1.0", + "version": "1.1.1", "description": "Galacean Effects runtime core for the web", "module": "./dist/index.mjs", "main": "./dist/index.js", diff --git a/packages/effects-helper/package.json b/packages/effects-helper/package.json index b5dd79ec8..f427948e7 100644 --- a/packages/effects-helper/package.json +++ b/packages/effects-helper/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-helper", - "version": "1.1.0", + "version": "1.1.1", "description": "Galacean Effects runtime helper for the web", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", diff --git a/packages/effects-threejs/package.json b/packages/effects-threejs/package.json index 23f34e7a7..e219086d6 100644 --- a/packages/effects-threejs/package.json +++ b/packages/effects-threejs/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-threejs", - "version": "1.1.0", + "version": "1.1.1", "description": "Galacean Effects runtime threejs plugin for the web", "module": "./dist/index.mjs", "main": "./dist/index.js", diff --git a/packages/effects-webgl/package.json b/packages/effects-webgl/package.json index 764839a8b..1a7aa8fd5 100644 --- a/packages/effects-webgl/package.json +++ b/packages/effects-webgl/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-webgl", - "version": "1.1.0", + "version": "1.1.1", "description": "Galacean Effects runtime webgl for the web", "types": "./dist/index.d.ts", "files": [ diff --git a/packages/effects/package.json b/packages/effects/package.json index 842dbcc6e..1b6ae1385 100644 --- a/packages/effects/package.json +++ b/packages/effects/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects", - "version": "1.1.0", + "version": "1.1.1", "description": "Galacean Effects runtime player for the web", "module": "./dist/index.mjs", "main": "./dist/index.js", diff --git a/plugin-packages/alipay-downgrade/package.json b/plugin-packages/alipay-downgrade/package.json index e5e0f4776..afb94de97 100644 --- a/plugin-packages/alipay-downgrade/package.json +++ b/plugin-packages/alipay-downgrade/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-plugin-alipay-downgrade", - "version": "1.1.0", + "version": "1.1.1", "description": "Galacean Effects player downgrade plugin for Alipay", "module": "./dist/index.mjs", "main": "./dist/index.js", diff --git a/plugin-packages/editor-gizmo/package.json b/plugin-packages/editor-gizmo/package.json index 45400cf67..574340029 100644 --- a/plugin-packages/editor-gizmo/package.json +++ b/plugin-packages/editor-gizmo/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-plugin-editor-gizmo", - "version": "1.1.0", + "version": "1.1.1", "description": "Galacean Effects player editor gizmo plugin", "module": "./dist/index.mjs", "main": "./dist/index.js", diff --git a/plugin-packages/model/package.json b/plugin-packages/model/package.json index 904c96b6c..2c9871212 100644 --- a/plugin-packages/model/package.json +++ b/plugin-packages/model/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-plugin-model", - "version": "1.1.0", + "version": "1.1.1", "description": "Galacean Effects player model plugin", "module": "./dist/index.mjs", "main": "./dist/index.js", diff --git a/plugin-packages/orientation-transformer/package.json b/plugin-packages/orientation-transformer/package.json index 7431bf1ec..270e65084 100644 --- a/plugin-packages/orientation-transformer/package.json +++ b/plugin-packages/orientation-transformer/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-plugin-orientation-transformer", - "version": "1.1.0", + "version": "1.1.1", "description": "Galacean Effects player orientation transformer plugin", "module": "./dist/index.mjs", "main": "./dist/index.js", diff --git a/plugin-packages/spine/package.json b/plugin-packages/spine/package.json index a5a14c6d4..19a68fa83 100644 --- a/plugin-packages/spine/package.json +++ b/plugin-packages/spine/package.json @@ -1,6 +1,6 @@ { "name": "@galacean/effects-plugin-spine", - "version": "1.1.0", + "version": "1.1.1", "description": "Galacean Effects player spine plugin", "module": "./dist/index.mjs", "main": "./dist/index.js",