Three.js: TS: Property 'uniforms' does not exist on type 'Material'.

Created on 22 May 2020  Â·  2Comments  Â·  Source: mrdoob/three.js

Description of the problem

Hi, I'm updated my Three.js version version 0.100.0 to 0.116.0 in my own project.

And, that's happened.

my code

import * as THREE from 'three';
import {
  GPUComputationRenderer,
  Variable
} from 'three/examples/jsm/misc/GPUComputationRenderer';

const fooTex = gpuCompute.createTexture();

// my function
fillTextures( fooTex );

const fooVar = gpuCompute.addVariable( 'textureVelocity', computeShaderFoo(), fooTex );
const velocityUniforms = fooVar.material.uniforms;

compiler said

ERROR in /Users/my-projects/src/index.ts(84,44)
      TS2339: Property 'uniforms' does not exist on type 'Material'.

So, I suspected what's wrong is type definition file, then I rewrite like below, finnaly it works!

three/examples/jsm/misc/GPUComputationRenderer.d.ts
line on 16

export interface Variable {
    name: string;
    initialValueTexture: Texture;
    // material: Material;  
        material: ShaderMaterial;
    dependencies: Variable[];
    renderTargets: RenderTarget[];
    wrapS: number;
    wrapT: number;
    minFilter: number;
    magFilter: number;
}
Node Version

v12.11.1

other dependencies

"ts-loader": "^7.0.1",
"typescript": "^3.8.3",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"

Three.js version
  • [ ] Dev
  • [x] r116
  • [ ] ...
Browser
  • [ ] All of them
  • [x] Chrome
  • [ ] Firefox
  • [ ] Internet Explorer
OS
  • [ ] All of them
  • [x] Windows
  • [ ] macOS
  • [ ] Linux
  • [ ] Android
  • [ ] iOS
Bug TypeScript

Most helpful comment

Thank you for confirming, I will push a PR later.

2020年5月22日(金) 21:08 Michael Herzog notifications@github.com:

Would you like to make a PR with the fix? Yes, the type of material has
to be ShaderMaterial.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/mrdoob/three.js/issues/19421#issuecomment-632658995,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AJ2YXQ7WBX7Q6JNIPCUU6WLRSZTKBANCNFSM4NHXFF3A
.

All 2 comments

Would you like to make a PR with the fix? Yes, the type of material has to be ShaderMaterial.

Thank you for confirming, I will push a PR later.

2020年5月22日(金) 21:08 Michael Herzog notifications@github.com:

Would you like to make a PR with the fix? Yes, the type of material has
to be ShaderMaterial.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/mrdoob/three.js/issues/19421#issuecomment-632658995,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AJ2YXQ7WBX7Q6JNIPCUU6WLRSZTKBANCNFSM4NHXFF3A
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

akshaysrin picture akshaysrin  Â·  3Comments

fuzihaofzh picture fuzihaofzh  Â·  3Comments

filharvey picture filharvey  Â·  3Comments

danieljack picture danieljack  Â·  3Comments

zsitro picture zsitro  Â·  3Comments