@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.
- package/CHANGELOG.md +37 -0
- package/dist/needle-engine.d.ts +2477 -2267
- package/dist/needle-engine.js +425 -425
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +40 -40
- package/dist/needle-engine.min.js.map +4 -4
- package/dist/needle-engine.tsbuildinfo +1 -0
- package/lib/engine/codegen/register_types.d.ts +1 -0
- package/lib/engine/codegen/register_types.js +346 -0
- package/lib/engine/codegen/register_types.js.map +1 -0
- package/lib/engine/debug/debug.d.ts +1 -0
- package/lib/engine/debug/debug.js +4 -0
- package/lib/engine/debug/debug.js.map +1 -1
- package/lib/engine/debug/debug_console.js +2 -1
- package/lib/engine/debug/debug_console.js.map +1 -1
- package/lib/engine/debug/debug_overlay.js +3 -1
- package/lib/engine/debug/debug_overlay.js.map +1 -1
- package/lib/engine/engine_default_parameters.d.ts +2 -2
- package/lib/engine/engine_element.js +4 -2
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_element_loading.d.ts +1 -0
- package/lib/engine/engine_element_loading.js +17 -6
- package/lib/engine/engine_element_loading.js.map +1 -1
- package/lib/engine/engine_element_overlay.js +4 -2
- package/lib/engine/engine_element_overlay.js.map +1 -1
- package/lib/engine/engine_fileloader.d.ts +3 -0
- package/lib/engine/engine_fileloader.js +8 -0
- package/lib/engine/engine_fileloader.js.map +1 -0
- package/lib/engine/engine_generic_utils.d.ts +1 -0
- package/lib/engine/engine_generic_utils.js +14 -0
- package/lib/engine/engine_generic_utils.js.map +1 -0
- package/lib/engine/engine_input.js +4 -0
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_lightdata.js +1 -1
- package/lib/engine/engine_lightdata.js.map +1 -1
- package/lib/engine/engine_mainloop_utils.js +8 -0
- package/lib/engine/engine_mainloop_utils.js.map +1 -1
- package/lib/engine/engine_networking_websocket.d.ts +1 -0
- package/lib/engine/engine_networking_websocket.js +1 -1
- package/lib/engine/engine_networking_websocket.js.map +1 -1
- package/lib/engine/engine_physics.d.ts +1 -1
- package/lib/engine/engine_physics.js +44 -3
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_physics.types.d.ts +13 -0
- package/lib/engine/engine_physics.types.js +7 -0
- package/lib/engine/engine_physics.types.js.map +1 -1
- package/lib/engine/engine_serialization_builtin_serializer.js +6 -3
- package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
- package/lib/engine/engine_setup.js +2 -2
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/engine_time.d.ts +1 -0
- package/lib/engine/engine_time.js +7 -0
- package/lib/engine/engine_time.js.map +1 -1
- package/lib/engine/engine_types.d.ts +4 -1
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/engine_utils.d.ts +2 -1
- package/lib/engine/engine_utils.js +6 -0
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_components.d.ts +1 -1
- package/lib/engine/extensions/NEEDLE_progressive.d.ts +22 -0
- package/lib/engine/extensions/NEEDLE_progressive.js +172 -44
- package/lib/engine/extensions/NEEDLE_progressive.js.map +1 -1
- package/lib/engine-components/Collider.d.ts +2 -0
- package/lib/engine-components/Collider.js +4 -0
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/GroundProjection.d.ts +2 -1
- package/lib/engine-components/GroundProjection.js +19 -12
- package/lib/engine-components/GroundProjection.js.map +1 -1
- package/lib/engine-components/ParticleSystem.d.ts +1 -0
- package/lib/engine-components/ParticleSystem.js +10 -5
- package/lib/engine-components/ParticleSystem.js.map +1 -1
- package/lib/engine-components/ParticleSystemModules.d.ts +2 -2
- package/lib/engine-components/ParticleSystemModules.js +65 -55
- package/lib/engine-components/ParticleSystemModules.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +1 -1
- package/lib/engine-components/Renderer.d.ts +2 -1
- package/lib/engine-components/Renderer.js +8 -8
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/RigidBody.js +1 -19
- package/lib/engine-components/RigidBody.js.map +1 -1
- package/lib/engine-components/SyncedTransform.js +1 -3
- package/lib/engine-components/SyncedTransform.js.map +1 -1
- package/lib/engine-components/VideoPlayer.d.ts +2 -1
- package/lib/engine-components/VideoPlayer.js +54 -51
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/engine-components/Volume.js +8 -1
- package/lib/engine-components/Volume.js.map +1 -1
- package/lib/engine-components/WebARSessionRoot.js +5 -0
- package/lib/engine-components/WebARSessionRoot.js.map +1 -1
- package/lib/engine-components/WebXR.d.ts +2 -2
- package/lib/engine-components/WebXR.js +13 -13
- package/lib/engine-components/WebXR.js.map +1 -1
- package/lib/engine-components/WebXRAvatar.d.ts +1 -1
- package/lib/engine-components/WebXRController.js +1 -2
- package/lib/engine-components/WebXRController.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +99 -99
- package/lib/engine-components/codegen/components.js +99 -99
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.d.ts +1 -0
- package/lib/engine-components/export/usdz/USDZExporter.js +17 -1
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/ui/Button.js +30 -0
- package/lib/engine-components/ui/Button.js.map +1 -1
- package/lib/engine-components/ui/InputField.d.ts +2 -0
- package/lib/engine-components/ui/InputField.js +23 -1
- package/lib/engine-components/ui/InputField.js.map +1 -1
- package/lib/engine-components/ui/Utils.d.ts +2 -0
- package/lib/engine-components/ui/Utils.js +10 -9
- package/lib/engine-components/ui/Utils.js.map +1 -1
- package/lib/engine-components-experimental/Presentation.d.ts +6 -0
- package/lib/engine-components-experimental/Presentation.js +11 -0
- package/lib/engine-components-experimental/Presentation.js.map +1 -0
- package/lib/engine-components-experimental/annotation/LineDrawer.d.ts +18 -0
- package/lib/engine-components-experimental/annotation/LineDrawer.js +175 -0
- package/lib/engine-components-experimental/annotation/LineDrawer.js.map +1 -0
- package/lib/engine-components-experimental/annotation/LinesManager.d.ts +54 -0
- package/lib/engine-components-experimental/annotation/LinesManager.js +155 -0
- package/lib/engine-components-experimental/annotation/LinesManager.js.map +1 -0
- package/lib/engine-components-experimental/networking/PlayerSync.d.ts +26 -0
- package/lib/engine-components-experimental/networking/PlayerSync.js +121 -0
- package/lib/engine-components-experimental/networking/PlayerSync.js.map +1 -0
- package/lib/engine-schemes/vec2.d.ts +10 -0
- package/lib/engine-schemes/vec2.js +26 -0
- package/lib/engine-schemes/vec2.js.map +1 -0
- package/lib/include/three/ARButton.d.ts +3 -0
- package/lib/include/three/ARButton.js +158 -0
- package/lib/include/three/ARButton.js.map +1 -0
- package/lib/include/three/EXT_mesh_gpu_instancing_exporter.d.ts +6 -0
- package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js +46 -0
- package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js.map +1 -0
- package/lib/include/three/VRButton.d.ts +5 -0
- package/lib/include/three/VRButton.js +122 -0
- package/lib/include/three/VRButton.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
- package/src/engine/codegen/register_types.js +214 -214
- package/src/engine/debug/debug.ts +5 -0
- package/src/engine/debug/debug_console.ts +3 -2
- package/src/engine/debug/debug_overlay.ts +3 -1
- package/src/engine/engine_element.ts +4 -2
- package/src/engine/engine_element_loading.ts +13 -6
- package/src/engine/engine_element_overlay.ts +4 -2
- package/src/engine/engine_input.ts +4 -0
- package/src/engine/engine_lightdata.ts +1 -1
- package/src/engine/engine_mainloop_utils.ts +6 -0
- package/src/engine/engine_networking_websocket.ts +3 -1
- package/src/engine/engine_physics.ts +47 -5
- package/src/engine/engine_physics.types.ts +17 -0
- package/src/engine/engine_serialization_builtin_serializer.ts +8 -5
- package/src/engine/engine_setup.ts +2 -2
- package/src/engine/engine_time.ts +7 -1
- package/src/engine/engine_types.ts +5 -2
- package/src/engine/engine_utils.ts +7 -1
- package/src/engine/extensions/NEEDLE_progressive.ts +185 -43
- package/src/engine-components/Collider.ts +3 -0
- package/src/engine-components/GroundProjection.ts +18 -12
- package/src/engine-components/ParticleSystem.ts +10 -5
- package/src/engine-components/ParticleSystemModules.ts +69 -59
- package/src/engine-components/Renderer.ts +11 -9
- package/src/engine-components/RigidBody.ts +1 -20
- package/src/engine-components/SyncedTransform.ts +1 -3
- package/src/engine-components/VideoPlayer.ts +55 -51
- package/src/engine-components/Volume.ts +8 -1
- package/src/engine-components/WebARSessionRoot.ts +5 -0
- package/src/engine-components/WebXR.ts +17 -15
- package/src/engine-components/WebXRController.ts +1 -2
- package/src/engine-components/codegen/components.ts +99 -99
- package/src/engine-components/export/usdz/USDZExporter.ts +19 -2
- package/src/engine-components/ui/Button.ts +8 -8
- package/src/engine-components/ui/InputField.ts +25 -2
- package/src/engine-components/ui/Utils.ts +12 -11
- package/src/engine-components-experimental/annotation/LineDrawer.ts +10 -7
- package/src/engine-components-experimental/annotation/LinesManager.ts +6 -6
- package/src/engine-components-experimental/networking/PlayerSync.ts +1 -1
- package/lib/engine/engine_caching.d.ts +0 -0
- package/lib/engine/engine_caching.js +0 -2
- package/lib/engine/engine_caching.js.map +0 -1
- package/lib/engine/tests/simulate_avatars.d.ts +0 -0
- package/lib/engine/tests/simulate_avatars.js +0 -3
- package/lib/engine/tests/simulate_avatars.js.map +0 -1
- package/lib/engine-components/NavMesh.d.ts +0 -0
- package/lib/engine-components/NavMesh.js +0 -101
- package/lib/engine-components/NavMesh.js.map +0 -1
- package/lib/engine-components/ParticleSystemBehaviours.d.ts +0 -0
- package/lib/engine-components/ParticleSystemBehaviours.js +0 -2
- package/lib/engine-components/ParticleSystemBehaviours.js.map +0 -1
- package/lib/engine-components/SpringJoint.d.ts +0 -0
- package/lib/engine-components/SpringJoint.js +0 -43
- package/lib/engine-components/SpringJoint.js.map +0 -1
- package/lib/engine-components/ui/CanvasScaler.d.ts +0 -0
- package/lib/engine-components/ui/CanvasScaler.js +0 -17
- package/lib/engine-components/ui/CanvasScaler.js.map +0 -1
- package/src/engine/dist/engine_three_utils.js +0 -279
- package/src/engine/engine_caching.ts +0 -0
- package/src/engine/tests/simulate_avatars.ts +0 -2
- package/src/engine-components/NavMesh.ts +0 -117
- package/src/engine-components/ParticleSystemBehaviours.ts +0 -0
- package/src/engine-components/SpringJoint.ts +0 -45
- 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 =
|
|
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(
|
|
71
|
+
if (el.classList.contains(EngineLoadingView.LoadingContainerClassName)) {
|
|
68
72
|
if (!this._allowCustomLoadingElement) {
|
|
69
|
-
console.warn("
|
|
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
|
|
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 ??
|
|
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
|
-
|
|
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
|
|
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) {
|
|
@@ -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(
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|