Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions Extensions/3D/A_RuntimeObject3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@ namespace gdjs {

type Object3DNetworkSyncDataType = {
// z is position on the Z axis, different from zo, which is Z order
z: number;
d: number;
rx: number;
ry: number;
z?: number;

d?: number;
depth?: number;

rx?: number;
rotationX?: number;

// no need for rz, as it is the angle from gdjs.RuntimeObject
flipX: boolean;
flipY: boolean;
flipZ: boolean;
ry?: number;
rotationY?: number;

flipX?: boolean;
flipY?: boolean;
flipZ?: boolean;
};

/** @category Objects > 3D Objects */
Expand Down Expand Up @@ -123,12 +130,14 @@ namespace gdjs {
getNetworkSyncData(
syncOptions: GetNetworkSyncDataOptions
): Object3DNetworkSyncData {
const getKey = (abbrev: string, full: string) =>
syncOptions.useFullNames ? full : abbrev;
return {
...super.getNetworkSyncData(syncOptions),
z: this.getZ(),
d: this.getDepth(),
rx: this.getRotationX(),
ry: this.getRotationY(),
[getKey('d', 'depth')]: this.getDepth(),
[getKey('rx', 'rotationX')]: this.getRotationX(),
[getKey('ry', 'rotationY')]: this.getRotationY(),
flipX: this.isFlippedX(),
flipY: this.isFlippedY(),
flipZ: this.isFlippedZ(),
Expand Down
23 changes: 15 additions & 8 deletions Extensions/3D/AmbientLight.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
namespace gdjs {
interface AmbientLightFilterNetworkSyncData {
i: number;
c: number;
i?: number;
intensity?: number;

c?: number;
color?: number;
}
gdjs.PixiFiltersTools.registerFilterCreator(
'Scene3D::AmbientLight',
Expand Down Expand Up @@ -88,15 +91,19 @@ namespace gdjs {
return 0;
}
updateBooleanParameter(parameterName: string, value: boolean): void {}
getNetworkSyncData(): AmbientLightFilterNetworkSyncData {
getNetworkSyncData(
syncOptions: GetNetworkSyncDataOptions
): AmbientLightFilterNetworkSyncData {
const getKey = (abbrev: string, full: string) =>
syncOptions.useFullNames ? full : abbrev;
return {
i: this.light.intensity,
c: this.light.color.getHex(),
};
[getKey('i', 'intensity')]: this.light.intensity,
[getKey('c', 'color')]: this.light.color.getHex(),
} as AmbientLightFilterNetworkSyncData;
}
updateFromNetworkSyncData(data: AmbientLightFilterNetworkSyncData) {
this.light.intensity = data.i;
this.light.color.setHex(data.c);
if (data.i !== undefined) this.light.intensity = data.i;
if (data.c !== undefined) this.light.color.setHex(data.c);
}
})();
}
Expand Down
31 changes: 20 additions & 11 deletions Extensions/3D/BloomEffect.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
namespace gdjs {
interface BloomFilterNetworkSyncData {
s: number;
r: number;
t: number;
s?: number;
strength?: number;

r?: number;
radius?: number;

t?: number;
threshold?: number;
}
gdjs.PixiFiltersTools.registerFilterCreator(
'Scene3D::Bloom',
Expand Down Expand Up @@ -87,17 +92,21 @@ namespace gdjs {
return 0;
}
updateBooleanParameter(parameterName: string, value: boolean): void {}
getNetworkSyncData(): BloomFilterNetworkSyncData {
getNetworkSyncData(
syncOptions: GetNetworkSyncDataOptions
): BloomFilterNetworkSyncData {
const getKey = (abbrev: string, full: string) =>
syncOptions.useFullNames ? full : abbrev;
return {
s: this.shaderPass.strength,
r: this.shaderPass.radius,
t: this.shaderPass.threshold,
};
[getKey('s', 'strength')]: this.shaderPass.strength,
[getKey('r', 'radius')]: this.shaderPass.radius,
[getKey('t', 'threshold')]: this.shaderPass.threshold,
} as BloomFilterNetworkSyncData;
}
updateFromNetworkSyncData(data: BloomFilterNetworkSyncData) {
this.shaderPass.strength = data.s;
this.shaderPass.radius = data.r;
this.shaderPass.threshold = data.t;
if (data.s !== undefined) this.shaderPass.strength = data.s;
if (data.r !== undefined) this.shaderPass.radius = data.r;
if (data.t !== undefined) this.shaderPass.threshold = data.t;
}
})();
}
Expand Down
27 changes: 19 additions & 8 deletions Extensions/3D/BrightnessAndContrastEffect.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
namespace gdjs {
interface BrightnessAndContrastFilterNetworkSyncData {
b: number;
c: number;
b?: number;
brightness?: number;

c?: number;
contrast?: number;
}
gdjs.PixiFiltersTools.registerFilterCreator(
'Scene3D::BrightnessAndContrast',
Expand Down Expand Up @@ -77,17 +80,25 @@ namespace gdjs {
return 0;
}
updateBooleanParameter(parameterName: string, value: boolean): void {}
getNetworkSyncData(): BrightnessAndContrastFilterNetworkSyncData {
getNetworkSyncData(
syncOptions: GetNetworkSyncDataOptions
): BrightnessAndContrastFilterNetworkSyncData {
const getKey = (abbrev: string, full: string) =>
syncOptions.useFullNames ? full : abbrev;
return {
b: this.shaderPass.uniforms.brightness.value,
c: this.shaderPass.uniforms.contrast.value,
};
[getKey('b', 'brightness')]:
this.shaderPass.uniforms.brightness.value,
[getKey('c', 'contrast')]:
this.shaderPass.uniforms.contrast.value,
} as BrightnessAndContrastFilterNetworkSyncData;
}
updateFromNetworkSyncData(
data: BrightnessAndContrastFilterNetworkSyncData
) {
this.shaderPass.uniforms.brightness.value = data.b;
this.shaderPass.uniforms.contrast.value = data.c;
if (data.b !== undefined)
this.shaderPass.uniforms.brightness.value = data.b;
if (data.c !== undefined)
this.shaderPass.uniforms.contrast.value = data.c;
}
})();
}
Expand Down
49 changes: 32 additions & 17 deletions Extensions/3D/Cube3DRuntimeObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,25 @@ namespace gdjs {
};

type Cube3DObjectNetworkSyncDataType = {
fo: 'Y' | 'Z';
bfu: 'X' | 'Y';
vfb: integer;
trfb: integer;
frn: [string, string, string, string, string, string];
mt: number;
tint: string;
fo?: 'Y' | 'Z';
facesOrientation?: 'Y' | 'Z';

bfu?: 'X' | 'Y';
backFaceUpThroughWhichAxisRotation?: 'X' | 'Y';

vfb?: integer;
visibleFacesBitmask?: integer;

trfb?: integer;
textureRepeatFacesBitmask?: integer;

frn?: [string, string, string, string, string, string];
faceResourceNames?: [string, string, string, string, string, string];

mt?: number;
materialType?: number;

tint?: string;
};

type Cube3DObjectNetworkSyncData = Object3DNetworkSyncData &
Expand Down Expand Up @@ -460,14 +472,18 @@ namespace gdjs {
getNetworkSyncData(
syncOptions: GetNetworkSyncDataOptions
): Cube3DObjectNetworkSyncData {
const getKey = (abbrev: string, full: string) =>
syncOptions.useFullNames ? full : abbrev;
return {
...super.getNetworkSyncData(syncOptions),
mt: this._materialType,
fo: this._facesOrientation,
bfu: this._backFaceUpThroughWhichAxisRotation,
vfb: this._visibleFacesBitmask,
trfb: this._textureRepeatFacesBitmask,
frn: this._faceResourceNames,
[getKey('mt', 'materialType')]: this._materialType,
[getKey('fo', 'facesOrientation')]: this._facesOrientation,
[getKey('bfu', 'backFaceUpThroughWhichAxisRotation')]:
this._backFaceUpThroughWhichAxisRotation,
[getKey('vfb', 'visibleFacesBitmask')]: this._visibleFacesBitmask,
[getKey('trfb', 'textureRepeatFacesBitmask')]:
this._textureRepeatFacesBitmask,
[getKey('frn', 'faceResourceNames')]: this._faceResourceNames,
tint: this._tint,
};
}
Expand Down Expand Up @@ -510,13 +526,12 @@ namespace gdjs {
}
}
if (networkSyncData.frn !== undefined) {
const frn = networkSyncData.frn;
// If one element is different, update all the faces.
if (
!this._faceResourceNames.every(
(value, index) => value === networkSyncData.frn[index]
)
!this._faceResourceNames.every((value, index) => value === frn[index])
) {
this._faceResourceNames = networkSyncData.frn;
this._faceResourceNames = frn;
// Update all faces. (Could optimize to only update the changed ones)
for (let i = 0; i < this._faceResourceNames.length; i++) {
this._renderer.updateFace(i);
Expand Down
34 changes: 23 additions & 11 deletions Extensions/3D/CustomRuntimeObject3D.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
namespace gdjs {
type CustomObject3DNetworkSyncDataType = {
z: float;
d: float;
rx: float;
ry: float;
ifz: boolean;
ccz: float;
z?: float;

d?: float;
depth?: float;

rx?: float;
rotationX?: float;

ry?: float;
rotationY?: float;

ifz?: boolean;
isFlippedZ?: boolean;

ccz?: float;
customCenterZ?: float;
};

type CustomObject3DNetworkSyncData = CustomObjectNetworkSyncData &
Expand Down Expand Up @@ -88,14 +98,16 @@ namespace gdjs {
getNetworkSyncData(
syncOptions: GetNetworkSyncDataOptions
): CustomObject3DNetworkSyncData {
const getKey = (abbrev: string, full: string) =>
syncOptions.useFullNames ? full : abbrev;
return {
...super.getNetworkSyncData(syncOptions),
z: this.getZ(),
d: this.getDepth(),
rx: this.getRotationX(),
ry: this.getRotationY(),
ifz: this.isFlippedZ(),
ccz: this._customCenterZ,
[getKey('d', 'depth')]: this.getDepth(),
[getKey('rx', 'rotationX')]: this.getRotationX(),
[getKey('ry', 'rotationY')]: this.getRotationY(),
[getKey('ifz', 'isFlippedZ')]: this.isFlippedZ(),
[getKey('ccz', 'customCenterZ')]: this._customCenterZ,
};
}

Expand Down
51 changes: 33 additions & 18 deletions Extensions/3D/DirectionalLight.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
namespace gdjs {
interface DirectionalLightFilterNetworkSyncData {
i: number;
c: number;
e: number;
r: number;
t: string;
i?: number;
intensity?: number;

c?: number;
color?: number;

e?: number;
elevation?: number;

r?: number;
rotation?: number;

t?: string;
top?: string;
}
const shadowHelper = false;
gdjs.PixiFiltersTools.registerFilterCreator(
Expand Down Expand Up @@ -258,21 +267,27 @@ namespace gdjs {
this._light.castShadow = value;
}
}
getNetworkSyncData(): DirectionalLightFilterNetworkSyncData {
getNetworkSyncData(
syncOptions: GetNetworkSyncDataOptions
): DirectionalLightFilterNetworkSyncData {
const getKey = (abbrev: string, full: string) =>
syncOptions.useFullNames ? full : abbrev;
return {
i: this._light.intensity,
c: this._light.color.getHex(),
e: this._elevation,
r: this._rotation,
t: this._top,
};
[getKey('i', 'intensity')]: this._light.intensity,
[getKey('c', 'color')]: this._light.color.getHex(),
[getKey('e', 'elevation')]: this._elevation,
[getKey('r', 'rotation')]: this._rotation,
[getKey('t', 'top')]: this._top,
} as DirectionalLightFilterNetworkSyncData;
}
updateFromNetworkSyncData(syncData: any): void {
this._light.intensity = syncData.i;
this._light.color.setHex(syncData.c);
this._elevation = syncData.e;
this._rotation = syncData.r;
this._top = syncData.t;
updateFromNetworkSyncData(
syncData: DirectionalLightFilterNetworkSyncData
): void {
if (syncData.i !== undefined) this._light.intensity = syncData.i;
if (syncData.c !== undefined) this._light.color.setHex(syncData.c);
if (syncData.e !== undefined) this._elevation = syncData.e;
if (syncData.r !== undefined) this._rotation = syncData.r;
if (syncData.t !== undefined) this._top = syncData.t;
}
})();
}
Expand Down
Loading
Loading