Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
19 changes: 19 additions & 0 deletions e2e/case/.mockForE2E.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ export const updateForE2E = (engine, deltaTime = 100, loopTime = 10) => {
engine._hardwareRenderer._gl.finish();
};

export const updateForE2EAsync = async (engine, deltaTime = 100, loopTime = 10) => {
engine._vSyncCount = Infinity;
engine._time._lastSystemTime = 0;
let times = 0;
performance.now = function () {
times++;
return times * deltaTime;
};
for (let i = 0; i < loopTime; ++i) {
engine.update();
engine._hardwareRenderer._gl.finish();
await new Promise<void>((resolve) => setTimeout(resolve, 0));
}
const currentTime = times * deltaTime;
performance.now = () => currentTime;
engine.update();
engine._hardwareRenderer._gl.finish();
};

let screenshotCanvas: HTMLCanvasElement = null;
let flipYCanvas: HTMLCanvasElement = null;

Expand Down
6 changes: 3 additions & 3 deletions e2e/case/particleRenderer-sub-emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
Texture2D,
WebGLEngine
} from "@galacean/engine";
import { initScreenshot, updateForE2E } from "./.mockForE2E";
import { initScreenshot, updateForE2EAsync } from "./.mockForE2E";

WebGLEngine.create({
canvas: "canvas"
Expand All @@ -48,9 +48,9 @@ WebGLEngine.create({
url: "https://mdn.alipayobjects.com/huamei_b4l2if/afts/img/A*JPsCSK5LtYkAAAAAAAAAAAAADil6AQ/original",
type: AssetType.Texture
})
.then((texture) => {
.then(async (texture) => {
createSubEmitterScene(engine, rootEntity, <Texture2D>texture);
updateForE2E(engine, 50, 14);
await updateForE2EAsync(engine, 50, 14);
initScreenshot(engine, camera);
});
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/core/src/ComponentsManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Camera } from "./Camera";
import { Component } from "./Component";
import { Renderer } from "./Renderer";
import { ParticleSystemManager } from "./particle/ParticleSystemManager";
import { Script } from "./Script";
import { Animator } from "./animation";
import { IUICanvas } from "./ui/IUICanvas";
Expand All @@ -10,6 +11,8 @@ import { DisorderedArray } from "./utils/DisorderedArray";
* The manager of the components.
*/
export class ComponentsManager {
/** @internal */
readonly _particleSystemManager = new ParticleSystemManager();
/** @internal */
_cameraNeedSorting = false;
/** @internal */
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ export class Engine extends EventDispatcher {
for (let i = 0, n = scenes.length; i < n; i++) {
const scene = scenes[i];
if (!scene.isActive || scene.destroyed) continue;
scene._componentsManager._particleSystemManager.update(deltaTime);
scene._componentsManager.callRendererOnUpdate(deltaTime);
scene._updateShaderData();
}
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/graphic/Buffer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GraphicsResource } from "../asset/GraphicsResource";
import { TypedArray } from "../base";
import { Engine } from "../Engine";
import { IPlatformBuffer } from "../renderingHardwareInterface";
import { IPlatformBuffer, IPlatformBufferReadback } from "../renderingHardwareInterface";
import { UpdateFlagManager } from "../UpdateFlagManager";
import { BufferBindFlag } from "./enums/BufferBindFlag";
import { BufferUsage } from "./enums/BufferUsage";
Expand Down Expand Up @@ -239,6 +239,11 @@ export class Buffer extends GraphicsResource {
this._platformBuffer.copyFromBuffer(srcBuffer._platformBuffer, srcByteOffset, dstByteOffset, byteLength);
}

/** @internal */
_createReadback(): IPlatformBufferReadback {
return this._platformBuffer.createReadback();
}

/**
* Mark buffer as readable, the `data` property will be not accessible anymore.
*/
Expand Down
14 changes: 12 additions & 2 deletions packages/core/src/particle/ParticleBufferUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@ import { ParticleInstanceVertexAttribute } from "./enums/attributes/ParticleInst
*/
export class ParticleBufferUtils {
static readonly feedbackVertexStride = 24;
static readonly trajectoryFeedbackVertexStride = 48;

static readonly feedbackVertexElements = [
new VertexElement(ParticleFeedbackVertexAttribute.Position, 0, VertexElementFormat.Vector3, 0),
new VertexElement(ParticleFeedbackVertexAttribute.Velocity, 12, VertexElementFormat.Vector3, 0)
];

static readonly trajectoryFeedbackVertexElements = [
...ParticleBufferUtils.feedbackVertexElements,
new VertexElement(ParticleFeedbackVertexAttribute.WorldPosition, 24, VertexElementFormat.Vector3, 0)
];

static readonly feedbackInstanceElements = [
new VertexElement(ParticleInstanceVertexAttribute.ShapePositionStartLifeTime, 0, VertexElementFormat.Vector4, 0),
new VertexElement(ParticleInstanceVertexAttribute.DirectionTime, 16, VertexElementFormat.Vector4, 0),
Expand All @@ -32,15 +38,19 @@ export class ParticleBufferUtils {
new VertexElement(ParticleInstanceVertexAttribute.Random1, 92, VertexElementFormat.Vector4, 0),
new VertexElement(ParticleInstanceVertexAttribute.SimulationWorldPosition, 108, VertexElementFormat.Vector3, 0),
new VertexElement(ParticleInstanceVertexAttribute.SimulationWorldRotation, 120, VertexElementFormat.Vector4, 0),
new VertexElement(ParticleInstanceVertexAttribute.Random2, 152, VertexElementFormat.Vector4, 0)
new VertexElement(ParticleInstanceVertexAttribute.Random2, 152, VertexElementFormat.Vector4, 0),
new VertexElement(ParticleInstanceVertexAttribute.InheritVelocityRandom, 168, VertexElementFormat.Float, 0)
];

static readonly instanceVertexStride = 168;
static readonly instanceVertexStride = 172;
static readonly instanceVertexFloatStride = ParticleBufferUtils.instanceVertexStride / 4;

static readonly startLifeTimeOffset = 3;
static readonly timeOffset = 7;
static readonly simulationUVOffset = 34;
static readonly inheritVelocityRandomOffset = 42;
static readonly feedbackWorldPositionOffset = 6;
static readonly feedbackTrajectoryVelocityOffset = 9;

static readonly billboardIndexCount = 6;

Expand Down
Loading
Loading