Importing model into three.js - performance

后端 未结 3 2024
南笙
南笙 2020-12-30 17:01

Is there a good/recommended approach regarding performance to load a 3D model from file to be used in a three.js JavaScript application (especially where the model is genera

3条回答
  •  难免孤独
    2020-12-30 17:48

    I saw your comment on my question and I can confirm I used Blender 2.68a. To load from openctm format I did:

    var loader = new THREE.CTMLoader();
    ...
    loader.load( 'models/basic_model.ctm',  function( geometry, material ){
        // create mesh and position it
        var material = new THREE.MeshPhongMaterial({ color: 0xEEEEEE, shininess: 100, side: THREE.DoubleSide }),
            mesh = new THREE.Mesh( geometry, material );
        // Faces have an orientation that orientation decides which side is which. And the culling removes the backside in normal circumstances
    
        mesh.position = position;
        mesh.scale.set( 30, 30, 30 );
    
        // render
        scene.add( mesh );
        render();
    
        meshes[ 'basic_model' ] = mesh;
    }, {} );
    

    You need to export from Blender using the openctm export plugin and to include js-openctm in your project. Don't remember more details, as I'm working on completely different stuff now.

    PS: I'm pretty sure I had to manually load the openctm plugin into Blender for it to work

提交回复
热议问题