Giter Site home page Giter Site logo

playcanvas-spine's Issues

Runtime Error in Internet Explorer 11

Launch
https://launch.playcanvas.com/581347
in Internet Explorer 11

Observe
Error: Object doesn't support property or method 'map'
File: playcanvas-spine.min.js, Line: 3, Column: 17925

Notes
This is a minimal example project with the most current version of the playcanvas-spine library, which works in Chrome and Edge. But i think the issue is that IE 11 has a different implementation of Float32Array and uses a object type instead of a float type.

Allow optional material configuration for the plugin

Hey team,

while using the Spine plugin on one of our projects we've noticed that the Spine animations were white. We discovered that that was due to the ambient light that was set to white. We fixed that issue by patching the plugin and inside createMaterial method we disabled the diffuse color

material.diffuse = new pc.Color(0, 0, 0, 0); // include diffuse component, this allows lights contribution

I think this is kind of "hacky" on our part and was wondering if there could be a way of setting this as an option on the SpineComponent?

Thanks!

Spine clipping mask problem

Memory leak: Spine component not fully removed on destroy (Fix included)

Description

I noticed a performance issue after creating and deleting a large number of spine entities and using chrome memory snapshot tool realized that a lot of spine related data remained in memory after deleting all spines. (Spine, SpineComponent, SpineComponentData, SineTextureWrapper)

Investigating the code I noticed that the SpineComponentSystem overwrite the removeComponent function without calling the original breaking the component deletion flow.

Fix

This issue can be fixed by adding a call to the base removeComponent
pc.ComponentSystem.prototype.removeComponent.call(entity.spine.system, entity);
or a cleaner fix would be to register for the "beforeremove" event and move the spine removeComponent code into the callback.

this.on('beforeremove', this.onBeforeRemove, this);

...

onBeforeRemove: function(entity, component) {
        var data = entity.spine.data;
        if (data.spine) {
            data.spine.destroy();
        }

        entity.spine.removeComponent();
    },

Test project:

https://playcanvas.com/project/780176/overview/spine-leak

Steps to reproduce:

  1. launch application.
  2. Press load to load assets.
  3. Take memory snapshot with chrome developer tools ans search for spine objects.
  4. Press spawn to create a new spine entity.
  5. Pres delete to delete it.
  6. Wait a few second, take another memory snapshot and search for spine objects again.
  7. Notice the issue.
    If you uncomment one of the two fixed in playcanvas-spine.3.8.js around lines 7740 to 8870 all the extra spine data will be removed from memory.

Awesome!!!

Do you have a version of Super SpineBoy for mobile? (safari and mobile chrome)

Your version apparently only works on desktop browsers.

Regards

Unable to disable or destroy entity in the complete callback

When trying to disable or destroy an entity at the end of an animation. I either throws an error saying the skeleton cannot be null or keeps rendering the last frame of the animation.

SpineAnim.prototype.LoadSpine = function(entityName)
{
        this.entity.spine.spine.skeleton.setSkinByName("default");
        this.entity.spine.spine.skeleton.setSlotsToSetupPose();
        
        this.entity.spine.states[1] = new spine.AnimationState(this.entity.spine.spine.stateData);

        this.delegateObj = {
            complete: this.onComplete.bind(this),
            interrupt: this.onComplete.bind(this)
        };

        this.entity.spine.state.addListener(this.delegateObj);
            this.entity.spine.state.defaultMix = 0.2;
           this.entity.spine.state.addAnimation(0, "Idle", false);
};

SpineAnim.prototype.onComplete = function(track){

//this.entity.enabled = false <- doesnt work.  continues to render last frame.
//this.entity.destroy();  <- throws an error saying skeleton cannot be null.

  setTimeout(function(){this.entity.enabled = false;}.bind(this), 10); // <- works because it is outside of the on complete function.
        
};

Mention required "Power Of Two" export option.

This took a fair bit of head-scratching, so I'll post it here to avoid that problem in the future.
Since PlayCanvas resizes the textures to nearest power of two by default, this "Power of two" Spine export option has to be used.
image
(otherwise, image resizing has to be disabled in PlayCanvas Asset Task settings)

