Karana.Scene

Contents

Karana.Scene#

Classes and modules related to Scenes.

Submodules#

Attributes#

Classes#

AbstractStaticGeometry

Interface for static geometry types

Alignment

Text alignment/justification type

AssimpExporter

Exporter implementation backed by the third-party ASSIMP library.

AssimpImporter

AbstractImport implementation using the third-party ASSIMP library

BoxGeometry

Concrete box geometry class

CapsuleGeometry

Geometry class for a cylinder capped with hemispheres

CollisionInfo

CollisionScene

Scene with added collision-specific interface

CollisionSceneNode

CollisionScenePart

Color

Color class

ConeGeometry

Concrete cone geometry class

Contact

CylinderGeometry

Concrete cylinder geometry class

DistanceInfo

GraphicalScene

Scene with an added graphics-specific interface

GraphicalSceneCamera

GraphicalSceneNode

GraphicalScenePart

GrayscaleTexture

Texture specialization for grayscale values

HeightFieldGeometry

Center-origin 2D heightfield with fixed X/Y extents and sampled Z

ImportResult

OrthographicProjection

Info for an orthographic camera projection

PerspectiveProjection

Info for a perspective camera projection

PhongMaterial

A standard Phong material

PhongMaterialInfo

Parameter struct for a PhongMaterial

PhysicalMaterial

A standard PBR material

PhysicalMaterialInfo

Parameter struct for a PhysicalMaterial

RoundFrustumGeometry

Concrete round frustum geometry class

Scene

Base container for a hierarchy of geometries

SceneFileObject

Class for an opaque node with contents loaded from a file.

SceneFileObjectSpec

SceneFileObjectVars

The Vars for the SceneFileObject class.

SceneNode

Base for objects with a transform i n the scene hierarchy

SceneNodeVars

ScenePart

Class for objects with geometry and material in the scene

ScenePartSpec

ScenePartSpecVars

The Vars for the ScenePartSpec class.

ScenePartVars

The Vars for the ScenePart class.

SceneVars

SphereGeometry

Concrete sphere geometry class

StaticMeshGeometry

Concrete triangular mesh geometry class

TextParameters

Style parameters for text

Texture

Class for a texture image

TransformUpdateScope

RAII wrapper for beginTransformUpdates and endTransformUpdates

ProxyScene

A Scene implementation acting as a proxy to any number of registered

ProxySceneFileObject

ProxySceneFileObjectVars

The Vars for the ProxySceneFileObject class.

ProxySceneNode

ProxyScenePart

ProxyScenePartVars

The Vars for the ProxyScenePart class.

ProxySceneVars

WebScene

GraphicalScene implementation for web-based graphics

WebSceneFileObject

WebSceneNode

WebScenePart

CoalScene

CollisionScene implementation using the COAL library

CoalSceneFileObject

CoalSceneNode

CoalScenePart

Functions#

getConvexDecomposition(→ list[StaticMeshGeometry])

Decompose a triangle mesh into a union of convex hulls using the COACD library.

colorConvexDecomposition(→ list[tuple[float, float, ...)

Get a graph coloring for subhulls resulting from a convex decomposition.

defaultGeometry(...)

defaultMaterial(→ PhysicalMaterial | PhongMaterial)

Package Contents#

Karana.Scene.getConvexDecomposition(geom: StaticMeshGeometry, coacd_args: dict = {}, verbose: bool = False, dupe_vertices: bool = True) list[StaticMeshGeometry]#

Decompose a triangle mesh into a union of convex hulls using the COACD library.

Parameters:

geom (StaticMeshGeometry) – Original mesh to decompose.

Returns:

List of StaticMeshGeometry objects corresponding to each subhull.

Return type:

list[StaticMeshGeometry]

Karana.Scene.colorConvexDecomposition(geoms: list[StaticMeshGeometry], eps: float = 0.001) list[tuple[float, float, float]]#

Get a graph coloring for subhulls resulting from a convex decomposition.

Parameters:
  • geoms (list[StaticMeshGeometry]) – Subhulls which comprise the convex decomposition.

  • eps (float) – Tolerance under which to consider adjacent vertices “touching”.

Returns:

List of RGB tuples corresponding to colors for each hull

Return type:

list[tuple[float, float, float]]

class Karana.Scene.AbstractStaticGeometry#

Bases: Karana.Core.BaseWithVars

Interface for static geometry types

See Scene layer for more discussion on the scene layer.

aabb() Karana.Math.AABB#

Compute the axis-aligned bounding box (AABB)

Returns:

The AABB

computeMesh() StaticMeshGeometry#

Convert to a triangular mesh

Returns:

The converted mesh

getConvexity() bool#

Get whether the object is convex or not; used for some client scenes.

Returns:

Whether the item is convex. For some geometries this can be manually-marked.

class Karana.Scene.Alignment(*args, **kwds)#

Bases: enum.Enum

Text alignment/justification type

CENTER: ClassVar[Alignment]#
LEFT: ClassVar[Alignment]#
RIGHT: ClassVar[Alignment]#
class Karana.Scene.AssimpExporter#

Exporter implementation backed by the third-party ASSIMP library.

AssimpExporter converts every ScenePartSpec to a triangulated Assimp mesh and writes an Assimp scene to disk. The exporter calls AbstractStaticGeometry::computeMesh() for each geometry, so built-in primitives, height fields, imported meshes, and user-defined static geometry all share the same output path.

Materials are emitted as simple diffuse/specular or PBR-style scalar colors when the selected Assimp format supports them. Texture maps are referenced by filepath when they were created through kdFlex texture cache APIs and Texture::lookupFilepath() or GrayscaleTexture::lookupFilepath() can resolve the source image path.

clearFormatId() None#

Clear the concrete Assimp format id and return to extension-based detection.

exportTo(filename: os.PathLike | str | bytes, parts: collections.abc.Sequence[ScenePartSpec]) None#

Export scene part specifications through Assimp.

Parameters:
  • filename – Destination file. If no explicit format id was configured, the extension is mapped to an Assimp exporter id such as “obj”, “collada”, or “gltf2”.

  • parts – ScenePartSpec collection to write.

Raises:
  • std::invalid_argument – when the filename has no supported format extension.

  • std::runtime_error – when Assimp rejects or cannot write the scene.

formatId() str#

Get the configured Assimp format id.

Returns:

The configured format id, or an empty string when extension detection is active.

setFormatId(format_id: str) None#

Set a concrete Assimp format id.

Parameters:

format_id – Assimp exporter id, for example “obj”, “collada”, “gltf2”, or “stl”.

class Karana.Scene.AssimpImporter#

AbstractImport implementation using the third-party ASSIMP library

See Scene layer for more discussion on the scene layer.

importFrom(filename: os.PathLike | str | bytes, is_convex: bool = False) ImportResult#
setJoinIdenticalVertices(join: bool) None#

Set whether we should deduplicate vertices by joining identical ones. This can be more memory-efficient, but some scenes (e.g., SPH) prefer to have unique vertices per face.

Parameters:

join – Whether to join identical vertices

class Karana.Scene.BoxGeometry(width: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex, depth: SupportsFloat | SupportsIndex)#

Bases: AbstractStaticGeometry

Concrete box geometry class

See Scene layer for more discussion on the scene layer.

static create(width: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex, depth: SupportsFloat | SupportsIndex) BoxGeometry#

Create a new instance of BoxGeometry from side-lengths.

Parameters:
  • width – side length in the x direction

  • height – side length in the y direction

  • depth – side length in the z direction

Returns:

A pointer to the newly created instance of BoxGeometry.

__getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [3, 1]]#
__setstate__(arg0: Annotated[numpy.typing.ArrayLike, numpy.float32, [3, 1]]) None#
computeMesh() StaticMeshGeometry#

Convert to a triangular mesh

Returns:

The converted mesh

property depth: float#

side length in the z direction

property height: float#

side length in the y direction

property width: float#

side length in the x direction

classmethod to_yaml(representer, node)#

Class method used to represent BoxGeometry in a yaml file.

classmethod from_yaml(_, node) Self#

Construct a BoxGeometry from yaml file data.

static to_json(o: BoxGeometry) dict[str, Any]#

Class method used to represent BoxGeometry in a json file.

classmethod from_json(d: dict[str, Any]) Self#

Construct a BoxGeometry from json file data.

class Karana.Scene.CapsuleGeometry(radius: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex)#

Bases: AbstractStaticGeometry

Geometry class for a cylinder capped with hemispheres

See Scene layer for more discussion on the scene layer.

static create(radius: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex) CapsuleGeometry#

Create a new instance of CapsuleGeometry from radius and height.

Parameters:
  • radius – radius of the capsule

  • height – height of the capsule’s middle section

Returns:

A pointer to the newly created instance of BoxGeometry.

__getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [2, 1]]#
__setstate__(arg0: Annotated[numpy.typing.ArrayLike, numpy.float32, [2, 1]]) None#
property height: float#

height of the capsule’s middle section

property radius: float#

radius of the capsule

classmethod to_yaml(representer, node)#

Class method used to represent CapsuleGeometry in a yaml file.

classmethod from_yaml(_, node) Self#

Construct a CapsuleGeometry from yaml file data.

static to_json(o: CapsuleGeometry) dict[str, Any]#

