lingo3d
Version:
Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor
44 lines • 1.9 kB
JavaScript
import MeshAppendable from "../display/core/MeshAppendable";
import { appendableRoot } from "../collections/appendableRoot";
import { selectionCandidates } from "../collections/selectionCandidates";
import { emitSelectionTarget } from "../events/onSelectionTarget";
import { getSelectionFocus } from "../states/useSelectionFocus";
import { getSelectionFrozen } from "../states/useSelectionFrozen";
import throttleFrameTrailing from "./utils/throttleFrameTrailing";
import { selectionFrozenSet } from "../collections/selectionFrozenSet";
import { getFoundManager } from "../display/core/utils/getFoundManager";
const traverse = (targets) => {
for (const manager of targets) {
if (selectionFrozenSet.has(manager) || manager.$disableSelection)
continue;
"$addToRaycastSet" in manager &&
manager.$addToRaycastSet(selectionCandidates);
manager.children && traverse(manager.children);
}
};
const traverseFocusChildren = (selectionFocus) => {
selectionFocus.outerObject3d.traverse((child) => {
if (child === selectionFocus.outerObject3d ||
child === selectionFocus.object3d ||
child.type === "Line")
return;
const manager = getFoundManager(child, selectionFocus);
if (selectionFrozenSet.has(manager) || manager.$disableSelection)
return;
manager.$addToRaycastSet(selectionCandidates);
});
};
export const getSelectionCandidates = throttleFrameTrailing(() => {
selectionCandidates.clear();
const selectionFocus = getSelectionFocus();
if (selectionFocus)
selectionFocus instanceof MeshAppendable &&
traverseFocusChildren(selectionFocus);
else
traverse(appendableRoot);
});
getSelectionFrozen(() => {
getSelectionCandidates();
emitSelectionTarget(undefined);
});
//# sourceMappingURL=getSelectionCandidates.js.map