Needle Engine

Changes between version 3.37.1-alpha and 3.37.2-alpha
Files changed (6) hide show
  1. src/engine/webcomponents/api.ts +1 -0
  2. src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +3 -4
  3. src/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.ts +8 -6
  4. src/engine/engine_mainloop_utils.ts +7 -3
  5. src/engine-components/export/usdz/extensions/behavior/PhysicsExtension.ts +1 -5
  6. src/engine-components/webxr/WebXR.ts +2 -2
src/engine/webcomponents/api.ts CHANGED
@@ -1,4 +1,5 @@
1
1
 
2
2
 
3
+ export { ButtonsFactory } from "./buttons.js"
3
4
  export * from "./icons.js"
4
5
  export { type NeedleMenuPostMessageModel } from "./needle menu/needle-menu.js"
src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Group,Material, Mesh, Object3D, Quaternion, Vector3 } from "three";
1
+ import { Material, Mesh, Object3D, Quaternion, Vector3 } from "three";
2
2
 
3
3
  import { isDevEnvironment, showBalloonWarning } from "../../../../../engine/debug/index.js";
4
4
  import { serializable } from "../../../../../engine/engine_serialization_decorator.js";
@@ -10,14 +10,13 @@
10
10
  import { Animator } from "../../../../Animator.js";
11
11
  import { AudioSource } from "../../../../AudioSource.js";
12
12
  import { Behaviour, GameObject } from "../../../../Component.js";
13
- import { Renderer } from "../../../../Renderer.js";
14
13
  import type { IPointerClickHandler, PointerEventData } from "../../../../ui/PointerEvents.js";
15
14
  import { ObjectRaycaster,Raycaster } from "../../../../ui/Raycaster.js";
16
15
  import { USDDocument, USDObject, USDZExporterContext } from "../../ThreeUSDZExporter.js";
17
16
  import { AnimationExtension, RegisteredAnimationInfo, type UsdzAnimation } from "../Animation.js";
18
17
  import { AudioExtension } from "./AudioExtension.js";
19
18
  import type { BehaviorExtension, UsdzBehaviour } from "./Behaviour.js";
20
- import { ActionBuilder, ActionModel, AuralMode, BehaviorModel, type IBehaviorElement, MotionType, MultiplePerformOperation,PlayAction, Space, TriggerBuilder } from "./BehavioursBuilder.js";
19
+ import { ActionBuilder, ActionModel, BehaviorModel, EmphasizeActionMotionType,type IBehaviorElement, TriggerBuilder } from "./BehavioursBuilder.js";
21
20
 
22
21
  const debug = getParam("debugusdzbehaviours");
23
22
 
@@ -583,7 +582,7 @@
583
582
  duration: number = 0.5;
584
583
 
585
584
  @serializable()
586
- motionType: MotionType = "bounce";
585
+ motionType: EmphasizeActionMotionType = "bounce";
587
586
 
588
587
  beforeCreateDocument() { }
589
588
 
src/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.ts CHANGED
@@ -234,9 +234,12 @@
234
234
  }
235
235
 
236
236
  /** @internal */
237
- export type MotionType = "pop" | "blink" | "bounce" | "flip" | "float" | "jiggle" | "pulse" | "spin";
237
+ export type EmphasizeActionMotionType = "pop" | "blink" | "bounce" | "flip" | "float" | "jiggle" | "pulse" | "spin";
238
238
 
239
239
  /** @internal */
240
+ export type VisibilityActionMotionType = "none" | "pop" | "scaleUp" | "scaleDown" | "moveLeft" | "moveRight" | "moveAbove" | "moveBelow" | "moveForward" | "moveBack";
241
+
242
+ /** @internal */
240
243
  export type MotionStyle = "basic";
241
244
 
242
245
  /** @internal */
@@ -257,7 +260,7 @@
257
260
  tokenId?: string;
258
261
  affectedObjects?: string | Target;
259
262
  easeType?: EaseType;;
260
- motionType?: MotionType;
263
+ motionType: EmphasizeActionMotionType | VisibilityActionMotionType = "none";
261
264
  duration?: number;
262
265
  moveDistance?: number;
263
266
  style?: MotionStyle;
@@ -306,8 +309,7 @@
306
309
  writer.appendLine(`token easeType = "${this.easeType}"`);
307
310
  if (this.tokenId)
308
311
  writer.appendLine(`token info:id = "${this.tokenId}"`);
309
- if (this.motionType)
310
- writer.appendLine(`token motionType = "${this.motionType}"`);
312
+ writer.appendLine(`token motionType = "${this.motionType}"`);
311
313
  if (typeof this.moveDistance === "number")