Class method used to represent CapsuleGeometry in a json file.

classmethod from_json(d: dict[str, Any]) Self#

Construct a CapsuleGeometry from json file data.

class Karana.Scene.CollisionInfo#
static singleton() CollisionInfo#
__bool__() bool#
hasContact() bool#
property contacts: list[Contact]#
property part1: int#
property part2: int#
class Karana.Scene.CollisionScene#

Bases: Scene

Scene with added collision-specific interface

See Scene layer for more discussion on the scene layer.

broadphase(callback: collections.abc.Callable[[CollisionScenePart, CollisionScenePart], None]) None#

Do a coarse sweep over the scene check for potential collisions.

Parameters:

callback

  • Function called for each potential collision

cachedCollisions() list[CollisionInfo]#

Get a list of collisions from the last sweep

Returns:

The cached collisions

lookupPart(id: SupportsInt | SupportsIndex) CollisionScenePart#

Fetch a part by its id

Returns:

The part

sweep(callback: collections.abc.Callable[[CollisionInfo], None], filter: collections.abc.Callable[[CollisionScenePart, CollisionScenePart], bool] = None) None#

Do a sweep over the scene checking for collisions

Parameters:
  • callback

    • Function called for each collision

  • filter

    • Filter function called for each potential collision pair

toDS() Karana.Scene.Scene_types.CollisionSceneDS#

Create a CollisionSceneDS from this CollisionScene model.

Returns:

  • CollisionSceneDS

  • A CollisionSceneDS instance with values set to match this model.

class Karana.Scene.CollisionSceneNode#

Bases: SceneNode

class Karana.Scene.CollisionScenePart#

Bases: ScenePart, CollisionSceneNode

collide(other: CollisionScenePart) CollisionInfo#
collide(other: CollisionScenePart, result: CollisionInfo) CollisionInfo
distance(other: CollisionScenePart) DistanceInfo#
distance(other: CollisionScenePart, result: DistanceInfo) DistanceInfo
class Karana.Scene.Color(other: Color)#

Color class

See Scene layer for more discussion on the scene layer.

ALICEBLUE: ClassVar[Color]#
ANTIQUEWHITE: ClassVar[Color]#
AQUA: ClassVar[Color]#
AQUAMARINE: ClassVar[Color]#
AZURE: ClassVar[Color]#
BEIGE: ClassVar[Color]#
BISQUE: ClassVar[Color]#
BLACK: ClassVar[Color]#
BLANCHEDALMOND: ClassVar[Color]#
BLUE: ClassVar[Color]#
BLUEVIOLET: ClassVar[Color]#
BROWN: ClassVar[Color]#
BURLYWOOD: ClassVar[Color]#
CADETBLUE: ClassVar[Color]#
CHARTREUSE: ClassVar[Color]#
CHOCOLATE: ClassVar[Color]#
CORAL: ClassVar[Color]#
CORNFLOWERBLUE: ClassVar[Color]#
CORNSILK: ClassVar[Color]#
CRIMSON: ClassVar[Color]#
CYAN: ClassVar[Color]#
DARKBLUE: ClassVar[Color]#
DARKCYAN: ClassVar[Color]#
DARKGOLDENROD: ClassVar[Color]#
DARKGRAY: ClassVar[Color]#
DARKGREEN: ClassVar[Color]#
DARKGREY: ClassVar[Color]#
DARKKHAKI: ClassVar[Color]#
DARKMAGENTA: ClassVar[Color]#
DARKOLIVEGREEN: ClassVar[Color]#
DARKORANGE: ClassVar[Color]#
DARKORCHID: ClassVar[Color]#
DARKRED: ClassVar[Color]#
DARKSALMON: ClassVar[Color]#
DARKSEAGREEN: ClassVar[Color]#
DARKSLATEBLUE: ClassVar[Color]#
DARKSLATEGRAY: ClassVar[Color]#
DARKSLATEGREY: ClassVar[Color]#
DARKTURQUOISE: ClassVar[Color]#
DARKVIOLET: ClassVar[Color]#
DEEPPINK: ClassVar[Color]#
DEEPSKYBLUE: ClassVar[Color]#
DIMGRAY: ClassVar[Color]#
DIMGREY: ClassVar[Color]#
DODGERBLUE: ClassVar[Color]#
FIREBRICK: ClassVar[Color]#
FLORALWHITE: ClassVar[Color]#
FORESTGREEN: ClassVar[Color]#
FUCHSIA: ClassVar[Color]#
GAINSBORO: ClassVar[Color]#
GHOSTWHITE: ClassVar[Color]#
GOLD: ClassVar[Color]#
GOLDENROD: ClassVar[Color]#
GRAY: ClassVar[Color]#
GREEN: ClassVar[Color]#
GREENYELLOW: ClassVar[Color]#
GREY: ClassVar[Color]#
HONEYDEW: ClassVar[Color]#
HOTPINK: ClassVar[Color]#
INDIANRED: ClassVar[Color]#
INDIGO: ClassVar[Color]#
IVORY: ClassVar[Color]#
KHAKI: ClassVar[Color]#
LAVENDER: ClassVar[Color]#
LAVENDERBLUSH: ClassVar[Color]#
LAWNGREEN: ClassVar[Color]#
LEMONCHIFFON: ClassVar[Color]#
LIGHTBLUE: ClassVar[Color]#
LIGHTCORAL: ClassVar[Color]#
LIGHTCYAN: ClassVar[Color]#
LIGHTGOLDENRODYELLOW: ClassVar[Color]#
LIGHTGRAY: ClassVar[Color]#
LIGHTGREEN: ClassVar[Color]#
LIGHTGREY: ClassVar[Color]#
LIGHTPINK: ClassVar[Color]#
LIGHTSALMON: ClassVar[Color]#
LIGHTSEAGREEN: ClassVar[Color]#
LIGHTSKYBLUE: ClassVar[Color]#
LIGHTSLATEGRAY: ClassVar[Color]#
LIGHTSLATEGREY: ClassVar[Color]#
LIGHTSTEELBLUE: ClassVar[Color]#
LIGHTYELLOW: ClassVar[Color]#
LIME: ClassVar[Color]#
LIMEGREEN: ClassVar[Color]#
LINEN: ClassVar[Color]#
MAGENTA: ClassVar[Color]#
MAROON: ClassVar[Color]#
MEDIUMAQUAMARINE: ClassVar[Color]#
MEDIUMBLUE: ClassVar[Color]#
MEDIUMORCHID: ClassVar[Color]#
MEDIUMPURPLE: ClassVar[Color]#
MEDIUMSEAGREEN: ClassVar[Color]#
MEDIUMSLATEBLUE: ClassVar[Color]#
MEDIUMSPRINGGREEN: ClassVar[Color]#
MEDIUMTURQUOISE: ClassVar[Color]#
MEDIUMVIOLETRED: ClassVar[Color]#
MIDNIGHTBLUE: ClassVar[Color]#
MINTCREAM: ClassVar[Color]#
MISTYROSE: ClassVar[Color]#
MOCCASIN: ClassVar[Color]#
NAVAJOWHITE: ClassVar[Color]#
NAVY: ClassVar[Color]#
OLDLACE: ClassVar[Color]#
OLIVE: ClassVar[Color]#
OLIVEDRAB: ClassVar[Color]#
ORANGE: ClassVar[Color]#
ORANGERED: ClassVar[Color]#
ORCHID: ClassVar[Color]#
PALEGOLDENROD: ClassVar[Color]#
PALEGREEN: ClassVar[Color]#
PALETURQUOISE: ClassVar[Color]#
PALEVIOLETRED: ClassVar[Color]#
PAPAYAWHIP: ClassVar[Color]#
PEACHPUFF: ClassVar[Color]#
PERU: ClassVar[Color]#
PINK: ClassVar[Color]#
PLUM: ClassVar[Color]#
POWDERBLUE: ClassVar[Color]#
PURPLE: ClassVar[Color]#
REBECCAPURPLE: ClassVar[Color]#
RED: ClassVar[Color]#
ROSYBROWN: ClassVar[Color]#
ROYALBLUE: ClassVar[Color]#
SADDLEBROWN: ClassVar[Color]#
SALMON: ClassVar[Color]#
SANDYBROWN: ClassVar[Color]#
SEAGREEN: ClassVar[Color]#
SEASHELL: ClassVar[Color]#
SIENNA: ClassVar[Color]#
SILVER: ClassVar[Color]#
SKYBLUE: ClassVar[Color]#
SLATEBLUE: ClassVar[Color]#
SLATEGRAY: ClassVar[Color]#
SLATEGREY: ClassVar[Color]#
SNOW: ClassVar[Color]#
SPRINGGREEN: ClassVar[Color]#
STEELBLUE: ClassVar[Color]#
TAN: ClassVar[Color]#
TEAL: ClassVar[Color]#
THISTLE: ClassVar[Color]#
TOMATO: ClassVar[Color]#
TURQUOISE: ClassVar[Color]#
VIOLET: ClassVar[Color]#
WHEAT: ClassVar[Color]#
WHITE: ClassVar[Color]#
WHITESMOKE: ClassVar[Color]#
YELLOW: ClassVar[Color]#
YELLOWGREEN: ClassVar[Color]#
__hash__: ClassVar[None] = None#
static fromHex(hex_str: str, alpha: SupportsFloat | SupportsIndex = 1.0) Color#

