@pixi/3d
    Preparing search index...

    Class TorusKnotGeometry

    A torus knot geometry, formed by sweeping a circular tube along a (p, q) torus knot path

    The centerline winds p times around the +Y axis and q times through the torus's hole: (2, 3) is a trefoil, and (3, 7) is more tightly wound. Use whole numbers that share no factor: other numbers leave a gap where the tube's ends should meet, and a shared factor runs the tube over the same loop more than once.

    const trefoil = new TorusKnotGeometry({
    radius: 1,
    tube: 0.4,
    tubularSegments: 64,
    radialSegments: 8,
    p: 2,
    q: 3,
    });

    Hierarchy (View Summary)

    Index
    bounds3D: Box

    The geometry's local bounding box, used for picking and for a mesh's local bounds

    Culling tests Geometry3D#boundsSphere instead.

    const size = geometry.bounds3D.getSize();
    
    boundsSphere: Sphere

    The sphere around Geometry3D#bounds3D, which frustum culling tests

    Computed once, at construction, so later edits to the positions or to bounds3D don't reach culling.

    const radius = geometry.boundsSphere.radius;
    
    dynamic: boolean

    Whether the geometry stays out of the shared buffers; see Geometry3DOptions#dynamic

    hasMorphNormals: boolean

    Whether the morph targets bend the normals as well as the positions; see Geometry3DOptions#morphTargets

    morphTargetCount: number = 0

    Count of morph targets; a mesh drawing the geometry takes one weight per target

    const weights = new Float32Array(geometry.morphTargetCount);
    
    defaultOptions: TorusKnotGeometryOptions = ...

    Defaults for every new TorusKnotGeometry

    TorusKnotGeometry.defaultOptions.tubularSegments = 128;
    
    • get attributeKey(): string
      Advanced

      The attribute names and formats, ignoring strides, offsets and buffers

      Geometries with the same key are packed into the same shared buffers. A geometry with positions, normals and UVs has the key aNormal:snorm16x4|aPosition:float32x3|aUV:float32x2|.

      Returns string

    • get indices(): Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>

      The index data

      Returns Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>

      const triangleCount = geometry.indices.length / 3;
      
    • set indices(
          value: Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>,
      ): void

      Sets the index data

      Parameters

      • value: Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>

        New indices, three per triangle for triangle-list

      Returns void

    • get normals(): TypedArray | undefined

      The normal data as stored, or undefined when the geometry has no normals

      With Geometry3DOptions#quantizeNormals (the default) it's an Int16Array with four values per vertex; on an interleaved geometry, the whole interleaved buffer as a Uint8Array. To read normals as floats, three per vertex, use getAttributeData.

      Returns TypedArray | undefined

      const normals = getAttributeData(geometry, 'aNormal', 3);
      const normal = new Vector3().fromArray(normals, vertexIndex * 3);
    • set normals(value: TypedArray): void

      Sets the normal data; ignored when the geometry has no normals

      Parameters

      • value: TypedArray

        New data, in the format the normals are stored in

      Returns void

    • get positions(): TypedArray

      The position data as stored

      A Float32Array, unless the geometry was built from quantized positions; on an interleaved geometry, the whole interleaved buffer as a Uint8Array. On a dynamic geometry that isn't interleaved, write through it and update its buffer. To read positions as floats, three per vertex, use getAttributeData.

      Returns TypedArray

      const trail = new Geometry3D({ positions: new Float32Array(64 * 3), dynamic: true });

      trail.positions.set(points);
      trail.attributes.aPosition.buffer.update();
    • set positions(value: TypedArray): void

      Sets the position data

      Parameters

      • value: TypedArray

        New data, covering at least as many vertices as before

      Returns void

    • get tangents(): TypedArray | undefined

      The tangent data as stored, or undefined when the geometry has no tangents

      With Geometry3DOptions#quantizeTangents (the default) it is an Int16Array with four values per vertex. Read tangents as floats, four per vertex, with getAttributeData.

      Returns TypedArray | undefined

    • set tangents(value: TypedArray): void

      Sets the tangent data; ignored when the geometry has no tangents

      Parameters

      • value: TypedArray

        New data, in the format the tangents are stored in

      Returns void

    • get uvs(): TypedArray | undefined

      The UV data as stored, or undefined when the geometry has no UVs

      Read them as floats, two per vertex, with getAttributeData.

      Returns TypedArray | undefined

    • set uvs(value: TypedArray): void

      Sets the UV data; ignored when the geometry has no UVs

      Parameters

      • value: TypedArray

        New data, covering every vertex

      Returns void

    • get vertexCount(): number

      Number of vertices

      Returns number

      const colors = new Float32Array(geometry.vertexCount * 4);
      
    • get EMPTY(): Geometry3D
      Advanced

      A shared geometry with no vertices, which a Mesh3D holds until it's given a geometry

      A mesh on it draws nothing and compiles no shader. Assign it to a mesh's geometry to stop the mesh drawing; to hide a mesh for a while, visible = false is cheaper to toggle. Only Mesh3D takes it: a BatchedMesh3D slot in a pass needs a real geometry.

      Its destroy does nothing, as with pixi's Texture.EMPTY, so destroying a mesh with geometry: true can't free it from under other meshes.

      Returns Geometry3D

      if (mesh.geometry === Geometry3D.EMPTY) mesh.geometry = new SphereGeometry();
      
    • Frees the geometry for good

      Its own buffers are destroyed only with destroyBuffers, since other geometries may share them. Calling it again does nothing.

      Parameters

      • OptionaldestroyBuffers: boolean

        Whether to destroy the geometry's own buffers as well

      Returns void

      view.root.removeChild(mesh);
      mesh.geometry.destroy(true);

      Geometry3D.unload To hand back the GPU memory but keep the geometry usable.

    • Unloads this geometry from the GPU, keeping its CPU data so it can be rebuilt

      A dynamic geometry frees its own GPU buffers; any other leaves its place in the shared buffers, which never shrink, for later geometries. The next render that draws it uploads it again, and the image comes out the same: a geometry out of the scene comes back when its mesh does, one still drawn on the next frame. A BatchedMesh3D slot that draws it also needs invalidate. Safe to call more than once, and does nothing after Geometry3D.destroy.

      Returns void

      view.root.removeChild(mesh);
      mesh.geometry.unload(); // adding the mesh again uploads it again

      Geometry3D.destroy To free the geometry for good.