gdcore-tools 2.0.0-beta6 → 2.0.0-beta7

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.
Files changed (138) hide show
  1. package/dist/Runtime/Cordova/config.xml +4 -0
  2. package/dist/Runtime/Cordova/package.json +12 -20
  3. package/dist/Runtime/CustomRuntimeObject.js +1 -1
  4. package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
  5. package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js +1 -1
  6. package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js.map +2 -2
  7. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js +1 -1
  8. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js.map +2 -2
  9. package/dist/Runtime/Extensions/3D/AmbientLight.js +1 -1
  10. package/dist/Runtime/Extensions/3D/AmbientLight.js.map +2 -2
  11. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
  12. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
  13. package/dist/Runtime/Extensions/3D/DirectionalLight.js +1 -1
  14. package/dist/Runtime/Extensions/3D/DirectionalLight.js.map +2 -2
  15. package/dist/Runtime/Extensions/3D/ExponentialFog.js +1 -1
  16. package/dist/Runtime/Extensions/3D/ExponentialFog.js.map +2 -2
  17. package/dist/Runtime/Extensions/3D/HemisphereLight.js +1 -1
  18. package/dist/Runtime/Extensions/3D/HemisphereLight.js.map +2 -2
  19. package/dist/Runtime/Extensions/3D/JsExtension.js +419 -228
  20. package/dist/Runtime/Extensions/3D/LinearFog.js +1 -1
  21. package/dist/Runtime/Extensions/3D/LinearFog.js.map +2 -2
  22. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
  23. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
  24. package/dist/Runtime/Extensions/AdvancedWindow/electron-advancedwindowtools.js +1 -1
  25. package/dist/Runtime/Extensions/AdvancedWindow/electron-advancedwindowtools.js.map +2 -2
  26. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js +1 -1
  27. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js.map +2 -2
  28. package/dist/Runtime/Extensions/BBText/JsExtension.js +45 -42
  29. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js +1 -1
  30. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js.map +2 -2
  31. package/dist/Runtime/Extensions/BitmapText/JsExtension.js +40 -49
  32. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js +1 -1
  33. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
  34. package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js +1 -1
  35. package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js.map +2 -2
  36. package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js +1 -1
  37. package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js.map +2 -2
  38. package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js +1 -1
  39. package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js.map +2 -2
  40. package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js +1 -1
  41. package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js.map +2 -2
  42. package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js +1 -1
  43. package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js.map +2 -2
  44. package/dist/Runtime/Extensions/ExampleJsExtension/JsExtension.js +18 -21
  45. package/dist/Runtime/Extensions/Firebase/B_firebasetools/C_firebasetools.js +1 -1
  46. package/dist/Runtime/Extensions/Firebase/B_firebasetools/C_firebasetools.js.map +2 -2
  47. package/dist/Runtime/Extensions/JsExtensionTypes.d.ts +8 -2
  48. package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js +1 -1
  49. package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js.map +2 -2
  50. package/dist/Runtime/Extensions/Lighting/JsExtension.js +50 -38
  51. package/dist/Runtime/Extensions/Lighting/lightruntimeobject-pixi-renderer.js +1 -1
  52. package/dist/Runtime/Extensions/Lighting/lightruntimeobject-pixi-renderer.js.map +2 -2
  53. package/dist/Runtime/Extensions/Multiplayer/JsExtension.js +15 -0
  54. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
  55. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  56. package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js.map +2 -2
  57. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js +1 -1
  58. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
  59. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js +1 -1
  60. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js.map +2 -2
  61. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js +1 -1
  62. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
  63. package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +76 -24
  64. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
  65. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
  66. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js +1 -1
  67. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js.map +2 -2
  68. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js +1 -1
  69. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
  70. package/dist/Runtime/Extensions/Spine/JsExtension.js +45 -36
  71. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js +1 -1
  72. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
  73. package/dist/Runtime/Extensions/TextInput/JsExtension.js +52 -55
  74. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js +1 -1
  75. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js.map +2 -2
  76. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js +1 -1
  77. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js.map +2 -2
  78. package/dist/Runtime/Extensions/TextObject/textruntimeobject-pixi-renderer.js +1 -1
  79. package/dist/Runtime/Extensions/TextObject/textruntimeobject-pixi-renderer.js.map +2 -2
  80. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js +1 -1
  81. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js.map +2 -2
  82. package/dist/Runtime/Extensions/TileMap/JsExtension.js +430 -261
  83. package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js +1 -1
  84. package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js.map +2 -2
  85. package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js +1 -1
  86. package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js.map +2 -2
  87. package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js +1 -1
  88. package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js.map +1 -1
  89. package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts.map +1 -1
  90. package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts +1 -0
  91. package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts.map +1 -1
  92. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
  93. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
  94. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js +1 -1
  95. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js.map +2 -2
  96. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js +1 -1
  97. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js.map +2 -2
  98. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js +1 -1
  99. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
  100. package/dist/Runtime/Extensions/Video/JsExtension.js +35 -44
  101. package/dist/Runtime/Extensions/Video/videoruntimeobject.js +1 -1
  102. package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
  103. package/dist/Runtime/ResourceLoader.js +1 -1
  104. package/dist/Runtime/ResourceLoader.js.map +2 -2
  105. package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
  106. package/dist/Runtime/debugger-client/hot-reloader.js +2 -2
  107. package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
  108. package/dist/Runtime/events-tools/inputtools.js +1 -1
  109. package/dist/Runtime/events-tools/inputtools.js.map +2 -2
  110. package/dist/Runtime/events-tools/objecttools.js +1 -1
  111. package/dist/Runtime/events-tools/objecttools.js.map +2 -2
  112. package/dist/Runtime/gd.js +1 -1
  113. package/dist/Runtime/gd.js.map +2 -2
  114. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  115. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  116. package/dist/Runtime/inputmanager.js +1 -1
  117. package/dist/Runtime/inputmanager.js.map +2 -2
  118. package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js +1 -1
  119. package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js.map +2 -2
  120. package/dist/Runtime/pixi-renderers/pixi-filters-tools.js +1 -1
  121. package/dist/Runtime/pixi-renderers/pixi-filters-tools.js.map +2 -2
  122. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
  123. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
  124. package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js +1 -1
  125. package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js.map +2 -2
  126. package/dist/Runtime/runtimegame.js +1 -1
  127. package/dist/Runtime/runtimegame.js.map +1 -1
  128. package/dist/Runtime/runtimeobject.js +1 -1
  129. package/dist/Runtime/runtimeobject.js.map +2 -2
  130. package/dist/Runtime/spriteruntimeobject.js +1 -1
  131. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  132. package/dist/Runtime/types/project-data.d.ts +5 -0
  133. package/dist/lib/libGD.cjs +1 -1
  134. package/dist/lib/libGD.d.cts +5 -0
  135. package/dist/lib/libGD.wasm +0 -0
  136. package/dist/loaders.d.cts +2 -0
  137. package/gd.d.ts +74 -30
  138. package/package.json +3 -3