Create a color from a hex string and opacity

The hex_str input is parsed to extract red, green, and blue components. For example, “ff0000” and “f00” are pure red.

Parameters:
  • hex_str – a 3 or 6 length hex string

  • alpha – the opacity factor between 0 and 1

Returns:

the created Color

static fromRGB(r: SupportsFloat | SupportsIndex, g: SupportsFloat | SupportsIndex, b: SupportsFloat | SupportsIndex) Color#

Create an opaque color from rgb components

Parameters:
  • r – the red component between 0 and 1

  • g – the green component between 0 and 1

  • b – the blue component between 0 and 1

Returns:

the created Color

static fromRGBA(r: SupportsFloat | SupportsIndex, g: SupportsFloat | SupportsIndex, b: SupportsFloat | SupportsIndex, alpha: SupportsFloat | SupportsIndex) Color#

Create a color from rgb components and opacity

Parameters:
  • r – the red component between 0 and 1

  • g – the green component between 0 and 1

  • b – the blue component between 0 and 1

  • alpha – the opacity factor between 0 and 1

Returns:

the created Color

__eq__(other: Color) bool#

Equality operator.

Parameters:

other – Another Color to compare with.

Returns:

True if all components are equal.

__getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [4, 1]]#
__repr__() str#
__setstate__(arg0: Annotated[numpy.typing.ArrayLike, numpy.float32, [4, 1]]) None#
alpha() float#

Get the alpha (opacity) value

Returns:

The alpha value

b() float#

Get the blue component

Returns:

The blue component

g() float#

Get the green component

Returns:

The green component

r() float#

Get the red component

Returns:

The red component

classmethod to_yaml(representer, node)#

Class method used to represent Color in a yaml file.

classmethod from_yaml(_, node) Self#

Construct a Color from yaml file data.

static to_json(o: Color) dict[str, Any]#

Class method used to represent Color in a json file.

classmethod from_json(d: dict[str, Any]) Self#

Construct a Color from json file data.

class Karana.Scene.ConeGeometry(radius: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex)#

Bases: AbstractStaticGeometry

Concrete cone geometry class

See Scene layer for more discussion on the scene layer.

static create(radius: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex) ConeGeometry#

Create a new instance of ConeGeometry from radius and height.

Parameters:
  • radius – radius of the capsule

  • height – height of the capsule’s middle section

Returns:

A pointer to the newly created instance of BoxGeometry.

__getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [2, 1]]#
__setstate__(arg0: Annotated[numpy.typing.ArrayLike, numpy.float32, [2, 1]]) None#
property height: float#

height of the cone

property radius: float#

radius of the cone

classmethod to_yaml(representer, node)#

Class method used to represent ConeGeometry in a yaml file.

classmethod from_yaml(_, node) Self#

Construct a ConeGeometry from yaml file data.

static to_json(o: ConeGeometry) dict[str, Any]#

Class method used to represent ConeGeometry in a json file.

classmethod from_json(d: dict[str, Any]) Self#

Construct a ConeGeometry from json file data.

class Karana.Scene.Contact#
property normal: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
property penetration: Karana.Math.Ktyping.Length#
property witness1: Karana.Math.Ktyping.Length3#
property witness2: Karana.Math.Ktyping.Length3#
class Karana.Scene.CylinderGeometry(radius: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex)#

Bases: AbstractStaticGeometry

Concrete cylinder geometry class

See Scene layer for more discussion on the scene layer.

static create(radius: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex) CylinderGeometry#

Create a new instance of CylinderGeometry from radius and height.

Parameters:
  • radius – radius of the capsule

  • height – height of the capsule’s middle section

Returns:

A pointer to the newly created instance of BoxGeometry.

__getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [2, 1]]#
__setstate__(arg0: Annotated[numpy.typing.ArrayLike, numpy.float32, [2, 1]]) None#
property height: float#

height of the cylinder

property radius: float#

radius of the cylinder

classmethod to_yaml(representer, node)#

Class method used to represent CylinderGeometry in a yaml file.

classmethod from_yaml(_, node) Self#

Construct a CylinderGeometry from yaml file data.

static to_json(o: CylinderGeometry) dict[str, Any]#

Class method used to represent CylinderGeometry in a json file.

classmethod from_json(d: dict[str, Any]) Self#

Construct a CylinderGeometry from json file data.

class Karana.Scene.DistanceInfo#
static singleton() DistanceInfo#
property distance: float#
property nearest1: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
property nearest2: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
class Karana.Scene.GraphicalScene#

Bases: Scene

Scene with an added graphics-specific interface

See Scene layer for more discussion on the scene layer.

addOverlayText(arg0: str, arg1: SupportsFloat | SupportsIndex, arg2: SupportsFloat | SupportsIndex, arg3: TextParameters) int#
addOverlayText(message: str, x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex, align: Alignment = Alignment.LEFT, size: SupportsFloat | SupportsIndex = 0.05000000074505806, color: Color = ...) int

Add text in screen space

Parameters:
  • message

    • The content of the overlay text

  • x

    • The horizontal position of the text between 0 and 1

  • y

    • The vertical position of the text between 0 and 1

  • parameters

    • Addition text parameters

Returns:

Unique id to later update the text instance

defaultCamera() GraphicalSceneCamera#

Get the automatically created default camera

Returns:

The default camera

removeOverlayText(arg0: SupportsInt | SupportsIndex) None#

Add text in screen space

Parameters:
  • message

    • The content of the overlay text

  • x

    • The horizontal position of the text between 0 and 1

  • y

    • The vertical position of the text between 0 and 1

  • parameters

    • Addition text parameters

Returns:

Unique id to later update the text instance

renderToFile(arg0: os.PathLike | str | bytes) None#

Render the scene to a file

Parameters:

filepath

  • filename to render to

setOverlayText(arg0: SupportsInt | SupportsIndex, arg1: str) None#

Add text in screen space

Parameters:
  • message

    • The content of the overlay text

  • x

    • The horizontal position of the text between 0 and 1

  • y

    • The vertical position of the text between 0 and 1

  • parameters

    • Addition text parameters

Returns:

Unique id to later update the text instance

class Karana.Scene.GraphicalSceneCamera#

Bases: GraphicalSceneNode

getMask() int#

Get the bitmask for which layers should be visible.

Returns:

The layers bitmask

getProjection() PerspectiveProjection | OrthographicProjection#

Get the camera projection parameters

Returns:

The camera projection parameters

pointCameraAt(offset: numpy.typing.ArrayLike | Karana.Math.Ktyping.Length3, target: numpy.typing.ArrayLike | Karana.Math.Ktyping.Length3, up: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]]) None#

Set the pose of the camera.

Parameters:
  • offset – The position of the camera.

  • target – The position the camera will point at.

  • up – The up vector of the camera.

setMask(mask: SupportsInt | SupportsIndex) None#

Set the bitmask for which layers should be visible.

Parameters:

mask

  • The layers bitmask

setProjection(projection: PerspectiveProjection | OrthographicProjection) None#

Set the camera projection parameters

Parameters:

proj – The camera projection parameters

class Karana.Scene.GraphicalSceneNode#

Bases: SceneNode

removeTrail() None#

Remove a trail previously created by calling trail

showAxes(size: SupportsFloat | SupportsIndex = 1.0) None#

Show axes to visualize the node’s position and orientation

Parameters:

size

  • Lengths of the axes (zero to remove the axes)

trail(reference: GraphicalSceneNode = None, color: Color = ...) None#

Display a trail tracking the node’s motion over time.

Parameters:
  • relative_to

    • Another node to draw the trail relative to.

  • color

    • The color of the Trail.

class Karana.Scene.GraphicalScenePart#

Bases: ScenePart, GraphicalSceneNode

class Karana.Scene.GrayscaleTexture#

Bases: Texture

Texture specialization for grayscale values

See Scene layer for more discussion on the scene layer.

static lookupFilepath(grayscale_texture: GrayscaleTexture) pathlib.Path | None#

Get the filepath associated with the provided texture.

Parameters:

grayscale_texture – The GrayscaleTexture to lookup the filepath for.

Returns:

The filepath of the provided grayscale texture, or nullopt if no filepath is associated with the grayscale texture.

static lookupOrCreateTexture(filename: os.PathLike | str | bytes) GrayscaleTexture#

Create a texture from a file name. This caches the texture so that future versions created with the same file name just return a pointer to the same texture.

Parameters:

filename – The name of the file.

Returns:

A ks_ptr to the GrayscaleTexture.

__getstate__() tuple[str, numpy.ndarray]#
__setstate__(arg0: tuple) None#
classmethod to_yaml(representer, node)#

Class method used to represent GrayscaleTexture in a yaml file.

classmethod from_yaml(_, node) Self#

Construct a GrayscaleTexture from yaml file data.

static to_json(o: GrayscaleTexture) dict[str, Any]#

Class method used to represent GrayscaleTexture in a json file.

classmethod from_json(d: dict[str, Any]) Self#

Construct a GrayscaleTexture from json file data.

