Skip to content

Commit 2402026

Browse files
committedNov 1, 2024
fix: Error in derived materials in Three r170
They changed Material.type to a getter that queries the object's constructor
1 parent f8bd307 commit 2402026

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

Diff for: ‎packages/troika-three-utils/src/DerivedMaterial.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ let materialInstanceId = 1e10
6666
* output value. Will be injected near the end of the `void main` function, but before any
6767
* of ThreeJS's color postprocessing shader chunks (tonemapping, fog, etc.), and before the
6868
* `fragmentMainOutro`.
69-
* @param {function({fragmentShader: string, vertexShader:string}):
69+
* @param {function({fragmentShader: string, vertexShader:string}):
7070
* {fragmentShader: string, vertexShader:string}} options.customRewriter - A function
7171
* for performing custom rewrites of the full shader code. Useful if you need to do something
7272
* special that's not covered by the other builtin options. This function will be executed before
@@ -170,6 +170,11 @@ export function createDerivedMaterial(baseMaterial, options) {
170170
constructor: {value: DerivedMaterial},
171171
isDerivedMaterial: {value: true},
172172

173+
type: {
174+
get: () => baseMaterial.type,
175+
set: (value) => {baseMaterial.type = value}
176+
},
177+
173178
isDerivedFrom: {
174179
writable: true,
175180
configurable: true,

0 commit comments

Comments
 (0)
Please sign in to comment.