WIP
This commit is contained in:
parent
e6d0e6e6bb
commit
021b0f4cc0
|
|
@ -11,35 +11,33 @@ import org.kde.kwin as KWinComponents
|
|||
Node {
|
||||
id: cube
|
||||
|
||||
property real faceDisplacement: 100
|
||||
required property size faceSize
|
||||
readonly property real faceDistance: 0.5 * faceSize.width / Math.tan(angleTick * Math.PI / 360) + faceDisplacement;
|
||||
readonly property real angleTick: 360 / faceRepeater.count
|
||||
|
||||
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;
|
||||
}
|
||||
required property real viewportFOVHorizontal
|
||||
required property real viewportWidth
|
||||
required property real viewportHeight
|
||||
property real distance: viewportWidth / (2 * Math.tan(Math.PI * viewportFOVHorizontal / 360))
|
||||
|
||||
Repeater3D {
|
||||
id: faceRepeater
|
||||
model: KWinComponents.Workspace.screens.length
|
||||
delegate: CubeFace {
|
||||
screen: KWinComponents.Workspace.screens[index]
|
||||
faceSize: cube.faceSize
|
||||
scale: Qt.vector3d(faceSize.width / 100, faceSize.height / 100, 1)
|
||||
eulerRotation.y: cube.angleTick * index
|
||||
|
||||
property real screenRotation: {
|
||||
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: {
|
||||
console.log(`\t\t\tBreezy - position ${distance} ${screenRotation}`);
|
||||
const transform = Qt.matrix4x4();
|
||||
transform.rotate(cube.angleTick * index, Qt.vector3d(0, 1, 0));
|
||||
return transform.times(Qt.vector3d(0, 0, cube.faceDistance));
|
||||
transform.rotate(screenRotation, Qt.vector3d(0, 1, 0));
|
||||
const position = Qt.vector3d(0, 0, -distance);
|
||||
return transform.times(position).minus(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ Model {
|
|||
|
||||
required property QtObject screen
|
||||
required property int index
|
||||
required property size faceSize
|
||||
|
||||
source: "#Rectangle"
|
||||
materials: [
|
||||
|
|
@ -22,8 +21,8 @@ Model {
|
|||
diffuseMap: Texture {
|
||||
sourceItem: DesktopView {
|
||||
screen: face.screen
|
||||
width: faceSize.width
|
||||
height: faceSize.height
|
||||
width: face.screen.geometry.width
|
||||
height: face.screen.geometry.height
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ Item {
|
|||
Repeater {
|
||||
model: KWinComponents.WindowFilterModel {
|
||||
activity: KWinComponents.Workspace.currentActivity
|
||||
screenName: desktopView.screen.name
|
||||
windowModel: KWinComponents.WindowModel {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ Item {
|
|||
}
|
||||
|
||||
function switchToSelected() {
|
||||
const eulerRotation = cameraController.rotation.toEulerAngles();
|
||||
const desktop = cube.screenAt(eulerRotation.y);
|
||||
KWinComponents.Workspace.currentDesktop = desktop;
|
||||
effect.deactivate();
|
||||
// const eulerRotation = cameraController.rotation.toEulerAngles();
|
||||
// const desktop = cube.screenAt(eulerRotation.y);
|
||||
// KWinComponents.Workspace.currentDesktop = desktop;
|
||||
// effect.deactivate();
|
||||
}
|
||||
|
||||
View3D {
|
||||
|
|
@ -69,12 +69,16 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
PerspectiveCamera { id: camera }
|
||||
PerspectiveCamera {
|
||||
id: camera
|
||||
fieldOfView: 22.55
|
||||
}
|
||||
|
||||
Cube {
|
||||
id: cube
|
||||
faceDisplacement: effect.cubeFaceDisplacement
|
||||
faceSize: Qt.size(root.width, root.height)
|
||||
viewportFOVHorizontal: 40.09
|
||||
viewportWidth: 1920
|
||||
viewportHeight: 1080
|
||||
}
|
||||
|
||||
CubeCameraController {
|
||||
|
|
@ -90,14 +94,14 @@ Item {
|
|||
name: "close"
|
||||
PropertyChanges {
|
||||
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 {
|
||||
name: "distant"
|
||||
PropertyChanges {
|
||||
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) {
|
||||
if (rotationAnimation.running) {
|
||||
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.onLeftPressed: cameraController.rotateToLeft();
|
||||
Keys.onRightPressed: cameraController.rotateToRight();
|
||||
Keys.onEnterPressed: root.switchToSelected();
|
||||
Keys.onReturnPressed: root.switchToSelected();
|
||||
Keys.onSpacePressed: root.switchToSelected();
|
||||
|
|
|
|||
Loading…
Reference in New Issue