312
314
  writer.appendLine(`double moveDistance = ${this.moveDistance} `);
313
315
  if (this.style)
@@ -405,7 +407,7 @@
405
407
  act.duration = duration;
406
408
 
407
409
  act.style = "basic";
408
- act.motionType = undefined;
410
+ act.motionType = "none"; // only VisibilityActionMotionType allowed
409
411
  act.moveDistance = 0;
410
412
  act.easeType = "none";
411
413
  return act;
@@ -464,7 +466,7 @@
464
466
  return act;
465
467
  }
466
468
 
467
- static emphasize(targets: Target, duration: number, motionType: MotionType = "bounce", moveDistance: number = 1, style: MotionStyle = "basic") {
469
+ static emphasize(targets: Target, duration: number, motionType: EmphasizeActionMotionType = "bounce", moveDistance: number = 1, style: MotionStyle = "basic") {
468
470
  const act = new ActionModel(targets);
469
471
  act.tokenId = "Emphasize";
470
472
  act.duration = duration;
src/engine/engine_mainloop_utils.ts CHANGED
@@ -22,7 +22,11 @@
22
22
  return new_scripts_buffer.length > 0;
23
23
  }
24
24
 
25
- /** @internal */
25
+ /**
26
+ * This method is called by the engine to process new scripts that were added to the scene.
27
+ * It will call the registering method on the script, then the awake method and finally the onEnable method.
28
+ * @internal
29
+ */
26
30
  export function processNewScripts(context: IContext) {
27
31
  if (context.new_scripts.length <= 0) return;
28
32
  if (debug)
@@ -59,7 +63,7 @@
59
63
  }
60
64
  if (script.destroyed) continue;
61
65
  if (!script.gameObject) {
62
- console.error("MISSING GAMEOBJECT - will ignore", script);
66
+ console.warn("Component can not be initialized: no GameObject assigned.\nDid you add and remove a component in the same frame?");
63
67
  new_scripts_buffer.splice(i, 1);
64
68
  i--;
65
69
  continue;
@@ -95,7 +99,7 @@
95
99
  // TODO: we should not call awake on components with inactive gameobjects
96
100
  if (script.__internalAwake !== undefined) {
97
101
  if (!script.gameObject) {
98
- console.error("MISSING GAMEOBJECT", script, script.gameObject);
102
+ console.error("Calling awake for a component without a GameObject", script, script.gameObject);
99
103
  }
100
104
  updateActiveInHierarchyWithoutEventCall(script.gameObject);
101
105
  if (script.activeAndEnabled)
src/engine-components/export/usdz/extensions/behavior/PhysicsExtension.ts CHANGED
@@ -26,7 +26,7 @@
26
26
  // see https://developer.apple.com/documentation/realitykit/collisioncomponent#overview
27
27
  let temporaryRigidbody: Rigidbody | undefined = undefined;
28
28
  if (colliderSource && !rigidBody) {
29
- rigidBody = GameObject.addComponent(object, Rigidbody);
29
+ rigidBody = new Rigidbody();
30
30
  rigidBody.isKinematic = true;
31
31
  temporaryRigidbody = rigidBody;
32
32
  }
@@ -70,10 +70,6 @@
70
70
  }
71
71
  writer.closeBlock( "}" );
72
72
  });
73
-
74
- // we can remove the temporary component again here
75
- if (temporaryRigidbody)
76
- GameObject.removeComponent(temporaryRigidbody);
77
73
  }
78
74
 
79
75
  if (colliderSource) {
src/engine-components/webxr/WebXR.ts CHANGED
@@ -223,7 +223,7 @@
223
223
  setDefaultMovementEnabled(enabled: boolean): XRControllerMovement | null {
224
224
  let movement = this.gameObject.getComponent(XRControllerMovement)
225
225
  if (!movement && enabled) {
226
- movement = this.gameObject.addNewComponent(XRControllerMovement)!;
226
+ movement = this.gameObject.addComponent(XRControllerMovement)!;
227
227
  this._createdComponentsInSession.push(movement);
228
228
  }
229
229
  if (movement) movement.enabled = enabled;
@@ -233,7 +233,7 @@
233
233
  setDefaultControllerRenderingEnabled(enabled: boolean): XRControllerModel | null {
234
234
  let models = this.gameObject.getComponent(XRControllerModel);
235
235
  if (!models && enabled) {
236
- models = this.gameObject.addNewComponent(XRControllerModel)!;
236
+ models = this.gameObject.addComponent(XRControllerModel)!;
237
237
  this._createdComponentsInSession.push(models);
238
238
  models.createControllerModel = this.showControllerModels;
239
239
  models.createHandModel == this.showHandModels;