My computer is configured with i9-12900KS RTX3080TI 96GB
GPU is basically 80% -100%
When I rotate and move, it feels very laggy
const loadModel = async (glb: any) => {
return new Promise(async (resolve) => {
console.log(glb, " 加载单个 GLB 模型");
const hpr = new HeadingPitchRoll(heading, pitch, roll); // 初始姿态
// 如果你想让模型从当前方向向右转 45 度
let rotationAngleInDegrees = 121;
let rotationAngleInRadians = CesiumMath.toRadians(rotationAngleInDegrees);
// 更新 heading
hpr.heading = (hpr.heading + rotationAngleInRadians) % (2 * Math.PI);
// Heading (朝北角度,偏航)
// Pitch (上下倾斜角度,俯仰)
// Roll (水平旋转角度,翻滚)
const modelMatrix = Transforms.headingPitchRollToFixedFrame(
position,
hpr,
Ellipsoid.WGS84
);
// 保存初始矩阵供后续使用
const initialModelMatrix = modelMatrix.clone();
const model = await Model.fromGltfAsync({
url: glb,
modelMatrix: modelMatrix,
scale: 0.01,
// minimumPixelSize: 128,
// maximumScale: Number.MAX_VALUE,
incrementallyLoadTextures: true,
// debugShowBoundingVolume: true,
// outlineColor: Color.RED,
// silhouetteSize: 2.0,
});
model.show = true;
modelRef.instance = model; // 引用保存,方便后续修改
modelRef.initialMatrix = initialModelMatrix; // 存储基准矩阵
modelRef.instance.color = getColor("White", opacity.value); // 设置模型透明度 "White", "Red", "Green", "Blue", "Yellow", "Gray"
// 通过轮询检查模型是否加载完成
const checkModelReady = setInterval(() => {
console.log(model.ready);
if (model.ready) {
console.log("模型加载完成", checkModelReady);
clearInterval(checkModelReady); // 停止轮询
} else {
console.log("模型正在加载...");
}
}, 100); // 每100毫秒检查一次模型加载状态
resolve(model);
});
};
for (const path of absolutePaths) {
if (!modelsMap.has(path)) {
const model = await loadModel(path);
modelsMap.set(path, model); // 存储模型引用
scene.value.primitives.add(model);
}
}