소스 검색

Improve scene fading performance by using canvas instead of Image.

pull/880/head
Nico Höllerich 4 년 전
부모
커밋
fdf02d9803
2개의 변경된 파일19개의 추가작업 그리고 6개의 파일을 삭제
  1. +5
    -1
      src/js/libpannellum.js
  2. +14
    -5
      src/js/pannellum.js

+ 5
- 1
src/js/libpannellum.js 파일 보기

@@ -899,7 +899,11 @@ function Renderer(container) {
}

if (params.returnImage !== undefined) {
return canvas.toDataURL('image/png');
var canv = document.createElement('canvas');
canv.width = canvas.width;
canv.height = canvas.height;
canv.getContext('2d').drawImage(canvas, 0, 0);
return canv;
}
};


+ 14
- 5
src/js/pannellum.js 파일 보기

@@ -2424,15 +2424,24 @@ function loadScene(sceneId, targetPitch, targetYaw, targetHfov, fadeDone) {
if (config.sceneFadeDuration && !fadeDone) {
var data = renderer.render(config.pitch * Math.PI / 180, config.yaw * Math.PI / 180, config.hfov * Math.PI / 180, {returnImage: true});
if (data !== undefined) {
fadeImg = new Image();
if (data instanceof HTMLCanvasElement)
fadeImg = data;
else
fadeImg = new Image();

fadeImg.className = 'pnlm-fade-img';
fadeImg.style.transition = 'opacity ' + (config.sceneFadeDuration / 1000) + 's';
fadeImg.style.width = '100%';
fadeImg.style.height = '100%';
fadeImg.onload = function() {
setTimeout(() => loadScene(sceneId, targetPitch, targetYaw, targetHfov, true), 100); // prevents black flickering before fading
};
fadeImg.src = data;

if (data instanceof HTMLCanvasElement)
setTimeout(() => loadScene(sceneId, targetPitch, targetYaw, targetHfov, true), 100);
else {
fadeImg.onload = function () {
setTimeout(() => loadScene(sceneId, targetPitch, targetYaw, targetHfov, true), 100); // prevents black flickering before fading
};
fadeImg.src = data;
}
renderContainer.appendChild(fadeImg);
renderer.fadeImg = fadeImg;
return;


불러오는 중...
취소
저장