# LightProbeGenerator static methods 'fromCubeTexture' Error

**URL:** https://discourse.threejs.org/t/lightprobegenerator-static-methods-fromcubetexture-error/36416
**Category:** Questions
**Tags:** light-probes
**Created:** [March 27, 2022, 12:23pm UTC](https://discourse.threejs.org/t/lightprobegenerator-static-methods-fromcubetexture-error/36416 "2022-03-27T12:23:35Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![OliverXH](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/oliverxh/32/13263_2.png) [@OliverXH](https://discourse.threejs.org/u/OliverXH)
#### Post date: [March 27, 2022, 12:23pm UTC](https://discourse.threejs.org/t/lightprobegenerator-static-methods-fromcubetexture-error/36416/1 "2022-03-27T12:23:35Z")

</div>

Here is my code:

```javascript
rgbeLoader.load('venice_sunset_1k.hdr', (texture)=>{

    const rt = new THREE.WebGLCubeRenderTarget(texture.image.height);
    rt.fromEquirectangularTexture(renderer, texture);
    
    const cubeTexture = rt.texture;

    console.log(cubeTexture.image);

    lightProbe.copy(LightProbeGenerator.fromCubeTexture(cubeTexture));

});

```

I use `RGBELoader` to load `.hdr` equirectangular texture, and generate a cube texture through `WebGLCubeRenderTarget`. Then use the static methods `fromCubeTexture` of `LightProbeGenerator` to generate a light probe, but I got an error:

```javascript
Uncaught (in promise) TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(CSSImageValue or HTMLCanvasElement or HTMLImageElement or HTMLVideoElement or ImageBitmap or OffscreenCanvas or SVGImageElement or VideoFrame)'.

```

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/b/e/bebe72a83d8ffa2aadede216b1dbad04ee9fde5b.png)

In [`fromCubeTexture`](https://github.com/mrdoob/three.js/blob/8921bfaee413e809cb2d27f0aec917408d690a0f/examples/jsm/lights/LightProbeGenerator.js#L42) method, it will use the `image`, but the `image` value is not an instance of `HTMLImageElement`:

```javascript
// ...
const image = cubeTexture.image[faceIndex];
// ...
context.drawImage( image, 0, 0, width, height );
// ...

```

![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/c/b/cb0c87f92281d4c7a39e8abb9abcdb34ee478237.png)  
Is there any solution?

---

<div class="post-metadata">

### Author: ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)
#### Post date: [March 27, 2022, 1:20pm UTC](https://discourse.threejs.org/t/lightprobegenerator-static-methods-fromcubetexture-error/36416/2 "2022-03-27T13:20:01Z")

</div>

> [@OliverXH](#):
>
> `LightProbeGenerator.fromCubeTexture(cubeTexture)`

Use the method `LightProbeGenerator.fromCubeRenderTarget()`. `fromCubeTexture()` does not work with a texture from a cube rendertarget.
