After modifying the code for a 3D map exported from qgis2threejs, the page now sits empty, waiting

I'm looking to make modifications to the code within a 3D map that was created using qgis2threejs, which is QGIS's plugin for creating 3D webmaps.

Although I don't have much experience with the threejs library or JavaScript, I want to alter the following code:

// load the scene
app.loadJSONFile(
        "./data/index/scene.json",
        function () {
          app.start();
          // North arrow inset
          if (Q3D.Config.northArrow.visible) app.buildNorthArrow(document.getElementById("northarrow"), app.scene.userData.rotation);
        }
      );

My goal is to include scene.json directly instead of specifying its path. So, I intend to use this updated code:

// load the scene
app.loadJSONFile(
        {"type": "scene", "properties": {"height": 90.1010101010101, "width": 100.0, "baseExtent": [725282.3732700318, 6006086.588087205, 727901.7482727035, 6008446.671422945], "crs": "EPSG:3857", "proj": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs", "rotation": 0, "wgs84Center": {"lat": 47.39790958284822, "lon": 6.527087535108197}, "zExaggeration": 1.0, "zShift": 0.0}, "layers": [{"type": "layer", "id": 0, "properties": {"name": "clip_dtm_francia_eudem", "queryable": 1, "visible": true, "type": "dem", "shading": true}, "data": [{"type": "block", "layer": 0, "block": 0, "grid": {"width": 211, "height": 190, "url": "./data/index/a0.bin"}, "width": 100.0, "height": 90.1010101010101, "translate": [0.0, 0.0, 0.0], "zShift": 0.0, "zScale": 0.038177046012121664, "material": {"type": 0, "image": {"url": "./data/index/a0.png"}, "ds": 1}, "sides": true}]}]},
        function () {
          app.start();
          // North arrow inset
          if (Q3D.Config.northArrow.visible) app.buildNorthArrow(document.getElementById("northarrow"), app.scene.userData.rotation);
        }
      );

After implementing these changes, the 3D map appears blank even though there are no errors in the Chrome Developers tool.

How can I resolve this issue? If you'd like to review all the code, you can download it here(2MB)

Answer №1

Swap out loadJSONFile() for loadJSONObject(). It's important to note that the new method does not require a callback parameter, so your revised code will resemble the following:

app.loadJSONObject( {"type": "map", "info": {"height": 72.04545454545455, "width": 88.0, "boundary": [725282.3732700318, 6006086.588087205, 727901.7482727035, 6008446.671422945], "crs": "EPSG:3857", "proj": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs", "rotation": 0, "centerWGS84": {"latitude": 47.39790958284822, "longitude": 6.527087535108197}, "zExaggeration": 1.0, "zOffset": 0.0}, "layers": [{"type": "section", "id": 0, "details": {"name": "area_topo_france_eudem", "queryable": 1, "visible": true, "category": "elevation model", "shade": true}, "data": [{"type": "chunk", "layer": 0, "segment": 0, "grid": {"length": 211, "distance": 190, "link": "./information/index/a0.bin"}, "width": 88.0, "height": 72.04545454545455, "shift": [0.0, 0.0, 0.0], "zOffset": 0.0, "zScale": 0.038177046012121664, "texture": {"variation": 0, "photo": {"link": "./information/index/a0.png"}, "ds": 1}, "panel": true}]}]} );
app.initialize();
if (Q3D.Config.compass.isVisible) app.generateCompass(document.getElementById("navigator"), app.view.data.rotation);

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

What's preventing the `@change` trigger from functioning properly with v-data-picker?

In my Vue.js application, I am utilizing the v-calendar package. I am trying to pass selected date range values to the parent component. However, why is the @change trigger not working? Parent.vue: <template> <div> <Child @set ...

How can I modify an array in Couchbase by using an N1QL query?

{ "name":"sara", "emailId":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="abcde8e2ea9627225c4b9a3afa7bbcc808cb554a1adaf">[email protected]</a>", "subjects" : [{ "name":"Math", "tutor":"alice", "classes" ...

Adding a query parameter to a dynamic route in NextJS

In my NextJS application, I have implemented a language selector that is displayed on every page. The goal is to change the current URL by adding a query parameter lang=en when a new language is selected. The function responsible for updating the URL look ...

Tips for incorporating a page route with an HTML extension in Next.js

I'm facing a challenge in converting a non-Next.js page to Next.js while maintaining my SEO ranking. To preserve the route structure with HTML extensions and enhance visual appeal, I have outlined the folder structure below: https://i.sstatic.net/zO1 ...

"Using Node.js Express 4.4 to efficiently upload files and store them in a dynamically

Looking for recommendations on the most efficient method to upload a file in node.js using express 4.4.1 and save it to a dynamically created directory? For example, like this: /uploads/john/image.png, uploads/mike/2.png ...

How to retrieve a value from an array using a specific name rather than a numerical key

After creating an object and adding an asset b345 with some properties in it, such as: asset = []; asset.push({'b345' : { 'prop1':'value 1', 'prop2': null}}); I aim to dynamically add more assets later into the sa ...

Creating a structure object in a Laravel controller for implementing Vue.js autocomplete functionality

I am currently facing an issue with my autocomplete feature not displaying options correctly. To start off, I am fetching hard coded data from my controller and passing it through an axios call: searchController.php $searchResults = [ 0 => (ob ...

Accessing variables in subfunctions proves challenging for Node.js

Here is a function I've been working on to calculate the total price for a checkout process. However, when I console.log() the variable before it is returned, I get 0. But if I log the variable inside the findOne() function, I get the correct value. ...

The Highcharts Range Selector feature may encounter issues when used with multiple series

Currently, I am facing an issue with my highchart/highstock where I retrieve data from a PHP file. The problem arises when I attempt to use multiple series as the RangeSelector Buttons cease to function properly. For instance, in the example provided, the ...

Developed a query, seeking information for populating a dropdown menu

I am currently in the process of editing a webpage that utilizes both PHP and HTML. Essentially, I have a dynamic list of items being generated where the number of values can vary based on the row length. Next to each item in the list, there is a "delete ...

Dealing with an Ajax request that returns a file or partial HTML in the event of an error - what is the best approach?

Imagine a scenario where we are engaged in a dialogue with certain settings. Upon clicking the "OK" button in the dialogue, the settings are transmitted to a controller function through an AJAX call. This call may either yield a downloadable file or an err ...

What is the best way to display a child component inside an iframe using Vue.js?

Looking to provide a live preview of an email before sending it out, I've opted to use an iframe to contain the preview and prevent style leaks. The goal is for the preview to update dynamically as the user fills out form details. How can I display a ...

Techniques for Extracting the Values of all ng-models within an ng-repeat Loop

How do I retrieve the total value of all ng-models within an ng-repeat loop using AngularJS? Below is my HTML code: <div ng-repeat="kind in plans.availableOptions"> <span class="payLabel text-left">{{kind.name}}</span> ...

The Distinction between Object.assign and the simple assignment operation

Could you please explain the distinction between these two lines of code? Object.assign(otherObject, { someNewProperty: '' }); vs. otherObject.someNewProperty = ''; Also, which one of these methods is more efficient in terms of sp ...

How well are DOM Mutation Observers supported across different web browsers?

I attempted to search for a solution by Googling, but was unsuccessful in finding an answer. Does anyone know if there is a compatibility matrix available for this feature that works across all browsers? In case someone is interested in the answer, here ...

Reduce the size of your Javascript files to the earliest possible version

Any suggestions for converting minimized JavaScript to earlier versions? Are there any tools or websites available for this task? Thank you in advance for any hints. ...

Exploring JSON File data and showcasing it with Python

There is a JSON data source at 'https://api.exchangerate.host/symbols' that contains information in the format 'symbols': {'AED': {'code': 'AED', 'description': 'United Arab Emirates Dirham& ...

Error: Objects cannot be used as constructors

An Azure Function using JavaScript HTTP Trigger posts activity in a Slack online community for customers. It has been functioning successfully for many years, but after upgrading from version ~2 to ~4, it started throwing an error stating Entities is not ...

Divergent find function behavior in jQuery when applied to div or tbody

I've encountered an issue while using the jQuery find selector by Id with a div and tbody. Let me simplify my problem for better understanding. HTML <div id='iamdiv'>HELLO</div> <table> <tbody id='iamtbody' ...

Transforming a group of text into a JSON format using Python

Currently in the process of setting up a flask server for my front end, I am receiving requests in the form of a JSON object like this: InputJson = {"text":"Field1:A|Field2:B|Field3:C","format":"Reader"} The goal is to convert the text field into proper ...