in src/component/slider/SliderGLRenderer.ts [273:408]
private _updateImagePlanes(state: IAnimationState, mode: SliderConfigurationMode): void {
const currentChanged: boolean = state.currentImage != null && this._currentKey !== state.currentImage.id;
const previousChanged: boolean = state.previousImage != null && this._previousKey !== state.previousImage.id;
const modeChanged: boolean = this._mode !== mode;
if (!(currentChanged || previousChanged || modeChanged)) {
return;
}
this._setDisabled(state);
this._needsRender = true;
this._mode = mode;
const motionless =
state.motionless ||
mode === SliderConfigurationMode.Stationary ||
isSpherical(state.currentImage.cameraType);
if (this.disabled || previousChanged) {
if (this._previousKey in this._previousProviderDisposers) {
this._previousProviderDisposers[this._previousKey]();
delete this._previousProviderDisposers[this._previousKey];
}
}
if (this.disabled) {
this._scene.setImagePlanesOld({});
} else {
if (previousChanged || modeChanged) {
const previousNode: Image = state.previousImage;
this._previousKey = previousNode.id;
const elements: number[] = state.currentTransform.rt.elements;
let translation: number[] = [elements[12], elements[13], elements[14]];
const currentAspect: number = state.currentTransform.basicAspect;
const previousAspect: number = state.previousTransform.basicAspect;
const textureScale: number[] = currentAspect > previousAspect ?
[1, previousAspect / currentAspect] :
[currentAspect / previousAspect, 1];
let rotation: number[] = state.currentImage.rotation;
let width: number = state.currentImage.width;
let height: number = state.currentImage.height;
if (isSpherical(previousNode.cameraType)) {
rotation = state.previousImage.rotation;
translation = this._spatial
.rotate(
this._spatial
.opticalCenter(
state.currentImage.rotation,
translation)
.toArray(),
rotation)
.multiplyScalar(-1)
.toArray();
width = state.previousImage.width;
height = state.previousImage.height;
}
const transform: Transform = new Transform(
state.currentImage.exifOrientation,
width,
height,
state.currentImage.scale,
rotation,
translation,
previousNode.image,
textureScale,
state.currentImage.cameraParameters,
<CameraType>state.currentImage.cameraType);
let mesh: THREE.Mesh = undefined;
if (isSpherical(previousNode.cameraType)) {
mesh = this._factory.createMesh(
previousNode,
motionless ||
isSpherical(state.currentImage.cameraType) ?
transform : state.previousTransform);
} else {
if (motionless) {
const [[basicX0, basicY0], [basicX1, basicY1]]: number[][] = this._getBasicCorners(currentAspect, previousAspect);
mesh = this._factory.createFlatMesh(
state.previousImage,
transform,
basicX0,
basicX1,
basicY0,
basicY1);
} else {
mesh = this._factory.createMesh(state.previousImage, state.previousTransform);
}
}
const previousPlanes: { [key: string]: THREE.Mesh } = {};
previousPlanes[previousNode.id] = mesh;
this._scene.setImagePlanesOld(previousPlanes);
}
}
if (currentChanged || modeChanged) {
if (this._currentKey in this._currentProviderDisposers) {
this._currentProviderDisposers[this._currentKey]();
delete this._currentProviderDisposers[this._currentKey];
}
this._currentKey = state.currentImage.id;
const planes: { [key: string]: THREE.Mesh } = {};
if (isSpherical(state.currentImage.cameraType)) {
planes[state.currentImage.id] =
this._factory.createCurtainMesh(
state.currentImage,
state.currentTransform);
} else {
if (motionless) {
planes[state.currentImage.id] = this._factory.createDistortedCurtainMesh(state.currentImage, state.currentTransform);
} else {
planes[state.currentImage.id] = this._factory.createCurtainMesh(state.currentImage, state.currentTransform);
}
}
this._scene.setImagePlanes(planes);
this._updateCurtain();
}
}