# Running the 3d Model code sample in sandcastle

**URL:** <https://community.cesium.com/t/running-the-3d-model-code-sample-in-sandcastle/4949>\
**Category:** CesiumJS\
**Created:** [December 23, 2016, 5:26pm UTC](https://community.cesium.com/t/running-the-3d-model-code-sample-in-sandcastle/4949 "2016-12-23T17:26:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sabah\_Motamedi](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@Sabah\_Motamedi](https://community.cesium.com/u/Sabah_Motamedi)\
**Post date:** [December 23, 2016, 5:26pm UTC](https://community.cesium.com/t/running-the-3d-model-code-sample-in-sandcastle/4949/1 "2016-12-23T17:26:25Z")

</div>

Hello,

Please help me,

I'm using the 3d Model code sample in sandcastle but it not run correctly. I runs but don't search for 3d models.

In this line there is error(line 40): var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);

Error description:

Uncaught TypeError: Cesium.HeadingPitchRoll is not a constructor  
&nbsp;&nbsp;&nbsp;&nbsp;at createModel (3D%20Models2.html:40)  
&nbsp;&nbsp;&nbsp;&nbsp;at Object.onselect (3D%20Models2.html:64)  
&nbsp;&nbsp;&nbsp;&nbsp;at HTMLSelectElement.menu.onchange (Sandcastle-header.js:57)

I attached image from error message,

This code is code from 3d model in sandcastle:

\<!DOCTYPE html\>  
\<html lang="en"\>  
\<head\>  
&nbsp;&nbsp;\<!-- Use correct character set. --\>  
&nbsp;&nbsp;\<meta charset="utf-8"\>  
&nbsp;&nbsp;\<!-- Tell IE to use the latest, best version. --\>  
&nbsp;&nbsp;\<meta http-equiv="X-UA-Compatible" content="IE=edge"\>  
&nbsp;&nbsp;\<!-- Make the application on mobile take up the full browser screen and disable user scaling. --\>  
&nbsp;&nbsp;\<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"\>  
&nbsp;&nbsp;\<title\>3d models\</title\>  
&nbsp;&nbsp;\<script type="text/javascript" src="../Sandcastle-header.js"\>\</script\>  
&nbsp;&nbsp;\<script src="../Build/Cesium/Cesium.js"\>\</script\>  
&nbsp;&nbsp;\<style\>  
&nbsp;&nbsp;&nbsp;&nbsp;@import url(../templates/bucket.css);  
&nbsp;&nbsp;&nbsp;&nbsp;@import url(../Build/Cesium/Widgets/widgets.css);  
&nbsp;&nbsp;html, body, #cesiumContainer {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
\</style\>  
&nbsp;&nbsp;  
\</head\>  
\<body\>  
\<div id="cesiumContainer" class="fullSize"\>\</div\>  
\<div id="loadingOverlay"\>\<h1\>Loading...\</h1\>\</div\>  
\<div id="toolbar"\>\</div\>  
&nbsp;&nbsp;\<script\>  
var viewer = new Cesium.Viewer('cesiumContainer', {  
&nbsp;&nbsp;&nbsp;&nbsp;infoBox : false,  
&nbsp;&nbsp;&nbsp;&nbsp;selectionIndicator : false,  
&nbsp;&nbsp;&nbsp;&nbsp;shadows : true  
});

function createModel(url, height) {  
&nbsp;&nbsp;&nbsp;&nbsp;viewer.entities.removeAll();

&nbsp;&nbsp;&nbsp;&nbsp;var position = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);  
&nbsp;&nbsp;&nbsp;&nbsp;var heading = Cesium.Math.toRadians(135);  
&nbsp;&nbsp;&nbsp;&nbsp;var pitch = 0;  
&nbsp;&nbsp;&nbsp;&nbsp;var roll = 0;  
&nbsp;&nbsp;&nbsp;&nbsp;var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);  
&nbsp;&nbsp;&nbsp;&nbsp;var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr);

