Andrey Lastovetskiy
Andrey Lastovetskiy

Reputation: 11

Three JS ColladaLoader

Kind people, please tell me how to use the parse method of the ColladaLoader class. I searched the whole Internet, but I didn't find a solution. I use the dae file as the model file. I compared the source code of the dae file, and the code that lies in JS, there are no differences.

I have a code where I just use the parse method. I used an ordinary red cube as a model.

let fileContents = <?= json_encode($decryptedContent); ?>; // the contents of the *.dae file
const loader = new ColladaLoader();
console.log(fileContents);
        
loader.parse(fileContents, function ( collada ) {
    const avatar = collada.scene; // model
    console.log(avatar);
    avatar.scale.set (1, 1, 1);
    avatar.position.set(0, 0, 0);
    scene.add( avatar );
});

The problem is that there is an alternative code that works properly. Actually, here it is, the cube is displayed here and everything works as it should.

const loader = new ColladaLoader();
loader.load( '/*.dae', function ( collada ) {
    const avatar = collada.scene; // model
    console.log(avatar);
    avatar.scale.set (0.3, 0.3, 0.3);
    avatar.position.set(0, 1, 0);
    scene.add( avatar );
} );

Upvotes: 1

Views: 44

Answers (0)

Related Questions