Physics

  • Hi Ashley, there are some Javascript physics libraries that should work well when integrated with Lens Studio. This is an area we want to investigate more. That said, it's worth checking out the following: 

    http://www.cannonjs.org/

    and

    https://github.com/kripken/ammo.js/

     

    Comment actions Permalink
  • Hello,

    Few weeks ago, I would like to see if integrating physics into Lens Studio was possible, I looked for a very simple physics engine library on internet and found "Verlet-JS". I succeeded to integrate it to Lens Studio (with a bit of rewriting code), and it works pretty well ! (to make simple things like moving earings for exemple)

    It's a 2D engine, but I think it should be the same for a 3D one (but modify the code to have no compilation error is a bit time-consuming...)

    https://github.com/subprotocol/verlet-js

    But it could be so cool if the Lens Studio Team could add their own physics component into Lens Studio !!!

    Have fun !

    Comment actions Permalink
  • Hi,

     

    Awesome! These are what I was going to look into.

    Going to have a play around this week :)

     

    Thanks for the heads up!

    Comment actions Permalink
  • Hi,

     

    Do you have any examples or a version of cannon.js that has been modified for Lens Studio?

     

    Thanks

    Comment actions Permalink
  • Ha ha, I'm currently trying to integrate it  ;-)

    It seems to have some issues because of "Y up" in LensStudio and "Z up" in CannonJS...

     

    Comment actions Permalink
  • haha amazing, what did you modify in the JS?

    I can't even get it imported...

    Comment actions Permalink
  • I just get it working !

    Just import the Cannon.js that is in the "build" folder.

    Don't modify anything in the code, and don't use the Cannon_Demo.js as it use Three library for rendering and we don't need it because the rendering is made directly by LensStudio.

    I started with the exemple code provided in the main GitHub page, and comment the last part (the simulation part).

    Then you have to create a new script that is "FrameUpdated", and write the simuation stuff inside (world.step() )

    Finaly you just have to create a new 3D object for each cannonJS object (a new sphere for a sphereBody, a new plane for a planeBody etc...) and in your "FrameUpdated" script, write some code to connect each of their transform to the corresponding cannonJS object transform(in a simpler way, the position of the LensStudio's sphere is driven by the position of the Cannon's sphere)

     

    Comment actions Permalink
  • you genius!

    I made the mistake of not having both scripts set to initialised.

    I've got it working now as well but I'm having the Y up issues.

    I tried changing the gravity but the sphere falls through the plane...

    any tips?

    Comment actions Permalink
  • Put every objects in an parent object that is rotated -90 degrees in x axis and work with local transform, not world transform 😜

    Comment actions Permalink
  • absolute genius haha!

    Thanks for the help on this one!

    Comment actions Permalink
  • I imported Cannon.js as they said, but it still gives an error "17:21:54 ReferenceError: identifier 'CANNON' undefined
    at [anon] (Script:1) preventsyield"

    Comment actions Permalink
Have a comment?

Please sign in to leave a comment.

We're here to help! We just need a little bit of information...

What system are you using?

Have you downloaded the latest version of Lens Studio?

Please download the latest version of Lens Studio. If you still run into this issue, please come back and report it!

Is this issue causing Lens Studio to crash?

What system do you run Lens Studio on?

Version

Graphics

Follow the next steps to help us solve your issue:

  • Copy and paste this text into your TerminalCommand Window
    open ~/Library/Preferences/Snap/Lens\ Studio/ %LOCALAPPDATA%\Snap\Lens Studio Copy Text
  • Press ReturnEnter to run the command. The Lens Studio folder will automatically open
  • Prepare to upload your files: zip the "Log" Folder by right-clicking and choosing "compress."
    Locate the Log.txt file right above it.

    Attach a screenshot of the issue:

Name:

Email:

What is this most relevant to?

Please enter a brief description of your issue:

Thanks for submitting this issue.

Unfortunately, it's likely due to the operating system or hardware you're using – since they don't meet the system requirements for Lens Studio.

Still, we hear you loud and clear, and are logging the issue in case there's ever a workaround we can provide!

Minimum Requirements

Operating System: Windows 10 (64 bit); MacOS 10.11+

Hardware: Minimum of Intel Core i3 2.5Ghz or AMD Phenom II 2.6Ghz with 4 GB RAM; Intel HD Graphics 4000 / Nvidia GeForce 710 / AMD Radeon HD 6450 or better; screen resolution of 1280x768 or higher

We'll try to resolve this issue as soon as possible. Thanks for letting us know about it!

Keep an eye out for a followup email from us. We may have a couple more questions for you, or we might already have a solution to offer.

Happy creating!