kripken / ammo.js Goto Github PK
View Code? Open in Web Editor NEWDirect port of the Bullet physics engine to JavaScript using Emscripten
License: Other
Direct port of the Bullet physics engine to JavaScript using Emscripten
License: Other
Compiling code in C++ that uses bullet works fine, but using the compiled library directly from JS is very hard.
We need some new tools and ideas here. Or maybe we should just manually write the API in JS. This would give the best results, but take some initial effort.
Hello,
I find performance issues with the latest versions of emscripten.
Hard to see this problem with the ammo webgl_demo. So, a simple way to test this :
Also, last versions of ammo are 1.6 or 1.8Mb. Older versions are 1.1 Mb.
I did a lot of tests to help to find the problem. I've check out few commits of emscripten and always build the last version of ammo.js. Some results :
29 may, commit 731ae9d12985230ea05bf174c22771f52d453332 : ammo.js = 1.6Mb. Slower
30 january, commit 9d50dabd93d499f8f059990668c2318d60c5dc1c : ammo.js = 1.1Mb and is ok
Between this 2 commits, I have tests some commits, but some problems appears (problem for build, or build ok but doesn't work, I think is related to issue 22 : #22)
Thanks for your help.
Perhaps I'm missing something obvious but I can't work out how to make those other two builds.
Thanks.
To "deal" with multi-arch issues on Debian, I had to apply the multi-arch patch mentioned in a Debian llvm-2.9 bug report and build llvm from debians Sid(unstable) repository.
Debians clang in Sid depends on gcc/g++-4.6, which I have a problem with, so I got the ubuntu sources (which use gcc/g++-4.5) and built/installed them.
Running the emscripten test is a lot faster!
python tests/runner.py clang_0_0.test_the_bullet
Running Emscripten tests...
test_the_bullet (main.clang_0_0) ... ok
Ran 1 test in 265.325s
OK
This compares with 664.900s when it was based on 4.3.
Unfortunately building ammo.js raises a problem:
// Unclear type in struct: <2 x float>, in %64
Assertion failed: undefined
Stack: Error
at assertTrue (utility.js:60:23)
at eval at (/v3c/dev/kripken/emscripten/src/compiler.js:65:6)
at Array.map (native)
at Object.calculateStructAlignment (eval at (/v3c/dev/kripken/emscripten/src/compiler.js:65:6))
at analyzer.js:201:19
at Array.forEach (native)
at Object.analyzeTypes as processItem
at Object.process (framework.js:155:26)
at framework.js:104:25
at Array.forEach (native)
utility.js:61: Assertion failed: undefined
throw msg;
^
Using Clang 3.1, an updated clone of emscripten and ammo.js, I successfully generated the file builds/ammo.js.
There was a lot of Clang warnings (see the end of this message), no problem during the stage 3 (Configure) and 4 (Make), but during the stage 5 (Linking), I have the following messages:
/usr/local/bin/llvm-dis: Could not open src/.libs/libBulletCollision.so: No such file or directory
/usr/local/bin/llvm-dis: Could not open src/.libs/libBulletDynamics.so: No such file or directory
/usr/local/bin/llvm-dis: Could not open src/.libs/libLinearMath.so: No such file or directory
Then the content of the stage 6 (emcc) is the following:
=============
Stage 6: emcc
=============
Warning: Applying some potentially unsafe optimizations! (Use -O2 if this fails.)
path.exists is now called `fs.exists`.
path.exists is now called `fs.exists`.
alzathar@ubuntu:~/Downloads/ammo.js.git$
I then tried to test the code using the webgl_demo, but in the Firefox Web console, I have an error in the file ammo.js. Moreover, the size of the file ammo.js is only 757kB instead of 1.6MB (size of the file in the Git repository).
I used also the command 'find . -name '*.so' -print' in the folder, but no file was found. In the folder '.libs', I have only '.la' files. I execute 'emconfigure ./configure' in the folder 'bullet' as well as 'emconfigure make' and still, there is no '.so' files.
Is it possible that the mechanism in Emscripten was updated but the Python script for ammo (make.py) was not?
bindings.cpp:12096:54: warning:
'emscripten_bind_btQuantizedBvh__getSubtreeInfoArray_p0' has C-linkage
specified, but returns user-defined type 'BvhSubtreeInfoArray &' (aka
'btAlignedObjectArray<btBvhSubtreeInfo> &') which is incompatible with C
[-Wreturn-type-c-linkage]
BvhSubtreeInfoArray& __attribute__((used, noinline)) e...
^
bindings.cpp:12099:44: warning: 'emscripten_bind_btQuantizedBvh__unQuantize_p1'
has C-linkage specified, but returns user-defined type 'btVector3 &' which
is incompatible with C [-Wreturn-type-c-linkage]
...noinline)) emscripten_bind_btQuantizedBvh__unQuantize_p1(btQuantizedBvh...
^
429 warnings generated.
#define ACTIVE_TAG 1
#define ISLAND_SLEEPING 2
#define WANTS_DEACTIVATION 3
#define DISABLE_DEACTIVATION 4
#define DISABLE_SIMULATION 5
where are these variables
The "Contact Test" example here:
http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_Callbacks_and_Triggers
shows how C++ callbacks can be used, when certain collisions happen. We need to do this from JS as well.
I am trying to find a way to know which objects are currently having a collition.
since the regular callback system isn't working now i found 2 possible other ways
customize the vtable with the following script
(function() {
var calledBack = false;
var callback = new Ammo.ConcreteContactResultCallback();
Ammo.customizeVTable(callback, [{
original: Ammo.ConcreteContactResultCallback.prototype.addSingleResult,
replacement: function(cp, etc) {
calledBack = true;
console.log('collition')
}
}]);
assert(!calledBack);
callback.addSingleResult(Ammo.NULL, Ammo.NULL, Ammo.NULL, Ammo.NULL, Ammo.NULL, Ammo.NULL,
Ammo.NULL);
assert(calledBack);
})();
this doesnt seems to work. at least i expect to have the replacement function to be called everytime a collition is detected. Now it get executed only once upon initialization
scene.world.stepSimulation( 1 / 60, 1, 1/60 );
var count = scene.world.getDispatcher().getNumManifolds();
for (var i=0; i < count;i++)
{
///myobjectA.activate();
///myobjectB.activate();
var contactManifold = scene.world.getDispatcher().getManifoldByIndexInternal(i);
var obA = contactManifold.getBody0();
var obB = contactManifold.getBody1();
if (myobjectA == obA && myobjectB == obB){
console.log("a and b collided")
}
else{
console.log('nothing')
}
}
unfortunaly the last one is behaving strange. it seems that when for example a ball is rolling in the direction of a box. both the box and the ball become part of the manifolds. Also without ccd this is happening. Normal behaviour?
Anyway i cannot find a way to proper get my collitions. Is there another way? or do i something wrong
m_dynamicsWorld.getDispatcher().getManifoldByIndexInternal(1).getBody0()
return 6098832
what does this number mean?
I can't get btTransform's getOpenGLMatrix function to work. Here's what I thought should work:
var m = new Array(16);
transform.getOpenGLMatrix(m);
I've tried various other things, but can't seem to get anything back from getOpenGLMatrix. I can get my code to work if I use getBasis().getRow()... and getOrigin(), and use that to make a matrix, but that seems like a very roundabout way to do it.
(I can't setOpenGLMatrix to work either, but I assume the issue is probably the same, since both functions expect a pointer to a btScalar array in the original Bullet version.)
What would be involved in getting a JS version of this stuff? https://github.com/kripken/ammo.js/tree/master/bullet/Extras/ConvexDecomposition
There are several comments on the Bullet forums referring to different behaviour for restitution in the case where a ball bounces on a static box (versus the case where a box bounces on a static box). For example:
http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=6787
I do note that Bullet 2.78 is nearly 2 years old now, and I do wonder whether this is simply a bug that has now been fixed. The first thing I wanted to do was download the latest bullet source (2.81) and compile with Emscripten. I have downloaded and installed Emscripten and I seem to have a valid install.
When I try to execute python make.py for ammo.js (compiling Bullet 2.78) on Mac OS X 10.8.3, I get:
Mac-mini:ammo.js willeastcott$ python make.py
--------------------------------------------------
Building ammo.js, build type: ['-O2', '-s', 'DOUBLE_MODE=0', '-s', 'PRECISE_I64_MATH=0', '-s', 'ASM_JS=1', '-s', 'EXPORT_BINDINGS=1', '-s', 'DEAD_FUNCTIONS=["__ZSt9terminatev","__ZN20btAxisSweep3InternalItE26processAllOverlappingPairsEP17btOverlapCallback","__ZN20btAxisSweep3InternalIjE26processAllOverlappingPairsEP17btOverlapCallback"]', '-s', 'TOTAL_MEMORY=67108864']
--------------------------------------------------
==========================
Stage 1: Generate bindings
==========================
Preprocessing...
i686-apple-darwin11-llvm-gcc-4.2: c: No such file or directory
i686-apple-darwin11-llvm-gcc-4.2: c++: No such file or directory
i686-apple-darwin11-llvm-gcc-4.2: warning: '-x -x' after last input file has no effect
i686-apple-darwin11-llvm-gcc-4.2: no input files
Cleaning...
Processing...
Therefore, I tried editing make.py to use gcc instead of cpp, and I get:
Mac-mini:ammo.js willeastcott$ python make.py
--------------------------------------------------
Building ammo.js, build type: ['-O2', '-s', 'DOUBLE_MODE=0', '-s', 'PRECISE_I64_MATH=0', '-s', 'ASM_JS=1', '-s', 'EXPORT_BINDINGS=1', '-s', 'DEAD_FUNCTIONS=["__ZSt9terminatev","__ZN20btAxisSweep3InternalItE26processAllOverlappingPairsEP17btOverlapCallback","__ZN20btAxisSweep3InternalIjE26processAllOverlappingPairsEP17btOverlapCallback"]', '-s', 'TOTAL_MEMORY=67108864']
--------------------------------------------------
==========================
Stage 1: Generate bindings
==========================
Preprocessing...
Undefined symbols for architecture x86_64:
"btAlignedFreeInternal(void*)", referenced from:
btAlignedAllocator<int, 16u>::deallocate(int*) in ccE3CEf1.o
btAlignedAllocator<btHashInt, 16u>::deallocate(btHashInt*) in ccE3CEf1.o
btAlignedAllocator<btTriangleInfo, 16u>::deallocate(btTriangleInfo*)in ccE3CEf1.o
"btTypedConstraint::serialize(void*, btSerializer*) const", referenced from:
vtable for btTypedConstraintin ccE3CEf1.o
"std::terminate()", referenced from:
btHashMap<btHashInt, btTriangleInfo>::~btHashMap()in ccE3CEf1.o
"vtable for __cxxabiv1::__class_type_info", referenced from:
typeinfo for btTypedObjectin ccE3CEf1.o
typeinfo for btHashMap<btHashInt, btTriangleInfo>in ccE3CEf1.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for __cxxabiv1::__vmi_class_type_info", referenced from:
typeinfo for btTypedConstraintin ccE3CEf1.o
typeinfo for btTriangleInfoMapin ccE3CEf1.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"operator delete(void*)", referenced from:
btTypedConstraint::~btTypedConstraint()in ccE3CEf1.o
btTypedConstraint::~btTypedConstraint()in ccE3CEf1.o
btTriangleInfoMap::~btTriangleInfoMap()in ccE3CEf1.o
btTriangleInfoMap::~btTriangleInfoMap()in ccE3CEf1.o
"___cxa_pure_virtual", referenced from:
vtable for btTypedConstraintin ccE3CEf1.o
"___gxx_personality_v0", referenced from:
Dwarf Exception Unwind Info (__eh_frame) in ccE3CEf1.o
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Cleaning...
Processing...
I do get an ammo.js built at the end but it's only about 57KB in length.
If anyone can help me, I'd be very appreciative! :)
When I update to:
I get the following error:
btDefaultCollisionConfiguration is not defined
I see a string for it in the source as a this.btDefaultCollisionConfiguration=Z8
reference but otherwise it appears to be gone..
Hello,
I compiled last ammo.js version with the last emscripten version.
When I test it, I've an error.
The last version of emscripten where ammo.js work fine is the 03 december (c735bb6469370c0a6be212a630c9a73698ebdfbc).
Thanks for your reply.
Hi,
It seems constants are undefined in some (or all) ammo classes. E.g no CF_* CO_* in btCollisionObject or DISABLE_DEACTIVATION in Ammo. How can I extract Bullet constants from C++ and use them in JavaScript?
Just trying to implement my landscape classes from C++ and noticed the btHeightfieldTerrainShape is missing -- please include it for the next build!
In the README you state that "Not all classes are exposed, for various reasons". Is there a chance you can compile a list of classes that are not accessible or explain why they are not exposed.
I'm converting a bullet C++ source file to javascript and some classes (i.e. Ammo.btAlignedObjectArray) are returning undefined.
why
body.getAngularVelocity().x()
has return NaN ,and getLinearVelocity() is right
plee@sos:~/nonrs/git$ cd ammo.js/
plee@sos:~/nonrs/git/ammo.js$ l
total 60
-rw-r--r-- 1 plee plee 195 2012-02-23 12:24 AUTHORS
drwxr-xr-x 2 plee plee 4096 2012-02-23 12:28 builds
drwxr-xr-x 6 plee plee 4096 2012-02-23 12:24 bullet
-rw-r--r-- 1 plee plee 212 2012-02-23 12:24 bundle.py
drwxr-xr-x 3 plee plee 4096 2012-02-23 12:25 examples
-rw-r--r-- 1 plee plee 905 2012-02-23 12:24 LICENSE
-rwxr-xr-x 1 plee plee 6586 2012-02-23 12:24 make.py
-rw-r--r-- 1 plee plee 11515 2012-02-23 12:24 README.markdown
-rw-r--r-- 1 plee plee 1390 2012-02-23 12:24 root.h
-rw-r--r-- 1 plee plee 1879 2012-02-23 12:24 test.py
drwxr-xr-x 2 plee plee 4096 2012-02-23 12:27 tests
-rw-r--r-- 1 plee plee 583 2012-02-23 12:24 wrap.py
plee@sos:~/nonrs/git/ammo.js$ python make.py
--------------------------------------------------
Building ammo.js, build type: ['-O3', '-s', 'DOUBLE_MODE=1', '-s', 'CORRECT_SIGNS=1', '-s', 'INLINING_LIMIT=0']
--------------------------------------------------
==========================
Stage 1: Generate bindings
==========================
Preprocessing...
Cleaning...
Processing...
=======================
Stage 2: Build bindings
=======================
==================
Stage 3: Configure
==================
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... /home/plee/Dev/emscripten/emcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /home/plee/Dev/emscripten/emcc accepts -g... yes
checking for /home/plee/Dev/emscripten/emcc option to accept ISO C89... none needed
checking dependency style of /home/plee/Dev/emscripten/emcc... none
checking whether /home/plee/Dev/emscripten/emcc and cc understand -c and -o together... yes
checking whether we are using the GNU C++ compiler... yes
checking whether /home/plee/Dev/emscripten/em++ accepts -g... yes
checking dependency style of /home/plee/Dev/emscripten/em++... none
checking for a sed that does not truncate output... ../configure: line 4229: echo: write error: Broken pipe
/bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by /home/plee/Dev/emscripten/emcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/bin/ld option to reload object files... -r
checking how to recognize dependent libraries... pass_all
checking for ar... /home/plee/Dev/emscripten/emar
checking for strip... strip
checking for ranlib... /home/plee/Dev/emscripten/emranlib
checking command to parse /usr/bin/nm -B output from /home/plee/Dev/emscripten/emcc object... ok
checking how to run the C preprocessor... /home/plee/Dev/emscripten/emcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether /home/plee/Dev/emscripten/em++ accepts -g... (cached) yes
checking dependency style of /home/plee/Dev/emscripten/em++... (cached) none
checking how to run the C++ preprocessor... /home/plee/Dev/emscripten/em++ -E
checking for objdir... .libs
checking if /home/plee/Dev/emscripten/emcc supports -fno-rtti -fno-exceptions... yes
checking for /home/plee/Dev/emscripten/emcc option to produce PIC... -fPIC -DPIC
checking if /home/plee/Dev/emscripten/emcc PIC flag -fPIC -DPIC works... yes
checking if /home/plee/Dev/emscripten/emcc static flag -static works... yes
checking if /home/plee/Dev/emscripten/emcc supports -c -o file.o... yes
checking if /home/plee/Dev/emscripten/emcc supports -c -o file.o... (cached) yes
checking whether the /home/plee/Dev/emscripten/emcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for ld used by /home/plee/Dev/emscripten/em++... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking whether the /home/plee/Dev/emscripten/em++ linker (/usr/bin/ld) supports shared libraries... yes
checking for /home/plee/Dev/emscripten/em++ option to produce PIC... -fPIC -DPIC
checking if /home/plee/Dev/emscripten/em++ PIC flag -fPIC -DPIC works... yes
checking if /home/plee/Dev/emscripten/em++ static flag -static works... yes
checking if /home/plee/Dev/emscripten/em++ supports -c -o file.o... yes
checking if /home/plee/Dev/emscripten/em++ supports -c -o file.o... (cached) yes
checking whether the /home/plee/Dev/emscripten/em++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether byte ordering is bigendian... no
checking BulletMultiThreaded... no
checking for GL/gl.h... yes
checking for GL/glu.h... yes
checking for GL/glext.h... yes
checking for GL/glut.h... yes
checking for main in -lGL... no
checking for main in -lGLU... no
checking for main in -lGLUT... no
checking for main in -lopengl32... no
checking for main in -lglu32... no
checking build mode... optimize
configure: creating ./config.status
config.status: creating bullet.pc
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating Extras/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
configure:
Please type 'make' to build Bullet
=============
Stage 4: Make
=============
cd .. && /bin/bash /home/plee/nonrs/git/ammo.js/bullet/missing --run aclocal-1.10
/home/plee/nonrs/git/ammo.js/bullet/missing: line 54: aclocal-1.10: command not found
WARNING: `aclocal-1.10' is missing on your system. You should only need it if
you modified `acinclude.m4' or `configure.ac'. You might want
to install the `Automake' and `Perl' packages. Grab them from
any GNU archive site.
cd .. && /bin/bash /home/plee/nonrs/git/ammo.js/bullet/missing --run autoconf
cd .. && /bin/bash /home/plee/nonrs/git/ammo.js/bullet/missing --run automake-1.10 --gnu
/home/plee/nonrs/git/ammo.js/bullet/missing: line 54: automake-1.10: command not found
WARNING: `automake-1.10' is missing on your system. You should only need it if
you modified `Makefile.am', `acinclude.m4' or `configure.ac'.
You might want to install the `Automake' and `Perl' packages.
Grab them from any GNU archive site.
aclocal.m4:14: error: this file was generated for autoconf 2.61.
You have another version of autoconf. If you want to use that,
you should regenerate the build system entirely.
aclocal.m4:14: the top level
autom4te: /usr/bin/m4 failed with exit status: 63
WARNING: `autoconf' is probably too old. You should only need it if
you modified `configure.ac'. You might want to install the
`Autoconf' and `GNU m4' packages. Grab them from any GNU
archive site.
/bin/bash ./config.status --recheck
running CONFIG_SHELL=/bin/bash /bin/bash ../configure --disable-demos --disable-dependency-tracking CC=/home/plee/Dev/emscripten/emcc CFLAGS= CXX=/home/plee/Dev/emscripten/em++ --no-create --no-recursion
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... /home/plee/Dev/emscripten/emcc
checking for C compiler default output file name... a.out.js
checking whether the C compiler works... configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.
make: *** [config.status] Error 1
=============
Stage 5: Link
=============
llvm-ld: error: Cannot find linker input 'src/.libs/libBulletCollision.a.bc'
Traceback (most recent call last):
File "make.py", line 157, in <module>
'libbullet.bc')
File "/home/plee/Dev/emscripten/tools/shared.py", line 466, in link
assert os.path.exists(target) and (output is None or 'Could not open input file' not in output), 'Linking error: ' + output
AssertionError: Linking error:
CC @kripken
Hello,
I made a rapid benchmark test file for testing performance with constraints.
When I launch the test, I've this error :
uncaught exception: Assertion: Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value ( 20971520), (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.
I think there an error because :
File for test : http://www.stoomm.com/benchconstraint.js (lauch with test.py)
Thanks a lot for your help.
Original Example by Eric Mixon and "fiddlization" and various cleanups by strelz
step 1) make you own fiddle account at http://jsfiddle.net
step 2) point chrome at http://jsfiddle.net/strelzoff/6zG3F/
step 3) fork your own copy
step 4) start fiddling
ps...eventually download or git your very own copy of ammo.js and link to it rather than ours
When I try to load http://www.syntensity.com/static/ammo.html the tab crashes on my Chrome 16. Don't know whether it is supposed to work.
Hello there. I've been playing with the current build of ammo.js, specifically ammo.ta1.js and ammo.small.js (built from source on Mac OSX). I've noticed that, when running ammo.small.js I can leave the simulation running for some time (1hour +) but eventually the following error occurs:
Uncaught Assertion: Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value, (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.
ta1 fails much faster with a similar error (which I will post shortly). Im guessing something is leaking somewhere along the line.
bullet is currently at 2.81 while ammo is only at 2.78.
Mainly interested since 2.79+ includes a new convex decomposition algorithm in Extras
: http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=18&t=7445
newer = better?
I was just wondering, is it possible to use other constructors of Bullet classes than the first?
For example, the btHingeConstraint. It's got four constructors:
new Ammo.btHingeConstraint (rbA, rbB, pivotInA, pivotInB, axisInA, axisInB, useReferenceFrameA)
new Ammo.btHingeConstraint (rbA, pivotInA, axisInA, useReferenceFrameA)
new Ammo.btHingeConstraint (rbA, rbB, rbAFrame, rbBFrame, useReferenceFrameA)
new Ammo.btHingeConstraint (rbA, rbAFrame, useReferenceFrameA)
(See http://www.bulletphysics.com/Bullet/BulletFull/classbtHingeConstraint.html for full doc.)
The first constructor seems to work (see the ragdoll demo), but nothing happens when I try any other constructor. Did I miss something obvious here?
The title says it all.
Although there is some dynamics (an object falls), all the rest is simply not happening (interaction with other objects in a normal way).
this is my code:
var triTransform = new Ammo.btTransform();
triTransform.setIdentity();
triTransform.setOrigin(new Ammo.btVector3(0, 3, 0));
var verti = [];
verti[0] = new Ammo.btVector3(-1.5, -.612, -.866);
verti[1] = new Ammo.btVector3(1.5, -.612, -.866);
verti[2] = new Ammo.btVector3(0, -.612, 1.732);
verti[3] = new Ammo.btVector3(0, 1.837, 0);
verti[0] = new Ammo.btVector3(0, 0, 0);
verti[1] = new Ammo.btVector3(1, 0, 0);
verti[2] = new Ammo.btVector3(.5, 0, 1);
verti[3] = new Ammo.btVector3(.5, 4, .5);
var triMesh = new Ammo.btTriangleMesh();
triMesh.addTriangle(verti[0], verti[1], verti[2], true);
triMesh.addTriangle(verti[1], verti[0], verti[3], true);
triMesh.addTriangle(verti[2], verti[1], verti[3], true);
triMesh.addTriangle(verti[0], verti[2], verti[3], true);
var triShape = new Ammo.btConvexTriangleMeshShape(triMesh, true);
this.shape1 = this.localCreateRigidBody(1, triTransform, triShape);
I am programming this in an environment made by schteppe (big ups for that really nice environment) so the motionstate and rigidbody are created in localCreateRigidBody, where a THREE object is linked to this as well.
In the C++ bullet written examples I see them using btHullShape when using the convextrianglemeshshape, this hullshape is missing in Ammo. Maybe this is where the problem lies? Elsewise I am lost...
Greetings Jesse
Hey,
I'm interesting in using heighmap with Three.js + ammo.js
for example:
http://robchadwick.com/TerrainEditor/
http://cjcliffe.github.io/CubicVR.js/experiment/landscape_editor/landscape_edit_500m.html
http://stemkoski.github.io/Three.js/Shader-Heightmap-Textures.html
http://qiao.github.io/fractal-terrain-generator/demo/
Please advise what should be the best way to implement that.
Thanks!
I get the above error message in Firefox, and an uninformative ‘Aw, snap!’ in Chrome when trying to use ammo.js
. In contrast, the ta1
build works well.
Hello,
I try to get the following code to work:
// retrieve array of position scalars. length % 3 === 0
var positions = this._getMeshPositions();
var objShape = new Ammo.btConvexHullShape(positions, positions.length/3);
this.collisionObject = new Ammo.btCollisionObject();
this.collisionObject.setCollisionShape(objShape);
However, no collisions are reported. If I change the objectshape-lines to the following, everything works as expected:
var objShape = new Ammo.btConvexHullShape();
for(var i = 0; i < positions.length; i += 3)
{
var pt = new Ammo.btVector3(positions[i], positions[i+1], positions[i+2]);
objShape.addPoint(pt);
}
This is a major performance problem because for large meshes addPoint() is really slow :/
Does someone know a solution to this?
I wrote the exact same code in C++. There everything works like a charme.
Regards,
bobbel
I'm trying to get called back on internal ticks, without success. I tried the naive approach:
dynamicsWorld = new ammo.btDiscreteDynamicsWorld(...)
dynamicsWorld.setInternalTickCallback(pretick, this, true)
dynamicsWorld.setInternalTickCallback(posttick, this, false)
dynamicsWorld.stepSimulation(1/30, 5)
function pretick(dw, timeStep) { /* XXX never called */ }
function posttick(dw, timeStep) { /* XXX never called */ }
I looked at Callbacks from C++ to JS in tests/wrapping.js
, but that doesn't seem to apply in this case, as I'm not replacing a function on an object, just trying to pass JS objects/functions.
I think I can work around not being able to use the worldUserInfo
parameter to setInternalTickCallback()
, but I do need the callback function to get invoked.
Am I doing something wrong, or is this just not possible right now?
http://strelz12.cs.usm.edu/physics/
This example has three.js rendering running in the main javascript thread and ammo.js running independently in a webworker
result is a HUGE improvement in performance from a limit of around 40 objects in the single-thread version to as many as a 1000 objects in the "workerized" version.
check it out - more examples to come
strelz
Was just noting that I can't seem to get to the m_raycastInfo
from my btWheelInfo
object obtained through btRaycastVehicle.getWheelInfo(x)
using myWheelInfo.get_m_raycastInfo()
. I've tested and every other available property and function appears to be working correctly.
I'm guessing it's related to the struct-in-struct that's used here:
struct btWheelInfo
{
struct RaycastInfo
{
//set by raycaster
btVector3 m_contactNormalWS;//contactnormal
btVector3 m_contactPointWS;//raycast hitpoint
btScalar m_suspensionLength;
btVector3 m_hardPointWS;//raycast starting point
btVector3 m_wheelDirectionWS; //direction in worldspace
btVector3 m_wheelAxleWS; // axle in worldspace
bool m_isInContact;
void* m_groundObject; //could be general void* ptr
};
RaycastInfo m_raycastInfo;
/// ... snip ...
So for an example ray-test of:
var rayCallback = new ClosestRayResultCallback(btRayFrom,btRayTo);
dynamicsWorld.rayTest(btRayFrom,btRayTo,rayCallback);
if (rayCallback.hasHit())
{
body = btRigidBody.prototype.upcast(rayCallback.m_collisionObject);
if (body !== NULL)
{
console.log("hit");
}
}
It appears that .hasHit() isn't a valid function, as well .m_collisionObject never appears to be set so the upcast() always fails as well.
The following code fails during the construction of btRigidBody:
var mesh = new Ammo.btTriangleMesh(true, true);
mesh.addTriangle(
new Ammo.btVector3(0, 0, 0),
new Ammo.btVector3(1, 0, 0),
new Ammo.btVector3(0, 1, 0),
false
);
var shape = Ammo.btBvhTriangleMeshShape(mesh, true, true);
var transform = new Ammo.btTransform();
transform.setIdentity();
var body = new Ammo.btRigidBody(
new Ammo.btRigidBodyConstructionInfo(
0,
new Ammo.btDefaultMotionState(transform),
shape,
new Ammo.btVector3(0, 0, 0)
)
);
The error message is the following:
ammo.js:2355: Uncaught TypeError: Cannot read property 'a' of undefined
First of all, many compliments for the awesome work.
Just two questions:
many thanks and again great work!
Hi again,
I found that Bullet class ClosestRayResultCallback is not in btCollisionWorld as it is stated in the Bullet API docs. Instead it is a member of global Ammo. Is this ok?
It seems like I should be able to checkout and build. This is Ubuntu x86_64 11.10, using Clang 3.0 from here: http://llvm.org/releases/download.html
emmaken.py: /home/USER/projects/emscripten/tools/emmaken.py -I../src -include ../../root.h bindings.cpp -c -o bindings.bc
Running: /home/USER/projects/clang+llvm-3.0-x86_64-linux-Ubuntu-11_10/bin/clang++ -I../src -include ../../root.h bindings.cpp -c -o bindings.bc -m32 -U__i386__ -U__x86_64__ -U_
i386 -U__x86_64 -U__SSE_ -U__SSE2__ -U__MMX__ -UX87_DOUBLE_ROUNDING -UHAVE_GCC_ASM_FOR_X87 -DEMSCRIPTEN -U__STRICT_ANSI__ -nostdinc -I/home/USER/projects/emscripten/system/in
clude -I/home/USER/projects/emscripten/system/include/bsd -I/home/USER/projects/emscripten/system/include/libc -I/home/USER/projects/emscripten/system/include/libcxx -I/home/US
ER/projects/emscripten/system/include/gfx -I/home/USER/projects/emscripten/system/include/net -I/home/USER/projects/emscripten/system/include/SDL -U__APPLE__ -emit-llvm -c
(None, None)
/bin/bash ./config.status --recheck
running CONFIG_SHELL=/bin/bash /bin/bash ../configure --disable-demos --disable-dependency-tracking CC=/home/USER/projects/emscripten/tools/emmaken.py CFLAGS=-g CXX=/home/USER
/projects/emscripten/tools/emmaken.py --no-create --no-recursion
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... /home/USER/projects/emscripten/tools/emmaken.py
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See `config.log' for more details.
make: *** [config.status] Error 77
Hi,
I have several students who would like to work on ammo.js related projects this semester
any help or pointers would be appreciated - also can you point us to a non-minimized version of ammo.js? Its hard to debug when the program trace disappears into minimized ammo.js code
thanks
strelz
Hello,
A little difference between versions with closure and without closure.
In the closure version (ex : ammo.small.js), we can get the pointer with object.a
In the no closure version (ex : ammo.fast.js or ammo.asm.js), it's object.ptr
FYI, object.a is used in physijs (a plugin for three.js : http://chandlerprall.github.com/Physijs/)
For testing, you can see this with a body :
[...]
var body = new Ammo.btRigidBody(rbInfo);
console.log(body.ptr);
console.log(body.a);
[...]
Another little problem : even if asm.js is not implemented yet in Chrome, Chrome for Android crash with ammo.asm.js (too large file ?).
Thanks :)
Stoomm.
http://stackoverflow.com/questions/20797266/build-error-ammo-js-by-emscripten-on-mac-osx
Dear All,
Hi, I have the problem to build ammo.js on Mac. ( OS is Maverick ). It doesn't compile C++ code and nothing in bindings.cpp code in /build folder.
I followed the procedure in this project page. Here is the 1st log I got.
==========================
Stage 1: Generate bindings
==========================
Preprocessing...
clang: error: language not recognized: '-x'
clang: error: no such file or directory: 'c'
clang: error: no such file or directory: 'c++'
clang: error: no input files
Cleaning...
Processing...
I know MacOSX includes clang compiler but emscripten guid forced to install llvm compiler from llvm repository. I wonder how I can fix it. Somebody said MacOsX has the issue to run emscripten. But I wonder it is right or not.
======UPDATE=====
I found 'cpp' called Apple's LLVM, not my own built LLVM in make.py file. In make.py file,
Old code
Popen(['cpp', '-x', 'c++', '-I../src', '../../root.h'], stdout=open('headers.pre.h', 'w')).communicate()
Changed code
Popen(['clang++', '-x', 'c++', '-I../src', '../../root.h' ], stdout=open('headers.pre.h', 'w')).communicate()
But still problem happens even I changed make.py. Error messages are below.
==========================
Stage 1: Generate bindings
==========================
Preprocessing...
In file included from ../../root.h:1:
In file included from ../../project/src/btBulletDynamicsCommon.h:20:
In file included from ../src/btBulletCollisionCommon.h:22:
In file included from ../src/BulletCollision/CollisionDispatch/btCollisionWorld.h:80:
In file included from ../src/LinearMath/btVector3.h:21:
../src/LinearMath/btScalar.h:26:10: fatal error: 'math.h' file not found
#include <math.h>
1 error generated.
Cleaning...
Processing...
I wonder how I can fix it.
Check out these demos:
https://github.com/schteppe/ammo.js-demos
Updating to the latest ammo.js build (versus the build currently checked into that repo) causes performance to improve significantly but exhibits a number of breakages:
I need to modify ammo.js because it lacks an ActionInterface implementation to customize with customizeVTable. Before doing that, I built the library as-is myself and tried it out. It didn't work.
This is the command I used to build ammo: ./make.py -O0
. I've uploaded the (gzipped) result here. Here's the test case that fails:
#!/usr/bin/env node
var Ammo = require("./builds/ammo");
var shape = new Ammo.btCapsuleShape(1, 2);
var motionState = new Ammo.btDefaultMotionState();
var bodyCI = new Ammo.btRigidBodyConstructionInfo(0, motionState, shape);
var body = new Ammo.btRigidBody(bodyCI);
To be specific, the last line produces an hell of a stack trace.
To make this work, I added the following line to builds/ammo.js
: module.exports = this.Ammo;
. This test case fails not only in node, but also in (at least) Google Chrome 18.0.1025.168 m.
Thing is, the ammo.js
that I checked out works perfectly. Here's a jsfiddle with the working ammo.js and here with the broken one.
Some details about my build environment:
Debian Squeeze, I've tried an apt-get update
followed by an apt-get upgrade
before executing the make.py
uname -sr
says Linux 2.6.32-5-686
gcc --version
says gcc (Debian 4.4.5-8) 4.4.5
~/devel/llvm/build/Debug/bin/clang --version
says
clang version 3.0 (tags/RELEASE_30/final 155985)
Target: i386-pc-linux-gnu
Thread model: posix
node --version
says v0.6.12
python --version
says Python 2.6.6
git rev-parse HEAD
in the emscripten directory says a6148681a26f3d41950c8f93a3f25f3ed7c76cd8
, which should be the current master
git rev-parse HEAD
in the ammo.js directory says 36200f52b3383deba7f3a4d7f57ac5870d0e1895
, which should also be the current master
Finally, here's my ~/.emscripten
.
This lets you run individual parts of the make process individually and provides closure() and wrap() parts.
It's just a suggestion!
I put it into my https://github.com/Philius/libbullet.ll.tar.bz2-- repo as there doesn't seem to be a way to mark a patch as a code block.
The demo is not working - neither in the web link on the main page, nor in the main download.
Error message (for the online demo):
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Utility.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Math.js
..... and many more.
I am using Google Chrome 31.0
Hi!
I would love to see btKinematicCharacterController being part of ammo.js. Since many create games out there, including me, this would be a blast to have. Are there any plans on implementing it, and if not, will there be? ^^
Thanks in advance,
Kind regards,
Roman
An example of using btSweepAxis3:
var maxProxies = 16384;
var aabbmin = new btVector3(-1000,-1000,-1000); // world size
var aabbmax = new btVector3(1000,1000,1000);
var overlappingPairCache = new btAxisSweep3(aabbmin, aabbmax, maxProxies);
vs.
overlappingPairCache = new btDbvtBroadphase();
results in the following:
Y[v[v[c] + 2]] is not a function @ ammo.js:255
which occurs during a call to:
dynamicsWorld.addRigidBody(body);
I just tried to instantiate a character controller via Ammo and it seems that btKinematicCharacterController is not currently exposed (Ammo.btKinematicCharacterController is undefined).
AllHitsRayResultCallback
has arrays of collision objects, and hit points/normals, instead of the single values like ClosestRayResultCallback
.
It seems like they are missing in Ammo.js and you just get access to the values inherited from RayResultCallback
.
Missing values:
m_collisionObjects
m_hitPointWorld
m_hitNormalWorld
m_hitFractions
Ammo.js seems to be the most versatile javascript physics engine out there, but the 1.8 mb file size is unacceptable for most web projects. Are there any plans to try to make the library any more compact?
I should not modify an object after passing a pointer as argument,but I can reuse object to avoid Garbage Collection if passing a value(mybe Object or Array) as argument
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.