Skip to content

TextureLoader return different data between node-three-gltf and threejs on transparent pixel #7

@misty000

Description

@misty000

I load a png image with transparent pixel
threejs is 0,0,0,0
image

// three_r148/src/extras/ImageUtils.js after line 49
const context = canvas.getContext('2d')
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
console.log(imageData)
for (let i = 0; i < imageData.width * imageData.height; i++) {
	const r = imageData.data[i * 4]
	const g = imageData.data[i * 4 + 1]
	const b = imageData.data[i * 4 + 2]
	const a = imageData.data[i * 4 + 3]
	console.log(i, '--', r, g, b, a)
}

node-three-gltf is 255,255,255,0
image

const textureLoader = new TextureLoader()
const metalnessMap = await textureLoader.loadAsync('./assets/textures/metalness.png')
// metalnessMap.encoding = sRGBEncoding

if (metalnessMap?.source?.data) {
    const imageData = metalnessMap.source.data
    for (let i = 0; i < imageData.width * imageData.height; i++) {
        const r = imageData.data[i * 4]
        const g = imageData.data[i * 4 + 1]
        const b = imageData.data[i * 4 + 2]
        const a = imageData.data[i * 4 + 3]
        console.log(i, '--', r, g, b, a)
    }
}

image.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions