|
@@ -14,13 +14,13 @@ import { GameEvent } from '../core/events.js';
|
14
|
14
|
const BALL_RADIUS = 0.27;
|
15
|
15
|
|
16
|
16
|
/** Minimum distance for scoring 3 points */
|
17
|
|
-const THREE_POINT_THRESHOLD = 5.0;
|
|
17
|
+const THREE_POINT_THRESHOLD = 6.0;
|
18
|
18
|
|
19
|
19
|
/** Shoot angle */
|
20
|
20
|
const SHOOT_ANGLE = Math.PI / 4;
|
21
|
21
|
|
22
|
22
|
/** Shoot sensitivity multiplier (y and z axes) */
|
23
|
|
-const SHOOT_SENSITIVITY = 1.65;
|
|
23
|
+const SHOOT_SENSITIVITY = 1.5;
|
24
|
24
|
|
25
|
25
|
/** Shoot sensitivity multiplier (x-axis) */
|
26
|
26
|
const SHOOT_HORIZONTAL_SENSITIVITY = 0.5;
|
|
@@ -128,7 +128,7 @@ export class Ball extends Entity
|
128
|
128
|
|
129
|
129
|
if(ar.pointers.length > 0) {
|
130
|
130
|
const pointer = ar.pointers[0];
|
131
|
|
- const position = ar.session.viewport.convertToPixels(pointer.position, 'adjusted');
|
|
131
|
+ const position = ar.session.viewport.convertToPixels(pointer.position, pointer.tracker.space);
|
132
|
132
|
|
133
|
133
|
if(position.x > 60) {
|
134
|
134
|
impostor.mass = 1; // enable gravity
|
|
@@ -167,11 +167,12 @@ export class Ball extends Entity
|
167
|
167
|
_onThrownState()
|
168
|
168
|
{
|
169
|
169
|
const ar = this.ar;
|
|
170
|
+ const rootPosition = ar.root.absolutePosition;
|
170
|
171
|
const cameraPosition = ar.camera.globalPosition;
|
171
|
172
|
const ballPosition = this._mesh.absolutePosition;
|
172
|
173
|
const distance = BABYLON.Vector3.Distance(cameraPosition, ballPosition);
|
173
|
174
|
|
174
|
|
- if(distance > MAX_DISTANCE || ballPosition.y < cameraPosition.y - MAX_Y_DISTANCE) {
|
|
175
|
+ if(distance > MAX_DISTANCE || ballPosition.y < rootPosition.y - MAX_Y_DISTANCE) {
|
175
|
176
|
this._broadcast(new GameEvent('lostball'));
|
176
|
177
|
this._state = 'ready';
|
177
|
178
|
}
|
|
@@ -185,11 +186,10 @@ export class Ball extends Entity
|
185
|
186
|
_throw(v)
|
186
|
187
|
{
|
187
|
188
|
const magnitude = SHOOT_SENSITIVITY * v.y;
|
188
|
|
- const angle = SHOOT_ANGLE;
|
189
|
189
|
const impulse = new BABYLON.Vector3(
|
190
|
190
|
v.x * SHOOT_HORIZONTAL_SENSITIVITY,
|
191
|
|
- magnitude * Math.sin(angle),
|
192
|
|
- -magnitude * Math.cos(angle)
|
|
191
|
+ magnitude * Math.sin(SHOOT_ANGLE),
|
|
192
|
+ -magnitude * Math.cos(SHOOT_ANGLE)
|
193
|
193
|
);
|
194
|
194
|
|
195
|
195
|
this._positionWhenThrown.copyFrom(this._mesh.absolutePosition);
|
|
@@ -204,17 +204,13 @@ export class Ball extends Entity
|
204
|
204
|
*/
|
205
|
205
|
_findVelocity(pointer)
|
206
|
206
|
{
|
207
|
|
- // we could return pointer.velocity, but that's not always
|
208
|
|
- // user-friendly when it comes to throwing the ball!
|
209
|
|
- const currentSpeed = pointer.velocity.length();
|
210
|
|
- const averageSpeed = pointer.totalDistance / pointer.elapsedTime;
|
211
|
|
- const speed = Math.max(currentSpeed, averageSpeed);
|
|
207
|
+ if(pointer.movementDuration == 0)
|
|
208
|
+ return pointer.velocity.times(0);
|
212
|
209
|
|
213
|
|
- let direction = pointer.initialPosition.directionTo(pointer.position);
|
214
|
|
- if(direction.y < 0)
|
215
|
|
- direction = pointer.deltaPosition.normalized();
|
|
210
|
+ const averageSpeed = pointer.movementLength / pointer.movementDuration;
|
|
211
|
+ const direction = pointer.initialPosition.directionTo(pointer.position);
|
216
|
212
|
|
217
|
|
- return direction.times(speed);
|
|
213
|
+ return direction.times(averageSpeed);
|
218
|
214
|
}
|
219
|
215
|
|
220
|
216
|
/**
|