Question

Following this question : How can I have a custom default scene in the three.js editor? I tried to load a .ctm file. However, it seems to not use the same method. What must I do to get it load properly?

Was it helpful?

Solution

Unlike and .obj file which probably contained information about the materials and geometries, the CTM file only contains information about the geometries.

So if you look at the code of the ThreeJs Editor here you will find that it loads the geometries from the CTM file and manually creates a MeshPhongMaterial and then creates a mesh using these two and adds it to the editor.scene.

So the complete code will be something like this would be

var loaderCTM = new THREE.CTMLoader( true );


            loaderCTM.load( "models/camaro/camaro.ctm", function( geometry  ) {

                    var material = new THREE.MeshPhongMaterial();

                    var mesh = new THREE.Mesh( geometry, material );
                    mesh.name = "camero";

                    editor.addObject( mesh );
                    editor.select( mesh );


            }, false );

I have also created a sample here , you can look around at lines 124 to understand better.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top