TS: Property ‘uniforms’ does not exist on type ‘Material’.

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
  • r116
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS

1 possible answer(s) on “TS: Property ‘uniforms’ does not exist on type ‘Material’.