This commit is contained in:
wheaney 2025-07-01 14:23:46 -07:00
parent e6d0e6e6bb
commit 021b0f4cc0
4 changed files with 36 additions and 50 deletions

View File

@ -11,35 +11,33 @@ import org.kde.kwin as KWinComponents
Node { Node {
id: cube id: cube
property real faceDisplacement: 100 required property real viewportFOVHorizontal
required property size faceSize required property real viewportWidth
readonly property real faceDistance: 0.5 * faceSize.width / Math.tan(angleTick * Math.PI / 360) + faceDisplacement; required property real viewportHeight
readonly property real angleTick: 360 / faceRepeater.count property real distance: viewportWidth / (2 * Math.tan(Math.PI * viewportFOVHorizontal / 360))
function screenAt(azimuth) {
let index = Math.round(azimuth / angleTick) % faceRepeater.count;
if (index < 0) {
index += faceRepeater.count;
}
return faceRepeater.objectAt(index).screen;
}
function screenAzimuth(screen) {
return cube.angleTick * screen.index;
}
Repeater3D { Repeater3D {
id: faceRepeater id: faceRepeater
model: KWinComponents.Workspace.screens.length model: KWinComponents.Workspace.screens.length
delegate: CubeFace { delegate: CubeFace {
screen: KWinComponents.Workspace.screens[index] screen: KWinComponents.Workspace.screens[index]
faceSize: cube.faceSize
scale: Qt.vector3d(faceSize.width / 100, faceSize.height / 100, 1) property real screenRotation: {
eulerRotation.y: cube.angleTick * index const geometry = screen.geometry;
const rot = (viewportFOVHorizontal / viewportWidth) * geometry.x
console.log(`\t\t\tBreezy - screenRotation ${geometry.x} ${geometry.width} ${rot}`);
return -rot;
}
scale: Qt.vector3d(viewportWidth / 100, viewportHeight / 100, 1)
eulerRotation.y: screenRotation
position: { position: {
console.log(`\t\t\tBreezy - position ${distance} ${screenRotation}`);
const transform = Qt.matrix4x4(); const transform = Qt.matrix4x4();
transform.rotate(cube.angleTick * index, Qt.vector3d(0, 1, 0)); transform.rotate(screenRotation, Qt.vector3d(0, 1, 0));
return transform.times(Qt.vector3d(0, 0, cube.faceDistance)); const position = Qt.vector3d(0, 0, -distance);
return transform.times(position).minus(position);
} }
} }
} }

View File

@ -12,7 +12,6 @@ Model {
required property QtObject screen required property QtObject screen
required property int index required property int index
required property size faceSize
source: "#Rectangle" source: "#Rectangle"
materials: [ materials: [
@ -22,8 +21,8 @@ Model {
diffuseMap: Texture { diffuseMap: Texture {
sourceItem: DesktopView { sourceItem: DesktopView {
screen: face.screen screen: face.screen
width: faceSize.width width: face.screen.geometry.width
height: faceSize.height height: face.screen.geometry.height
} }
} }
} }

View File

@ -15,6 +15,7 @@ Item {
Repeater { Repeater {
model: KWinComponents.WindowFilterModel { model: KWinComponents.WindowFilterModel {
activity: KWinComponents.Workspace.currentActivity activity: KWinComponents.Workspace.currentActivity
screenName: desktopView.screen.name
windowModel: KWinComponents.WindowModel {} windowModel: KWinComponents.WindowModel {}
} }

View File

@ -30,10 +30,10 @@ Item {
} }
function switchToSelected() { function switchToSelected() {
const eulerRotation = cameraController.rotation.toEulerAngles(); // const eulerRotation = cameraController.rotation.toEulerAngles();
const desktop = cube.screenAt(eulerRotation.y); // const desktop = cube.screenAt(eulerRotation.y);
KWinComponents.Workspace.currentDesktop = desktop; // KWinComponents.Workspace.currentDesktop = desktop;
effect.deactivate(); // effect.deactivate();
} }
View3D { View3D {
@ -69,12 +69,16 @@ Item {
} }
} }
PerspectiveCamera { id: camera } PerspectiveCamera {
id: camera
fieldOfView: 22.55
}
Cube { Cube {
id: cube id: cube
faceDisplacement: effect.cubeFaceDisplacement viewportFOVHorizontal: 40.09
faceSize: Qt.size(root.width, root.height) viewportWidth: 1920
viewportHeight: 1080
} }
CubeCameraController { CubeCameraController {
@ -90,14 +94,14 @@ Item {
name: "close" name: "close"
PropertyChanges { PropertyChanges {
target: cameraController target: cameraController
radius: cube.faceDistance + 0.5 * cube.faceSize.height / Math.tan(0.5 * camera.fieldOfView * Math.PI / 180) radius: 0.0 + 0.5 * cube.viewportHeight / Math.tan(0.5 * camera.fieldOfView * Math.PI / 180)
} }
}, },
State { State {
name: "distant" name: "distant"
PropertyChanges { PropertyChanges {
target: cameraController target: cameraController
radius: cube.faceDistance * effect.distanceFactor + 0.5 * cube.faceSize.height / Math.tan(0.5 * camera.fieldOfView * Math.PI / 180) radius: 0.0 * effect.distanceFactor + 0.5 * cube.viewportHeight / Math.tan(0.5 * camera.fieldOfView * Math.PI / 180)
} }
} }
] ]
@ -117,25 +121,11 @@ Item {
} }
} }
function rotateToLeft() {
if (rotationAnimation.running) {
return;
}
rotation = Quaternion.fromEulerAngles(0, -cube.angleTick, 0).times(rotation);
}
function rotateToRight() {
if (rotationAnimation.running) {
return;
}
rotation = Quaternion.fromEulerAngles(0, cube.angleTick, 0).times(rotation);
}
function rotateTo(desktop) { function rotateTo(desktop) {
if (rotationAnimation.running) { if (rotationAnimation.running) {
return; return;
} }
rotation = Quaternion.fromEulerAngles(0, cube.screenAzimuth(desktop), 0); rotation = Quaternion.fromEulerAngles(0, 0, 0);
} }
} }
} }
@ -146,8 +136,6 @@ Item {
} }
Keys.onEscapePressed: effect.deactivate(); Keys.onEscapePressed: effect.deactivate();
Keys.onLeftPressed: cameraController.rotateToLeft();
Keys.onRightPressed: cameraController.rotateToRight();
Keys.onEnterPressed: root.switchToSelected(); Keys.onEnterPressed: root.switchToSelected();
Keys.onReturnPressed: root.switchToSelected(); Keys.onReturnPressed: root.switchToSelected();
Keys.onSpacePressed: root.switchToSelected(); Keys.onSpacePressed: root.switchToSelected();