Attaching listeners to AnimationState

Hi, I'm not sure where to ask questions regarding the PC runtime for Spine so I'm asking here.

Can you provide an example of how to use addListener()? The Spine User Guide wasn't able to help me in this regard.

Spine Layer is set to UI Layer

The layer for spine rendering gets set to UI layer with this code in spine.js:

this._layers = [pc.LAYERID_UI];

Since one also wants to have UI rendererd over the spine characters, please consider to make this changeable via attributes.

Best,
Rene

Mask problem in Spine

Dear Mr. mvaligursky

Here's my conclusion: you are using an outdated Spine library.
Now for the details.
In the provided example, there are 2 objects drawn, a circle and a square, along with a mask.
The code that iterates through the Spine slots:
for (let i = 0; i < count; i++) {
const slot = drawOrder[i];
follows the logic of the original (https://github.com/EsotericSoftware/spine-runtimes/blob/3.7/spine-ts/webgl/src/SkeletonRenderer.ts) except for:

if (!this._spine_3_7_99) {
if (!slot.bone.active) {
clipper.clipEndWithSlot(slot);
continue;
}
}
However, even if I comment out this code, the situation remains unchanged.
Tracing this code, I see 3 objects in this loop:

  1. Set mask
  2. Draw circle
  3. Draw square

But it should:

  1. Set mask
  2. draw the circle
  3. remove mask
  4. draw the square
    Please update the spine library and rebuild playcanvas-spine.4.1.js.

You can check:
https://playcanvas.com/editor/scene/2001633
https://www.youtube.com/shorts/BnI2MctLFNg
https://github.com/eugene1kolombet/public/blob/main/moving_mask_spine_test.zip
Thank You!

Support modification of material properties

Currently this plugin just creates a material with properties defined by the plugin. It is useful to choose some of these properties. For example:

  • should the texture be the diffusemap or emissivemap
  • if emissive, diffuse color should be (0,0,0)
  • user may wish to disable lighting/fog/tonemapping on material.

Data export from Spine 3.8.xx

Hello,

I use spine 3.8.xx version.. When I export data from spine to playcanvas it's not working because of version. In contrib/spine-ts there is a warning: Spine-ts works with data exported from Spine 3.6.xx.
What can I do to upgrade to 3.8.xx version(how can I create a compatible playcanvas-spine.js) or do you have a plan to create a new playcanvas-spine.min.js for 3.8.xx?

Thank you

ES6 Compatibility

Current implementation modifies the global "pc" variable to store its data. In the more modern and performant builds of pc engine, this does not work.

The current implementation of spine needs to store data and make features available to every app instance that the global "pc" instance might create. It needs to persist it even when those app instances, scenes, or root nodes are destroyed. At the time, a clever and graceful solution was to tuck things neatly into the "pc" variable to make sure its available no matter what happens.

While the chances for conflict are low, modern language features have been introduced to solve conflicts between vendor libraries. Unfortunately, the current approach is what a conflicting vendor library would do. If the spine plugin implementation took a different approach to meet those goals, this issue goes away.

It seems a small refactor is required.

This issue was first raised on the engine project here:
playcanvas/engine#5399

Memory Leaks

I noticed that spine entities don't get freed in the memory. I used this project to reproduce this issue by having two scenes with one spine object each and you can switch between them. After each scene change, the previous spine entity can't get fully deleted. You can check this out by using the Memory Allocation Timeline of the chrome debugging tools. I explain it in further detail in this forum post.

Meshinstance memory leak in render

Repo project: https://playcanvas.com/project/704630/overview/spine-test

https://github.com/playcanvas/playcanvas-spine/blob/master/src/spine.js#L453

meshinstances are removed in the render loop but the materials that they referenced still have a reference to the meshinstance.

A temp fix that was used:

Spine.prototype.render = function () {
    // FIX: clear materials before dropping mesh instances:
    this._meshInstances.forEach(function(instance) {
        instance.material = null;
    });
    // END FIX
    this.removeFromLayers();
    this._meshes = [];
    this._meshInstances.length = 0;
  etc...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.