This commit is contained in:
2026-05-22 13:33:13 +08:00
parent c504fca3de
commit 84c8752e0b
17 changed files with 361939 additions and 921 deletions

View File

@ -31,7 +31,7 @@ export class AppCamera extends Monobehiver {
// 限制垂直角范围,实现上帝视角
this.object.upperBetaLimit = Tools.ToRadians(90); // 最大垂直角接近90度避免万向锁
this.object.position = new Vector3(0, 10, 0);
this.object.position = new Vector3(0,0, 10);
this.setTarget(0, 0.5, 0);
}

View File

@ -1,6 +1,7 @@
import { Engine } from '@babylonjs/core/Engines/engine';
import { Monobehiver } from '../base/Monobehiver';
import { AppConfig } from './AppConfig';
import { DefaultRenderingPipeline } from '@babylonjs/core';
/**
* 渲染引擎管理类 - 负责创建和管理3D渲染引擎
@ -27,6 +28,9 @@ export class AppEngin extends Monobehiver {
});
this.object.setSize(window.innerWidth, window.innerHeight);
this.object.setHardwareScalingLevel(1); // 1:1像素比例
}
/** 处理窗口大小变化 */

View File

@ -1,21 +1,22 @@
import { CubeTexture } from '@babylonjs/core/Materials/Textures/cubeTexture';
import { Monobehiver } from '../base/Monobehiver';
import { AppConfig } from './AppConfig';
import { PhotoDome, StandardMaterial } from '@babylonjs/core';
/**
* 环境管理类- 负责创建和管理HDR环境贴图
*/
export class AppEnv extends Monobehiver {
object: CubeTexture | null;
photoDome: PhotoDome | null;
constructor(mainApp: any) {
super(mainApp);
this.object = null;
}
/** 初始化 - 创建默认HDR环境 */
Awake(): void {
this.createHDR();
// this.createPanorama();
}
/**
@ -24,7 +25,7 @@ export class AppEnv extends Monobehiver {
*/
createHDR(): void {
const envPath = AppConfig.env.envPath;
const intensity = AppConfig.env.intensity ?? 1.5;
const intensity = AppConfig.env.intensity ?? 3;
const rotationY = AppConfig.env.rotationY ?? 0;
const scene = this.mainApp.appScene.object;
if (!scene) return;
@ -57,6 +58,31 @@ export class AppEnv extends Monobehiver {
}
createPanorama() {
if (!this.photoDome) {
this.photoDome = new PhotoDome(
'sphere_yundong',
'https://cdn.files.zguiy.com/zt/bg2.jpg', // 全景图路径
{
resolution: 64,
size: 30, // 球体大小,越大越远
generateMipMaps: false,
},
this.mainApp.appScene.object
);
this.photoDome.imageMode = PhotoDome.MODE_MONOSCOPIC; // 单镜头图像
// const clipPlane = new Plane(0, -1, 0, 0); // y < 0 裁掉下半球
// this.mainApp.appScene.object.clipPlane = clipPlane;
(this.photoDome.mesh.material as StandardMaterial).alpha = 0;
// 添加旋转
this.photoDome.mesh.rotation.y = 160 / 180 * Math.PI;
(this.photoDome.mesh.material as StandardMaterial).alpha = 1;
}
}
/**
* 修改HDR环境光强度
* @param intensity 强度值

View File

@ -58,10 +58,10 @@ export class AppGround extends Monobehiver {
receiveShadows: true,
position: new Vector3(0, 0, 0),
textureScale: { u: 10, v: 10 },
color: new Color3(0.5, 0.5, 0.5),
textureUrl: "https://cdn.files.zguiy.com/zt/ground1.jpg", // 默认贴图
color: new Color3(1,1,1),
textureUrl: "https://cdn.files.zguiy.com/zt/ground2.png", // 默认贴图
showGrid: true, // 默认显示网格
gridColor: new Color3(1,1,1),
gridColor: new Color3(0,0,0),
gridRatio: 1.0,
...config
};
@ -100,6 +100,7 @@ export class AppGround extends Monobehiver {
if (this.config.receiveShadows) {
this.ground.receiveShadows = true;
}
this.ground.isPickable = false;
}
/** 创建材质 */
@ -130,7 +131,7 @@ export class AppGround extends Monobehiver {
// PBR 材质属性设置
this.material.metallic = 0.0; // 非金属
this.material.roughness = 1.0; // 粗糙表面
this.material.alpha = 0.2;
this.ground.material = this.material;
}
@ -153,7 +154,7 @@ export class AppGround extends Monobehiver {
const gridPosition = this.config.position ? this.config.position.clone() : new Vector3(0, 0, 0);
gridPosition.y += 0.01; // 抬高0.01单位避免z-fighting
this.gridGround.position = gridPosition;
this.gridGround.isPickable = false;
// 创建网格材质
this.gridMaterial = new GridMaterial('gridMaterial', this.mainApp.appScene.object);
this.gridMaterial.mainColor = this.config.gridColor || new Color3(0.3, 0.3, 0.3);

View File

@ -34,9 +34,8 @@ export class AppLight extends Monobehiver {
/** 初始化灯光并开启阴影 */
Awake(): void {
const light = new DirectionalLight(
"mainLight",
new Vector3(0, -0.5, -1),
);
// 主光源(模拟太阳)
const light = new DirectionalLight("sun", new Vector3(-1, -2, -1), this.mainApp.appScene.object);
light.intensity = 1.2;
}
}

View File

@ -145,7 +145,7 @@ class AppRay extends Monobehiver {
const modelMetadata = this.mainApp.appModel.getMetadataByMesh(pickInfo.pickedMesh);
// 获取模型名称(优先使用 modelName如果没有则使用 modelId
const modelName = this.mainApp.appModel.findModelNameByMesh(pickInfo.pickedMesh);
console.log(modelName);
console.log(modelName);
EventBridge.modelClick({
meshName: pickInfo.pickedMesh.name,
@ -156,8 +156,7 @@ console.log(modelName);
modelControlType: modelMetadata?.modelControlType,
});
}
else{
console.log(1111);
else {
this.mainApp.appSelectionOutline.clear();
this.mainApp.appPositionGizmo.detach();

View File

@ -75,10 +75,10 @@ export class GameManager extends Monobehiver {
// 初始化材质和网格字典
this.updateDictionaries();
this.cacheRollerDoorMeshes();
// this.cacheRollerDoorMeshes();
this.setRollerDoorScale("Box006.001", new Vector3(0.12, 0.02, 0.118));
this.setRollerDoorScale("Box005.001", new Vector3(0.13, 0.02, 0.12));
// this.setRollerDoorScale("Box006.001", new Vector3(0.12, 0.02, 0.118));
// this.setRollerDoorScale("Box005.001", new Vector3(0.13, 0.02, 0.12));
}
/**