Skip to content

Commit

Permalink
Merge origin/main into origin/feat/2.0 (#33)
Browse files Browse the repository at this point in the history
* chore: auto tigger bot review for specific branches

* fix: correct the mean of visible

* fix: destroyed spine item is visible when clicked in editor

* feat: add setRotation、setScale and setPosition method in class Composition

* fix: setScale error in spine item

* chore: detail annotation about setPosition method

* chore: modify annotation

* test: fix case test problem

* test: fix case test problem

* test: fix spine test case problem

* test: update case test time stamp

* test: delete useless spine case

* test: fix sprite unit test case

* test: fix unit test problem

* fix: solve pre composition problem in 3D plugin

* test: update plugin unit test

* build: add vite legacy polyfill

* docs: changelog 1.1.0

* docs: update changelog

* Update packages/effects-core/src/plugins/text/text-vfx-item.ts

Co-authored-by: Zheeeng <hi@zheeeng.me>

* Update packages/effects-core/src/plugins/text/text-vfx-item.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: Zheeeng <hi@zheeeng.me>
Co-authored-by: RGCHN <dacong9610@163.com>
Co-authored-by: liuxi150 <liuxi150@hotmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
5 people authored Dec 12, 2023
1 parent bd1b4cf commit f090372
Show file tree
Hide file tree
Showing 44 changed files with 194 additions and 137 deletions.
11 changes: 11 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
reviews:
auto_review:
enabled: true
drafts: true
base_branches:
- "main"
- "hotfix"
- "dev"
- "feat/*"
chat:
auto_reply: true
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
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.0.1",
"version": "1.1.0",
"description": "Galacean Effects runtime core for the web",
"module": "./dist/index.mjs",
"main": "./dist/index.js",
Expand Down
33 changes: 28 additions & 5 deletions packages/effects-core/src/composition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -804,24 +805,46 @@ export class Composition implements Disposable, LostHandler {
}

/**
* 设置合成在 3D 坐标轴上相对移动
* 设置合成在 3D 坐标轴上相对当前的位移
*/
translate (x: number, y: number, z: number) {
this.content.translate(x, y, z);
}

/**
* 设置合成在 3D 坐标轴上相对原点的位移
*/
setPosition (x: number, y: number, z: number) {
this.content.setPosition(x, y, z);
}

/**
* 设置合成在 3D 坐标轴上相对旋转(角度)
* 设置合成在 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);
}

/**
* 卸载贴图纹理方法,减少内存
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/effects-core/src/plugins/cal/calculate-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class CalculateItem {

constructor (
props: spec.NullContent,
vfxItem: VFXItem<VFXItemContent>,
protected vfxItem: VFXItem<VFXItemContent>,
) {
this.transform = vfxItem.transform;
const scale = this.transform.scale;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ export class ParticleVFXItem extends VFXItem<ParticleSystem> {
}
}
if (hide) {
this.content.setVisible(true);
} else {
this.content.setVisible(false);
} else {
this.content.setVisible(true);
this.content.onUpdate(dt);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/effects-core/src/plugins/sprite/sprite-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions packages/effects-core/src/plugins/sprite/sprite-mesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class SpriteMesh {
let pointCount = 0;

if (!items.length) {
this.mesh.setVisible(true);
this.mesh.setVisible(false);

return true;
}
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 0 additions & 8 deletions packages/effects-core/src/plugins/sprite/sprite-vfx-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,16 @@ export class SpriteVFXItem extends VFXItem<SpriteItem> {
}

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);
}
Expand Down
34 changes: 15 additions & 19 deletions packages/effects-core/src/plugins/text/text-item.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -63,13 +62,11 @@ 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();
}

/**
* 设置字号大小
* @param value 字号
* @param value - 字号
* @returns
*/
setFontSize (value: number): void {
Expand All @@ -85,7 +82,7 @@ export class TextItem extends SpriteItem {

/**
* 设置字重
* @param value 字重类型
* @param value - 字重类型
* @returns
*/
setFontWeight (value: spec.TextWeight): void {
Expand All @@ -111,7 +108,7 @@ export class TextItem extends SpriteItem {

/**
* 设置文本
* @param value 文本内容
* @param value - 文本内容
* @returns
*/
setText (value: string): void {
Expand All @@ -124,7 +121,7 @@ export class TextItem extends SpriteItem {

/**
* 设置文本水平布局
* @param value 布局选项
* @param value - 布局选项
* @returns
*/
setTextAlign (value: spec.TextAlignment): void {
Expand All @@ -137,7 +134,7 @@ export class TextItem extends SpriteItem {

/**
* 设置文本垂直布局
* @param value 布局选项
* @param value - 布局选项
* @returns
*/
setTextBaseline (value: spec.TextBaseline): void {
Expand All @@ -150,7 +147,7 @@ export class TextItem extends SpriteItem {

/**
* 设置文本颜色
* @param value 颜色内容
* @param value - 颜色内容
* @returns
*/
setTextColor (value: spec.RGBAColorValue): void {
Expand All @@ -163,7 +160,7 @@ export class TextItem extends SpriteItem {

/**
* 设置文本字体
* @param value 文本字体
* @param value - 文本字体
* @returns
*/
setFontFamily (value: string): void {
Expand All @@ -176,7 +173,7 @@ export class TextItem extends SpriteItem {

/**
* 设置外描边文本颜色
* @param value 颜色内容
* @param value - 颜色内容
* @returns
*/
setOutlineColor (value: spec.RGBAColorValue): void {
Expand All @@ -189,7 +186,7 @@ export class TextItem extends SpriteItem {

/**
* 设置外描边文本宽度
* @param value 外描边宽度
* @param value - 外描边宽度
* @returns
*/
setOutlineWidth (value: number): void {
Expand All @@ -202,7 +199,7 @@ export class TextItem extends SpriteItem {

/**
* 设置阴影模糊
* @param value 阴影模糊强度
* @param value - 阴影模糊强度
* @returns
*/
setShadowBlur (value: number): void {
Expand All @@ -215,7 +212,7 @@ export class TextItem extends SpriteItem {

/**
* 设置阴影颜色
* @param value 阴影颜色
* @param value - 阴影颜色
* @returns
*/
setShadowColor (value: spec.RGBAColorValue): void {
Expand All @@ -228,7 +225,7 @@ export class TextItem extends SpriteItem {

/**
* 设置阴影水平偏移距离
* @param value 水平偏移距离
* @param value - 水平偏移距离
* @returns
*/
setShadowOffsetX (value: number): void {
Expand All @@ -241,7 +238,7 @@ export class TextItem extends SpriteItem {

/**
* 设置阴影水平偏移距离
* @param value 水平偏移距离
* @param value - 水平偏移距离
* @returns
*/
setShadowOffsetY (value: number): void {
Expand All @@ -254,7 +251,7 @@ export class TextItem extends SpriteItem {

/**
* 设置字体清晰度
* @param value 字体清晰度
* @param value - 字体清晰度
* @returns
*/
setFontScale (value: number): void {
Expand Down Expand Up @@ -285,7 +282,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;
Expand Down Expand Up @@ -435,5 +432,4 @@ export class TextItem extends SpriteItem {
context!.shadowOffsetX = style.shadowOffsetX ;
context!.shadowOffsetY = -style.shadowOffsetY ;
}

}
Loading

0 comments on commit f090372

Please sign in to comment.