본문으로 건너뛰기

GetNearestObjects

적용 버전: VIZWide3D 3.0

두 점으로 정의된 레이와 교차하는 개체 검색

Parameters​

NameTypeDescription
startPtVIZCore.Vector3레이 시작점 (world)
endPtVIZCore.Vector3레이 끝점 (world)
[offset=0]Number검색 허용 오차 (world 단위).
0이면 레이와 직접 교차하는 개체만 반환.
0보다 크면 레이에서 offset 거리 이내에 있는 개체도 반환.
[nodeIDs=[]]Number[]검색할 nodeID 배열 (빈 배열 = 전체)
[visibleOnly=false]Boolean가시화된 개체만 검색
[opaqueOnly=false]Boolean불투명 개체만 검색

Returns​

TypeDescription
Promise<object>{results: [{fileKey, nodeID, axisDirection, inputPoint, collisionPoint, distance}]}

Example​

import VIZCore3DModule from "./VIZCore3D/VIZCore3D.js";

let main = document.createElement('div');
main.className = "VIZWeb_Main";

let view = document.createElement('div');
view.id = "view"
view.className = "VIZCore3D";
main.appendChild(view);

document.body.appendChild(main);
const vizcore = new VIZCore3DModule(view);

let onInitialize = function () {
const fileKey = "example"
const url = "./model/toycar/vizw/toycar_wh.vizw";

let onload = async (e) => {
//해당파일 다운로드 성공
console.log("onload::", e);

if (e.kind === vizcore.Enum.ImportFiledataKind.Meshblock) {
//모델 전체 BoundBox의 대각선(min→max)을 레이로 사용
let bbox = vizcore.Object3D.GetBoundBoxAll();

//레이와 교차하는 개체 검색 (offset 0 = 직접 교차만)
let getNearestObjects = await vizcore.Object3D.GetNearestObjects(bbox.min, bbox.max);
console.log("GetNearestObjects", getNearestObjects);
}
};

let onerror = function () {
//해당파일 다운로드 실패
console.log("onerror");
};

//모델 열기
vizcore.Model.OpenFile(fileKey, url, onload, onerror);
};

let vizcoreParam = {
event: {
onInit: onInitialize,
}
};

vizcore.Init(vizcoreParam);