@needle-tools/engine 2.53.0-pre → 2.55.0-pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/needle-engine.d.ts +2477 -2267
  3. package/dist/needle-engine.js +425 -425
  4. package/dist/needle-engine.js.map +4 -4
  5. package/dist/needle-engine.min.js +40 -40
  6. package/dist/needle-engine.min.js.map +4 -4
  7. package/dist/needle-engine.tsbuildinfo +1 -0
  8. package/lib/engine/codegen/register_types.d.ts +1 -0
  9. package/lib/engine/codegen/register_types.js +346 -0
  10. package/lib/engine/codegen/register_types.js.map +1 -0
  11. package/lib/engine/debug/debug.d.ts +1 -0
  12. package/lib/engine/debug/debug.js +4 -0
  13. package/lib/engine/debug/debug.js.map +1 -1
  14. package/lib/engine/debug/debug_console.js +2 -1
  15. package/lib/engine/debug/debug_console.js.map +1 -1
  16. package/lib/engine/debug/debug_overlay.js +3 -1
  17. package/lib/engine/debug/debug_overlay.js.map +1 -1
  18. package/lib/engine/engine_default_parameters.d.ts +2 -2
  19. package/lib/engine/engine_element.js +4 -2
  20. package/lib/engine/engine_element.js.map +1 -1
  21. package/lib/engine/engine_element_loading.d.ts +1 -0
  22. package/lib/engine/engine_element_loading.js +17 -6
  23. package/lib/engine/engine_element_loading.js.map +1 -1
  24. package/lib/engine/engine_element_overlay.js +4 -2
  25. package/lib/engine/engine_element_overlay.js.map +1 -1
  26. package/lib/engine/engine_fileloader.d.ts +3 -0
  27. package/lib/engine/engine_fileloader.js +8 -0
  28. package/lib/engine/engine_fileloader.js.map +1 -0
  29. package/lib/engine/engine_generic_utils.d.ts +1 -0
  30. package/lib/engine/engine_generic_utils.js +14 -0
  31. package/lib/engine/engine_generic_utils.js.map +1 -0
  32. package/lib/engine/engine_input.js +4 -0
  33. package/lib/engine/engine_input.js.map +1 -1
  34. package/lib/engine/engine_lightdata.js +1 -1
  35. package/lib/engine/engine_lightdata.js.map +1 -1
  36. package/lib/engine/engine_mainloop_utils.js +8 -0
  37. package/lib/engine/engine_mainloop_utils.js.map +1 -1
  38. package/lib/engine/engine_networking_websocket.d.ts +1 -0
  39. package/lib/engine/engine_networking_websocket.js +1 -1
  40. package/lib/engine/engine_networking_websocket.js.map +1 -1
  41. package/lib/engine/engine_physics.d.ts +1 -1
  42. package/lib/engine/engine_physics.js +44 -3
  43. package/lib/engine/engine_physics.js.map +1 -1
  44. package/lib/engine/engine_physics.types.d.ts +13 -0
  45. package/lib/engine/engine_physics.types.js +7 -0
  46. package/lib/engine/engine_physics.types.js.map +1 -1
  47. package/lib/engine/engine_serialization_builtin_serializer.js +6 -3
  48. package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
  49. package/lib/engine/engine_setup.js +2 -2
  50. package/lib/engine/engine_setup.js.map +1 -1
  51. package/lib/engine/engine_time.d.ts +1 -0
  52. package/lib/engine/engine_time.js +7 -0
  53. package/lib/engine/engine_time.js.map +1 -1
  54. package/lib/engine/engine_types.d.ts +4 -1
  55. package/lib/engine/engine_types.js.map +1 -1
  56. package/lib/engine/engine_utils.d.ts +2 -1
  57. package/lib/engine/engine_utils.js +6 -0
  58. package/lib/engine/engine_utils.js.map +1 -1
  59. package/lib/engine/extensions/NEEDLE_components.d.ts +1 -1
  60. package/lib/engine/extensions/NEEDLE_progressive.d.ts +22 -0
  61. package/lib/engine/extensions/NEEDLE_progressive.js +172 -44
  62. package/lib/engine/extensions/NEEDLE_progressive.js.map +1 -1
  63. package/lib/engine-components/Collider.d.ts +2 -0
  64. package/lib/engine-components/Collider.js +4 -0
  65. package/lib/engine-components/Collider.js.map +1 -1
  66. package/lib/engine-components/GroundProjection.d.ts +2 -1
  67. package/lib/engine-components/GroundProjection.js +19 -12
  68. package/lib/engine-components/GroundProjection.js.map +1 -1
  69. package/lib/engine-components/ParticleSystem.d.ts +1 -0
  70. package/lib/engine-components/ParticleSystem.js +10 -5
  71. package/lib/engine-components/ParticleSystem.js.map +1 -1
  72. package/lib/engine-components/ParticleSystemModules.d.ts +2 -2
  73. package/lib/engine-components/ParticleSystemModules.js +65 -55
  74. package/lib/engine-components/ParticleSystemModules.js.map +1 -1
  75. package/lib/engine-components/ReflectionProbe.d.ts +1 -1
  76. package/lib/engine-components/Renderer.d.ts +2 -1
  77. package/lib/engine-components/Renderer.js +8 -8
  78. package/lib/engine-components/Renderer.js.map +1 -1
  79. package/lib/engine-components/RigidBody.js +1 -19
  80. package/lib/engine-components/RigidBody.js.map +1 -1
  81. package/lib/engine-components/SyncedTransform.js +1 -3
  82. package/lib/engine-components/SyncedTransform.js.map +1 -1
  83. package/lib/engine-components/VideoPlayer.d.ts +2 -1
  84. package/lib/engine-components/VideoPlayer.js +54 -51
  85. package/lib/engine-components/VideoPlayer.js.map +1 -1
  86. package/lib/engine-components/Volume.js +8 -1
  87. package/lib/engine-components/Volume.js.map +1 -1
  88. package/lib/engine-components/WebARSessionRoot.js +5 -0
  89. package/lib/engine-components/WebARSessionRoot.js.map +1 -1
  90. package/lib/engine-components/WebXR.d.ts +2 -2
  91. package/lib/engine-components/WebXR.js +13 -13
  92. package/lib/engine-components/WebXR.js.map +1 -1
  93. package/lib/engine-components/WebXRAvatar.d.ts +1 -1
  94. package/lib/engine-components/WebXRController.js +1 -2
  95. package/lib/engine-components/WebXRController.js.map +1 -1
  96. package/lib/engine-components/codegen/components.d.ts +99 -99
  97. package/lib/engine-components/codegen/components.js +99 -99
  98. package/lib/engine-components/codegen/components.js.map +1 -1
  99. package/lib/engine-components/export/usdz/USDZExporter.d.ts +1 -0
  100. package/lib/engine-components/export/usdz/USDZExporter.js +17 -1
  101. package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
  102. package/lib/engine-components/ui/Button.js +30 -0
  103. package/lib/engine-components/ui/Button.js.map +1 -1
  104. package/lib/engine-components/ui/InputField.d.ts +2 -0
  105. package/lib/engine-components/ui/InputField.js +23 -1
  106. package/lib/engine-components/ui/InputField.js.map +1 -1
  107. package/lib/engine-components/ui/Utils.d.ts +2 -0
  108. package/lib/engine-components/ui/Utils.js +10 -9
  109. package/lib/engine-components/ui/Utils.js.map +1 -1
  110. package/lib/engine-components-experimental/Presentation.d.ts +6 -0
  111. package/lib/engine-components-experimental/Presentation.js +11 -0
  112. package/lib/engine-components-experimental/Presentation.js.map +1 -0
  113. package/lib/engine-components-experimental/annotation/LineDrawer.d.ts +18 -0
  114. package/lib/engine-components-experimental/annotation/LineDrawer.js +175 -0
  115. package/lib/engine-components-experimental/annotation/LineDrawer.js.map +1 -0
  116. package/lib/engine-components-experimental/annotation/LinesManager.d.ts +54 -0
  117. package/lib/engine-components-experimental/annotation/LinesManager.js +155 -0
  118. package/lib/engine-components-experimental/annotation/LinesManager.js.map +1 -0
  119. package/lib/engine-components-experimental/networking/PlayerSync.d.ts +26 -0
  120. package/lib/engine-components-experimental/networking/PlayerSync.js +121 -0
  121. package/lib/engine-components-experimental/networking/PlayerSync.js.map +1 -0
  122. package/lib/engine-schemes/vec2.d.ts +10 -0
  123. package/lib/engine-schemes/vec2.js +26 -0
  124. package/lib/engine-schemes/vec2.js.map +1 -0
  125. package/lib/include/three/ARButton.d.ts +3 -0
  126. package/lib/include/three/ARButton.js +158 -0
  127. package/lib/include/three/ARButton.js.map +1 -0
  128. package/lib/include/three/EXT_mesh_gpu_instancing_exporter.d.ts +6 -0
  129. package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js +46 -0
  130. package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js.map +1 -0
  131. package/lib/include/three/VRButton.d.ts +5 -0
  132. package/lib/include/three/VRButton.js +122 -0
  133. package/lib/include/three/VRButton.js.map +1 -0
  134. package/lib/tsconfig.tsbuildinfo +1 -0
  135. package/package.json +1 -1
  136. package/src/engine/codegen/register_types.js +214 -214
  137. package/src/engine/debug/debug.ts +5 -0
  138. package/src/engine/debug/debug_console.ts +3 -2
  139. package/src/engine/debug/debug_overlay.ts +3 -1
  140. package/src/engine/engine_element.ts +4 -2
  141. package/src/engine/engine_element_loading.ts +13 -6
  142. package/src/engine/engine_element_overlay.ts +4 -2
  143. package/src/engine/engine_input.ts +4 -0
  144. package/src/engine/engine_lightdata.ts +1 -1
  145. package/src/engine/engine_mainloop_utils.ts +6 -0
  146. package/src/engine/engine_networking_websocket.ts +3 -1
  147. package/src/engine/engine_physics.ts +47 -5
  148. package/src/engine/engine_physics.types.ts +17 -0
  149. package/src/engine/engine_serialization_builtin_serializer.ts +8 -5
  150. package/src/engine/engine_setup.ts +2 -2
  151. package/src/engine/engine_time.ts +7 -1
  152. package/src/engine/engine_types.ts +5 -2
  153. package/src/engine/engine_utils.ts +7 -1
  154. package/src/engine/extensions/NEEDLE_progressive.ts +185 -43
  155. package/src/engine-components/Collider.ts +3 -0
  156. package/src/engine-components/GroundProjection.ts +18 -12
  157. package/src/engine-components/ParticleSystem.ts +10 -5
  158. package/src/engine-components/ParticleSystemModules.ts +69 -59
  159. package/src/engine-components/Renderer.ts +11 -9
  160. package/src/engine-components/RigidBody.ts +1 -20
  161. package/src/engine-components/SyncedTransform.ts +1 -3
  162. package/src/engine-components/VideoPlayer.ts +55 -51
  163. package/src/engine-components/Volume.ts +8 -1
  164. package/src/engine-components/WebARSessionRoot.ts +5 -0
  165. package/src/engine-components/WebXR.ts +17 -15
  166. package/src/engine-components/WebXRController.ts +1 -2
  167. package/src/engine-components/codegen/components.ts +99 -99
  168. package/src/engine-components/export/usdz/USDZExporter.ts +19 -2
  169. package/src/engine-components/ui/Button.ts +8 -8
  170. package/src/engine-components/ui/InputField.ts +25 -2
  171. package/src/engine-components/ui/Utils.ts +12 -11
  172. package/src/engine-components-experimental/annotation/LineDrawer.ts +10 -7
  173. package/src/engine-components-experimental/annotation/LinesManager.ts +6 -6
  174. package/src/engine-components-experimental/networking/PlayerSync.ts +1 -1
  175. package/lib/engine/engine_caching.d.ts +0 -0
  176. package/lib/engine/engine_caching.js +0 -2
  177. package/lib/engine/engine_caching.js.map +0 -1
  178. package/lib/engine/tests/simulate_avatars.d.ts +0 -0
  179. package/lib/engine/tests/simulate_avatars.js +0 -3
  180. package/lib/engine/tests/simulate_avatars.js.map +0 -1
  181. package/lib/engine-components/NavMesh.d.ts +0 -0
  182. package/lib/engine-components/NavMesh.js +0 -101
  183. package/lib/engine-components/NavMesh.js.map +0 -1
  184. package/lib/engine-components/ParticleSystemBehaviours.d.ts +0 -0
  185. package/lib/engine-components/ParticleSystemBehaviours.js +0 -2
  186. package/lib/engine-components/ParticleSystemBehaviours.js.map +0 -1
  187. package/lib/engine-components/SpringJoint.d.ts +0 -0
  188. package/lib/engine-components/SpringJoint.js +0 -43
  189. package/lib/engine-components/SpringJoint.js.map +0 -1
  190. package/lib/engine-components/ui/CanvasScaler.d.ts +0 -0
  191. package/lib/engine-components/ui/CanvasScaler.js +0 -17
  192. package/lib/engine-components/ui/CanvasScaler.js.map +0 -1
  193. package/src/engine/dist/engine_three_utils.js +0 -279
  194. package/src/engine/engine_caching.ts +0 -0
  195. package/src/engine/tests/simulate_avatars.ts +0 -2
  196. package/src/engine-components/NavMesh.ts +0 -117
  197. package/src/engine-components/ParticleSystemBehaviours.ts +0 -0
  198. package/src/engine-components/SpringJoint.ts +0 -45
  199. package/src/engine-components/ui/CanvasScaler.ts +0 -21
