Needle Engine

Changes between version 3.19.5 and 3.19.6
Files changed (3) hide show
  1. src/engine-components/AudioSource.ts +6 -3
  2. src/engine-components/OrbitControls.ts +11 -2
  3. src/engine-components/VideoPlayer.ts +2 -0
src/engine-components/AudioSource.ts CHANGED
@@ -143,6 +143,7 @@
143
143
  @serializable()
144
144
  rollOffMode: AudioRolloffMode = 0;
145
145
 
146
+ @serializable()
146
147
  playInBackground: boolean = true;
147
148
 
148
149
  private _loop: boolean = false;
@@ -157,11 +158,13 @@
157
158
 
158
159
  public get Sound(): PositionalAudio | null {
159
160
  if (!this.sound && AudioSource._userInteractionRegistered) {
160
- const listener = GameObject.getComponent(this.context.mainCamera, AudioListener) ?? GameObject.findObjectOfType(AudioListener, this.context);
161
+ let listener = GameObject.getComponent(this.context.mainCamera, AudioListener) ?? GameObject.findObjectOfType(AudioListener, this.context);
162
+ if (!listener && this.context.mainCamera) listener = GameObject.addNewComponent(this.context.mainCamera, AudioListener);
161
163
  if (listener?.listener) {
162
164
  this.sound = new PositionalAudio(listener.listener);
163
165
  this.gameObject.add(this.sound);
164
166
  }
167
+ else if(debug) console.warn("No audio listener found in scene - can not play audio");
165
168
  }
166
169
  return this.sound;
167
170
  }
@@ -222,7 +225,7 @@
222
225
 
223
226
  private lerp = (x, y, a) => x * (1 - a) + y * a;
224
227
 
225
- private onLoaded(buffer) {
228
+ private onLoaded = (buffer) => {
226
229
  if (debug) console.log("audio buffer loaded");
227
230
  AudioSource.registerWaitForAllowAudio(() => {
228
231
  if (debug)
@@ -303,7 +306,7 @@
303
306
  this._lastClipStartedLoading = this.clip;
304
307
  if (debug)
305
308
  console.log("load audio", this.clip);
306
- this.audioLoader.load(this.clip, this.onLoaded.bind(this), () => { }, console.error);
309
+ this.audioLoader.load(this.clip, this.onLoaded, () => { }, console.error);
307
310
  }
308
311
  }
309
312
  }
src/engine-components/OrbitControls.ts CHANGED
@@ -43,6 +43,8 @@
43
43
  }
44
44
 
45
45
  @serializable()
46
+ enableRotate: boolean = true;
47
+ @serializable()
46
48
  autoRotate: boolean = false;
47
49
  @serializable()
48
50
  autoRotateSpeed: number = 1.0;
@@ -71,6 +73,8 @@
71
73
  middleClickToFocus: boolean = true;
72
74
  @serializable()
73
75
  doubleClickToFocus: boolean = true;
76
+ // @serializable()
77
+ // zoomToCursor: boolean = false;
74
78
 
75
79
  // remove once slerp works correctly
76
80
  useSlerp: boolean = true;
@@ -248,8 +252,10 @@
248
252
  this._inputs += 1;
249
253
  }
250
254
  if (this._inputs > 0) {
251
- this.autoRotate = false;
252
- this._controls.autoRotate = false;
255
+ // if a user has disabled rotation but enabled auto rotate we don't want to change it when we receive input
256
+ if (this.enableRotate) {
257
+ this.autoRotate = false;
258
+ }
253
259
  this._lerpCameraToTarget = false;
254
260
  this._lerpToTargetPosition = false;
255
261
  }
@@ -309,6 +315,9 @@
309
315
  this._controls.enableZoom = this.enableZoom;
310
316
  this._controls.dampingFactor = this.dampingFactor;
311
317
  this._controls.enablePan = this.enablePan;
318
+ this._controls.enableRotate = this.enableRotate;
319
+ //@ts-ignore
320
+ // this._controls.zoomToCursor = this.zoomToCursor;
312
321
  if (!this.context.isInXR)
313
322
  this._controls.update();
314
323
  }
src/engine-components/VideoPlayer.ts CHANGED
@@ -312,6 +312,8 @@
312
312
  break;
313
313
  case VideoSource.Url:
314
314
  src = this.url;
315
+ if(!src?.length && typeof this.clip === "string")
316
+ src = this.clip;
315
317
  break;
316
318
  }