diff --git a/dist/Spine-v1.36.3.c3addon b/dist/Spine-v1.36.3.c3addon new file mode 100644 index 0000000..d41121a Binary files /dev/null and b/dist/Spine-v1.36.3.c3addon differ diff --git a/dist/Spine-v1.36.4.c3addon b/dist/Spine-v1.36.4.c3addon new file mode 100644 index 0000000..0e821c3 Binary files /dev/null and b/dist/Spine-v1.36.4.c3addon differ diff --git a/dist/Spine-v1.36.5.c3addon b/dist/Spine-v1.36.5.c3addon new file mode 100644 index 0000000..1355e64 Binary files /dev/null and b/dist/Spine-v1.36.5.c3addon differ diff --git a/src/addon.json b/src/addon.json index 43bba0a..5c00f09 100755 --- a/src/addon.json +++ b/src/addon.json @@ -3,7 +3,7 @@ "type": "plugin", "name": "Spine", "id": "Gritsenko_Spine", - "version": "1.36.2", + "version": "1.36.5", "author": "Mikal and Igor Gritsenko", "website": "https://gritsenko.github.io/c3_spine_plugin", "documentation": "https://gritsenko.github.io/c3_spine_plugin", diff --git a/src/c3runtime/actions.js b/src/c3runtime/actions.js index cc15639..8725b60 100644 --- a/src/c3runtime/actions.js +++ b/src/c3runtime/actions.js @@ -247,6 +247,11 @@ for(slotName in this.slotColors) { let slot = skeleton.findSlot(slotName); + if (slot === null) + { + console.warn("[Spine] ApplySlotColors, slot not found: ",slotName,this.uid,this.runtime.GetTickCount()); + continue; + } let color = this.slotColors[slotName]; slot.color.set( spineBatcher.getRValue(color), @@ -259,6 +264,11 @@ for(slotName in this.slotDarkColors) { let slot = skeleton.findSlot(slotName); + if (slot === null) + { + console.warn("[Spine] ApplySlotColors dark color, slot not found: ",slotName,this.uid,this.runtime.GetTickCount()); + continue; + } // Set only if dark Color is available, (Tint Black must be applied to the slot in the project.) if (slot.darkColor) { diff --git a/src/c3runtime/instance.js b/src/c3runtime/instance.js index b3aec82..4481725 100644 --- a/src/c3runtime/instance.js +++ b/src/c3runtime/instance.js @@ -14,7 +14,6 @@ this.isPlaying = true; this.instance = inst; - this.isSkeletonLoaded = false; this.skeletonInfo = null; this.renderer = null; this.gl = null; @@ -30,6 +29,7 @@ this.sdkType = this.GetSdkType(); this.atlasPath = ""; + this.objectName = this.GetInstance().GetObjectClass().GetName(); if (properties) { this.jsonPath = properties[0]; @@ -48,7 +48,6 @@ } this.isMirrored = false; - this._elementId = ""; this._elementTexture = null @@ -83,7 +82,6 @@ initInstance() { this.initSpineInProgress = true; - this._elementId = 1; // XXX remove when possible // Init Spine elements this.mvp = new spine.webgl.Matrix4(); this.mvp.ortho2d(0, 0, 0, 0); // Texture size unknown at this point @@ -165,8 +163,15 @@ // Sentry error reported if (atlasURI === undefined || atlasURI === null) { - console.warn('[Spine] loadSkeletonData, atlasURI not set', atlasURI, assetTag, this.atlasURI, assetManager.isLoadingComplete(assetTag), this.atlasPath); + console.warn('[Spine] loadSkeletonData, atlasURI not set', atlasURI, assetTag, this.atlasURI, assetManager.isLoadingComplete(assetTag), this.atlasPath, this.runtime.GetTickCount()); + console.warn('[Spine] objectclass',this.objectName, this.sdkType, this.runtime.GetTickCount()); + if (globalThis.Sentry) + { + globalThis.Sentry.captureException('[Spine] loadSkeletonData, atlasURI not set, object:'+this.objectName); + } + return; } + this.sdkType._atlas = new spine.TextureAtlas(atlasURI, function(path) { return assetManager.get(self.sdkType._assetTag, self.sdkType._assetPaths[path]); }); @@ -198,8 +203,6 @@ const animations = this.skeletonInfo.skeleton.data.animations; this.animationNames = animations.map(x => x.name); - this.isSkeletonLoaded = true; - this.resize(); spineBatcher.addInstance(this.skeletonInfo, this.skeletonScale, this.GetInstance().GetUID()); @@ -207,7 +210,7 @@ } loadSkeleton(name, animationName, sequenceSlots) { - if (this.debug) console.info("[Spine] Reading skeleton data:", this.uid, name, animationName); + if (this.debug) console.info("[Spine] Reading skeleton data:", this.uid, this.sdkType.GetObjectClass().GetName(), animationName); // If skeletonData not initialized, create it and stop other instances from creating it let skeleton = new spine.Skeleton(this.sdkType._skeletonData); @@ -424,8 +427,19 @@ this.isPlaying = false; } - IsSpineReady() { - if (this.isSkeletonLoaded) { + async IsSpineReady() { + // Guard for case where sdkType does not exist (deleted on release) + if (this.sdkType === null || this.sdkType === undefined) + { + if (this.debug) console.warn('[Spine] IsSpineReady, sdkType not defined', this.sdkType); + if (globalThis.Sentry) + { + globalThis.Sentry.captureException('[Spine] IsSpineReady, sdkType not defined:'+this.sdkType); + } + return false; + } + + if (this.isLoaded) { return true; } @@ -441,7 +455,7 @@ if(!this.sdkType._texturesBatcherInitializing) { this.sdkType._texturesBatcherInitializing = true; - this.initTexturesBatcher(); + await this.initTexturesBatcher(); } return false; } @@ -485,7 +499,6 @@ this.canvas = null; this.bgColor = null; this.isPlaying = null; - this.isSkeletonLoaded = null; this.skeletonInfo = null; this.renderer = null; this.gl = null; @@ -501,7 +514,6 @@ this.collisionsEnabled = null; this.defaultMix = null; this.isMirrored = null; - this._elementId = null; this._elementTexture = null this.pngURI = null; this.atlasURI = null; @@ -527,7 +539,10 @@ } Tick() { - if (!this.IsSpineReady()) { + // Async function, set this.isLoaded on completion + this.IsSpineReady(); + + if (!this.isLoaded) { return; } @@ -609,7 +624,7 @@ var gl = renderer._gl - if (this._elementId == "" || !this.isSkeletonLoaded) return; // elementID not set, can't draw the element + if (!this.isLoaded) return; // Spine instance not loaded, can't draw var myCanvas = this.canvas; diff --git a/src/c3runtime/spine-draw.js b/src/c3runtime/spine-draw.js index 873d3b0..fef2cec 100644 --- a/src/c3runtime/spine-draw.js +++ b/src/c3runtime/spine-draw.js @@ -305,6 +305,6 @@ class SpineBatch { if (!globalThis.spineBatcher) { - console.log('[Spine] SpineBatcher init, 1.36.2'); + console.log('[Spine] SpineBatcher init, 1.36.5'); globalThis.spineBatcher = new SpineBatch(); } \ No newline at end of file diff --git a/src/c3runtime/type.js b/src/c3runtime/type.js index 5e71762..9d9efcb 100644 --- a/src/c3runtime/type.js +++ b/src/c3runtime/type.js @@ -11,11 +11,13 @@ Release() { + console.warn('[Spine] type.Release', this.GetObjectClass().GetName(), this._runtime.GetTickCount()) super.Release(); } OnCreate() { + console.info('[Spine] type.OnCreate', this.GetObjectClass().GetName(), this._runtime.GetTickCount()) this.GetImageInfo().LoadAsset(this._runtime); this._skeletonDataInitialized = false; this._skeletonDataInitializing = false; diff --git a/src/plugin.js b/src/plugin.js index 034feda..1121d28 100755 --- a/src/plugin.js +++ b/src/plugin.js @@ -3,7 +3,7 @@ const C3 = self.C3; const PLUGIN_ID = "Gritsenko_Spine"; - const PLUGIN_VERSION = "1.36.2"; + const PLUGIN_VERSION = "1.36.5"; const PLUGIN_CATEGORY = "general"; const PLUGIN_CLASS = SDK.Plugins.Gritsenko_Spine = class SpinePlugin extends SDK.IPluginBase { @@ -23,7 +23,7 @@ this._info.SetIsRotatable(true); // allow to be rotated this._info.SetHasImage(true); this._info.SetSupportsEffects(true); // allow effects - this._info.SetMustPreDraw(true); + this._info.SetMustPreDraw(false); this._info.AddCommonPositionACEs(); this._info.AddCommonAngleACEs(); this._info.AddCommonAppearanceACEs();