rails-physics 1.3.4 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +5 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -17,10 +17,6 @@ export const Rails = {
|
|
|
17
17
|
base.before("Body.update", function(body) {
|
|
18
18
|
Rails.Body.alignRailBody(body);
|
|
19
19
|
});
|
|
20
|
-
|
|
21
|
-
base.after("Body.update", function(body) {
|
|
22
|
-
Rails.Body.prepareRailBody(body);
|
|
23
|
-
});
|
|
24
20
|
},
|
|
25
21
|
|
|
26
22
|
Body: {
|
|
@@ -33,20 +29,22 @@ export const Rails = {
|
|
|
33
29
|
let slide_axis = body.plugin.slide_axis;
|
|
34
30
|
body.plugin.centre_finder = new SegmentTree(body, body.plugin.rails_granularity, transverse_axis, slide_axis);
|
|
35
31
|
body.plugin.old_offset_multiplier = body.plugin.centre_finder.centreOfMass();
|
|
36
|
-
|
|
37
32
|
body.plugin.test_start = (1 << 16) - 1;
|
|
38
33
|
}
|
|
39
34
|
},
|
|
40
35
|
|
|
41
36
|
alignRailBody: function(body) {
|
|
42
37
|
if(body.plugin.centre_finder !== undefined) {
|
|
38
|
+
let transverse_axis = body.plugin.transverse_axis;
|
|
39
|
+
let slide_axis = body.plugin.slide_axis;
|
|
40
|
+
body.plugin.centre_finder.update(body.plugin.test_start, (1 << 16), 0.001);
|
|
41
|
+
body.plugin.test_start = Math.max(body.plugin.test_start - 1, 0);
|
|
43
42
|
let upcoming_offset_multiplier = body.plugin.centre_finder.centreOfMass();
|
|
44
43
|
let old_offset = mapToRail(body.plugin.old_offset_multiplier, transverse_axis, slide_axis);
|
|
45
44
|
let upcoming_offset = mapToRail(upcoming_offset_multiplier, transverse_axis, slide_axis);
|
|
46
45
|
Matter.Body.setCentre(body, Matter.Vector.add(Matter.Vector.sub(body.position, old_offset, Matter.Vector.create()), upcoming_offset, Matter.Vector.create()));
|
|
47
46
|
body.plugin.old_offset_multiplier = upcoming_offset_multiplier;
|
|
48
|
-
|
|
49
|
-
body.plugin.test_start = Math.max(body.plugin.test_start - 1, 0);
|
|
47
|
+
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rails-physics",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"description": "A plugin for the matter-js physics library designed to efficiently simulate objects moving in a one-dimensional space whose projection onto the 2-dimensional space of the screen changes over time",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|