@@ -196,7 +196,7 @@
|
|
196
196
|
onDisable() {
|
197
197
|
globalThis.removeEventListener('visibilitychange', this.onVisibilityChanged);
|
198
198
|
this.context.application.removeEventListener(ApplicationEvents.MuteChanged, this.onApplicationMuteChanged);
|
199
|
-
this.
|
199
|
+
this.pause();
|
200
200
|
}
|
201
201
|
|
202
202
|
private onVisibilityChanged = () => {
|
@@ -609,7 +609,10 @@
|
|
609
609
|
if (value.isVector4 || value.isVector3 || value.isVector2 || value.isQuaternion || value.isEuler) {
|
610
610
|
return value.clone();
|
611
611
|
}
|
612
|
-
else if(value.
|
612
|
+
else if (value.isColor === true) {
|
613
|
+
return value.clone();
|
614
|
+
}
|
615
|
+
else if (value.isEventList === true) {
|
613
616
|
// create a new instance of the object
|
614
617
|
const copy = new value.constructor();
|
615
618
|
return copy;
|
@@ -2,7 +2,10 @@
|
|
2
2
|
|
3
3
|
class MathHelper {
|
4
4
|
|
5
|
-
random(): number {
|
5
|
+
random(min?: number, max?: number): number {
|
6
|
+
if (min !== undefined && max !== undefined) {
|
7
|
+
return Math.random() * (max - min) + min;
|
8
|
+
}
|
6
9
|
return Math.random();
|
7
10
|
}
|
8
11
|
|
@@ -651,35 +651,45 @@
|
|
651
651
|
// TODO: we might want to update this if the material changes
|
652
652
|
const physicsMaterial = collider.sharedMaterial;
|
653
653
|
if (physicsMaterial) {
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
654
|
+
|
655
|
+
if (physicsMaterial.bounciness !== undefined)
|
656
|
+
desc.setRestitution(physicsMaterial.bounciness);
|
657
|
+
|
658
|
+
if (physicsMaterial.bounceCombine !== undefined) {
|
659
|
+
switch (physicsMaterial.bounceCombine) {
|
660
|
+
case PhysicsMaterialCombine.Average:
|
661
|
+
desc.setRestitutionCombineRule(CoefficientCombineRule.Average);
|
662
|
+
break;
|
663
|
+
case PhysicsMaterialCombine.Maximum:
|
664
|
+
desc.setRestitutionCombineRule(CoefficientCombineRule.Max);
|
665
|
+
break;
|
666
|
+
case PhysicsMaterialCombine.Minimum:
|
667
|
+
desc.setRestitutionCombineRule(CoefficientCombineRule.Min);
|
668
|
+
break;
|
669
|
+
case PhysicsMaterialCombine.Multiply:
|
670
|
+
desc.setRestitutionCombineRule(CoefficientCombineRule.Multiply);
|
671
|
+
break;
|
672
|
+
}
|
668
673
|
}
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
674
|
+
|
675
|
+
if (physicsMaterial.dynamicFriction !== undefined)
|
676
|
+
desc.setFriction(physicsMaterial.dynamicFriction);
|
677
|
+
|
678
|
+
if (physicsMaterial.frictionCombine !== undefined) {
|
679
|
+
switch (physicsMaterial.frictionCombine) {
|
680
|
+
case PhysicsMaterialCombine.Average:
|
681
|
+
desc.setFrictionCombineRule(CoefficientCombineRule.Average);
|
682
|
+
break;
|
683
|
+
case PhysicsMaterialCombine.Maximum:
|
684
|
+
desc.setFrictionCombineRule(CoefficientCombineRule.Max);
|
685
|
+
break;
|
686
|
+
case PhysicsMaterialCombine.Minimum:
|
687
|
+
desc.setFrictionCombineRule(CoefficientCombineRule.Min);
|
688
|
+
break;
|
689
|
+
case PhysicsMaterialCombine.Multiply:
|
690
|
+
desc.setFrictionCombineRule(CoefficientCombineRule.Multiply);
|
691
|
+
break;
|
692
|
+
}
|
683
693
|
}
|
684
694
|
}
|
685
695
|
|
@@ -8,11 +8,12 @@
|
|
8
8
|
}
|
9
9
|
|
10
10
|
export type PhysicsMaterial = {
|
11
|
-
bounceCombine
|
12
|
-
bounciness
|
13
|
-
frictionCombine
|
14
|
-
dynamicFriction
|
15
|
-
|
11
|
+
bounceCombine?: PhysicsMaterialCombine;
|
12
|
+
bounciness?: number;
|
13
|
+
frictionCombine?: PhysicsMaterialCombine;
|
14
|
+
dynamicFriction?: number;
|
15
|
+
/**@deprecated not used */
|
16
|
+
staticFriction?:number;
|
16
17
|
}
|
17
18
|
|
18
19
|
export enum CollisionDetectionMode {
|
@@ -106,13 +106,29 @@
|
|
106
106
|
if (typeof path !== "string") {
|
107
107
|
console.warn("Parse gltf binary without path, this might lead to errors in resolving extensions. Please provide the source path of the gltf/glb file", path, typeof path);
|
108
108
|
}
|
109
|
+
if (printGltf) console.log("Parse glTF", path)
|
109
110
|
const loader = await createGLTFLoader(path, context);
|
110
111
|
const componentsExtension = registerComponentExtension(loader);
|
111
112
|
return new Promise((resolve, reject) => {
|
112
113
|
try {
|
114
|
+
|
115
|
+
// GltfLoader expects a base path for resolving referenced assets
|
116
|
+
// https://threejs.org/docs/#examples/en/loaders/GLTFLoader.parse
|
117
|
+
// so we make sure that "path" is never a file path
|
118
|
+
let gltfLoaderPath = path.split("?")[0].trimEnd();
|
119
|
+
if (gltfLoaderPath.endsWith(".glb") || gltfLoaderPath.endsWith(".gltf")) {
|
120
|
+
// strip file from path
|
121
|
+
const parts = gltfLoaderPath.split("/");
|
122
|
+
parts.pop();
|
123
|
+
gltfLoaderPath = parts.join("/");
|
124
|
+
if (!gltfLoaderPath.endsWith("/")) gltfLoaderPath += "/";
|
125
|
+
}
|
126
|
+
loader.resourcePath = gltfLoaderPath;
|
127
|
+
|
113
128
|
loaders.addDracoAndKTX2Loaders(loader, context);
|
129
|
+
|
114
130
|
invokeEvents(GltfLoadEventType.BeforeLoad, new GltfLoadEvent(context, path, loader));
|
115
|
-
loader.parse(data,
|
131
|
+
loader.parse(data, "", async res => {
|
116
132
|
invokeEvents(GltfLoadEventType.AfterLoaded, new GltfLoadEvent(context, path, loader, res));
|
117
133
|
await handleLoadedGltf(context, path, res, seed, componentsExtension);
|
118
134
|
invokeEvents(GltfLoadEventType.FinishedSetup, new GltfLoadEvent(context, path, loader, res));
|
@@ -211,6 +211,7 @@
|
|
211
211
|
cullingMask: number;
|
212
212
|
aspect: number;
|
213
213
|
fieldOfView?: number;
|
214
|
+
/** x and y are in pixel on the canvas / dom element */
|
214
215
|
screenPointToRay(x: number, y: number, ray?: Ray): Ray;
|
215
216
|
targetTexture: RenderTexture | null;
|
216
217
|
}
|
@@ -68,29 +68,36 @@
|
|
68
68
|
// @serializable(Vector2)
|
69
69
|
// offsetMax: Vector2 = new Vector2(0, 0);
|
70
70
|
|
71
|
+
/** Optional min width in pixel, set to undefined to disable it */
|
72
|
+
minWidth?: number;
|
73
|
+
/** Optional min height in pixel, set to undefined to disable it */
|
74
|
+
minHeight?: number;
|
75
|
+
|
71
76
|
get width() {
|
77
|
+
let width = this.sizeDelta.x;
|
72
78
|
if (this.anchorMin.x !== this.anchorMax.x) {
|
73
79
|
if (this._parentRectTransform) {
|
74
80
|
const parentWidth = this._parentRectTransform.width;
|
75
81
|
const anchorWidth = this.anchorMax.x - this.anchorMin.x;
|
76
|
-
|
82
|
+
width = parentWidth * anchorWidth;
|
77
83
|
width += this.sizeDelta.x;
|
78
|
-
return width;
|
79
84
|
}
|
80
85
|
}
|
81
|
-
return this.
|
86
|
+
if(this.minWidth !== undefined && width < this.minWidth) return this.minWidth;
|
87
|
+
return width
|
82
88
|
}
|
83
89
|
get height() {
|
90
|
+
let height = this.sizeDelta.y;
|
84
91
|
if (this.anchorMin.y !== this.anchorMax.y) {
|
85
92
|
if (this._parentRectTransform) {
|
86
93
|
const parentHeight = this._parentRectTransform.height;
|
87
94
|
const anchorHeight = this.anchorMax.y - this.anchorMin.y;
|
88
|
-
|
95
|
+
height = parentHeight * anchorHeight;
|
89
96
|
height += this.sizeDelta.y;
|
90
|
-
return height
|
91
97
|
}
|
92
98
|
}
|
93
|
-
return this.
|
99
|
+
if(this.minHeight !== undefined && height < this.minHeight) return this.minHeight;
|
100
|
+
return height;
|
94
101
|
}
|
95
102
|
|
96
103
|
// private lastMatrixWorld!: Matrix4;
|
@@ -337,9 +337,16 @@
|
|
337
337
|
this.context.physics.engine?.applyImpulse(this, vec, wakeup);
|
338
338
|
}
|
339
339
|
|
340
|
-
public setForce(x: number, y
|
340
|
+
public setForce(x: Vector3 | Vec3 | number, y?: number, z?: number, wakeup: boolean = true) {
|
341
341
|
this.context.physics.engine?.resetForces(this, wakeup);
|
342
|
-
|
342
|
+
if (typeof x === "number") {
|
343
|
+
y ??= 0;
|
344
|
+
z ??= 0;
|
345
|
+
this.context.physics.engine?.addForce(this, { x, y, z }, wakeup);
|
346
|
+
}
|
347
|
+
else {
|
348
|
+
this.context.physics.engine?.addForce(this, x, wakeup);
|
349
|
+
}
|
343
350
|
}
|
344
351
|
|
345
352
|
public getVelocity(): Vector3 {
|
@@ -0,0 +1,7 @@
|
|
1
|
+
fileFormatVersion: 2
|
2
|
+
guid: aeb5cd8dfc66d8647a9ae66a8c05b289
|
3
|
+
DefaultImporter:
|
4
|
+
externalObjects: {}
|
5
|
+
userData:
|
6
|
+
assetBundleName:
|
7
|
+
assetBundleVariant:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
fileFormatVersion: 2
|
2
|
+
guid: f0e01709ea200b648a0c053c2c79f225
|
3
|
+
DefaultImporter:
|
4
|
+
externalObjects: {}
|
5
|
+
userData:
|
6
|
+
assetBundleName:
|
7
|
+
assetBundleVariant:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
fileFormatVersion: 2
|
2
|
+
guid: ed9ae84735d6def4b8122977a98ffa67
|
3
|
+
DefaultImporter:
|
4
|
+
externalObjects: {}
|
5
|
+
userData:
|
6
|
+
assetBundleName:
|
7
|
+
assetBundleVariant:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
fileFormatVersion: 2
|
2
|
+
guid: 48d3950534f4dae478088f839e8c1578
|
3
|
+
DefaultImporter:
|
4
|
+
externalObjects: {}
|
5
|
+
userData:
|
6
|
+
assetBundleName:
|
7
|
+
assetBundleVariant:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
fileFormatVersion: 2
|
2
|
+
guid: 5f962500714f41d45b62c935327da875
|
3
|
+
DefaultImporter:
|
4
|
+
externalObjects: {}
|
5
|
+
userData:
|
6
|
+
assetBundleName:
|
7
|
+
assetBundleVariant:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
fileFormatVersion: 2
|
2
|
+
guid: 426cba1d1719d9240aba902b59b93adb
|
3
|
+
DefaultImporter:
|
4
|
+
externalObjects: {}
|
5
|
+
userData:
|
6
|
+
assetBundleName:
|
7
|
+
assetBundleVariant:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
fileFormatVersion: 2
|
2
|
+
guid: 1d631bded37bcc249bc1c0f40c3c67be
|
3
|
+
DefaultImporter:
|
4
|
+
externalObjects: {}
|
5
|
+
userData:
|
6
|
+
assetBundleName:
|
7
|
+
assetBundleVariant:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
fileFormatVersion: 2
|
2
|
+
guid: e8764b784e44b1346ad7119078221aa2
|
3
|
+
DefaultImporter:
|
4
|
+
externalObjects: {}
|
5
|
+
userData:
|
6
|
+
assetBundleName:
|
7
|
+
assetBundleVariant:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
fileFormatVersion: 2
|
2
|
+
guid: eab38a2bd1b4834448fd9acc5fba06d0
|
3
|
+
DefaultImporter:
|
4
|
+
externalObjects: {}
|
5
|
+
userData:
|
6
|
+
assetBundleName:
|
7
|
+
assetBundleVariant:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
fileFormatVersion: 2
|
2
|
+
guid: a1b516d1fe960a441be75734a9d63918
|
3
|
+
DefaultImporter:
|
4
|
+
externalObjects: {}
|
5
|
+
userData:
|
6
|
+
assetBundleName:
|
7
|
+
assetBundleVariant:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
fileFormatVersion: 2
|
2
|
+
guid: 8bb79deb329f82d45b65efdbcfcfa590
|
3
|
+
DefaultImporter:
|
4
|
+
externalObjects: {}
|
5
|
+
userData:
|
6
|
+
assetBundleName:
|
7
|
+
assetBundleVariant:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
fileFormatVersion: 2
|
2
|
+
guid: 77f3ae2882ffe74409bea2f9443fb40d
|
3
|
+
DefaultImporter:
|
4
|
+
externalObjects: {}
|
5
|
+
userData:
|
6
|
+
assetBundleName:
|
7
|
+
assetBundleVariant:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
fileFormatVersion: 2
|
2
|
+
guid: f2624a361e4f4e046998075d7c419627
|
3
|
+
DefaultImporter:
|
4
|
+
externalObjects: {}
|
5
|
+
userData:
|
6
|
+
assetBundleName:
|
7
|
+
assetBundleVariant:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
fileFormatVersion: 2
|
2
|
+
guid: 92b7a6f0a8029fd4799f91553f3a9a58
|
3
|
+
DefaultImporter:
|
4
|
+
externalObjects: {}
|
5
|
+
userData:
|
6
|
+
assetBundleName:
|
7
|
+
assetBundleVariant:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
fileFormatVersion: 2
|
2
|
+
guid: b82b7d00193cb1d4f851ab843c5bb99f
|
3
|
+
DefaultImporter:
|
4
|
+
externalObjects: {}
|
5
|
+
userData:
|
6
|
+
assetBundleName:
|
7
|
+
assetBundleVariant:
|