Needle Engine

Changes between version 3.7.3-alpha.2 and 3.7.4-alpha
Files changed (3) hide show
  1. src/engine/codegen/register_types.js +2 -2
  2. src/engine-components/Component.ts +3 -1
  3. src/engine/engine_context.ts +9 -6
src/engine/codegen/register_types.js CHANGED
@@ -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 { ActionBuilder } from "../../engine-components/export/usdz/extensions/behavior/BehavioursBuilder";
@@ -216,7 +216,7 @@
216
216
  import { XRGrabRendering } from "../../engine-components/webxr/WebXRGrabRendering";
217
217
  import { XRRig } from "../../engine-components/webxr/WebXRRig";
218
218
  import { XRState } from "../../engine-components/XRFlag";
219
-
219
+
220
220
  // Register types
221
221
  TypeStore.add("__Ignore", __Ignore);
222
222
  TypeStore.add("ActionBuilder", ActionBuilder);
src/engine-components/Component.ts CHANGED
@@ -328,8 +328,10 @@
328
328
  return this.gameObject?.userData.tag;
329
329
  }
330
330
  set tag(str: string) {
331
- if (this.gameObject)
331
+ if (this.gameObject) {
332
+ if (!this.gameObject.userData) this.gameObject.userData = {}
332
333
  this.gameObject.userData.tag = str;
334
+ }
333
335
  }
334
336
  get static() {
335
337
  return this.gameObject?.userData.static;
src/engine/engine_context.ts CHANGED
@@ -783,16 +783,19 @@
783
783
  }
784
784
  }
785
785
 
786
- private internalRender(_, frame: XRFrame | null) {
786
+ private _lastTimestamp = 0;
787
+ private internalRender(timestamp : DOMHighResTimeStamp, frame: XRFrame | null) {
787
788
  this._xrFrame = frame;
788
789
 
789
790
  this._currentFrameEvent = FrameEvent.Undefined;
790
-
791
+
791
792
  if (this.isInXR === false && this.targetFrameRate !== undefined) {
792
- this._accumulatedTime += this._framerateClock.getDelta();
793
- let targetFrameRate = this.targetFrameRate as any;
794
- if (typeof targetFrameRate === "object") targetFrameRate = targetFrameRate.value;
795
- // if(debug) console.log(targetFrameRate)
793
+ if(this._lastTimestamp === 0) this._lastTimestamp = timestamp;
794
+ this._accumulatedTime += (timestamp - this._lastTimestamp) /1000;
795
+ this._lastTimestamp = timestamp;
796
+ let targetFrameRate = this.targetFrameRate;
797
+ if (typeof targetFrameRate === "object") targetFrameRate = targetFrameRate.value!;
798
+ // if(debug) console.log(this._accumulatedTime, (1 / (targetFrameRate)))
796
799
  if (this._accumulatedTime < (1 / (targetFrameRate + 1))) {
797
800
  return;
798
801
  }