class Karana.Scene.HeightFieldGeometry(size_x: SupportsFloat | SupportsIndex, size_y: SupportsFloat | SupportsIndex, heights: Annotated[numpy.typing.ArrayLike, numpy.float32, [m, n]])#

Bases: AbstractStaticGeometry

Center-origin 2D heightfield with fixed X/Y extents and sampled Z values.

The local origin is at the center of the X/Y extent. Grid sample (0, 0) is located at (size_x / 2, size_y / 2). Increasing the column index advances toward -X; increasing the row index advances toward -Y. Consequently, the heightfield occupies [-size_x / 2, size_x / 2] x [-size_y / 2, size_y / 2] in its local frame. This convention matches the centered local bounds of coal::HeightField.

See Scene layer for more discussion on the scene layer.

static create(size_x: SupportsFloat | SupportsIndex, size_y: SupportsFloat | SupportsIndex, heights: Annotated[numpy.typing.ArrayLike, numpy.float32, [m, n]]) HeightFieldGeometry#

Create a center-origin heightfield.

Parameters:
  • size_x – Side length in the X direction; finite and positive.

  • size_y – Side length in the Y direction; finite and positive.

  • heights – Height grid with at least two rows and columns. Entry (0, 0) is at local (+size_x / 2, +size_y / 2); columns advance toward -X and rows advance toward -Y.

Returns:

A pointer to the new heightfield geometry.

__getstate__() tuple[float, float, Annotated[numpy.typing.NDArray[numpy.float32], [m, n]]]#
__setstate__(arg0: tuple) None#
computeMesh() StaticMeshGeometry#
Returns:

A triangle mesh using the same centered local frame.

property heights: Annotated[numpy.typing.NDArray[numpy.float32], [m, n]]#

Height samples over the centered X/Y extent.

property size_x: float#

Side length in the X direction.

property size_y: float#

Side length in the Y direction.

class Karana.Scene.ImportResult#
property geometries: list[BoxGeometry | CapsuleGeometry | ConeGeometry | CylinderGeometry | RoundFrustumGeometry | SphereGeometry | HeightFieldGeometry | StaticMeshGeometry | AbstractStaticGeometry]#
property materials: list[PhysicalMaterial | PhongMaterial]#
property parts: list[ScenePartSpec]#
Karana.Scene.LAYER_ALL: int = 4294967295#
Karana.Scene.LAYER_COLLISION: int = 134217728#
Karana.Scene.LAYER_CUSTOM0: int = 1#
Karana.Scene.LAYER_CUSTOM1: int = 2#
Karana.Scene.LAYER_CUSTOM10: int = 1024#
Karana.Scene.LAYER_CUSTOM11: int = 2048#
Karana.Scene.LAYER_CUSTOM12: int = 4096#
Karana.Scene.LAYER_CUSTOM13: int = 8192#
Karana.Scene.LAYER_CUSTOM14: int = 16384#
Karana.Scene.LAYER_CUSTOM15: int = 32768#
Karana.Scene.LAYER_CUSTOM16: int = 65536#
Karana.Scene.LAYER_CUSTOM17: int = 131072#
Karana.Scene.LAYER_CUSTOM18: int = 262144#
Karana.Scene.LAYER_CUSTOM19: int = 524288#
Karana.Scene.LAYER_CUSTOM2: int = 4#
Karana.Scene.LAYER_CUSTOM20: int = 1048576#
Karana.Scene.LAYER_CUSTOM21: int = 2097152#
Karana.Scene.LAYER_CUSTOM22: int = 4194304#
Karana.Scene.LAYER_CUSTOM23: int = 8388608#
Karana.Scene.LAYER_CUSTOM3: int = 8#
Karana.Scene.LAYER_CUSTOM4: int = 16#
Karana.Scene.LAYER_CUSTOM5: int = 32#
Karana.Scene.LAYER_CUSTOM6: int = 64#
Karana.Scene.LAYER_CUSTOM7: int = 128#
Karana.Scene.LAYER_CUSTOM8: int = 256#
Karana.Scene.LAYER_CUSTOM9: int = 512#
Karana.Scene.LAYER_FLUIDS: int = 268435456#
Karana.Scene.LAYER_GRAPHICS: int = 117440512#
Karana.Scene.LAYER_NONE: int = 0#
Karana.Scene.LAYER_ORNAMENTAL: int = 33554432#
Karana.Scene.LAYER_PHYSICAL: int = 150994944#
Karana.Scene.LAYER_PHYSICAL_GRAPHICS: int = 16777216#
Karana.Scene.LAYER_RESERVED0: int = 16777216#
Karana.Scene.LAYER_RESERVED1: int = 33554432#
Karana.Scene.LAYER_RESERVED2: int = 67108864#
Karana.Scene.LAYER_RESERVED3: int = 134217728#
Karana.Scene.LAYER_RESERVED4: int = 268435456#
Karana.Scene.LAYER_RESERVED5: int = 536870912#
Karana.Scene.LAYER_RESERVED6: int = 1073741824#
Karana.Scene.LAYER_RESERVED7: int = 2147483648#
Karana.Scene.LAYER_STICK_FIGURE: int = 67108864#
Karana.Scene.MASK_LAYERS_ALL: int = 4294967295#
Karana.Scene.MASK_LAYERS_ALL_GRAPHICS: int = 117440512#
Karana.Scene.MASK_LAYERS_NONE: int = 0#
class Karana.Scene.OrthographicProjection#

Info for an orthographic camera projection

property far: float#

distance to far clipping plane

property height: float#

distance between top and bottom viewing planes

property near: float#

distance to near clipping plane

Karana.Scene.PART_LAYERS_PHYSICAL: int = 150994944#
class Karana.Scene.PerspectiveProjection#

Info for a perspective camera projection

property far: float#

distance to far clipping plane

property fov: float#

vertical field of view in degrees

property near: float#

distance to near clipping plane

class Karana.Scene.PhongMaterial(mat: PhongMaterialInfo)#

Bases: Karana.Core.BaseWithVars

A standard Phong material

See Scene layer for more discussion on the scene layer.

static create(mat: PhongMaterialInfo) PhongMaterial#

Create a PhongMaterial

Parameters:

mat – the parameter struct

Returns:

The created PhongMaterial

__getstate__() PhongMaterialInfo#
__setstate__(arg0: PhongMaterialInfo) None#
property info: PhongMaterialInfo#

Parameters for the materials

classmethod to_yaml(representer, node)#

Class method used to represent PhongMaterial in a yaml file.

classmethod from_yaml(_, node) Self#

Construct a PhongMaterial from yaml file data.

static to_json(o: PhongMaterial) dict[str, Any]#

Class method used to represent PhongMaterial in a json file.

classmethod from_json(d: dict[str, Any]) Self#

Construct a PhongMaterial from json file data.

class Karana.Scene.PhongMaterialInfo#

Parameter struct for a PhongMaterial

__getstate__() tuple[Color, Texture, Color, Texture, Color, Texture, Color, Texture]#
__setstate__(arg0: tuple) None#
property ambient_color: Color#

constant ambient color

property ambient_color_map: Texture#

ambient color map

property color: Color#

constant diffuse color

property color_map: Texture#

diffuse color map

property emissive_color: Color#

constant emissive color

property emissive_color_map: Texture#

emissive color map

property specular_color: Color#

constant specular color

property specular_color_map: Texture#

specular color map

classmethod to_yaml(representer, node)#

Class method used to represent PhongMaterialInfo in a yaml file.

classmethod from_yaml(_, node) Self#

Construct a PhongMaterialInfo from yaml file data.

static to_json(o: PhongMaterialInfo) dict[str, Any]#

Class method used to represent PhongMaterialInfo in a json file.

classmethod from_json(d: dict[str, Any]) Self#

Construct a PhongMaterialInfo from json file data.

class Karana.Scene.PhysicalMaterial(mat: PhysicalMaterialInfo)#

Bases: Karana.Core.BaseWithVars

A standard PBR material

See Scene layer for more discussion on the scene layer.

static create(mat: PhysicalMaterialInfo) PhysicalMaterial#

Create a PhysicalMaterial

Parameters:

mat – the parameter struct

Returns:

The created PhysicalMaterial

__getstate__() PhysicalMaterialInfo#
__setstate__(arg0: PhysicalMaterialInfo) None#
property info: PhysicalMaterialInfo#

Parameters for the materials

classmethod to_yaml(representer, node)#

Class method used to represent PhysicalMaterial in a yaml file.

classmethod from_yaml(_, node) Self#

Construct a PhysicalMaterial from yaml file data.

static to_json(o: PhysicalMaterial) dict[str, Any]#

Class method used to represent PhysicalMaterial in a json file.

classmethod from_json(d: dict[str, Any]) Self#

Construct a PhysicalMaterial from json file data.

class Karana.Scene.PhysicalMaterialInfo#

Parameter struct for a PhysicalMaterial

__getstate__() tuple[Texture, Color, float, GrayscaleTexture, float, GrayscaleTexture, Texture]#
__setstate__(arg0: tuple) None#
property color: Color#

constant base color

property color_map: Texture#

base color map

property metalness: float#

how metal-like the material is, between 0 and 1

property metalness_map: GrayscaleTexture#

grayscale metalness map

property normal_map: Texture#

normal map (assumes tangent space)

property roughness: float#

how rough the material is, between 0 and 1

