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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

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
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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