matterjs

Scaling canvas size - Matter.js

妖精的绣舞 提交于 2020-03-05 06:04:39
问题 As per attached image, I'm trying to remove the section that extends beyond the lower horizontal wall scribbled in green. I'm new to matter.js and have issues with the canvas width and height. I've tried several ways but still to no avail. I don't quite grasp how the engine scales and renders itself. It will also get blurry depends on the width and height I set. How can I adjust the canvas correctly to fit the world ? I'm using this mixed shapes example from matter.js demo. //Fetch our canvas

Bouncing ball code causes jitter in HTML5 canvas

…衆ロ難τιáo~ 提交于 2020-03-05 04:39:33
问题 I have a HTML Canvas on my website that I use to contain balls that drop into the canvas, they bounce around and have a real good time settling down at the bottom in a range of ways. I was under the impression this was working perfectly. However, it has now been brought to my attention these balls jitter and freak out on other people's computers. I checked the browser they are using and it is the same as mine (Chrome V79). So just to clarify - I have never had it bug on my computer but it

Bouncing ball code causes jitter in HTML5 canvas

本小妞迷上赌 提交于 2020-03-05 04:37:28
问题 I have a HTML Canvas on my website that I use to contain balls that drop into the canvas, they bounce around and have a real good time settling down at the bottom in a range of ways. I was under the impression this was working perfectly. However, it has now been brought to my attention these balls jitter and freak out on other people's computers. I checked the browser they are using and it is the same as mine (Chrome V79). So just to clarify - I have never had it bug on my computer but it

Prevent force-dragging bodies through other bodies with MatterJS

自古美人都是妖i 提交于 2020-01-21 01:31:31
问题 I'm using MatterJs for a physics based game and have not found a solution for the problem of preventing bodies being force-dragged by the mouse through other bodies. If you drag a body into another body, the body being dragged can force itself into and through the other body. I'm looking for a reliable way to prevent them from intersecting. You can observe this effect in any MatterJS demo by selecting a body with the mouse, and trying to force it through another body. Here is a typical

how to prevent [circle] body from sliding into 0px gaps between static bodies

点点圈 提交于 2020-01-02 13:18:30
问题 So I have this body that is a circle collider and it has sometimes a big velocity the problem is that the tiled map of the boundaries is made of small tiles and at high velocity the body goes through it here is my config of all bodies: const config = { inertia: Infinity, // do not spin friction: 0, // X*100% stop on hit frictionAir: 0, // X*100% slow on move restitution: 0.5, // bounce X*100% on hit collisionFilter: this.level.getCollisionFilter(), // default collision filter isStatic } ...

2D soft bodies: Gelly and moldable?

狂风中的少年 提交于 2019-12-10 12:31:25
问题 I am using Matter.js physics in an attempt to create soft bodies. I was able to create a body like this: However I am not sure if this is the "soft body" I want. It is true that this body is not entirely rigid and has that bouncy feel when it collides and gets dragged. I was looking for a body that shares similarities with a gelly. This image might visually help explaining the concept: I was wondering how these type of bodies can be made. Is it the same as the as matter.js soft body but with

Import matter-js in typescript project

纵饮孤独 提交于 2019-12-10 09:35:36
问题 I found this file : https://www.npmjs.com/package/@types/matter-js i execute this line : npm install --save @types/matter-js In root ts file i got error message : 'Matter' refers to a UMD global, but the current file is a module. Consider adding an import instead. Code looks like : ///<reference path="matter-js.d.ts"/> import Ioc from "./libs/ioc"; let master = new Ioc(); console.log(master); console.log(Matter); Error in browser: app.ts:11 Uncaught ReferenceError: Matter is not defined Did i

JavaScript, Matter.js: Disable collision for one body

倾然丶 夕夏残阳落幕 提交于 2019-12-06 02:20:12
问题 As already mentioned in the title, I am looking for a way, to disable every collision of a body in Matter.js. It should still be linkable with Constraints, and there should be the possibility of enabling the collision again after some time. Is there a way to do this? The hard thing about it, is that the object should not collide with any other object, but all the other objects should collide with each other. 回答1: You can use collision filters to do this. You can see an example of them working

Import matter-js in typescript project

梦想与她 提交于 2019-12-05 14:33:05
I found this file : https://www.npmjs.com/package/@types/matter-js i execute this line : npm install --save @types/matter-js In root ts file i got error message : 'Matter' refers to a UMD global, but the current file is a module. Consider adding an import instead. Code looks like : ///<reference path="matter-js.d.ts"/> import Ioc from "./libs/ioc"; let master = new Ioc(); console.log(master); console.log(Matter); Error in browser: app.ts:11 Uncaught ReferenceError: Matter is not defined Did i need to load matter-js.js lib ? If i put : import matter from 'matter-js' i get : Module ''matter-js''