# GLTF object will not load into the scene gives error:error: THREE.WebGLInfo: Unknown draw mode: undefined

**URL:** <https://discourse.threejs.org/t/gltf-object-will-not-load-into-the-scene-gives-error-three-webglinfo-unknown-draw-mode-undefined/63332>\
**Category:** Questions\
**Tags:** obj-loader, object3d, gltf-loader, questions, loaders, gltf, threejs\
**Created:** [March 27, 2024, 3:44pm UTC](https://discourse.threejs.org/t/gltf-object-will-not-load-into-the-scene-gives-error-three-webglinfo-unknown-draw-mode-undefined/63332 "2024-03-27T15:44:56Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Somgolie\_Ejinkeonye](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/somgolie_ejinkeonye/32/46127_2.png) [@Somgolie\_Ejinkeonye](https://discourse.threejs.org/u/Somgolie_Ejinkeonye)\
**Post date:** [March 27, 2024, 3:44pm UTC](https://discourse.threejs.org/t/gltf-object-will-not-load-into-the-scene-gives-error-three-webglinfo-unknown-draw-mode-undefined/63332/1 "2024-03-27T15:44:56Z")

</div>

I was able to import the GLTF loader but it gives be this error that just keeps running forever when I add my object. :error:  
THREE.WebGLInfo: Unknown draw mode: undefined  
I searched it up and **nothing** came up, I don’t know what I can do

 ![15](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/2/3/23cc07ccae454db24d67141808395bed8fb45713.png)  
this is my script:

```javascript
    <html>
    <head>
	
        <meta charset=utf-8>
        <title>Maze</title> 
        <script src="https://three.js.org/build/three.js"></script>
		<script type="importmap">
	{
		"imports": {
			"three": "https://unpkg.com/three@0.160.0/build/three.module.js",
      "three/addons/": "https://unpkg.com/three@0.160.0/examples/jsm/"
		}
	}
</script>
        <script type="module">
		// SOMGOLIE EJINKEONYE COSC3306 ASSIGNMENT 2
		
		
		// Import the Three.js module
		import * as THREE from 'https://unpkg.com/three@0.111.0/build/three.module.js';
        import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
		//import { OrbitControls } from 'three/addons/Controls/OrbitControls.js';
        window.onload = function() { // one big function for all our JavaScript code
  
        //Define the WebGL renderer:
            var object;
      
   const loader = new GLTFLoader();

loader.load( 'Pot Plant.glb', function ( gltf ) {

	scene.add( gltf.scene );

}, undefined, function ( error ) {

	console.error( error );
});
 
        var renderer = new THREE.WebGLRenderer(); // Specify the use of WebGL
        renderer.setSize(1520, 750); // Scene size (Width, Height)
        document.body.appendChild(renderer.domElement);
  renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;

        //Initialize (create) the scene:
        var scene = new THREE.Scene();
   

         //THE CAMERA
        var camera = new THREE.PerspectiveCamera(
                35, // Field of view
                800 / 600, // Aspect ratio
                0.1, // Near plane
                10000 // Far plane
            );
            camera.position.x= 0; //default value anyway
            camera.position.y= 0; //default value anyway
            camera.position.z = 100; //We move the camera backwards to see all the scene
            camera.lookAt(scene.position);
            var object0

			// creating the terrain
             var terrainGeometry = new THREE.PlaneGeometry(600, 620, 199, 199);
             var terrainMaterial = new THREE.MeshLambertMaterial({ color: "brown" }); // Brown color
             var terrain = new THREE.Mesh(terrainGeometry, terrainMaterial);
			 terrain.castShadow=false;
			terrain.receiveShadow=true;
             terrain.rotation.x +=250
			 terrain.position.y -=15
             scene.add(terrain);
			//lights	
			 var pointLight = new THREE.PointLight(0xFFFFFF);
            // set the light position:
            pointLight.position.x = 10;
            pointLight.position.y = 50;
            pointLight.position.z = 100;
            // add the light to the scene:
            scene.add(pointLight);
			
			//the skydome
			var geometry =new THREE.SphereGeometry(100,60,80);
			var texture = new THREE.TextureLoader().load('bluesky.png');
			var material = new THREE.MeshBasicMaterial({map:texture});
			material.side =THREE.BackSide;
			var skydome = new THREE.Mesh(geometry,material);
            
           var geometry = new THREE.BoxGeometry( 6, 16, 6 );
           //It defines colour green:
		   
		   var texture2 = new THREE.TextureLoader().load('check.jpg');
           var material = new THREE.MeshLambertMaterial( {map:texture2} );
		 
           var cube = new THREE.Mesh(geometry,material);
		   cube.castShadow=true;
			cube.receiveShadow=false;
           cube.translateX(10);
           cube.translateZ(70);
			
           scene.add(cube);
		   
		   
		   var geometry = new THREE.BoxGeometry( 6, 16, 6 );
           //It defines colour green:
		   var texture2 = new THREE.TextureLoader().load('check.jpg');
           var material = new THREE.MeshLambertMaterial( {map:texture2} );
		 
           var cube2 = new THREE.Mesh(geometry,material);
		   cube2.castShadow=true;
			cube2.receiveShadow=true;
           cube2.translateX(-10);
           cube2.translateZ(70);
		   //scene.add(cube2);
		   var geometry = new THREE.BoxGeometry( 16, 16, 16 );
           //It defines colour green:
		   var texture2 = new THREE.TextureLoader().load('check.jpg');
           var material = new THREE.MeshLambertMaterial( {map:texture2} );
		 
           var cube3 = new THREE.Mesh(geometry,material);
		   cube3.castShadow=true;
			cube3.receiveShadow=true;
           cube3.translateX(5);
           cube3.translateZ(50);
		   //scene.add(cube3);
            // adding the skydome
           scene.add( skydome );
         //the fog 0.007 is the intensity 
		
const light = new THREE.SpotLight( 0xffffff );
light.castShadow = true; // default false

//Set up shadow properties for the light
light.shadow.mapSize.width = 12; // default
light.shadow.mapSize.height = 12; // default
light.shadow.camera.near = 0.5; // default
light.shadow.camera.far = 50; // default
light.shadow.focus = 1; // default
scene.add( light );

const spotLight = new THREE.SpotLight( 0xffffff ); spotLight.position.set( 100, 1000, 100 ); spotLight.map = new THREE.TextureLoader().load( "https://threejs.org/examples/#webgl_lights_spotlights" ); spotLight.castShadow = true; spotLight.shadow.mapSize.width = 1024; spotLight.shadow.mapSize.height = 1024; spotLight.shadow.camera.near = 500; spotLight.shadow.camera.far = 4000; spotLight.shadow.camera.fov = 30; scene.add( spotLight );
          

		
           			//render the skydome
             function render(){
               requestAnimationFrame(render);
              renderer.render( scene, camera );
            }
			
      

  
			render();
			
        }; // onload function
        </script>
    </head>
    <body></body>
    </html>

```

I’m required to use notepad++ and serverz :

 ![14](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/0/c/0c563e311d022f8fc6ade6ce1d4f4cdd8c4aacb8.png)  
 ![13](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/8/6/86489c8fc99e160b0f9669aba7c6a2fb8d1b2bbc.png)

How can I add the object to the scene?

---

<div class="post-metadata">

**Author:** ![seanwasere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/seanwasere/32/20864_2.png) [@seanwasere](https://discourse.threejs.org/u/seanwasere)\
**Post date:** [March 27, 2024, 4:39pm UTC](https://discourse.threejs.org/t/gltf-object-will-not-load-into-the-scene-gives-error-three-webglinfo-unknown-draw-mode-undefined/63332/2 "2024-03-27T16:39:15Z")

</div>

You still have a problem in the code you are sharing above.

You are mixing threejs versions.

Replace this,

```javascript
import * as THREE from 'https://unpkg.com/three@0.111.0/build/three.module.js';

```

with this

```javascript
import * as THREE from 'three';

```

And in your folder screen grab, I don’t see “Pot plant.glb” in there?

There are many examples of loading GLBs into Threejs on the internet,

Here is another one,

> **[glTF Loader - Part 1](https://sbedit.net/bbf5f1ead0954856f9630f0a3c5b9eed93f4f22c)**
>
> Three.js TypeScript Tutorials by Sean Bradley : https://sbcode.net/threejs

---

<div class="post-metadata">

**Author:** ![Somgolie\_Ejinkeonye](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/somgolie_ejinkeonye/32/46127_2.png) [@Somgolie\_Ejinkeonye](https://discourse.threejs.org/u/Somgolie_Ejinkeonye)\
**Post date:** [March 27, 2024, 5:05pm UTC](https://discourse.threejs.org/t/gltf-object-will-not-load-into-the-scene-gives-error-three-webglinfo-unknown-draw-mode-undefined/63332/3 "2024-03-27T17:05:46Z")

</div>

yeah, the script in the link you gave me worked!!, but for some reason when I replace the link with ‘three’ all the textures disappear

 ![black.PNG](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/e/2/e264c8df9b4aa45f841b11ddbe7435e77dade5bd.jpeg)

---

<div class="post-metadata">

**Author:** ![seanwasere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/seanwasere/32/20864_2.png) [@seanwasere](https://discourse.threejs.org/u/seanwasere)\
**Post date:** [March 27, 2024, 5:08pm UTC](https://discourse.threejs.org/t/gltf-object-will-not-load-into-the-scene-gives-error-three-webglinfo-unknown-draw-mode-undefined/63332/4 "2024-03-27T17:08:03Z")

</div>

The texures disappear because your pointlight intensity is too low.

And your spotlight intensity is also too low.

---

<div class="post-metadata">

**Author:** ![Somgolie\_Ejinkeonye](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/somgolie_ejinkeonye/32/46127_2.png) [@Somgolie\_Ejinkeonye](https://discourse.threejs.org/u/Somgolie_Ejinkeonye)\
**Post date:** [March 27, 2024, 5:11pm UTC](https://discourse.threejs.org/t/gltf-object-will-not-load-into-the-scene-gives-error-three-webglinfo-unknown-draw-mode-undefined/63332/5 "2024-03-27T17:11:03Z")

</div>

```javascript
	 var pointLight = new THREE.PointLight(0xFFFFFF,5);
            // set the light position:
            pointLight.position.x = 10;
            pointLight.position.y = 50;
            pointLight.position.z = 100;
            // add the light to the scene:
            scene.add(pointLight);

```

I changed it to 5, but it’s still black.

---

<div class="post-metadata">

**Author:** ![seanwasere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/seanwasere/32/20864_2.png) [@seanwasere](https://discourse.threejs.org/u/seanwasere)\
**Post date:** [March 27, 2024, 5:12pm UTC](https://discourse.threejs.org/t/gltf-object-will-not-load-into-the-scene-gives-error-three-webglinfo-unknown-draw-mode-undefined/63332/6 "2024-03-27T17:12:05Z")

</div>

Try much much higher

---

<div class="post-metadata">

**Author:** ![Somgolie\_Ejinkeonye](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/somgolie_ejinkeonye/32/46127_2.png) [@Somgolie\_Ejinkeonye](https://discourse.threejs.org/u/Somgolie_Ejinkeonye)\
**Post date:** [March 27, 2024, 5:16pm UTC](https://discourse.threejs.org/t/gltf-object-will-not-load-into-the-scene-gives-error-three-webglinfo-unknown-draw-mode-undefined/63332/7 "2024-03-27T17:16:53Z")

</div>

Ok, it works! thank you so much!!  
btw, I know this is a different question but, why are the textures not wrapping around the cube geometry?  
do you know any way I can fix it?

 ![2side.PNG](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/e/2/e2486630315b097965df86e03ebde6ec6ee38766.jpeg)

---

<div class="post-metadata">

**Author:** ![seanwasere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/seanwasere/32/20864_2.png) [@seanwasere](https://discourse.threejs.org/u/seanwasere)\
**Post date:** [March 27, 2024, 5:23pm UTC](https://discourse.threejs.org/t/gltf-object-will-not-load-into-the-scene-gives-error-three-webglinfo-unknown-draw-mode-undefined/63332/8 "2024-03-27T17:23:12Z")

</div>

Thats the dark side. Reposition your light, or add an ambient light with intensity ‘Math.PI / 16’

Also check your spotlight code, what do think the ‘map’ property is doing. You are loading html into it?

---

<div class="post-metadata">

**Author:** ![Somgolie\_Ejinkeonye](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/somgolie_ejinkeonye/32/46127_2.png) [@Somgolie\_Ejinkeonye](https://discourse.threejs.org/u/Somgolie_Ejinkeonye)\
**Post date:** [March 27, 2024, 5:33pm UTC](https://discourse.threejs.org/t/gltf-object-will-not-load-into-the-scene-gives-error-three-webglinfo-unknown-draw-mode-undefined/63332/9 "2024-03-27T17:33:33Z")

</div>

the map url in the spot light: [three.js examples](https://threejs.org/examples/#webgl_lights_spotlight)  
I don’t think so? I followed the code on the three.js website [three.js docs](https://threejs.org/docs/index.html#api/en/lights/SpotLight) should I remove it?

---

<div class="post-metadata">

**Author:** ![seanwasere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/seanwasere/32/20864_2.png) [@seanwasere](https://discourse.threejs.org/u/seanwasere)\
**Post date:** [March 27, 2024, 5:57pm UTC](https://discourse.threejs.org/t/gltf-object-will-not-load-into-the-scene-gives-error-three-webglinfo-unknown-draw-mode-undefined/63332/10 "2024-03-27T17:57:03Z")

</div>

The threejs docs says,

```javascript
spotLight.map = new THREE.TextureLoader().load( url );

```

but you have

```javascript
spotLight.map = new THREE.TextureLoader().load( "https://threejs.org/examples/#webgl_lights_spotlights" ); 

```

You are loading HTML into your `spotLight.map`

If you look at the specifc [map](https://threejs.org/docs/index.html#api/en/lights/SpotLight.map) property in the docs. It does not say, load HTML into it.

This URL points to a webpage made of HTML.  
`"https://threejs.org/examples/#webgl_lights_spotlights"`

The docs say the property should point to a texture. A texture is an image. Not HTML.

Anyway, do you really need it?

It appears that you have just copy pasted all kinds of things without considering what it does.

---

<div class="post-metadata">

**Author:** ![Somgolie\_Ejinkeonye](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/somgolie_ejinkeonye/32/46127_2.png) [@Somgolie\_Ejinkeonye](https://discourse.threejs.org/u/Somgolie_Ejinkeonye)\
**Post date:** [March 27, 2024, 6:01pm UTC](https://discourse.threejs.org/t/gltf-object-will-not-load-into-the-scene-gives-error-three-webglinfo-unknown-draw-mode-undefined/63332/11 "2024-03-27T18:01:04Z")

</div>

oh, I don’t really need it. yeah you’re right, I was not paying attention, I’ve never really worked with three.js and I didn’t want to mess around too much
