fluencyCAD/3d_windows.py
2023-12-30 16:55:01 +01:00

38 lines
1.1 KiB
Python

from PySide6 import QtGui
from PySide6.Qt3DCore import Qt3DCore
from PySide6.Qt3DExtras import Qt3DExtras
from PySide6.QtWidgets import QApplication, QMainWindow
import sys
class My3DWindow(QMainWindow):
def __init__(self):
super(My3DWindow, self).__init__()
# Create the 3D scene
scene = Qt3DCore.QEntity()
# Create a 3D view container
view = Qt3DExtras.Qt3DWindow()
view.defaultFrameGraph().setClearColor(QtGui.QColor(0, 0, 0, 0))
# Set root entity for the scene
view.setRootEntity(scene)
# Create a 3D transform
transform = Qt3DCore.QTransform()
transform.setScale3D(QtGui.QVector3D(1.0, 1.0, 1.0))
# Set components for the mesh entity
mesh_entity.addComponent(material)
mesh_entity.addComponent(transform)
# Add the mesh entity to the scene
scene.addComponent(mesh_entity)
self.setCentralWidget(view)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = My3DWindow()
window.show()
sys.exit(app.exec_())