Skip to content

Custom (matrix_model / matrix_normal) values for meshInstance #8820

@AlexAPPi

Description

@AlexAPPi

Sometimes, for mesh instances, it is useful to have a dedicated proxy function that overrides the original position. For example, in the case of prefabs where world coordinates are defined relative to an internal root node, this helps avoid sending redundant data through the (model_matrix) | (matrix_normal) uniform channel.

It is worth considering adding such a feature.


setMeshInstanceMatrices(meshInstance, setNormalMatrix = false) {

Prototype:

    setMeshInstanceMatrices(meshInstance, setNormalMatrix = false) {
        const modelMatrix = meshInstance.customModelMatrix ?? meshInstance.node.worldTransform;
        this.modelMatrixId.setValue(modelMatrix.data);
        if (setNormalMatrix) {
            this.normalMatrixId.setValue((meshInstance.customNormalMatrix ?? meshInstance.node.normalMatrix).data);
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions