question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Camera translations

See original GitHub issue

Hey, thank you for this extremely cool api. After 5 days head banging, I found that I need to take into account the pixi’s renderer resolution in order to make the camera coord conversion to work as it should. Here are the wrapped methods (I am not sure 100% about the z values, because I do not need z at all in my app).

public static toWorld(
        container: Container,
        anchor: Point,
        model: Model
    ): ObservablePoint3D {
        let bounds = container.getBounds();
        let x = bounds.x + anchor.x * bounds.width;
        let y = bounds.y + anchor.y * bounds.height;
        return this.screenToWorld(x, y, model);
    }

    public static screenToWorld(
        x: number,
        y: number,
        model: Model
    ): ObservablePoint3D {
        let worldCoordinates = Camera.main.screenToWorld(
            x,
            y,
            Camera.main.z - model.z,
            undefined,
            {
                width:
                    App.instance.renderer.width /
                    App.instance.renderer.resolution,
                height:
                    App.instance.renderer.height /
                    App.instance.renderer.resolution,
            }
        );

        return worldCoordinates;
    }

    public static worldToScreen(
        x: number,
        y: number,
        z: number = Camera.main.z
    ): Point {
        let worldCoordinates = Camera.main.worldToScreen(x, y, z, undefined, {
            width:
                App.instance.renderer.width / App.instance.renderer.resolution,
            height:
                App.instance.renderer.height / App.instance.renderer.resolution,
        });

        return worldCoordinates;
    }

I hope this helps and it will save time to someone using your api.

Thanks, Ivan

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
djlastnightcommented, Sep 12, 2021

Thank you, it is merged, I will test it when I go back to home. -edit- Yes, it works now. The white rect is not centered on zoom change, but this is not important, because the model and pps works as they should.

0reactions
djlastnightcommented, Sep 13, 2021

I guess we could close this now, thank you again 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Camera Translator - App Store
Built with powerful camera & high quality AI translation. Translate photo, text, camera from English to Chinese, Japanese, Spanish, French, Arabic, etc. Explore ......
Read more >
Camera Translator - Translate - Apps on Google Play
Camera Translator uses the most advanced OCR technology to recognize and translate any object in any language. - Camera Translator automatically detects ...
Read more >
Google Translate's instant camera translation gets an upgrade
Google Translate adds new languages, source language auto-detect, and increased accuracy to its instant camera translations feature.
Read more >
Translate images - Android - Google Support
Use offline camera translations · On your Android phone or tablet, open the Translate app Translate app . · Tap the Camera Camera...
Read more >
Camera translator - - Talkao
Use the camera to translate texts between more than 80 different languages. Crop the image to translate only what you need and share...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found