&nbsp;&nbsp;&nbsp;&nbsp;var entity = viewer.entities.add({  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name : url,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;position : position,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;orientation : orientation,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;model : {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;uri : url,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minimumPixelSize : 128,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;maximumScale : 20000  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;&nbsp;&nbsp;});  
&nbsp;&nbsp;&nbsp;&nbsp;viewer.trackedEntity = entity;  
}

var options = [{  
&nbsp;&nbsp;&nbsp;&nbsp;text : 'Aircraft',  
&nbsp;&nbsp;&nbsp;&nbsp;onselect : function() {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;createModel('../../SampleData/models/CesiumAir/Cesium\_Air.glb', 5000.0);  
&nbsp;&nbsp;&nbsp;&nbsp;}  
}, {  
&nbsp;&nbsp;&nbsp;&nbsp;text : 'Ground vehicle',  
&nbsp;&nbsp;&nbsp;&nbsp;onselect : function() {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;createModel('../../SampleData/models/CesiumGround/Cesium\_Ground.glb', 0);  
&nbsp;&nbsp;&nbsp;&nbsp;}  
}, {  
&nbsp;&nbsp;&nbsp;&nbsp;text : 'Hot Air Balloon',  
&nbsp;&nbsp;&nbsp;&nbsp;onselect : function() {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;createModel('../../SampleData/models/CesiumBalloon/CesiumBalloon.glb', 1000.0);  
&nbsp;&nbsp;&nbsp;&nbsp;}  
}, {  
&nbsp;&nbsp;&nbsp;&nbsp;text : 'Milk truck',  
&nbsp;&nbsp;&nbsp;&nbsp;onselect : function() {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;createModel('../../SampleData/models/CesiumMilkTruck/CesiumMilkTruck-kmc.glb', 0);  
&nbsp;&nbsp;&nbsp;&nbsp;}  
}, {  
&nbsp;&nbsp;&nbsp;&nbsp;text : 'Skinned character',  
&nbsp;&nbsp;&nbsp;&nbsp;onselect : function() {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;createModel('../../SampleData/models/CesiumMan/Cesium\_Man.glb', 0);  
&nbsp;&nbsp;&nbsp;&nbsp;}  
}];

Sandcastle.addToolbarMenu(options);

&nbsp;&nbsp;\</script\>

\</body\>  
\</html\>

---

<div class="post-metadata">

**Author:** ![hannah](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/hannah/32/4509_2.png) [@hannah](https://community.cesium.com/u/hannah)\
**Post date:** [December 27, 2016, 3:22pm UTC](https://community.cesium.com/t/running-the-3d-model-code-sample-in-sandcastle/4949/2 "2016-12-27T15:22:35Z")

</div>

Hello,

The example you posted runs fine on our website: [http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=3D%20Models.html&label=Showcases](http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=3D%20Models.html&label=Showcases)

What version of Cesium are you using? Have you tried clearing your cookies/cache? Sometimes that can have unusual side effects.

Best,

Hannah

---

<div class="post-metadata">

**Author:** ![Sabah\_Motamedi](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@Sabah\_Motamedi](https://community.cesium.com/u/Sabah_Motamedi)\
**Post date:** [December 27, 2016, 10:33pm UTC](https://community.cesium.com/t/running-the-3d-model-code-sample-in-sandcastle/4949/3 "2016-12-27T22:33:56Z")

</div>

Hello,

Do you tried to run my code that i sent for you?

I’m use a version 1.21.

I don’t know how to clear cookies/cache,

Best,

Sabah

---

<div class="post-metadata">

**Author:** ![hannah](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/hannah/32/4509_2.png) [@hannah](https://community.cesium.com/u/hannah)\
**Post date:** [December 28, 2016, 3:57pm UTC](https://community.cesium.com/t/running-the-3d-model-code-sample-in-sandcastle/4949/4 "2016-12-28T15:57:49Z")

</div>

The code isn’t working because you are using an old version of Cesium and the HeadingPitchRoll class isn’t defined. Please update to the latest version and the example should work.

-Hannah
