Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESM First Person Controller #7252

Merged
merged 10 commits into from
Jan 13, 2025
12 changes: 5 additions & 7 deletions examples/src/examples/camera/first-person.example.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// @config DESCRIPTION <div style='text-align:center'><div>(<b>WASD</b>) Move</div><div>(<b>Space</b>) Jump</div><div>(<b>Mouse</b>) Look</div></div>
import { deviceType, rootPath } from 'examples/utils';
import { deviceType, fileImport, rootPath } from 'examples/utils';
import * as pc from 'playcanvas';

const { FirstPersonController } = await fileImport(`${rootPath}/static/scripts/esm/first-person-controller.mjs`);

const canvas = /** @type {HTMLCanvasElement} */ (document.getElementById('application-canvas'));
window.focus();

Expand All @@ -23,7 +25,6 @@ const gfxOptions = {

const assets = {
map: new pc.Asset('map', 'container', { url: `${rootPath}/static/assets/models/fps-map.glb` }),
script: new pc.Asset('script', 'script', { url: `${rootPath}/static/scripts/camera/first-person-camera.js` }),
helipad: new pc.Asset(
'helipad-env-atlas',
'texture',
Expand Down Expand Up @@ -112,15 +113,12 @@ function createCharacterController(camera) {
restitution: 0
});
entity.addComponent('script');
entity.script.create('characterController', {
entity.script.create(FirstPersonController, {
attributes: {
camera: camera,
camera,
jumpForce: 850
}
});
entity.script.create('desktopInput');
entity.script.create('mobileInput');
entity.script.create('gamePadInput');

return entity;
}
Expand Down
Loading
Loading