How the geometry of solids is shown, and the bounds of a model. The three.js geometry itself, made from the
graphic ClassCAD sends, is for apps that work with faces and edges directly.
type GeometryConfig = {
disabled?: boolean;
edges?: ElementConfig;
meshes?: ElementConfig & {
depthWrite?: boolean;
wireframe?: boolean;
};
points?: ElementConfig;
};
How the geometry of solids is shown in the 3D view of @buerli.io/react.
It is set for all solids (config.geometry in the options of init of @buerli.io/classcad), and for a
product or a solid with setConfig of a drawing's api.geometry; the solid's goes over the product's, which
goes over the one for all.
import { init, WASMClient } from '@buerli.io/classcad'
import { getDrawing } from '@buerli.io/core'
init(drawingId => new WASMClient(drawingId, { token: 'ccpk_…' }), {
config: { geometry: { edges: { color: '#333333' }, points: { hidden: true } } },
})
getDrawing(drawingId).api.geometry.setConfig(solidId, { disabled: true, meshes: { wireframe: true } })
getDrawing(drawingId).api.geometry.setConfig(solidId, null)
| Property | Type | Description |
|---|
disabled? | boolean | Shows the faces faded (opacity 0.1), and lets the pointer pass through the geometry. |
edges? | ElementConfig | How the edges are shown: hidden, color and opacity (for edges without their own). Hidden edges are still picked by the pointer. |
meshes? | ElementConfig & { depthWrite?: boolean; wireframe?: boolean; } | How the faces are shown: hidden, color, opacity (0 to 1, for faces without their own), wireframe to draw them as lines, and depthWrite: false to let what is behind them show. |
points? | ElementConfig | How the points are shown: hidden, color and opacity. |
type GeometryBounds = {
center: THREE.Vector3;
max: THREE.Vector3;
min: THREE.Vector3;
radius: number;
};
The bounds of a model, in world coordinates: a box (min, max) and the sphere around it (center, radius).
geometry.bounds of a drawing holds the bounds of all its products, for example to fit the camera; it changes
when graphic comes in or products are added or removed. Before there is any, it is a box from -100 to 100.
import { getDrawing } from '@buerli.io/core'
import * as THREE from 'three'
const { center, radius } = getDrawing(drawingId).geometry.bounds
camera.position.copy(center).add(new THREE.Vector3(0, 0, radius * 3))
camera.lookAt(center)
| Property | Type | Description |
|---|
center | THREE.Vector3 | The center of the box and of the sphere. |
max | THREE.Vector3 | The box's largest corner. |
min | THREE.Vector3 | The box's smallest corner. |
radius | number | The radius of the sphere around the box. |
Most apps do not need these directly: types they meet through the exports above, and what is there for special cases or for building on buerli itself.
An arc or a circle of a solid (or of a sketch), as three.js line segments, with its center, radius and plane.
import { ScgGraphicType } from '@buerli.io/classcad'
import { getDrawing } from '@buerli.io/core'
const arcs = getDrawing(drawingId).geometry.cache[solidId]?.arcs ?? []
for (const circle of arcs.filter(arc => arc.type === ScgGraphicType.CIRCLE)) {
console.log(circle.center.toArray(), circle.radius * 2)
}
| Property | Type | Description |
|---|
angle | number | The angle the arc spans, in radians. |
center | Vector3 | The center. |
color | Color | undefined | The color ClassCAD gave it (its material), if any. |
container | { id: number; ownerId: number; type: NONE | BREP | POLYBREP | CURVEARRAY; } | The container (solid) it is in. |
container.id | number | The container's id, the solid's CAD entity, as in geometry.cache. |
container.ownerId | number | The solid object it belongs to, in the structure tree. |
container.type | NONE | BREP | POLYBREP | CURVEARRAY | What kind of container: brep, polyBrep or curveArray. |
end | Vector3 | Where it ends; where it starts for a circle. |
geometry | BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap> | The arc, as line segments. |
graphicId | number | The edge's id in its container. |
layer | any | The layer ClassCAD put it on. |
normal | Vector3 | The normal of the arc's plane, of length 1. |
opacity | number | The opacity ClassCAD gave it, from 0 to 1; 0 when it has none. |
operationId | any | The operation (feature) that made a face. |
radius | number | The radius. |
rawGraphic | ScgGraphicElement | null | The element as ClassCAD sent it (ScgGraphicElement). |
start | Vector3 | Where the arc starts. |
type | ScgGraphicType | arc or circle, or curveArc or curveCircle in a sketch's curves. |
type CircleGeometry = ArcGeometry;
A circle of a solid: an ArcGeometry whose type is circle (or curveCircle).
A conical face of a solid: a MeshGeometry with its cone.
| Property | Type | Description |
|---|
axis | Vector3 | The cone's axis, of length 1. |
color | Color | undefined | The color ClassCAD gave it (its material), if any. |
container | { id: number; ownerId: number; type: NONE | BREP | POLYBREP | CURVEARRAY; } | The container (solid) it is in. |
container.id | number | The container's id, the solid's CAD entity, as in geometry.cache. |
container.ownerId | number | The solid object it belongs to, in the structure tree. |
container.type | NONE | BREP | POLYBREP | CURVEARRAY | What kind of container: brep, polyBrep or curveArray. |
geometry | BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap> | The face's triangles, with normals. |
graphicId | number | The face's id in its container. |
height | number | Its height along the axis. |
isValid | boolean | Whether the face has vertices; faces without are left out. |
layer | any | The layer ClassCAD put it on. |
loops | number[][] | The loops of edges around the face, each a list of edge ids. |
opacity | number | The opacity ClassCAD gave it, from 0 to 1; 0 when it has none. |
operationId | any | The operation (feature) that made a face. |
origin | Vector3 | The center of the cone's base. |
radiusBottom | number | The radius at the base. |
radiusTop | number | The radius at the top. |
rawGraphic | ScgGraphicElement | null | The element as ClassCAD sent it (ScgGraphicElement). |
type | ScgGraphicType | cone. |
The three.js geometry of a container, a solid: its faces, edges and points, made from the graphic ClassCAD sent.
geometry.cache of a drawing holds it by container id, the ids in solids of a part. Its coordinates are those
of the part; the product's transformation (api.structure.calculateGlobalTransformation) places it in the world.
import { getDrawing } from '@buerli.io/core'
const { geometry, structure } = getDrawing(drawingId)
const part = structure.currentProduct ? structure.tree[structure.currentProduct] : undefined
const faces = (part?.solids ?? []).flatMap(id => geometry.cache[id]?.meshes.map(mesh => mesh.geometry) ?? [])
| Property | Type | Description |
|---|
arcs | ArcGeometry[] | The arcs and circles. |
box | { max: Vector3; min: Vector3; } | The bounding box, in the coordinates of the part. |
box.max | Vector3 | Its largest corner. |
box.min | Vector3 | Its smallest corner. |
color | Color | undefined | The color ClassCAD gave it (its material), if any. |
container | { id: number; ownerId: number; type: NONE | BREP | POLYBREP | CURVEARRAY; } | The container (solid) it is in. |
container.id | number | The container's id, the solid's CAD entity, as in geometry.cache. |
container.ownerId | number | The solid object it belongs to, in the structure tree. |
container.type | NONE | BREP | POLYBREP | CURVEARRAY | What kind of container: brep, polyBrep or curveArray. |
edges | EdgeGeometry[] | The other curved edges. |
graphicId | number | The container's id, the solid's CAD entity. |
layer | any | The layer ClassCAD put it on. |
lines | LineGeometry[] | The straight edges. |
map | Record<GraphicID, GeometryElement> | The faces and edges by id. |
meshes | MeshGeometry[] | The faces. |
opacity | number | The opacity ClassCAD gave it, from 0 to 1; 0 when it has none. |
operationId | any | The operation (feature) that made a face. |
points | PointGeometry[] | The points, the ends of the edges. |
rawGraphic | ScgGraphicElement | null | The element as ClassCAD sent it (ScgGraphicElement). |
type | ScgGraphicType | The kind of container: brep for a solid, polyBrep for a mesh solid, curveArray for a sketch's curves. |
A cylindrical face of a solid: a MeshGeometry with its cylinder.
| Property | Type | Description |
|---|
axis | Vector3 | The cylinder's axis, of length 1. |
color | Color | undefined | The color ClassCAD gave it (its material), if any. |
container | { id: number; ownerId: number; type: NONE | BREP | POLYBREP | CURVEARRAY; } | The container (solid) it is in. |
container.id | number | The container's id, the solid's CAD entity, as in geometry.cache. |
container.ownerId | number | The solid object it belongs to, in the structure tree. |
container.type | NONE | BREP | POLYBREP | CURVEARRAY | What kind of container: brep, polyBrep or curveArray. |
geometry | BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap> | The face's triangles, with normals. |
graphicId | number | The face's id in its container. |
height | number | Its height along the axis. |
isValid | boolean | Whether the face has vertices; faces without are left out. |
layer | any | The layer ClassCAD put it on. |
loops | number[][] | The loops of edges around the face, each a list of edge ids. |
opacity | number | The opacity ClassCAD gave it, from 0 to 1; 0 when it has none. |
operationId | any | The operation (feature) that made a face. |
origin | Vector3 | The center of the cylinder's base. |
radius | number | Its radius. |
rawGraphic | ScgGraphicElement | null | The element as ClassCAD sent it (ScgGraphicElement). |
type | ScgGraphicType | cylinder. |
A curved edge of a solid that is not an arc (or a spline of a sketch), as three.js line segments, with its ends.
| Property | Type | Description |
|---|
color | Color | undefined | The color ClassCAD gave it (its material), if any. |
container | { id: number; ownerId: number; type: NONE | BREP | POLYBREP | CURVEARRAY; } | The container (solid) it is in. |
container.id | number | The container's id, the solid's CAD entity, as in geometry.cache. |
container.ownerId | number | The solid object it belongs to, in the structure tree. |
container.type | NONE | BREP | POLYBREP | CURVEARRAY | What kind of container: brep, polyBrep or curveArray. |
end | Vector3 | Where it ends. |
geometry | BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap> | The curve, as line segments. |
graphicId | number | The edge's id in its container. |
layer | any | The layer ClassCAD put it on. |
opacity | number | The opacity ClassCAD gave it, from 0 to 1; 0 when it has none. |
operationId | any | The operation (feature) that made a face. |
rawGraphic | ScgGraphicElement | null | The element as ClassCAD sent it (ScgGraphicElement). |
start | Vector3 | Where the curve starts. |
type | ScgGraphicType | nurbsCurve, or curveSpline in a sketch's curves. |
type GeometryElement =
| MeshGeometry
| PlaneGeometry
| CylinderGeometry
| ConeGeometry
| SphereGeometry
| LineGeometry
| EdgeGeometry
| ArcGeometry
| CircleGeometry
| PointGeometry;
An element of the geometry of a solid: a face, an edge or a point.
Its type (a GraphicType) tells which: plane, cylinder, cone, sphere and nurbsSurface are faces
(MeshGeometry), line, arc, circle and nurbsCurve edges, point a point.
import { ScgGraphicType } from '@buerli.io/classcad'
import { CylinderGeometry, getDrawing } from '@buerli.io/core'
const { api } = getDrawing(drawingId)
const cylinders = api.geometry.filter(elem => elem.type === ScgGraphicType.CYLINDER) as CylinderGeometry[]
cylinders.forEach(cylinder => console.log(cylinder.graphicId, cylinder.radius))
function isEqualGeometry(a, b): boolean;
Returns whether two elements of the geometry are the same: the same graphicId and type.
boolean
A straight edge of a solid (or a line of a sketch), as three.js geometry, with its ends.
| Property | Type | Description |
|---|
color | Color | undefined | The color ClassCAD gave it (its material), if any. |
container | { id: number; ownerId: number; type: NONE | BREP | POLYBREP | CURVEARRAY; } | The container (solid) it is in. |
container.id | number | The container's id, the solid's CAD entity, as in geometry.cache. |
container.ownerId | number | The solid object it belongs to, in the structure tree. |
container.type | NONE | BREP | POLYBREP | CURVEARRAY | What kind of container: brep, polyBrep or curveArray. |
end | Vector3 | Where it ends. |
geometry | BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap> | The line, as a line segment. |
graphicId | number | The edge's id in its container. |
layer | any | The layer ClassCAD put it on. |
opacity | number | The opacity ClassCAD gave it, from 0 to 1; 0 when it has none. |
operationId | any | The operation (feature) that made a face. |
rawGraphic | ScgGraphicElement | null | The element as ClassCAD sent it (ScgGraphicElement). |
start | Vector3 | Where the line starts. |
type | ScgGraphicType | line, or curveLine in a sketch's curves. |
A face of a solid, as three.js geometry: its triangles, its kind, and the loops of edges around it.
A planar, cylindrical, conical or spherical face is a PlaneGeometry, CylinderGeometry,
ConeGeometry or SphereGeometry, with what describes its surface. Its coordinates are those of its
part; the product's transformation (api.structure.calculateGlobalTransformation) places it in the world.
import { getDrawing, MeshGeometry } from '@buerli.io/core'
import * as THREE from 'three'
const { api, geometry } = getDrawing(drawingId)
const face = geometry.cache[solidId]?.map[faceId] as MeshGeometry | undefined
if (face) {
const mesh = new THREE.Mesh(face.geometry, new THREE.MeshStandardMaterial({ color: 'orange' }))
mesh.applyMatrix4(api.structure.calculateGlobalTransformation(productId))
scene.add(mesh)
}
| Property | Type | Description |
|---|
color | Color | undefined | The color ClassCAD gave it (its material), if any. |
container | { id: number; ownerId: number; type: NONE | BREP | POLYBREP | CURVEARRAY; } | The container (solid) it is in. |
container.id | number | The container's id, the solid's CAD entity, as in geometry.cache. |
container.ownerId | number | The solid object it belongs to, in the structure tree. |
container.type | NONE | BREP | POLYBREP | CURVEARRAY | What kind of container: brep, polyBrep or curveArray. |
geometry | BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap> | The face's triangles, with normals. |
graphicId | number | The face's id in its container. |
isValid | boolean | Whether the face has vertices; faces without are left out. |
layer | any | The layer ClassCAD put it on. |
loops | number[][] | The loops of edges around the face, each a list of edge ids. |
opacity | number | The opacity ClassCAD gave it, from 0 to 1; 0 when it has none. |
operationId | any | The operation (feature) that made a face. |
rawGraphic | ScgGraphicElement | null | The element as ClassCAD sent it (ScgGraphicElement). |
type | ScgGraphicType | The kind of face: plane, cylinder, cone, sphere or nurbsSurface. |
A planar face of a solid: a MeshGeometry with its plane.
| Property | Type | Description |
|---|
color | Color | undefined | The color ClassCAD gave it (its material), if any. |
container | { id: number; ownerId: number; type: NONE | BREP | POLYBREP | CURVEARRAY; } | The container (solid) it is in. |
container.id | number | The container's id, the solid's CAD entity, as in geometry.cache. |
container.ownerId | number | The solid object it belongs to, in the structure tree. |
container.type | NONE | BREP | POLYBREP | CURVEARRAY | What kind of container: brep, polyBrep or curveArray. |
geometry | BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap> | The face's triangles, with normals. |
graphicId | number | The face's id in its container. |
isValid | boolean | Whether the face has vertices; faces without are left out. |
layer | any | The layer ClassCAD put it on. |
loops | number[][] | The loops of edges around the face, each a list of edge ids. |
normal | Vector3 | The plane's normal, of length 1. |
opacity | number | The opacity ClassCAD gave it, from 0 to 1; 0 when it has none. |
operationId | any | The operation (feature) that made a face. |
pointOnPlane | Vector3 | A point of the plane. |
rawGraphic | ScgGraphicElement | null | The element as ClassCAD sent it (ScgGraphicElement). |
type | ScgGraphicType | plane. |
A point of a solid (or of a sketch): an end of edges, with the edges it is an end of.
| Property | Type | Description |
|---|
color | Color | undefined | The color ClassCAD gave it (its material), if any. |
container | { id: number; ownerId: number; type: NONE | BREP | POLYBREP | CURVEARRAY; } | The container (solid) it is in. |
container.id | number | The container's id, the solid's CAD entity, as in geometry.cache. |
container.ownerId | number | The solid object it belongs to, in the structure tree. |
container.type | NONE | BREP | POLYBREP | CURVEARRAY | What kind of container: brep, polyBrep or curveArray. |
geometry | Vector3 | Where the point is, as for position. |
graphicId | number | The point's id in its container. |
key | string | The point's key in its container, <graphicId>|point. |
layer | any | The layer ClassCAD put it on. |
opacity | number | The opacity ClassCAD gave it, from 0 to 1; 0 when it has none. |
operationId | any | The operation (feature) that made a face. |
owners | { ownerId: number; type: PointType; }[] & { ownerId: number; type: PointType; }[] | The edges the point is an end of: each edge's id (ownerId) and which end it is (type). |
position | Vector3 | Where the point is. |
rawGraphic | ScgGraphicElement | null | The element as ClassCAD sent it (ScgGraphicElement). |
type | ScgGraphicType | point, or curvePoint in a sketch's curves. |
type ProductElement = GeometryElement & {
productId: ObjectID;
};
An element of the geometry with the product it is in: the data of a SelectedItem in BuerliScope.
The product places the element in the world (see Measure.transform).
| Name | Type | Description |
|---|
productId | ObjectID | The product (part or assembly instance) the element belongs to. |
import { BuerliScope, getDrawing, ProductElement } from '@buerli.io/core'
const { selection } = getDrawing(drawingId)
const items = selection.active ? selection.refs[selection.active].items : []
const elements = items.filter(item => item.scope === BuerliScope).map(item => item.data as ProductElement)
A spherical face of a solid: a MeshGeometry with its radius.
| Property | Type | Description |
|---|
color | Color | undefined | The color ClassCAD gave it (its material), if any. |
container | { id: number; ownerId: number; type: NONE | BREP | POLYBREP | CURVEARRAY; } | The container (solid) it is in. |
container.id | number | The container's id, the solid's CAD entity, as in geometry.cache. |
container.ownerId | number | The solid object it belongs to, in the structure tree. |
container.type | NONE | BREP | POLYBREP | CURVEARRAY | What kind of container: brep, polyBrep or curveArray. |
geometry | BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap> | The face's triangles, with normals. |
graphicId | number | The face's id in its container. |
isValid | boolean | Whether the face has vertices; faces without are left out. |
layer | any | The layer ClassCAD put it on. |
loops | number[][] | The loops of edges around the face, each a list of edge ids. |
opacity | number | The opacity ClassCAD gave it, from 0 to 1; 0 when it has none. |
operationId | any | The operation (feature) that made a face. |
radius | number | The sphere's radius. |
rawGraphic | ScgGraphicElement | null | The element as ClassCAD sent it (ScgGraphicElement). |
type | ScgGraphicType | sphere. |