Skip to content

Commit

Permalink
fix: Error in derived materials in Three r170
Browse files Browse the repository at this point in the history
They changed Material.type to a getter that queries the object's constructor
  • Loading branch information
lojjic committed Nov 1, 2024
1 parent f8bd307 commit 2402026
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/troika-three-utils/src/DerivedMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ let materialInstanceId = 1e10
* output value. Will be injected near the end of the `void main` function, but before any
* of ThreeJS's color postprocessing shader chunks (tonemapping, fog, etc.), and before the
* `fragmentMainOutro`.
* @param {function({fragmentShader: string, vertexShader:string}):
* @param {function({fragmentShader: string, vertexShader:string}):
* {fragmentShader: string, vertexShader:string}} options.customRewriter - A function
* for performing custom rewrites of the full shader code. Useful if you need to do something
* special that's not covered by the other builtin options. This function will be executed before
Expand Down Expand Up @@ -170,6 +170,11 @@ export function createDerivedMaterial(baseMaterial, options) {
constructor: {value: DerivedMaterial},
isDerivedMaterial: {value: true},

type: {
get: () => baseMaterial.type,
set: (value) => {baseMaterial.type = value}
},

isDerivedFrom: {
writable: true,
configurable: true,
Expand Down

0 comments on commit 2402026

Please sign in to comment.