Needle Engine

Changes between version 3.37.13-alpha and 3.37.14-alpha
Files changed (7) hide show
  1. src/engine-components/ui/BaseUIComponent.ts +1 -0
  2. src/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.ts +1 -1
  3. src/engine-components/ui/RectTransform.ts +7 -0
  4. src/engine-components/ScreenCapture.ts +1 -1
  5. src/engine-components/SpriteRenderer.ts +1 -0
  6. src/engine-components/export/usdz/USDZExporter.ts +9 -0
  7. src/engine-components/export/usdz/extensions/USDZUI.ts +2 -0
src/engine-components/ui/BaseUIComponent.ts CHANGED
@@ -97,6 +97,7 @@
97
97
  */
98
98
  protected addShadowComponent(container: any, parent?: BaseUIComponent) {
99
99
 
100
+ if (!container) return;
100
101
  this.removeShadowComponent();
101
102
 
102
103
  // instead of inserting here, we attach to the matching shadow hierarchy starting with the Canvas component.
src/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.ts CHANGED
@@ -98,7 +98,7 @@
98
98
  }
99
99
  const res = (obj as any).getPath?.call(obj) as string;
100
100
  if (addedStrings.has(res)) continue;
101
- console.log(str, res, addedStrings)
101
+ // console.log(str, res, addedStrings)
102
102
  str += res;
103
103
  addedStrings.add(res);
104
104
  }
src/engine-components/ui/RectTransform.ts CHANGED
@@ -133,6 +133,13 @@
133
133
 
134
134
  onEnable() {
135
135
  super.onEnable();
136
+
137
+ if (!this.rectBlock) this.rectBlock = new Object3D();
138
+ if (!this.lastMatrix) this.lastMatrix = new Matrix4();
139
+ if (!this._lastAnchoring) this._lastAnchoring = new Vector2();
140
+ if (!this._initialPosition) this._initialPosition = new Vector3();
141
+ if (!this._anchoredPosition) this._anchoredPosition = new Vector2();
142
+
136
143
  this.addShadowComponent(this.rectBlock);
137
144
  this._transformNeedsUpdate = true;
138
145
  this.canvas?.registerTransform(this);
src/engine-components/ScreenCapture.ts CHANGED
@@ -348,7 +348,7 @@
348
348
  this.gameObject.addComponent(this._audioSource);
349
349
  }
350
350
  if (!isSending) {
351
- console.log("PLAY", stream.getAudioTracks())
351
+ if(debug) console.log("PLAY", stream.getAudioTracks())
352
352
  this._audioSource.volume = 1;
353
353
  this._audioSource?.play(stream);
354
354
  }
src/engine-components/SpriteRenderer.ts CHANGED
@@ -187,6 +187,7 @@
187
187
  drawMode: SpriteDrawMode = SpriteDrawMode.Simple;
188
188
 
189
189
  /** @internal Used when drawMode is set to Tiled */
190
+ @serializable(Vec2)
190
191
  size: Vec2 = { x: 1, y: 1 };
191
192
 
192
193
  @serializable(RGBAColor)
src/engine-components/export/usdz/USDZExporter.ts CHANGED
@@ -8,6 +8,7 @@
8
8
  import { getParam, isiOS, isMobileDevice, isSafari } from "../../../engine/engine_utils.js";
9
9
  import { Behaviour, GameObject } from "../../Component.js";
10
10
  import { Renderer } from "../../Renderer.js"
11
+ import { SpriteRenderer } from "../../SpriteRenderer.js";
11
12
  import { WebARSessionRoot } from "../../webxr/WebARSessionRoot.js";
12
13
  import { WebXR } from "../../webxr/WebXR.js";
13
14
  import { WebXRButtonFactory } from "../../webxr/WebXRButtons.js";
@@ -294,6 +295,14 @@
294
295
  Progress.report("export-usdz", { message: "Starting export", totalSteps: 40, currentStep: 0 });
295
296
  Progress.report("export-usdz", { message: "Load progressive textures", autoStep: 5 });
296
297
  Progress.start("export-usdz-textures", "export-usdz");
298
+
299
+ // force Sprites to be created
300
+ const sprites = GameObject.getComponentsInChildren(objectToExport, SpriteRenderer);
301
+ for (const sprite of sprites) {
302
+ if (sprite && sprite.enabled && sprite.start)
303
+ sprite.start();
304
+ }
305
+
297
306
  // trigger progressive textures to be loaded:
298
307
  const renderers = GameObject.getComponentsInChildren(objectToExport, Renderer);
299
308
  const progressiveLoading = new Array<Promise<any>>();
src/engine-components/export/usdz/extensions/USDZUI.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Color, Mesh, MeshBasicMaterial, Object3D } from "three";
2
2
 
3
3
  import { GameObject } from "../../../Component.js";
4
+ import { SpriteRenderer } from "../../../SpriteRenderer.js";
4
5
  import { $shadowDomOwner, BaseUIComponent } from "../../../ui/BaseUIComponent.js";
5
6
  import { Canvas } from "../../../ui/Canvas.js";
6
7
  import { RenderMode } from "../../../ui/Canvas.js";
@@ -19,6 +20,7 @@
19
20
  // TODO would probably be better to export each object instead of the entire Canvas
20
21
  // so that we don't export them twice (once as regular hierarchy, once as part of Canvas export)
21
22
  onExportObject(object: Object3D, model: USDObject, _context: USDZExporterContext) {
23
+
22
24
  const canvas = GameObject.getComponent(object, Canvas);
23
25
 
24
26
  if (canvas && canvas.enabled && canvas.renderMode === RenderMode.WorldSpace) {