Camera translations
See original GitHub issueHey, 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:
- Created 2 years ago
- Comments:10 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
I guess we could close this now, thank you again 😉