@@ -4,6 +4,7 @@ import { LoadingProgressArgs } from "./engine_setup";
4
4
  import { getParam } from "./engine_utils";
5
5
 
6
6
  const debug = getParam("debugloadingbar");
7
+ const debugRendering = getParam("debugloadingbarrendering");
7
8
 
8
9
  export class LoadingElementOptions {
9
10
  className?: string;
@@ -43,12 +44,14 @@ export function calculateProgress01(progress: LoadingProgressArgs) {
43
44
 
44
45
  export class EngineLoadingView implements ILoadingViewHandler {
45
46
 
47
+ static LoadingContainerClassName = "loading";
48
+
46
49
  // the raw progress
47
50
  loadingProgress: number = 0;
48
51
 
49
52
  private container: HTMLElement;
50
53
  private _progress: number = 0;
51
- private _allowCustomLoadingElement: boolean = false;
54
+ private _allowCustomLoadingElement: boolean = true;
52
55
  private _loadingElement?: HTMLElement;
53
56
  private _loadingTextContainer: HTMLElement | null = null;
54
57
  private _loadingBar: HTMLElement | null = null;
@@ -61,20 +64,21 @@ export class EngineLoadingView implements ILoadingViewHandler {
61
64
  }
62
65
 
63
66
  onLoadingBegin(message?: string) {
67
+ if(debug) console.log("Begin Loading")
64
68
  if (!this._loadingElement) {
65
69
  for (let i = 0; i < this.container.children.length; i++) {
66
70
  const el = this.container.children[i] as HTMLElement;
67
- if (el.classList.contains("loading")) {
71
+ if (el.classList.contains(EngineLoadingView.LoadingContainerClassName)) {
68
72
  if (!this._allowCustomLoadingElement) {
69
- console.warn("Custom loading container is not allowed")
73
+ if(debug) console.warn("Remove custom loading container")
70
74
  this.container.removeChild(el);
71
75
  continue;
72
76
  }
73
77
  this._loadingElement = this.createLoadingElement(el);
74
- return;
75
78
  }
76
79
  }
77
- this._loadingElement = this.createLoadingElement();
80
+ if (!this._loadingElement)
81
+ this._loadingElement = this.createLoadingElement();
78
82
  }
79
83
  this._progress = 0;
80
84
  this.loadingProgress = 0;
@@ -121,9 +125,11 @@ export class EngineLoadingView implements ILoadingViewHandler {
121
125
  if (this._progressLoop) return;
122
126
  let dt = 1 / 12;
123
127
  const max = 1 - .05;
128
+ if(debugRendering) dt = 1 / 500;
124
129
  this._progressLoop = setInterval(() => {
125
130
  if (this.loadingProgress >= 1 && this._progress >= max) {
126
131
  if (this._loadingElement) {
132
+ if(debug) console.log("Hiding loading element");
127
133
  this._loadingElement.style.display = "none";
128
134
  this._loadingElement.remove();
129
135
  }
@@ -148,6 +154,7 @@ export class EngineLoadingView implements ILoadingViewHandler {
148
154
  }
149
155
 
150
156
  private createLoadingElement(existing?: HTMLElement): HTMLElement {
157
+ if(debug && !existing) console.log("Creating loading element");
151
158
  this._loadingElement = existing || document.createElement("div");
152
159
  if (!existing) {
153
160
  this._loadingElement.style.position = "fixed";
@@ -165,7 +172,7 @@ export class EngineLoadingView implements ILoadingViewHandler {
165
172
  this._loadingElement.style.color = "white";
166
173
  }
167
174
 
168
- const className = this._loadingElementOptions?.className ?? "loading";
175
+ const className = this._loadingElementOptions?.className ?? EngineLoadingView.LoadingContainerClassName;
169
176
  this._loadingElement.classList.add(className);
170
177
  if (this._loadingElementOptions?.additionalClasses) {
171
178
  for (const c of this._loadingElementOptions.additionalClasses) {
@@ -1,6 +1,7 @@
1
1
  import { Context } from "./engine_setup";
2
- import { isMozillaXR } from "./engine_utils";
2
+ import { getParam, isMozillaXR } from "./engine_utils";
3
3
 
4
+ const debug = getParam("debugaroverlay");
4
5
  export const arContainerClassName = "ar";
5
6
  export const quitARClassName = "quit-ar";
6
7
 
@@ -110,7 +111,8 @@ export class AROverlayHandler {
110
111
  if (arElements && arElements.length > 0)
111
112
  return arElements[0] as HTMLElement;
112
113
 
113
- console.log("No overlay container found in document - generating new ony");
114
+ if (debug)
115
+ console.log("No overlay container found in document - generating new ony");
114
116
  const el = document.createElement("div");
115
117
  el.classList.add(arContainerClassName);
116
118
  el.style.position = "absolute";
@@ -384,6 +384,8 @@ export class Input extends EventTarget {
384
384
  for (let i = 0; i < evt.changedTouches.length; i++) {
385
385
  const touch = evt.changedTouches[i];
386
386
  const id = this.getPointerIndex(touch.identifier)
387
+ if (debug)
388
+ showBalloonMessage(`touch start #${id}, identifier:${touch.identifier}`);
387
389
  const args: PointerEventArgs = { button: id, clientX: touch.clientX, clientY: touch.clientY, pointerType: PointerType.Touch, source: evt };
388
390
  this.onDown(args);
389
391
  }
@@ -404,6 +406,8 @@ export class Input extends EventTarget {
404
406
  for (let i = 0; i < evt.changedTouches.length; i++) {
405
407
  const touch = evt.changedTouches[i];
406
408
  const id = this.getPointerIndex(touch.identifier)
409
+ if (debug)
410
+ showBalloonMessage(`touch up #${id}, identifier:${touch.identifier}`);
407
411
  const args: PointerEventArgs = { button: id, clientX: touch.clientX, clientY: touch.clientY, pointerType: PointerType.Touch, source: evt };
408
412
  this.onUp(args);
409
413
  }
@@ -33,7 +33,7 @@ export class LightDataRegistry implements ILightDataRegistry {
33
33
  }
34
34
 
35
35
  registerTexture(sourceId: SourceIdentifier, type: LightmapType, tex: Texture, index: number) {
36
- if (debugLightmap) console.log("Registering lightmap", sourceId, LightmapType[type], tex);
36
+ if (debugLightmap) console.log("Registering ", LightmapType[type], tex, sourceId);
37
37
  if (!this._lightmaps.has(sourceId))
38
38
  this._lightmaps.set(sourceId, new Map());
39
39
  const map = this._lightmaps.get(sourceId);
@@ -68,6 +68,12 @@ export function processNewScripts(context: Context) {
68
68
  new_scripts_buffer.splice(i, 1);
69
69
  i--; continue;
70
70
  }
71
+ if (script.registering) {
72
+ try {
73
+ script.registering();
74
+ }
75
+ catch (err) { console.error(err); }
76
+ }
71
77
  // console.log(script, script.gameObject)
72
78
  // TODO: we should not call awake on components with inactive gameobjects
73
79
  if (script.__internalAwake !== undefined) {
@@ -1 +1,3 @@
1
- // TODO: move websocket specific networking code here!
1
+ // TODO: move websocket specific networking code here!
2
+
3
+ export {}
@@ -15,9 +15,10 @@ import {
15
15
  import { InstancingUtil } from './engine_instancing';
16
16
  import { foreachComponent } from './engine_gameobject';
17
17
 
18
- import RAPIER, { ActiveEvents, Collider, ColliderDesc, EventQueue, JointData, RigidBody, RigidBodyType, World } from '@dimforge/rapier3d-compat';
19
- import { CollisionDetectionMode } from '../engine/engine_physics.types';
18
+ import RAPIER, { ActiveEvents, CoefficientCombineRule, Collider, ColliderDesc, EventQueue, JointData, RigidBody, RigidBodyType, World } from '@dimforge/rapier3d-compat';
19
+ import { CollisionDetectionMode, PhysicsMaterialCombine } from '../engine/engine_physics.types';
20
20
  import { Gizmos } from './engine_gizmos';
21
+ import { Mathf } from './engine_math';
21
22
  export type Rapier = typeof RAPIER;
22
23
 
23
24
 
@@ -354,7 +355,7 @@ export class Physics {
354
355
  this.createCollider(collider, desc, center);
355
356
  }
356
357
 
357
- addMeshCollider(collider: ICollider, mesh: Mesh, convex: boolean, scale:Vector3) {
358
+ addMeshCollider(collider: ICollider, mesh: Mesh, convex: boolean, scale: Vector3) {
358
359
  const geo = mesh.geometry;
359
360
  if (!geo) {
360
361
  if (debugPhysics) console.warn("Missing mesh geometry", mesh.name);
@@ -405,7 +406,7 @@ export class Physics {
405
406
  matrix.decompose(this._tempPosition, this._tempQuaternion, this._tempScale);
406
407
  getWorldScale(collider.gameObject, this._tempScale);
407
408
  if (center) {
408
- center.multiply( this._tempScale);
409
+ center.multiply(this._tempScale);
409
410
  this._tempPosition.x -= center.x;
410
411
  this._tempPosition.y += center.y;
411
412
  this._tempPosition.z += center.z;
@@ -414,6 +415,42 @@ export class Physics {
414
415
  desc.setRotation(this._tempQuaternion);
415
416
  desc.setSensor(collider.isTrigger);
416
417
 
418
+ // TODO: we might want to update this if the material changes
419
+ const physicsMaterial = collider.sharedMaterial;
420
+ if (physicsMaterial) {
421
+ CoefficientCombineRule
422
+ desc.setRestitution(physicsMaterial.bounciness);
423
+ switch (physicsMaterial.bounceCombine) {
424
+ case PhysicsMaterialCombine.Average:
425
+ desc.setRestitutionCombineRule(CoefficientCombineRule.Average);
426
+ break;
427
+ case PhysicsMaterialCombine.Maximum:
428
+ desc.setRestitutionCombineRule(CoefficientCombineRule.Max);
429
+ break;
430
+ case PhysicsMaterialCombine.Minimum:
431
+ desc.setRestitutionCombineRule(CoefficientCombineRule.Min);
432
+ break;
433
+ case PhysicsMaterialCombine.Multiply:
434
+ desc.setRestitutionCombineRule(CoefficientCombineRule.Multiply);
435
+ break;
436
+ }
437
+ desc.setFriction(physicsMaterial.dynamicFriction);
438
+ switch (physicsMaterial.frictionCombine) {
439
+ case PhysicsMaterialCombine.Average:
440
+ desc.setFrictionCombineRule(CoefficientCombineRule.Average);
441
+ break;
442
+ case PhysicsMaterialCombine.Maximum:
443
+ desc.setFrictionCombineRule(CoefficientCombineRule.Max);
444
+ break;
445
+ case PhysicsMaterialCombine.Minimum:
446
+ desc.setFrictionCombineRule(CoefficientCombineRule.Min);
447
+ break;
448
+ case PhysicsMaterialCombine.Multiply:
449
+ desc.setFrictionCombineRule(CoefficientCombineRule.Multiply);
450
+ break;
451
+ }
452
+ }
453
+
417
454
  // if we want to use explicit mass properties, we need to set the collider density to 0
418
455
  // otherwise rapier will compute the mass properties based on the collider shape and density
419
456
  // https://rapier.rs/docs/user_guides/javascript/rigid_bodies#mass-properties
@@ -583,12 +620,17 @@ export class Physics {
583
620
  // private _lastStepTime: number | undefined = 0;
584
621
  private lines?: LineSegments;
585
622
 
586
- public step(_deltaTime?: number) {
623
+ public step(dt?: number) {
587
624
  if (!this.world) return;
588
625
  this._isUpdatingPhysicsWorld = true;
589
626
  if (!this.eventQueue) {
590
627
  this.eventQueue = new EventQueue(false);
591
628
  }
629
+ if (dt) {
630
+ // if we make to sudden changes to the timestep the physics can get unstable
631
+ // https://rapier.rs/docs/user_guides/javascript/integration_parameters/#dt
632
+ this.world.timestep = Mathf.lerp(this.world.timestep, dt, 0.8);
633
+ }
592
634
  this.world.step(this.eventQueue);
593
635
  this._isUpdatingPhysicsWorld = false;
594
636
  this.updateDebugRendering(this.world);
@@ -1,5 +1,22 @@
1
1
 
2
2
 
3
+
4
+ export enum PhysicsMaterialCombine
5
+ {
6
+ Average = 0,
7
+ Multiply = 1,
8
+ Minimum = 2,
9
+ Maximum = 3,
10
+ }
11
+
12
+ export type PhysicsMaterial = {
13
+ bounceCombine: PhysicsMaterialCombine;
14
+ bounciness: number;
15
+ frictionCombine: PhysicsMaterialCombine;
16
+ dynamicFriction: number;
17
+ staticFriction: number;
18
+ }
19
+
3
20
  export enum CollisionDetectionMode {
4
21
  Discrete = 0,
5
22
  Continuous = 1,
@@ -6,6 +6,7 @@ import { debugExtension } from "./engine_default_parameters";
6
6
  import { CallInfo, EventList } from "../engine-components/EventList";
7
7
  import { Color, Object3D, Texture, WebGLRenderTarget } from "three";
8
8
  import { RenderTexture } from "./engine_texture";
9
+ import { isDevEnvironment } from "../engine/debug/debug";
9
10
 
10
11
  // export class SourcePath {
11
12
  // src?:string
@@ -98,7 +99,8 @@ class ObjectSerializer extends TypeSerializer {
98
99
  res = GameObject.findByGuid(data.guid, context.context.scene);
99
100
  }
100
101
  if (!res) {
101
- console.warn("Could not resolve object reference", context.path, data, context.target, context.context.scene);
102
+ if (isDevEnvironment() || debugExtension)
103
+ console.warn("Could not resolve object reference", context.path, data, context.target, context.context.scene);
102
104
  data["could_not_resolve"] = true;
103
105
  }
104
106
  else if (debugExtension)
@@ -141,9 +143,10 @@ class ComponentSerializer extends TypeSerializer {
141
143
  // if not found within the gltf use the provided context scene
142
144
  // to find references outside
143
145
  res = this.findObjectForGuid(data.guid, context.context?.scene);
144
- if(res) return res;
146
+ if (res) return res;
145
147
  }
146
- console.warn("Could not resolve component reference", context.path, data, context.target);
148
+ if (isDevEnvironment() || debugExtension)
149
+ console.warn("Could not resolve component reference", context.path, data, context.target);
147
150
  data["could_not_resolve"] = true;
148
151
  return undefined;
149
152
  }
@@ -227,7 +230,7 @@ class EventListSerializer extends TypeSerializer {
227
230
  call.method = call.method.substring(4);
228
231
  if (target[call.method] !== undefined) foundMethod = true;
229
232
  }
230
- if (!foundMethod)
233
+ if (!foundMethod && (isDevEnvironment() || debugExtension))
231
234
  printWarningMethodNotFound();
232
235
  }
233
236
  }
@@ -302,7 +305,7 @@ export class RenderTextureSerializer extends TypeSerializer {
302
305
  }
303
306
 
304
307
  onDeserialize(data: any, context: SerializationContext) {
305
- if(data instanceof Texture && context.type === RenderTexture){
308
+ if (data instanceof Texture && context.type === RenderTexture) {
306
309
  const tex = data as Texture;
307
310
  const rt = new RenderTexture(tex.image.width, tex.image.height);
308
311
  rt.texture = tex;
@@ -315,8 +315,8 @@ export class Context {
315
315
  this.renderer.domElement.style.width = "100%";
316
316
  this.renderer.domElement.style.height = "100%";
317
317
  if (this.composer) {
318
- this.composer.setSize(width, height);
319
- this.composer.setPixelRatio(window.devicePixelRatio);
318
+ this.composer.setSize?.call(this.composer, width, height);
319
+ this.composer.setPixelRatio?.call(this.composer, window.devicePixelRatio);
320
320
  }
321
321
  }
322
322
  }
@@ -1,10 +1,15 @@
1
-
2
1
  import { Clock } from 'three'
2
+ import { getParam } from './engine_utils';
3
+
4
+ const debug = getParam("debugtime");
5
+ let timeScale = 1;
6
+ if(typeof debug === "number") timeScale = debug;
3
7
 
4
8
  export class Time {
5
9
 
6
10
  deltaTime = 0;
7
11
  time = 0;
12
+ timeScale = 1;
8
13
 
9
14
  /** same as frameCount */
10
15
  frame = 0;
@@ -27,6 +32,7 @@ export class Time {
27
32
  this.deltaTime = this.clock.getDelta();
28
33
  // clamp delta time because if tab is not active clock.getDelta can get pretty big
29
34
  this.deltaTime = Math.min(.1, this.deltaTime);
35
+ this.deltaTime *= timeScale * this.timeScale;
30
36
  if(this.deltaTime <= 0) this.deltaTime = 0.000000000001;
31
37
  this.frame += 1;
32
38
  this.time += this.deltaTime;
@@ -1,6 +1,6 @@
1
1
  import { Camera, Color, Material, Object3D, Vector3, Quaternion, Ray } from "three";
2
2
  import { RGBAColor } from "../engine-components/js-extensions/RGBAColor";
3
- import { CollisionDetectionMode, RigidbodyConstraints } from "./engine_physics.types";
3
+ import { CollisionDetectionMode, PhysicsMaterial, RigidbodyConstraints } from "./engine_physics.types";
4
4
  import { getWorldPosition } from "./engine_three_utils";
5
5
  import { CircularBuffer } from "./engine_utils";
6
6
 
@@ -67,6 +67,8 @@ export interface IComponent {
67
67
  __internalDestroy();
68
68
  resolveGuids?(guidsMap: GuidsMap): void;
69
69
 
70
+ /** experimental, called when the script is registered for the first time, this is called even if the component is not enabled. */
71
+ registering?();
70
72
  awake();
71
73
  onEnable();
72
74
  onDisable();
@@ -78,7 +80,7 @@ export interface IComponent {
78
80
  /** called when this.context.isPaused changes or when rendering loop changes due to changing DOM element visibility
79
81
  * e.g. when the DOM element becomes hidden or out ot view
80
82
  */
81
- onPausedChanged?(isPaused:boolean, wasPaused:boolean);
83
+ onPausedChanged?(isPaused: boolean, wasPaused: boolean);
82
84
 
83
85
  start?(): void;
84
86
  earlyUpdate?(): void;
@@ -138,6 +140,7 @@ export declare interface ICollider extends IComponent {
138
140
  get isCollider();
139
141
  attachedRigidbody: IRigidbody | null;
140
142
  isTrigger: boolean;
143
+ sharedMaterial?: PhysicsMaterial;
141
144
  }
142
145
 
143
146
  export declare interface IRigidbody extends IComponent {
@@ -52,7 +52,7 @@ export function getUrlParams() {
52
52
  return new URLSearchParams(window.location.search);
53
53
  }
54
54
 
55
- export function getParam(paramName: string): string | boolean {
55
+ export function getParam(paramName: string): string | boolean | number {
56
56
 
57
57
  if (saveParams && !requestedParams.includes(paramName))
58
58
  requestedParams.push(paramName);
@@ -60,6 +60,8 @@ export function getParam(paramName: string): string | boolean {
60
60
  if (urlParams.has(paramName)) {
61
61
  const val = urlParams.get(paramName);
62
62
  if (val) {
63
+ const num = Number(val);
64
+ if (!isNaN(num)) return num;
63
65
  return val;
64
66
  }
65
67
  else return true;
@@ -383,4 +385,8 @@ export function isiOS() {
383
385
 
384
386
  export function isSafari() {
385
387
  return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
388
+ }
389
+
390
+ export function isQuest() {
391
+ return navigator.userAgent.includes("OculusBrowser");
386
392
  }