Skip to content

Commit

Permalink
[Community] [WithThreeJs] Supports shadow
Browse files Browse the repository at this point in the history
Supports real-time shadow feature, etc.

The "Create 3D Scene", "Load 3D Texture", "Play 3D Sound" and "Create 3D Light" actions have been updated in version 2.0.0.  
The previous actions with the same names still work but are deprecated. (Look for the ⚠️ icon in the event.) Please use the new actions with the same names.
  • Loading branch information
PANDAKO-GitHub authored Jun 4, 2024
1 parent b4c0a06 commit 7b34c31
Showing 1 changed file with 41 additions and 47 deletions.
88 changes: 41 additions & 47 deletions extensions/community/WithThreeJS.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "WithThreeJS",
"previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/rotate-3d.svg",
"shortDescription": "Create a simple 3D scene.",
"version": "2.0.0",
"version": "2.0.1",
"description": [
"Extension for GDevelop to create simple 3D scenes. ",
"This extension is intended for easy and simple 3D rendering. It does not currently aim for realistic 3D rendering. ",
Expand All @@ -17,6 +17,10 @@
"Check out this page. ",
"[WithThreeJs Extension for GDevelop](https://pandako.itch.io/with-threejs-extension-for-gdevelop) ",
"",
"## ⚠️ Notes on updating from version 1.x.x to version 2.0.0 ",
"The \"Create 3D Scene\", \"Load 3D Texture\", \"Play 3D Sound\" and \"Create 3D Light\" actions have been updated in version 2.0.0. ",
"The previous actions with the same names still work but are deprecated. (Look for the ⚠️ icon in the event.) Please use the new actions with the same names. ",
"",
"## 🍩 Donation ",
"Currently, I'm doing development in between jobs, but if many people support me, I will be able to devote more time to the development. ",
"If you enjoy this extension, please consider [downloading the Example project file](https://pandako.itch.io/with-threejs-extension-for-gdevelop) to maintain this extension. (The Example project file will surely help you.😉) ",
Expand Down Expand Up @@ -338,6 +342,31 @@
" const AllCams = gdjs.__WithThreeJS.get(\"AllCams\");\r",
" return AllCams.get(\"Camera\" + gdjs.evtTools.common.clamp(Id, 1, 4));\r",
"});\r",
"//\r",
"gdjs.__WithThreeJS.set(\"DisposeChildren\", function(Obj) {\r",
" // テクスチャは共有している場合があるので対象外\r",
" Obj.traverse((Child) => {\r",
" // Material\r",
" if (Child.material) {\r",
" if (Array.isArray(Child.material)) {\r",
" for (let i = Child.material.length - 1; i >= 0; i--){\r",
" Child.material[i].dispose();\r",
" }\r",
" } else {\r",
" Child.material.dispose();\r",
" }\r",
" }\r",
" // Light\r",
" if (Child.isLight) {\r",
" if (Child.castShadow) {\r",
" Child.shadow.dispose();\r",
" }\r",
" Child.dispose();\r",
" }\r",
" // ObjectList\r",
" gdjs.__WithThreeJS.get(\"ObjectList\").delete(Child.name);\r",
" });\r",
"});\r",
"\r",
""
],
Expand Down Expand Up @@ -6216,26 +6245,7 @@
"}",
"//",
"// Obj.clear();",
"Obj.traverse((Child) => {",
" // Material",
" if (Child.material) {",
" if (Array.isArray(Child.material)) {",
" for (let i = Child.material.length - 1; i >= 0; i--){",
" Child.material[i].dispose();",
" }",
" } else {",
" Child.material.dispose();",
" }",
" }",
" // Light",
" if (Child.isLight) {",
" if (Child.castShadow) {",
" Child.shadow.dispose();",
" }",
" Child.dispose();",
" }",
"});",
"gdjs.__WithThreeJS.get(\"ObjectList\").delete(Id);",
"gdjs.__WithThreeJS.get(\"DisposeChildren\")(Obj);",
"Obj.removeFromParent();",
"",
""
Expand Down Expand Up @@ -9688,9 +9698,10 @@
"const Scene = gdjs.__WithThreeJS.get(\"Scene\");\r",
"const Sprite = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);\r",
"//\r",
"Sprite.material.dispose();\r",
"gdjs.__WithThreeJS.get(\"ObjectList\").delete(Id);\r",
"Sprite.removeFromParent();"
"gdjs.__WithThreeJS.get(\"DisposeChildren\")(Sprite);\r",
"Sprite.removeFromParent();\r",
"\r",
""
],
"parameterObjects": "Object",
"useStrict": true,
Expand Down Expand Up @@ -10550,8 +10561,7 @@
"const Scene = gdjs.__WithThreeJS.get(\"Scene\");\r",
"const Sprite = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);\r",
"//\r",
"Sprite.material.dispose();\r",
"gdjs.__WithThreeJS.get(\"ObjectList\").delete(Id);\r",
"gdjs.__WithThreeJS.get(\"DisposeChildren\")(Sprite);\r",
"Sprite.removeFromParent();"
],
"parameterObjects": "Object",
Expand Down Expand Up @@ -11510,8 +11520,7 @@
"// インスタンスごとなので全て削除\r",
"Texture.dispose();\r",
"Textures.delete(TextureId);\r",
"Obj.material.dispose();\r",
"gdjs.__WithThreeJS.get(\"ObjectList\").delete(Id);\r",
"gdjs.__WithThreeJS.get(\"DisposeChildren\")(Obj);\r",
"Obj.removeFromParent();\r",
"\r",
""
Expand Down Expand Up @@ -12692,14 +12701,7 @@
" Textures.delete(TBTextureId);\r",
"}\r",
"//\r",
"if (Array.isArray(Obj.material)) {\r",
" for (let i = Obj.material.length - 1; i >= 0; i--){\r",
" Obj.material[i].dispose();\r",
" }\r",
"} else {\r",
" Obj.material.dispose();\r",
"}\r",
"gdjs.__WithThreeJS.get(\"ObjectList\").delete(Id);\r",
"gdjs.__WithThreeJS.get(\"DisposeChildren\")(Obj);\r",
"Obj.removeFromParent();\r",
"\r",
""
Expand Down Expand Up @@ -14596,11 +14598,7 @@
"const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);\r",
"const CastShadow = Behavior._getCastShadow();\r",
"//\r",
"if (CastShadow) {\r",
" Obj.shadow.dispose();\r",
"}\r",
"Obj.dispose();\r",
"gdjs.__WithThreeJS.get(\"ObjectList\").delete(Id);\r",
"gdjs.__WithThreeJS.get(\"DisposeChildren\")(Obj);\r",
"Obj.removeFromParent();\r",
"\r",
""
Expand Down Expand Up @@ -15338,11 +15336,6 @@
" console.warn(\"3D Object not found.\");\r",
" return;\r",
"}\r",
"// インスタンスごとなので全て削除してOK\r",
"// material dispose\r",
"for (let i = Obj3D.material.length - 1; i >= 0; i--){\r",
" Obj3D.material[i].dispose();\r",
"}\r",
"// Texture dispose\r",
"Textures.get(Obj2D._getTextureIdTop()).dispose();\r",
"Textures.delete(Obj2D._getTextureIdTop());\r",
Expand All @@ -15356,8 +15349,9 @@
"Textures.delete(Obj2D._getTextureIdLeft());\r",
"Textures.get(Obj2D._getTextureIdRight()).dispose();\r",
"Textures.delete(Obj2D._getTextureIdRight());\r",
"// material dispose インスタンスごとなので全て削除してOK\r",
"gdjs.__WithThreeJS.get(\"DisposeChildren\")(Obj3D);\r",
"//\r",
"gdjs.__WithThreeJS.get(\"ObjectList\").delete(Id);\r",
"Obj3D.removeFromParent();\r",
"\r",
""
Expand Down

0 comments on commit 7b34c31

Please sign in to comment.