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

I noticed different screen sizes cause incorrect positioning of objects #6249

Closed
garryygpw opened this issue Mar 18, 2015 · 10 comments
Closed

Comments

@garryygpw
Copy link

I noticed different screen sizes cause incorrect positioning of objects.

Best example of this is using this page:

http://threejs.org/examples/#canvas_interactive_voxelpainter

On larger laptop screen the cubes are positioned correctly, when viewing the same page on a smaller smartphone screen blocks are positioned in consistently incorrect positions.

Click in the bottom right corner of the grid and the blocks get positioned in the center

@mrdoob
Copy link
Owner

mrdoob commented Mar 18, 2015

Hmmm, could you share screenshots?

@garryygpw
Copy link
Author

Hello mrdoob, The device i used is a HTC one mini as you can see when i click on the grid in the bottom right corner the block appears in the middle left.

000126

To let you know the webgl voxel painter demo on the same pages works fine on the same device

http://threejs.org/examples/#webgl_interactive_voxelpainter

@michelgokan
Copy link

It also have the same problem when your browser is in zoom mode (cmd+plus).

@garryygpw
Copy link
Author

Thanks for your comment

I looked at the previous release example code and found r28 worked fine. Since then none of the other release example code seemed to work for the voxelpainter example.

Adding render() to the onDocumentMouseDown function got it working fine on the HTC one mini smartphone:

function onDocumentMouseDown(event) {
    event.preventDefault();
    // Adding render(); fixes the issue
    render();

@mrdoob
Copy link
Owner

mrdoob commented Mar 26, 2015

What mobile browser is that with?

@garryygpw
Copy link
Author

Default android browser v 6.0.798481 on a HTC one mini 2. Android version 4.4.2. I think this version uses the Chromium 30 browser. Am using the browser is an application using webview

@mrdoob
Copy link
Owner

mrdoob commented Mar 30, 2015

I see. I was confused because that example doesn't have touch events.

@garryygpw
Copy link
Author

Thanks for the info.

I thought might have worked ok. I understand is a little old now but used your r28 version (http://mrdoob.com/projects/voxels/) in the mobile browser with cubes being placed in the correct places perfectly.

I'd like to use merge with cubeGeometry and place the cubes in the correct place. Will keep trying, thanks for your comments

@garryygpw
Copy link
Author

Am so pleased got the example working for r71. In function onDocumentMouseDown(event) changed the following:

from

mouse.x = (event.clientX / renderer.domElement.width) * 2 - 1;
mouse.y = -(event.clientY / renderer.domElement.height) * 2 + 1;

to

mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;

Thanks again for your help

@mrdoob
Copy link
Owner

mrdoob commented Mar 30, 2015

Yays!

@mrdoob mrdoob closed this as completed Mar 30, 2015
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