Commit 890b44ea authored by 李苏's avatar 李苏 💬

避免缓存运行卡顿,设置重新渲染方法

parent cbfe8e71
...@@ -48,13 +48,33 @@ export default class Viewer { ...@@ -48,13 +48,33 @@ export default class Viewer {
const animate = () => { const animate = () => {
if(this.canRequestAnimationFrame){ if(this.canRequestAnimationFrame){
requestAnimationFrame(animate)
this.#updateDom()
this.#renderDom()
this.animateEventList.forEach(
event => {
event.fun && event.content && event.fun(event.content)
})
requestAnimationFrame(animate)
}
}
animate()
}
reInit(){
const animate = () => {
if(this.canRequestAnimationFrame){
this.#updateDom() this.#updateDom()
this.#renderDom() this.#renderDom()
this.animateEventList.forEach( this.animateEventList.forEach(
event => { event => {
event.fun && event.content && event.fun(event.content) event.fun && event.content && event.fun(event.content)
}) })
requestAnimationFrame(animate)
} }
} }
...@@ -127,7 +147,14 @@ export default class Viewer { ...@@ -127,7 +147,14 @@ export default class Viewer {
alpha: true, // true/false 表示是否可以设置背景色透明 alpha: true, // true/false 表示是否可以设置背景色透明
precision: "highp", // highp/mediump/lowp 表示着色精度选择 precision: "highp", // highp/mediump/lowp 表示着色精度选择
premultipliedAlpha: true, // true/false 表示是否可以设置像素深度(用来度量图像的分辨率) premultipliedAlpha: true, // true/false 表示是否可以设置像素深度(用来度量图像的分辨率)
autoClear: true,
preserveDrawingBuffer: false,
antialias: true,
shadowMap :false,
physicalCorrectLights: false
}) })
this.renderer.clearDepth(); // 设置深度缓冲区 this.renderer.clearDepth(); // 设置深度缓冲区
this.renderer.shadowMap.enabled = true // 场景中的阴影自动更新 this.renderer.shadowMap.enabled = true // 场景中的阴影自动更新
this.viewerDom.appendChild(this.renderer.domElement) // 将渲染器添加到画布中 this.viewerDom.appendChild(this.renderer.domElement) // 将渲染器添加到画布中
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment