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;
110 Q_REVISION(6, 11) Q_INVOKABLE QQuick3DPickResult closestPointPick(
const QVector3D &origin,
float radius, QQuick3DModel *model =
nullptr)
const;
112 void processPointerEventFromRay(
const QVector3D &origin,
const QVector3D &direction, QPointerEvent *event)
const;
113 bool singlePointPick(QSinglePointEvent *event,
const QVector3D &origin,
const QVector3D &direction);
115 Q_REVISION(6, 8) Q_INVOKABLE
void setTouchpoint(QQuickItem *target,
const QPointF &position,
int pointId,
bool active);
117 QQuick3DLightmapBaker *maybeLightmapBaker();
118 QQuick3DLightmapBaker *lightmapBaker();
120 Q_INVOKABLE
void bakeLightmap();
121 Q_REVISION(6, 10) Q_INVOKABLE
void denoiseLightmap();
123 QQmlListProperty<QQuick3DObject> extensions();
125 Q_REVISION(6, 7)
int explicitTextureWidth()
const;
126 Q_REVISION(6, 7)
int explicitTextureHeight()
const;
127 Q_REVISION(6, 7) QSize effectiveTextureSize()
const;
130 [[nodiscard]]
bool extensionListDirty()
const {
return m_extensionListDirty; }
131 [[nodiscard]]
const QList<QQuick3DObject *> &extensionList()
const {
return m_extensions; }
132 void clearExtensionListDirty() { m_extensionListDirty =
false; }
134 Q_REVISION(6, 7) Q_INVOKABLE
void rebuildExtensionList();
136 enum class PrivateInstanceType : quint8 { XrViewInstance = 1 };
137 explicit QQuick3DViewport(PrivateInstanceType type, QQuickItem *parent =
nullptr);
138 [[nodiscard]]
bool isXrViewInstance()
const {
return m_isXrViewInstance; }
140 static void updateCameraForLayer(
const QQuick3DViewport &view3D, QSSGRenderLayer &layerNode);
143 void geometryChange(
const QRectF &newGeometry,
const QRectF &oldGeometry) override;
144 QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
145 void itemChange(QQuickItem::ItemChange change,
const QQuickItem::ItemChangeData &value) override;
147 bool event(QEvent *) override;
148 void componentComplete() override;
151 void setCamera(QQuick3DCamera *camera);
152 void setEnvironment(QQuick3DSceneEnvironment * environment);
153 void setImportScene(QQuick3DNode *inScene);
154 void setRenderMode(QQuick3DViewport::RenderMode renderMode);
155#if QT_CONFIG(quick_shadereffect)
156 Q_REVISION(6, 4)
void setRenderFormat(QQuickShaderEffectSource::Format format);
158 Q_REVISION(6, 7)
void setExplicitTextureWidth(
int width);
159 Q_REVISION(6, 7)
void setExplicitTextureHeight(
int height);
160 void cleanupDirectRenderer();
164 void setGlobalPickingEnabled(
bool isEnabled);
167 void invalidateSceneGraph();
168 void updateInputProcessing();
169 void onReleaseCachedResources();
172 void cameraChanged();
173 void environmentChanged();
175 void importSceneChanged();
176 void renderModeChanged();
177 Q_REVISION(6, 4)
void renderFormatChanged();
178 Q_REVISION(6, 7)
void explicitTextureWidthChanged();
179 Q_REVISION(6, 7)
void explicitTextureHeightChanged();
180 Q_REVISION(6, 7)
void effectiveTextureSizeChanged();
183 void setMultiViewCameras(QQuick3DCamera **firstCamera,
int count);
185 void setMultiViewCameras(QQuick3DCamera *(&cameras)[N])
187 static_assert(N > 1,
"Use setCamera for single view");
188 setMultiViewCameras(cameras, N);
191 friend class QQuick3DExtensionListHelper;
192 friend class QQuick3DXrManager;
193 friend class QQuick3DXrManagerPrivate;
194 friend class QQuick3DRenderLayerHelpers;
196 Q_DISABLE_COPY(QQuick3DViewport)
197 struct SubsceneInfo {
198 QQuick3DObject* obj =
nullptr;
199 QVarLengthArray<QPointF, 16> eventPointScenePositions;
201 QQuick3DSceneRenderer *getRenderer()
const;
202 void updateDynamicTextures();
203 QSGNode *setupOffscreenRenderer(QSGNode *node);
204 QSGNode *setupInlineRenderer(QSGNode *node);
205 void setupDirectRenderer(RenderMode mode);
206 bool checkIsVisible()
const;
207 bool internalPick(QPointerEvent *event,
const QVector3D &origin = QVector3D(),
const QVector3D &direction = QVector3D())
const;
208 QPair<QQuickItem *, QPointF> getItemAndPosition(
const QSSGRenderPickResult &pickResult)
const;
209 QVarLengthArray<QSSGRenderPickResult, 20> getPickResults(QQuick3DSceneRenderer *renderer,
const QVector3D &origin,
const QVector3D &direction)
const;
210 QVarLengthArray<QSSGRenderPickResult, 20> getPickResults(QQuick3DSceneRenderer *renderer,
const QEventPoint &eventPoint)
const;
211 bool forwardEventToSubscenes(QPointerEvent *event,
213 QQuick3DSceneRenderer *renderer,
214 const QFlatMap<QQuickItem *, SubsceneInfo> &visitedSubscenes)
const;
216 void processPickedObject(
const QSSGRenderPickResult &pickResult,
218 QPointerEvent *event,
219 QFlatMap<QQuickItem *, SubsceneInfo> &vistedSubscenes)
const;
220 QQuickItem *getSubSceneRootItem(QQuick3DMaterial *material)
const;
221 QQuick3DPickResult getNearestPickResult(
const QVarLengthArray<QSSGRenderPickResult, 20> &pickResults)
const;
222 QQuick3DPickResult processPickResult(
const QSSGRenderPickResult &pickResult)
const;
223 QQuick3DObject *findFrontendNode(
const QSSGRenderGraphObject *backendObject)
const;
224 QQuick3DSceneManager *findChildSceneManager(QQuick3DObject *inObject, QQuick3DSceneManager *manager =
nullptr);
225 void updateSceneManagerForImportScene();
226 QQuick3DCamera *m_camera =
nullptr;
227 QVarLengthArray<QQuick3DCamera *, 2> m_multiViewCameras;
228 QQuick3DSceneEnvironment *m_environment =
nullptr;
229 mutable QPointer<QQuick3DSceneEnvironment> m_builtInEnvironment;
230 QQuick3DSceneRootNode *m_sceneRoot =
nullptr;
231 QQuick3DNode *m_importScene =
nullptr;
232 mutable SGFramebufferObjectNode *m_node =
nullptr;
233 mutable QQuick3DSGRenderNode *m_renderNode =
nullptr;
234 mutable QQuick3DSGDirectRenderer *m_directRenderer =
nullptr;
235 bool m_renderModeDirty =
false;
236 RenderMode m_renderMode = Offscreen;
237#if QT_CONFIG(quick_shadereffect)
238 QQuickShaderEffectSource::Format m_renderFormat = QQuickShaderEffectSource::RGBA8;
240 int m_explicitTextureWidth = 0;
241 int m_explicitTextureHeight = 0;
242 QSize m_effectiveTextureSize;
243 float m_widthMultiplier = 1.0f;
244 float m_heightMultiplier = 1.0f;
245 QQuick3DRenderStats *m_renderStats =
nullptr;
246 bool m_enableInputProcessing =
false;
247 QQuick3DLightmapBaker *m_lightmapBaker =
nullptr;
248 QList<QQuick3DObject *> m_extensions;
249 bool m_extensionListDirty =
false;
250 bool m_isXrViewInstance =
false;
253 QQuickItem *target =
nullptr;
255 bool isPressed =
false;
257 QPointingDevice *m_syntheticTouchDevice =
nullptr;
258 QVarLengthArray<TouchState, 2> m_touchState{2};
260 QPointer<QQuickItem> m_prevMouseItem =
nullptr;
261 QPointF m_prevMousePos;