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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这是一个演示
http://code.almeros.com/code-examples/water-effect-画布/
Here's one demo
http://code.almeros.com/code-examples/water-effect-canvas/
http://rumpetroll.com/ 是开源的,并且具有您可以根据需要进行修改的运动类型
http://rumpetroll.com/ is open source and has the kind of movement you could probably modify to do as you wanted
我不确定你到底想模拟什么(或者我是否得到了概念艺术:)),但这可能是一个方向:
processing.js 不是物理引擎,而是 javascript 的图形库端口(利用画布) - http://processingjs.org/ 。
但是,您可能会在他们的演示中找到与您尝试创建的内容类似的内容。
原始处理库示例之一使用粒子系统进行了很好的流体模拟,并且它在processing.js上成功运行 - http://processing.org/learning/topics/fluid.html,但是帧率非常差。您可以在 http://processingjs.org/learning/ide 亲自尝试 - 只需复制并粘贴示例中的代码(并为您的计算机爬行停止做好准备)。
您可以尝试调整粒子数 (pnum),以提高速度,并尝试使用其他变量。
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.
抱歉,我不知道图书馆,但我最近确实在画布演示中看到了水物理:
http://hakim.se/experiments/html5/wave/03/
也许你可以在那里得到一些灵感...你也许可以使用像 Box2DJS 这样的普通 JS 物理库来完成它。
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.
只是一个想法,但您可以搜索 Java 引擎,然后使用 GWT 将其编译为 Javascript。
Just an idea, but you could search for a Java engine and then use GWT to compile it to Javascript.