Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: When Application is proxied by Vue 3(ref), an error occurs when rendering graphics #10477

Open
ZaneL1u opened this issue Apr 26, 2024 · 2 comments
Assignees

Comments

@ZaneL1u
Copy link

ZaneL1u commented Apr 26, 2024

Current Behavior

When Application is proxied by Vue 3, an error occurs when rendering graphics, like:

<script setup lang="ts">
import { Application, Graphics } from "pixi.js";
import { onMounted, ref } from "vue";

const app = ref<Application>();

onMounted(() => {
  (async () => {
    // Create a new application
    app.value = new Application();

    // Initialize the application
    await app.value.init({ antialias: true, resizeTo: window });

    // Append the application canvas to the document body
    document.body.appendChild(app.value.canvas);

    const graphics = new Graphics();
    graphics.rect(50, 50, 100, 100);
    graphics.fill(0xde3249);

    app.value.stage.addChild(graphics);
  })();
});
</script>

<template>
  <div id="pixi"></div>
</template>

<style scoped>
.pixi {
  width: 100%;
  height: 100%;
}
</style>

Then an error will be reported:
image

Expected Behavior

Align and process rendering correctly.

Steps to Reproduce

recurrent: https://codesandbox.io/p/devbox/pixijs-texturematrix-recurrent-lqknp4?file=%2Fsrc%2FApp.vue%3A6%2C8

Environment

  • pixi.js version: 8.0.0 - 8.1.0
  • Browser & Version: Chrome 124
  • OS & Version: MacOS 14.3 (23D56)
  • Running Example: recurrent

Possible Solution

After investigation, it was found:

if (texture !== Texture.WHITE)

The texture object was mistakenly pointed to the Texture.WHITE object. Comparison.

I want to submit a PR to solve this kind of problem, but it seems that comparing Label is inappropriate, and introducing additional Vue toRaw dependencies will increase complexity.

I would like to hear your suggestions?

Additional Information

No response

@jarvisniu
Copy link

Change ref to shallowRef will work

@ZaneL1u
Copy link
Author

ZaneL1u commented May 6, 2024

Change ref to shallowRef will work

YES, but I need ref to listen for deep value changes.
And I think it should be a pointer problem, which will make Proxy unavailable. @jarvisniu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants