[ts] 4.3 porting WIP.

This commit is contained in:
Davide Tantillo 2025-06-20 12:00:04 +02:00
parent d126475b84
commit 9482f60ccf
13 changed files with 36 additions and 36 deletions

View File

@ -65,7 +65,7 @@ export class SkeletonRenderer {
let bone = slot.bone;
if (!bone.active) continue;
let pose = slot.pose;
let pose = slot.applied;
let attachment = pose.attachment;
if (!(attachment instanceof RegionAttachment)) continue;
attachment.computeWorldVertices(slot, worldVertices, 0, 2);
@ -119,7 +119,7 @@ export class SkeletonRenderer {
for (let i = 0, n = drawOrder.length; i < n; i++) {
const slot = drawOrder[i];
let pose = slot.pose;
let pose = slot.applied;
let attachment = pose.attachment;
let texture: HTMLImageElement;
@ -228,7 +228,7 @@ export class SkeletonRenderer {
private computeRegionVertices (slot: Slot, region: RegionAttachment, pma: boolean) {
let skeletonColor = slot.skeleton.color;
let slotColor = slot.pose.color;
let slotColor = slot.applied.color;
let regionColor = region.color;
let alpha = skeletonColor.a * slotColor.a * regionColor.a;
let multiplier = pma ? alpha : 1;
@ -277,7 +277,7 @@ export class SkeletonRenderer {
private computeMeshVertices (slot: Slot, mesh: MeshAttachment, pma: boolean) {
let skeleton = slot.skeleton;
let skeletonColor = skeleton.color;
let slotColor = slot.pose.color;
let slotColor = slot.applied.color;
let regionColor = mesh.color;
let alpha = skeletonColor.a * slotColor.a * regionColor.a;
let multiplier = pma ? alpha : 1;

View File

@ -235,7 +235,7 @@ export class SkeletonRenderer {
continue;
}
let pose = slot.pose;
let pose = slot.applied;
let attachment = pose.attachment;
let positions = this.scratchPositions;
let colors = this.scratchColors;

View File

@ -76,7 +76,7 @@ export class SkeletonBounds {
for (let i = 0; i < slotCount; i++) {
let slot = slots[i];
if (!slot.bone.active) continue;
let attachment = slot.pose.attachment;
let attachment = slot.applied.attachment;
if (attachment instanceof BoundingBoxAttachment) {
boundingBoxes.push(attachment);

View File

@ -587,7 +587,7 @@ export class Spine extends Container {
private updateSlotObject (element: { container: Container, followAttachmentTimeline: boolean }, slot: Slot, zIndex: number) {
const { container: slotObject, followAttachmentTimeline } = element
const pose = slot.pose;
const pose = slot.applied;
const followAttachmentValue = followAttachmentTimeline ? Boolean(pose.attachment) : true;
slotObject.visible = this.skeleton.drawOrder.includes(slot) && followAttachmentValue;
@ -627,7 +627,7 @@ export class Spine extends Container {
}
if (!pixiMaskSource.computed) {
pixiMaskSource.computed = true;
const clippingAttachment = pixiMaskSource.slot.pose.attachment as ClippingAttachment;
const clippingAttachment = pixiMaskSource.slot.applied.attachment as ClippingAttachment;
const worldVerticesLength = clippingAttachment.worldVerticesLength;
if (this.clippingVertAux.length < worldVerticesLength) this.clippingVertAux = new Float32Array(worldVerticesLength);
clippingAttachment.computeWorldVertices(this.skeleton, pixiMaskSource.slot, 0, worldVerticesLength, this.clippingVertAux, 0, 2);
@ -675,7 +675,7 @@ export class Spine extends Container {
this.updateAndSetPixiMask(pixiMaskSource, pixiObject.container);
}
const pose = slot.pose;
const pose = slot.applied;
const useDarkColor = !!pose.darkColor;
const vertexSize = useDarkColor ? Spine.DARK_VERTEX_SIZE : Spine.VERTEX_SIZE;
if (!slot.bone.active) {

View File

@ -338,7 +338,7 @@ export class SpineDebugRenderer implements ISpineDebugRenderer {
for (let i = 0, len = slots.length; i < len; i++) {
const slot = slots[i];
const attachment = slot.pose.attachment;
const attachment = slot.applied.attachment;
if (attachment == null || !(attachment instanceof RegionAttachment)) {
continue;
@ -366,7 +366,7 @@ export class SpineDebugRenderer implements ISpineDebugRenderer {
if (!slot.bone.active) {
continue;
}
const attachment = slot.pose.attachment;
const attachment = slot.applied.attachment;
if (attachment == null || !(attachment instanceof MeshAttachment)) {
continue;
@ -422,7 +422,7 @@ export class SpineDebugRenderer implements ISpineDebugRenderer {
if (!slot.bone.active) {
continue;
}
const attachment = slot.pose.attachment;
const attachment = slot.applied.attachment;
if (attachment == null || !(attachment instanceof ClippingAttachment)) {
continue;
@ -497,7 +497,7 @@ export class SpineDebugRenderer implements ISpineDebugRenderer {
if (!slot.bone.active) {
continue;
}
const attachment = slot.pose.attachment;
const attachment = slot.applied.attachment;
if (attachment == null || !(attachment instanceof PathAttachment)) {
continue;

View File

@ -542,7 +542,7 @@ export class Spine extends ViewContainer {
for (let i = 0; i < currentDrawOrder.length; i++) {
const slot = currentDrawOrder[i];
const attachment = slot.pose.attachment;
const attachment = slot.applied.attachment;
if (attachment) {
if (attachment !== lastAttachments[index]) {
@ -565,7 +565,7 @@ export class Spine extends ViewContainer {
private currentClippingSlot: SlotsToClipping | undefined;
private updateAndSetPixiMask (slot: Slot, last: boolean) {
// assign/create the currentClippingSlot
const pose = slot.pose;
const pose = slot.applied;
const attachment = pose.attachment;
if (attachment && attachment instanceof ClippingAttachment) {
const clip = (this.clippingSlotToPixiMasks[slot.data.name] ||= { slot, vertices: new Array<number>() });
@ -604,7 +604,7 @@ export class Spine extends ViewContainer {
}
// if current slot is the ending one of the currentClippingSlot mask, set currentClippingSlot to undefined
if (currentClippingSlot && (currentClippingSlot.slot.pose.attachment as ClippingAttachment).endSlot == slot.data) {
if (currentClippingSlot && (currentClippingSlot.slot.applied.attachment as ClippingAttachment).endSlot == slot.data) {
this.currentClippingSlot = undefined;
}
@ -612,7 +612,7 @@ export class Spine extends ViewContainer {
if (last) {
for (const key in this.clippingSlotToPixiMasks) {
const clippingSlotToPixiMask = this.clippingSlotToPixiMasks[key];
if ((!(clippingSlotToPixiMask.slot.pose.attachment instanceof ClippingAttachment) || !clippingSlotToPixiMask.maskComputed) && clippingSlotToPixiMask.mask) {
if ((!(clippingSlotToPixiMask.slot.applied.attachment instanceof ClippingAttachment) || !clippingSlotToPixiMask.maskComputed) && clippingSlotToPixiMask.mask) {
this.removeChild(clippingSlotToPixiMask.mask);
maskPool.free(clippingSlotToPixiMask.mask);
clippingSlotToPixiMask.mask = undefined;
@ -631,7 +631,7 @@ export class Spine extends ViewContainer {
this.updateAndSetPixiMask(slot, i === currentDrawOrder.length - 1);
const pose = slot.pose;
const pose = slot.applied;
const attachment = pose.attachment;
if (attachment) {
@ -787,7 +787,7 @@ export class Spine extends ViewContainer {
private updateSlotObject (slotAttachment: { slot: Slot, container: Container, followAttachmentTimeline: boolean }) {
const { slot, container } = slotAttachment;
const pose = slot.pose;
const pose = slot.applied;
const followAttachmentValue = slotAttachment.followAttachmentTimeline ? Boolean(pose.attachment) : true;
container.visible = this.skeleton.drawOrder.includes(slot) && followAttachmentValue;
@ -1006,7 +1006,7 @@ export class Spine extends ViewContainer {
for (let i = 0; i < drawOrder.length; i++) {
const slot = drawOrder[i];
const attachment = slot.pose.attachment;
const attachment = slot.applied.attachment;
if (attachment && (attachment instanceof RegionAttachment || attachment instanceof MeshAttachment)) {
const cacheData = this._getCachedData(slot, attachment);

View File

@ -360,7 +360,7 @@ export class SpineDebugRenderer implements ISpineDebugRenderer {
for (let i = 0, len = slots.length; i < len; i++) {
const slot = slots[i];
const attachment = slot.pose.attachment;
const attachment = slot.applied.attachment;
if (attachment === null || !(attachment instanceof RegionAttachment)) {
continue;
@ -391,7 +391,7 @@ export class SpineDebugRenderer implements ISpineDebugRenderer {
if (!slot.bone.active) {
continue;
}
const attachment = slot.pose.attachment;
const attachment = slot.applied.attachment;
if (attachment === null || !(attachment instanceof MeshAttachment)) {
continue;
@ -451,7 +451,7 @@ export class SpineDebugRenderer implements ISpineDebugRenderer {
if (!slot.bone.active) {
continue;
}
const attachment = slot.pose.attachment;
const attachment = slot.applied.attachment;
if (attachment === null || !(attachment instanceof ClippingAttachment)) {
continue;
@ -536,7 +536,7 @@ export class SpineDebugRenderer implements ISpineDebugRenderer {
if (!slot.bone.active) {
continue;
}
const attachment = slot.pose.attachment;
const attachment = slot.applied.attachment;
if (attachment === null || !(attachment instanceof PathAttachment)) {
continue;

View File

@ -86,7 +86,7 @@ export class SpinePipe implements RenderPipe<Spine> {
for (let i = 0, n = drawOrder.length; i < n; i++) {
const slot = drawOrder[i];
const attachment = slot.pose.attachment;
const attachment = slot.applied.attachment;
if (attachment instanceof RegionAttachment || attachment instanceof MeshAttachment) {
const cacheData = spine._getCachedData(slot, attachment);
@ -122,7 +122,7 @@ export class SpinePipe implements RenderPipe<Spine> {
for (let i = 0, n = drawOrder.length; i < n; i++) {
const slot = drawOrder[i];
const attachment = slot.pose.attachment;
const attachment = slot.applied.attachment;
const blendMode = spineBlendModeMap[slot.data.blendMode];
if (attachment instanceof RegionAttachment || attachment instanceof MeshAttachment) {
@ -165,7 +165,7 @@ export class SpinePipe implements RenderPipe<Spine> {
for (let i = 0, n = drawOrder.length; i < n; i++) {
const slot = drawOrder[i];
const attachment = slot.pose.attachment;
const attachment = slot.applied.attachment;
if (attachment instanceof RegionAttachment || attachment instanceof MeshAttachment) {
const cacheData = spine._getCachedData(slot, attachment);

View File

@ -237,7 +237,7 @@ export class SkeletonMesh extends THREE.Object3D {
clipper.clipEnd(slot);
continue;
}
let pose = slot.pose;
let pose = slot.applied;
let attachment = pose.attachment;
let attachmentColor: Color | null;
let texture: ThreeJsTexture | null;

View File

@ -685,7 +685,7 @@ export class SpineWebComponentOverlay extends HTMLElement implements OverlayAttr
element.style.display = ""
const pose = slot.pose;
const pose = slot.applied;
if (followVisibility && !pose.attachment) {
element.style.opacity = "0";
} else if (followOpacity) {

View File

@ -1156,7 +1156,7 @@ export class SpineWebComponentSkeleton extends HTMLElement implements Disposable
private checkSlotInteraction (type: PointerEventTypesInput, originalEvent?: UIEvent) {
for (let [slot, interactionState] of this.pointerSlotEventCallbacks) {
if (!slot.bone.active) continue;
let attachment = slot.pose.attachment;
let attachment = slot.applied.attachment;
if (!(attachment instanceof RegionAttachment || attachment instanceof MeshAttachment)) continue;
@ -1245,7 +1245,7 @@ export class SpineWebComponentSkeleton extends HTMLElement implements Disposable
if (!slot) return;
if (hideAttachment) {
slot.pose.setAttachment(null);
slot.applied.setAttachment(null);
}
element.style.position = 'absolute';

View File

@ -90,7 +90,7 @@ export class SkeletonDebugRenderer implements Disposable {
for (let i = 0, n = slots.length; i < n; i++) {
let slot = slots[i];
if (!slot.bone.active) continue;
let attachment = slot.pose.attachment;
let attachment = slot.applied.attachment;
if (attachment instanceof RegionAttachment) {
let vertices = this.vertices;
attachment.computeWorldVertices(slot, vertices, 0, 2);
@ -107,7 +107,7 @@ export class SkeletonDebugRenderer implements Disposable {
for (let i = 0, n = slots.length; i < n; i++) {
let slot = slots[i];
if (!slot.bone.active) continue;
let attachment = slot.pose.attachment;
let attachment = slot.applied.attachment;
if (!(attachment instanceof MeshAttachment)) continue;
let vertices = this.vertices;
attachment.computeWorldVertices(skeleton, slot, 0, attachment.worldVerticesLength, vertices, 0, 2);
@ -156,7 +156,7 @@ export class SkeletonDebugRenderer implements Disposable {
for (let i = 0, n = slots.length; i < n; i++) {
let slot = slots[i];
if (!slot.bone.active) continue;
let attachment = slot.pose.attachment;
let attachment = slot.applied.attachment;
if (!(attachment instanceof PathAttachment)) continue;
let nn = attachment.worldVerticesLength;
let world = this.temp = Utils.setArraySize(this.temp, nn, 0);
@ -205,7 +205,7 @@ export class SkeletonDebugRenderer implements Disposable {
for (let i = 0, n = slots.length; i < n; i++) {
let slot = slots[i];
if (!slot.bone.active) continue;
let attachment = slot.pose.attachment;
let attachment = slot.applied.attachment;
if (!(attachment instanceof ClippingAttachment)) continue;
let nn = attachment.worldVerticesLength;
let world = this.temp = Utils.setArraySize(this.temp, nn, 0);

View File

@ -97,7 +97,7 @@ export class SkeletonRenderer {
inRange = false;
}
const pose = slot.pose;
const pose = slot.applied;
const attachment = pose.attachment;
let texture: GLTexture;
if (attachment instanceof RegionAttachment) {