Skip to content

Commit

Permalink
Mesh fix material.needsUpdate flag on props object change
Browse files Browse the repository at this point in the history
Fixed / refactored due to `SvelthreeProps` changes after closing #102 -> `mat.needsUpdate` removed from `Propeller`.
  • Loading branch information
Vatroslav Vrbanic committed Jun 20, 2022
1 parent d39342c commit c75bf91
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/Mesh.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,16 @@ svelthree uses svelte-accmod, where accessors are always `true`, regardless of `
// TODO MULTIPLE MATERIALS: this works only with single Material atm, multiple Materials are not implemented yet.
/** **shorthand** attribute for setting properties of a `Material` using key-value pairs in an `Object`. */
export let mat: { [P in keyof AnyMaterialProps]: AnyMaterialProps[P] } = undefined
$: if (mat && sMat) sMat.update(mat)
$: if (mat && sMat) {
const updated_keys: string[] = sMat.update(mat)
if (updated_keys.length) material_needs_update()
}
function material_needs_update(): void {
const current_single_material = material as Material
current_single_material.needsUpdate = true
}
/** ☝️ `matrix` **shorthand** attribute overrides ( *are ignored* ) `pos`, `rot`, `quat`, `scale` and `lookAt` 'shorthand' attributes! */
export let matrix: Matrix4 | Parameters<Matrix4["set"]> = undefined
Expand Down

0 comments on commit c75bf91

Please sign in to comment.