This commit is contained in:
2026-03-23 19:56:37 +02:00
parent 45074d78d2
commit 627452a308
4 changed files with 15 additions and 21 deletions
@@ -75,26 +75,18 @@ export default{
engine.ambientLight.intensity = 25;
if (this.obj.type == 'panorama2d') {
await engine.loadPanorama(this.obj.asset.name);
// let t = await engine.loadTexture(`/asset/default/${this.obj.asset.name}`);
// t.mapping = engine.$.EquirectangularReflectionMapping;
// engine.scene.background = t;
// engine.scene.environment = t;
// engine.scene.add(engine.camera);
} else {
let gltf = await engine.load(this.obj.asset.name);
//console.debug('GLTF', gltf);
this.loadedAsset = gltf;
this.animations = gltf.animations.map(a => ({
name: a.name, id: a.uuid
}));
autoScale(gltf.scene);
let bb = new engine.$.Box3().setFromObject(gltf.scene);
//console.log(bb)
engine.camera.position.set(bb.max.x, bb.max.y, bb.max.z*3);
engine.orbitControls.target.set((bb.max.x + bb.min.x) / 2, (bb.max.y + bb.min.y) / 2, (bb.max.z + bb.min.z) / 2)
engine.orbitControls.update();
engine.activeObjects.add(gltf.scene);
//engine.scene.add(engine.light);
}
}
},
@@ -43,8 +43,8 @@ class MazeQuizGame extends EventManager {
super();
this.data = data;
data.noPhysics = true;
params.mazeFile = data.style || 'quiz-s2.gltf';
params.io = this;
this.params = { ...params, mazeFile: data.style || 'quiz-s2.gltf', io: this }
this.maxPoints = (data.points || 0) + (data.questionPoints||0) * data.questions.length;
this.minPoints = this.maxPoints - (data.questionPenalty||0) * data.questions.length;
@@ -52,7 +52,7 @@ class MazeQuizGame extends EventManager {
return new Promise(async (resolve, reject)=>{
let questions = data.shuffle ? Utils.shuffleArray(data.questions) : data.questions;
let def = this.generate(questions);
this.mazeObject = new MazeObject(engine, def, params)
this.mazeObject = new MazeObject(engine, def, this.params)
engine.addEventListener('collision', async e=>{
let ud1 = engine.physics.world.getCollider(e.handle1)?.parent()?.userData,
ud2 = engine.physics.world.getCollider(e.handle2)?.parent()?.userData;
@@ -124,7 +124,7 @@ class MazeQuizGame extends EventManager {
{
type: 'SceneSwitcher', switchScene: this.data.switchScene, switchType: this.data.switchType,
position:[0,.22,len + .52], scale: [0.33, 0.33, 0.33],
distance: params.wallSize*4
distance: this.params.wallSize*4
}
]
};
+6 -7
View File
@@ -68,12 +68,12 @@ class GameEngine extends EventManager{
dirLight.castShadow = true;
dirLight.shadow.mapSize.width = 1024;
dirLight.shadow.mapSize.height = 1024;
const d = 10;
const d = 50;
dirLight.shadow.camera.left = - d;
dirLight.shadow.camera.right = d;
dirLight.shadow.camera.top = d;
dirLight.shadow.camera.bottom = - d;
dirLight.shadow.camera.far = 1000;
dirLight.shadow.camera.far = 100;
dirLight.shadow.bias = - 0.001;
// const spotLight = new THREE.SpotLight(0xffffff);
@@ -162,7 +162,7 @@ class GameEngine extends EventManager{
renderer.toneMapping = THREE.CineonToneMapping;
renderer.toneMappingExposure = 1.0;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFShadowMap; // default THREE.PCFShadowMap
renderer.shadowMap.type = THREE.VSMShadowMap; // default THREE.PCFShadowMap
// renderer.toneMapping = THREE.ACESFilmicToneMapping;
// renderer.toneMappingExposure = 1;
// renderer.shadowMap.enabled = true;
@@ -674,18 +674,15 @@ class GameEngine extends EventManager{
this.ambientSound.stop();
this.loadedObjects.forEach(o=>clearObject(o.scene))
GameEngine.loadedTextures.forEach(t=>{
//console.log('Disposing', t.name, this.renderer.info.memory.textures );
t.dispose();
//console.log('Disposed', t.name, this.renderer.info.memory.textures );
});
GameEngine.loadedTextures.splice(0, GameEngine.loadedTextures.length);
this.scene.background?.dispose?.();
this.scene.environment?.dispose?.();
clearObject(this.scene);
this.scene = null;
this.tm?.setScene(null);
this.removeAllListenersOfType('beforeRender');
this.renderer.renderLists.dispose();
this.renderer.properties.dispose();
}
async resetScene(){
@@ -703,6 +700,8 @@ class GameEngine extends EventManager{
this.arBtn?.remove();
this.xrBtn?.remove();
this.stats?.dom?.remove();
this.renderer.renderLists.dispose();
this.renderer.properties.dispose();
this.renderer.domElement.removeEventListener('wheel', this._wheelEvent)
this.renderer.domElement.remove();
super.dispose();
+5 -2
View File
@@ -93,12 +93,14 @@ function clearObject(o){
disposables.push(object);
}
if (object.isLight){
object.shadow?.map?.dispose();
object.shadow?.dispose();
//console.log('Disposeing light', object)
object.dispose();
object.shadow?.dispose();
object.shadow?.map?.dispose();
}
if (object.userData?._io){
object.userData._io.dispose?.();
delete object.userData._io;
}
});
disposables.forEach(object=>{
@@ -110,6 +112,7 @@ function clearObject(o){
for (const material of object.material) clearMaterial(material)
}
})
o.clear();
}
function clearMaterial(material) {