Guide on using threeJS in a browser to display a single DRC file and single MTL file together

I'm attempting to display DRC files in a web browser because of the superior compression results compared to OBJ files. I have successfully rendered DRC files, but I am facing an issue with adding an MTL file. Each object I have includes both a DRC and an MTL file, and I want to load and render both in the browser.

Initially, I tried using the OBJLoader_MTLLoader_example from here, but it does not seem to work with DRACOLoader.

Next, I attempted the solution provided at this link. However, I encountered an error stating that the setMaterials function in MTLLoader.js is not defined, even though it actually is. Any assistance would be greatly appreciated.

<script 
 src="https://cdn.rawgit.com/mrdoob/three.js/dev/build/three.min.js"> 
</script>
<script src="DDSLoader.js"></script>
<script src="DRACOLoader.js"></script>
<script src="MTLLoader.js"></script>
<script src="geometry_helper.js"></script>

...

//MTL Loader

    THREE.Loader.Handlers.add( /\.dds$/i, new THREE.DDSLoader() );
       new THREE.MTLLoader()
        .load( './bed.mtl', function ( materials ) {
         materials.preload();
         new THREE.DRACOLoader()
        .setMaterials( materials )
  } );

... scene.add(geometry, materials);

Link to entire file: This link

The desired output is a colored 3D object, but currently, it only appears in black. This suggests that only the geometry is visible, without any colors, materials, or textures applied.

Answer №1

I'm not familiar with the DRC format, but DRACOLoader is a plugin that can be used with GLTFLoader. Have you tried using GLTF format instead of DRC?

Could you explain what DRC is?

Check out these resources for more information:

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

Is there a way to manipulate text in JQuery without altering the inner element?

I am struggling with an issue in my HTML code. Currently, I have the following structure: <h3 id="price">0.00<sup id="category">N/A</sup></h3> My intention is to use AJAX to replace the content within the <h3 ...

Leverage the URL parameter with variables in HTML using AngularJS

I'm facing the same issue as yesterday: trying to extract and utilize parameters from the URL within my HTML page using AngularJS. What am I doing wrong? The parameter I need to work with is: https://url.com/index.html?user I aim to retrieve the "u ...

Best methods for deleting an element's attribute or style attribute

Imagine this snippet of CSS code: .notif-icon { display: inline-block; } In my HTML, I have the following element which starts off hidden by overriding the display property of the notif-icon class: <span id="error" class="notif-icon& ...

Tips for solving errors in Microsoft JScript runtime: "The definition of '$' is not clear"

While trying to transfer my live site to Visual Studio 2010, I encountered an issue. After copying and pasting the code from Internet Explorer's view source into VS2010->Newwebsite, I ran into an error upon testing. Microsoft JScript runtime err ...

Experiencing difficulties applying a condition in a mongoDB projection

Imagine a scenario where I have a separate collection named 'Collection1' containing the following data: userID: "1" container:[ {"item" : "false", "price" : NumberDecimal("80"), "sizes" : "S", "arrayIndex" : NumberLong(0) } {"item" : ...

Canvas image zoom and crop feature ensures fixed selection area across all platforms

After finding inspiration from a source I cannot name, I developed a plugin that allows for image cropping on both mobile and desktop devices. The key features of my plugin include touch support, dynamic canvas sizing based on image dimensions, and the ab ...

Combining two numbers retrieved from Firebase using React

Hello, I am new to React and finding it challenging to perform mathematical calculations with React. I have been attempting to add two values retrieved from a Firebase database, but they keep displaying as strings without adding the actual values together. ...

Tips for fixing the Runtime.UnhandledPromiseRejection error when deploying your next.js project on Vercel and Netlify

Encountering an error during deployment on Vercel or Netlify. The same error persists on both platforms. Any suggestions on resolving this issue would be greatly appreciated. Snippet of the Database code: import mongoose from 'mongoose'; const ...

What could be causing an issue with CORS in ExpressJS in one scenario but not in another?

I am currently in the process of setting up a database and connecting it to various routes. Interestingly, I have been successful with one route ('register') but encountering issues with another ('login'). Whenever I attempt to run the ...

Optimizing Angular's ng-repeat for efficient updates by restricting the watch functionality to the relevant iteration

My task involves creating a table where users can edit certain fields in each row, which will impact other fields within the same row. Due to this requirement, I cannot use bind-once for all the rendered data. To address this issue, I attempted using the ...

Extract data from nested JSON and populate a list with corresponding values

<ul> <li><a href="" class="edit">a unique item in the list</a></li> <li><a href="" class="edit">another unique item in the list</a></li> <li><a href="" class="edit">yet another unique ...

What is causing the angular ng-repeat table to not sort correctly?

Currently, I am facing an issue with a table that is being populated by Angular: I have provided the code here so you can see the problem in action: http://plnkr.co/edit/qzY4r2XWq1UUJVrcqBsw?p=preview When I click on the a elements, the sort order change ...

unable to utilize the clear method on password field using Selenium WebDriver

I am currently testing the validation on a login form using Selenium webdriver. I have noticed that while the username field clears successfully, the password field does not clear when using the clear method. Is there something I am overlooking? it(' ...

Validation of time picker consistently returns false

While using the daterangepicker library for my form validation with JavaScript, I encountered an issue with the time field. It returns false and displays an error message saying: "Please enter a valid time, between 00:00 and 23:59," preventing me from addi ...

Applying specific style properties in styled-components can vary based on certain conditions

Is it possible to apply multiple properties at once? const Button = styled.div` color: blue; opacity: 0.6; background-color: #ccc; ` I want to apply styles for the active state without having to specify conditions for each property individually. Ho ...

The functionality of my script relies on the presence of an alert function within it

My code seems to only work when I include an alert function in it. I'm trying to make my div scroll to the bottom. I've done some research, but for some reason, the script doesn't run without an alert function. $(document).ready(function ...

Having trouble importing the d3-geo package into a Node.js TypeScript project

Seeking a way to test the inclusion of specific latitude and longitude coordinates within different GeoJSON Features using code. When attempting this with: import d3 from 'd3-geo'; // or: import * as d3 from 'd3-geo' // no difference ...

What is the best way to obtain the SearchIDs for various searchNames using JavaScript?

Who can assist me in resolving this issue? I am trying to retrieve the id of a searchName whenever a user selects the checkbox. Ideally, I would like to assign the value of the PHP line $search_row->searchid to the id attribute in the input field. Apolo ...

A guide on using AJAX to update an HTML table and other data simultaneously from within a single script

I'm reaching out for your assistance. In my javascript code, I currently make two separate AJAX calls - one to create a map using openstreetmap and another to refresh an HTML table. Both PHP pages involved in these calls utilize the same MySQL reques ...

Function "Contains" not Present in Object

Upon executing the code provided below, I encounter the following error message. An issue has arisen: Cannot find function contains in object Is Patient Fasting?/# of Hours->Yes; 12 hours. Here is the snippet of my code: var i = 0; var tempF ...