objects locking system

This commit is contained in:
2025-11-13 16:32:55 +02:00
parent c8e501ff6e
commit a2f9f73e85
10 changed files with 119 additions and 56 deletions
+19 -12
View File
@@ -16,6 +16,8 @@ import { Clickable } from './Clickable.js';
import { DashBoard } from './Dashboard.js';
import { MotionEngine } from './MotionEngine.js';
THREE.Cache.enabled = true
const assetPath = '/asset/default/';
class GameEngine extends THREE.EventDispatcher{
@@ -161,7 +163,7 @@ class GameEngine extends THREE.EventDispatcher{
domNode.appendChild(renderer.domElement);
let texture = await this.loadTexture('/static/textures/bck.webp', '');
let texture = await GameEngine.loadTexture('/static/textures/bck.webp', '');
// let bck = await this.loadTexture('/static/textures/bck.webp');
// bck.premultiplyAlpha = true;
texture.mapping = THREE.EquirectangularReflectionMapping;
@@ -415,18 +417,8 @@ class GameEngine extends THREE.EventDispatcher{
})
}
async loadTexture(url, path = assetPath, progress) {
return new Promise((resolve, reject) => {
new THREE.TextureLoader().load(`${path}${url}`, texture => {
//texture.encoding = THREE.sRGBEncoding;
texture.colorSpace = THREE.SRGBColorSpace;
resolve(texture)
}, progress, reject)
})
}
async loadPanorama(url, path = assetPath) {
let t = await this.loadTexture(url, path);
let t = await GameEngine.loadTexture(url, path);
t.mapping = THREE.EquirectangularReflectionMapping;
this.scene.background = t;
this.scene.environment = t;
@@ -567,6 +559,21 @@ class GameEngine extends THREE.EventDispatcher{
this.clickable.removeAll();
this.motionQueue.clearAll();
}
static textureLoader = new THREE.TextureLoader();
static async loadTexture(url, path = assetPath, progress, assignTo) {
return new Promise((resolve, reject) => {
GameEngine.textureLoader.load(`${path}${url}`, texture => {
texture.colorSpace = THREE.SRGBColorSpace;
if (assignTo){
assignTo[0][assignTo[1]] = texture;
}
resolve(texture)
}, progress, reject)
})
}
loadTexture = GameEngine.loadTexture
}
export { GameEngine }