# Queries

Queries are a simple mechanism that allows the user to perform several operations in a contained way. The supported operations are

  • Project a point
  • Unproject a point
  • Intersection test
  • Occlusion test

Queries are not meant to be used directly, but rather through the viewer's query function

#

Typedefs

IntersectionQuery IntersectionQueryResult PointQuery PointQueryResult
Query QueryArgsResultMap QueryOperation QueryResult


# IntersectionQuery

interface IntersectionQuery extends Query {
  point: { x: number; y: number; z?: number; w?: number }
  tolerance?: number
  operation: 'Occlusion' | 'Pick'
}
1
2
3
4
5
  • point: The point to test for intersections
  • optional tolerance: Tolerance for intersection
  • operation: The query operation type

Based on the operation modes:

  • Occlusion: Test if a point in the scene is being occluded by the scene's geometry
  • Pick: Cast a camer ray to the specified point and return all intersection results

# IntersectionQueryResult

interface IntersectionQueryResult {
  objects: Array<{
    guid: string
    object?: Record<string, unknown>
    point: { x: number; y: number; z: number }
  }> | null
}
1
2
3
4
5
6
7
  • guid: The id of the object
  • optional object: The raw data of the intersected object
  • point: The point of intersection

# PointQuery

interface PointQuery extends Query {
  point: { x: number; y: number; z?: number; w?: number }
  operation: 'Project' | 'Unproject'
}
1
2
3
4
  • point: The point to run the operation on
  • operation: The operation type

Based on the operation modes:

  • Project: Projects a world point onto the screen. Result is in NDC
  • Unproject: Unprojects an NDC point into a world point

# PointQuery

interface PointQuery extends Query {
  point: { x: number; y: number; z?: number; w?: number }
  operation: 'Project' | 'Unproject'
}
1
2
3
4
  • point: The point to run the operation on
  • operation: The operation type

Based on the operation modes:

  • Project: Projects a world point onto the screen. Result is in NDC
  • Unproject: Unprojects an NDC point into a world point

# PointQueryResult

interface PointQueryResult {
  x: number
  y: number
  z?: number
  w?: number
}
1
2
3
4
5
6

The result is a point of variable component length

# PointQueryResult

interface Query {
  id?: string 
  operation: string
}
1
2
3
4
  • optional id: Currently unused
  • operation: The operation type

# QueryArgsResultMap

type QueryArgsResultMap = {
  Project: PointQueryResult
  Unproject: PointQueryResult
  Occlusion: IntersectionQueryResult
  Pick: IntersectionQueryResult
} & { [key: string]: unknown }
1
2
3
4
5
6

Mapping between the query type and query result type.

# QueryOperation

type QueryOperation = 'Project' | 'Unproject' | 'Occlusion' | 'Pick'
1

Query operation type values

# QueryResult

type QueryResult = PointQueryResult | IntersectionQueryResult
1

Query result type values