Qt Quick 3D - 피킹 예시
모델 선택 기능을 시연합니다.
이 예제는 선택 기능을 보여줍니다. 선택할 수 있는 3가지 서로 다른 애니메이션 모델이 있습니다. 모델을 선택하면 애니메이션이 중지되고 모델의 색상이 변경되어 어떤 모델이 선택되었는지 명확하게 알 수 있습니다. 선택 결과에 대한 상세 정보는 애플리케이션 창 상단에 표시됩니다.

모델 선택 가능하게 만들기
모델을 선택 가능하게 하려면 ` pickable ` 속성을 ` true`로 설정해야 합니다. 또한 선택된 모델의 이름을 표시할 수 있도록 모델에 ` objectName ` 속성을 추가합니다.
Model {
id: cubeModel
objectName: "Cube"
source: "#Cube"
pickable: true
property bool isPicked: falseisPicked 속성은 애니메이션과 색상을 전환하는 데 사용하도록 추가되었습니다.
materials: PrincipledMaterial {
baseColor: cubeModel.isPicked ? "#41cd52" : "#09102b"
...
SequentialAnimation on eulerRotation {
running: !cubeModel.isPicked선택 결과 가져오기
실제 선택을 수행하려면 View3D 전체를 덮을 수 있는 MouseArea 을 추가해야 합니다.
MouseArea {
anchors.fill: view마우스 영역의 ` onClicked ` 핸들러에서 ` pick ` 메서드를 사용하여 선택의 실제 결과를 가져옵니다.
var result = view.pick(mouse.x, mouse.y);결과에 target object 가 포함되어 있으면, 결과의 세부 사항을 확인하고 애플리케이션 뷰 상단의 텍스트 필드에 표시합니다.
if (result.objectHit) {
var pickedObject = result.objectHit;
// Toggle the isPicked property for the model
pickedObject.isPicked = !pickedObject.isPicked;
// Get picked model name
pickName.text = pickedObject.objectName;
// Get other pick specifics
uvPosition.text = "("
+ result.uvPosition.x.toFixed(2) + ", "
+ result.uvPosition.y.toFixed(2) + ")";
distance.text = result.distance.toFixed(2);
scenePosition.text = "("
+ result.scenePosition.x.toFixed(2) + ", "
+ result.scenePosition.y.toFixed(2) + ", "
+ result.scenePosition.z.toFixed(2) + ")";
localPosition.text = "("
+ result.position.x.toFixed(2) + ", "
+ result.position.y.toFixed(2) + ", "
+ result.position.z.toFixed(2) + ")";
worldNormal.text = "("
+ result.sceneNormal.x.toFixed(2) + ", "
+ result.sceneNormal.y.toFixed(2) + ", "
+ result.sceneNormal.z.toFixed(2) + ")";
localNormal.text = "("
+ result.normal.x.toFixed(2) + ", "
+ result.normal.y.toFixed(2) + ", "
+ result.normal.z.toFixed(2) + ")";© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.