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