Here the code of the animation with the camera position, do I need to change the camera position for mobile so that it could be scrollable on mobile as well or other change should needed.
Thanks in advance, help would be appreciated
function init() {
let windowSize1 = gsap.matchMedia();
const container = document.createElement(‘div’);
container.id = ‘canvasContainer’
document.body.appendChild(container);
camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.25, 2000);
camera.position.set(0, 5, 5);
// camera.position.set(0, 0, 20);
windowSize1.add("(max-width : 550px)", ()=>{
camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.25, 2000);
camera.position.set(0, 5, 5);
});
scene = new THREE.Scene();
// const light = new THREE.AmbientLight("#ffffff"); // soft white light
// scene.add(light);
// const light2 = new THREE.HemisphereLight(0xffffbb, 0xffffff, .1);
// scene.add(light2)
light = new THREE.PointLight(0xffffff,10, 100);
light.position.set(0, 5, 0);
scene.add(light);
rectLight = new THREE.RectAreaLight(0xffffff, 4, 12, 1.2);
rectLight.position.set(0, 6, -2);
rectLight.lookAt(0, 5, 5);
scene.add(rectLight)
// const rectLightHelper = new RectAreaLightHelper(rectLight);
// rectLight.add(rectLightHelper);
// const size = 20;
// const divisions = 10;
// const gridHelper = new THREE.GridHelper(size, divisions);
// scene.add(gridHelper);
// model
const loader = new GLTFLoader().setPath('/');
//const url = "/dev.thealphagency.com/alpha-v2/";
const url = "";
loader.load(`${url}moon.gltf`, function (gltf) {
moon = gltf;
scene.add(moon.scene);
gsap
.timeline()
.from(
moon.scene.rotation,
{
// x: 0.2,
// y: 5,
// duration: 1, // [x] Add timing
animation: animate(),
},
0
)
.to(
"#alpha",
{
opacity: 1,
y: -10,
duration: 2,
// backgroundImage: "url(17@2x.png)",
},
1
);
});