The object has been successfully loaded but is currently not visible

Currently, I am working with Nuxtjs and Threejs. The website's default script displays the geometry and animation correctly. However, I need to use a custom model, so I installed OBJLoader and MTLLoader using npm, which were successfully installed.

<template>
  <div id="three" class="three">

  </div>
</template>

Script snippet:

<script>
import * as Three from 'three'
import { MTLLoader, OBJLoader } from 'three-obj-mtl-loader'

export default {
  data() {
    return {
      camera: null,
      scene: null,
      renderer: null,
      mesh: null,
      mtl: null,
      obj: null
    }
  },
  methods: {
    init: function() {
        let container = document.getElementById('three')

        this.camera = new Three.PerspectiveCamera(70, container.clientWidth/container.clientHeight, 0.01, 10)
        this.camera.position.z = 1

        this.scene = new Three.Scene()
        this.mtl = new MTLLoader()
        this.obj = new OBJLoader()

        this.mtl.load('/mesh/sources/Coffee Hot Cup Sketchfab.mtl', (materials) => {
          materials.preload()
          this.obj.setMaterials(materials)
          this.obj.load('/mesh/sources/Coffee Hot Cup Sketchfab.obj', (object) => {
            this.scene.add(object)
          })
        })

        this.renderer = new Three.WebGLRenderer({antialias: true, alpha: true})
        this.renderer.setSize(container.clientWidth, container.clientHeight)
        this.renderer.setClearColor(0x000000, 0)
        this.renderer.render(this.scene, this.camera)
        container.appendChild(this.renderer.domElement)

    }
  },
  mounted() {
      this.init()
  }
}
</script>

Although the object is reported to have loaded successfully, my custom model is not appearing. It seems strange because there are no errors indicating missing paths. How can I resolve this issue? Thank you!

Answer №1

It's important to ensure that your material is set to double-sided when working in Unity game engine. I encountered a similar issue where textures were missing from loaded files. By verifying the double-sided property of my object materials, I was able to resolve the problem successfully!

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

Looking for guidance on how to initiate or halt React Native Moti animation when the state changes? I've been running into issues where my method appears to disrupt

While experimenting with the Moti animation, everything was working perfectly until I included the playbackState === State.Playing condition. Unfortunately, once I added it, the animation looped only once and then stopped repeating. I'm puzzled as to ...

Exploring the Exciting World of Jquery Cycle and Dynamic Ajax Capt

Utilizing Jquery Cycle for image fading loaded by Ajax, along with displaying corresponding captions using the onBefore option in the plugin. The image transition is functioning perfectly, however, there seems to be a slight issue with the caption display. ...

What is the method for determining someone's age?

I am trying to extract the date from a field called "DatePicker" and then enter that date into the field labeled "NumericTextBox" Thank you <div> <sq8:DatePicker runat="server" ID="dateDatePicker"> <ClientEvents OnDateSelected="get_curr ...

Utilizing the onchange event handler to dynamically alter the webpage upon input

I am attempting to dynamically change my HTML page based on certain input. However, I have encountered issues with JavaScript event handlers not functioning as expected in achieving this. Below is the code snippet I used: var nam = document.getElementById( ...

The error message: "Trying to access property 'get' of an undefined object"

$http.get('/contactList'). success(function(data){ console.log('received data from http get'); }). error(function(data) { $scope.error = true; $scope.data = data; return 'error message'; }); There seems to be ...

Would you say the time complexity of this function is O(N) or O(N^2)?

I am currently analyzing the time complexity of a particular function. This function takes a string as input, reverses the order of words in the string, and then reverses the order of letters within each word. For example: “the sky is blue” => ...

Tips for avoiding mui datatables from rendering when updating states in onRowSelectionChange function

Currently, I am involved in a React js project using "mui-datatables": "^4.2.2". The project involves displaying a list of data that is paginated with checkboxes for item selection: https://i.sstatic.net/49gYU.png However, I am facin ...

Transmit data or communications to a webpage while a script is performing operations (Django 4)

Currently, in my Python script with Django, when a user submits a file, I have a series of tasks that are processed which can take several minutes. While the user is waiting, a loading screen in JavaScript is displayed and updates are printed in the consol ...

Is it more important to focus on passing props or making API requests the top priority in your web application structure

Context Currently, I am working on a Vue App utilizing the Composition API. My backend serves as the source of data for loading pages and components. Inquiry When it comes to structuring my app's architecture, should I prioritize passing props thro ...

Execute a Python script with a JavaScript click event

I am looking for a way to run a Python script with just a click of a button on an HTML page and display the result on my page. Since this is a small project, I want to avoid learning more complex frameworks like Django even though I understand they would w ...

Updating Vue 3 slot content dynamically

Is there a way to dynamically modify slot content in Vue 3? I attempted to retrieve slots using useSlot, set a ref, update the ref.value (slotref.value = [...slotref.value, slotref.value[0]]), but the content remained unchanged. ...

Exploring the Shopware 6 Admin API: Saving a new entity with a default entity property

How can I set a default value for a new entity property (such as defaultCurrency.id) within the sw-entity-single-select component before calling this.repository.save()? Is this possible, or do I have to wait until after calling save() and then listen for ...

Tips on changing the URL of the current tab after clicking on a link

const selenium = require('selenium-webdriver'); require('chromedriver'); const By = selenium.By; const driver = new selenium.Builder().forBrowser('chrome').build(); const url = 'https://example.com'; driver.get(url) ...

Execute a function when the submit button is clicked

Here is an example of html text input and javascript code: <input type="text" name="statuspopup" id="statuspopup" value="" /> <script type="text/javascript"> function SubmitTicketForm() { return CheckRequired(); if($('#statuspopu ...

ng-show directive in AngularJS is not functioning properly when utilized with CLI

After setting up my Angular app with ng new app, I attempted to hide certain elements conditionally using ng-show. Unfortunately, it doesn't seem to be working as expected. <span ng-show="false">Angular App</span> Regardless ...

Restricting the download of data in Firebase when using the

I have implemented a Firestore listener in my app that downloads items from the database as they are added. Initially, all documents are downloaded using onSnapshot, but I want to limit this to 12 items as I am using a FlatList to render items as I scroll. ...

Guide to displaying a template using Vue.js

Incorporating jQuery and vuejs version 2.3.4: https://cdnjs.cloudflare.com/ajax/libs/vue/2.3.4/vue.min.js The code snippet below demonstrates my current setup: // Instantiating Vue. vueVar = new Vue({ el: '#content', ...

How to utilize an AngularJS filter within a controller

Having a root controller in my AngularJS web application with a filter. The filter functions properly when applied in the html template, but it fails to work when attempted to be applied in the controller. function Controller ( ... deps ...) { filter ...

Common mistakes made while working with decorators in Visual Studio Code

Having trouble compiling TypeScript to JavaScript when using decorators. A persistent error message I encounter is: app.ts:11:7 - error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the ' ...

Implementing Cross-Origin Resource Sharing (CORS) in Express.js to facilitate communication between various ports

Struggling to make API calls using React and Axios from my front end (localhost:3000) to my back end (localhost:4567) is proving challenging. The consistent error message I encounter is: The CORS policy is blocking access to XMLHttpRequest at 'localh ...