Skip to content

Commit

Permalink
Merge branch 'PIXI-Core' into PIXI-WebGL
Browse files Browse the repository at this point in the history
  • Loading branch information
JPMeehan committed Dec 14, 2023
2 parents d1b5532 + 79320b0 commit b7ac207
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 135 deletions.
8 changes: 3 additions & 5 deletions src/foundry/client/pixi/core/containers/cached-container.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,9 @@ declare global {
*/
clear(destroy?: boolean): CachedContainer;

/** {@inheritdoc} */
destroy(options?: Parameters<PIXI.Container["destroy"]>[0]): ReturnType<PIXI.Container["destroy"]>;
override destroy(options?: boolean | PIXI.IDestroyOptions): void;

/** {@inheritdoc} */
render(renderer: Parameters<PIXI.Container["render"]>[0]): void;
override render(renderer: PIXI.Renderer): void;

/**
* Resize a render texture passed as a parameter with the renderer.
Expand All @@ -91,7 +89,7 @@ declare global {
namespace CachedContainer {
type RenderOptions = {
/** Render function that will be called to render into the RT. */
renderFunction?: (...args: any[]) => any;
renderFunction?: (renderer: PIXI.Renderer) => void;
/** An optional clear color to clear the RT before rendering into it. */
clearColor?: number[];
};
Expand Down
2 changes: 1 addition & 1 deletion src/foundry/client/pixi/core/containers/quadtree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ declare global {
/**
* A constant that enumerates the index order of the quadtree nodes from top-left to bottom-right.
*/
static INDICES: {
static readonly INDICES: {
tl: 0;
tr: 1;
bl: 2;
Expand Down
9 changes: 3 additions & 6 deletions src/foundry/client/pixi/core/containers/sprite-mesh.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { IBaseTextureOptions } from "@pixi/core";
import { IPointData } from "@pixi/math";

export {};

declare global {
Expand Down Expand Up @@ -145,9 +142,9 @@ declare global {

override getLocalBounds(rect: PIXI.Rectangle): PIXI.Rectangle;

override containsPoint(point: IPointData): boolean;
override containsPoint(point: PIXI.IPointData): boolean;

override destroy(...args: any[]): void;
override destroy(options: PIXI.IDestroyOptions | boolean): void;

/**
* Create a SpriteMesh from another source.
Expand All @@ -158,7 +155,7 @@ declare global {
*/
static from(
source: string | PIXI.Texture | HTMLCanvasElement | HTMLVideoElement,
textureOptions?: IBaseTextureOptions,
textureOptions?: PIXI.IBaseTextureOptions,
shaderCls?: typeof AbstractBaseShader,
): SpriteMesh;
}
Expand Down
125 changes: 23 additions & 102 deletions src/foundry/client/pixi/core/interaction/canvas-animation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,36 +114,6 @@ declare global {
{ context, name, duration, easing, ontick, priority }?: CanvasAnimationOptions,
): Promise<boolean | void>;

/**
* Apply a linear animation from the current value of some attribute to a new value
* Resolve a Promise once the animation has concluded and the attributes have reached their new target
* @param attributes - An array of attributes to animate. Structure of the Array is shown in the example
* @param options - Additional options which customize the animation
* (default: `{}`)
* @returns A Promise which resolves once the linear animation has concluded
*
* @example
* ```typescript
* let animation = [
* {
* parent: token,
* attribute: x,
* to: 1000
* },
* {
* parent: token,
* attribute: y,
* to: 2000
* }
* ];
* CanvasAnimation.animateLinear(attributes, {duration:500, ontick: console.log("ticking")});
* ```
*/
static animateLinear(
attributes: CanvasAnimation.Attribute[],
options?: InexactPartial<LinearAnimationOptions>,
): Promise<boolean>;

/**
* Retrieve an animation currently in progress by its name
* @param name - The animation name to retrieve
Expand All @@ -158,82 +128,33 @@ declare global {
static terminateAnimation(name: string): void;

/**
* Asynchronously animate a transition function and resolve a Promise once the animation has completed
* @param fn - A suitable transition function. See PIXI.Ticker for details
* @param context - The Canvas container providing scope for the transition
* @param name - Provide a unique animation name which may be referenced later
* @param attributes - The attributes being animated by the function
* @param duration - The duration in milliseconds over which the animation should occur
* @param ontick - A function which defines additional behaviors to apply every animation frame
* @returns A Promise which resolves once the animation has completed
* Cosine based easing with smooth in-out.
* @param pt - The proportional animation timing on [0,1]
* @returns The eased animation progress on [0,1]
*/
protected static _animatePromise(
fn: TransitionFunction,
context: PIXI.Container,
name: string,
attributes: CanvasAnimation.Attribute[],
duration: number,
ontick: TickFunction | undefined,
): Promise<boolean>;
static easeInOutCosine(pt: number): number;

/**
* Generic ticker function to implement the animation.
* This animation wrapper executes once per frame for the duration of the animation event.
* Once the animated attributes have converged to their targets, it resolves the original Promise.
* The user-provided ontick function runs each frame update to apply additional behaviors.
* Shallow ease out.
* @param pt - The proportional animation timing on [0,1]
* @returns The eased animation progress on [0,1]
*/
protected static _animateFrame(
deltaTime: number,
resolve: CanvasAnimationData["resolve"],
reject: (reason?: any) => void,
attributes: CanvasAnimation.Attribute[],
duration: number,
ontick: TickFunction | undefined,
): void;
}
static easeOutCircle(pt: number): number;

namespace CanvasAnimation {
interface Attribute {
attribute: string;
d?: number;
delta?: number;
done?: number;
parent: any;
remaining?: number;
to: number;
}
}
}

interface LinearAnimationOptions {
/**
* An animation context to use which defines scope
*/
context: PIXI.DisplayObject;

/**
* Provide a unique animation name which may be referenced later
*/
name: string;

/**
* The duration in milliseconds over which the animation should occur
* @defaultValue `1000`
*/
duration: number;
/**
* Shallow ease in.
* @param pt - The proportional animation timing on [0,1]
* @returns The eased animation progress on [0,1]
*/
static easeInCircle(pt: number): number;

/**
* A function which defines additional behaviors to apply every animation frame
*/
ontick: TickFunction;
/**
* @deprecated since v10, will be removed in v12
* @remarks "You are calling CanvasAnimation.animateLinear which is deprecated in favor of CanvasAnimation.animate"
*/
static animateLinear(
attributes: CanvasAnimationAttribute[],
options: CanvasAnimationOptions,
): Promise<boolean | void>;
}
}

type TickFunction = (dt: number, attributes: CanvasAnimation.Attribute[]) => void;
type TransitionFunction = (
dt: number,
resolve: CanvasAnimationData["resolve"],
reject: (reason?: any) => void,
attributes: CanvasAnimation.Attribute[],
duration: number,
ontick?: TickFunction,
) => void;
2 changes: 1 addition & 1 deletion src/foundry/client/pixi/core/interaction/control-icon.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ declare class ControlIcon extends PIXI.Container {
/**
* @defaultValue `static`
*/
eventMode: "none" | "passive" | "auto" | "static" | "dynamic";
override eventMode: "none" | "passive" | "auto" | "static" | "dynamic";

/**
* @defaultValue `false`
Expand Down
5 changes: 0 additions & 5 deletions src/foundry/client/pixi/core/interaction/targets.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,5 @@ declare global {
* @remarks Returns void, but Set<T>.delete returns boolean
*/
override delete(token: InstanceType<ObjectClass<typeof TokenDocument>>): void;

/**
* Dispatch the targetToken hook whenever the user's target set changes
*/
protected _hook(token: InstanceType<ObjectClass<typeof TokenDocument>>, targeted: boolean): void;
}
}
15 changes: 0 additions & 15 deletions src/foundry/client/pixi/placeables/token.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,21 +357,6 @@ declare global {
*/
animateMovement(ray: Ray): Promise<void>;

/**
* Animate the continual revealing of Token vision during a movement animation
* @internal
*/
protected _onMovementFrame(
dt: number,
anim: Array<{
context: unknown;
name: string | null;
duration: number;
ontick: (dt: number, attributes: CanvasAnimation.Attribute[]) => void;
}>,
config: { fog?: boolean; sound?: boolean; source?: boolean },
): void;

/**
* Update perception each frame depending on the animation configuration
* @param source - (default: `false`)
Expand Down

0 comments on commit b7ac207

Please sign in to comment.