Jump to content

How to use mouse to change the size of a cube?


southorion
 Share

Recommended Posts

Hi everyone! What I'm trying to do is to display a cube on the screen and I can use mouse to change the size of the cube.

The idea is

1. Display a cube on the center of the screen.

2. Hold the left key of the mouse then point the cursor to any part of the cube and flip along a certain direction. The cube's size will grow along the fliiping direction.(You can image this like your finger flipping on the iPhone sceen)

3. I can rotate the cube using mouse.

I'm very new to babylon.js. Hope you can give a little clue. Thank you sooooo much!

Link to comment
Share on other sites

Hiya S!  Umm... here's a cool playground.

https://www.babylonjs-playground.com/#PZGBU#10

Mouse-drag does one thing, CONTROL-mousedrag does another thing, SHIFT-mousedrag does a third thing, ALT-mousedrag does a fourth.

There's quite a bit to be learned from experimenting with that playground.  Grab its zip... take it home... or make more playground versions.... edit/save as many as you wish.

I think this will be a good start for you.  Ask more questions if you wish... we're here.  :)

The model-loading method used in that playground... is a bit "older".  You might wish to remove it and just use some simple mesh, or modernize it to an "AssetsManager task" way-of loading stuff. 

ALSO... I think some/all the DOM-based pointer/eventHandler stuff... can be replaced with more tech-wise ActionManager things.  cya

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...