integrate game1 and game2

This commit is contained in:
2025-11-05 09:43:12 +02:00
parent 4236927537
commit 4b722750c3
12 changed files with 354 additions and 278 deletions
+11 -8
View File
@@ -16,6 +16,8 @@ import { Clickable } from './Clickable.js';
import { DashBoard } from './Dashboard.js';
import { MotionEngine } from './MotionEngine.js';
const assetPath = '/asset/default/';
class GameEngine extends THREE.EventDispatcher{
async init(domNode, opts = {}) {
this.w = domNode.clientWidth || 1200, this.h = domNode.clientHeight || 800;
@@ -101,6 +103,7 @@ class GameEngine extends THREE.EventDispatcher{
this.dashboard = dashboard;
this.motionQueue = new MotionEngine();
this.assetPath = assetPath;
this.activeObjects = new THREE.Group();
scene.add(this.activeObjects);
@@ -158,7 +161,7 @@ class GameEngine extends THREE.EventDispatcher{
domNode.appendChild(renderer.domElement);
let texture = await this.loadTexture('/static/textures/bck.webp');
let texture = await this.loadTexture('/static/textures/bck.webp', '');
// let bck = await this.loadTexture('/static/textures/bck.webp');
// bck.premultiplyAlpha = true;
texture.mapping = THREE.EquirectangularReflectionMapping;
@@ -383,12 +386,12 @@ class GameEngine extends THREE.EventDispatcher{
$ = THREE;
async load(url, progress) {
async load(url, path = assetPath, progress) {
return new Promise((resolve, reject) => {
this.loader.load(url, o => {
this.loader.load(`${path}${url}`, o => {
o.scene.traverse(object => {
if (object.name == 'environment' || object.material){
console.log('env recomputing')
//console.log('env recomputing')
object.material.shading = THREE.SmoothShading;
object.geometry.computeVertexNormals(true);
//object.material.metalness = 0;
@@ -408,9 +411,9 @@ class GameEngine extends THREE.EventDispatcher{
})
}
async loadTexture(url, progress) {
async loadTexture(url, path = assetPath, progress) {
return new Promise((resolve, reject) => {
new THREE.TextureLoader().load(url, texture => {
new THREE.TextureLoader().load(`${path}${url}`, texture => {
//texture.encoding = THREE.sRGBEncoding;
texture.colorSpace = THREE.SRGBColorSpace;
resolve(texture)
@@ -418,8 +421,8 @@ class GameEngine extends THREE.EventDispatcher{
})
}
async loadPanorama(url) {
let t = await this.loadTexture(url);
async loadPanorama(url, path = assetPath) {
let t = await this.loadTexture(url, path);
t.mapping = THREE.EquirectangularReflectionMapping;
this.scene.background = t;
this.scene.environment = t;