Sign in to follow this  
JohnnyDevNull

TS2339: Property specularColor does not exist on type Material

Recommended Posts

Hi there,

i have ported the world axes example from http://doc.babylonjs.com/snippets/world_axes into my Angular-Babylon template, but getting the following error:

let makeTextPlane = function(text, color, size) {
  let dynamicTexture = new BABYLON.DynamicTexture('DynamicTexture', 50, $scope.scene, true);
  dynamicTexture.hasAlpha = true;
  dynamicTexture.drawText(text, 5, 40, 'bold 36px Arial', color , 'transparent', true);
  let plane = BABYLON.Mesh.CreatePlane('TextPlane', size, $scope.scene, true);
  plane.material = new BABYLON.StandardMaterial('TextPlaneMaterial', $scope.scene);
  plane.material.backFaceCulling = false;
  plane.material.specularColor = new BABYLON.Color3(0, 0, 0);
  plane.material.diffuseTexture = dynamicTexture;
  return plane;
};
webpack: Compiled with warnings.
ERROR in src/app/engine/engine.service.ts(91,22): error TS2339: Property 'specularColor' does not exist on type 'Material'.
src/app/engine/engine.service.ts(92,22): error TS2339: Property 'diffuseTexture' does not exist on type 'Material'.

I can only fix it with an <any> in front of the BABYLON.Mesh.CreatePlane() function.

Am i doing something wrong here?

I don't think that this should be the right way...

Share this post


Link to post
Share on other sites

Sorry but i'am a little bit confused...

my workaround for now is as followed:

    let makeTextPlane = function(text: string, color: string, textSize: number) {
      let dynamicTexture = new BABYLON.DynamicTexture('DynamicTexture', 50, $scope.scene, true);
      dynamicTexture.hasAlpha = true;
      dynamicTexture.drawText(text, 5, 40, 'bold 36px Arial', color , 'transparent', true);
      // @todo fix <any> - actual a hack for @types Error...
      let plane = <any>BABYLON.Mesh.CreatePlane('TextPlane', textSize, $scope.scene, true);
      plane.material = new BABYLON.StandardMaterial('TextPlaneMaterial', $scope.scene);
      plane.material.backFaceCulling = false;
      plane.material.specularColor = new BABYLON.Color3(0, 0, 0);
      plane.material.diffuseTexture = dynamicTexture;
      return plane;
    };

Sorry i'am not as familiar with typescript than with javascript or php, but how can i overwrite an existing propeties type from an instance?

Share this post


Link to post
Share on other sites

Here is how you can do it:

 let makeTextPlane = function(text: string, color: string, textSize: number) {
      let dynamicTexture = new BABYLON.DynamicTexture('DynamicTexture', 50, $scope.scene, true);
      dynamicTexture.hasAlpha = true;
      dynamicTexture.drawText(text, 5, 40, 'bold 36px Arial', color , 'transparent', true);
      // @todo fix <any> - actual a hack for @types Error...
      let plane = BABYLON.Mesh.CreatePlane('TextPlane', textSize, $scope.scene, true);
      let material = new BABYLON.StandardMaterial('TextPlaneMaterial', $scope.scene);
      plane.material = material;
      material.backFaceCulling = false;
      material.specularColor = new BABYLON.Color3(0, 0, 0);
      material.diffuseTexture = dynamicTexture;
      return plane;
    };

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.