Good morning everyone!
I am new to the word of Phaser, so pardon me if the question sound sil.ly
In my Phaser3 game, I am trying to import a 3D model from an .obj file to be the main character of my game. My code is :
class Scene1 extends Phaser.Scene {
constructor() {
super("startScene");
}
preload() {
this.load.image("texture", "assets/images/<filename>.png");
this.load.obj({
key: "keymodel",
url: "assets/models/<filename>.obj",
matURL: "assets/models/<filename>.mtl",
});
}
create(){
const mesh = this.add.mesh(50,50,"texture");
mesh.addVerticesFromObj('keymodel', 0.1);
mesh.panZ(7);
mesh.modelRotation.y += 0.5;
this.debug = this.add.graphics();
mesh.setDebug();
console.log(mesh);
}
The game works fine when I use the base model offered in the tutorial (the skull from this tutorial Phaser - Examples - Mesh From Obj ) But When I try to import my model from 3DS max, errors start popping out. In particular, I receive different errors depending on the model on the addVerticesFromObj function.
When I try to load the full model (composed of several objects), I receive the error:
Uncaught TypeError: Cannot read properties of undefined (reading 'u')
at t.exports (phaser.min.js:1:580548)
at initialize.addVerticesFromObj (phaser.min.js:1:298100)
at Scene1.create (Scene1.js:54:10)
at initialize.create (phaser.min.js:1:491015)
at initialize.loadComplete (phaser.min.js:1:490466)
at o.emit (phaser.min.js:1:7809)
at initialize.loadComplete (phaser.min.js:1:944358)
at initialize.fileProcessComplete (phaser.min.js:1:944058)
at initialize.onProcessComplete (phaser.min.js:1:21253)
at initialize.onProcess (phaser.min.js:1:303819)
When I try to load the model of a single object, I receive the error:
Uncaught TypeError: Cannot read properties of undefined (reading 'x')
at t.exports (phaser.min.js:1:580422)
at initialize.addVerticesFromObj (phaser.min.js:1:298100)
at Scene1.create (Scene1.js:54:10)
at initialize.create (phaser.min.js:1:491015)
at initialize.loadComplete (phaser.min.js:1:490466)
at o.emit (phaser.min.js:1:7809)
at initialize.loadComplete (phaser.min.js:1:944358)
at initialize.fileProcessComplete (phaser.min.js:1:944058)
at initialize.onProcessComplete (phaser.min.js:1:21253)
at initialize.onProcess (phaser.min.js:1:303819)
This happens only by changing the filename without modifying the rest of the code. Could It be that there are special export parameters from 3DS max I need to set? Or is there another error in my code I cannot see?
Thank you all for your help!