Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

Creating Custom visual using Three.js

I'm currently trying to implement Three.js within the PowerBI in order to visualise some meshes. However I don't seem to be having much luck getting the meshes to appear within the Power BI developer window. My main concern is which three.js object should I be appending to the HTMLElement, my code is below. Also I am only using three.js as it was the first mesh library that I cam across, if it is not the best library to use please let me know.

 

code:

constructor(optionsVisualConstructorOptions) {
        let scene = new THREE.Scene();
        console.log('Visual constructor'options);
        this.target = options.element;
        this.updateCount = 0;
        if (document) {
            const new_pHTMLElement = document.createElement("p");
            new_p.appendChild(document.createTextNode("Updates: "));
            const new_emHTMLElement = document.createElement("em");
            this.textNode = document.createTextNode(this.updateCount.toString());
            const new_mHTMLElement = document.createElement("M");
            
            new_em.appendChild(this.textNode);
            new_p.appendChild(new_em);
            this.target.appendChild(new_p);
            this.camera = new THREE.PerspectiveCamera(100,window.innerWidth/window.innerHeight,0.1,1000);
            this.camera.position.z=5;
            
            this.renderer = new THREE.WebGLRenderer();
            this.renderer.setSize(window.innerWidth,window.innerHeight);
            this.renderer.setClearColor('#D13D1D'); 
            
            window.addEventListener('resize',()=>{
              this.renderer.setSize(window.innerWidth,window.innerHeight);
              this.camera.aspect = window.innerWidth/window.innerHeight;
              this.camera.updateProjectMatrix();
            })
            this.geometry = new THREE.SphereGeometry(1.5,10,10);         
         
            this.materials = new THREE.MeshStandardMaterial({color0xFFFFFF})
            
            
            this.mesh = new THREE.Mesh(this.geometry,this.materials);
            this.mesh.material.color.set("green");
         
            this.light = new THREE.PointLight(0xFFFFFF,1,500);
            this.light.position.set(10,0,40);
         
            scene.add(this.light);
            
            scene.add(this.mesh);
            document.appendChild(new_m);
            this.renderer.render(scene,this.camera);
            this.target.append(this.renderer);
         
        }
    }
 
 
Any help would be much appreciated

 

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous 

Here I found some related blogs, I hope they could help you.

How to run things locally

How to Reference Three.js in a Power BI Custom Visual Project

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.