amazing maze

This commit is contained in:
2025-10-20 22:49:08 +03:00
parent 192a900a96
commit 3ff60a1cf4
9 changed files with 140 additions and 70 deletions
+30
View File
@@ -0,0 +1,30 @@
import { TextureLoader } from "three";
function assignParams(mesh, params){
['scale', 'rotation', 'position'].forEach(p=>params[p] && mesh[p].fromArray(params[p]));
['visible', 'name'].forEach(p=>{
if (params[p]!==undefined) mesh[p] = params[p];
});
}
function assignMaterial(mesh, params, context){
if (params.name && params.material){
console.log(mesh)
//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);
mesh.material.map = dm;
}
if (params.nm){
mesh.material.normalMap = new TextureLoader().setPath(context.path).load(params.nm);
}
if (params.em) {
mesh.material.emissiveMap = new TextureLoader().setPath(context.path).load(params.em);
}
//mesh.material = mp;
mesh.material.needsUpdate = true;
}
}
export { assignParams, assignMaterial }
+6 -1
View File
@@ -4,6 +4,7 @@ import { DRACOLoader } from 'three/examples/jsm/Addons.js';
import { OrbitControls } from 'three/examples/jsm/Addons.js';
//import { Controller as OrbitControls } from './3rd-party/phy/3TH/Controller.js';
import { ViewportGizmo } from "three-viewport-gizmo";
import Stats from 'three/examples/jsm/libs/stats.module';
//import { AnaglyphEffect } from './three/AnaglyphEffect';
import { AnaglyphEffect } from 'three/addons/effects/AnaglyphEffect.js';
import { StereoEffect } from 'three/addons/effects/StereoEffect.js';
@@ -23,7 +24,7 @@ class GameEngine {
this.opts = opts;
const gameEngine = this;
this.perspectiveCamera = new THREE.PerspectiveCamera(45, this.aspect, 0.01, 1000);
this.perspectiveCamera = new THREE.PerspectiveCamera(45, this.aspect, 0.01, 25);
this.raycaster = new THREE.Raycaster();
this.perspectiveCamera.position.set(0, 0, 10);
@@ -163,6 +164,9 @@ class GameEngine {
await this.initPhysics();
this.stats = new Stats();
document.body.appendChild(this.stats.dom);
if (opts.ar) {
renderer.xr.enabled = true;
document.body.appendChild(ARButton.createButton(renderer, {}));
@@ -569,6 +573,7 @@ class GameEngine {
} else {
this.renderer.render(scene, camera);
}
this.stats?.update()
}
}
-7
View File
@@ -54,11 +54,4 @@ export default {
rad2deg(rad){
return rad * 180 / Math.PI;
},
assignMeshParams(mesh, params){
['scale', 'rotation', 'position'].forEach(p=>params[p] && mesh[p].fromArray(params[p]));
['visible', 'name'].forEach(p=>{
if (params[p]!==undefined) mesh[p] = params[p];
});
},
}