Skip to content
Snippets Groups Projects
Commit e8e8870b authored by Alexander Rose's avatar Alexander Rose
Browse files

fixed inadvertedly shared array for color textures

parent da4368c6
No related branches found
No related tags found
No related merge requests found
...@@ -34,14 +34,6 @@ export function createColors(ctx: RuntimeContext, locationIt: LocationIterator, ...@@ -34,14 +34,6 @@ export function createColors(ctx: RuntimeContext, locationIt: LocationIterator,
} }
} }
const emptyColorTexture = { array: new Uint8Array(3), width: 1, height: 1 }
function createEmptyColorTexture() {
return {
tColor: ValueCell.create(emptyColorTexture),
uColorTexDim: ValueCell.create(Vec2.create(1, 1))
}
}
export function createValueColor(value: Color, colorData?: ColorData): ColorData { export function createValueColor(value: Color, colorData?: ColorData): ColorData {
if (colorData) { if (colorData) {
ValueCell.update(colorData.uColor, Color.toRgbNormalized(value) as Vec3) ValueCell.update(colorData.uColor, Color.toRgbNormalized(value) as Vec3)
...@@ -53,7 +45,8 @@ export function createValueColor(value: Color, colorData?: ColorData): ColorData ...@@ -53,7 +45,8 @@ export function createValueColor(value: Color, colorData?: ColorData): ColorData
return { return {
uColor: ValueCell.create(Color.toRgbNormalized(value) as Vec3), uColor: ValueCell.create(Color.toRgbNormalized(value) as Vec3),
aColor: ValueCell.create(new Float32Array(0)), aColor: ValueCell.create(new Float32Array(0)),
...createEmptyColorTexture(), tColor: ValueCell.create({ array: new Uint8Array(3), width: 1, height: 1 }),
uColorTexDim: ValueCell.create(Vec2.create(1, 1)),
dColorType: ValueCell.create('uniform'), dColorType: ValueCell.create('uniform'),
} }
} }
...@@ -85,7 +78,7 @@ export function createTextureColor(colors: TextureImage, type: ColorType, colorD ...@@ -85,7 +78,7 @@ export function createTextureColor(colors: TextureImage, type: ColorType, colorD
/** Creates color texture with color for each instance/unit */ /** Creates color texture with color for each instance/unit */
export async function createInstanceColor(ctx: RuntimeContext, locationIt: LocationIterator, color: LocationColor, colorData?: ColorData): Promise<ColorData> { export async function createInstanceColor(ctx: RuntimeContext, locationIt: LocationIterator, color: LocationColor, colorData?: ColorData): Promise<ColorData> {
const { instanceCount} = locationIt const { instanceCount } = locationIt
const colors = colorData && colorData.tColor.ref.value.array.length >= instanceCount * 3 ? colorData.tColor.ref.value : createTextureImage(instanceCount, 3) const colors = colorData && colorData.tColor.ref.value.array.length >= instanceCount * 3 ? colorData.tColor.ref.value : createTextureImage(instanceCount, 3)
let i = 0 let i = 0
while (locationIt.hasNext) { while (locationIt.hasNext) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment