hit test view fix
This commit is contained in:
parent
da42c146bd
commit
e8c635c139
|
|
@ -8,8 +8,8 @@ export const HitTestView = observer(function ({ float }: { float: boolean }) {
|
|||
|
||||
const style: CSSProperties = {};
|
||||
if (float) {
|
||||
style.left = state.mousePosition.x;
|
||||
style.top = state.mousePosition.y;
|
||||
style.left = 0; //state.mousePosition.x;
|
||||
style.top = 0; // state.mousePosition.y;
|
||||
style.width = 'auto';
|
||||
style.height = 'auto';
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ export const HitTestView = observer(function ({ float }: { float: boolean }) {
|
|||
<pre style={{ textWrap: 'wrap' }}>
|
||||
{
|
||||
state.hitResults.hits.map((hit) =>
|
||||
<div key={hit.id}>
|
||||
<div key={hit.faceId + '-' + hit.id}>
|
||||
<div>{yaml.stringify(
|
||||
{
|
||||
hit: { ...hit, intersection: { ...hit.intersection, point: formatPoint(hit.intersection.point), object: undefined, triangle: undefined } },
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ export type BaseHitResult = {
|
|||
export type FaceHitResult = BaseHitResult & {
|
||||
kind: 'face',
|
||||
id?: Id,
|
||||
faceId: Id,
|
||||
}
|
||||
|
||||
export type EdgeHitResult = BaseHitResult & {
|
||||
|
|
@ -112,9 +113,9 @@ function classifyTriangleHit(
|
|||
const onBC = u < BARYCENTRIC_EPSILON;
|
||||
const onCA = v < BARYCENTRIC_EPSILON;
|
||||
|
||||
if (onAB) return { kind: 'edge', index: 0, id: 'none' };
|
||||
if (onBC) return { kind: 'edge', index: 1, id: 'none' };
|
||||
if (onCA) return { kind: 'edge', index: 2, id: 'none' };
|
||||
if (onAB) return { kind: 'edge', index: 0, id: `${vertexIds?.[0]}-${vertexIds?.[1]}` };
|
||||
if (onBC) return { kind: 'edge', index: 1, id: `${vertexIds?.[1]}-${vertexIds?.[2]}` };
|
||||
if (onCA) return { kind: 'edge', index: 2, id: `${vertexIds?.[2]}-${vertexIds?.[0]}` };
|
||||
|
||||
return { kind: 'face' };
|
||||
}
|
||||
|
|
@ -383,23 +384,33 @@ export class CircularFrustumIntersection {
|
|||
|
||||
const results: HitResult[] = [{
|
||||
kind: 'face',
|
||||
intersection,
|
||||
id: faceId,
|
||||
faceId,
|
||||
intersection: {
|
||||
...intersection,
|
||||
triHit: undefined,
|
||||
},
|
||||
}];
|
||||
if (intersection.triHit?.kind === 'edge') {
|
||||
results.unshift({
|
||||
kind: 'edge',
|
||||
intersection,
|
||||
id: intersection.triHit?.id,
|
||||
faceId,
|
||||
intersection: {
|
||||
...intersection,
|
||||
triHit: undefined,
|
||||
},
|
||||
});
|
||||
}
|
||||
if (intersection.triHit?.kind === 'vertex') {
|
||||
results.unshift({
|
||||
kind: 'vertex',
|
||||
intersection,
|
||||
id: intersection.triHit?.id,
|
||||
faceId,
|
||||
intersection: {
|
||||
...intersection,
|
||||
triHit: undefined,
|
||||
},
|
||||
});
|
||||
}
|
||||
return results;
|
||||
|
|
|
|||
Loading…
Reference in New Issue