Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- check() {
- this.segments.forEach(element => {
- this.detect(element.position);
- });
- }
- detect(elem) {
- // Speed might jump the distanceThreshold ** CAUTION **
- this.hid.speed = 5;
- var moveSpeed = this.hid.speed;
- var norbitA = (Math.abs(this.camera.position.x)) ?? -1;
- var norbitB = (Math.abs(this.camera.position.z)) ?? -1;
- var x = this.hid.direction.x;
- var z = this.hid.direction.z;
- var positive = ((this.hid.moveForward || this.hid.moveRight) > (this.hid.moveBackward || this.hid.moveLeft)) * (-1);
- // 1 for either direction
- var d = (x > z) ?? z * (-norbitA);
- var cam = this.camera.position;
- // find hyperbolic in condition
- console.log((d * moveSpeed) * positive * (-norbitB));
- this.hid.controls.moveRight((d * moveSpeed) * positive * (-norbitB));
- this.hid.controls.moveForward((d * moveSpeed) * positive * (-norbitB));
- const delta = this.hid.clock.getDelta();
- this.hid.update(delta);
- if (cam.x === (elem.x | elem.z) || cam.z === (elem.x | elem.z)) {
- this.hid.controls.moveRight((d * moveSpeed) * positive * (norbitB));
- this.hid.controls.moveForward((d * moveSpeed) * positive * (norbitB));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement