51 Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE
false FINAL)
52 Q_PROPERTY(QQuick3DCamera *camera READ camera WRITE setCamera NOTIFY cameraChanged FINAL)
53 Q_PROPERTY(QQuick3DSceneEnvironment *environment READ environment WRITE setEnvironment NOTIFY environmentChanged FINAL)
54 Q_PROPERTY(QQuick3DNode *scene READ scene NOTIFY sceneChanged)
55 Q_PROPERTY(QQuick3DNode *importScene READ importScene WRITE setImportScene NOTIFY importSceneChanged FINAL)
56 Q_PROPERTY(RenderMode renderMode READ renderMode WRITE setRenderMode NOTIFY renderModeChanged FINAL)
57#if QT_CONFIG(quick_shadereffect)
58 Q_PROPERTY(QQuickShaderEffectSource::Format renderFormat READ renderFormat WRITE setRenderFormat NOTIFY renderFormatChanged FINAL REVISION(6, 4))
60 Q_PROPERTY(QQuick3DRenderStats *renderStats READ renderStats CONSTANT)
61 Q_PROPERTY(QQmlListProperty<QQuick3DObject> extensions READ extensions FINAL REVISION(6, 6))
62 Q_PROPERTY(
int explicitTextureWidth READ explicitTextureWidth WRITE setExplicitTextureWidth NOTIFY explicitTextureWidthChanged FINAL REVISION(6, 7))
63 Q_PROPERTY(
int explicitTextureHeight READ explicitTextureHeight WRITE setExplicitTextureHeight NOTIFY explicitTextureHeightChanged FINAL REVISION(6, 7))
64 Q_PROPERTY(QSize effectiveTextureSize READ effectiveTextureSize NOTIFY effectiveTextureSizeChanged FINAL REVISION(6, 7))
65 Q_CLASSINFO(
"DefaultProperty",
"data")
67 QML_NAMED_ELEMENT(View3D)
78 explicit QQuick3DViewport(QQuickItem *parent =
nullptr);
79 ~QQuick3DViewport() override;
81 QQmlListProperty<QObject> data();
83 QQuick3DCamera *camera()
const;
84 QQuick3DSceneEnvironment *environment()
const;
85 QQuick3DNode *scene()
const;
86 QQuick3DNode *importScene()
const;
87 RenderMode renderMode()
const;
88#if QT_CONFIG(quick_shadereffect)
89 Q_REVISION(6, 4) QQuickShaderEffectSource::Format renderFormat()
const;
91 QQuick3DRenderStats *renderStats()
const;
93 QQuick3DSceneRenderer *createRenderer()
const;
95 bool isTextureProvider()
const override;
96 QSGTextureProvider *textureProvider()
const override;
97 void releaseResources() override;
99 Q_INVOKABLE QVector3D mapFrom3DScene(
const QVector3D &scenePos)
const;
100 Q_INVOKABLE QVector3D mapTo3DScene(
const QVector3D &viewPos)
const;
102 Q_INVOKABLE QQuick3DPickResult pick(
float x,
float y)
const;
103 Q_REVISION(6, 8) Q_INVOKABLE QQuick3DPickResult pick(
float x,
float y, QQuick3DModel *model)
const;
104 Q_REVISION(6, 8) Q_INVOKABLE QList<QQuick3DPickResult> pickSubset(
float x,
float y,
const QJSValue &models)
const;
105 Q_REVISION(6, 2) Q_INVOKABLE QList<QQuick3DPickResult> pickAll(
float x,
float y)
const;
106 Q_REVISION(6, 2) Q_INVOKABLE QQuick3DPickResult rayPick(
const QVector3D &origin,
const QVector3D &direction)
const;
107 Q_REVISION(6, 2) Q_INVOKABLE QList<QQuick3DPickResult> rayPickAll(
const QVector3D &origin,
const QVector3D &direction)
const;
109 Q_REVISION(6, 11) Q_INVOKABLE QQuick3DPickResult rayPick(
const QVector3D &origin,
const QVector3D &direction, QQuick3DModel *model)
const;
111 void processPointerEventFromRay(
const QVector3D &origin,
const QVector3D &direction, QPointerEvent *event)
const;
112 bool singlePointPick(QSinglePointEvent *event,
const QVector3D &origin,
const QVector3D &direction);
114 Q_REVISION(6, 8) Q_INVOKABLE
void setTouchpoint(QQuickItem *target,
const QPointF &position,
int pointId,
bool active);
116 QQuick3DLightmapBaker *maybeLightmapBaker();
117 QQuick3DLightmapBaker *lightmapBaker();
119 Q_INVOKABLE
void bakeLightmap();
120 Q_REVISION(6, 10) Q_INVOKABLE
void denoiseLightmap();
122 QQmlListProperty<QQuick3DObject> extensions();
124 Q_REVISION(6, 7)
int explicitTextureWidth()
const;
125 Q_REVISION(6, 7)
int explicitTextureHeight()
const;
126 Q_REVISION(6, 7) QSize effectiveTextureSize()
const;
129 [[nodiscard]]
bool extensionListDirty()
const {
return m_extensionListDirty; }
130 [[nodiscard]]
const QList<QQuick3DObject *> &extensionList()
const {
return m_extensions; }
131 void clearExtensionListDirty() { m_extensionListDirty =
false; }
133 Q_REVISION(6, 7) Q_INVOKABLE
void rebuildExtensionList();
135 enum class PrivateInstanceType : quint8 { XrViewInstance = 1 };
136 explicit QQuick3DViewport(PrivateInstanceType type, QQuickItem *parent =
nullptr);
137 [[nodiscard]]
bool isXrViewInstance()
const {
return m_isXrViewInstance; }
139 static void updateCameraForLayer(
const QQuick3DViewport &view3D, QSSGRenderLayer &layerNode);
142 void geometryChange(
const QRectF &newGeometry,
const QRectF &oldGeometry) override;
143 QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
144 void itemChange(QQuickItem::ItemChange change,
const QQuickItem::ItemChangeData &value) override;
146 bool event(QEvent *) override;
147 void componentComplete() override;
150 void setCamera(QQuick3DCamera *camera);
151 void setEnvironment(QQuick3DSceneEnvironment * environment);
152 void setImportScene(QQuick3DNode *inScene);
153 void setRenderMode(QQuick3DViewport::RenderMode renderMode);
154#if QT_CONFIG(quick_shadereffect)
155 Q_REVISION(6, 4)
void setRenderFormat(QQuickShaderEffectSource::Format format);
157 Q_REVISION(6, 7)
void setExplicitTextureWidth(
int width);
158 Q_REVISION(6, 7)
void setExplicitTextureHeight(
int height);
159 void cleanupDirectRenderer();
163 void setGlobalPickingEnabled(
bool isEnabled);
166 void invalidateSceneGraph();
167 void updateInputProcessing();
168 void onReleaseCachedResources();
171 void cameraChanged();
172 void environmentChanged();
174 void importSceneChanged();
175 void renderModeChanged();
176 Q_REVISION(6, 4)
void renderFormatChanged();
177 Q_REVISION(6, 7)
void explicitTextureWidthChanged();
178 Q_REVISION(6, 7)
void explicitTextureHeightChanged();
179 Q_REVISION(6, 7)
void effectiveTextureSizeChanged();
182 void setMultiViewCameras(QQuick3DCamera **firstCamera,
int count);
184 void setMultiViewCameras(QQuick3DCamera *(&cameras)[N])
186 static_assert(N > 1,
"Use setCamera for single view");
187 setMultiViewCameras(cameras, N);
190 friend class QQuick3DExtensionListHelper;
191 friend class QQuick3DXrManager;
192 friend class QQuick3DXrManagerPrivate;
193 friend class QQuick3DRenderLayerHelpers;
195 Q_DISABLE_COPY(QQuick3DViewport)
196 struct SubsceneInfo {
197 QQuick3DObject* obj =
nullptr;
198 QVarLengthArray<QPointF, 16> eventPointScenePositions;
200 QQuick3DSceneRenderer *getRenderer()
const;
201 void updateDynamicTextures();
202 QSGNode *setupOffscreenRenderer(QSGNode *node);
203 QSGNode *setupInlineRenderer(QSGNode *node);
204 void setupDirectRenderer(RenderMode mode);
205 bool checkIsVisible()
const;
206 bool internalPick(QPointerEvent *event,
const QVector3D &origin = QVector3D(),
const QVector3D &direction = QVector3D())
const;
207 QPair<QQuickItem *, QPointF> getItemAndPosition(
const QSSGRenderPickResult &pickResult);
208 QVarLengthArray<QSSGRenderPickResult, 20> getPickResults(QQuick3DSceneRenderer *renderer,
const QVector3D &origin,
const QVector3D &direction)
const;
209 QVarLengthArray<QSSGRenderPickResult, 20> getPickResults(QQuick3DSceneRenderer *renderer,
const QEventPoint &eventPoint)
const;
210 bool forwardEventToSubscenes(QPointerEvent *event,
212 QQuick3DSceneRenderer *renderer,
213 const QFlatMap<QQuickItem *, SubsceneInfo> &visitedSubscenes)
const;
215 void processPickedObject(
const QSSGRenderPickResult &pickResult,
217 QPointerEvent *event,
218 QFlatMap<QQuickItem *, SubsceneInfo> &vistedSubscenes)
const;
219 QQuickItem *getSubSceneRootItem(QQuick3DMaterial *material)
const;
220 QQuick3DPickResult getNearestPickResult(
const QVarLengthArray<QSSGRenderPickResult, 20> &pickResults)
const;
221 QQuick3DPickResult processPickResult(
const QSSGRenderPickResult &pickResult)
const;
222 QQuick3DObject *findFrontendNode(
const QSSGRenderGraphObject *backendObject)
const;
223 QQuick3DSceneManager *findChildSceneManager(QQuick3DObject *inObject, QQuick3DSceneManager *manager =
nullptr);
224 void updateSceneManagerForImportScene();
225 QQuick3DCamera *m_camera =
nullptr;
226 QVarLengthArray<QQuick3DCamera *, 2> m_multiViewCameras;
227 QQuick3DSceneEnvironment *m_environment =
nullptr;
228 mutable QPointer<QQuick3DSceneEnvironment> m_builtInEnvironment;
229 QQuick3DSceneRootNode *m_sceneRoot =
nullptr;
230 QQuick3DNode *m_importScene =
nullptr;
231 mutable SGFramebufferObjectNode *m_node =
nullptr;
232 mutable QQuick3DSGRenderNode *m_renderNode =
nullptr;
233 mutable QQuick3DSGDirectRenderer *m_directRenderer =
nullptr;
234 bool m_renderModeDirty =
false;
235 RenderMode m_renderMode = Offscreen;
236#if QT_CONFIG(quick_shadereffect)
237 QQuickShaderEffectSource::Format m_renderFormat = QQuickShaderEffectSource::RGBA8;
239 int m_explicitTextureWidth = 0;
240 int m_explicitTextureHeight = 0;
241 QSize m_effectiveTextureSize;
242 float m_widthMultiplier = 1.0f;
243 float m_heightMultiplier = 1.0f;
244 QQuick3DRenderStats *m_renderStats =
nullptr;
245 bool m_enableInputProcessing =
false;
246 QQuick3DLightmapBaker *m_lightmapBaker =
nullptr;
247 QList<QQuick3DObject *> m_extensions;
248 bool m_extensionListDirty =
false;
249 bool m_isXrViewInstance =
false;
252 QQuickItem *target =
nullptr;
254 bool isPressed =
false;
256 QPointingDevice *m_syntheticTouchDevice =
nullptr;
257 QVarLengthArray<TouchState, 2> m_touchState{2};
259 QPointer<QQuickItem> m_prevMouseItem =
nullptr;
260 QPointF m_prevMousePos;