Comments (9)
Hi @oleksiikiselov,
So are you saying that you are able to render complex shapes using SVG - however, you also need to attach these complex shapes to a physics body so that you can perform physics simulations with MatterJS?
Have your tried creating a composite body using multiple shapes and constraints?
The Matter.Bodies.fromVertices
method looks really promising though - it might be worth debugging to sort out the issues you are having. Just from the notes on the MatterJS docs it seems like you need to have an additional package installed:
Creates a body using the supplied vertices (or an array containing multiple sets of vertices). If the vertices are convex, they will pass through as supplied. Otherwise if the vertices are concave, they will be decomposed if poly-decomp.js is available. Note that this process is not guaranteed to support complex sets of vertices (e.g. those with holes may fail). By default the decomposition will discard collinear edges (to improve performance). It can also optionally discard any parts that have an area less than minimumArea. If the vertices can not be decomposed, the result will fall back to using the convex hull. The options parameter is an object that specifies any Matter.Body properties you wish to override the defaults. See the properties section of the Matter.Body module for detailed information on what you can pass via the options object.
from react-native-game-engine.
Hi @bberak,
Thank you for the response. I think creating composite body might be too hard because the shape we need is too complex, but I will try to sort out the issues with SVG. The main issue is that according to MatterJS
example I have to parse SVG and get paths from it and we don't have anything like DOMParser
in react-native
. Because of that it requires to install some additional libraries and unfortunately mostly all of them do not work as expected, so the only reliable choice I found is JSDOM
which is kind of large.
from react-native-game-engine.
Hi @oleksiikiselov,
Are you able to process the SVGs ahead of time to get their vertices rather than parsing them in real-time? This would allow you to use JSDOM or other tools to get the vertices during development, save the vertices alongside the SVGs and then reference the vertices when required during runtime. This should hopefully prevent you from having to load and use heavy tools whilst the actual app is running..
from react-native-game-engine.
Hi @bberak,
Yes, I was thinking about that, have to make sure that I will be able to do animations with that approach in the future, but I plan to try that for sure. Thank you.
from react-native-game-engine.
No worries @oleksiikiselov - sounds like an interesting project. Let me know how it goes..
from react-native-game-engine.
Probably itโs kind of necroposting, but @oleksiikiselov did you succeed in this issue?
I developing a simple mobile shooter, and had low FPS issue with MatterJS bodies of simple shapes (as I assume mainly because of its collision detection system), so Iโm just curious,how fast was it in your case?
PS. Also previously I tried iOS native development using swift and this issue about low FPS with collision handling for complex shapes is even documented there in swift.
from react-native-game-engine.
Hey @gokadi,
What happens to the performance of your game if you turn off / remove MatterJS collisions completely? Does the FPS improve? I suspect the low FPS is most likely due to the number of entities you are rendering at one time - but it might be useful to isolate the issue..
PS. Also previously I tried iOS native development using swift and this issue about low FPS with collision handling for complex shapes is even documented there in swift.
Interesting.. Could you point me to this documentation by any chance?
Cheers,
Boris
from react-native-game-engine.
Hi!
What happens to the performance of your game if you turn off / remove MatterJS collisions completely? Does the FPS improve?
Yesterday I removed Matter from the project completely, and, well, fps slightly improved, but very slightly.
Interesting.. Could you point me to this documentation by any chance?
Well, it's not bluntly stated here, but still...
Use Edge-Based Physics Bodies Only When Needed
An edge-based body is more expensive to compute than a volume-based body.
I think I faced several similar issue when I tried to do it, but unfortunately no links are saved from that time. Collision there was between very complex edge-based sprite and simple rectangular bullet. When collision started, fps dropped to almost 0. That's why I guess it's something related to this functionality on the "native" level. Too many computations are needed for very complex shaped, I guess.
from react-native-game-engine.
Thanks for the link @gokadi.
Hopefully you can get away with very simple compound bodies for your bullet hell game. However, as I mentioned in the other thread, the bottleneck for you will probably be the large number of dynamic sprites and particles that will be moving on the screen (plus I'm sure the physics calculations for this on the JS thread will be relatively slow).
from react-native-game-engine.
Related Issues (20)
- Touch array is empty in iOS HOT 1
- Functions not in TypeScript definition files HOT 8
- How can i catch in Entity onPress event and value on System.js HOT 3
- Custom fonts used inside GameEngine not working
- Default timer doesn't stop when calling `.stop()` HOT 3
- Nested entity property change doesn't trigger rerender process HOT 3
- How to use TouchEvent for continious handelrs? HOT 1
- Systems functions
- FPS issues HOT 9
- Add animation for moving HOT 10
- Best Way to handle touch as directional control HOT 3
- Support for Expo SDK 43, 44, 45 HOT 7
- Cant handle multitouch operations and it is really slow HOT 4
- How to change Game Engine's coordinate ?
- Tilemap free pan
- while dragging create line like WordSearch game
- What type of game can i build???
- is there anyone who is maintaining this library yet? HOT 2
- GameEngine re-rendering on entities change HOT 3
- Types not importing; not a real fix, but raising the issue HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-game-engine.