npm install
npx vite .
To start api server (do this in separate terminal):
node ./api/server.js
Camera: - press C
to toggle camera rotation. Dragging mouse near the edge of the screen rotates the camera around. - to move around the scene use WASD
keys on your keyboard.
/model_inits
add a new file (for example my_model_init.mjs)./models
create you object folder and put in your obj, mtl and texture files. (See example models/dashboard/
).import { loadObject } from '../utils/loadObject.mjs';
const init = function (object) {
object.position.y = -0.5;
object.position.z = 0;
object.scale.set(0.5, 0.5, 0.5);
}
export const loadMyObject = async () => {
try {
var myObject = await loadObject("models/myObject/myObject.obj", "models/myObject/myObject.mtl");
init(myObject)
return myObject;
} catch (e) {
console.error(e);
}
return;
}
Now import and add addObject(scene, gui, "Panel", loadPanel);
to addObjectsToScene
.
Optionally you can declare methods on your object:
105
in main.jsYou can aso declare your own methods and callbacks to implement aditional functionality to your model (API calls, keyboardEvent callbacks...).
For more examples look at already implemented objects and their init files.
You can send me tips and tricks to this paypal: https://paypal.me/prlek