glbRepulsionSystem in transitionManager.js
This commit is contained in:
parent
6bd4a96e2d
commit
bd2bccdcb2
|
@ -25,6 +25,9 @@ export let mixer = null;
|
|||
export let nextMixer = null;
|
||||
export let autoRotationAngle = 0;
|
||||
|
||||
// GLB repulsion system reference (will be set by main.js)
|
||||
export let glbRepulsionSystem = null;
|
||||
|
||||
// Setter functions to modify exported variables safely
|
||||
export function setCurrentModel(model) {
|
||||
currentModel = model;
|
||||
|
@ -42,6 +45,10 @@ export function setNextMixer(animMixer) {
|
|||
nextMixer = animMixer;
|
||||
}
|
||||
|
||||
export function setGLBRepulsionSystem(system) {
|
||||
glbRepulsionSystem = system;
|
||||
}
|
||||
|
||||
// Calculate camera-relative transition vectors for diagonal movement
|
||||
export function calculateTransitionVectors(camera) {
|
||||
// Get camera's world direction
|
||||
|
@ -81,6 +88,7 @@ export function startTransition(direction = 1, preloadedModels, scene, camera, c
|
|||
if (direction < 0 && currentScene <= 0) return; // Can't go backward from bold
|
||||
|
||||
console.log(`Starting diagonal transition: direction=${direction}, currentScene=${currentScene}`);
|
||||
|
||||
// Calculate camera-relative diagonal transition vectors
|
||||
calculateTransitionVectors(camera);
|
||||
|
||||
|
@ -126,6 +134,12 @@ export function startTransition(direction = 1, preloadedModels, scene, camera, c
|
|||
nextModel.position.copy(transitionUpVector);
|
||||
console.log(`Next model positioned at diagonal up vector (top-left): x=${nextModel.position.x}, y=${nextModel.position.y}, z=${nextModel.position.z}`);
|
||||
}
|
||||
|
||||
// Register next model with GLB repulsion system
|
||||
if (glbRepulsionSystem) {
|
||||
glbRepulsionSystem.originalPositions.set(nextModel, nextModel.position.clone());
|
||||
}
|
||||
|
||||
// Add next model to scene without opacity changes - it will appear instantly when it enters the camera view
|
||||
scene.add(nextModel);
|
||||
}
|
||||
|
@ -137,6 +151,7 @@ export function updateTransition(deltaTime, scene) {
|
|||
|
||||
const elapsed = (performance.now() - transitionStartTime) / 1000;
|
||||
const transitionProgress = Math.min(elapsed / transitionDuration, 1);
|
||||
|
||||
// Smooth easing function (ease-in-out)
|
||||
const easeInOut = (t) => t * t * (3 - 2 * t);
|
||||
const easedProgress = easeInOut(transitionProgress);
|
||||
|
@ -184,6 +199,11 @@ export function updateTransition(deltaTime, scene) {
|
|||
});
|
||||
// Clean up geometry user data completely
|
||||
cleanupGeometryData(currentModel);
|
||||
// Remove from GLB repulsion system
|
||||
if (glbRepulsionSystem) {
|
||||
glbRepulsionSystem.originalPositions.delete(currentModel);
|
||||
glbRepulsionSystem.currentTargets.delete(currentModel);
|
||||
}
|
||||
scene.remove(currentModel);
|
||||
console.log('Previous model removed from scene');
|
||||
}
|
||||
|
@ -194,6 +214,10 @@ export function updateTransition(deltaTime, scene) {
|
|||
mixer = nextMixer;
|
||||
// Reset position to center
|
||||
currentModel.position.set(0, 0, 0);
|
||||
// Update GLB repulsion system with new center position
|
||||
if (glbRepulsionSystem) {
|
||||
glbRepulsionSystem.originalPositions.set(currentModel, currentModel.position.clone());
|
||||
}
|
||||
}
|
||||
|
||||
nextModel = null;
|
||||
|
@ -236,4 +260,4 @@ export function onMouseScroll(event, preloadedModels, scene, camera, controls) {
|
|||
startTransition(-1, preloadedModels, scene, camera, controls); // Backward direction
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue