Skip to content

Regression in release 2.3.0, materials are no longer updated #605

@jellynoone

Description

@jellynoone

I recently started experimenting with this library. My use case is loading a simple model and then changing some material textures dynamically at runtime. This works with io.github.sceneview:arsceneview:2.2.1, today I tried out the new release io.github.sceneview:arsceneview:2.3.0 and the same code no longer does.

Relevant bits.

fun updateTexture(node: ModelNode, bitmap: Bitmap): Boolean {
    val material = findMaterial(node) ?: return false
    val texture = createTexture(node.engine, bitmap)
    material.setBaseColorMap(texture)
    return true
}

fun findMaterial(node: ModelNode): MaterialInstance? {
    node.materialInstances.forEach {
        it.forEach {
            if (/* insert filter */) {
                return it
            }
        }
    }

    return null
}


fun createTexture(engine: Engine, bitmap: Bitmap): Texture {
    val texture = Texture.Builder()
        .width(bitmap.width)
        .height(bitmap.height)
        .sampler(Texture.Sampler.SAMPLER_2D)
        .build(engine)

    texture.setBitmap(engine, bitmap)

    return texture
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions