# My .obj failing to work with loadModel() - " Cannot read property 'vertices' of undefined"

**URL:** <https://discourse.processing.org/t/my-obj-failing-to-work-with-loadmodel-cannot-read-property-vertices-of-undefined/22909>\
**Category:** Coding Questions\
**Created:** [July 29, 2020, 3:07pm UTC](https://discourse.processing.org/t/my-obj-failing-to-work-with-loadmodel-cannot-read-property-vertices-of-undefined/22909 "2020-07-29T15:07:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TinkererDuty](https://avatars.discourse-cdn.com/v4/letter/t/71c47a/32.png) [@TinkererDuty](https://discourse.processing.org/u/TinkererDuty)\
**Post date:** [July 29, 2020, 3:07pm UTC](https://discourse.processing.org/t/my-obj-failing-to-work-with-loadmodel-cannot-read-property-vertices-of-undefined/22909/1 "2020-07-29T15:07:06Z")

</div>

Hi all,

Apologies if this makes no sense as I’m fairly new to p5.

I’m having trouble trying to get my .obj to work with loadModel() in my code.

What I’m hoping is to allow the user to select an .obj of their choice and have it appear on the canvas.

I am using “createGraphics()” instead of another canvas as that initially didn’t work and I’ve read more than one canvas can cause unintended issues.

Please see below:

```auto
let objCreation;

let loadModelOn;

let lamp;

function preload()

{

  lamp = loadModel("/lamp.obj");

}

function setup() {

  objCreation = createGraphics(1500, 1500, WEBGL);

}

function draw() {

  // BEGGINNING OF loadModel 

  loadModelObj = createButton("Δ");

  loadModelObj.position(1261.5, 953);

  loadModelObj.mousePressed(loadModelOn);

  loadModelOn = () => {

    objCreation.model(lamp);

    objCreation.frameRate(60);

    objCreation.background(150);

    objCreation.ambientLight(100);

    objCreation.directionalLight(255, 255, 255, 0, 0, 1);

    objCreation.rotateX(frameCount * 0.05);

    objCreation.rotateY(frameCount * 0.05);

  }

  image(objCreation, 0, 0);

}

```

There is more code but is redundant for this issue so I’ve isolated it to what the issue is.

I appreciate any and all input! 🙂

Many thanks
