mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
pre fix model3D object data transfering for cast and receive shadow
This commit is contained in:
@@ -2535,9 +2535,6 @@ module.exports = {
|
||||
RenderedInstance.toRad(this._instance.getAngle())
|
||||
);
|
||||
|
||||
this._threeObject.castShadow = object.content.isCastingShadow;
|
||||
this._threeObject.receiveShadow = object.content.isReceivingShadow;
|
||||
|
||||
let materialsDirty = false;
|
||||
let uvMappingDirty = false;
|
||||
let tintDirty = false;
|
||||
|
@@ -38,8 +38,8 @@ namespace gdjs {
|
||||
| 'BottomCenterY';
|
||||
animations: Model3DAnimation[];
|
||||
crossfadeDuration: float;
|
||||
castShadow: boolean;
|
||||
receiveShadow: boolean;
|
||||
isCastingShadow: boolean;
|
||||
isReceivingShadow: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ namespace gdjs {
|
||||
_animationSpeedScale: float = 1;
|
||||
_animationPaused: boolean = false;
|
||||
_crossfadeDuration: float = 0;
|
||||
_castShadow: boolean = true;
|
||||
_receiveShadow: boolean = true;
|
||||
_isCastingShadow: boolean = false;
|
||||
_isReceivingShadow: boolean = false;
|
||||
|
||||
constructor(
|
||||
instanceContainer: gdjs.RuntimeInstanceContainer,
|
||||
@@ -131,8 +131,8 @@ namespace gdjs {
|
||||
|
||||
this._crossfadeDuration = objectData.content.crossfadeDuration || 0;
|
||||
|
||||
this._castShadow = objectData.content.castShadow;
|
||||
this._receiveShadow = objectData.content.receiveShadow;
|
||||
this._isCastingShadow = objectData.content.isCastingShadow;
|
||||
this._isReceivingShadow = objectData.content.isReceivingShadow;
|
||||
|
||||
// *ALWAYS* call `this.onCreated()` at the very end of your object constructor.
|
||||
this.onCreated();
|
||||
@@ -202,6 +202,18 @@ namespace gdjs {
|
||||
newObjectData.content.centerLocation
|
||||
);
|
||||
}
|
||||
if (
|
||||
oldObjectData.content.isCastingShadow !==
|
||||
newObjectData.content.isCastingShadow
|
||||
) {
|
||||
this._isCastingShadow = newObjectData.content.isCastingShadow;
|
||||
}
|
||||
if (
|
||||
oldObjectData.content.isReceivingShadow !==
|
||||
newObjectData.content.isReceivingShadow
|
||||
) {
|
||||
this._isReceivingShadow = newObjectData.content.isReceivingShadow;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -366,11 +378,11 @@ namespace gdjs {
|
||||
}
|
||||
|
||||
setCastShadow(value: boolean): void {
|
||||
this._castShadow = value;
|
||||
this._isCastingShadow = value;
|
||||
}
|
||||
|
||||
setReceiveShadow(value: boolean): void {
|
||||
this._receiveShadow = value;
|
||||
this._isReceivingShadow = value;
|
||||
}
|
||||
|
||||
setCrossfadeDuration(duration: number): void {
|
||||
|
@@ -286,6 +286,10 @@ namespace gdjs {
|
||||
this.get3DRendererObject().remove(this._threeObject);
|
||||
this.get3DRendererObject().add(threeObject);
|
||||
this._threeObject = threeObject;
|
||||
this._threeObject.traverse((child) => {
|
||||
child.castShadow = this._model3DRuntimeObject._isCastingShadow;
|
||||
child.receiveShadow = this._model3DRuntimeObject._isReceivingShadow;
|
||||
});
|
||||
|
||||
// Start the current animation on the new 3D object.
|
||||
this._animationMixer = new THREE.AnimationMixer(root);
|
||||
@@ -302,8 +306,6 @@ namespace gdjs {
|
||||
* Replace materials to better work with lights (or no light).
|
||||
*/
|
||||
private _replaceMaterials(threeObject: THREE.Object3D) {
|
||||
threeObject.castShadow = this._model3DRuntimeObject._castShadow;
|
||||
threeObject.receiveShadow = this._model3DRuntimeObject._receiveShadow;
|
||||
if (
|
||||
this._model3DRuntimeObject._materialType ===
|
||||
gdjs.Model3DRuntimeObject.MaterialType.StandardWithoutMetalness
|
||||
|
Reference in New Issue
Block a user