keystonemc 1.0.1 → 1.1.0
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/dist/core/index.d.ts +1 -0
- package/dist/core/math/axisAlignedBB.d.ts +114 -0
- package/dist/core/math/vector3.d.ts +60 -30
- package/dist/index.js +249 -31
- package/package.json +1 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { keystone } from './keystone';
|
|
2
2
|
export { Vector3 } from './math/vector3';
|
|
3
|
+
export { AxisAlignedBB } from './math/axisAlignedBB';
|
|
3
4
|
export { Priority } from './event/priority';
|
|
4
5
|
export { EventManager } from './event/eventManager';
|
|
5
6
|
export { debug } from './utils/debugger';
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { AABB, Vector3 } from '@minecraft/server';
|
|
2
|
+
export declare class AxisAlignedBB implements AABB {
|
|
3
|
+
center: Vector3;
|
|
4
|
+
extent: Vector3;
|
|
5
|
+
constructor(center: Vector3, extent: Vector3);
|
|
6
|
+
/**
|
|
7
|
+
* 最小点最大点からオブジェクト化
|
|
8
|
+
* @param min
|
|
9
|
+
* @param max
|
|
10
|
+
* @returns {AxisAlignedBB}
|
|
11
|
+
*/
|
|
12
|
+
static fromMinMax(min: Vector3, max: Vector3): AxisAlignedBB;
|
|
13
|
+
/**
|
|
14
|
+
* 大きさ1のAABB生成
|
|
15
|
+
* @returns {AxisAlignedBB}
|
|
16
|
+
*/
|
|
17
|
+
static one(): AxisAlignedBB;
|
|
18
|
+
/**
|
|
19
|
+
* {center, extent} オブジェクトから生成
|
|
20
|
+
* @param aabb
|
|
21
|
+
* @returns {AxisAlignedBB}
|
|
22
|
+
*/
|
|
23
|
+
static fromBDS(aabb: AABB): AxisAlignedBB;
|
|
24
|
+
/**
|
|
25
|
+
* 最小点
|
|
26
|
+
* @returns {Vector3}
|
|
27
|
+
*/
|
|
28
|
+
get min(): Vector3;
|
|
29
|
+
/**
|
|
30
|
+
* 最大点
|
|
31
|
+
* @returns {Vector3}
|
|
32
|
+
*/
|
|
33
|
+
get max(): Vector3;
|
|
34
|
+
/**
|
|
35
|
+
* オフセット
|
|
36
|
+
* @param dx
|
|
37
|
+
* @param dy
|
|
38
|
+
* @param dz
|
|
39
|
+
* @returns {AxisAlignedBB}
|
|
40
|
+
*/
|
|
41
|
+
offset(dx: number, dy: number, dz: number): AxisAlignedBB;
|
|
42
|
+
/**
|
|
43
|
+
* 拡大
|
|
44
|
+
* @param dx
|
|
45
|
+
* @param dy
|
|
46
|
+
* @param dz
|
|
47
|
+
* @returns {AxisAlignedBB}
|
|
48
|
+
*/
|
|
49
|
+
expand(dx: number, dy: number, dz: number): AxisAlignedBB;
|
|
50
|
+
/**
|
|
51
|
+
* 縮小
|
|
52
|
+
* @param dx
|
|
53
|
+
* @param dy
|
|
54
|
+
* @param dz
|
|
55
|
+
* @returns {AxisAlignedBB}
|
|
56
|
+
*/
|
|
57
|
+
contract(dx: number, dy: number, dz: number): AxisAlignedBB;
|
|
58
|
+
/**
|
|
59
|
+
* 接触判定
|
|
60
|
+
* @param other
|
|
61
|
+
* @param epsilon
|
|
62
|
+
* @returns {boolean}
|
|
63
|
+
*/
|
|
64
|
+
intersects(other: AxisAlignedBB, epsilon?: number): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* 対象座標が内包されているか
|
|
67
|
+
* @param v
|
|
68
|
+
* @returns {boolean}
|
|
69
|
+
*/
|
|
70
|
+
contains(v: Vector3): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Xの長さ
|
|
73
|
+
* @returns {number}
|
|
74
|
+
*/
|
|
75
|
+
getXLength(): number;
|
|
76
|
+
/**
|
|
77
|
+
* Yの長さ
|
|
78
|
+
* @returns {number}
|
|
79
|
+
*/
|
|
80
|
+
getYLength(): number;
|
|
81
|
+
/**
|
|
82
|
+
* Zの長さ
|
|
83
|
+
* @returns {number}
|
|
84
|
+
*/
|
|
85
|
+
getZLength(): number;
|
|
86
|
+
/**
|
|
87
|
+
* 体積
|
|
88
|
+
* @returns {number}
|
|
89
|
+
*/
|
|
90
|
+
getVolume(): number;
|
|
91
|
+
/**
|
|
92
|
+
* キューブ判定
|
|
93
|
+
* @param epsilon
|
|
94
|
+
* @returns {boolean}
|
|
95
|
+
*/
|
|
96
|
+
isCube(epsilon?: number): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* BDS ScriptAPIで使える {center, extent} 形式に変換
|
|
99
|
+
* @returns {AABB}
|
|
100
|
+
*/
|
|
101
|
+
toBDS(): AABB;
|
|
102
|
+
/**
|
|
103
|
+
* オブジェクトに変換
|
|
104
|
+
*/
|
|
105
|
+
toObject(): {
|
|
106
|
+
center: Vector3;
|
|
107
|
+
extent: Vector3;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* toString
|
|
111
|
+
* @returns {string}
|
|
112
|
+
*/
|
|
113
|
+
toString(): string;
|
|
114
|
+
}
|
|
@@ -11,53 +11,77 @@ export declare class Vector3 {
|
|
|
11
11
|
static zero(): Vector3;
|
|
12
12
|
/**
|
|
13
13
|
* {x, y, z} オブジェクトから生成
|
|
14
|
-
* @param
|
|
15
|
-
* @returns
|
|
14
|
+
* @param pos
|
|
15
|
+
* @returns {Vector3}
|
|
16
16
|
*/
|
|
17
17
|
static fromBDS(pos: _Vector3): Vector3;
|
|
18
|
+
/**
|
|
19
|
+
* x
|
|
20
|
+
* @returns {number}
|
|
21
|
+
*/
|
|
18
22
|
getX(): number;
|
|
23
|
+
/**
|
|
24
|
+
* y
|
|
25
|
+
* @returns {number}
|
|
26
|
+
*/
|
|
19
27
|
getY(): number;
|
|
28
|
+
/**
|
|
29
|
+
* z
|
|
30
|
+
* @returns {number}
|
|
31
|
+
*/
|
|
20
32
|
getZ(): number;
|
|
33
|
+
/**
|
|
34
|
+
* x (整数値)
|
|
35
|
+
* @returns {number}
|
|
36
|
+
*/
|
|
21
37
|
getFloorX(): number;
|
|
38
|
+
/**
|
|
39
|
+
* y (整数値)
|
|
40
|
+
* @returns {number}
|
|
41
|
+
*/
|
|
22
42
|
getFloorY(): number;
|
|
43
|
+
/**
|
|
44
|
+
* z (整数値)
|
|
45
|
+
* @returns {number}
|
|
46
|
+
*/
|
|
23
47
|
getFloorZ(): number;
|
|
24
48
|
/**
|
|
25
49
|
* 加算
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
50
|
+
* @param x
|
|
51
|
+
* @param y
|
|
52
|
+
* @param z
|
|
29
53
|
* @return {Vector3}
|
|
30
54
|
*/
|
|
31
55
|
add(x: number, y: number, z: number): Vector3;
|
|
32
56
|
/**
|
|
33
57
|
* ベクトル単位での加算
|
|
34
|
-
* @param
|
|
58
|
+
* @param v
|
|
35
59
|
* @returns {Vector3}
|
|
36
60
|
*/
|
|
37
61
|
addVector(v: _Vector3): Vector3;
|
|
38
62
|
/**
|
|
39
63
|
* 減算
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
64
|
+
* @param x
|
|
65
|
+
* @param y
|
|
66
|
+
* @param z
|
|
43
67
|
* @return {Vector3}
|
|
44
68
|
*/
|
|
45
69
|
subtract(x: number, y: number, z: number): Vector3;
|
|
46
70
|
/**
|
|
47
71
|
* ベクトル単位での減算
|
|
48
|
-
* @param
|
|
72
|
+
* @param v
|
|
49
73
|
* @return {Vector3}
|
|
50
74
|
*/
|
|
51
75
|
subtractVector(v: _Vector3): Vector3;
|
|
52
76
|
/**
|
|
53
77
|
* 乗算
|
|
54
|
-
* @param
|
|
78
|
+
* @param value
|
|
55
79
|
* @return {Vector3}
|
|
56
80
|
*/
|
|
57
81
|
multiply(value: number): Vector3;
|
|
58
82
|
/**
|
|
59
83
|
* 除算
|
|
60
|
-
* @param
|
|
84
|
+
* @param value
|
|
61
85
|
* @return {Vector3}
|
|
62
86
|
*/
|
|
63
87
|
divide(value: number): Vector3;
|
|
@@ -73,7 +97,7 @@ export declare class Vector3 {
|
|
|
73
97
|
floor(): Vector3;
|
|
74
98
|
/**
|
|
75
99
|
* ベクトルの内部数値小数点四捨五入
|
|
76
|
-
* @param
|
|
100
|
+
* @param precision
|
|
77
101
|
* @return {Vector3}
|
|
78
102
|
*/
|
|
79
103
|
round(precision?: number): Vector3;
|
|
@@ -84,31 +108,31 @@ export declare class Vector3 {
|
|
|
84
108
|
abs(): Vector3;
|
|
85
109
|
/**
|
|
86
110
|
* 指定した2点間のユークリッド距離
|
|
87
|
-
* @param
|
|
111
|
+
* @param pos
|
|
88
112
|
* @return {number}
|
|
89
113
|
*/
|
|
90
114
|
distance(pos: _Vector3): number;
|
|
91
115
|
/**
|
|
92
116
|
* 指定した2点間のユークリッド距離の2乗
|
|
93
|
-
* @param
|
|
117
|
+
* @param pos
|
|
94
118
|
* @return {number}
|
|
95
119
|
*/
|
|
96
120
|
distanceSquared(pos: _Vector3): number;
|
|
97
121
|
/**
|
|
98
122
|
* 内積
|
|
99
|
-
* @param
|
|
123
|
+
* @param pos
|
|
100
124
|
* @return {number}
|
|
101
125
|
*/
|
|
102
126
|
dot(pos: _Vector3): number;
|
|
103
127
|
/**
|
|
104
128
|
* 外積
|
|
105
|
-
* @param
|
|
129
|
+
* @param pos
|
|
106
130
|
* @return {Vector3}
|
|
107
131
|
*/
|
|
108
132
|
cross(pos: _Vector3): Vector3;
|
|
109
133
|
/**
|
|
110
134
|
* ベクトルの比較
|
|
111
|
-
* @param
|
|
135
|
+
* @param pos
|
|
112
136
|
* @return {boolean}
|
|
113
137
|
*/
|
|
114
138
|
equals(pos: _Vector3): boolean;
|
|
@@ -129,9 +153,9 @@ export declare class Vector3 {
|
|
|
129
153
|
normalize(): Vector3;
|
|
130
154
|
/**
|
|
131
155
|
* オブジェクトの数値指定再生成
|
|
132
|
-
* @param
|
|
133
|
-
* @param
|
|
134
|
-
* @param
|
|
156
|
+
* @param x
|
|
157
|
+
* @param y
|
|
158
|
+
* @param z
|
|
135
159
|
* @return {Vector3}
|
|
136
160
|
*/
|
|
137
161
|
withComponents(x?: number, y?: number, z?: number): Vector3;
|
|
@@ -139,21 +163,21 @@ export declare class Vector3 {
|
|
|
139
163
|
* X座標をxValueにしたとき線分上に存在する点を返す
|
|
140
164
|
* @param end 終点
|
|
141
165
|
* @param xValue 途中点のX値
|
|
142
|
-
* @returns {Vector3
|
|
166
|
+
* @returns {Vector3|undefined}
|
|
143
167
|
*/
|
|
144
168
|
getIntermediateWithXValue(end: Vector3, xValue: number): Vector3 | undefined;
|
|
145
169
|
/**
|
|
146
170
|
* Y座標をyValueにしたとき線分上に存在する点を返す
|
|
147
171
|
* @param end 終点
|
|
148
172
|
* @param yValue 途中点のY値
|
|
149
|
-
* @returns {Vector3
|
|
173
|
+
* @returns {Vector3|undefined}
|
|
150
174
|
*/
|
|
151
175
|
getIntermediateWithYValue(end: Vector3, yValue: number): Vector3 | undefined;
|
|
152
176
|
/**
|
|
153
177
|
* Z座標をzValueにしたとき線分上に存在する点を返す
|
|
154
178
|
* @param end 終点
|
|
155
179
|
* @param zValue 途中点のZ値
|
|
156
|
-
* @returns {Vector3
|
|
180
|
+
* @returns {Vector3|undefined}
|
|
157
181
|
*/
|
|
158
182
|
getIntermediateWithZValue(end: Vector3, zValue: number): Vector3 | undefined;
|
|
159
183
|
/**
|
|
@@ -161,30 +185,36 @@ export declare class Vector3 {
|
|
|
161
185
|
* @returns {_Vector3}
|
|
162
186
|
*/
|
|
163
187
|
toBDS(): _Vector3;
|
|
164
|
-
/**
|
|
188
|
+
/**
|
|
189
|
+
* オブジェクトに変換
|
|
190
|
+
*/
|
|
165
191
|
toObject(): {
|
|
166
192
|
x: number;
|
|
167
193
|
y: number;
|
|
168
194
|
z: number;
|
|
169
195
|
};
|
|
196
|
+
/**
|
|
197
|
+
* toString
|
|
198
|
+
* @returns {string}
|
|
199
|
+
*/
|
|
170
200
|
toString(): string;
|
|
171
201
|
/**
|
|
172
202
|
* 最大点
|
|
173
|
-
* @param
|
|
174
|
-
* @param
|
|
203
|
+
* @param vector
|
|
204
|
+
* @param vectors
|
|
175
205
|
* @returns {Vector3}
|
|
176
206
|
*/
|
|
177
207
|
static maxComponents(vector: _Vector3, ...vectors: _Vector3[]): Vector3;
|
|
178
208
|
/**
|
|
179
209
|
* 最小点
|
|
180
|
-
* @param
|
|
181
|
-
* @param
|
|
210
|
+
* @param vector
|
|
211
|
+
* @param vectors
|
|
182
212
|
* @returns {Vector3}
|
|
183
213
|
*/
|
|
184
214
|
static minComponents(vector: _Vector3, ...vectors: _Vector3[]): Vector3;
|
|
185
215
|
/**
|
|
186
216
|
* 合計
|
|
187
|
-
* @param
|
|
217
|
+
* @param vectors
|
|
188
218
|
* @returns {Vector3}
|
|
189
219
|
*/
|
|
190
220
|
static sum(...vectors: {
|
package/dist/index.js
CHANGED
|
@@ -19,36 +19,59 @@ class Vector3 {
|
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* {x, y, z} オブジェクトから生成
|
|
22
|
-
* @param
|
|
23
|
-
* @returns
|
|
22
|
+
* @param pos
|
|
23
|
+
* @returns {Vector3}
|
|
24
24
|
*/
|
|
25
25
|
static fromBDS(pos) {
|
|
26
26
|
return new Vector3(pos.x, pos.y, pos.z);
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* x
|
|
30
|
+
* @returns {number}
|
|
31
|
+
*/
|
|
29
32
|
getX() {
|
|
30
33
|
return this.x;
|
|
31
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* y
|
|
37
|
+
* @returns {number}
|
|
38
|
+
*/
|
|
32
39
|
getY() {
|
|
33
40
|
return this.y;
|
|
34
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* z
|
|
44
|
+
* @returns {number}
|
|
45
|
+
*/
|
|
35
46
|
getZ() {
|
|
36
47
|
return this.z;
|
|
37
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* x (整数値)
|
|
51
|
+
* @returns {number}
|
|
52
|
+
*/
|
|
38
53
|
getFloorX() {
|
|
39
54
|
return Math.floor(this.x);
|
|
40
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* y (整数値)
|
|
58
|
+
* @returns {number}
|
|
59
|
+
*/
|
|
41
60
|
getFloorY() {
|
|
42
61
|
return Math.floor(this.y);
|
|
43
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* z (整数値)
|
|
65
|
+
* @returns {number}
|
|
66
|
+
*/
|
|
44
67
|
getFloorZ() {
|
|
45
68
|
return Math.floor(this.z);
|
|
46
69
|
}
|
|
47
70
|
/**
|
|
48
71
|
* 加算
|
|
49
|
-
* @param
|
|
50
|
-
* @param
|
|
51
|
-
* @param
|
|
72
|
+
* @param x
|
|
73
|
+
* @param y
|
|
74
|
+
* @param z
|
|
52
75
|
* @return {Vector3}
|
|
53
76
|
*/
|
|
54
77
|
add(x, y, z) {
|
|
@@ -60,7 +83,7 @@ class Vector3 {
|
|
|
60
83
|
}
|
|
61
84
|
/**
|
|
62
85
|
* ベクトル単位での加算
|
|
63
|
-
* @param
|
|
86
|
+
* @param v
|
|
64
87
|
* @returns {Vector3}
|
|
65
88
|
*/
|
|
66
89
|
addVector(v) {
|
|
@@ -68,9 +91,9 @@ class Vector3 {
|
|
|
68
91
|
}
|
|
69
92
|
/**
|
|
70
93
|
* 減算
|
|
71
|
-
* @param
|
|
72
|
-
* @param
|
|
73
|
-
* @param
|
|
94
|
+
* @param x
|
|
95
|
+
* @param y
|
|
96
|
+
* @param z
|
|
74
97
|
* @return {Vector3}
|
|
75
98
|
*/
|
|
76
99
|
subtract(x, y, z) {
|
|
@@ -78,7 +101,7 @@ class Vector3 {
|
|
|
78
101
|
}
|
|
79
102
|
/**
|
|
80
103
|
* ベクトル単位での減算
|
|
81
|
-
* @param
|
|
104
|
+
* @param v
|
|
82
105
|
* @return {Vector3}
|
|
83
106
|
*/
|
|
84
107
|
subtractVector(v) {
|
|
@@ -86,7 +109,7 @@ class Vector3 {
|
|
|
86
109
|
}
|
|
87
110
|
/**
|
|
88
111
|
* 乗算
|
|
89
|
-
* @param
|
|
112
|
+
* @param value
|
|
90
113
|
* @return {Vector3}
|
|
91
114
|
*/
|
|
92
115
|
multiply(value) {
|
|
@@ -98,7 +121,7 @@ class Vector3 {
|
|
|
98
121
|
}
|
|
99
122
|
/**
|
|
100
123
|
* 除算
|
|
101
|
-
* @param
|
|
124
|
+
* @param value
|
|
102
125
|
* @return {Vector3}
|
|
103
126
|
*/
|
|
104
127
|
divide(value) {
|
|
@@ -132,7 +155,7 @@ class Vector3 {
|
|
|
132
155
|
}
|
|
133
156
|
/**
|
|
134
157
|
* ベクトルの内部数値小数点四捨五入
|
|
135
|
-
* @param
|
|
158
|
+
* @param precision
|
|
136
159
|
* @return {Vector3}
|
|
137
160
|
*/
|
|
138
161
|
round(precision = 0) {
|
|
@@ -156,7 +179,7 @@ class Vector3 {
|
|
|
156
179
|
}
|
|
157
180
|
/**
|
|
158
181
|
* 指定した2点間のユークリッド距離
|
|
159
|
-
* @param
|
|
182
|
+
* @param pos
|
|
160
183
|
* @return {number}
|
|
161
184
|
*/
|
|
162
185
|
distance(pos) {
|
|
@@ -164,7 +187,7 @@ class Vector3 {
|
|
|
164
187
|
}
|
|
165
188
|
/**
|
|
166
189
|
* 指定した2点間のユークリッド距離の2乗
|
|
167
|
-
* @param
|
|
190
|
+
* @param pos
|
|
168
191
|
* @return {number}
|
|
169
192
|
*/
|
|
170
193
|
distanceSquared(pos) {
|
|
@@ -175,7 +198,7 @@ class Vector3 {
|
|
|
175
198
|
}
|
|
176
199
|
/**
|
|
177
200
|
* 内積
|
|
178
|
-
* @param
|
|
201
|
+
* @param pos
|
|
179
202
|
* @return {number}
|
|
180
203
|
*/
|
|
181
204
|
dot(pos) {
|
|
@@ -183,7 +206,7 @@ class Vector3 {
|
|
|
183
206
|
}
|
|
184
207
|
/**
|
|
185
208
|
* 外積
|
|
186
|
-
* @param
|
|
209
|
+
* @param pos
|
|
187
210
|
* @return {Vector3}
|
|
188
211
|
*/
|
|
189
212
|
cross(pos) {
|
|
@@ -195,7 +218,7 @@ class Vector3 {
|
|
|
195
218
|
}
|
|
196
219
|
/**
|
|
197
220
|
* ベクトルの比較
|
|
198
|
-
* @param
|
|
221
|
+
* @param pos
|
|
199
222
|
* @return {boolean}
|
|
200
223
|
*/
|
|
201
224
|
equals(pos) {
|
|
@@ -228,9 +251,9 @@ class Vector3 {
|
|
|
228
251
|
}
|
|
229
252
|
/**
|
|
230
253
|
* オブジェクトの数値指定再生成
|
|
231
|
-
* @param
|
|
232
|
-
* @param
|
|
233
|
-
* @param
|
|
254
|
+
* @param x
|
|
255
|
+
* @param y
|
|
256
|
+
* @param z
|
|
234
257
|
* @return {Vector3}
|
|
235
258
|
*/
|
|
236
259
|
withComponents(x, y, z) {
|
|
@@ -244,7 +267,7 @@ class Vector3 {
|
|
|
244
267
|
* X座標をxValueにしたとき線分上に存在する点を返す
|
|
245
268
|
* @param end 終点
|
|
246
269
|
* @param xValue 途中点のX値
|
|
247
|
-
* @returns {Vector3
|
|
270
|
+
* @returns {Vector3|undefined}
|
|
248
271
|
*/
|
|
249
272
|
getIntermediateWithXValue(end, xValue) {
|
|
250
273
|
const dx = end.x - this.x;
|
|
@@ -261,7 +284,7 @@ class Vector3 {
|
|
|
261
284
|
* Y座標をyValueにしたとき線分上に存在する点を返す
|
|
262
285
|
* @param end 終点
|
|
263
286
|
* @param yValue 途中点のY値
|
|
264
|
-
* @returns {Vector3
|
|
287
|
+
* @returns {Vector3|undefined}
|
|
265
288
|
*/
|
|
266
289
|
getIntermediateWithYValue(end, yValue) {
|
|
267
290
|
const dy = end.y - this.y;
|
|
@@ -278,7 +301,7 @@ class Vector3 {
|
|
|
278
301
|
* Z座標をzValueにしたとき線分上に存在する点を返す
|
|
279
302
|
* @param end 終点
|
|
280
303
|
* @param zValue 途中点のZ値
|
|
281
|
-
* @returns {Vector3
|
|
304
|
+
* @returns {Vector3|undefined}
|
|
282
305
|
*/
|
|
283
306
|
getIntermediateWithZValue(end, zValue) {
|
|
284
307
|
const dz = end.z - this.z;
|
|
@@ -298,17 +321,23 @@ class Vector3 {
|
|
|
298
321
|
toBDS() {
|
|
299
322
|
return { x: this.x, y: this.y, z: this.z };
|
|
300
323
|
}
|
|
301
|
-
/**
|
|
324
|
+
/**
|
|
325
|
+
* オブジェクトに変換
|
|
326
|
+
*/
|
|
302
327
|
toObject() {
|
|
303
328
|
return { x: this.x, y: this.y, z: this.z };
|
|
304
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* toString
|
|
332
|
+
* @returns {string}
|
|
333
|
+
*/
|
|
305
334
|
toString() {
|
|
306
335
|
return `_Vector3(x=${this.x}, y=${this.y}, z=${this.z})`;
|
|
307
336
|
}
|
|
308
337
|
/**
|
|
309
338
|
* 最大点
|
|
310
|
-
* @param
|
|
311
|
-
* @param
|
|
339
|
+
* @param vector
|
|
340
|
+
* @param vectors
|
|
312
341
|
* @returns {Vector3}
|
|
313
342
|
*/
|
|
314
343
|
static maxComponents(vector, ...vectors) {
|
|
@@ -324,8 +353,8 @@ class Vector3 {
|
|
|
324
353
|
}
|
|
325
354
|
/**
|
|
326
355
|
* 最小点
|
|
327
|
-
* @param
|
|
328
|
-
* @param
|
|
356
|
+
* @param vector
|
|
357
|
+
* @param vectors
|
|
329
358
|
* @returns {Vector3}
|
|
330
359
|
*/
|
|
331
360
|
static minComponents(vector, ...vectors) {
|
|
@@ -341,7 +370,7 @@ class Vector3 {
|
|
|
341
370
|
}
|
|
342
371
|
/**
|
|
343
372
|
* 合計
|
|
344
|
-
* @param
|
|
373
|
+
* @param vectors
|
|
345
374
|
* @returns {Vector3}
|
|
346
375
|
*/
|
|
347
376
|
static sum(...vectors) {
|
|
@@ -354,6 +383,194 @@ class Vector3 {
|
|
|
354
383
|
return new Vector3(x, y, z);
|
|
355
384
|
}
|
|
356
385
|
}
|
|
386
|
+
class AxisAlignedBB {
|
|
387
|
+
constructor(center, extent) {
|
|
388
|
+
this.center = center;
|
|
389
|
+
this.extent = extent;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* 最小点最大点からオブジェクト化
|
|
393
|
+
* @param min
|
|
394
|
+
* @param max
|
|
395
|
+
* @returns {AxisAlignedBB}
|
|
396
|
+
*/
|
|
397
|
+
static fromMinMax(min, max) {
|
|
398
|
+
return new AxisAlignedBB(
|
|
399
|
+
{
|
|
400
|
+
x: (min.x + max.x) / 2,
|
|
401
|
+
y: (min.y + max.y) / 2,
|
|
402
|
+
z: (min.z + max.z) / 2
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
x: (max.x - min.x) / 2,
|
|
406
|
+
y: (max.y - min.y) / 2,
|
|
407
|
+
z: (max.z - min.z) / 2
|
|
408
|
+
}
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* 大きさ1のAABB生成
|
|
413
|
+
* @returns {AxisAlignedBB}
|
|
414
|
+
*/
|
|
415
|
+
static one() {
|
|
416
|
+
return AxisAlignedBB.fromMinMax(
|
|
417
|
+
{ x: 0, y: 0, z: 0 },
|
|
418
|
+
{ x: 1, y: 1, z: 1 }
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* {center, extent} オブジェクトから生成
|
|
423
|
+
* @param aabb
|
|
424
|
+
* @returns {AxisAlignedBB}
|
|
425
|
+
*/
|
|
426
|
+
static fromBDS(aabb) {
|
|
427
|
+
return new AxisAlignedBB(aabb.center, aabb.extent);
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* 最小点
|
|
431
|
+
* @returns {Vector3}
|
|
432
|
+
*/
|
|
433
|
+
get min() {
|
|
434
|
+
return {
|
|
435
|
+
x: this.center.x - this.extent.x,
|
|
436
|
+
y: this.center.y - this.extent.y,
|
|
437
|
+
z: this.center.z - this.extent.z
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* 最大点
|
|
442
|
+
* @returns {Vector3}
|
|
443
|
+
*/
|
|
444
|
+
get max() {
|
|
445
|
+
return {
|
|
446
|
+
x: this.center.x + this.extent.x,
|
|
447
|
+
y: this.center.y + this.extent.y,
|
|
448
|
+
z: this.center.z + this.extent.z
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* オフセット
|
|
453
|
+
* @param dx
|
|
454
|
+
* @param dy
|
|
455
|
+
* @param dz
|
|
456
|
+
* @returns {AxisAlignedBB}
|
|
457
|
+
*/
|
|
458
|
+
offset(dx, dy, dz) {
|
|
459
|
+
return new AxisAlignedBB(
|
|
460
|
+
{ x: this.center.x + dx, y: this.center.y + dy, z: this.center.z + dz },
|
|
461
|
+
this.extent
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* 拡大
|
|
466
|
+
* @param dx
|
|
467
|
+
* @param dy
|
|
468
|
+
* @param dz
|
|
469
|
+
* @returns {AxisAlignedBB}
|
|
470
|
+
*/
|
|
471
|
+
expand(dx, dy, dz) {
|
|
472
|
+
return new AxisAlignedBB(
|
|
473
|
+
this.center,
|
|
474
|
+
{
|
|
475
|
+
x: this.extent.x + dx,
|
|
476
|
+
y: this.extent.y + dy,
|
|
477
|
+
z: this.extent.z + dz
|
|
478
|
+
}
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* 縮小
|
|
483
|
+
* @param dx
|
|
484
|
+
* @param dy
|
|
485
|
+
* @param dz
|
|
486
|
+
* @returns {AxisAlignedBB}
|
|
487
|
+
*/
|
|
488
|
+
contract(dx, dy, dz) {
|
|
489
|
+
return this.expand(-dx, -dy, -dz);
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* 接触判定
|
|
493
|
+
* @param other
|
|
494
|
+
* @param epsilon
|
|
495
|
+
* @returns {boolean}
|
|
496
|
+
*/
|
|
497
|
+
intersects(other, epsilon = 1e-6) {
|
|
498
|
+
const aMin = this.min;
|
|
499
|
+
const aMax = this.max;
|
|
500
|
+
const bMin = other.min;
|
|
501
|
+
const bMax = other.max;
|
|
502
|
+
return bMax.x - aMin.x > epsilon && aMax.x - bMin.x > epsilon && bMax.y - aMin.y > epsilon && aMax.y - bMin.y > epsilon && bMax.z - aMin.z > epsilon && aMax.z - bMin.z > epsilon;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* 対象座標が内包されているか
|
|
506
|
+
* @param v
|
|
507
|
+
* @returns {boolean}
|
|
508
|
+
*/
|
|
509
|
+
contains(v) {
|
|
510
|
+
const min = this.min;
|
|
511
|
+
const max = this.max;
|
|
512
|
+
return v.x > min.x && v.x < max.x && v.y > min.y && v.y < max.y && v.z > min.z && v.z < max.z;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Xの長さ
|
|
516
|
+
* @returns {number}
|
|
517
|
+
*/
|
|
518
|
+
getXLength() {
|
|
519
|
+
return this.extent.x * 2;
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Yの長さ
|
|
523
|
+
* @returns {number}
|
|
524
|
+
*/
|
|
525
|
+
getYLength() {
|
|
526
|
+
return this.extent.y * 2;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Zの長さ
|
|
530
|
+
* @returns {number}
|
|
531
|
+
*/
|
|
532
|
+
getZLength() {
|
|
533
|
+
return this.extent.z * 2;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* 体積
|
|
537
|
+
* @returns {number}
|
|
538
|
+
*/
|
|
539
|
+
getVolume() {
|
|
540
|
+
return this.getXLength() * this.getYLength() * this.getZLength();
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* キューブ判定
|
|
544
|
+
* @param epsilon
|
|
545
|
+
* @returns {boolean}
|
|
546
|
+
*/
|
|
547
|
+
isCube(epsilon = 1e-6) {
|
|
548
|
+
const x = this.getXLength();
|
|
549
|
+
const y = this.getYLength();
|
|
550
|
+
const z = this.getZLength();
|
|
551
|
+
return Math.abs(x - y) < epsilon && Math.abs(y - z) < epsilon;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* BDS ScriptAPIで使える {center, extent} 形式に変換
|
|
555
|
+
* @returns {AABB}
|
|
556
|
+
*/
|
|
557
|
+
toBDS() {
|
|
558
|
+
return { center: this.center, extent: this.extent };
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* オブジェクトに変換
|
|
562
|
+
*/
|
|
563
|
+
toObject() {
|
|
564
|
+
return { center: this.center, extent: this.extent };
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* toString
|
|
568
|
+
* @returns {string}
|
|
569
|
+
*/
|
|
570
|
+
toString() {
|
|
571
|
+
return `AxisAlignedBB{center=(${this.center.x}, ${this.center.y}, ${this.center.z}), extent=(${this.center.x}, ${this.center.y}, ${this.center.z})}`;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
357
574
|
var Priority = /* @__PURE__ */ ((Priority2) => {
|
|
358
575
|
Priority2[Priority2["LOWEST"] = 5] = "LOWEST";
|
|
359
576
|
Priority2[Priority2["LOW"] = 4] = "LOW";
|
|
@@ -757,6 +974,7 @@ function sleep(tick) {
|
|
|
757
974
|
});
|
|
758
975
|
}
|
|
759
976
|
export {
|
|
977
|
+
AxisAlignedBB,
|
|
760
978
|
DelayedTimer,
|
|
761
979
|
EventManager,
|
|
762
980
|
Priority,
|