diff --git a/dist/Spine-v1.34.1.c3addon b/dist/Spine-v1.34.1.c3addon new file mode 100644 index 0000000..92534cf Binary files /dev/null and b/dist/Spine-v1.34.1.c3addon differ diff --git a/src/addon.json b/src/addon.json index 2ec2ea1..e9f35ee 100755 --- a/src/addon.json +++ b/src/addon.json @@ -3,7 +3,7 @@ "type": "plugin", "name": "Spine", "id": "Gritsenko_Spine", - "version": "1.34.0", + "version": "1.34.1", "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/instance.js b/src/c3runtime/instance.js index 1c29580..6666ee2 100644 --- a/src/c3runtime/instance.js +++ b/src/c3runtime/instance.js @@ -105,15 +105,15 @@ // this.assetManager = new spine.SharedAssetManager(); // this.bgColor = new spine.Color(0.0, 0.0, 0.0, 0.0); - if (this._sdkType._skeletonData.notInitialized) + if (!this._sdkType._skeletonDataInitialized) { + this._sdkType._skeletonDataInitializing = true; this._sdkType._assetManager = new spine.SharedAssetManager(); this._sdkType._assetTag = this.uid; this.assetManager = this._sdkType._assetManager; - this._sdkType._skeletonData.initializing = true; const assetTag = this._sdkType._assetTag; - if (this.debug) console.log(this.GetInstance().GetUID(),'[Spine] Loading skeleton, textures, json, atlas'); + if (this.debug) console.info(this.GetInstance().GetUID(),'[Spine] Loading skeleton, textures, json, atlas'); // Only load textures once for creation of skeletonData, not for each instance // Disable PMA when loading Spine textures spine.webgl.GLTexture.DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL = true; @@ -140,7 +140,6 @@ } this.assetManager.loadText(assetTag, this.atlasURI); - this._sdkType._skeletonData.initializing = false; } this.isSpineInitialized = true; } @@ -187,11 +186,10 @@ const assetTag = this._sdkType._assetTag; const self = this; - if (this.debug) console.log("[Spine] Reading skeleton data:", this.uid, name, animationName); + if (this.debug) console.info("[Spine] Reading skeleton data:", this.uid, name, animationName); // If skeletonData not initialized, create it and stop other instances from creating it - if (this._sdkType._skeletonData.notInitialized) + if (!this._sdkType._skeletonDataInitialized) { - this._sdkType._skeletonData.notInitialized = false; const atlasURI = assetManager.get(assetTag, this.atlasURI); this._sdkType._atlas = new spine.TextureAtlas(atlasURI, function(path) { return assetManager.get(self._sdkType._assetTag, self._sdkType._assetPaths[path]); @@ -209,6 +207,8 @@ { this._sdkType._skeletonData = this._sdkType._skeletonJson.readSkeletonData(assetManager.get(assetTag, this.jsonURI) [name] ); } + this._sdkType._skeletonDataInitialized = true; + this._sdkType._skeletonDataInitializing = false; } var skeleton = new spine.Skeleton(this._sdkType._skeletonData); @@ -240,7 +240,7 @@ } }; - // if (this.debug) console.log('[Spine] track:', state.tracks[0]); + // if (this.debug) console.info('[Spine] track:', state.tracks[0]); state.apply(skeleton); skeleton.updateWorldTransform(); @@ -417,7 +417,7 @@ } if (!this.isSpineInitialized) { - if (!this.initSpineInProgress && !this._sdkType._skeletonData.initializing) + if (!this.initSpineInProgress && !this._sdkType._skeletonDataInitializing) { this.initSpine(); } @@ -497,7 +497,7 @@ let layerRect = wi.GetLayer().GetViewport(); let instanceRect = wi.GetBoundingBox(); let onScreen = instanceRect.intersectsRect(layerRect); - // console.log('[Spine] onscreen, rects', onScreen, layerRect, instanceRect); + // console.info('[Spine] onscreen, rects', onScreen, layerRect, instanceRect); spineBatcher.setInstanceOnScreen(onScreen, this.uid); @@ -575,7 +575,7 @@ let options = { mipMap: false, sampling: sampling } if (this.debug) { - console.log('[Spine] CreateDynamicTexture x,y:', Math.round(this.textureWidth), Math.round(this.textureHeight), this.uid, this.runtime.GetTickCount()); + console.info('[Spine] CreateDynamicTexture x,y:', Math.round(this.textureWidth), Math.round(this.textureHeight), this.uid, this.runtime.GetTickCount()); } this._elementTexture = renderer.CreateDynamicTexture(this.textureWidth, this.textureHeight, options); diff --git a/src/c3runtime/spine-bone-control.js b/src/c3runtime/spine-bone-control.js index 8a5a567..5a50502 100644 --- a/src/c3runtime/spine-bone-control.js +++ b/src/c3runtime/spine-bone-control.js @@ -30,11 +30,20 @@ class SpineBoneControl { const bones = this.bones; for(let boneName in bones) { - let bone = skeleton.findBone(boneName); - if (!bone) {console.warn('[Spine] applyBoneControl bone not found', boneName);continue;} + if(!bones[boneName].hasOwnProperty('__boneControlReference')) + { + let boneControlReference = skeleton.findBone(boneName); + if (!boneControlReference) {console.warn('[Spine] applyBoneControl bone not found', boneName);continue;} + // Cache reference + bones[boneName].__boneControlReference = boneControlReference; + } + for(const property in bones[boneName]) { - bone[property] = bones[boneName][property]; + // Ignore reference to bone + if (property == '__boneControlReference') continue; + + bones[boneName].__boneControlReference[property] = bones[boneName][property]; } } } diff --git a/src/c3runtime/spine-draw.js b/src/c3runtime/spine-draw.js index 0dabe94..5689cfe 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.34.0'); + console.log('[Spine] SpineBatcher init, 1.34.1'); globalThis.spineBatcher = new SpineBatch(); } \ No newline at end of file diff --git a/src/c3runtime/type.js b/src/c3runtime/type.js index 39c839a..5e71762 100644 --- a/src/c3runtime/type.js +++ b/src/c3runtime/type.js @@ -17,7 +17,8 @@ OnCreate() { this.GetImageInfo().LoadAsset(this._runtime); - this._skeletonData = {notInitialized : true, initializing : false} + this._skeletonDataInitialized = false; + this._skeletonDataInitializing = false; this._skeletonJson = null; // Tag for asset manager for skeletonData assets. this._assetTag = null; diff --git a/src/plugin.js b/src/plugin.js index 4227c23..ba0dc85 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.34.0"; + const PLUGIN_VERSION = "1.34.1"; const PLUGIN_CATEGORY = "general"; const PLUGIN_CLASS = SDK.Plugins.Gritsenko_Spine = class SpinePlugin extends SDK.IPluginBase {