property roughness_map: GrayscaleTexture#

grayscale roughness map

classmethod to_yaml(representer, node)#

Class method used to represent PhysicalMaterialInfo in a yaml file.

classmethod from_yaml(_, node) Self#

Construct a PhysicalMaterialInfo from yaml file data.

static to_json(o: PhysicalMaterialInfo) dict[str, Any]#

Class method used to represent PhysicalMaterialInfo in a json file.

classmethod from_json(d: dict[str, Any]) Self#

Construct a PhysicalMaterialInfo from json file data.

class Karana.Scene.RoundFrustumGeometry(bottom_radius: SupportsFloat | SupportsIndex, top_radius: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex)#

Bases: AbstractStaticGeometry

Concrete round frustum geometry class

See Scene layer for more discussion on the scene layer.

static create(bottom_radius: SupportsFloat | SupportsIndex, top_radius: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex) RoundFrustumGeometry#

Create a new instance of CapsuleGeometry from radii and height.

Parameters:
  • bottom_radius – radius of bottom face

  • top_radius – radius of top face

  • height – height of the frustum

Returns:

A pointer to the newly created instance of RoundFrustumGeometry.

__getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [3, 1]]#
__setstate__(arg0: Annotated[numpy.typing.ArrayLike, numpy.float32, [3, 1]]) None#
property bottom_radius: float#

radius of the bottom face

property height: float#

height of the frustum

property top_radius: float#

radius of the top face

classmethod to_yaml(representer, node)#

Class method used to represent RoundFrustumGeometry in a yaml file.

classmethod from_yaml(_, node) Self#

Construct a RoundFrustumGeometry from yaml file data.

static to_json(o: RoundFrustumGeometry) dict[str, Any]#

Class method used to represent RoundFrustumGeometry in a json file.

classmethod from_json(d: dict[str, Any]) Self#

Construct a RoundFrustumGeometry from json file data.

class Karana.Scene.Scene#

Bases: Karana.Core.BaseWithVars

Base container for a hierarchy of geometries

See Scene layer for more discussion on the scene layer.

defaultLayers() int#

Get the layers that should be created by default

Returns:

The default layers

getManager() Scene#

Get the Scene managing this one

Returns:

The managing scene or nullptr

getSceneNodes() list[SceneNode]#

Get the list of scene nodes in the scene

Returns:

The SceneNodes for this Scene.

getSceneParts(layers: SupportsInt | SupportsIndex = 4294967295) list[ScenePart]#

Get the list of scene parts in the scene

Parameters:

layers – Limit the returned list to parts belonging to the specified layers.

Returns:

The SceneParts for this Scene.

setManager(manager: Scene) None#

Assign a managing scene

Parameters:

manager – The scene managing this one (nullable)

class Karana.Scene.SceneFileObject#

Bases: SceneNode

Class for an opaque node with contents loaded from a file.

See Scene layer for more discussion on the scene layer.

static getLayersString(arg0: SupportsInt | SupportsIndex) str#

Convert the layer value into a more readable string form

The conversion only uses the pre-defined and known layer values (eg. COLLISION etc)

Parameters:

layer – the layer value

Returns:

A string representation of the bitmask for which layers the part belongs to.

getConvexity() int#

Get the is_convex flag set upon creation.

Returns:

The value of the is_convex flag.

getFilepath() pathlib.Path#

Get the file node’s filepath

Returns:

The file node’s filepath

getLayers() int#

Get which layers the part belongs to.

Returns:

Bitmask for which layers the part belongs to.

getVars() SceneFileObjectVars#
class Karana.Scene.SceneFileObjectSpec(name: str = 'unnamed', filepath: os.PathLike | str | bytes = '', transform: Karana.Math.HomTran = ..., scale: SupportsFloat | SupportsIndex = 1.0, layers: SupportsInt | SupportsIndex = 150994944, is_convex: bool = False)#
is_convex: bool#
name: str#
transform: Karana.Math.HomTran#
property filepath: pathlib.Path#
property layers: int#
property scale: float#
class Karana.Scene.SceneFileObjectVars#

Bases: SceneNodeVars, Karana.Core.BaseVars

The Vars for the SceneFileObject class.

property filepath: Karana.Core.VarString#

The filepath of the SceneFileObject.

property is_convex: Karana.Core.VarBool#

Hint for whether the file’s shapes are all convex

property layers: Karana.Core.VarInt#

The layers for the SceneFileObject.

property layers_string: Karana.Core.VarString#

Readable string representation of the layers for the SceneFileObject

class Karana.Scene.SceneNode#

Bases: Karana.Core.BaseWithVars

Base for objects with a transform i n the scene hierarchy

See Scene layer for more discussion on the scene layer.

attachTo(parent: SceneNode, maintain_world_transform: bool = False) None#

Attach to a parent node

Parameters:
  • parent

    • The parent node

  • maintain_world_sim_transform

    • If true, update the node’s

    relative transform so that its overall world transform doesn’t change after attaching it to the parent

childrenNodes() list[SceneNode]#

Get the node’s children nodes

Returns:

A list of the node’s children nodes

detach(maintain_world_transform: bool = False) None#

Detach the node from its parent

Parameters:

maintain_world_sim_transform

  • If true, update the node’s

relative transform so that its overall world transform doesn’t change after detaching

getManager() SceneNode#

Get a SceneNode managing this one

Returns:

The managing scene node or nullptr

getScale() float#

Get uniform scale of the node relative to its parent

Returns:

The relative uniform scale

getSimTransform() Karana.Math.SimTran#

Get similarity transform of the node relative to its parent

Returns:

The similarity transform

getVars() SceneNodeVars#
getVisible() bool#

Get whether the object is visible

Returns:

The visibility flag

getWorldSimTransform() Karana.Math.SimTran#

Get similarity transform of the node relative to the scene’s root

Returns:

The similarity transform

isSceneFileObject() bool#

Return true if this scene node is a scene file node

Returns:

true if the node is a scene file node

isScenePart() bool#

Return true if this scene node is a scene part

Returns:

true if the node is a scene part

setManager(manager: SceneNode) None#

Assign a managing scene node

Parameters:

manager – The scene node managing this one (nullable)

setScale(scale: SupportsFloat | SupportsIndex) None#

Set uniform of the node relative to its parent

Parameters:

scale

  • The relative uniform scale

setSimTransform(scale: Karana.Math.SimTran) None#

Set similarity transform of the node relative to its parent

Parameters:

transform

  • The similarity transform

setTranslation(translation: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]]) None#

Set position of the node relative to its parent

Parameters:

translation

  • The relative translation

setUnitQuaternion(quaternion: Karana.Math.UnitQuaternion) None#

Set rotation of the node relative to its parent

Parameters:

quaternion

  • The relative rotation as a unit quaternion

setVisible(visible: bool) None#

Set whether the object is visible

Parameters:

visible

  • The visibility flag

class Karana.Scene.SceneNodeVars#

Bases: Karana.Core.BaseVars

property children_nodes: Karana.Core.VarVecString#

The names of the children SceneNode instances.

property parent_node: Karana.Core.VarString#

The name of the parent SceneNode.

property scale: Karana.Core.VarDouble#

The local scale of the SceneNode.

property transform: Karana.Core.VarHomTran#

The local transform of the SceneNode.

property world_scale: Karana.Core.VarDouble#

The world scale of the SceneNode.

property world_transform: Karana.Core.VarHomTran#

The world transform of the SceneNode.

class Karana.Scene.ScenePart#

Bases: SceneNode

Class for objects with geometry and material in the scene

See Scene layer for more discussion on the scene layer.

static getLayersString(arg0: SupportsInt | SupportsIndex) str#

Convert the layer value into a more readable string form

The conversion only uses the pre-defined and known layer values (eg. COLLISION etc)

Parameters:

layer – the layer value

Returns:

A string representation of the bitmask for which layers the part belongs to.

getGeometry() BoxGeometry | CapsuleGeometry | ConeGeometry | CylinderGeometry | RoundFrustumGeometry | SphereGeometry | HeightFieldGeometry | StaticMeshGeometry | AbstractStaticGeometry#

Get the part’s geometry

Returns:

The part’s geometry

getIntrinsicScale() Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#

Get the part’s intrinsic scale.

The intrinsic scale can be non-uniform but does not apply to attached nodes.

Returns:

The part’s intrinsic scale.

getLayers() int#

Get which layers the part belongs to.

Returns:

Bitmask for which layers the part belongs to.

getMaterial() PhysicalMaterial | PhongMaterial#

Get the part’s material

Returns:

The part’s material

getVars() ScenePartVars#
setIntrinsicScale(arg0: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]]) None#

Set the part’s intrinsic scale.

The intrinsic scale can be non-uniform but does not apply to attached nodes.

Parameters:

scale

  • The part’s intrinsic scale.

setMaterial(arg0: PhysicalMaterial | PhongMaterial) None#

Set the part’s material

Parameters:

material

  • The part’s new material.

