A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(sdk): spine tint resets when cleared; mix duration is per-asset
esenginecb6a4618e1bd
diff --git a/sdk/src/spine/ModuleBackend.ts b/sdk/src/spine/ModuleBackend.tsindex abd782068..0aed3fdd3 100644--- a/sdk/src/spine/ModuleBackend.ts+++ b/sdk/src/spine/ModuleBackend.ts@@ -131,6 +131,10 @@ export class ModuleBackend {return this.controller_.getSkins(info.instanceId);}+ // NOTE: mix durations live on the skeleton's AnimationStateData (C++ takes a+ // skeletonHandle), so these apply to EVERY entity sharing this asset, not just+ // `entity`. Crossfade timing is an asset-level property here — pass an entity+ // only to resolve which asset. (True per-instance mix would need a C++ change.)setDefaultMix(entity: Entity, duration: number): void {const info = this.entities_.get(entity);if (info) this.controller_.setDefaultMix(info.skelHandle, duration);diff --git a/sdk/src/spine/loadSpineScene.ts b/sdk/src/spine/loadSpineScene.tsindex 57c6ea087..c39214ec5 100644--- a/sdk/src/spine/loadSpineScene.ts+++ b/sdk/src/spine/loadSpineScene.ts@@ -47,7 +47,10 @@ export function spineEntityProps(d: Record<string, unknown>): {layer: num(d.layer, 0),timeScale: num(d.timeScale, 1),playing: d.playing !== false,- color: color && typeof color === 'object' ? (color as { r: number; g: number; b: number; a: number }) : undefined,+ // Default to opaque white (spine's no-tint identity) rather than undefined, so+ // CLEARING the color field resets the native skeleton tint instead of leaving+ // the last-applied color stuck (setEntityProps only writes a defined color).+ color: color && typeof color === 'object' ? (color as { r: number; g: number; b: number; a: number }) : { r: 1, g: 1, b: 1, a: 1 },};}diff --git a/sdk/tests/spine-apply-routing.test.ts b/sdk/tests/spine-apply-routing.test.tsindex de17d0575..8d15f8039 100644--- a/sdk/tests/spine-apply-routing.test.ts+++ b/sdk/tests/spine-apply-routing.test.ts@@ -9,7 +9,7 @@*/import { describe, it, expect, beforeEach, vi } from 'vitest';import { defineComponent, clearUserComponents } from '../src/component';-import { applySpineEntities } from '../src/spine/loadSpineScene';+import { applySpineEntities, spineEntityProps } from '../src/spine/loadSpineScene';import type { SceneData } from '../src/scene';import type { Entity } from '../src/types';@@ -74,3 +74,13 @@ describe('applySpineEntities routes every version to the SpineManager (S3)', ()expect(manager.loadEntity).not.toHaveBeenCalled();});});++describe('spineEntityProps color default', () => {+ it('defaults a missing color to opaque white so clearing resets the tint', () => {+ expect(spineEntityProps({}).color).toEqual({ r: 1, g: 1, b: 1, a: 1 });+ expect(spineEntityProps({ color: null }).color).toEqual({ r: 1, g: 1, b: 1, a: 1 });+ });+ it('passes a set color through', () => {+ expect(spineEntityProps({ color: { r: 1, g: 0, b: 0, a: 1 } }).color).toEqual({ r: 1, g: 0, b: 0, a: 1 });+ });+});