BlueGit

timfa frameworkv3

Merge branch 'master' of https://gitlab.com/Timfa/frameworkv3

timfa wsadhelios · pushed by timfa

Authored 2022-10-18 · 4 years ago

Hash
90c1b77f0e49b87fc70d9442a489a05a55f436ca
4 files changed +19 −11
framework/engine/objectComponents/collider.js +2 −2
@@ -59,9 +59,9 @@ class Collider
59 59 var hw = this.gameObject.transform.size.x / 2;
60 60 var hh = this.gameObject.transform.size.y / 2;
61 61
62 if(point.x > this.transform.position.x - hw && point.x < this.transform.position.x + hw)
62 if(point.x > this.gameObject.transform.position.x - hw && point.x < this.gameObject.transform.position.x + hw)
63 63 {
64 if(point.y > this.transform.position.y - hh && point.y < this.transform.position.y + hh)
64 if(point.y > this.gameObject.transform.position.y - hh && point.y < this.gameObject.transform.position.y + hh)
65 65 {
66 66 return true;
67 67 }
@@ -59,9 +59,9 @@ class Collider
59 var hw = this.gameObject.transform.size.x / 2;
59 var hw = this.gameObject.transform.size.x / 2;
60 var hh = this.gameObject.transform.size.y / 2;
60 var hh = this.gameObject.transform.size.y / 2;
61
61
62 if(point.x > this.transform.position.x - hw && point.x < this.transform.position.x + hw)
62 if(point.x > this.gameObject.transform.position.x - hw && point.x < this.gameObject.transform.position.x + hw)
63 {
63 {
64 if(point.y > this.transform.position.y - hh && point.y < this.transform.position.y + hh)
64 if(point.y > this.gameObject.transform.position.y - hh && point.y < this.gameObject.transform.position.y + hh)
65 {
65 {
66 return true;
66 return true;
67 }
67 }
framework/extensions/extentions.js +8 −0
@@ -16,6 +16,14 @@ Array.prototype.remove = function(element)
16 16 }
17 17 }
18 18
19 Array.prototype.removeAt = function(index)
20 {
21 if (index > -1)
22 {
23 this.splice(index, 1);
24 }
25 }
26
19 27 Array.prototype.contains = function(element)
20 28 {
21 29 var index = this.indexOf(element);
@@ -16,6 +16,14 @@ Array.prototype.remove = function(element)
16 }
16 }
17}
17}
18
18
19Array.prototype.removeAt = function(index)
20{
21 if (index > -1)
22 {
23 this.splice(index, 1);
24 }
25}
26
19Array.prototype.contains = function(element)
27Array.prototype.contains = function(element)
20{
28{
21 var index = this.indexOf(element);
29 var index = this.indexOf(element);
framework/util/ray.js +4 −4
@@ -20,14 +20,14 @@ class Ray
20 20 new vector(scene.activeObjects[i].transform.position.x + hw, scene.activeObjects[i].transform.position.y + hh)
21 21 ]
22 22
23 //drop longest vector as this will be hidden by other faces
24 23 let points = pointsUnsort.sort((p1,p2) => p1.subtract(origin).length - p2.subtract(origin).length).pop();
25 24
26 for(let p = 0; o < points.length; p++)
25 for(let p = 0; p < points.length; p++)
27 26 {
28 let point = points[p].subtract(origin);
27 let point = points[p];
28 let deltaDistance = point.subtract(origin).length;
29 29
30 let stretched = direction.stretch(Math.min(point.length, maxLength >= 0? maxLength : point.length))
30 let stretched = direction.stretch(Math.min(deltaDistance, maxLength > 0? maxLength : deltaDistance))
31 31
32 32 let calcPoint = origin.add(stretched);
33 33
@@ -20,14 +20,14 @@ class Ray
20 new vector(scene.activeObjects[i].transform.position.x + hw, scene.activeObjects[i].transform.position.y + hh)
20 new vector(scene.activeObjects[i].transform.position.x + hw, scene.activeObjects[i].transform.position.y + hh)
21 ]
21 ]
22
22
23 //drop longest vector as this will be hidden by other faces
24 let points = pointsUnsort.sort((p1,p2) => p1.subtract(origin).length - p2.subtract(origin).length).pop();
23 let points = pointsUnsort.sort((p1,p2) => p1.subtract(origin).length - p2.subtract(origin).length).pop();
25
24
26 for(let p = 0; o < points.length; p++)
25 for(let p = 0; p < points.length; p++)
27 {
26 {
28 let point = points[p].subtract(origin);
27 let point = points[p];
28 let deltaDistance = point.subtract(origin).length;
29
29
30 let stretched = direction.stretch(Math.min(point.length, maxLength >= 0? maxLength : point.length))
30 let stretched = direction.stretch(Math.min(deltaDistance, maxLength > 0? maxLength : deltaDistance))
31
31
32 let calcPoint = origin.add(stretched);
32 let calcPoint = origin.add(stretched);
33
33
framework/util/vector.js +5 −5
@@ -12,10 +12,10 @@ class vector
12 12
13 13 get length()
14 14 {
15 return this.length();
15 return Math.sqrt((this.x * this.x) + (this.y * this.y));
16 16 }
17 17
18 length()
18 getLength()
19 19 {
20 20 return Math.sqrt((this.x * this.x) + (this.y * this.y));
21 21 }
@@ -31,9 +31,9 @@ class vector
31 31 {
32 32 var newVector = this.getCopy();
33 33
34 if(newVector.length() != 0)
34 if(newVector.length != 0)
35 35 {
36 var length = newVector.length();
36 var length = newVector.length;
37 37 newVector.x /= length;
38 38 newVector.y /= length;
39 39 }
@@ -55,7 +55,7 @@ class vector
55 55 var dX = this.x - otherVector.x;
56 56 var dY = this.y - otherVector.y;
57 57
58 return new vector(dX, dY).length();
58 return new vector(dX, dY).length;
59 59 }
60 60
61 61
@@ -12,10 +12,10 @@ class vector
12
12
13 get length()
13 get length()
14 {
14 {
15 return this.length();
15 return Math.sqrt((this.x * this.x) + (this.y * this.y));
16 }
16 }
17
17
18 length()
18 getLength()
19 {
19 {
20 return Math.sqrt((this.x * this.x) + (this.y * this.y));
20 return Math.sqrt((this.x * this.x) + (this.y * this.y));
21 }
21 }
@@ -31,9 +31,9 @@ class vector
31 {
31 {
32 var newVector = this.getCopy();
32 var newVector = this.getCopy();
33
33
34 if(newVector.length() != 0)
34 if(newVector.length != 0)
35 {
35 {
36 var length = newVector.length();
36 var length = newVector.length;
37 newVector.x /= length;
37 newVector.x /= length;
38 newVector.y /= length;
38 newVector.y /= length;
39 }
39 }
@@ -55,7 +55,7 @@ class vector
55 var dX = this.x - otherVector.x;
55 var dX = this.x - otherVector.x;
56 var dY = this.y - otherVector.y;
56 var dY = this.y - otherVector.y;
57
57
58 return new vector(dX, dY).length();
58 return new vector(dX, dY).length;
59 }
59 }
60
60
61
61