Hi threejs community. Using this code, I expect sphereGeometry as left side and boxGeometry as right side. But, they are rendered on opposite side. Could you tell me why ?
I think in case of camera from (0, 0, -1000) ----> to (0, 0, 0),
- X positive direction as right side
- Y positive direction as up side
<html>
<head>
<meta charset='utf-8' />
<script type='importmap'>
{
"imports" : {
"THREEJS" : "https://cdn.jsdelivr.net/npm/three@0.130.1/build/three.module.js"
}
}
</script>
</head>
<body>
<script type='module'>
import * as THREE from 'THREEJS';
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 2000);
camera.position.set(0, 0, -1000);
camera.lookAt(new THREE.Vector3(0, 0, 0));
camera.up.set(0, 1, 0);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
const material = new THREE.MeshBasicMaterial({ color: 0x44aa88 });
// sphereGeometry (expect left side)
const sphereGeometry = new THREE.SphereGeometry(50, 32, 32);
const sphere = new THREE.Mesh(sphereGeometry, material);
sphere.position.x = -150;
scene.add(sphere);
// boxGeometry (expect right side)
const boxGeometry = new THREE.BoxGeometry(100, 100, 100);
const box = new THREE.Mesh(boxGeometry, material);
box.position.x = 150;
scene.add(box);
function animate() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>