Jump to content

TS2339: Property specularColor does not exist on type Material


JohnnyDevNull
 Share

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...

Link to comment
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?

Link to comment
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;
    };

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...