Load blender scene with functional lighting using THREE.JS GLTFLoader

Recently, I've been experimenting with the GLTFLoader feature in THREE.js along with the new blender exporter found here. After successfully adding a model with similar color material and importing the scene into my THREE.js project, I noticed that while the mesh imported correctly, the lights from the Blender scene were not working as expected.

I had to manually add a THREE.js light to see anything, indicating that the imported lights were recognized as 3D objects without their functionality. Is there a way to automatically activate the imported lights or do I need to programmatically replace them with THREE.js lights at their respective positions? Furthermore, is there a method to configure sun lights and point lights from Blender so they face the correct direction when imported?

Below is some of the code I've been working on (with limited support for all types of lights):

function automaticallyAddLightsTo(inputScene) {
            inputScene.children.forEach((x) => {
                var light = new THREE.DirectionalLight(0xffffff, 0), //placeholder
                    isActuallyALight = false;
                if(x.name.includes("Sun")) {
                    light = new THREE.DirectionalLight(0xffffff, 1);
                    isActuallyALight = true;
                } else if(x.name.includes("Point")) {
                    light = new THREE.PointLight(0xffffff, 1, 100);
                    isActuallyALight = true;
                } // Add other light types here
                light.position.copy(x.position);
                light.rotation.copy(x.rotation);
                light.scale.copy(x.scale);
                light.quaternion.copy(x.quaternion);
                if(isActuallyALight)    
                    s.add(light);
            });
        }

One question remains: how can I detect the intensity of these imported lights?

Answer №1

Here's a handy tip for enhancing your blender lighting:

Make sure to set renderer.physicallyCorrectLights to true;

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using jQuery to display checkbox text even when it is not directly adjacent to the checkbox

I'm struggling to display the checked value text as shown in the image without any refresh or click. Can anyone offer assistance? This is my PHP dynamic form: <div class="products-row"> <?php $tq=$conn->query("select * from os_tiffen ...

Mastering the Art of Revealing and Concealing

I stumbled upon a great demonstration on reversing the Hide and Show functionality at https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_toggle_hide_show <!DOCTYPE html> <html> <head> <meta name="viewport" content="width ...

Selecting checkboxes based on a delimited string containing specific values can be done using Javascript

I have a set of checkboxes similar to the ones below that I would like to select based on database values. If I convert the database values into a string format like DC0|100;DK0|100;DM0-SRM|200;DR0|300 (delimited by semicolons or another delimiter), how ca ...

Organizing express queries independently of routes

I am currently working on creating an express route that allows me to input an equity name as a query parameter by using ?symbol= in the URL. Once the equity name is provided, I intend to include a new route after that. const express = require("expres ...

What is the best approach for adding variable rows to a Postgres junction table: should you concatenate a query string, utilize multiple queries, or explore alternative methods

Below is the code snippet for handling a variable-length list of tags and inserting data into the database: // JSON object from req.body { "title": "title", "reference": "1213", "noteType": &q ...

Scrolling to the active list item in the navigation bar

Having an unordered list with the id mainul in the navigation bar is causing a problem when the page reloads. The navigation bar always starts at the beginning, but I would like it to automatically scroll to the active li element. This is my HTML code: & ...

What is the best way to trigger an event using vue-chartjs?

I am using vue js to display a graph with chartjs. I have implemented an onClick function on the graph to emit an event in the parent component and retrieve data. However, the event is not working as expected. Can you help me identify the issue? Component ...

Error message: "The property is not found within the specified type when using the OR operator with

Within my Angular component, I am faced with a challenge involving an Input that can be one of two types. @Input() profile: UserProfileDetails | BusinessProfileDetails; The structure of the profile template is straightforward and I want to avoid duplicati ...

Tips for Transferring Values Between Multiple Dropdown Menus with jQuery

Hello there, can anyone guide me on how to transfer selected items from one multiple combo box to another multi-combo box? I would really appreciate it if someone could provide an example for this scenario. <HTML> <HEAD> <TITLE></T ...

In my Node.js application using Express and Passport, I encountered an issue where res.locals.users is functioning properly but the data it

I'm currently working on an application using NodeJS, Express, and Passport. However, I've encountered an issue when trying to display user data in the views. While I am able to retrieve the ObjectID of the user from res.locals.user, accessing s ...

Encountering an issue when attempting to extend a module in nodejs

In my current project, I am developing a module called animal.js that inherits from the color.js module and then is used in the app.js file. Inside Animal.js: var exports = module.exports = {}; exports.animalName = function() { console.log(&apos ...

Exploring the power of Jade and Angular through implementing a for loop within a table structure

I'm brand new to using Jade and Angular, and I could really use a hint from someone more experienced. ... - for (var i = 0; i < p.length; i++) tr td= i + 1 td= price(value='p[i].somedbstuff') ... I want the la ...

Transition from traditional class-based components to functional components

I am utilizing the ref from the parent class to access the child class. However, in this scenario, I want to access the child functional component from the parent class. In the parent class: class Waveform extends Component { constructor(props){ s ...

What is the process for transferring an object to a different file?

Currently, I am working on a web application using Node.js. In my project, I have two main files. The first one is Server.js, where I handle server actions such as going online. The second file contains a large object filled with data. I successfully impo ...

Scraping dynamic content with Python for websites using JavaScript-generated elements

Seeking assistance in using Python3 to fetch the Bibtex citation produced by . The URLs follow a predictable pattern, enabling the script to determine the URL without requiring interaction with the webpage. Attempts have been made using Selenium, bs4, amon ...

Trigger an event in Vue with specified parameters

I am attempting to emit a function with parameters in the following way. template: ` <div class="searchDropDown"> <div class="dropdown is-active"> <div class="dropdown-trigger"> <button class="button" aria-haspopup=" ...

Is it possible for the children of a Three.js scene to have matrix positions that differ from the children of those children?

I am facing an issue with my ferris wheel. The baskets on the wheel are not aligning correctly when the scene is rotated: https://i.sstatic.net/Ek1mT.png Everything functions as intended until the scene is rotated, causing the baskets to misalign with th ...

Ways to determine the current page I am viewing

I am working with a list of tabs and I need to track my current location every time I click on a specific tab. My MainCTRL controller, which is the parent of all tab controllers, needs to be aware of the active tab at any given moment. I attempted to use n ...

Retrieve the file name from the URL while disregarding the query string

Looking for a way to extract the test.jsp from this URL: http://www.xyz.com/a/test.jsp?a=b&c=d Can anyone provide guidance on how to accomplish this task? ...

What steps can I take to ensure my website is optimized for a seamless viewing experience on all mobile devices

Could you please check out the link on your smartphone and let me know if it looks a bit off to you? I have centered everything and the website looks fine on desktop, but on my iPhone 5S, it doesn't seem to display properly. Is there a way to make it ...