0
votes

I am working on a web app which will render 3D animated models. These models made by 'Maya 2016'. I am exporting these models using three.js (r81) 'maya exporter plugin' (You can check maya exporter plugin here). link, When i am loading this exported json model using below code:

var objectLoader = new THREE.ObjectLoader(manager);
objectLoader.load( 'assets/New-Heart/full_heart.json', function (object) {            
    scene.add(object);
}, onProgress, onError );

Then it is giving following error: Uncaught TypeError: Materials[json.type] is not a constructor in three.js library file (var material = new Materials json.type ;) on line no : 31381

Please help me to fix this issue. any suggestion would be appreciable.

1

1 Answers

0
votes

I was experiencing this error earlier today. I ended up checking what my json.type was in the json object I passed to see if it matched any of the types in the Materials object. It was an old object file from R72, and the type it was returning was "MeshFaceMaterial". But that type no longer exists in R82. Here is the object with the list of materials in ThreeJs R82. If your type isn't in here, that is why you are getting the error.

var Materials = Object.freeze({
    ShadowMaterial: ShadowMaterial,
    SpriteMaterial: SpriteMaterial,
    RawShaderMaterial: RawShaderMaterial,
    ShaderMaterial: ShaderMaterial,
    PointsMaterial: PointsMaterial,
    MultiMaterial: MultiMaterial,
    MeshPhysicalMaterial: MeshPhysicalMaterial,
    MeshStandardMaterial: MeshStandardMaterial,
    MeshPhongMaterial: MeshPhongMaterial,
    MeshNormalMaterial: MeshNormalMaterial,
    MeshLambertMaterial: MeshLambertMaterial,
    MeshDepthMaterial: MeshDepthMaterial,
    MeshBasicMaterial: MeshBasicMaterial,
    LineDashedMaterial: LineDashedMaterial,
    LineBasicMaterial: LineBasicMaterial,
    Material: Material
});