Is there a water physics engine for javascript? - javascript

I want to make a demo using javascript and <canvas>, I was thinking of doing a little moving creature, seen from the top and swimming in a water environment.
Concept "art" :
Is there something I can use to start this project, or do I need to create everything from scratch ?

Here's one demo
http://code.almeros.com/code-examples/water-effect-canvas/

http://rumpetroll.com/ is open source and has the kind of movement you could probably modify to do as you wanted

I'm not sure what exactly do you intend to simulate (or whether I got the conceptual art :) ), but this might be a direction:
processing.js is not a physics engine, but rather a graphics library port to javascript (utilizing canvas) - http://processingjs.org/ .
However, you might find something in their demos that is similiar to what you are trying to create.
One of the original processing library examples has a nice fluid simulation using a particle system, and it runssuccessfully on processing.js - http://processing.org/learning/topics/fluid.html , however the framerate is very poor. You can try it yourself at http://processingjs.org/learning/ide - just copy&paste the code from the example (and prepare for your computer to crawl to a halt).
You can try to adjust the particle numbers (pnum), to improve speed, and play around with other variables.

Sorry I don't know of a library, but I did see a water physics in canvas demo recently:
http://hakim.se/experiments/html5/wave/03/
Maybe you can get some inspiration there...you might be able to accomplish it with a normal JS physics library like Box2DJS.

Just an idea, but you could search for a Java engine and then use GWT to compile it to Javascript.

Related

HTML Javascript - Need help learning to transition to 3D from Canvas

So now I can pretty much do almost whatever I want in 2 dimensional games/apps, using HTML Javascript Canvas.
Problem is now I want to make some 3D applications, but have NO IDEA where to start.
3D is completely new to me and I think regardless it seems like it will be very difficult for me to learn, but I want to try - I just don't know what to do now.
I've looked into three.js a bit, but it's chinese for me.
Thanks!
start learning from three.js
three.js
you can create mini to almost-enterprise quality of application with it. But here is a little issue, if you think about creating large games, where you need to put a lot of collisions , you can try babylon.js
they are for your coding aspect. Besides, you need to learn blender/3d studio max. try to get the basic philosophy of three basic operations (i suppose you already have..) rotation,translation,scaling.
try to edit the examples of three.js and see what it comes, trust me, it is not that tough that you are thinking.
After that, you can try shader (GLSL). you can find many shader examples in GLSL playground and shadertoy
Also this website is legendary for learning three.js
and try some others libraries like playcanvas,unity3d(webGL)
happy learning

Pathfinding.js in PlayCanvas

I am making a space game using Playcanvas. I want to add some AI to ships that fly around and shoot. I don't have any idea of how to impliment Pathfinding.js on a 3D space, let alone, using the PlayCanvas Script API as well. Does anyone know how to:
- Implement Pathfinding.js in a 3D Space
- Implement Pathfinding.js into a 3D PlayCanvas World
- Impliment Pathfinding.js into a 3D Object, inside a 3D PlayCanvas World
- Add basic tasks such as follow, attack, run away using Pathfinding.js
I am kind of a noob at Pathfinding.js, even using 2D, so please be exact, if you want to answer.
Thanks to all of you guys who work hard to help noobs like me!
Thanks much,
Noah
Pathfinding.js provides functionality for 2D pathfinding. Note that a fork of Pathfinding.js exists for 3D environments.
Some PlayCanvas projects that use the 2D version of Pathfinding.js do exist. Namely:
Zombie Pac-man (map.js uses Pathfinding.js API)
Last Line of Defense (map.js uses Pathfinding.js API)
Note that both of these projects are based on PlayCanvas' previous scripting system. New projects in PlayCanvas default to a newer (better) scripting system, but generally, the code will be very similar.

Build a webpage with a flock of birds flying endlessly around on it

I would like to build a webpage with a flock of birds flying around on it. White background, black, "bird-shapes" to begin with - I'm thinking folding triangles. Eventually I would be interested to generate random flying patterns but for now I would be happy to make regular, repeating patterns, with one "bird" to begin.
I'm wondering how might this best be achieved or where to begin? I have plenty of programming experience with Java, and some in HTML/JavaScript. But I'm interested to learn. I'm just looking for a few pointers. WebGL? Or just use JavaScript?
You're best bet is html 5's canvas tag. Canvas also supports WebGL, so using that would be easy too.
http://www.html5canvastutorials.com/advanced/html5-canvas-animation-stage/
Here is an example:
http://cssdeck.com/labs/flying-bird-animation
&
http://cssdeck.com/labs/o1jukgxc
You can use this idea to replicate your needs.
It depends on the effect you're looking for. If you want a 3d effect you should look into THREE.js. This tutorial is a pretty decent introduction. Personally I think you could do what you need using the 2d canvas. Daniel Shiffman's Nature of Code is a great tutorial on vehicles, all with the standard canvas context. Most of the examples have been translated into JavaScript (using p5.js), but it's originally in Java so it could be a great way to get your feet wet.

Javascript Optical Flow Implementation

I'm looking for an optical flow implementation to run on my web app in html5 canvas, but didn't found something immediately usable. If I choose to implement it by myself, is it be possible to achieve (near) real-time performance?
Or, since in the current setting, I actually just want to know the main optical flow is moving to the left or right, are there some easier algorithms I can use?
I made this little library which does (I hope) exactly what you are asking for.
A demo
Which utilizes this library to control the ball by moving your hands.
I made a real time feature tracking that can generate sparse optical flow and point trajectories. It uses asm.js, so it runs faster on firefox (50ms per 320x240 frame - 1500 points)
www.ensta-paristech.fr/~garrigues/js_tracking/javascript_video_tracking.html

How to make 3D animation with Canvas

I have background on Canvas 2D context, but i want to perform a 3D animation like this one, is Three.js library the best choice to do such animation? Can you point me to some useful tutorial or documentation that may help. Thanx in advance.
That's one of the most common choices.
As WebGL enables OpenGL without the need for libraries, you might also do it with just Vanilla JS but that would be harder as WebGL doens't offer much more refinement over the raw and crude OpenGL.
Apart three.js, you could also try GLGE or PhiloGL but as Three.js is the most popular I would recommend to go for it if you have no specific requirement.
Looks like the demo you linked to is using a canvas library called Clay.js. Not one that I've personally heard about until now. For 3d in canvas the most popular one I know of it Three.js as you already mentioned. It has the benefit of supporting webGL as well (browser based openGL variant).
Three.js has limited documentation and some examples but outside of some books you may buy there isn't a lot of hand holding. You basically need to dive in and start coding. Here are some online resources that may help you get started (not necessarily all focused on THREE.js):
http://aerotwist.com/tutorials/getting-started-with-three-js/
http://learningthreejs.com/
http://learningwebgl.com/blog/
To make it easier to work with THREE.js Jérôme Etienne created a project called tQuery which you can think of kinda like jQuery. A wrapper to make it easier to get your hands dirty. Here's a video where he shows how to create a webGL game in 10 minutes.

Categories