#Hello, I have some problems using FPS Controls, can you help?
54 messages · Page 1 of 1 (latest)
That’s a wrong console then
Because in your animate() function you have a console.log - which doesn’t show in the console on the screenshot
Or you shared a different code
No, I have just removed console.log
import * as THREE from "three";
import { FirstPersonControls } from "three/addons/controls/FirstPersonControls.js";
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
1000
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
const geometry = new THREE.BoxGeometry();
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
const cube = new THREE.Mesh(geometry, material);
scene.add(cube);
// Create a plane to serve as the ground
const planeGeometry = new THREE.PlaneGeometry(100, 100);
const planeMaterial = new THREE.MeshBasicMaterial({
color: 0xffffff,
side: THREE.DoubleSide,
});
const plane = new THREE.Mesh(planeGeometry, planeMaterial);
plane.rotateX(Math.PI / 2);
scene.add(plane);
// Add a light to the scene
const light = new THREE.PointLight(0xffffff, 1, 100);
light.position.set(0, 0, 10);
scene.add(light);
// Set up the FirstPersonControls
const controls = new FirstPersonControls(camera, renderer.domElement);
controls.lookSpeed = 0.1;
controls.movementSpeed = 10;
controls.noFly = true;
controls.lookVertical = true;
controls.constrainVertical = true;
controls.verticalMin = 1.0;
controls.verticalMax = 2.0;
controls.lon = -90;
camera.position.y = 1;
camera.position.z = 5;
const animate = function () {
requestAnimationFrame(animate);
controls.update();
renderer.render(scene, camera);
};
animate();
I also have seen this
Can I see the code? I want exactly same thing to do
Yes - bottom right corner 😁
where??
I have opened it and plaied
Corner
ok 1 m
Screenshot the browser
I’m on phone
Playing with Ogar while @pseudo pecan ain’t paying attention
Ahh
I have seen it I think
<>
this
button
ah some problems
this is throwing error
how to handle it?
what do I lay my eyes upon tho
just copy code parts from the example - no point in running it locally, it'll look same as the one online
(to run examples locally you'll need a webserver that points to correct assets)
yoou see collision-world.glb
yes, you need the assets to be served locally