This commit is contained in:
2026-06-04 16:15:21 +08:00
parent 7676364229
commit bef0bf527b
34 changed files with 158 additions and 309 deletions

View File

@ -21,18 +21,29 @@ export class AppCamera extends Monobehiver {
const canvas = AppConfig.container;
if (!scene || !canvas) return;
// 创建弧形旋转相机水平角70度垂直角85度接近上帝视角距离5目标点(0,2,0)
this.object = new ArcRotateCamera('Camera', Tools.ToRadians(70), Tools.ToRadians(85), 5, new Vector3(0, 2, 0), scene);
// 从配置中获取相机参数
const { position, target } = AppConfig.camera;
// 创建弧形旋转相机水平角70度垂直角85度接近上帝视角距离5目标点从配置读取
this.object = new ArcRotateCamera(
'Camera',
Tools.ToRadians(70),
Tools.ToRadians(85),
5,
new Vector3(target.x, target.y, target.z),
scene
);
this.object.attachControl(canvas, true);
this.object.minZ = 0.01; // 近裁剪面
this.object.wheelPrecision =200; // 滚轮缩放精度
this.object.wheelPrecision = 200; // 滚轮缩放精度
this.object.panningSensibility = 0;
// 限制垂直角范围,实现上帝视角
this.object.upperBetaLimit = Tools.ToRadians(90); // 最大垂直角接近90度避免万向锁
this.object.position = new Vector3(0,0, 10);
this.setTarget(0, 0.5, 0);
// 设置相机位置(从配置读取)
this.object.position = new Vector3(position.x, position.y, position.z);
this.setTarget(target.x, target.y, target.z);
}
/** 设置相机目标点 */

View File

@ -14,6 +14,10 @@ export const AppConfig = {
rotationY: 0,
background: false,
},
camera: {
position: { x: 0, y: 2, z: 5 },
target: { x: 0, y: 1, z: 0 },
},
gizmo: {
position: true,
rotation: false,

View File

@ -839,16 +839,17 @@ export class GameManager extends Monobehiver {
// material.metallicTexture = null;
// }
// }
console.log(options);
// 应用粗糙度值
// if (options.roughness !== undefined) {
// material.roughness = options.roughness;
// }
if (options.roughness !== undefined) {
material.roughness = options.roughness;
}
// // 应用金属度值
// if (options.metallic !== undefined) {
// material.metallic = options.metallic;
// }
if (options.metallic !== undefined) {
material.metallic = options.metallic;
}
// alert(typeof options.metallic + ' ' + typeof options.roughness);
// 强制刷新材质

View File

@ -70,6 +70,7 @@ export class MainApp {
AppConfig.container = config.container;
AppConfig.modelUrlList = config.modelUrlList || [];
AppConfig.env = { ...AppConfig.env, ...(config.env || {}) };
AppConfig.camera = { ...AppConfig.camera, ...(config.camera || {}) };
AppConfig.gizmo = { ...AppConfig.gizmo, ...(config.gizmo || {}) };
AppConfig.outline = { ...AppConfig.outline, ...(config.outline || {}) };
this.appPositionGizmo.configure(AppConfig.gizmo);

View File

@ -113,6 +113,7 @@ export class KernelAdapter {
roughness?: number;
metallic?: number;
}): void => {
console.log(options);
this.mainApp.gameManager.applyMaterial(options);
},

View File

@ -23,6 +23,10 @@ type InitParams = {
rotationY?: number;
background?: boolean;
};
camera?: {
position?: { x: number; y: number; z: number };
target?: { x: number; y: number; z: number };
};
gizmo?: {
position?: boolean;
rotation?: boolean;
@ -66,6 +70,7 @@ const kernel = {
container,
modelUrlList: params.modelUrlList || [],
env: params.env,
camera: params.camera,
gizmo: params.gizmo,
outline: params.outline,
});