@needle-tools/engine 3.2.2-alpha → 3.2.3-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/engine",
3
- "version": "3.2.2-alpha",
3
+ "version": "3.2.3-alpha",
4
4
  "description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in",
5
5
  "main": "dist/needle-engine.umd.cjs",
6
6
  "type": "module",
@@ -1,5 +1,5 @@
1
1
  import { TypeStore } from "./../engine_typestore"
2
-
2
+
3
3
  // Import types
4
4
  import { __Ignore } from "../../engine-components/codegen/components";
5
5
  import { AlignmentConstraint } from "../../engine-components/AlignmentConstraint";
@@ -184,7 +184,7 @@ import { XRGrabModel } from "../../engine-components/WebXRGrabRendering";
184
184
  import { XRGrabRendering } from "../../engine-components/WebXRGrabRendering";
185
185
  import { XRRig } from "../../engine-components/WebXRRig";
186
186
  import { XRState } from "../../engine-components/XRFlag";
187
-
187
+
188
188
  // Register types
189
189
  TypeStore.add("__Ignore", __Ignore);
190
190
  TypeStore.add("AlignmentConstraint", AlignmentConstraint);
@@ -243,28 +243,31 @@ export class Input extends EventTarget {
243
243
  return null;
244
244
  }
245
245
  isKeyDown(keyCode: KeyCode | string) {
246
+ if (!this.context.application.isVisible || !this.context.application.hasFocus) return false;
246
247
  const codes = this.getCodeForCommonKeyName(keyCode);
247
248
  if (codes !== null) {
248
249
  for (const code of codes) if (this.isKeyDown(code)) return true;
249
250
  return false;
250
251
  }
251
- return this.context.application.isVisible && this.context.application.hasFocus && this.keysPressed[keyCode]?.startFrame === this.context.time.frameCount && this.keysPressed[keyCode].pressed;
252
+ return this.keysPressed[keyCode]?.startFrame === this.context.time.frameCount && this.keysPressed[keyCode].pressed;
252
253
  }
253
254
  isKeyUp(keyCode: KeyCode | string) {
255
+ if (!this.context.application.isVisible || !this.context.application.hasFocus) return false;
254
256
  const codes = this.getCodeForCommonKeyName(keyCode);
255
257
  if (codes !== null) {
256
258
  for (const code of codes) if (this.isKeyUp(code)) return true;
257
259
  return false;
258
260
  }
259
- return this.context.application.isVisible && this.context.application.hasFocus && this.keysPressed[keyCode]?.frame === this.context.time.frameCount && !this.keysPressed[keyCode].pressed;
261
+ return this.keysPressed[keyCode]?.frame === this.context.time.frameCount && !this.keysPressed[keyCode].pressed;
260
262
  }
261
263
  isKeyPressed(keyCode: KeyCode | string) {
264
+ if (!this.context.application.isVisible || !this.context.application.hasFocus) return false;
262
265
  const codes = this.getCodeForCommonKeyName(keyCode);
263
266
  if (codes !== null) {
264
267
  for (const code of codes) if (this.isKeyPressed(code)) return true;
265
268
  return false;
266
269
  }
267
- return this.context.application.isVisible && this.context.application.hasFocus && this.keysPressed[keyCode]?.pressed;// && time.frameCount - this.keysPressed[keyCode].frame < 100;
270
+ return this.keysPressed[keyCode]?.pressed;// && time.frameCount - this.keysPressed[keyCode].frame < 100;
268
271
  }
269
272
 
270
273
  // utility helper for mapping common names to actual codes; e.g. "Shift" -> "ShiftLeft" and "ShiftRight" or "a" -> "KeyA"