[SOLVED] How do we import a blender mesh in Run Kit + npm?

I have ready blender fbx & obj file; how do I import it in the “Playcanvas RunKit” ?

const canvas = document.getElementById('application');

const app = new pc.Application(canvas);

app.setCanvasFillMode(pc.FILLMODE_FILL_WINDOW);

app.setCanvasResolution(pc.RESOLUTION_AUTO);

window.addEventListener('resize', () => app.resizeCanvas());


// I want to display the blender mesh instead of Box shape/ Model

const box = new pc.Entity('cube');

box.addComponent('model', {

    type: 'box'

});

app.root.addChild(box);

// create camera entity

const camera = new pc.Entity('camera');

camera.addComponent('camera', {

    clearColor: new pc.Color(0.1, 0.1, 0.1)

});

app.root.addChild(camera);

camera.setPosition(0, 0, 3);

// create directional light entity

const light = new pc.Entity('light');

light.addComponent('light');

app.root.addChild(light);

light.setEulerAngles(45, 0, 0);

// rotate the box according to the delta time since the last frame

app.on('update', dt => box.rotate(10 * dt, 20 * dt, 30 * dt));

app.start();

Hi @devstu,

You can export your Blender mesh to GLB and then load it using this example code:

https://playcanvas.github.io/#/loaders/glb

2 Likes

Thank you so much @Leonidas. SOLVED

1 Like