mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-14 05:15:35 +02:00
wip
This commit is contained in:
@@ -212,8 +212,8 @@ const resolutionRaw = prefer.model('world.resolution');
|
||||
const resolutionAutoValue = computed<number>(() => deviceKind !== 'desktop' ? 0.5 : 1);
|
||||
const resolution = computed<number>(() => resolutionRaw.value ?? resolutionAutoValue.value);
|
||||
|
||||
//const useVirtualJoystick = isTouchUsing && (deviceKind === 'smartphone' || deviceKind === 'tablet');
|
||||
const useVirtualJoystick = true;
|
||||
const useVirtualJoystick = isTouchUsing && (deviceKind === 'smartphone' || deviceKind === 'tablet');
|
||||
//const useVirtualJoystick = true;
|
||||
|
||||
const wasdVec = { x: 0, y: 0 };
|
||||
let isDashing = false;
|
||||
|
||||
@@ -191,6 +191,8 @@ export class RoomController {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
this.canvas!.focus();
|
||||
|
||||
this.pointerDownPosition = { x: ev.offsetX, y: ev.offsetY };
|
||||
this.canvas!.setPointerCapture(ev.pointerId);
|
||||
|
||||
|
||||
@@ -301,13 +301,13 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
|
||||
this.camera.inputs.clear();
|
||||
|
||||
if (options.useVirtualJoystick) {
|
||||
this.camera.inputs.add(new FreeCameraManualInput({
|
||||
this.camera.inputs.add(new FreeCameraManualInput(this.scene, {
|
||||
moveSensitivity: 0.015 * WORLD_SCALE,
|
||||
rotationSensitivity: 0.0005,
|
||||
rotationSensitivity: 0.0007,
|
||||
}));
|
||||
this.camera.inertia = 0.75;
|
||||
} else {
|
||||
this.camera.inputs.add(new FreeCameraManualInput({
|
||||
this.camera.inputs.add(new FreeCameraManualInput(this.scene, {
|
||||
moveSensitivity: 0.002 * WORLD_SCALE,
|
||||
rotationSensitivity: 0.0003,
|
||||
}));
|
||||
|
||||
@@ -620,14 +620,16 @@ export function getRgb(hex: string | number): [number, number, number] | null {
|
||||
|
||||
export class FreeCameraManualInput implements BABYLON.ICameraInput<BABYLON.FreeCamera> {
|
||||
public camera: BABYLON.FreeCamera;
|
||||
private scene: BABYLON.Scene;
|
||||
private moveSensitivity: number;
|
||||
private rotationSensitivity: number;
|
||||
private moveVector = BABYLON.Vector3.Zero();
|
||||
|
||||
constructor(options: {
|
||||
constructor(scene: BABYLON.Scene, options: {
|
||||
moveSensitivity?: number;
|
||||
rotationSensitivity?: number;
|
||||
}) {
|
||||
this.scene = scene;
|
||||
this.moveSensitivity = options.moveSensitivity ?? 0.01;
|
||||
this.rotationSensitivity = options.rotationSensitivity ?? 0.01;
|
||||
}
|
||||
@@ -648,7 +650,7 @@ export class FreeCameraManualInput implements BABYLON.ICameraInput<BABYLON.FreeC
|
||||
|
||||
public setRotationVector(vec: { x: number; y: number }) {
|
||||
let directionAdjust = 1;
|
||||
if (this.camera.getScene().useRightHandedSystem) directionAdjust *= -1;
|
||||
if (this.scene.useRightHandedSystem) directionAdjust *= -1;
|
||||
if (this.camera.parent && this.camera.parent._getWorldMatrixDeterminant() < 0) directionAdjust *= -1;
|
||||
|
||||
this.camera.cameraRotation.x += vec.y * this.rotationSensitivity * directionAdjust;
|
||||
@@ -656,8 +658,9 @@ export class FreeCameraManualInput implements BABYLON.ICameraInput<BABYLON.FreeC
|
||||
}
|
||||
|
||||
checkInputs() {
|
||||
const ratio = this.scene.getAnimationRatio();
|
||||
this.camera.cameraDirection.addInPlace(
|
||||
BABYLON.Vector3.TransformCoordinates(this.moveVector, BABYLON.Matrix.RotationY(this.camera.rotation.y)),
|
||||
BABYLON.Vector3.TransformCoordinates(this.moveVector.scale(ratio), BABYLON.Matrix.RotationY(this.camera.rotation.y)),
|
||||
);
|
||||
|
||||
//const engine = this.camera.getEngine();
|
||||
|
||||
Reference in New Issue
Block a user