Needle Engine

Changes between version 3.7.4-alpha and 3.7.5-alpha
Files changed (5) hide show
  1. src/engine/codegen/register_types.js +2 -2
  2. src/engine-components/AudioSource.ts +3 -0
  3. src/engine-components/timeline/SignalAsset.ts +6 -2
  4. src/engine-components/SpatialTrigger.ts +3 -3
  5. src/engine-components/timeline/TimelineTracks.ts +3 -1
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/AudioSource.ts CHANGED
@@ -309,6 +309,9 @@
309
309
  }
310
310
 
311
311
  play(clip: string | undefined = undefined) {
312
+ // Make sure this is always just a string
313
+ if (typeof clip !== "string") clip = undefined;
314
+
312
315
  if (!this.audioLoader || !this.sound || (clip && clip !== this.clip)) {
313
316
  this.loadAndPlay(clip);
314
317
  return;
src/engine-components/timeline/SignalAsset.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { EventList } from "../EventList";
2
2
  import { Behaviour } from "../Component";
3
- import { ISerializable, SerializationContext, TypeSerializer } from "../../engine/engine_serialization_core";
4
- import { eventListSerializer } from "../../engine/engine_serialization_builtin_serializer";
5
3
  import { serializable } from "../../engine/engine_serialization_decorator";
4
+ import { getParam } from "../../engine/engine_utils";
6
5
 
6
+ const debug = getParam("debugsignals")
7
7
 
8
8
 
9
9
  export class SignalAsset {
@@ -36,6 +36,10 @@
36
36
  @serializable(SignalReceiverEvent)
37
37
  events?: SignalReceiverEvent[];
38
38
 
39
+ awake(): void {
40
+ if(debug) console.log("SignalReceiver awake", this);
41
+ }
42
+
39
43
  onEnable(): void {
40
44
  if (this.events) {
41
45
  for (const evt of this.events) {
src/engine-components/SpatialTrigger.ts CHANGED
@@ -63,17 +63,17 @@
63
63
  onEnterTrigger(trigger: SpatialTrigger): void {
64
64
  if(debug) console.log("ENTER TRIGGER", this.name, trigger.name, this, trigger);
65
65
  trigger.raiseOnEnterEvent(this);
66
- this.onEnter?.invoke(this, trigger);
66
+ this.onEnter?.invoke();
67
67
  }
68
68
  onExitTrigger(trigger: SpatialTrigger): void {
69
69
  if(debug) console.log("EXIT TRIGGER", this.name, trigger.name, this, trigger);
70
70
  trigger.raiseOnExitEvent(this);
71
- this.onExit?.invoke(this, trigger);
71
+ this.onExit?.invoke();
72
72
  }
73
73
 
74
74
  onStayTrigger(trigger: SpatialTrigger): void {
75
75
  trigger.raiseOnStayEvent(this);
76
- this.onStay?.invoke(this, trigger);
76
+ this.onStay?.invoke();
77
77
  }
78
78
  }
79
79
 
src/engine-components/timeline/TimelineTracks.ts CHANGED
@@ -723,6 +723,8 @@
723
723
  // if (lastTime === -1) lastTime = time;
724
724
  // this._lastTime = time;
725
725
 
726
+ const estimatedFrameLengthWithPadding = this.director.context.time.deltaTime * 1.5;
727
+
726
728
  for (let i = 0; i < this.models.length; i++) {
727
729
  const model = this.models[i];
728
730
  const wasTriggered = this.didTrigger[i];
@@ -738,7 +740,7 @@
738
740
  // }
739
741
  else {
740
742
  const abs = Math.abs(td);
741
- if (abs >= .00001 && abs < .1) {
743
+ if (abs >= .00001 && abs < estimatedFrameLengthWithPadding) {
742
744
  isActive = true;
743
745
  }
744
746
  }