margelo / react-native-filament

🐧 A real-time physically based 3D rendering engine for React Native
https://margelo.github.io/react-native-filament/
MIT License
952 stars 17 forks source link

DataTexture support. #245

Open NikitaDudin opened 3 months ago

NikitaDudin commented 3 months ago

It would be a good to have a possibility to create a textureSource directly from raw data, width and height.

const textureWidth = 1024;
const textureHeight = 1024;
const textureData = new Uint8Array(textureWidth * textureHeight * 4);
for (let i = 0; i < textureWidth * textureHeight * 4; i += 4) {
  textureData[i] = 255; // r
  textureData[i+1] = 0; // g
  textureData[i+2] = 0; // b
  textureData[i+3] = 255; // a
}
...
const textureSource = createBufferFromRawData(textureData, textureWidth, textureHeight, ...otherOptions);
...
<Model ...>
<EntitySelector byName="Tip" textureMap={{ materialName, textureSource }} />
</Model>