refactoring

This commit is contained in:
2025-11-06 18:17:56 +02:00
parent fd3f9a6d69
commit 4565782e9f
14 changed files with 113 additions and 92 deletions
+5
View File
@@ -16,6 +16,11 @@ class Clickable {
delete object._clickable;
};
this.removeAll = function(){
objects.forEach(o=>delete o._clickable)
objects.splice(0, objects.length);
}
this.update = function (mouse, camera, event) {
raycaster.setFromCamera(mouse, camera);
let forExecute = [];
+9
View File
@@ -560,6 +560,15 @@ class GameEngine extends THREE.EventDispatcher{
}
this.stats?.update()
}
clearScene(){
// this.hero?.destroy();
// this.dashboard?.reset();
// this.activeObjects.clear();
// this.physics.clear();
// this.clickable.removeAll();
// this.motionQueue.clearAll();
}
}
export { GameEngine }
+4 -4
View File
@@ -7,19 +7,19 @@ function assignParams(mesh, params){
});
}
function assignMaterial(mesh, params, context){
function assignMaterial(mesh, params){
if (params.name && params.material){
//let mp = params.material.metalness ? new MeshStandardMaterial(params.material) : new MeshBasicMaterial(params.material)
Object.assign(mesh.material, params.material)
if (params.dm){
var dm = new TextureLoader().setPath(context.path).load(params.dm);
var dm = new TextureLoader().setPath(params.path).load(params.dm);
mesh.material.map = dm;
}
if (params.nm){
mesh.material.normalMap = new TextureLoader().setPath(context.path).load(params.nm);
mesh.material.normalMap = new TextureLoader().setPath(params.path).load(params.nm);
}
if (params.em) {
mesh.material.emissiveMap = new TextureLoader().setPath(context.path).load(params.em);
mesh.material.emissiveMap = new TextureLoader().setPath(params.path).load(params.em);
}
//mesh.material = mp;
mesh.material.needsUpdate = true;
+5 -1
View File
@@ -4,7 +4,6 @@ class MotionEngine {
constructor() {
const aq = [];
const clock = new Clock();
this.animationQueue = aq;
function calcValues(target, values, initial, k = 1, mode = 'offset') {
@@ -42,6 +41,11 @@ class MotionEngine {
}
};
this.clearAll = function(){
aq.splice(0, aq.length);
return;
}
this.remove = function (a) {
let idx = aq.indexOf(a);
if (idx > -1) {