createBox(device, [opts])

createBox(device, [opts]) in this line of code device parameter is graphicsDevice. What is mean by graphicsDevice
I tried with pc.createBox(“graphicsDevice”) and pc.createBox(graphicsDevice) but it is not working

Assuming you mean this function and you are using it in a gamescript: pc | PlayCanvas API Reference

The first param takes an instead of the graphicsDevice object which is created on the application object: Application | PlayCanvas API Reference

const boxMesh = pc.createBox(, {
    // Options for the size of the box and other properties

However, if you are doing this in the Editor it is recommended to use the renderComponent on an Entity instead

// Assuming there isn't a render component on the entity already
this.entity.addComponent('render', {
    type: 'box'
1 Like

It’s useful to call directly only if you want to pass some other creation parameters. For example see PlayCanvas Examples - the createHighQualitySphere function creates the sphere directly, to be able to create higher subdivision for smoother sphere

        const mesh = pc.createSphere(app.graphicsDevice, {
            latitudeBands: 200,
            longitudeBands: 200,

In order to render it, you can either go the route of creating a mesh instance + graph node etc. or simply use app.renderMesh:

app =;
mesh = pc.createBox(app.graphicsDevice);
material = new pc.StandardMaterial();
mat4 = new pc.Mat4();
if (typeof meshUpdate !== 'undefined') {'update', meshUpdate)
function meshUpdate() {
    Math.sin( * 0.005),
    Math.cos( * 0.005),
    Math.tan( * 0.005)
  app.renderMesh(mesh, material, mat4);
app.on('update', meshUpdate);

(you can just open f12/devtools and execute it on any PlayCanvas code, as long as pc or app is accessible)

1 Like