class Karana.Scene.ScenePartSpec(name: str = 'unnamed', geometry: BoxGeometry | CapsuleGeometry | ConeGeometry | CylinderGeometry | RoundFrustumGeometry | SphereGeometry | HeightFieldGeometry | StaticMeshGeometry | AbstractStaticGeometry = None, material: PhysicalMaterial | PhongMaterial = None, transform: Karana.Math.HomTran = ..., scale: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]] = ..., layers: SupportsInt | SupportsIndex = 150994944)#
geometry: BoxGeometry | CapsuleGeometry | ConeGeometry | CylinderGeometry | RoundFrustumGeometry | SphereGeometry | HeightFieldGeometry | StaticMeshGeometry | AbstractStaticGeometry#
material: PhysicalMaterial | PhongMaterial#
name: str#
transform: Karana.Math.HomTran#
property layers: int#
property scale: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
class Karana.Scene.ScenePartSpecVars#

Bases: Karana.Core.BaseVars

The Vars for the ScenePartSpec class.

property convex: Karana.Core.VarBool#

The convexity flag

property geometry: Karana.Core.VarString#

The geometry type

property layers: Karana.Core.VarInt#

The layers for the ScenePart.

property layers_string: Karana.Core.VarString#

Readable string representation of the layers for the ScenePart

property material: Karana.Core.VarString#

The material type

property scale: Karana.Core.VarVec3#

The intrinsic (possibly non-uniform) scale for the geometry

property transform: Karana.Core.VarHomTran#

The transform

class Karana.Scene.ScenePartVars#

Bases: SceneNodeVars, Karana.Core.BaseVars

The Vars for the ScenePart class.

property aabb: Karana.Core.VarSpatialVector#

The bounding box

property convex: Karana.Core.VarBool#

The convexity flag

property geometry: Karana.Core.VarString#

The geometry type

property intrinsic_scale: Karana.Core.VarVec3#

The intrinsic (possibly non-uniform) scale for the geometry

property layers: Karana.Core.VarInt#

The layers for the ScenePart.

property layers_string: Karana.Core.VarString#

Readable string representation of the layers for the ScenePart

class Karana.Scene.SceneVars#

Bases: Karana.Core.BaseVars

property num_nodes: Karana.Core.VarInt#

The number of scene nodes

class Karana.Scene.SphereGeometry(radius: SupportsFloat | SupportsIndex)#

Bases: AbstractStaticGeometry

Concrete sphere geometry class

See Scene layer for more discussion on the scene layer.

static create(radius: SupportsFloat | SupportsIndex) SphereGeometry#

Create a new instance of SphereGeometry from a radius.

Parameters:

radius – radius of the sphere

Returns:

A pointer to the newly created instance of SphereGeometry.

__getstate__() float#
__setstate__(arg0: SupportsFloat | SupportsIndex) None#
computeMesh() StaticMeshGeometry#

Convert to a triangular mesh

Returns:

The converted mesh

property radius: float#

radius of the sphere

classmethod to_yaml(representer, node)#

Class method used to represent SphereGeometry in a yaml file.

classmethod from_yaml(_, node) Self#

Construct a SphereGeometry from yaml file data.

static to_json(o: SphereGeometry) dict[str, Any]#

Class method used to represent SphereGeometry in a json file.

classmethod from_json(d: dict[str, Any]) Self#

Construct a SphereGeometry from json file data.

class Karana.Scene.StaticMeshGeometry(positions: Annotated[numpy.typing.ArrayLike, numpy.float32, [m, 3]], faces: Annotated[numpy.typing.ArrayLike, numpy.int32, [m, 3]], normals: Annotated[numpy.typing.ArrayLike, numpy.float32, [m, 3]], surface_map_coords: Annotated[numpy.typing.ArrayLike, numpy.float32, [m, 2]])#

Bases: AbstractStaticGeometry

Concrete triangular mesh geometry class

See Scene layer for more discussion on the scene layer.

static create(positions: Annotated[numpy.typing.ArrayLike, numpy.float32, [m, 3]], faces: Annotated[numpy.typing.ArrayLike, numpy.int32, [m, 3]], normals: Annotated[numpy.typing.ArrayLike, numpy.float32, [m, 3]], surface_map_coords: Annotated[numpy.typing.ArrayLike, numpy.float32, [m, 2]]) StaticMeshGeometry#

Create a new instance of CapsuleGeometry from radius and height.

Parameters:
  • positions – matrix of vertex positions

  • faces – matrix of triangles as three vertex indices

  • normals – matrix of vertex normals

  • surface_map_coords – matrix of uv (texture) coords

Returns:

A pointer to the newly created instance of StaticMeshGeometry.

__getstate__() tuple[Annotated[numpy.typing.NDArray[numpy.float32], [m, 3]], Annotated[numpy.typing.NDArray[numpy.int32], [m, 3]], Annotated[numpy.typing.NDArray[numpy.float32], [m, 3]], Annotated[numpy.typing.NDArray[numpy.float32], [m, 2]], str, bool]#
__setstate__(arg0: tuple) None#
setConvexity(is_convex: bool = False) None#

Set whether this static mesh is convex; used by some client scenes.

Parameters:

is_convex – Whether the mesh is convex

property faces: Annotated[numpy.typing.NDArray[numpy.int32], [m, 3]]#

triangles consisting of three vertex indices

property filename: str#

If this mesh comes from a file, this is the filename.

property normals: Annotated[numpy.typing.NDArray[numpy.float32], [m, 3]]#

vertex normals

property positions: Annotated[numpy.typing.NDArray[numpy.float32], [m, 3]]#

vertex positions

property surface_map_coords: Annotated[numpy.typing.NDArray[numpy.float32], [m, 2]]#

vertex uv (texture) coordinates

classmethod to_yaml(representer, node)#

Class method used to represent StaticMeshGeometry in a yaml file.

classmethod from_yaml(_, node) Self#

Construct a StaticMeshGeometry from yaml file data.

static to_json(o: StaticMeshGeometry) dict[str, Any]#

Class method used to represent StaticMeshGeometry in a json file.

classmethod from_json(d: dict[str, Any]) Self#

Construct a StaticMeshGeometry from json file data.

class Karana.Scene.TextParameters#

Style parameters for text

property align: Alignment#

Controls text alignment/justification

property color: Color#

Color of the text

property size: float#

Text size as a portion of the screen’s full vertical space

class Karana.Scene.Texture#

Bases: Karana.Core.BaseWithVars

Class for a texture image

See Scene layer for more discussion on the scene layer.

static create(name: str, data: Annotated[numpy.typing.ArrayLike, numpy.int8]) Texture#

Create a Texture instance.

Parameters:
  • name – The Texture’s name.

  • data – The data for the texture.

Returns:

A ks_ptr to the Texture.

static lookupFilepath(texture: Texture) pathlib.Path | None#

Get the filepath associated with the provided texture.

Parameters:

texture – The GrayscaleTexture to lookup the filepath for.

Returns:

The filepath of the provided texture, or nullopt if no filepath is associated with the texture.

static lookupOrCreateTexture(filename: os.PathLike | str | bytes) Texture#

Create a texture from a file name. This caches the texture so that future versions created with the same file name just return a pointer to the same texture.

Parameters:

filename – The name of the file.

Returns:

A ks_ptr to the Texture.

__getstate__() tuple[str, numpy.ndarray]#
__setstate__(arg0: tuple) None#
getData() numpy.ndarray#

Get the texture data associated with the Texture.

Returns:

The texture data associated with the Texture.

setData(data: Annotated[numpy.typing.ArrayLike, numpy.int8]) None#

Set the texture data associated with the Texture.

Parameters:

data – The data to set the Texture data to.

writeToFile(filename: os.PathLike | str | bytes) None#

Write the texture to a file.

Parameters:

filename – The name of the file to write to.

classmethod to_yaml(representer, node)#

Class method used to represent Texture in a yaml file.

classmethod from_yaml(_, node) Self#

Construct a Texture from yaml file data.

static to_json(o: Texture) dict[str, Any]#

Class method used to represent Texture in a json file.

classmethod from_json(d: dict[str, Any]) Self#

Construct a Texture from json file data.

class Karana.Scene.TransformUpdateScope(arg0: Scene)#

RAII wrapper for beginTransformUpdates and endTransformUpdates

__enter__() None#
__exit__(arg0: type | None, arg1: Any | None, arg2: Any | None) bool#
close() None#

Close the scope early.

isOpen() bool#

Check if the scope is still open.

Returns:

Whether the scope is open.

Karana.Scene.defaultGeometry() BoxGeometry | CapsuleGeometry | ConeGeometry | CylinderGeometry | RoundFrustumGeometry | SphereGeometry | HeightFieldGeometry | StaticMeshGeometry | AbstractStaticGeometry#
Karana.Scene.defaultMaterial() PhysicalMaterial | PhongMaterial#
class Karana.Scene.ProxyScene(name: str, root_frame: Karana.Frame.Frame)#

Bases: Karana.Scene.Scene

A Scene implementation acting as a proxy to any number of registered ‘client’ Scenes.

See Scene layer for more discussion on the scene layer.

static create(name: str, root_frame: Karana.Frame.Frame) ProxyScene#

Create a ProxyScene

Parameters:
  • name

    • Name of the ProxyScene.

  • root_frame

    • Default Frame to attach nodes to.

Returns:

The created ProxyScene

chaseFrame(frame: Karana.Frame.Frame, offset: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]], at_offset: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]] = ..., up: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]] = ...) None#

Position the default camera relative to a Frame

