Skip to content

Commit

Permalink
Primary Canvas Objects for v11
Browse files Browse the repository at this point in the history
  • Loading branch information
JPMeehan committed Dec 18, 2023
1 parent 3216b27 commit 99b2658
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ declare class OccludableObject {
* })
* ```
*/
static get defaultData(): OccludableObject.Data & Record<string, unknown>;
static get defaultData(): OccludableObject.Data;

/**
* Contains :
Expand Down Expand Up @@ -138,16 +138,22 @@ declare class OccludableObject {
declare global {
namespace OccludableObject {
type Data = {
/** The PCO is considered as a roof? */
/**
* The PCO is considered as a roof?
* @defaultValue false
*/
roof: boolean;

/** The occlusion object for this PCO */
occlusion: {
/** @defaultValue `CONST.OCCLUSION_MODES.NONE` */
mode: OCCLUSION_MODES;
/** @defaultValue `0` */
alpha: number;
/** @defaultValue `null` */
radius: number | null;
};
};
} & PrimaryCanvasObject.Data;
}

/**
Expand All @@ -162,5 +168,5 @@ declare global {
new (
...args: ConstructorParameters<typeof OccludableObject>
): InstanceType<typeof OccludableObject> & InstanceType<BaseClass>;
};
} & ReturnType<typeof PrimaryCanvasObjectMixin<BaseClass>>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ declare class PrimaryCanvasObject {
* Synchronize the position of the ObjectMesh using the position of its represented Document.
* @remarks Marked as abstract
*/
setPosition(): void;
setPosition(...args: any[]): void;

/**
* Synchronize the bounds of the ObjectMesh into the primary group quadtree.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { MeshMaterial } from "pixi.js";

export {};

declare global {
Expand All @@ -10,5 +12,43 @@ declare global {
override setPosition(x: number, y: number): void;

override updateBounds(): void;

protected override _getCanvasDocumentData(data: Document): unknown;
}

/**
* A special case subclass of PIXI.TilingSprite which is used in cases where the tile texture needs to repeat.
* This should eventually be refactored in favor of a more generalized TilingMesh.
* FIXME: Workaround until we have our custom TilingMesh class.
*/
//@ts-expect-error There's some property mismatches on Foundry's end but this class is going away in v12 anyways
class TileSprite extends OccludableObjectMixin(PIXI.TilingSprite) {
constructor(...args: any[]);

override setShaderClass(): void;

override renderDepthData(): void;

/**
* @remarks Always returns false
*/
override get isOccludable(): boolean;

/**
* @remarks Always returns false
*/
override get shouldRenderDepth(): boolean;

override shader: MeshMaterial;

/**
* @remarks Monkey patch copied from TileMesh.refresh()
*/
override refresh(): void;

/**
* @remarks Monkey patch copied from TileMesh.setPosition()
*/
override setPosition(): void;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
export {};

type Color = number;

declare global {
/**
* A SpriteMesh which visualizes a Token object in the PrimaryCanvasGroup.
*/
class TokenMesh extends OccludableObjectMixin(SpriteMesh) {
/**
* Sorting values to deal with ties.
* @defaultValue `750`
*/
static PRIMARY_SORT_ORDER: number;

static override get defaultData(): TokenMesh.Data;

override refresh(): void;

override setPosition(x: number, y: number): void;

override updateBounds(): void;

protected override _getTextureCoordinate(testX: number, testY: number): { x: number; y: number } | null;

/**
* Get the attributes for this TokenMesh which configure the display of this TokenMesh and are compatible
* with CanvasAnimation.
*/
getDisplayAttributes(): TokenMeshDisplayAttributes;
}

namespace TokenMesh {
type Data = {
/**
* Is this TokenMesh rotation locked?
* @defaultValue `false`
*/
lockRotation: boolean;
} & ReturnType<typeof OccludableObjectMixin<typeof SpriteMesh>>["defaultData"];
}

type TokenMeshDisplayAttributes = {
x: number;

y: number;

width: number;

height: number;

alpha: number;

rotation: number;

scaleX: number;

scaleY: number;

tint: Color;
};
}

0 comments on commit 99b2658

Please sign in to comment.