Skip to content

Commit 859218c

Browse files
Simulation runtime
1 parent 758c382 commit 859218c

File tree

69 files changed

+4709
-874
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+4709
-874
lines changed

Extensions/3D/A_RuntimeObject3D.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@ namespace gdjs {
44

55
type Object3DNetworkSyncDataType = {
66
// z is position on the Z axis, different from zo, which is Z order
7-
z: number;
8-
d: number;
9-
rx: number;
10-
ry: number;
7+
z?: number;
8+
9+
d?: number;
10+
depth?: number;
11+
12+
rx?: number;
13+
rotationX?: number;
14+
1115
// no need for rz, as it is the angle from gdjs.RuntimeObject
12-
flipX: boolean;
13-
flipY: boolean;
14-
flipZ: boolean;
16+
ry?: number;
17+
rotationY?: number;
18+
19+
flipX?: boolean;
20+
flipY?: boolean;
21+
flipZ?: boolean;
1522
};
1623

1724
/** @category Objects > 3D Objects */
@@ -123,12 +130,14 @@ namespace gdjs {
123130
getNetworkSyncData(
124131
syncOptions: GetNetworkSyncDataOptions
125132
): Object3DNetworkSyncData {
133+
const getKey = (abbrev: string, full: string) =>
134+
syncOptions.useFullNames ? full : abbrev;
126135
return {
127136
...super.getNetworkSyncData(syncOptions),
128137
z: this.getZ(),
129-
d: this.getDepth(),
130-
rx: this.getRotationX(),
131-
ry: this.getRotationY(),
138+
[getKey('d', 'depth')]: this.getDepth(),
139+
[getKey('rx', 'rotationX')]: this.getRotationX(),
140+
[getKey('ry', 'rotationY')]: this.getRotationY(),
132141
flipX: this.isFlippedX(),
133142
flipY: this.isFlippedY(),
134143
flipZ: this.isFlippedZ(),

Extensions/3D/AmbientLight.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
namespace gdjs {
22
interface AmbientLightFilterNetworkSyncData {
3-
i: number;
4-
c: number;
3+
i?: number;
4+
intensity?: number;
5+
6+
c?: number;
7+
color?: number;
58
}
69
gdjs.PixiFiltersTools.registerFilterCreator(
710
'Scene3D::AmbientLight',
@@ -88,15 +91,17 @@ namespace gdjs {
8891
return 0;
8992
}
9093
updateBooleanParameter(parameterName: string, value: boolean): void {}
91-
getNetworkSyncData(): AmbientLightFilterNetworkSyncData {
94+
getNetworkSyncData(syncOptions: GetNetworkSyncDataOptions): AmbientLightFilterNetworkSyncData {
95+
const getKey = (abbrev: string, full: string) =>
96+
syncOptions.useFullNames ? full : abbrev;
9297
return {
93-
i: this.light.intensity,
94-
c: this.light.color.getHex(),
95-
};
98+
[getKey('i', 'intensity')]: this.light.intensity,
99+
[getKey('c', 'color')]: this.light.color.getHex(),
100+
} as AmbientLightFilterNetworkSyncData;
96101
}
97102
updateFromNetworkSyncData(data: AmbientLightFilterNetworkSyncData) {
98-
this.light.intensity = data.i;
99-
this.light.color.setHex(data.c);
103+
if (data.i !== undefined) this.light.intensity = data.i;
104+
if (data.c !== undefined) this.light.color.setHex(data.c);
100105
}
101106
})();
102107
}

Extensions/3D/BloomEffect.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
namespace gdjs {
22
interface BloomFilterNetworkSyncData {
3-
s: number;
4-
r: number;
5-
t: number;
3+
s?: number;
4+
strength?: number;
5+
6+
r?: number;
7+
radius?: number;
8+
9+
t?: number;
10+
threshold?: number;
611
}
712
gdjs.PixiFiltersTools.registerFilterCreator(
813
'Scene3D::Bloom',
@@ -87,17 +92,19 @@ namespace gdjs {
8792
return 0;
8893
}
8994
updateBooleanParameter(parameterName: string, value: boolean): void {}
90-
getNetworkSyncData(): BloomFilterNetworkSyncData {
95+
getNetworkSyncData(syncOptions: GetNetworkSyncDataOptions): BloomFilterNetworkSyncData {
96+
const getKey = (abbrev: string, full: string) =>
97+
syncOptions.useFullNames ? full : abbrev;
9198
return {
92-
s: this.shaderPass.strength,
93-
r: this.shaderPass.radius,
94-
t: this.shaderPass.threshold,
95-
};
99+
[getKey('s', 'strength')]: this.shaderPass.strength,
100+
[getKey('r', 'radius')]: this.shaderPass.radius,
101+
[getKey('t', 'threshold')]: this.shaderPass.threshold,
102+
} as BloomFilterNetworkSyncData;
96103
}
97104
updateFromNetworkSyncData(data: BloomFilterNetworkSyncData) {
98-
this.shaderPass.strength = data.s;
99-
this.shaderPass.radius = data.r;
100-
this.shaderPass.threshold = data.t;
105+
if (data.s !== undefined) this.shaderPass.strength = data.s;
106+
if (data.r !== undefined) this.shaderPass.radius = data.r;
107+
if (data.t !== undefined) this.shaderPass.threshold = data.t;
101108
}
102109
})();
103110
}

Extensions/3D/BrightnessAndContrastEffect.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
namespace gdjs {
22
interface BrightnessAndContrastFilterNetworkSyncData {
3-
b: number;
4-
c: number;
3+
b?: number;
4+
brightness?: number;
5+
6+
c?: number;
7+
contrast?: number;
58
}
69
gdjs.PixiFiltersTools.registerFilterCreator(
710
'Scene3D::BrightnessAndContrast',
@@ -77,17 +80,19 @@ namespace gdjs {
7780
return 0;
7881
}
7982
updateBooleanParameter(parameterName: string, value: boolean): void {}
80-
getNetworkSyncData(): BrightnessAndContrastFilterNetworkSyncData {
83+
getNetworkSyncData(syncOptions: GetNetworkSyncDataOptions): BrightnessAndContrastFilterNetworkSyncData {
84+
const getKey = (abbrev: string, full: string) =>
85+
syncOptions.useFullNames ? full : abbrev;
8186
return {
82-
b: this.shaderPass.uniforms.brightness.value,
83-
c: this.shaderPass.uniforms.contrast.value,
84-
};
87+
[getKey('b', 'brightness')]: this.shaderPass.uniforms.brightness.value,
88+
[getKey('c', 'contrast')]: this.shaderPass.uniforms.contrast.value,
89+
} as BrightnessAndContrastFilterNetworkSyncData;
8590
}
8691
updateFromNetworkSyncData(
8792
data: BrightnessAndContrastFilterNetworkSyncData
8893
) {
89-
this.shaderPass.uniforms.brightness.value = data.b;
90-
this.shaderPass.uniforms.contrast.value = data.c;
94+
if (data.b !== undefined) this.shaderPass.uniforms.brightness.value = data.b;
95+
if (data.c !== undefined) this.shaderPass.uniforms.contrast.value = data.c;
9196
}
9297
})();
9398
}

Extensions/3D/Cube3DRuntimeObject.ts

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,25 @@ namespace gdjs {
4444
};
4545

4646
type Cube3DObjectNetworkSyncDataType = {
47-
fo: 'Y' | 'Z';
48-
bfu: 'X' | 'Y';
49-
vfb: integer;
50-
trfb: integer;
51-
frn: [string, string, string, string, string, string];
52-
mt: number;
53-
tint: string;
47+
fo?: 'Y' | 'Z';
48+
facesOrientation?: 'Y' | 'Z';
49+
50+
bfu?: 'X' | 'Y';
51+
backFaceUpThroughWhichAxisRotation?: 'X' | 'Y';
52+
53+
vfb?: integer;
54+
visibleFacesBitmask?: integer;
55+
56+
trfb?: integer;
57+
textureRepeatFacesBitmask?: integer;
58+
59+
frn?: [string, string, string, string, string, string];
60+
faceResourceNames?: [string, string, string, string, string, string];
61+
62+
mt?: number;
63+
materialType?: number;
64+
65+
tint?: string;
5466
};
5567

5668
type Cube3DObjectNetworkSyncData = Object3DNetworkSyncData &
@@ -460,14 +472,16 @@ namespace gdjs {
460472
getNetworkSyncData(
461473
syncOptions: GetNetworkSyncDataOptions
462474
): Cube3DObjectNetworkSyncData {
475+
const getKey = (abbrev: string, full: string) =>
476+
syncOptions.useFullNames ? full : abbrev;
463477
return {
464478
...super.getNetworkSyncData(syncOptions),
465-
mt: this._materialType,
466-
fo: this._facesOrientation,
467-
bfu: this._backFaceUpThroughWhichAxisRotation,
468-
vfb: this._visibleFacesBitmask,
469-
trfb: this._textureRepeatFacesBitmask,
470-
frn: this._faceResourceNames,
479+
[getKey('mt', 'materialType')]: this._materialType,
480+
[getKey('fo', 'facesOrientation')]: this._facesOrientation,
481+
[getKey('bfu', 'backFaceUpThroughWhichAxisRotation')]: this._backFaceUpThroughWhichAxisRotation,
482+
[getKey('vfb', 'visibleFacesBitmask')]: this._visibleFacesBitmask,
483+
[getKey('trfb', 'textureRepeatFacesBitmask')]: this._textureRepeatFacesBitmask,
484+
[getKey('frn', 'faceResourceNames')]: this._faceResourceNames,
471485
tint: this._tint,
472486
};
473487
}
@@ -510,13 +524,14 @@ namespace gdjs {
510524
}
511525
}
512526
if (networkSyncData.frn !== undefined) {
527+
const frn = networkSyncData.frn;
513528
// If one element is different, update all the faces.
514529
if (
515530
!this._faceResourceNames.every(
516-
(value, index) => value === networkSyncData.frn[index]
531+
(value, index) => value === frn[index]
517532
)
518533
) {
519-
this._faceResourceNames = networkSyncData.frn;
534+
this._faceResourceNames = frn;
520535
// Update all faces. (Could optimize to only update the changed ones)
521536
for (let i = 0; i < this._faceResourceNames.length; i++) {
522537
this._renderer.updateFace(i);

Extensions/3D/CustomRuntimeObject3D.ts

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
namespace gdjs {
22
type CustomObject3DNetworkSyncDataType = {
3-
z: float;
4-
d: float;
5-
rx: float;
6-
ry: float;
7-
ifz: boolean;
8-
ccz: float;
3+
z?: float;
4+
5+
d?: float;
6+
depth?: float;
7+
8+
rx?: float;
9+
rotationX?: float;
10+
11+
ry?: float;
12+
rotationY?: float;
13+
14+
ifz?: boolean;
15+
isFlippedZ?: boolean;
16+
17+
ccz?: float;
18+
customCenterZ?: float;
919
};
1020

1121
type CustomObject3DNetworkSyncData = CustomObjectNetworkSyncData &
@@ -88,14 +98,16 @@ namespace gdjs {
8898
getNetworkSyncData(
8999
syncOptions: GetNetworkSyncDataOptions
90100
): CustomObject3DNetworkSyncData {
101+
const getKey = (abbrev: string, full: string) =>
102+
syncOptions.useFullNames ? full : abbrev;
91103
return {
92104
...super.getNetworkSyncData(syncOptions),
93105
z: this.getZ(),
94-
d: this.getDepth(),
95-
rx: this.getRotationX(),
96-
ry: this.getRotationY(),
97-
ifz: this.isFlippedZ(),
98-
ccz: this._customCenterZ,
106+
[getKey('d', 'depth')]: this.getDepth(),
107+
[getKey('rx', 'rotationX')]: this.getRotationX(),
108+
[getKey('ry', 'rotationY')]: this.getRotationY(),
109+
[getKey('ifz', 'isFlippedZ')]: this.isFlippedZ(),
110+
[getKey('ccz', 'customCenterZ')]: this._customCenterZ,
99111
};
100112
}
101113

Extensions/3D/DirectionalLight.ts

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
namespace gdjs {
22
interface DirectionalLightFilterNetworkSyncData {
3-
i: number;
4-
c: number;
5-
e: number;
6-
r: number;
7-
t: string;
3+
i?: number;
4+
intensity?: number;
5+
6+
c?: number;
7+
color?: number;
8+
9+
e?: number;
10+
elevation?: number;
11+
12+
r?: number;
13+
rotation?: number;
14+
15+
t?: string;
16+
top?: string;
817
}
918
const shadowHelper = false;
1019
gdjs.PixiFiltersTools.registerFilterCreator(
@@ -258,21 +267,23 @@ namespace gdjs {
258267
this._light.castShadow = value;
259268
}
260269
}
261-
getNetworkSyncData(): DirectionalLightFilterNetworkSyncData {
270+
getNetworkSyncData(syncOptions: GetNetworkSyncDataOptions): DirectionalLightFilterNetworkSyncData {
271+
const getKey = (abbrev: string, full: string) =>
272+
syncOptions.useFullNames ? full : abbrev;
262273
return {
263-
i: this._light.intensity,
264-
c: this._light.color.getHex(),
265-
e: this._elevation,
266-
r: this._rotation,
267-
t: this._top,
268-
};
274+
[getKey('i', 'intensity')]: this._light.intensity,
275+
[getKey('c', 'color')]: this._light.color.getHex(),
276+
[getKey('e', 'elevation')]: this._elevation,
277+
[getKey('r', 'rotation')]: this._rotation,
278+
[getKey('t', 'top')]: this._top,
279+
} as DirectionalLightFilterNetworkSyncData;
269280
}
270-
updateFromNetworkSyncData(syncData: any): void {
271-
this._light.intensity = syncData.i;
272-
this._light.color.setHex(syncData.c);
273-
this._elevation = syncData.e;
274-
this._rotation = syncData.r;
275-
this._top = syncData.t;
281+
updateFromNetworkSyncData(syncData: DirectionalLightFilterNetworkSyncData): void {
282+
if (syncData.i !== undefined) this._light.intensity = syncData.i;
283+
if (syncData.c !== undefined) this._light.color.setHex(syncData.c);
284+
if (syncData.e !== undefined) this._elevation = syncData.e;
285+
if (syncData.r !== undefined) this._rotation = syncData.r;
286+
if (syncData.t !== undefined) this._top = syncData.t;
276287
}
277288
})();
278289
}

Extensions/3D/ExponentialFog.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
namespace gdjs {
22
interface ExponentialFogFilterNetworkSyncData {
3-
d: number;
4-
c: number;
3+
d?: number;
4+
density?: number;
5+
6+
c?: number;
7+
color?: number;
58
}
69
gdjs.PixiFiltersTools.registerFilterCreator(
710
'Scene3D::ExponentialFog',
@@ -87,17 +90,19 @@ namespace gdjs {
8790
return 0;
8891
}
8992
updateBooleanParameter(parameterName: string, value: boolean): void {}
90-
getNetworkSyncData(): ExponentialFogFilterNetworkSyncData {
93+
getNetworkSyncData(syncOptions: GetNetworkSyncDataOptions): ExponentialFogFilterNetworkSyncData {
94+
const getKey = (abbrev: string, full: string) =>
95+
syncOptions.useFullNames ? full : abbrev;
9196
return {
92-
d: this.fog.density,
93-
c: this.fog.color.getHex(),
94-
};
97+
[getKey('d', 'density')]: this.fog.density,
98+
[getKey('c', 'color')]: this.fog.color.getHex(),
99+
} as ExponentialFogFilterNetworkSyncData;
95100
}
96101
updateFromNetworkSyncData(
97102
syncData: ExponentialFogFilterNetworkSyncData
98103
): void {
99-
this.fog.density = syncData.d;
100-
this.fog.color.setHex(syncData.c);
104+
if (syncData.d !== undefined) this.fog.density = syncData.d;
105+
if (syncData.c !== undefined) this.fog.color.setHex(syncData.c);
101106
}
102107
})();
103108
}

0 commit comments

Comments
 (0)