Parameters:
  • frm – the Frame to chase around

  • offset – camera position relative to the Frame

  • at_offset – camera target relative to the Frame

  • up – camera up vector

clientScenes() list[Karana.Scene.Scene]#

Get a list of all registered client Scenes

Returns:

The list of client Scenes

collision() Karana.Scene.CollisionScene#

Get a registered CollisionScene

If there is more than one only the first one found is returned.

Returns:

A CollisionScene or nullptr

empty() bool#

Check if the ProxyScene has any nodes or parts

Returns:

Whether the ProxyScene is empty

getFileObjectsAttachedToFrame(frame: Karana.Frame.Frame, strict: bool, layers: SupportsInt | SupportsIndex = 4294967295) list[ProxySceneFileObject]#

Retrieve all ProxySceneFileObjects attached to the provided frame.

Parameters:
  • frame

    • The frame to retrieve parts from.

  • strict

    • If true, then only get parts directly attached to the

    provided frame. If false, then return all parts whose ancestor frame is the provided frame.

  • layers

    • Limit to parts belonging to the specified layer.

Returns:

A vector of ProxySceneFileObjects attached to the provided frame.

getNodesAttachedToFrame(frame: Karana.Frame.Frame, strict: bool) list[ProxySceneNode]#

Retrieve all ProxySceneNodes attached to the provided frame.

Parameters:
  • frame

    • The frame to retrieve nodes from.

  • strict

    • If true, then only get nodes directly attached to the

    provided frame. If false, then return all nodes whose ancestor frame is the provided frame.

Returns:

A vector of ProxySceneNodes attached to the provided frame.

getPartsAttachedToFrame(frame: Karana.Frame.Frame, strict: bool, layers: SupportsInt | SupportsIndex = 4294967295) list[ProxyScenePart]#

Retrieve all ProxySceneParts attached to the provided frame.

Parameters:
  • frame

    • The frame to retrieve parts from.

  • strict

    • If true, then only get parts directly attached to the

    provided frame. If false, then return all parts whose ancestor frame is the provided frame.

  • layers

    • Limit to parts belonging to the specified layer.

Returns:

A vector of ProxySceneParts attached to the provided frame.

getVars() ProxySceneVars#
graphics() Karana.Scene.GraphicalScene#

Get a registered GraphicalScene

If there is more than one only the first one found is returned.

Returns:

A GraphicalScene or nullptr

layers(client_scene: Karana.Scene.Scene) int#

Get the client’s layers value

Parameters:

client_scene

  • The client Scene

Returns:

The layers value

lookupProxyFromImpl(impl: Karana.Scene.SceneNode) ProxySceneNode#

Lookup the ProxySceneNode managing the given implementation

Parameters:

impl

  • The SceneNode in a client Scene

Returns:

The corresponding ProxySceneNode

originFrame(client_scene: Karana.Scene.Scene) Karana.Frame.Frame#

Get the Frame the client’s origin is centered at

Parameters:

client_scene

  • The client Scene

Returns:

The origin Frame for the given client Scene

registerClientScene(scene: Karana.Scene.Scene, origin_frame: Karana.Frame.Frame, layers: SupportsInt | SupportsIndex | None = None) None#

Register a client Scene to be managed

Parameters:
  • scene

    • The client Scene

  • origin_frame

    • The Frame to center the client’s origin at

  • layers

    • Bitmask for objects to implement

rootFrame() Karana.Frame.Frame#

Get the root frame.

This is the frame that nodes are attached to by default.

Returns:

The root Frame.

showAxes(frame: Karana.Frame.Frame, size: SupportsFloat | SupportsIndex = 1.0) None#

Show the axes for a Frame

Parameters:
  • frm – the Frame to show axes for

  • size – the size of the axes

unregisterClientScene(arg0: Karana.Scene.Scene) None#

Unregister a client Scene to no longer be managed

Parameters:

scene

  • The client Scene.

update() None#
update(arg0: Karana.Scene.Scene) None

Update all Frame-attached nodes’ transforms for all clients

viewAroundFrame(frame: Karana.Frame.Frame, offset: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]], at_offset: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]] = ..., up: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]] = ...) None#

Position the default camera relative to a Frame

Parameters:
  • frm – the Frame to view around

  • offset – camera position relative to the Frame

  • at_offset – camera target relative to the Frame

  • up – camera up vector

property update_callbacks: Karana.Core.VoidCallbackRegistry#
setupGraphics(origin_frame: Karana.Frame.Frame, *, port: int = 29523, axes: float = 1.0, client_type: Literal['auto', 'electron', 'notebook', 'webbrowser', 'selenium'] | None = 'auto', wait_for_clients: int = 0, wait_for_clients_timeout: float = 0.0) tuple[Callable[[], None], Karana.Scene.WebScene]#

Easily set up graphics.

Parameters:
  • origin_frame (Frame) – Frame to use as the world origin for the graphics scene.

  • port (int) – Port to bind the WebUI server to. Use 0 to request an arbitrary unused port. Defaults to 29523.

  • axes (float) – Length of axes visualization on root frame. Defaults to 1.0.

  • client_type (Literal["auto", "electron", "notebook", "webbrowser", "selenium"] | None) –

    Policy for launching a client.

    ”auto”: pick the best option for the environment and OS “electron”: always launch the electron client “notebook”: always open an IFrame in IPython “webbrowser”: always open a browser tab “selenium”: always open a chrome driver using selenium None: don’t automatically open a client

    Defaults to “auto”.

  • wait_for_clients (int) – Number of client connections to wait for before continuing. Defaults to 0.

  • wait_for_clients_timeout (float) – Number of seconds to wait before raising an error if wait_for_clients is positive. Defaults to 0.

Returns:

A tuple containing the a cleanup callable and the graphics scene.

Return type:

tuple[Callable[[],None], WebScene]

class Karana.Scene.ProxySceneFileObject(name: str, scene: ProxyScene, filepath: os.PathLike | str | bytes, layers: SupportsInt | SupportsIndex = 150994944, is_convex: bool = False)#

Bases: Karana.Scene.SceneFileObject, ProxySceneNode

static create(name: str, scene: ProxyScene, filepath: os.PathLike | str | bytes, layers: SupportsInt | SupportsIndex = 150994944, is_convex: bool = False) ProxySceneFileObject#

Create a ProxySceneFileObject.

Parameters:
  • name – Name of the ProxySceneFileObject.

  • scene – The ProxyScene to add the ProxySceneFileObject to.

  • filepath – File to populate the node from.

  • layers – Layers to use for the ProxySceneFileObject.

  • is_convex – Whether the file’s geometries are all convex.

Returns:

The new ProxyScene part.

getVars() ProxySceneFileObjectVars#
of(scene: Karana.Scene.Scene) Karana.Scene.SceneFileObject#

Get the implementation for a given client

Parameters:

scene

  • The client scene

Returns:

The implementation of this node for the client

class Karana.Scene.ProxySceneFileObjectVars#

Bases: Karana.Scene.SceneFileObjectVars, Karana.Core.BaseVars

The Vars for the ProxySceneFileObject class.

property parent_frame: Karana.Core.VarString#

The parent frame name

class Karana.Scene.ProxySceneNode(name: str, scene: ProxyScene)#

Bases: Karana.Scene.SceneNode

ancestorFrame() Karana.Frame.Frame#

Get the unique Frame that an ancestor is attached to

Returns:

The Frame that this node or an ancestor is attached to

attachTo(parent: Karana.Scene.SceneNode, maintain_world_transform: bool = False) None#
attachTo(parent: Karana.Frame.Frame, maintain_world_transform: bool = False) None

Attach the node to a Frame

Parameters:
  • parent

    • The Frame to attach to

  • maintain_world_transform

    • If true, update the node’s relative

    transform so that its overall world transform doesn’t change after attaching it to the parent

collision() Karana.Scene.CollisionSceneNode#
collision(arg0: Karana.Scene.Scene) Karana.Scene.CollisionSceneNode

Get a collision implementation If there is more than one collision implementation only the first one found is returned.

Returns:

A collision implementation or nullptr

create(name: Karana.Frame.Frame) ProxyScene#

Create a ProxyScene node.

Parameters:
  • name

    • The name of the ProxySceneNode.

  • scene

    • The ProxyScene to add the node to.

Returns:

The created ProxySceneNode

detach(maintain_world_transform: bool = False) None#
graphics() Karana.Scene.GraphicalSceneNode#
graphics(arg0: Karana.Scene.Scene) Karana.Scene.GraphicalSceneNode

Get a graphical implementation If there is more than one graphical implementation only the first one found is returned.

Returns:

A graphical implementation or nullptr

of(scene: Karana.Scene.Scene) Karana.Scene.SceneNode#

Get the implementation for a given client

Parameters:

scene

  • The client scene

Returns:

The implementation of this node for the client

setScale(arg0: SupportsFloat | SupportsIndex) None#
setTranslation(arg0: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]]) None#
setUnitQuaternion(arg0: Karana.Math.UnitQuaternion) None#
class Karana.Scene.ProxyScenePart(name: str, scene: ProxyScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial, layers: SupportsInt | SupportsIndex = 150994944)#
class Karana.Scene.ProxyScenePart(name: str, scene: ProxyScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, layers: SupportsInt | SupportsIndex = 150994944)

