I have the following files which runs fine locally, but not working when uploaded to github as a github page.
The error message in console shows “Failed to load resource: the server responded with a status of 404(): /examples/models/3dm/model.3dm”
May I ask how to solve this relative path related issue?
The file structure is:
|-- index.html (which calls main.js in the scripts folder)
| ...
| <script type="module" src="scripts/main.js"></script>)
| ...
|
|-- scripts
| |__ main.js (which loads model.3dm file in the examples/models/3dm folder)
|
|-- examples
|__ models
|__ 3dm
|__ model.3dm
The code in main.js to load the model is shown below:
loader.load(
"../examples/models/3dm/model.3dm",
function (object) {
object.traverse(function (child) {
if (child instanceof THREE.Mesh) {
child.material = meshMaterial;
}
});
scene.add(object);
}
);