@@ -803,11 +803,8 @@ module.exports = {
803
803
  }
804
804
 
805
805
  const Cube3DObject = new gd.ObjectJsImplementation();
806
- Cube3DObject.updateProperty = function (
807
- objectContent,
808
- propertyName,
809
- newValue
810
- ) {
806
+ Cube3DObject.updateProperty = function (propertyName, newValue) {
807
+ const objectContent = this.content;
811
808
  if (
812
809
  propertyName === 'width' ||
813
810
  propertyName === 'height' ||
@@ -851,8 +848,9 @@ module.exports = {
851
848
 
852
849
  return false;
853
850
  };
854
- Cube3DObject.getProperties = function (objectContent) {
851
+ Cube3DObject.getProperties = function () {
855
852
  const objectProperties = new gd.MapStringPropertyDescriptor();
853
+ const objectContent = this.content;
856
854
 
857
855
  objectProperties
858
856
  .getOrCreate('enableTextureTransparency')
@@ -878,7 +876,8 @@ module.exports = {
878
876
  'The top of each image can touch the **top face** (Y) or the **front face** (Z).'
879
877
  )
880
878
  )
881
- .setGroup(_('Face orientation'));
879
+ .setGroup(_('Face orientation'))
880
+ .setAdvanced(true);
882
881
 
883
882
  objectProperties
884
883
  .getOrCreate('width')
@@ -909,7 +908,7 @@ module.exports = {
909
908
  .setValue(objectContent.frontFaceResourceName || '')
910
909
  .setType('resource')
911
910
  .addExtraInfo('image')
912
- .setLabel(_('Front face image'))
911
+ .setLabel(_('Front face'))
913
912
  .setGroup(_('Textures'));
914
913
 
915
914
  objectProperties
@@ -917,7 +916,7 @@ module.exports = {
917
916
  .setValue(objectContent.backFaceResourceName || '')
918
917
  .setType('resource')
919
918
  .addExtraInfo('image')
920
- .setLabel(_('Back face image'))
919
+ .setLabel(_('Back face'))
921
920
  .setGroup(_('Textures'));
922
921
 
923
922
  objectProperties
@@ -932,14 +931,15 @@ module.exports = {
932
931
  'The top of the image can touch the **top face** (Y) or the **bottom face** (X).'
933
932
  )
934
933
  )
935
- .setGroup(_('Textures'));
934
+ .setGroup(_('Face orientation'))
935
+ .setAdvanced(true);
936
936
 
937
937
  objectProperties
938
938
  .getOrCreate('leftFaceResourceName')
939
939
  .setValue(objectContent.leftFaceResourceName || '')
940
940
  .setType('resource')
941
941
  .addExtraInfo('image')
942
- .setLabel(_('Left face image'))
942
+ .setLabel(_('Left face'))
943
943
  .setGroup(_('Textures'));
944
944
 
945
945
  objectProperties
@@ -947,7 +947,7 @@ module.exports = {
947
947
  .setValue(objectContent.rightFaceResourceName || '')
948
948
  .setType('resource')
949
949
  .addExtraInfo('image')
950
- .setLabel(_('Right face image'))
950
+ .setLabel(_('Right face'))
951
951
  .setGroup(_('Textures'));
952
952
 
953
953
  objectProperties
@@ -955,7 +955,7 @@ module.exports = {
955
955
  .setValue(objectContent.topFaceResourceName || '')
956
956
  .setType('resource')
957
957
  .addExtraInfo('image')
958
- .setLabel(_('Top face image'))
958
+ .setLabel(_('Top face'))
959
959
  .setGroup(_('Textures'));
960
960
 
961
961
  objectProperties
@@ -963,92 +963,98 @@ module.exports = {
963
963
  .setValue(objectContent.bottomFaceResourceName || '')
964
964
  .setType('resource')
965
965
  .addExtraInfo('image')
966
- .setLabel(_('Bottom face image'))
966
+ .setLabel(_('Bottom face'))
967
967
  .setGroup(_('Textures'));
968
968
 
969
969
  objectProperties
970
970
  .getOrCreate('frontFaceResourceRepeat')
971
971
  .setValue(objectContent.frontFaceResourceRepeat ? 'true' : 'false')
972
972
  .setType('boolean')
973
- .setLabel(_('Tile front face image'))
973
+ .setLabel(_('Tile'))
974
974
  .setGroup(_('Textures'));
975
975
 
976
976
  objectProperties
977
977
  .getOrCreate('backFaceResourceRepeat')
978
978
  .setValue(objectContent.backFaceResourceRepeat ? 'true' : 'false')
979
979
  .setType('boolean')
980
- .setLabel(_('Tile back face image'))
980
+ .setLabel(_('Tile'))
981
981
  .setGroup(_('Textures'));
982
982
 
983
983
  objectProperties
984
984
  .getOrCreate('leftFaceResourceRepeat')
985
985
  .setValue(objectContent.leftFaceResourceRepeat ? 'true' : 'false')
986
986
  .setType('boolean')
987
- .setLabel(_('Tile left face image'))
987
+ .setLabel(_('Tile'))
988
988
  .setGroup(_('Textures'));
989
989
 
990
990
  objectProperties
991
991
  .getOrCreate('rightFaceResourceRepeat')
992
992
  .setValue(objectContent.rightFaceResourceRepeat ? 'true' : 'false')
993
993
  .setType('boolean')
994
- .setLabel(_('Tile right face image'))
994
+ .setLabel(_('Tile'))
995
995
  .setGroup(_('Textures'));
996
996
 
997
997
  objectProperties
998
998
  .getOrCreate('topFaceResourceRepeat')
999
999
  .setValue(objectContent.topFaceResourceRepeat ? 'true' : 'false')
1000
1000
  .setType('boolean')
1001
- .setLabel(_('Tile top face image'))
1001
+ .setLabel(_('Tile'))
1002
1002
  .setGroup(_('Textures'));
1003
1003
 
1004
1004
  objectProperties
1005
1005
  .getOrCreate('bottomFaceResourceRepeat')
1006
1006
  .setValue(objectContent.bottomFaceResourceRepeat ? 'true' : 'false')
1007
1007
  .setType('boolean')
1008
- .setLabel(_('Tile bottom face image'))
1008
+ .setLabel(_('Tile'))
1009
1009
  .setGroup(_('Textures'));
1010
1010
 
1011
1011
  objectProperties
1012
1012
  .getOrCreate('frontFaceVisible')
1013
1013
  .setValue(objectContent.frontFaceVisible ? 'true' : 'false')
1014
1014
  .setType('boolean')
1015
- .setLabel(_('Show front face'))
1016
- .setGroup(_('Face visibility'));
1015
+ .setLabel(_('Front face'))
1016
+ .setGroup(_('Face visibility'))
1017
+ .setAdvanced(true);
1017
1018
 
1018
1019
  objectProperties
1019
1020
  .getOrCreate('backFaceVisible')
1020
1021
  .setValue(objectContent.backFaceVisible ? 'true' : 'false')
1021
1022
  .setType('boolean')
1022
- .setLabel(_('Show back face'))
1023
- .setGroup(_('Face visibility'));
1023
+ .setLabel(_('Back face'))
1024
+ .setGroup(_('Face visibility'))
1025
+ .setAdvanced(true);
1024
1026
 
1025
1027
  objectProperties
1026
1028
  .getOrCreate('leftFaceVisible')
1027
1029
  .setValue(objectContent.leftFaceVisible ? 'true' : 'false')
1028
1030
  .setType('boolean')
1029
- .setLabel(_('Show left face'))
1030
- .setGroup(_('Face visibility'));
1031
+ .setLabel(_('Left face'))
1032
+ .setGroup(_('Face visibility'))
1033
+ .setAdvanced(true);
1031
1034
 
1032
1035
  objectProperties
1033
1036
  .getOrCreate('rightFaceVisible')
1034
1037
  .setValue(objectContent.rightFaceVisible ? 'true' : 'false')
1035
1038
  .setType('boolean')
1036
- .setLabel(_('Show right face'))
1037
- .setGroup(_('Face visibility'));
1039
+ .setLabel(_('Right face'))
1040
+ .setGroup(_('Face visibility'))
1041
+ .setAdvanced(true);
1038
1042
 
1039
1043
  objectProperties
1040
1044
  .getOrCreate('topFaceVisible')
1041
1045
  .setValue(objectContent.topFaceVisible ? 'true' : 'false')
1042
1046
  .setType('boolean')
1043
- .setLabel(_('Show top face'))
1044
- .setGroup(_('Face visibility'));
1047
+ .setLabel(_('Top face'))
1048
+ .setGroup(_('Face visibility'))
1049
+ .setAdvanced(true);
1045
1050
 
1046
1051
  objectProperties
1047
1052
  .getOrCreate('bottomFaceVisible')
1048
1053
  .setValue(objectContent.bottomFaceVisible ? 'true' : 'false')
1049
1054
  .setType('boolean')
1050
- .setLabel(_('Show bottom face'))
1051
- .setGroup(_('Face visibility'));
1055
+ .setLabel(_('Bottom face'))
1056
+ .setGroup(_('Face visibility'))
1057
+ .setAdvanced(true);
1052
1058
 
1053
1059
  objectProperties
1054
1060
  .getOrCreate('materialType')
@@ -1060,38 +1066,35 @@ module.exports = {
1060
1066
 
1061
1067
  return objectProperties;
1062
1068
  };
1063
- Cube3DObject.setRawJSONContent(
1064
- JSON.stringify({
1065
- width: 100,
1066
- height: 100,
1067
- depth: 100,
1068
- enableTextureTransparency: false,
1069
- facesOrientation: 'Y',
1070
- frontFaceResourceName: '',
1071
- backFaceResourceName: '',
1072
- backFaceUpThroughWhichAxisRotation: 'X',
1073
- leftFaceResourceName: '',
1074
- rightFaceResourceName: '',
1075
- topFaceResourceName: '',
1076
- bottomFaceResourceName: '',
1077
- frontFaceVisible: true,
1078
- backFaceVisible: false,
1079
- leftFaceVisible: true,
1080
- rightFaceVisible: true,
1081
- topFaceVisible: true,
1082
- bottomFaceVisible: true,
1083
- frontFaceResourceRepeat: false,
1084
- backFaceResourceRepeat: false,
1085
- leftFaceResourceRepeat: false,
1086
- rightFaceResourceRepeat: false,
1087
- topFaceResourceRepeat: false,
1088
- bottomFaceResourceRepeat: false,
1089
- materialType: 'Basic',
1090
- })
1091
- );
1069
+ Cube3DObject.content = {
1070
+ width: 100,
1071
+ height: 100,
1072
+ depth: 100,
1073
+ enableTextureTransparency: false,
1074
+ facesOrientation: 'Y',
1075
+ frontFaceResourceName: '',
1076
+ backFaceResourceName: '',
1077
+ backFaceUpThroughWhichAxisRotation: 'X',
1078
+ leftFaceResourceName: '',
1079
+ rightFaceResourceName: '',
1080
+ topFaceResourceName: '',
1081
+ bottomFaceResourceName: '',
1082
+ frontFaceVisible: true,
1083
+ backFaceVisible: false,
1084
+ leftFaceVisible: true,
1085
+ rightFaceVisible: true,
1086
+ topFaceVisible: true,
1087
+ bottomFaceVisible: true,
1088
+ frontFaceResourceRepeat: false,
1089
+ backFaceResourceRepeat: false,
1090
+ leftFaceResourceRepeat: false,
1091
+ rightFaceResourceRepeat: false,
1092
+ topFaceResourceRepeat: false,
1093
+ bottomFaceResourceRepeat: false,
1094
+ materialType: 'Basic',
1095
+ };
1092
1096
 
1093
1097
  Cube3DObject.updateInitialInstanceProperty = function (
1094
- objectContent,
1095
1098
  instance,
1096
1099
  propertyName,
1097
1100
  newValue
@@ -1099,7 +1102,7 @@ module.exports = {
1099
1102
  return false;
1100
1103
  };
1101
1104
 
1102
- Cube3DObject.getInitialInstanceProperties = function (content, instance) {
1105
+ Cube3DObject.getInitialInstanceProperties = function (instance) {
1103
1106
  const instanceProperties = new gd.MapStringPropertyDescriptor();
1104
1107
  return instanceProperties;
1105
1108
  };
@@ -2060,7 +2063,10 @@ module.exports = {
2060
2063
  };
2061
2064
 
2062
2065
  const getFirstVisibleFaceResourceName = (objectConfiguration) => {
2063
- const properties = objectConfiguration.getProperties();
2066
+ const object = gd.castObject(
2067
+ objectConfiguration,
2068
+ gd.ObjectJsImplementation
2069
+ );
2064
2070
 
2065
2071
  const orderedFaces = [
2066
2072
  ['frontFaceVisible', 'frontFaceResourceName'],
@@ -2075,10 +2081,8 @@ module.exports = {
2075
2081
  faceVisibleProperty,
2076
2082
  faceResourceNameProperty,
2077
2083
  ] of orderedFaces) {
2078
- if (properties.get(faceVisibleProperty).getValue() === 'true') {
2079
- const textureResource = properties
2080
- .get(faceResourceNameProperty)
2081
- .getValue();
2084
+ if (object.content[faceVisibleProperty]) {
2085
+ const textureResource = object.content[faceResourceNameProperty];
2082
2086
  if (textureResource) return textureResource;
2083
2087
  }
2084
2088
  }
@@ -2124,10 +2128,14 @@ module.exports = {
2124
2128
  // Name of the resource that is rendered.
2125
2129
  // If no face is visible, this will be null.
2126
2130
  this._renderedResourceName = undefined;
2127
- const properties = associatedObjectConfiguration.getProperties();
2128
- this._defaultWidth = parseFloat(properties.get('width').getValue());
2129
- this._defaultHeight = parseFloat(properties.get('height').getValue());
2130
- this._defaultDepth = parseFloat(properties.get('depth').getValue());
2131
+
2132
+ const object = gd.castObject(
2133
+ this._associatedObjectConfiguration,
2134
+ gd.ObjectJsImplementation
2135
+ );
2136
+ this._defaultWidth = object.content.width;
2137
+ this._defaultHeight = object.content.height;
2138
+ this._defaultDepth = object.content.depth;
2131
2139
 
2132
2140
  this._pixiObject = new PIXI.Container();
2133
2141
  this._pixiFallbackObject = new PIXI.Graphics();
@@ -2195,6 +2203,8 @@ module.exports = {
2195
2203
  if (!texture.baseTexture.valid) {
2196
2204
  // Post pone texture update if texture is not loaded.
2197
2205
  texture.once('update', () => {
2206
+ if (this._wasDestroyed) return;
2207
+
2198
2208
  this.updateTexture();
2199
2209
  this.updatePIXISprite();
2200
2210
  });
@@ -2216,8 +2226,14 @@ module.exports = {
2216
2226
  this._centerY / objectTextureFrame.height;
2217
2227
 
2218
2228
  this._pixiTexturedObject.angle = this._instance.getAngle();
2219
- this._pixiTexturedObject.scale.x = width / objectTextureFrame.width;
2220
- this._pixiTexturedObject.scale.y = height / objectTextureFrame.height;
2229
+ const scaleX =
2230
+ (width / objectTextureFrame.width) *
2231
+ (this._instance.isFlippedX() ? -1 : 1);
2232
+ const scaleY =
2233
+ (height / objectTextureFrame.height) *
2234
+ (this._instance.isFlippedY() ? -1 : 1);
2235
+ this._pixiTexturedObject.scale.x = scaleX;
2236
+ this._pixiTexturedObject.scale.y = scaleY;
2221
2237
 
2222
2238
  this._pixiTexturedObject.position.x =
2223
2239
  this._instance.getX() +
@@ -2244,6 +2260,9 @@ module.exports = {
2244
2260
  this._pixiFallbackObject.position.y =
2245
2261
  this._instance.getY() + height / 2;
2246
2262
  this._pixiFallbackObject.angle = this._instance.getAngle();
2263
+
2264
+ if (this._instance.isFlippedX()) this._pixiFallbackObject.scale.x = -1;
2265
+ if (this._instance.isFlippedY()) this._pixiFallbackObject.scale.y = -1;
2247
2266
  }
2248
2267
 
2249
2268
  update() {
@@ -2306,70 +2325,68 @@ module.exports = {
2306
2325
  pixiResourcesLoader
2307
2326
  );
2308
2327
 
2309
- const properties = associatedObjectConfiguration.getProperties();
2310
- this._defaultWidth = parseFloat(properties.get('width').getValue());
2311
- this._defaultHeight = parseFloat(properties.get('height').getValue());
2312
- this._defaultDepth = parseFloat(properties.get('depth').getValue());
2328
+ this._defaultWidth = 1;
2329
+ this._defaultHeight = 1;
2330
+ this._defaultDepth = 1;
2313
2331
 
2314
2332
  this._pixiObject = new PIXI.Graphics();
2315
2333
  this._pixiContainer.addChild(this._pixiObject);
2316
2334
 
2317
- this._faceResourceNames = [
2318
- properties.get('frontFaceResourceName').getValue(),
2319
- properties.get('backFaceResourceName').getValue(),
2320
- properties.get('leftFaceResourceName').getValue(),
2321
- properties.get('rightFaceResourceName').getValue(),
2322
- properties.get('topFaceResourceName').getValue(),
2323
- properties.get('bottomFaceResourceName').getValue(),
2324
- ];
2325
- this._faceVisibilities = [
2326
- properties.get('frontFaceVisible').getValue() === 'true',
2327
- properties.get('backFaceVisible').getValue() === 'true',
2328
- properties.get('leftFaceVisible').getValue() === 'true',
2329
- properties.get('rightFaceVisible').getValue() === 'true',
2330
- properties.get('topFaceVisible').getValue() === 'true',
2331
- properties.get('bottomFaceVisible').getValue() === 'true',
2332
- ];
2333
- this._shouldRepeatTextureOnFace = [
2334
- properties.get('frontFaceResourceRepeat').getValue() === 'true',
2335
- properties.get('backFaceResourceRepeat').getValue() === 'true',
2336
- properties.get('leftFaceResourceRepeat').getValue() === 'true',
2337
- properties.get('rightFaceResourceRepeat').getValue() === 'true',
2338
- properties.get('topFaceResourceRepeat').getValue() === 'true',
2339
- properties.get('bottomFaceResourceRepeat').getValue() === 'true',
2340
- ];
2341
- this._facesOrientation = properties.get('facesOrientation').getValue();
2342
- this._backFaceUpThroughWhichAxisRotation = properties
2343
- .get('backFaceUpThroughWhichAxisRotation')
2344
- .getValue();
2345
- this._shouldUseTransparentTexture =
2346
- properties.get('enableTextureTransparency').getValue() === 'true';
2335
+ this._faceResourceNames = ['', '', '', '', '', ''];
2336
+ this._faceVisibilities = [true, true, true, true, true, true];
2337
+ this._shouldRepeatTextureOnFace = [true, true, true, true, true, true];
2338
+ this._facesOrientation = 'Y';
2339
+ this._backFaceUpThroughWhichAxisRotation = 'X';
2340
+ this._shouldUseTransparentTexture = false;
2347
2341
 
2348
2342
  const geometry = new THREE.BoxGeometry(1, 1, 1);
2349
2343
  const materials = [
2350
- this._getFaceMaterial(project, materialIndexToFaceIndex[0]),
2351
- this._getFaceMaterial(project, materialIndexToFaceIndex[1]),
2352
- this._getFaceMaterial(project, materialIndexToFaceIndex[2]),
2353
- this._getFaceMaterial(project, materialIndexToFaceIndex[3]),
2354
- this._getFaceMaterial(project, materialIndexToFaceIndex[4]),
2355
- this._getFaceMaterial(project, materialIndexToFaceIndex[5]),
2344
+ getTransparentMaterial(),
2345
+ getTransparentMaterial(),
2346
+ getTransparentMaterial(),
2347
+ getTransparentMaterial(),
2348
+ getTransparentMaterial(),
2349
+ getTransparentMaterial(),
2356
2350
  ];
2357
2351
  this._threeObject = new THREE.Mesh(geometry, materials);
2358
2352
  this._threeObject.rotation.order = 'ZYX';
2359
-
2360
2353
  this._threeGroup.add(this._threeObject);
2354
+
2355
+ this.updateThreeObject();
2361
2356
  }
2362
2357
 
2363
- _getFaceMaterial(project, faceIndex) {
2364
- if (!this._faceVisibilities[faceIndex]) return getTransparentMaterial();
2358
+ async _updateThreeObjectMaterials() {
2359
+ const getFaceMaterial = async (project, faceIndex) => {
2360
+ if (!this._faceVisibilities[faceIndex])
2361
+ return getTransparentMaterial();
2365
2362
 
2366
- return this._pixiResourcesLoader.getThreeMaterial(
2367
- project,
2368
- this._faceResourceNames[faceIndex],
2369
- {
2370
- useTransparentTexture: this._shouldUseTransparentTexture,
2371
- }
2372
- );
2363
+ return await this._pixiResourcesLoader.getThreeMaterial(
2364
+ project,
2365
+ this._faceResourceNames[faceIndex],
2366
+ {
2367
+ useTransparentTexture: this._shouldUseTransparentTexture,
2368
+ }
2369
+ );
2370
+ };
2371
+
2372
+ const materials = await Promise.all([
2373
+ getFaceMaterial(this._project, materialIndexToFaceIndex[0]),
2374
+ getFaceMaterial(this._project, materialIndexToFaceIndex[1]),
2375
+ getFaceMaterial(this._project, materialIndexToFaceIndex[2]),
2376
+ getFaceMaterial(this._project, materialIndexToFaceIndex[3]),
2377
+ getFaceMaterial(this._project, materialIndexToFaceIndex[4]),
2378
+ getFaceMaterial(this._project, materialIndexToFaceIndex[5]),
2379
+ ]);
2380
+ if (this._wasDestroyed) return;
2381
+
2382
+ this._threeObject.material[0] = materials[0];
2383
+ this._threeObject.material[1] = materials[1];
2384
+ this._threeObject.material[2] = materials[2];
2385
+ this._threeObject.material[3] = materials[3];
2386
+ this._threeObject.material[4] = materials[4];
2387
+ this._threeObject.material[5] = materials[5];
2388
+
2389
+ this._updateTextureUvMapping();
2373
2390
  }
2374
2391
 
2375
2392
  static _getResourceNameToDisplay(objectConfiguration) {
@@ -2377,6 +2394,15 @@ module.exports = {
2377
2394
  }
2378
2395
 
2379
2396
  updateThreeObject() {
2397
+ const object = gd.castObject(
2398
+ this._associatedObjectConfiguration,
2399
+ gd.ObjectJsImplementation
2400
+ );
2401
+
2402
+ this._defaultWidth = object.content.width;
2403
+ this._defaultHeight = object.content.height;
2404
+ this._defaultDepth = object.content.depth;
2405
+
2380
2406
  const width = this.getWidth();
2381
2407
  const height = this.getHeight();
2382
2408
  const depth = this.getDepth();
@@ -2393,14 +2419,107 @@ module.exports = {
2393
2419
  RenderedInstance.toRad(this._instance.getAngle())
2394
2420
  );
2395
2421
 
2422
+ let materialsDirty = false;
2423
+ let uvMappingDirty = false;
2424
+
2425
+ const shouldUseTransparentTexture =
2426
+ object.content.enableTextureTransparency;
2427
+ if (this._shouldUseTransparentTexture !== shouldUseTransparentTexture) {
2428
+ this._shouldUseTransparentTexture = shouldUseTransparentTexture;
2429
+ materialsDirty = true;
2430
+ }
2431
+
2432
+ const faceResourceNames = [
2433
+ object.content.frontFaceResourceName,
2434
+ object.content.backFaceResourceName,
2435
+ object.content.leftFaceResourceName,
2436
+ object.content.rightFaceResourceName,
2437
+ object.content.topFaceResourceName,
2438
+ object.content.bottomFaceResourceName,
2439
+ ];
2440
+ if (
2441
+ this._faceResourceNames[0] !== faceResourceNames[0] ||
2442
+ this._faceResourceNames[1] !== faceResourceNames[1] ||
2443
+ this._faceResourceNames[2] !== faceResourceNames[2] ||
2444
+ this._faceResourceNames[3] !== faceResourceNames[3] ||
2445
+ this._faceResourceNames[4] !== faceResourceNames[4] ||
2446
+ this._faceResourceNames[5] !== faceResourceNames[5]
2447
+ ) {
2448
+ this._faceResourceNames = faceResourceNames;
2449
+ materialsDirty = true;
2450
+ }
2451
+
2452
+ const faceVisibilities = [
2453
+ object.content.frontFaceVisible,
2454
+ object.content.backFaceVisible,
2455
+ object.content.leftFaceVisible,
2456
+ object.content.rightFaceVisible,
2457
+ object.content.topFaceVisible,
2458
+ object.content.bottomFaceVisible,
2459
+ ];
2396
2460
  if (
2397
- width !== this._threeObject.scale.width ||
2398
- height !== this._threeObject.scale.height ||
2399
- depth !== this._threeObject.scale.depth
2461
+ this._faceVisibilities[0] !== faceVisibilities[0] ||
2462
+ this._faceVisibilities[1] !== faceVisibilities[1] ||
2463
+ this._faceVisibilities[2] !== faceVisibilities[2] ||
2464
+ this._faceVisibilities[3] !== faceVisibilities[3] ||
2465
+ this._faceVisibilities[4] !== faceVisibilities[4] ||
2466
+ this._faceVisibilities[5] !== faceVisibilities[5]
2400
2467
  ) {
2401
- this._threeObject.scale.set(width, height, depth);
2402
- this.updateTextureUvMapping();
2468
+ this._faceVisibilities = faceVisibilities;
2469
+ materialsDirty = true;
2470
+ uvMappingDirty = true;
2403
2471
  }
2472
+
2473
+ const shouldRepeatTextureOnFace = [
2474
+ object.content.frontFaceResourceRepeat,
2475
+ object.content.backFaceResourceRepeat,
2476
+ object.content.leftFaceResourceRepeat,
2477
+ object.content.rightFaceResourceRepeat,
2478
+ object.content.topFaceResourceRepeat,
2479
+ object.content.bottomFaceResourceRepeat,
2480
+ ];
2481
+ if (
2482
+ this._shouldRepeatTextureOnFace[0] !== shouldRepeatTextureOnFace[0] ||
2483
+ this._shouldRepeatTextureOnFace[1] !== shouldRepeatTextureOnFace[1] ||
2484
+ this._shouldRepeatTextureOnFace[2] !== shouldRepeatTextureOnFace[2] ||
2485
+ this._shouldRepeatTextureOnFace[3] !== shouldRepeatTextureOnFace[3] ||
2486
+ this._shouldRepeatTextureOnFace[4] !== shouldRepeatTextureOnFace[4] ||
2487
+ this._shouldRepeatTextureOnFace[5] !== shouldRepeatTextureOnFace[5]
2488
+ ) {
2489
+ this._shouldRepeatTextureOnFace = shouldRepeatTextureOnFace;
2490
+ uvMappingDirty = true;
2491
+ }
2492
+
2493
+ const backFaceUpThroughWhichAxisRotation =
2494
+ object.content.backFaceUpThroughWhichAxisRotation;
2495
+ if (
2496
+ backFaceUpThroughWhichAxisRotation !==
2497
+ this._backFaceUpThroughWhichAxisRotation
2498
+ ) {
2499
+ this._backFaceUpThroughWhichAxisRotation = backFaceUpThroughWhichAxisRotation;
2500
+ uvMappingDirty = true;
2501
+ }
2502
+
2503
+ const facesOrientation = object.content.facesOrientation;
2504
+ if (facesOrientation !== this._facesOrientation) {
2505
+ this._facesOrientation = facesOrientation;
2506
+ uvMappingDirty = true;
2507
+ }
2508
+
2509
+ const scaleX = width * (this._instance.isFlippedX() ? -1 : 1);
2510
+ const scaleY = height * (this._instance.isFlippedY() ? -1 : 1);
2511
+ const scaleZ = depth * (this._instance.isFlippedZ() ? -1 : 1);
2512
+ if (
2513
+ scaleX !== this._threeObject.scale.x ||
2514
+ scaleY !== this._threeObject.scale.y ||
2515
+ scaleZ !== this._threeObject.scale.z
2516
+ ) {
2517
+ this._threeObject.scale.set(scaleX, scaleY, scaleZ);
2518
+ uvMappingDirty = true;
2519
+ }
2520
+
2521
+ if (materialsDirty) this._updateThreeObjectMaterials();
2522
+ if (uvMappingDirty) this._updateTextureUvMapping();
2404
2523
  }
2405
2524
 
2406
2525
  /**
@@ -2409,7 +2528,7 @@ module.exports = {
2409
2528
  * The mesh must be configured with a list of materials in order
2410
2529
  * for the method to work.
2411
2530
  */
2412
- updateTextureUvMapping() {
2531
+ _updateTextureUvMapping() {
2413
2532
  // @ts-ignore - position is stored as a Float32BufferAttribute
2414
2533
  /** @type {THREE.BufferAttribute} */
2415
2534
  const pos = this._threeObject.geometry.getAttribute('position');
@@ -2683,25 +2802,23 @@ module.exports = {
2683
2802
  pixiContainer,
2684
2803
  pixiResourcesLoader
2685
2804
  );
2686
- const properties = associatedObjectConfiguration.getProperties();
2687
- this._defaultWidth = parseFloat(properties.get('width').getValue());
2688
- this._defaultHeight = parseFloat(properties.get('height').getValue());
2689
- this._defaultDepth = parseFloat(properties.get('depth').getValue());
2690
- const rotationX = parseFloat(properties.get('rotationX').getValue());
2691
- const rotationY = parseFloat(properties.get('rotationY').getValue());
2692
- const rotationZ = parseFloat(properties.get('rotationZ').getValue());
2693
- const keepAspectRatio =
2694
- properties.get('keepAspectRatio').getValue() === 'true';
2695
- const modelResourceName = properties
2696
- .get('modelResourceName')
2697
- .getValue();
2698
- this._originPoint = getPointForLocation(
2699
- properties.get('originLocation').getValue()
2700
- );
2701
- this._centerPoint = getPointForLocation(
2702
- properties.get('centerLocation').getValue()
2805
+ const object = gd.castObject(
2806
+ this._associatedObjectConfiguration,
2807
+ gd.Model3DObjectConfiguration
2703
2808
  );
2704
2809
 
2810
+ this._defaultWidth = object.getWidth();
2811
+ this._defaultHeight = object.getHeight();
2812
+ this._defaultDepth = object.getDepth();
2813
+ const rotationX = object.getRotationX();
2814
+ const rotationY = object.getRotationY();
2815
+ const rotationZ = object.getRotationZ();
2816
+ const keepAspectRatio = object.shouldKeepAspectRatio();
2817
+ const modelResourceName = object.getModelResourceName();
2818
+
2819
+ this._originPoint = getPointForLocation(object.getOriginLocation());
2820
+ this._centerPoint = getPointForLocation(object.getCenterLocation());
2821
+
2705
2822
  // This renderer shows a placeholder for the object:
2706
2823
  this._pixiObject = new PIXI.Graphics();
2707
2824
  this._pixiContainer.addChild(this._pixiObject);
@@ -2709,6 +2826,7 @@ module.exports = {
2709
2826
  this._pixiResourcesLoader
2710
2827
  .get3DModel(project, modelResourceName)
2711
2828
  .then((model3d) => {
2829
+ if (this._wasDestroyed) return;
2712
2830
  const clonedModel3D = THREE_ADDONS.SkeletonUtils.clone(
2713
2831
  model3d.scene
2714
2832
  );
@@ -2910,6 +3028,17 @@ module.exports = {
2910
3028
  }
2911
3029
  }
2912
3030
 
3031
+ const isSamePoint = (point1, point2) => {
3032
+ if (!point1 && !point2) return true;
3033
+ if (point1 && !point2) return false;
3034
+ if (!point1 && point2) return false;
3035
+ return (
3036
+ point1[0] === point2[0] &&
3037
+ point1[1] === point2[1] &&
3038
+ point1[2] === point2[2]
3039
+ );
3040
+ };
3041
+
2913
3042
  const getPointForLocation = (location) => {
2914
3043
  switch (location) {
2915
3044
  case 'ModelOrigin':
@@ -2946,24 +3075,20 @@ module.exports = {
2946
3075
  threeGroup,
2947
3076
  pixiResourcesLoader
2948
3077
  );
2949
- const properties = associatedObjectConfiguration.getProperties();
2950
- this._defaultWidth = parseFloat(properties.get('width').getValue());
2951
- this._defaultHeight = parseFloat(properties.get('height').getValue());
2952
- this._defaultDepth = parseFloat(properties.get('depth').getValue());
2953
- const rotationX = parseFloat(properties.get('rotationX').getValue());
2954
- const rotationY = parseFloat(properties.get('rotationY').getValue());
2955
- const rotationZ = parseFloat(properties.get('rotationZ').getValue());
2956
- const keepAspectRatio =
2957
- properties.get('keepAspectRatio').getValue() === 'true';
2958
- const modelResourceName = properties
2959
- .get('modelResourceName')
2960
- .getValue();
2961
- this._originPoint = getPointForLocation(
2962
- properties.get('originLocation').getValue()
2963
- );
2964
- this._centerPoint = getPointForLocation(
2965
- properties.get('centerLocation').getValue()
2966
- );
3078
+
3079
+ this._defaultWidth = 1;
3080
+ this._defaultHeight = 1;
3081
+ this._defaultDepth = 1;
3082
+ this._originalWidth = 1;
3083
+ this._originalHeight = 1;
3084
+ this._originalDepth = 1;
3085
+ this._rotationX = 0;
3086
+ this._rotationY = 0;
3087
+ this._rotationZ = 0;
3088
+ this._keepAspectRatio = false;
3089
+
3090
+ this._originPoint = null;
3091
+ this._centerPoint = null;
2967
3092
 
2968
3093
  this._pixiObject = new PIXI.Graphics();
2969
3094
  this._pixiContainer.addChild(this._pixiObject);
@@ -2972,28 +3097,8 @@ module.exports = {
2972
3097
  this._threeObject.rotation.order = 'ZYX';
2973
3098
  this._threeGroup.add(this._threeObject);
2974
3099
 
2975
- this._pixiResourcesLoader
2976
- .get3DModel(project, modelResourceName)
2977
- .then((model3d) => {
2978
- const clonedModel3D = THREE_ADDONS.SkeletonUtils.clone(
2979
- model3d.scene
2980
- );
2981
- // This group hold the rotation defined by properties.
2982
- const threeObject = new THREE.Group();
2983
- threeObject.rotation.order = 'ZYX';
2984
- threeObject.add(clonedModel3D);
2985
- this._updateDefaultTransformation(
2986
- threeObject,
2987
- rotationX,
2988
- rotationY,
2989
- rotationZ,
2990
- this._defaultWidth,
2991
- this._defaultHeight,
2992
- this._defaultDepth,
2993
- keepAspectRatio
2994
- );
2995
- this._threeObject.add(threeObject);
2996
- });
3100
+ this._threeModelGroup = null;
3101
+ this._clonedModel3D = null;
2997
3102
  }
2998
3103
 
2999
3104
  getOriginX() {
@@ -3034,23 +3139,28 @@ module.exports = {
3034
3139
  return this._centerPoint || this._modelOriginPoint;
3035
3140
  }
3036
3141
 
3037
- _updateDefaultTransformation(
3038
- threeObject,
3039
- rotationX,
3040
- rotationY,
3041
- rotationZ,
3042
- originalWidth,
3043
- originalHeight,
3044
- originalDepth,
3045
- keepAspectRatio
3046
- ) {
3047
- threeObject.rotation.set(
3048
- (rotationX * Math.PI) / 180,
3049
- (rotationY * Math.PI) / 180,
3050
- (rotationZ * Math.PI) / 180
3142
+ _updateDefaultTransformation() {
3143
+ if (!this._clonedModel3D) return; // Model is not ready - nothing to do.
3144
+
3145
+ if (this._threeModelGroup) {
3146
+ // Remove any previous container as we will recreate it just below
3147
+ this._threeObject.clear();
3148
+ }
3149
+ // This group hold the rotation defined by properties.
3150
+ // Always restart from a new group to avoid miscomputing bounding boxes/sizes.
3151
+ this._threeModelGroup = new THREE.Group();
3152
+ this._threeModelGroup.rotation.order = 'ZYX';
3153
+ this._threeModelGroup.add(this._clonedModel3D);
3154
+
3155
+ this._threeModelGroup.rotation.set(
3156
+ (this._rotationX * Math.PI) / 180,
3157
+ (this._rotationY * Math.PI) / 180,
3158
+ (this._rotationZ * Math.PI) / 180
3159
+ );
3160
+ this._threeModelGroup.updateMatrixWorld(true);
3161
+ const boundingBox = new THREE.Box3().setFromObject(
3162
+ this._threeModelGroup
3051
3163
  );
3052
- threeObject.updateMatrixWorld(true);
3053
- const boundingBox = new THREE.Box3().setFromObject(threeObject);
3054
3164
 
3055
3165
  const shouldKeepModelOrigin = !this._originPoint;
3056
3166
  if (shouldKeepModelOrigin) {
@@ -3077,7 +3187,7 @@ module.exports = {
3077
3187
  // Center the model.
3078
3188
  const centerPoint = this._centerPoint;
3079
3189
  if (centerPoint) {
3080
- threeObject.position.set(
3190
+ this._threeModelGroup.position.set(
3081
3191
  -(boundingBox.min.x + modelWidth * centerPoint[0]),
3082
3192
  // The model is flipped on Y axis.
3083
3193
  -(boundingBox.min.y + modelHeight * (1 - centerPoint[1])),
@@ -3086,11 +3196,11 @@ module.exports = {
3086
3196
  }
3087
3197
 
3088
3198
  // Rotate the model.
3089
- threeObject.scale.set(1, 1, 1);
3090
- threeObject.rotation.set(
3091
- (rotationX * Math.PI) / 180,
3092
- (rotationY * Math.PI) / 180,
3093
- (rotationZ * Math.PI) / 180
3199
+ this._threeModelGroup.scale.set(1, 1, 1);
3200
+ this._threeModelGroup.rotation.set(
3201
+ (this._rotationX * Math.PI) / 180,
3202
+ (this._rotationY * Math.PI) / 180,
3203
+ (this._rotationZ * Math.PI) / 180
3094
3204
  );
3095
3205
 
3096
3206
  // Stretch the model in a 1x1x1 cube.
@@ -3102,23 +3212,23 @@ module.exports = {
3102
3212
  // Flip on Y because the Y axis is on the opposite side of direct basis.
3103
3213
  // It avoids models to be like a mirror refection.
3104
3214
  scaleMatrix.makeScale(scaleX, -scaleY, scaleZ);
3105
- threeObject.updateMatrix();
3106
- threeObject.applyMatrix4(scaleMatrix);
3215
+ this._threeModelGroup.updateMatrix();
3216
+ this._threeModelGroup.applyMatrix4(scaleMatrix);
3107
3217
 
3108
- if (keepAspectRatio) {
3218
+ if (this._keepAspectRatio) {
3109
3219
  // Reduce the object dimensions to keep aspect ratio.
3110
3220
  const widthRatio =
3111
3221
  modelWidth < epsilon
3112
3222
  ? Number.POSITIVE_INFINITY
3113
- : originalWidth / modelWidth;
3223
+ : this._originalWidth / modelWidth;
3114
3224
  const heightRatio =
3115
3225
  modelHeight < epsilon
3116
3226
  ? Number.POSITIVE_INFINITY
3117
- : originalHeight / modelHeight;
3227
+ : this._originalHeight / modelHeight;
3118
3228
  const depthRatio =
3119
3229
  modelDepth < epsilon
3120
3230
  ? Number.POSITIVE_INFINITY
3121
- : originalDepth / modelDepth;
3231
+ : this._originalDepth / modelDepth;
3122
3232
  const minScaleRatio = Math.min(widthRatio, heightRatio, depthRatio);
3123
3233
  if (!Number.isFinite(minScaleRatio)) {
3124
3234
  this._defaultWidth = modelWidth;
@@ -3126,48 +3236,125 @@ module.exports = {
3126
3236
  this._defaultDepth = modelDepth;
3127
3237
  } else {
3128
3238
  if (widthRatio === minScaleRatio) {
3129
- this._defaultWidth = originalWidth;
3239
+ this._defaultWidth = this._originalWidth;
3130
3240
  this._defaultHeight = Rendered3DInstance.applyRatio({
3131
3241
  oldReferenceValue: modelWidth,
3132
- newReferenceValue: originalWidth,
3242
+ newReferenceValue: this._originalWidth,
3133
3243
  valueToApplyTo: modelHeight,
3134
3244
  });
3135
3245
  this._defaultDepth = Rendered3DInstance.applyRatio({
3136
3246
  oldReferenceValue: modelWidth,
3137
- newReferenceValue: originalWidth,
3247
+ newReferenceValue: this._originalWidth,
3138
3248
  valueToApplyTo: modelDepth,
3139
3249
  });
3140
3250
  } else if (heightRatio === minScaleRatio) {
3141
3251
  this._defaultWidth = Rendered3DInstance.applyRatio({
3142
3252
  oldReferenceValue: modelHeight,
3143
- newReferenceValue: originalHeight,
3253
+ newReferenceValue: this._originalHeight,
3144
3254
  valueToApplyTo: modelWidth,
3145
3255
  });
3146
3256
 
3147
- this._defaultHeight = originalHeight;
3257
+ this._defaultHeight = this._originalHeight;
3148
3258
  this._defaultDepth = Rendered3DInstance.applyRatio({
3149
3259
  oldReferenceValue: modelHeight,
3150
- newReferenceValue: originalHeight,
3260
+ newReferenceValue: this._originalHeight,
3151
3261
  valueToApplyTo: modelDepth,
3152
3262
  });
3153
3263
  } else {
3154
3264
  this._defaultWidth = Rendered3DInstance.applyRatio({
3155
3265
  oldReferenceValue: modelDepth,
3156
- newReferenceValue: originalDepth,
3266
+ newReferenceValue: this._originalDepth,
3157
3267
  valueToApplyTo: modelWidth,
3158
3268
  });
3159
3269
  this._defaultHeight = Rendered3DInstance.applyRatio({
3160
3270
  oldReferenceValue: modelDepth,
3161
- newReferenceValue: originalDepth,
3271
+ newReferenceValue: this._originalDepth,
3162
3272
  valueToApplyTo: modelHeight,
3163
3273
  });
3164
- this._defaultDepth = originalDepth;
3274
+ this._defaultDepth = this._originalDepth;
3165
3275
  }
3166
3276
  }
3167
3277
  }
3278
+
3279
+ this._threeObject.add(this._threeModelGroup);
3168
3280
  }
3169
3281
 
3170
3282
  updateThreeObject() {
3283
+ const object = gd.castObject(
3284
+ this._associatedObjectConfiguration,
3285
+ gd.Model3DObjectConfiguration
3286
+ );
3287
+
3288
+ let defaultTransformationDirty = false;
3289
+
3290
+ const originalWidth = object.getWidth();
3291
+ const originalHeight = object.getHeight();
3292
+ const originalDepth = object.getDepth();
3293
+ if (
3294
+ this._originalWidth !== originalWidth ||
3295
+ this._originalHeight !== originalHeight ||
3296
+ this._originalDepth !== originalDepth
3297
+ ) {
3298
+ this._originalWidth = originalWidth;
3299
+ this._originalHeight = originalHeight;
3300
+ this._originalDepth = originalDepth;
3301
+ defaultTransformationDirty = true;
3302
+ }
3303
+
3304
+ const rotationX = object.getRotationX();
3305
+ const rotationY = object.getRotationY();
3306
+ const rotationZ = object.getRotationZ();
3307
+ if (
3308
+ this._rotationX !== rotationX ||
3309
+ this._rotationY !== rotationY ||
3310
+ this._rotationZ !== rotationZ
3311
+ ) {
3312
+ this._rotationX = rotationX;
3313
+ this._rotationY = rotationY;
3314
+ this._rotationZ = rotationZ;
3315
+ defaultTransformationDirty = true;
3316
+ }
3317
+
3318
+ const keepAspectRatio = object.shouldKeepAspectRatio();
3319
+ if (this._keepAspectRatio !== keepAspectRatio) {
3320
+ this._keepAspectRatio = keepAspectRatio;
3321
+ defaultTransformationDirty = true;
3322
+ }
3323
+
3324
+ const originPoint = getPointForLocation(object.getOriginLocation());
3325
+ if (!isSamePoint(originPoint, this._originPoint)) {
3326
+ this._originPoint = originPoint;
3327
+ defaultTransformationDirty = true;
3328
+ }
3329
+
3330
+ const centerPoint = getPointForLocation(object.getCenterLocation());
3331
+ if (!isSamePoint(centerPoint, this._centerPoint)) {
3332
+ this._centerPoint = centerPoint;
3333
+ defaultTransformationDirty = true;
3334
+ }
3335
+
3336
+ if (defaultTransformationDirty) this._updateDefaultTransformation();
3337
+
3338
+ const modelResourceName = object.getModelResourceName();
3339
+ if (this._modelResourceName !== modelResourceName) {
3340
+ this._modelResourceName = modelResourceName;
3341
+
3342
+ this._pixiResourcesLoader
3343
+ .get3DModel(this._project, modelResourceName)
3344
+ .then((model3d) => {
3345
+ if (this._wasDestroyed) return;
3346
+ this._clonedModel3D = THREE_ADDONS.SkeletonUtils.clone(
3347
+ model3d.scene
3348
+ );
3349
+
3350
+ this._updateDefaultTransformation();
3351
+ });
3352
+ }
3353
+
3354
+ this._updateThreeObjectPosition();
3355
+ }
3356
+
3357
+ _updateThreeObjectPosition() {
3171
3358
  const width = this.getWidth();
3172
3359
  const height = this.getHeight();
3173
3360
  const depth = this.getDepth();
@@ -3186,12 +3373,16 @@ module.exports = {
3186
3373
  RenderedInstance.toRad(this._instance.getAngle())
3187
3374
  );
3188
3375
 
3376
+ const scaleX = width * (this._instance.isFlippedX() ? -1 : 1);
3377
+ const scaleY = height * (this._instance.isFlippedY() ? -1 : 1);
3378
+ const scaleZ = depth * (this._instance.isFlippedZ() ? -1 : 1);
3379
+
3189
3380
  if (
3190
- width !== this._threeObject.scale.width ||
3191
- height !== this._threeObject.scale.height ||
3192
- depth !== this._threeObject.scale.depth
3381
+ scaleX !== this._threeObject.scale.x ||
3382
+ scaleY !== this._threeObject.scale.y ||
3383
+ scaleZ !== this._threeObject.scale.z
3193
3384
  ) {
3194
- this._threeObject.scale.set(width, height, depth);
3385
+ this._threeObject.scale.set(scaleX, scaleY, scaleZ);
3195
3386
  }
3196
3387
  }
3197
3388