Spaces:
Running
Running
Update viewer.js
Browse files
viewer.js
CHANGED
|
@@ -166,6 +166,7 @@ export async function initializeViewer(config, instanceId) {
|
|
| 166 |
opts.graphicsDevice = device;
|
| 167 |
opts.mouse = new pc.Mouse(canvas);
|
| 168 |
opts.touch = new pc.TouchDevice(canvas);
|
|
|
|
| 169 |
opts.componentSystems = [
|
| 170 |
pc.RenderComponentSystem,
|
| 171 |
pc.CameraComponentSystem,
|
|
@@ -194,7 +195,10 @@ export async function initializeViewer(config, instanceId) {
|
|
| 194 |
resizeObserver.observe(viewerContainer);
|
| 195 |
|
| 196 |
window.addEventListener('resize', () => app.resizeCanvas(viewerContainer.clientWidth, viewerContainer.clientHeight));
|
| 197 |
-
app.on('destroy', () =>
|
|
|
|
|
|
|
|
|
|
| 198 |
|
| 199 |
// Assets after app exists
|
| 200 |
const assets = {
|
|
@@ -281,7 +285,13 @@ export async function initializeViewer(config, instanceId) {
|
|
| 281 |
});
|
| 282 |
cameraEntity.script.create('orbitCameraInputMouse');
|
| 283 |
cameraEntity.script.create('orbitCameraInputTouch');
|
| 284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
app.root.addChild(cameraEntity);
|
| 286 |
|
| 287 |
app.resizeCanvas(viewerContainer.clientWidth, viewerContainer.clientHeight);
|
|
|
|
| 166 |
opts.graphicsDevice = device;
|
| 167 |
opts.mouse = new pc.Mouse(canvas);
|
| 168 |
opts.touch = new pc.TouchDevice(canvas);
|
| 169 |
+
opts.keyboard = new pc.Keyboard(window);
|
| 170 |
opts.componentSystems = [
|
| 171 |
pc.RenderComponentSystem,
|
| 172 |
pc.CameraComponentSystem,
|
|
|
|
| 195 |
resizeObserver.observe(viewerContainer);
|
| 196 |
|
| 197 |
window.addEventListener('resize', () => app.resizeCanvas(viewerContainer.clientWidth, viewerContainer.clientHeight));
|
| 198 |
+
app.on('destroy', () => {
|
| 199 |
+
resizeObserver.disconnect();
|
| 200 |
+
if (opts.keyboard) opts.keyboard.detach && opts.keyboard.detach();
|
| 201 |
+
});
|
| 202 |
|
| 203 |
// Assets after app exists
|
| 204 |
const assets = {
|
|
|
|
| 285 |
});
|
| 286 |
cameraEntity.script.create('orbitCameraInputMouse');
|
| 287 |
cameraEntity.script.create('orbitCameraInputTouch');
|
| 288 |
+
cameraEntity.script.create('orbitCameraInputKeyboard', {
|
| 289 |
+
attributes: {
|
| 290 |
+
forwardSpeed: 1.2, // vitesses relatives à la distance
|
| 291 |
+
strafeSpeed: 1.2,
|
| 292 |
+
fastMultiplier: 2.5, // Shift
|
| 293 |
+
slowMultiplier: 0.5 // Ctrl
|
| 294 |
+
}
|
| 295 |
app.root.addChild(cameraEntity);
|
| 296 |
|
| 297 |
app.resizeCanvas(viewerContainer.clientWidth, viewerContainer.clientHeight);
|