Bases: Karana.Scene.ScenePart, ProxySceneNode

static create(name: str, scene: ProxyScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial, layers: SupportsInt | SupportsIndex = 150994944) ProxyScenePart#
static create(name: str, scene: ProxyScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, layers: SupportsInt | SupportsIndex = 150994944) ProxyScenePart

Create a ProxyScenePart.

Parameters:
  • name

    • Name of the ProxyScenePart.

  • scene

    • The ProxyScene to add the ProxyScenePart to.

  • geometry

    • Geometry of the ProxyScenePart.

  • material

    • Material for the ProxyScenePart.

  • layers

    • Layers to use for the ProxyScenePart.

Returns:

The new ProxyScene part.

static fromScenePartSpec(scene: ProxyScene, spec: Karana.Scene.ScenePartSpec) ProxyScenePart#

Create a ProxyScenePart from a ScenePartSpec.

Parameters:
  • scene

    • The ProxyScene to add the ProxyScenePart to.

  • spec – The spec to use to create the ProxyScenePart.

Returns:

The new ProxyScene part.

collision() Karana.Scene.CollisionScenePart#
collision(arg0: Karana.Scene.Scene) Karana.Scene.CollisionScenePart

Get a collision implementation If there is more than one collision implementation only the first one found is returned.

Returns:

A collision implementation or nullptr

getVars() ProxyScenePartVars#
graphics() Karana.Scene.GraphicalScenePart#
graphics(arg0: Karana.Scene.Scene) Karana.Scene.GraphicalScenePart

Get a graphical implementation If there is more than one graphical implementation only the first one found is returned.

Returns:

A graphical implementation or nullptr

of(scene: Karana.Scene.Scene) Karana.Scene.ScenePart#

Get the implementation for a given client

Parameters:

scene

  • The client scene

Returns:

The implementation of this node for the client

setIntrinsicScale(arg0: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]]) None#
class Karana.Scene.ProxyScenePartVars#

Bases: Karana.Scene.ScenePartVars, Karana.Core.BaseVars

The Vars for the ProxyScenePart class.

property parent_frame: Karana.Core.VarString#

The parent frame name

class Karana.Scene.ProxySceneVars#

Bases: Karana.Scene.SceneVars, Karana.Core.BaseVars

property root_frame: Karana.Core.VarString#

the root frame name

class Karana.Scene.WebScene(name: str, server: Karana.WebUI.Server)#

Bases: Karana.Scene.GraphicalScene

GraphicalScene implementation for web-based graphics

See Scene layer for more discussion on the scene layer.

static create(name: str, server: Karana.WebUI.Server) WebScene#

Create a WebScene

Parameters:
  • name

    • Name for the WebScene

  • server

    • Server to communicate with frontends

Returns:

The created WebScene

defaultCamera() Karana.Scene.GraphicalSceneCamera#

Get the default camera

Returns:

The camera

pushChanges() None#

Hint to the frontend that it’s a good time to render

renderToFile(filepath: os.PathLike | str | bytes) None#
server() Karana.WebUI.Server#

Get the server used by WebScene

Returns:

The server used to communicate with frontends

setOnHover(on_pick: collections.abc.Callable[[WebScenePart | None], None]) None#

Set a callback for when a part is hovered over

Parameters:

on_hover – The callback to call with the part’s id

setOnPick(on_pick: collections.abc.Callable[[WebScenePart | None], None]) None#

Set a callback for when a part is clicked on

Parameters:

on_pick – The callback to call with the part’s id

class Karana.Scene.WebSceneFileObject(name: str, scene: WebScene, filepath: os.PathLike | str | bytes, layers: SupportsInt | SupportsIndex = 150994944, is_convex: bool = False)#

Bases: Karana.Scene.SceneFileObject, WebSceneNode

static create(name: str, scene: WebScene, filepath: os.PathLike | str | bytes, layers: SupportsInt | SupportsIndex = 150994944, is_convex: bool = False) WebSceneFileObject#

Create a WebSceneFileObject.

Parameters:
  • name – Name of the WebSceneFileObject.

  • scene – The GraphicalScene to add the WebSceneFileObject to.

  • filepath – Filepath to populate the node from.

  • layers – Layers to use for the WebSceneFileObject.

  • is_convex – Whether the file’s shapes are all convex.

Returns:

The new WebScene file node.

class Karana.Scene.WebSceneNode(name: str, scene: WebScene)#

Bases: Karana.Scene.GraphicalSceneNode

static create(name: str, scene: WebScene) WebSceneNode#

Create a WebSceneNode.

Parameters:
  • name

    • Name of the node.

  • scene

    • The WebScene to add the node to.

Returns:

The created WebSceneNode.

class Karana.Scene.WebScenePart(name: str, scene: WebScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial, layers: SupportsInt | SupportsIndex = 150994944)#
class Karana.Scene.WebScenePart(name: str, scene: WebScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, layers: SupportsInt | SupportsIndex = 150994944)

Bases: Karana.Scene.GraphicalScenePart, WebSceneNode

static create(name: str, scene: WebScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial, layers: SupportsInt | SupportsIndex = 150994944) WebScenePart#
static create(name: str, scene: WebScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, layers: SupportsInt | SupportsIndex = 150994944) WebScenePart

Create a WebScenePart.

Parameters:
  • name

    • Name of the WebScenePart.

  • scene

    • The GraphicalScene to add the WebScenePart to.

  • geometry

    • Geometry of the WebScenePart.

  • material

    • Material for the WebScenePart.

  • layers

    • Layers to use for the WebScenePart.

Returns:

The new WebScene part.

getIntrinsicScale() Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
outline() None#

Draw an outline around the part

removeOutline() None#

Remove a previously added outline

setIntrinsicScale(arg0: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]]) None#
class Karana.Scene.CoalScene(name: str)#

Bases: Karana.Scene.CollisionScene

CollisionScene implementation using the COAL library

See Scene layer for more discussion on the scene layer.

static create(name: str) CoalScene#

Create a CoalScene

Parameters:

name

  • Name for the CoalScene

Returns:

The created CoalScene

getGJKEPATolerance() float#

Get the tolerance used by the GJK and EPA narrowphase solvers.

Returns:

The shared GJK/EPA tolerance.

getMaxNumContacts() int#

Get the maximum number of contact points that we track between any two scene parts

Returns:

size_t

setGJKEPATolerance(tolerance: SupportsFloat | SupportsIndex) None#

Set the tolerance used by the GJK and EPA narrowphase solvers.

Also broadcasts this value to every existing CoalScenePart.

Parameters:

tolerance – Positive, finite solver tolerance.

setMaxNumContacts(max_contacts: SupportsInt | SupportsIndex) None#

Set the maximum number of contact points that we track between any two scene parts.

Also broadcasts this information to every existing CoalScenePart

Parameters:

max_contacts – New maximum count

toDS() Karana.Scene.CoalScene_types.CoalSceneDS#

Create a CoalSceneDS from this CoalScene model.

Returns:

  • CoalSceneDS

  • A CoalSceneDS instance with values set to match this model.

class Karana.Scene.CoalSceneFileObject(name: str, scene: CoalScene, filepath: os.PathLike | str | bytes, layers: SupportsInt | SupportsIndex = 150994944, is_convex: bool = False)#

Bases: Karana.Scene.SceneFileObject, CoalSceneNode

static create(name: str, scene: CoalScene, filepath: os.PathLike | str | bytes, layers: SupportsInt | SupportsIndex = 150994944, is_convex: bool = False) CoalSceneFileObject#

Create a CoalSceneFileObject.

Parameters:
  • name – Name of the CoalSceneFileObject.

  • scene – The GraphicalScene to add the CoalSceneFileObject to.

  • filepath – Filepath to populate the node from.

  • layers – Layers to use for the CoalSceneFileObject.

  • is_convex – Whether the file’s shapes are all convex.

Returns:

The new CoalScene file node.

class Karana.Scene.CoalSceneNode(name: str, scene: CoalScene)#

Bases: Karana.Scene.CollisionSceneNode

static create(name: str, scene: CoalScene) CoalSceneNode#

Create a CoalSceneNode.

Parameters:
  • name

    • The name of the CoalSceneNode.

  • scene

    • The CoalScene to add the node to.

Returns:

The created CoalSceneNode.

class Karana.Scene.CoalScenePart(name: str, scene: CoalScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial, layers: SupportsInt | SupportsIndex = 150994944)#
class Karana.Scene.CoalScenePart(name: str, scene: CoalScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, layers: SupportsInt | SupportsIndex = 150994944)

Bases: CoalSceneNode, Karana.Scene.CollisionScenePart

static create(name: str, scene: CoalScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial, layers: SupportsInt | SupportsIndex = 150994944) CoalScenePart#
static create(name: str, scene: CoalScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, layers: SupportsInt | SupportsIndex = 150994944) CoalScenePart

Create a CoalScenePart.

Parameters:
  • name

    • Name of the CoalScenePart.

  • scene

    • The GraphicalScene to add the CoalScenePart to.

  • geometry

    • Geometry of the CoalScenePart.

  • material

    • Material for the CoalScenePart.

  • layers

    • Layers to use for the CoalScenePart.

Returns:

The new CoalScene part.