Request

Response

    Autodesk.Viewing.Scene
    Version 8 preview
    This page documents a preview of the Viewer SDK v8. APIs and content can still change before the final release.

    BufferGeometry

    new BufferGeometry()

    Constructs a new BufferGeometry.

    Methods

    clone()

    Clones the geometry.

    Returns

    typedescription
    BufferGeometry The cloned geometry.

    computeBoundingBox()

    Computes the axis-aligned bounding box of the geometry.

    computeBoundingSphere()

    Computes the bounding sphere of the geometry.

    setAttribute(name, attribute)

    Sets a named vertex attribute.

    Parameters

    name*
    string
    Attribute name: ‘position’, ‘normal’, ‘uv’, ‘color’.
    attribute*A BufferAttribute wrapping the vertex data.
    * Required

    Returns

    typedescription
    BufferGeometry this

    getAttribute(name)

    Returns the BufferAttribute for a named attribute. Before commit, returns the original BufferAttribute. After commit, the BufferAttribute data has been processed and might differ from the original.

    Parameters

    name*
    string
    Attribute name.
    * Required

    Returns

    typedescription
    BufferAttribute, null

    hasAttribute(name)

    Returns true if the named attribute is set.

    Parameters

    name*
    string
    Attribute name.
    * Required

    Returns

    typedescription
    boolean

    getVertexCount()

    Number of vertices, derived from position attribute or interleaved buffer.

    Returns

    typedescription
    number

    setInterleavedBuffer(data, stride, layout)

    Sets a pre-interleaved vertex buffer with attribute layout. Mutually exclusive with setAttribute() — mixing the two throws.

    Parameters

    data*
    Float32Array
    Interleaved vertex buffer.
    stride*
    number
    Number of float32 elements per vertex.
    layout*
    Object.<string, AttributeLayout>
    Map of attribute names to their layouts.
    * Required

    Returns

    typedescription
    BufferGeometry this

    setIndices(data)

    Sets the index buffer of the geometry.

    Parameters

    data*
    Uint16Array, Uint32Array
    Index buffer.
    * Required

    Returns

    typedescription
    BufferGeometry this

    getIndices()

    Returns the index buffer, or null.

    Returns

    typedescription
    Uint16Array, Uint32Array, null

    setEdgeIndices(data)

    Sets edge wireframe indices. Every 2 consecutive values form a line segment.

    Parameters

    data*
    Uint16Array, Uint32Array
    Edge index buffer.
    * Required

    Returns

    typedescription
    BufferGeometry this

    getEdgeIndices()

    Returns edge index buffer, or null.

    Returns

    typedescription
    Uint16Array, Uint32Array, null

    getEdgeCount()

    Number of edge line segments (edgeIndices.length / 2).

    Returns

    typedescription
    number

    isCommitted()

    Returns true after the geometry has been added to an InstanceCollection3D.

    Returns

    typedescription
    boolean

    getByteSize()

    Total byte size of all buffers.

    Returns

    typedescription
    number

    setBoundingBox(min, max)

    Explicitly sets the bounding box.

    Parameters

    min*
    max*
    * Required

    Returns

    typedescription
    BufferGeometry this

    getBoundingBox(target)

    Returns the bounding box. If target is provided, copies into it, otherwise returns a clone. Returns null if neither computed nor set.

    Parameters

    target

    Returns

    typedescription
    Box3, null

    isInterleaved()

    Returns true if the geometry uses an interleaved vertex buffer.

    Returns

    typedescription
    boolean

    getPositionReader()

    Returns a function(vertexIndex, outVec3) that reads a decoded position into outVec3.

    Returns

    typedescription
    VertexAttributeReader, null

    getNormalReader()

    Returns a function(vertexIndex, outVec3) that reads a decoded normal into outVec3.

    Returns

    typedescription
    VertexAttributeReader, null

    getNormal(index, target)

    Decodes a normal from the vertex buffer. For performance critical readbacks of large parts of the geometry use getNormalReader instead.

    Parameters

    index*
    number
    The index of the vertex.
    target*The target vector to store the decoded normal.
    * Required

    Returns

    typedescription
    Vector3, null The decoded normal or null if the normal is not set.

    getPosition(index, target)

    Decodes a position from the vertex buffer. For performance critical readbacks of large parts of the geometry use getPositionReader instead.

    Parameters

    index*
    number
    The index of the vertex.
    target*The target vector to store the decoded position.
    * Required

    Returns

    typedescription
    Vector3, null The decoded position or null if the position is not set.