mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-13 14:05:35 +02:00
wip
This commit is contained in:
@@ -219,6 +219,7 @@ const resolutionAutoValue = computed<number>(() => deviceKind !== 'desktop' ? 0.
|
||||
const resolution = computed<number>(() => resolutionRaw.value ?? resolutionAutoValue.value);
|
||||
|
||||
const useVirtualJoystick = isTouchUsing && (deviceKind === 'smartphone' || deviceKind === 'tablet');
|
||||
//const useVirtualJoystick = true;
|
||||
|
||||
const wasdVec = { x: 0, y: 0 };
|
||||
const pointerVec = { x: 0, y: 0 };
|
||||
@@ -426,10 +427,11 @@ onMounted(async () => {
|
||||
|
||||
timeoutId = window.setTimeout(() => {
|
||||
timeoutId = null;
|
||||
pointerVec.x = 0;
|
||||
pointerVec.y = 0;
|
||||
|
||||
controller.setCameraRotateVector(pointerVec);
|
||||
controller.setCameraRotateVector({
|
||||
x: 0,
|
||||
y: 0,
|
||||
});
|
||||
}, 10);
|
||||
};
|
||||
|
||||
|
||||
@@ -308,13 +308,11 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
|
||||
this.camera.inertia = 0.75;
|
||||
} else {
|
||||
this.camera.inputs.add(new FreeCameraManualInput({
|
||||
moveSensitivity: 0.001 * WORLD_SCALE,
|
||||
rotationSensitivity: 0.01,
|
||||
moveSensitivity: 0.002 * WORLD_SCALE,
|
||||
rotationSensitivity: 0.0003,
|
||||
}));
|
||||
}
|
||||
|
||||
this.camera.attachControl(this.canvas);
|
||||
|
||||
//this.scene.activeCamera = this.camera;
|
||||
|
||||
this.roomLight = new BABYLON.SpotLight('roomLight', new BABYLON.Vector3(0, cm(249), 0), new BABYLON.Vector3(0, -1, 0), 16, 8, this.scene);
|
||||
@@ -606,7 +604,7 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
|
||||
}
|
||||
|
||||
public cameraMove(vector: { x: number; y: number; }, dash: boolean) {
|
||||
(this.camera.inputs.attached.manual as FreeCameraManualInput).setMoveVector(dash ? { x: vector.x * 4, y: vector.y * 4 } : vector);
|
||||
(this.camera.inputs.attached.manual as FreeCameraManualInput).setMoveVector(dash ? { x: vector.x * 3, y: vector.y * 3 } : vector);
|
||||
}
|
||||
|
||||
public cameraRotate(vector: { x: number; y: number; }) {
|
||||
|
||||
@@ -653,7 +653,7 @@ export class FreeCameraVirtualJoystickInput implements BABYLON.ICameraInput<BABY
|
||||
if (this.camera.getScene().useRightHandedSystem) directionAdjust *= -1;
|
||||
if (this.camera.parent && this.camera.parent._getWorldMatrixDeterminant() < 0) directionAdjust *= -1;
|
||||
|
||||
this.rotationVecX = vec.y * this.rotationSensitivity;
|
||||
this.rotationVecX = vec.y * this.rotationSensitivity * directionAdjust;
|
||||
this.rotationVecY = vec.x * this.rotationSensitivity * directionAdjust;
|
||||
}
|
||||
|
||||
@@ -672,8 +672,6 @@ export class FreeCameraManualInput implements BABYLON.ICameraInput<BABYLON.FreeC
|
||||
private moveSensitivity: number;
|
||||
private rotationSensitivity: number;
|
||||
private moveVector = BABYLON.Vector3.Zero();
|
||||
private rotationVecX = 0;
|
||||
private rotationVecY = 0;
|
||||
|
||||
constructor(options: {
|
||||
moveSensitivity?: number;
|
||||
@@ -702,16 +700,21 @@ export class FreeCameraManualInput implements BABYLON.ICameraInput<BABYLON.FreeC
|
||||
if (this.camera.getScene().useRightHandedSystem) directionAdjust *= -1;
|
||||
if (this.camera.parent && this.camera.parent._getWorldMatrixDeterminant() < 0) directionAdjust *= -1;
|
||||
|
||||
this.rotationVecX = vec.y * this.rotationSensitivity;
|
||||
this.rotationVecY = vec.x * this.rotationSensitivity * directionAdjust;
|
||||
this.camera.cameraRotation.x += vec.y * this.rotationSensitivity * directionAdjust;
|
||||
this.camera.cameraRotation.y += vec.x * this.rotationSensitivity * directionAdjust;
|
||||
}
|
||||
|
||||
checkInputs() {
|
||||
this.camera.cameraRotation.y += this.rotationVecY;
|
||||
this.camera.cameraRotation.x += this.rotationVecX;
|
||||
|
||||
this.camera.cameraDirection.addInPlace(
|
||||
BABYLON.Vector3.TransformCoordinates(this.moveVector, BABYLON.Matrix.RotationY(this.camera.rotation.y)),
|
||||
);
|
||||
|
||||
//const engine = this.camera.getEngine();
|
||||
//const v = this.moveVector.scale(Math.sqrt(engine.getDeltaTime() / (engine.getFps() * 100.0)));
|
||||
//console.log(v);
|
||||
//this.camera._localDirection.copyFromFloats(v.x, v.y, v.z);
|
||||
//this.camera.getViewMatrix().invertToRef(this.camera._cameraTransformMatrix);
|
||||
//BABYLON.Vector3.TransformNormalToRef(this.camera._localDirection, this.camera._cameraTransformMatrix, this.camera._transformedDirection);
|
||||
//this.camera.cameraDirection.addInPlace(this.camera._transformedDirection);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user