diff --git a/extensions/community/WithThreeJS.json b/extensions/community/WithThreeJS.json
index a66c9533..44d5e4e5 100644
--- a/extensions/community/WithThreeJS.json
+++ b/extensions/community/WithThreeJS.json
@@ -8,7 +8,7 @@
"name": "WithThreeJS",
"previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/rotate-3d.svg",
"shortDescription": "Create a simple 3D scene.",
- "version": "1.2.2",
+ "version": "2.0.0",
"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. ",
@@ -85,6 +85,19 @@
" gdjs.__WithThreeJS.set(\"LightIntensityScale\", Math.PI);\r",
" gdjs.__WithThreeJS.set(\"LightIntensityCandela\", 10000);//適当\r",
"}\r",
+ "gdjs.__WithThreeJS.set(\"ShadowMapSizeStringToValue\", {\"128px\": 128, \"256px\": 256, \"512px\": 512, \"1024px\": 1024, \"2048px\": 2048});\r",
+ "gdjs.__WithThreeJS.set(\"ObjectList\", new Map());\r",
+ "//\r",
+ "gdjs.__WithThreeJS.set(\"SearchObject\", function(Id) {\r",
+ " let Obj = gdjs.__WithThreeJS.get(\"ObjectList\").get(Id);\r",
+ " if (!Obj) {\r",
+ " Obj = gdjs.__WithThreeJS.get(\"Scene\").getObjectByName(Id);\r",
+ " if (Obj) {\r",
+ " gdjs.__WithThreeJS.get(\"ObjectList\").set(Id, Obj);\r",
+ " }\r",
+ " }\r",
+ " return Obj;\r",
+ "});\r",
"//\r",
"gdjs.__WithThreeJS.set(\"GetResourceFileName\", function(ResourceName, Kind) {\r",
" for (const V of gdjs.projectData.resources.resources) {\r",
@@ -94,27 +107,23 @@
" }\r",
"});\r",
"//\r",
- "gdjs.__WithThreeJS.set(\"SettingRecursiveTextures\", function(Obj, Textures) {\r",
- " let TxNum = Textures.length;\r",
- " if (Obj.isMesh || Obj.isGroup || Obj.isObject3D) {\r",
- " if (Obj.material) {\r",
- " if (Array.isArray(Obj.material)) {\r",
- " for (let i = 0; i < Obj.material.length; i++) {\r",
- " if (i < TxNum && (Obj.material[i].map !== undefined)) {\r",
- " Obj.material[i].map = Textures[i];\r",
+ "gdjs.__WithThreeJS.set(\"SetAllTextures\", function(Obj, Textures) {\r",
+ " const TxNum = Textures.length;\r",
+ " Obj.traverse((Child) => {\r",
+ " if (Child.material) {\r",
+ " if (Array.isArray(Child.material)) {\r",
+ " for (let i = 0; i < Child.material.length; i++) {\r",
+ " if (i < TxNum && (Child.material[i].map !== undefined)) {\r",
+ " Child.material[i].map = Textures[i];\r",
" }\r",
" }\r",
" } else {\r",
- " if (Obj.material.map !== undefined) {\r",
- " Obj.material.map = Textures[0];\r",
+ " if (Child.material.map !== undefined) {\r",
+ " Child.material.map = Textures[0];\r",
" }\r",
" }\r",
" }\r",
- " //\r",
- " for (let i = 0; i < Obj.children.length; i++) {\r",
- " gdjs.__WithThreeJS.get(\"SettingRecursiveTextures\")(Obj.children[i], Textures);\r",
- " }\r",
- " }\r",
+ " });\r",
"});\r",
"//\r",
"gdjs.__WithThreeJS.set(\"GetModelInfo\", function(Obj, T, Lv) {\r",
@@ -141,72 +150,41 @@
" return T;\r",
"});\r",
"//\r",
- "/*\r",
- "gdjs.__WithThreeJS.set(\"AllMaterialClone\", function(Obj, Transparent, AlphaTest, Blend, Opacity) {\r",
- " if (Obj.material) {\r",
- " if (Array.isArray(Obj.material)) {\r",
- " for (let i = 0; i < Obj.material.length; i++) {\r",
- " const CloneMaterial = Obj.material[i].clone();\r",
- " Obj.material[i] = CloneMaterial;\r",
- " Obj.material[i].transparent = Transparent;\r",
- " Obj.material[i].alphaTest = AlphaTest;\r",
- " Obj.material[i].blending = Blend;\r",
- " Obj.material[i].opacity = Opacity;\r",
- " }\r",
- " } else {\r",
- " const CloneMaterial = Obj.material.clone();\r",
- " Obj.material = CloneMaterial;\r",
- " Obj.material.transparent = Transparent;\r",
- " Obj.material.alphaTest = AlphaTest;\r",
- " Obj.material.blending = Blend;\r",
- " Obj.material.opacity = Opacity;\r",
- " }\r",
- " }\r",
- " //\r",
- " for (let i = 0; i < Obj.children.length; i++) {\r",
- " gdjs.__WithThreeJS.get(\"AllMaterialClone\")(Obj.children[i], Transparent, AlphaTest, Blend, Opacity);\r",
- " }\r",
- "});\r",
- "*/\r",
"// マテリアルのリストアップ\r",
"gdjs.__WithThreeJS.set(\"GetAllMaterials\", function(Obj, Mats) {\r",
- " if (Obj.material) {\r",
- " if (Array.isArray(Obj.material)) {\r",
- " for (let i = 0; i < Obj.material.length; i++) {\r",
- " if (!Mats.has(Obj.material[i].uuid)) {\r",
- " Mats.set(Obj.material[i].uuid, Obj.material[i]);\r",
+ " Obj.traverse((Child) => {\r",
+ " if (Child.material) {\r",
+ " if (Array.isArray(Child.material)) {\r",
+ " for (let i = 0; i < Child.material.length; i++) {\r",
+ " if (!Mats.has(Child.material[i].uuid)) {\r",
+ " Mats.set(Child.material[i].uuid, Child.material[i]);\r",
+ " }\r",
+ " }\r",
+ " } else {\r",
+ " if (!Mats.has(Child.material.uuid)) {\r",
+ " Mats.set(Child.material.uuid, Child.material);\r",
" }\r",
- " }\r",
- " } else {\r",
- " if (!Mats.has(Obj.material.uuid)) {\r",
- " Mats.set(Obj.material.uuid, Obj.material);\r",
" }\r",
" }\r",
- " }\r",
- " //\r",
- " for (let i = 0; i < Obj.children.length; i++) {\r",
- " gdjs.__WithThreeJS.get(\"GetAllMaterials\")(Obj.children[i], Mats);\r",
- " }\r",
+ " });\r",
"});\r",
"// マテリアルリストによる差し替え\r",
"gdjs.__WithThreeJS.set(\"ReplaceMaterial\", function(Obj, Mats) {\r",
- " if (Obj.material) {\r",
- " if (Array.isArray(Obj.material)) {\r",
- " for (let i = 0; i < Obj.material.length; i++) {\r",
- " if (Mats.has(Obj.material[i].uuid)) {\r",
- " Obj.material[i] = Mats.get(Obj.material[i].uuid);\r",
+ " Obj.traverse((Child) => {\r",
+ " if (Child.material) {\r",
+ " if (Array.isArray(Child.material)) {\r",
+ " for (let i = 0; i < Child.material.length; i++) {\r",
+ " if (Mats.has(Child.material[i].uuid)) {\r",
+ " Child.material[i] = Mats.get(Child.material[i].uuid);\r",
+ " }\r",
+ " }\r",
+ " } else {\r",
+ " if (Mats.has(Child.material.uuid)) {\r",
+ " Child.material = Mats.get(Child.material.uuid);\r",
" }\r",
- " }\r",
- " } else {\r",
- " if (Mats.has(Obj.material.uuid)) {\r",
- " Obj.material = Mats.get(Obj.material.uuid);\r",
" }\r",
" }\r",
- " }\r",
- " //\r",
- " for (let i = 0; i < Obj.children.length; i++) {\r",
- " gdjs.__WithThreeJS.get(\"ReplaceMaterial\")(Obj.children[i], Mats);\r",
- " }\r",
+ " });\r",
"});\r",
"//\r",
"gdjs.__WithThreeJS.set(\"GetAllObjectsName\", function(Obj, T, Lv) {\r",
@@ -219,36 +197,9 @@
" return T;\r",
"});\r",
"//\r",
- "gdjs.__WithThreeJS.set(\"AllMaterialDispose\", function(Obj) {\r",
- " if (Obj.material) {\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",
- " }\r",
- " //\r",
- " for (let i = 0; i < Obj.children.length; i++) {\r",
- " gdjs.__WithThreeJS.get(\"AllMaterialDispose\")(Obj.children[i]);\r",
- " }\r",
- "});\r",
- "//\r",
- "gdjs.__WithThreeJS.set(\"AllSoundsStop\", function(Obj) {\r",
- " if (Obj.type === \"Audio\") {\r",
- " if (Obj.isPlaying) {\r",
- " Obj.stop();\r",
- " }\r",
- " }\r",
- " //\r",
- " for (let i = 0; i < Obj.children.length; i++) {\r",
- " gdjs.__WithThreeJS.get(\"AllSoundsStop\")(Obj.children[i]);\r",
- " }\r",
- "});\r",
- "//\r",
"gdjs.__WithThreeJS.set(\"GetSingleRadian3\", function(Obj) {\r",
" /*\r",
+ " 3D Camera Angle でのみ使用\r",
" XYZそれぞれ独立して求めているので、組み合わせて使用することはできない。\r",
" 例えば海老反り視点はこれで求めたXYZを組み合わせても再現できない。\r",
" */\r",
@@ -321,7 +272,7 @@
" const Geo1 = Obj1.geometry;\r",
" const Geo2 = Obj2.geometry;\r",
" if (!Geo1 || !Geo2) {\r",
- " console.warn(\"Geometry not found.\");\r",
+ " console.warn(\"Geometry not found: \" + Obj1.name + \" or \" + Obj2.name);\r",
" return BoundingBoxCollisionResult;\r",
" }\r",
" //\r",
@@ -387,92 +338,6 @@
" const AllCams = gdjs.__WithThreeJS.get(\"AllCams\");\r",
" return AllCams.get(\"Camera\" + gdjs.evtTools.common.clamp(Id, 1, 4));\r",
"});\r",
- "//\r",
- "gdjs.__WithThreeJS.set(\"SetAllOpacity\", function(Obj, Operator, Opacity) {\r",
- " if (Obj.material) {\r",
- " if (Array.isArray(Obj.material)) {\r",
- " for (let i = 0; i < Obj.material.length; i++) {\r",
- " // Obj.material[i].transparent = (Obj.material[i].alphaTest !== 0 || Opacity !== 1);\r",
- " if (!Obj.material[i].transparent) {\r",
- " Obj.material[i].transparent = true;\r",
- " Obj.material[i].needsUpdate = true;\r",
- " }\r",
- " if (Operator == \"=\") {\r",
- " Obj.material[i].opacity = Opacity;\r",
- " } else if (Operator == \"+\") {\r",
- " Obj.material[i].opacity += Opacity;\r",
- " } else {\r",
- " Obj.material[i].opacity -= Opacity;\r",
- " }\r",
- " if (Obj.material[i].opacity < 0) Obj.material[i].opacity = 0;\r",
- " if (Obj.material[i].opacity > 1) Obj.material[i].opacity = 1;\r",
- " }\r",
- " } else {\r",
- " // Obj.material.transparent = (Obj.material.alphaTest !== 0 || Opacity !== 1);\r",
- " if (!Obj.material.transparent) {\r",
- " Obj.material.transparent = true;\r",
- " Obj.material.needsUpdate = true;\r",
- " }\r",
- " if (Operator == \"=\") {\r",
- " Obj.material.opacity = Opacity;\r",
- " } else if (Operator == \"+\") {\r",
- " Obj.material.opacity += Opacity;\r",
- " } else {\r",
- " Obj.material.opacity -= Opacity;\r",
- " }\r",
- " if (Obj.material.opacity < 0) Obj.material.opacity = 0;\r",
- " if (Obj.material.opacity > 1) Obj.material.opacity = 1;\r",
- " }\r",
- " }\r",
- " //\r",
- " for (let i = 0; i < Obj.children.length; i++) {\r",
- " gdjs.__WithThreeJS.get(\"SetAllOpacity\")(Obj.children[i], Operator, Opacity);\r",
- " }\r",
- "});\r",
- "//\r",
- "gdjs.__WithThreeJS.set(\"SetAllDepthWrite\", function(Obj, Write) {\r",
- " if (Obj.material) {\r",
- " if (Array.isArray(Obj.material)) {\r",
- " for (let i = 0; i < Obj.material.length; i++) {\r",
- " Obj.material[i].depthWrite = Write;\r",
- " }\r",
- " } else {\r",
- " Obj.material.depthWrite = Write;\r",
- " }\r",
- " }\r",
- " //\r",
- " for (let i = 0; i < Obj.children.length; i++) {\r",
- " gdjs.__WithThreeJS.get(\"SetAllDepthWrite\")(Obj.children[i], Write);\r",
- " }\r",
- "});\r",
- "//\r",
- "gdjs.__WithThreeJS.set(\"AddSuffixToAllIds\", function(Obj, Suffix) {\r",
- " // !Obj.isLight && !Obj.isLine && !Obj.isSkinnedMesh && !Obj.isBone\r",
- " // Obj.type != \"Audio\"\r",
- " if (!Obj.isCamera && !Obj.isScene) {\r",
- " Obj.name += Suffix;\r",
- " }\r",
- " //\r",
- " for (let i = 0; i < Obj.children.length; i++) {\r",
- " gdjs.__WithThreeJS.get(\"AddSuffixToAllIds\")(Obj.children[i], Suffix);\r",
- " }\r",
- "});\r",
- "//\r",
- "gdjs.__WithThreeJS.set(\"SetAllBlendMode\", function(Obj, Blend) {\r",
- " if (Obj.material) {\r",
- " if (Array.isArray(Obj.material)) {\r",
- " for (let i = 0; i < Obj.material.length; i++) {\r",
- " Obj.material[i].blending = Blend;\r",
- " }\r",
- " } else {\r",
- " Obj.material.blending = Blend;\r",
- " }\r",
- " }\r",
- " //\r",
- " for (let i = 0; i < Obj.children.length; i++) {\r",
- " gdjs.__WithThreeJS.get(\"SetAllBlendMode\")(Obj.children[i], Blend);\r",
- " }\r",
- "});\r",
"\r",
""
],
@@ -1314,163 +1179,910 @@
],
"parameterObjects": "",
"useStrict": true,
- "eventsSheetExpanded": true
- }
- ],
- "parameters": [],
- "objectGroups": []
- },
- {
- "fullName": "",
- "functionType": "Action",
- "name": "onScenePostEvents",
- "sentence": "",
- "events": [
- {
- "type": "BuiltinCommonInstructions::JsCode",
- "inlineCode": [
- "// console.log(\"Three.js post events\");",
- "if (!gdjs.__WithThreeJS.has(\"Renderer\")) {",
- " return;",
- "}",
- "// if (gdjs.__WithThreeJS.has(\"BuiltIn3DWithThreeJS\")) {",
- "// return;",
- "// }",
- "const Canvas2D = gdjs.__WithThreeJS.get(\"Canvas2D\");",
- "const Rect = Canvas2D.getBoundingClientRect();",
- "const Scene = gdjs.__WithThreeJS.get(\"Scene\");",
- "const AllCams = gdjs.__WithThreeJS.get(\"AllCams\");",
- "const Renderer = gdjs.__WithThreeJS.get(\"Renderer\");",
- "const AnimationMixer = gdjs.__WithThreeJS.get(\"AnimationMixer\");",
- "//",
- "AnimationMixer.update(runtimeScene.getElapsedTime() / 1000);",
- "// const Camera = gdjs.__WithThreeJS.get(\"Camera\");",
- "// Renderer.render( Scene, Camera );",
- "for (const [K, V] of AllCams) {",
- " if (V.userData.CameraStatus.Active) {",
- " const X = V.userData.CameraStatus.X;",
- " const Y = V.userData.CameraStatus.Y;",
- " const W = V.userData.CameraStatus.W;",
- " const H = V.userData.CameraStatus.H;",
- " Renderer.setViewport(X, Y, W, H);",
- " Renderer.setScissor(X, Y, W, H);",
- " Renderer.render( Scene, V );",
- " }",
- "}",
- "",
- ""
- ],
- "parameterObjects": "",
- "useStrict": true,
- "eventsSheetExpanded": true
- }
- ],
- "parameters": [],
- "objectGroups": []
- },
- {
- "fullName": "",
- "functionType": "Action",
- "name": "onSceneUnloading",
- "sentence": "",
- "events": [
+ "eventsSheetExpanded": false
+ },
{
- "type": "BuiltinCommonInstructions::Standard",
- "conditions": [],
- "actions": [
- {
- "type": {
- "value": "WithThreeJS::Clear3DScene"
- },
- "parameters": [
- "",
- ""
- ]
- }
- ]
+ "type": "BuiltinCommonInstructions::Comment",
+ "color": {
+ "b": 109,
+ "g": 230,
+ "r": 255,
+ "textB": 0,
+ "textG": 0,
+ "textR": 0
+ },
+ "comment": "OBB (Custom)"
},
{
"type": "BuiltinCommonInstructions::JsCode",
"inlineCode": [
- "if (gdjs.__WithThreeJS.get(\"BuiltIn3D\")) {",
- " if (runtimeScene.getRenderer()._threeRenderer._render_WithThreeJS) {",
- " runtimeScene.getRenderer()._threeRenderer.render = runtimeScene.getRenderer()._threeRenderer._render_WithThreeJS;",
- " runtimeScene.getRenderer()._threeRenderer._render_WithThreeJS = null;",
- " };",
- " if (runtimeScene.getRenderer().getPIXIRenderer()._clear_WithThreeJS) {",
- " runtimeScene.getRenderer().getPIXIRenderer().clear = runtimeScene.getRenderer().getPIXIRenderer()._clear_WithThreeJS;",
- " runtimeScene.getRenderer().getPIXIRenderer()._clear_WithThreeJS = null;",
- " };",
- "}",
- "// if (gdjs.__WithThreeJS.has(\"BuiltIn3DWithThreeJS\")) {",
- "// gdjs.__WithThreeJS.delete(\"Scene\");",
- "// gdjs.__WithThreeJS.delete(\"BuiltIn3dCamera\");",
- "// gdjs.__WithThreeJS.delete(\"BuiltIn3dRenderer\");",
- "// gdjs.__WithThreeJS.delete(\"Listener\");",
- "// gdjs.__WithThreeJS.delete(\"BuiltIn3DWithThreeJS\");",
- "// }",
- "if (runtimeScene.getRenderer().getPIXIRenderer().background) {",
- " runtimeScene.getRenderer().getPIXIRenderer().background.alpha = 1;// For PixiJS 7",
- "} else {",
- " runtimeScene.getRenderer().getPIXIRenderer().backgroundAlpha = 1;// For PixiJS 6",
+ "// Custom",
+ "if (gdjs.__WithThreeJS.get(\"NoTHREE\")) {",
+ " return;",
"}",
- "gdjs.__WithThreeJS.set(\"SceneIsReady\", false);",
+ "/* // Custom",
+ "import {",
+ "\tBox3,",
+ "\tMathUtils,",
+ "\tMatrix4,",
+ "\tMatrix3,",
+ "\tRay,",
+ "\tVector3",
+ "} from 'three';",
+ "*/",
"",
- ""
- ],
- "parameterObjects": "",
- "useStrict": true,
- "eventsSheetExpanded": true
- }
- ],
- "parameters": [],
- "objectGroups": []
- },
- {
- "description": "Create a 3D Scene and initialize all 3D Cameras.",
- "fullName": "Create 3D Scene",
- "functionType": "Action",
- "group": "3D Scene",
- "name": "Create3DScene",
- "sentence": "Create 3D Scene (Background: _PARAM1_, _PARAM2_, Ambient: _PARAM3_, Fog: _PARAM4_, _PARAM5_, _PARAM6_, Projection Scale: _PARAM7_, View Mode: _PARAM8_)",
- "events": [
- {
- "type": "BuiltinCommonInstructions::JsCode",
- "inlineCode": [
- "// console.log(\"Three.js create scene\");",
- "// v5.1.162 以上で Built-In 3D がゲームに含まれている",
- "const BuiltIn3D = gdjs.__WithThreeJS.get(\"BuiltIn3D\");",
- "if (BuiltIn3D) {",
- " // runtimescene-pixi-renderer.ts カスタム",
- " console.log(\"[WithThreeJS] Built-in 3D is enabled.\");",
- " if (!runtimeScene.getRenderer()._threeRenderer._render_WithThreeJS) {",
- " runtimeScene.getRenderer()._threeRenderer._render_WithThreeJS = runtimeScene.getRenderer()._threeRenderer.render;",
- " runtimeScene.getRenderer()._threeRenderer.render = function(S, C) {",
- " // Three.js のレンダラーが利用される場合の透過設定",
- " runtimeScene.getLayer(\"\").getRenderer().getThreeScene().background = null;",
- " this._render_WithThreeJS(S, C);",
- " }",
- " }",
- " if (!runtimeScene.getRenderer().getPIXIRenderer()._clear_WithThreeJS) {",
- " runtimeScene.getRenderer().getPIXIRenderer()._clear_WithThreeJS = runtimeScene.getRenderer().getPIXIRenderer().clear;",
- " runtimeScene.getRenderer().getPIXIRenderer().clear = function() {",
- " // PixiJS のレンダラーが利用される場合の透過設定",
- " runtimeScene.setBackgroundColor(0,0,0);",
- " if (this.background) {",
- " this.background.alpha = 0;// For PixiJS 7",
- " } else {",
- " this.backgroundAlpha = 0;// For PixiJS 6",
- " }",
- " this._clear_WithThreeJS();",
- " }",
- " }",
- "} else {",
- " console.log(\"[WithThreeJS] Built-in 3D is disabled. (LEGACY MODE)\");",
- " // 警告表示",
- " let AlertElement = document.createElement('div');",
- " AlertElement.innerHTML = `Warning from WithThreeJS
",
- " Please add an \"Enable WithThreeJS\" object to a scene.
",
- " For more information, please click here.`;",
+ "// module scope helper variables",
+ "",
+ "const a = {",
+ "\tc: null, // center",
+ "\tu: [ new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3() ], // basis vectors // Custom",
+ "\te: [] // half width",
+ "};",
+ "",
+ "const b = {",
+ "\tc: null, // center",
+ "\tu: [ new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3() ], // basis vectors // Custom",
+ "\te: [] // half width",
+ "};",
+ "",
+ "const R = [[], [], []];",
+ "const AbsR = [[], [], []];",
+ "const t = [];",
+ "",
+ "const xAxis = new THREE.Vector3(); // Custom",
+ "const yAxis = new THREE.Vector3(); // Custom",
+ "const zAxis = new THREE.Vector3(); // Custom",
+ "const v1 = new THREE.Vector3(); // Custom",
+ "const size = new THREE.Vector3(); // Custom",
+ "const closestPoint = new THREE.Vector3(); // Custom",
+ "const rotationMatrix = new THREE.Matrix3(); // Custom",
+ "const aabb = new THREE.Box3(); // Custom",
+ "const matrix = new THREE.Matrix4(); // Custom",
+ "const inverse = new THREE.Matrix4(); // Custom",
+ "const localRay = new THREE.Ray(); // Custom",
+ "",
+ "// OBB",
+ "",
+ "class OBB {",
+ "",
+ "\tconstructor( center = new THREE.Vector3(), halfSize = new THREE.Vector3(), rotation = new THREE.Matrix3() ) { // Custom",
+ "",
+ "\t\tthis.center = center;",
+ "\t\tthis.halfSize = halfSize;",
+ "\t\tthis.rotation = rotation;",
+ "",
+ "\t}",
+ "",
+ "\tset( center, halfSize, rotation ) {",
+ "",
+ "\t\tthis.center = center;",
+ "\t\tthis.halfSize = halfSize;",
+ "\t\tthis.rotation = rotation;",
+ "",
+ "\t\treturn this;",
+ "",
+ "\t}",
+ "",
+ "\tcopy( obb ) {",
+ "",
+ "\t\tthis.center.copy( obb.center );",
+ "\t\tthis.halfSize.copy( obb.halfSize );",
+ "\t\tthis.rotation.copy( obb.rotation );",
+ "",
+ "\t\treturn this;",
+ "",
+ "\t}",
+ "",
+ "\tclone() {",
+ "",
+ "\t\treturn new this.constructor().copy( this );",
+ "",
+ "\t}",
+ "",
+ "\tgetSize( result ) {",
+ "",
+ "\t\treturn result.copy( this.halfSize ).multiplyScalar( 2 );",
+ "",
+ "\t}",
+ "",
+ "\t/**",
+ "\t* Reference: Closest Point on OBB to Point in Real-Time Collision Detection",
+ "\t* by Christer Ericson (chapter 5.1.4)",
+ "\t*/",
+ "\tclampPoint( point, result ) {",
+ "",
+ "\t\tconst halfSize = this.halfSize;",
+ "",
+ "\t\tv1.subVectors( point, this.center );",
+ "\t\tthis.rotation.extractBasis( xAxis, yAxis, zAxis );",
+ "",
+ "\t\t// start at the center position of the OBB",
+ "",
+ "\t\tresult.copy( this.center );",
+ "",
+ "\t\t// project the target onto the OBB axes and walk towards that point",
+ "",
+ "\t\tconst x = MathUtils.clamp( v1.dot( xAxis ), - halfSize.x, halfSize.x );",
+ "\t\tresult.add( xAxis.multiplyScalar( x ) );",
+ "",
+ "\t\tconst y = MathUtils.clamp( v1.dot( yAxis ), - halfSize.y, halfSize.y );",
+ "\t\tresult.add( yAxis.multiplyScalar( y ) );",
+ "",
+ "\t\tconst z = MathUtils.clamp( v1.dot( zAxis ), - halfSize.z, halfSize.z );",
+ "\t\tresult.add( zAxis.multiplyScalar( z ) );",
+ "",
+ "\t\treturn result;",
+ "",
+ "\t}",
+ "",
+ "\tcontainsPoint( point ) {",
+ "",
+ "\t\tv1.subVectors( point, this.center );",
+ "\t\tthis.rotation.extractBasis( xAxis, yAxis, zAxis );",
+ "",
+ "\t\t// project v1 onto each axis and check if these points lie inside the OBB",
+ "",
+ "\t\treturn Math.abs( v1.dot( xAxis ) ) <= this.halfSize.x &&",
+ "\t\t\t\tMath.abs( v1.dot( yAxis ) ) <= this.halfSize.y &&",
+ "\t\t\t\tMath.abs( v1.dot( zAxis ) ) <= this.halfSize.z;",
+ "",
+ "\t}",
+ "",
+ "\tintersectsBox3( box3 ) {",
+ "",
+ "\t\treturn this.intersectsOBB( obb.fromBox3( box3 ) );",
+ "",
+ "\t}",
+ "",
+ "\tintersectsSphere( sphere ) {",
+ "",
+ "\t\t// find the point on the OBB closest to the sphere center",
+ "",
+ "\t\tthis.clampPoint( sphere.center, closestPoint );",
+ "",
+ "\t\t// if that point is inside the sphere, the OBB and sphere intersect",
+ "",
+ "\t\treturn closestPoint.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );",
+ "",
+ "\t}",
+ "",
+ "\t/**",
+ "\t* Reference: OBB-OBB Intersection in Real-Time Collision Detection",
+ "\t* by Christer Ericson (chapter 4.4.1)",
+ "\t*",
+ "\t*/",
+ "\tintersectsOBB( obb, epsilon = Number.EPSILON ) {",
+ "",
+ "\t\t// prepare data structures (the code uses the same nomenclature like the reference)",
+ "",
+ "\t\ta.c = this.center;",
+ "\t\ta.e[ 0 ] = this.halfSize.x;",
+ "\t\ta.e[ 1 ] = this.halfSize.y;",
+ "\t\ta.e[ 2 ] = this.halfSize.z;",
+ "\t\tthis.rotation.extractBasis( a.u[ 0 ], a.u[ 1 ], a.u[ 2 ] );",
+ "",
+ "\t\tb.c = obb.center;",
+ "\t\tb.e[ 0 ] = obb.halfSize.x;",
+ "\t\tb.e[ 1 ] = obb.halfSize.y;",
+ "\t\tb.e[ 2 ] = obb.halfSize.z;",
+ "\t\tobb.rotation.extractBasis( b.u[ 0 ], b.u[ 1 ], b.u[ 2 ] );",
+ "",
+ "\t\t// compute rotation matrix expressing b in a's coordinate frame",
+ "",
+ "\t\tfor ( let i = 0; i < 3; i ++ ) {",
+ "",
+ "\t\t\tfor ( let j = 0; j < 3; j ++ ) {",
+ "",
+ "\t\t\t\tR[ i ][ j ] = a.u[ i ].dot( b.u[ j ] );",
+ "",
+ "\t\t\t}",
+ "",
+ "\t\t}",
+ "",
+ "\t\t// compute translation vector",
+ "",
+ "\t\tv1.subVectors( b.c, a.c );",
+ "",
+ "\t\t// bring translation into a's coordinate frame",
+ "",
+ "\t\tt[ 0 ] = v1.dot( a.u[ 0 ] );",
+ "\t\tt[ 1 ] = v1.dot( a.u[ 1 ] );",
+ "\t\tt[ 2 ] = v1.dot( a.u[ 2 ] );",
+ "",
+ "\t\t// compute common subexpressions. Add in an epsilon term to",
+ "\t\t// counteract arithmetic errors when two edges are parallel and",
+ "\t\t// their cross product is (near) null",
+ "",
+ "\t\tfor ( let i = 0; i < 3; i ++ ) {",
+ "",
+ "\t\t\tfor ( let j = 0; j < 3; j ++ ) {",
+ "",
+ "\t\t\t\tAbsR[ i ][ j ] = Math.abs( R[ i ][ j ] ) + epsilon;",
+ "",
+ "\t\t\t}",
+ "",
+ "\t\t}",
+ "",
+ "\t\tlet ra, rb;",
+ "",
+ "\t\t// test axes L = A0, L = A1, L = A2",
+ "",
+ "\t\tfor ( let i = 0; i < 3; i ++ ) {",
+ "",
+ "\t\t\tra = a.e[ i ];",
+ "\t\t\trb = b.e[ 0 ] * AbsR[ i ][ 0 ] + b.e[ 1 ] * AbsR[ i ][ 1 ] + b.e[ 2 ] * AbsR[ i ][ 2 ];",
+ "\t\t\tif ( Math.abs( t[ i ] ) > ra + rb ) return false;",
+ "",
+ "",
+ "\t\t}",
+ "",
+ "\t\t// test axes L = B0, L = B1, L = B2",
+ "",
+ "\t\tfor ( let i = 0; i < 3; i ++ ) {",
+ "",
+ "\t\t\tra = a.e[ 0 ] * AbsR[ 0 ][ i ] + a.e[ 1 ] * AbsR[ 1 ][ i ] + a.e[ 2 ] * AbsR[ 2 ][ i ];",
+ "\t\t\trb = b.e[ i ];",
+ "\t\t\tif ( Math.abs( t[ 0 ] * R[ 0 ][ i ] + t[ 1 ] * R[ 1 ][ i ] + t[ 2 ] * R[ 2 ][ i ] ) > ra + rb ) return false;",
+ "",
+ "\t\t}",
+ "",
+ "\t\t// test axis L = A0 x B0",
+ "",
+ "\t\tra = a.e[ 1 ] * AbsR[ 2 ][ 0 ] + a.e[ 2 ] * AbsR[ 1 ][ 0 ];",
+ "\t\trb = b.e[ 1 ] * AbsR[ 0 ][ 2 ] + b.e[ 2 ] * AbsR[ 0 ][ 1 ];",
+ "\t\tif ( Math.abs( t[ 2 ] * R[ 1 ][ 0 ] - t[ 1 ] * R[ 2 ][ 0 ] ) > ra + rb ) return false;",
+ "",
+ "\t\t// test axis L = A0 x B1",
+ "",
+ "\t\tra = a.e[ 1 ] * AbsR[ 2 ][ 1 ] + a.e[ 2 ] * AbsR[ 1 ][ 1 ];",
+ "\t\trb = b.e[ 0 ] * AbsR[ 0 ][ 2 ] + b.e[ 2 ] * AbsR[ 0 ][ 0 ];",
+ "\t\tif ( Math.abs( t[ 2 ] * R[ 1 ][ 1 ] - t[ 1 ] * R[ 2 ][ 1 ] ) > ra + rb ) return false;",
+ "",
+ "\t\t// test axis L = A0 x B2",
+ "",
+ "\t\tra = a.e[ 1 ] * AbsR[ 2 ][ 2 ] + a.e[ 2 ] * AbsR[ 1 ][ 2 ];",
+ "\t\trb = b.e[ 0 ] * AbsR[ 0 ][ 1 ] + b.e[ 1 ] * AbsR[ 0 ][ 0 ];",
+ "\t\tif ( Math.abs( t[ 2 ] * R[ 1 ][ 2 ] - t[ 1 ] * R[ 2 ][ 2 ] ) > ra + rb ) return false;",
+ "",
+ "\t\t// test axis L = A1 x B0",
+ "",
+ "\t\tra = a.e[ 0 ] * AbsR[ 2 ][ 0 ] + a.e[ 2 ] * AbsR[ 0 ][ 0 ];",
+ "\t\trb = b.e[ 1 ] * AbsR[ 1 ][ 2 ] + b.e[ 2 ] * AbsR[ 1 ][ 1 ];",
+ "\t\tif ( Math.abs( t[ 0 ] * R[ 2 ][ 0 ] - t[ 2 ] * R[ 0 ][ 0 ] ) > ra + rb ) return false;",
+ "",
+ "\t\t// test axis L = A1 x B1",
+ "",
+ "\t\tra = a.e[ 0 ] * AbsR[ 2 ][ 1 ] + a.e[ 2 ] * AbsR[ 0 ][ 1 ];",
+ "\t\trb = b.e[ 0 ] * AbsR[ 1 ][ 2 ] + b.e[ 2 ] * AbsR[ 1 ][ 0 ];",
+ "\t\tif ( Math.abs( t[ 0 ] * R[ 2 ][ 1 ] - t[ 2 ] * R[ 0 ][ 1 ] ) > ra + rb ) return false;",
+ "",
+ "\t\t// test axis L = A1 x B2",
+ "",
+ "\t\tra = a.e[ 0 ] * AbsR[ 2 ][ 2 ] + a.e[ 2 ] * AbsR[ 0 ][ 2 ];",
+ "\t\trb = b.e[ 0 ] * AbsR[ 1 ][ 1 ] + b.e[ 1 ] * AbsR[ 1 ][ 0 ];",
+ "\t\tif ( Math.abs( t[ 0 ] * R[ 2 ][ 2 ] - t[ 2 ] * R[ 0 ][ 2 ] ) > ra + rb ) return false;",
+ "",
+ "\t\t// test axis L = A2 x B0",
+ "",
+ "\t\tra = a.e[ 0 ] * AbsR[ 1 ][ 0 ] + a.e[ 1 ] * AbsR[ 0 ][ 0 ];",
+ "\t\trb = b.e[ 1 ] * AbsR[ 2 ][ 2 ] + b.e[ 2 ] * AbsR[ 2 ][ 1 ];",
+ "\t\tif ( Math.abs( t[ 1 ] * R[ 0 ][ 0 ] - t[ 0 ] * R[ 1 ][ 0 ] ) > ra + rb ) return false;",
+ "",
+ "\t\t// test axis L = A2 x B1",
+ "",
+ "\t\tra = a.e[ 0 ] * AbsR[ 1 ][ 1 ] + a.e[ 1 ] * AbsR[ 0 ][ 1 ];",
+ "\t\trb = b.e[ 0 ] * AbsR[ 2 ][ 2 ] + b.e[ 2 ] * AbsR[ 2 ][ 0 ];",
+ "\t\tif ( Math.abs( t[ 1 ] * R[ 0 ][ 1 ] - t[ 0 ] * R[ 1 ][ 1 ] ) > ra + rb ) return false;",
+ "",
+ "\t\t// test axis L = A2 x B2",
+ "",
+ "\t\tra = a.e[ 0 ] * AbsR[ 1 ][ 2 ] + a.e[ 1 ] * AbsR[ 0 ][ 2 ];",
+ "\t\trb = b.e[ 0 ] * AbsR[ 2 ][ 1 ] + b.e[ 1 ] * AbsR[ 2 ][ 0 ];",
+ "\t\tif ( Math.abs( t[ 1 ] * R[ 0 ][ 2 ] - t[ 0 ] * R[ 1 ][ 2 ] ) > ra + rb ) return false;",
+ "",
+ "\t\t// since no separating axis is found, the OBBs must be intersecting",
+ "",
+ "\t\treturn true;",
+ "",
+ "\t}",
+ "",
+ "\t/**",
+ "\t* Reference: Testing Box Against Plane in Real-Time Collision Detection",
+ "\t* by Christer Ericson (chapter 5.2.3)",
+ "\t*/",
+ "\tintersectsPlane( plane ) {",
+ "",
+ "\t\tthis.rotation.extractBasis( xAxis, yAxis, zAxis );",
+ "",
+ "\t\t// compute the projection interval radius of this OBB onto L(t) = this->center + t * p.normal;",
+ "",
+ "\t\tconst r = this.halfSize.x * Math.abs( plane.normal.dot( xAxis ) ) +",
+ "\t\t\t\tthis.halfSize.y * Math.abs( plane.normal.dot( yAxis ) ) +",
+ "\t\t\t\tthis.halfSize.z * Math.abs( plane.normal.dot( zAxis ) );",
+ "",
+ "\t\t// compute distance of the OBB's center from the plane",
+ "",
+ "\t\tconst d = plane.normal.dot( this.center ) - plane.constant;",
+ "",
+ "\t\t// Intersection occurs when distance d falls within [-r,+r] interval",
+ "",
+ "\t\treturn Math.abs( d ) <= r;",
+ "",
+ "\t}",
+ "",
+ "\t/**",
+ "\t* Performs a ray/OBB intersection test and stores the intersection point",
+ "\t* to the given 3D vector. If no intersection is detected, *null* is returned.",
+ "\t*/",
+ "\tintersectRay( ray, result ) {",
+ "",
+ "\t\t// the idea is to perform the intersection test in the local space",
+ "\t\t// of the OBB.",
+ "",
+ "\t\tthis.getSize( size );",
+ "\t\taabb.setFromCenterAndSize( v1.set( 0, 0, 0 ), size );",
+ "",
+ "\t\t// create a 4x4 transformation matrix",
+ "",
+ "\t\tmatrix.setFromMatrix3( this.rotation );",
+ "\t\tmatrix.setPosition( this.center );",
+ "",
+ "\t\t// transform ray to the local space of the OBB",
+ "",
+ "\t\tinverse.copy( matrix ).invert();",
+ "\t\tlocalRay.copy( ray ).applyMatrix4( inverse );",
+ "",
+ "\t\t// perform ray <-> AABB intersection test",
+ "",
+ "\t\tif ( localRay.intersectBox( aabb, result ) ) {",
+ "",
+ "\t\t\t// transform the intersection point back to world space",
+ "",
+ "\t\t\treturn result.applyMatrix4( matrix );",
+ "",
+ "\t\t} else {",
+ "",
+ "\t\t\treturn null;",
+ "",
+ "\t\t}",
+ "",
+ "\t}",
+ "",
+ "\t/**",
+ "\t* Performs a ray/OBB intersection test. Returns either true or false if",
+ "\t* there is a intersection or not.",
+ "\t*/",
+ "\tintersectsRay( ray ) {",
+ "",
+ "\t\treturn this.intersectRay( ray, v1 ) !== null;",
+ "",
+ "\t}",
+ "",
+ "\tfromBox3( box3 ) {",
+ "",
+ "\t\tbox3.getCenter( this.center );",
+ "",
+ "\t\tbox3.getSize( this.halfSize ).multiplyScalar( 0.5 );",
+ "",
+ "\t\tthis.rotation.identity();",
+ "",
+ "\t\treturn this;",
+ "",
+ "\t}",
+ "",
+ "\tequals( obb ) {",
+ "",
+ "\t\treturn obb.center.equals( this.center ) &&",
+ "\t\t\tobb.halfSize.equals( this.halfSize ) &&",
+ "\t\t\tobb.rotation.equals( this.rotation );",
+ "",
+ "\t}",
+ "",
+ "\tapplyMatrix4( matrix ) {",
+ "",
+ "\t\tconst e = matrix.elements;",
+ "",
+ "\t\tlet sx = v1.set( e[ 0 ], e[ 1 ], e[ 2 ] ).length();",
+ "\t\tconst sy = v1.set( e[ 4 ], e[ 5 ], e[ 6 ] ).length();",
+ "\t\tconst sz = v1.set( e[ 8 ], e[ 9 ], e[ 10 ] ).length();",
+ "",
+ "\t\tconst det = matrix.determinant();",
+ "\t\tif ( det < 0 ) sx = - sx;",
+ "",
+ "\t\trotationMatrix.setFromMatrix4( matrix );",
+ "",
+ "\t\tconst invSX = 1 / sx;",
+ "\t\tconst invSY = 1 / sy;",
+ "\t\tconst invSZ = 1 / sz;",
+ "",
+ "\t\trotationMatrix.elements[ 0 ] *= invSX;",
+ "\t\trotationMatrix.elements[ 1 ] *= invSX;",
+ "\t\trotationMatrix.elements[ 2 ] *= invSX;",
+ "",
+ "\t\trotationMatrix.elements[ 3 ] *= invSY;",
+ "\t\trotationMatrix.elements[ 4 ] *= invSY;",
+ "\t\trotationMatrix.elements[ 5 ] *= invSY;",
+ "",
+ "\t\trotationMatrix.elements[ 6 ] *= invSZ;",
+ "\t\trotationMatrix.elements[ 7 ] *= invSZ;",
+ "\t\trotationMatrix.elements[ 8 ] *= invSZ;",
+ "",
+ "\t\tthis.rotation.multiply( rotationMatrix );",
+ "",
+ "\t\tthis.halfSize.x *= sx;",
+ "\t\tthis.halfSize.y *= sy;",
+ "\t\tthis.halfSize.z *= sz;",
+ "",
+ "\t\tv1.setFromMatrixPosition( matrix );",
+ "\t\tthis.center.add( v1 );",
+ "",
+ "\t\treturn this;",
+ "",
+ "\t}",
+ "",
+ "}",
+ "",
+ "// const obb = new OBB();// Custom",
+ "",
+ "// export { OBB };// Custom",
+ "",
+ "THREE.OBB = OBB;// Custom"
+ ],
+ "parameterObjects": "",
+ "useStrict": true,
+ "eventsSheetExpanded": false
+ }
+ ],
+ "parameters": [],
+ "objectGroups": []
+ },
+ {
+ "fullName": "",
+ "functionType": "Action",
+ "name": "onScenePostEvents",
+ "sentence": "",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::JsCode",
+ "inlineCode": [
+ "// console.log(\"Three.js post events\");",
+ "if (!gdjs.__WithThreeJS.has(\"Renderer\")) {",
+ " return;",
+ "}",
+ "const Canvas2D = gdjs.__WithThreeJS.get(\"Canvas2D\");",
+ "const Rect = Canvas2D.getBoundingClientRect();",
+ "const Scene = gdjs.__WithThreeJS.get(\"Scene\");",
+ "const AllCams = gdjs.__WithThreeJS.get(\"AllCams\");",
+ "const Renderer = gdjs.__WithThreeJS.get(\"Renderer\");",
+ "const AnimationMixer = gdjs.__WithThreeJS.get(\"AnimationMixer\");",
+ "//",
+ "AnimationMixer.update(runtimeScene.getElapsedTime() / 1000);",
+ "for (const [K, V] of AllCams) {",
+ " if (V.userData.CameraStatus.Active) {",
+ " const X = V.userData.CameraStatus.X;",
+ " const Y = V.userData.CameraStatus.Y;",
+ " const W = V.userData.CameraStatus.W;",
+ " const H = V.userData.CameraStatus.H;",
+ " Renderer.setViewport(X, Y, W, H);",
+ " Renderer.setScissor(X, Y, W, H);",
+ " Renderer.render( Scene, V );",
+ " }",
+ "}",
+ "",
+ ""
+ ],
+ "parameterObjects": "",
+ "useStrict": true,
+ "eventsSheetExpanded": true
+ }
+ ],
+ "parameters": [],
+ "objectGroups": []
+ },
+ {
+ "fullName": "",
+ "functionType": "Action",
+ "name": "onSceneUnloading",
+ "sentence": "",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::Standard",
+ "conditions": [],
+ "actions": [
+ {
+ "type": {
+ "value": "WithThreeJS::Clear3DScene"
+ },
+ "parameters": [
+ "",
+ ""
+ ]
+ }
+ ]
+ },
+ {
+ "type": "BuiltinCommonInstructions::JsCode",
+ "inlineCode": [
+ "if (gdjs.__WithThreeJS.get(\"BuiltIn3D\")) {",
+ " if (runtimeScene.getRenderer()._threeRenderer._render_WithThreeJS) {",
+ " runtimeScene.getRenderer()._threeRenderer.render = runtimeScene.getRenderer()._threeRenderer._render_WithThreeJS;",
+ " runtimeScene.getRenderer()._threeRenderer._render_WithThreeJS = null;",
+ " };",
+ " if (runtimeScene.getRenderer().getPIXIRenderer()._clear_WithThreeJS) {",
+ " runtimeScene.getRenderer().getPIXIRenderer().clear = runtimeScene.getRenderer().getPIXIRenderer()._clear_WithThreeJS;",
+ " runtimeScene.getRenderer().getPIXIRenderer()._clear_WithThreeJS = null;",
+ " };",
+ "}",
+ "if (runtimeScene.getRenderer().getPIXIRenderer().background) {",
+ " runtimeScene.getRenderer().getPIXIRenderer().background.alpha = 1;// For PixiJS 7",
+ "} else {",
+ " runtimeScene.getRenderer().getPIXIRenderer().backgroundAlpha = 1;// For PixiJS 6",
+ "}",
+ "gdjs.__WithThreeJS.set(\"SceneIsReady\", false);",
+ "",
+ ""
+ ],
+ "parameterObjects": "",
+ "useStrict": true,
+ "eventsSheetExpanded": true
+ }
+ ],
+ "parameters": [],
+ "objectGroups": []
+ },
+ {
+ "description": "Create a 3D Scene and initialize all 3D Cameras.",
+ "fullName": "Create 3D Scene V1 (Deprecated)",
+ "functionType": "Action",
+ "group": "3D Scene",
+ "name": "Create3DScene",
+ "private": true,
+ "sentence": "⚠️ Create 3D Scene V1 (Background: _PARAM1_, _PARAM2_, Ambient: _PARAM3_, Fog: _PARAM4_, _PARAM5_, _PARAM6_, Projection Scale: _PARAM7_, View Mode: _PARAM8_)",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::JsCode",
+ "inlineCode": [
+ "// console.log(\"Three.js create scene\");",
+ "// v5.1.162 以上で Built-In 3D がゲームに含まれている",
+ "const BuiltIn3D = gdjs.__WithThreeJS.get(\"BuiltIn3D\");",
+ "if (BuiltIn3D) {",
+ " // runtimescene-pixi-renderer.ts カスタム",
+ " console.log(\"[WithThreeJS] Built-in 3D is enabled.\");",
+ " if (!runtimeScene.getRenderer()._threeRenderer._render_WithThreeJS) {",
+ " runtimeScene.getRenderer()._threeRenderer._render_WithThreeJS = runtimeScene.getRenderer()._threeRenderer.render;",
+ " runtimeScene.getRenderer()._threeRenderer.render = function(S, C) {",
+ " // Three.js のレンダラーが利用される場合の透過設定",
+ " runtimeScene.getLayer(\"\").getRenderer().getThreeScene().background = null;",
+ " this._render_WithThreeJS(S, C);",
+ " }",
+ " }",
+ " if (!runtimeScene.getRenderer().getPIXIRenderer()._clear_WithThreeJS) {",
+ " runtimeScene.getRenderer().getPIXIRenderer()._clear_WithThreeJS = runtimeScene.getRenderer().getPIXIRenderer().clear;",
+ " runtimeScene.getRenderer().getPIXIRenderer().clear = function() {",
+ " // PixiJS のレンダラーが利用される場合の透過設定",
+ " runtimeScene.setBackgroundColor(0,0,0);",
+ " if (this.background) {",
+ " this.background.alpha = 0;// For PixiJS 7",
+ " } else {",
+ " this.backgroundAlpha = 0;// For PixiJS 6",
+ " }",
+ " this._clear_WithThreeJS();",
+ " }",
+ " }",
+ "} else {",
+ " console.log(\"[WithThreeJS] Built-in 3D is disabled.\");",
+ " // 警告表示",
+ " let AlertElement = document.createElement('div');",
+ " AlertElement.innerHTML = `Warning from WithThreeJS
",
+ " Please add an \"Enable WithThreeJS\" object to a scene.
",
+ " For more information, please click here.`;",
+ " AlertElement.style.position = \"absolute\";",
+ " AlertElement.style.zIndex = 999;",
+ " AlertElement.style.top = 0;",
+ " AlertElement.style.left = 0;",
+ " AlertElement.style.backgroundColor = \"red\";",
+ " AlertElement.style.color = \"white\";",
+ " AlertElement.style.padding = \"0.5em\";",
+ " document.body.appendChild(AlertElement);",
+ " return;",
+ "}",
+ "//",
+ "const ProjectionScale = eventsFunctionContext.getArgument(\"ProjectionScale\") || 1;",
+ "let ViewMode = eventsFunctionContext.getArgument(\"ViewMode\");",
+ "if (ViewMode !== \"Top Down\" && ViewMode !== \"Side\") {",
+ " ViewMode = \"Top Down\";",
+ "}",
+ "gdjs.__WithThreeJS.set(\"ProjectionScale\", ProjectionScale);",
+ "gdjs.__WithThreeJS.set(\"ViewMode\", ViewMode);",
+ "//",
+ "const Canvas2D = document.getElementsByTagName(\"canvas\")[0];",
+ "gdjs.__WithThreeJS.set(\"Canvas2D\", Canvas2D);",
+ "const Rect = Canvas2D.getBoundingClientRect();",
+ "//",
+ "let Scene;",
+ "if (gdjs.__WithThreeJS.has(\"Scene\")) {",
+ " Scene = gdjs.__WithThreeJS.get(\"Scene\");",
+ "} else {",
+ " Scene = new THREE.Scene();",
+ " gdjs.__WithThreeJS.set(\"Scene\", Scene);",
+ "}",
+ "Scene.name =\"Scene\";",
+ "gdjs.__WithThreeJS.set(\"SceneIsReady\", true);",
+ "//",
+ "const BG_RGB = eventsFunctionContext.getArgument(\"BackGroundColor\") || \"0;0;0\";",
+ "const BG_Img = eventsFunctionContext.getArgument(\"BackGroundImage\") || \"\";",
+ "const Ambient_RGB = eventsFunctionContext.getArgument(\"AmbientColor\") || \"255;255;255\";",
+ "const FogColor = eventsFunctionContext.getArgument(\"FogColor\") || \"\";",
+ "const FogNear = eventsFunctionContext.getArgument(\"FogNear\") || 1;",
+ "const FogFar = eventsFunctionContext.getArgument(\"FogFar\") || 1000;",
+ "//",
+ "if (Scene.background) {",
+ " if (Scene.background.isTexture) {",
+ " Scene.background.dispose();",
+ " Scene.background = null;",
+ " }",
+ "}",
+ "//",
+ "if (BG_Img !== \"\") {",
+ " const Resource = runtimeScene.getGame().getImageManager().getPIXITexture(BG_Img).baseTexture.resource;",
+ " const ResourceWidth = Resource.width;",
+ " const ResourceHeight = Resource.height;",
+ " const BGTexture = new THREE.Texture();",
+ " BGTexture.image = Resource.source;",
+ " if (ResourceWidth == ResourceHeight * 2) {",
+ " BGTexture.mapping = THREE.EquirectangularReflectionMapping;",
+ " }",
+ " BGTexture.colorSpace = THREE.SRGBColorSpace;",
+ " BGTexture.needsUpdate = true;//必須",
+ " Scene.background = BGTexture;",
+ "} else {",
+ " const RGB = BG_RGB.split(\";\");",
+ " Scene.background = new THREE.Color(`rgb(${RGB[0]}, ${RGB[1]}, ${RGB[2]})`);",
+ "}",
+ "//",
+ "let AmbientLight;",
+ "const AmbientColor = Ambient_RGB.split(\";\");",
+ "if (gdjs.__WithThreeJS.has(\"AmbientLight\")) {",
+ " AmbientLight = gdjs.__WithThreeJS.get(\"AmbientLight\");",
+ "} else {",
+ " AmbientLight = new THREE.AmbientLight();",
+ " AmbientLight.intensity = gdjs.__WithThreeJS.get(\"LightIntensityScale\");// Three.js r160",
+ " gdjs.__WithThreeJS.set(\"AmbientLight\", AmbientLight);",
+ "}",
+ "Scene.add(AmbientLight);",
+ "AmbientLight.color.set(`rgb(${AmbientColor[0]}, ${AmbientColor[1]}, ${AmbientColor[2]})`);",
+ "//",
+ "if (FogColor === \"\") {",
+ " Scene.fog = null;",
+ "} else {",
+ " const RGB = FogColor.split(\";\");",
+ " Scene.fog = new THREE.Fog(`rgb(${RGB[0]}, ${RGB[1]}, ${RGB[2]})`, FogNear, FogFar);",
+ " // Scene.fog = new THREE.FogExp2(\"rgb(0,0,0)\", 0.005);",
+ "}",
+ "//",
+ "// 複数カメラ",
+ "let AllCams, Camera1, Camera2, Camera3, Camera4;",
+ "if (gdjs.__WithThreeJS.has(\"AllCams\")) {",
+ " AllCams = gdjs.__WithThreeJS.get(\"AllCams\");",
+ " Camera1 = AllCams.get(\"Camera1\");",
+ " Camera2 = AllCams.get(\"Camera2\");",
+ " Camera3 = AllCams.get(\"Camera3\");",
+ " Camera4 = AllCams.get(\"Camera4\");",
+ "} else {",
+ " AllCams = new Map();",
+ " Camera1 = new THREE.PerspectiveCamera();",
+ " Camera2 = new THREE.PerspectiveCamera();",
+ " Camera3 = new THREE.PerspectiveCamera();",
+ " Camera4 = new THREE.PerspectiveCamera();",
+ " AllCams.set(\"Camera1\", Camera1);",
+ " AllCams.set(\"Camera2\", Camera2);",
+ " AllCams.set(\"Camera3\", Camera3);",
+ " AllCams.set(\"Camera4\", Camera4);",
+ " gdjs.__WithThreeJS.set(\"AllCams\", AllCams);",
+ "}",
+ "for (const [K, V] of AllCams) {",
+ " V.name = K;",
+ " V.fov = 50;",
+ " V.aspect = Rect.width / Rect.height;",
+ " V.near = 0.1;",
+ " V.far = 10000;//1000",
+ " V.position.set(0, 0, 0);",
+ " V.rotation.set(0, 0, 0);",
+ " V.updateProjectionMatrix();//必須",
+ " V.userData.CameraStatus = {};",
+ " V.userData.CameraStatus.Active = false;",
+ " V.userData.CameraStatus.T = 1;",
+ " V.userData.CameraStatus.B = 0;",
+ " V.userData.CameraStatus.L = 0;",
+ " V.userData.CameraStatus.R = 1;",
+ " V.userData.CameraStatus.X = 0;",
+ " V.userData.CameraStatus.Y = 0;",
+ " V.userData.CameraStatus.W = Rect.width;",
+ " V.userData.CameraStatus.H = Rect.height;",
+ "}",
+ "Camera1.userData.CameraStatus.Active = true;",
+ "//",
+ "let Listener;",
+ "if (gdjs.__WithThreeJS.has(\"Listener\")) {",
+ " Listener = gdjs.__WithThreeJS.get(\"Listener\");",
+ "} else {",
+ " Listener = new THREE.AudioListener();",
+ " gdjs.__WithThreeJS.set(\"Listener\", Listener);",
+ "}",
+ "Listener.name =\"Listener\";",
+ "Camera1.add(Listener);",
+ "//",
+ "let Renderer;",
+ "if (gdjs.__WithThreeJS.has(\"Renderer\")) {",
+ " Renderer = gdjs.__WithThreeJS.get(\"Renderer\");",
+ "} else {",
+ " Renderer = new THREE.WebGLRenderer();",
+ " document.body.appendChild( Renderer.domElement );",
+ " gdjs.__WithThreeJS.set(\"Renderer\", Renderer);",
+ "}",
+ "Renderer.setPixelRatio(window.devicePixelRatio);",
+ "// Renderer.setSize( window.innerWidth, window.innerHeight );",
+ "Renderer.setSize(Rect.width, Rect.height);",
+ "Renderer.domElement.id = \"WithThreeJS_Canvas\";",
+ "Renderer.domElement.style.position = \"absolute\";",
+ "Renderer.domElement.style.zIndex = -99;",
+ "Renderer.domElement.style.left = Rect.left + \"px\";",
+ "Renderer.domElement.style.top = Rect.top + \"px\";",
+ "Renderer.setScissorTest(true);",
+ "Renderer.shadowMap.enabled = false;",
+ "// Renderer.shadowMap.type = THREE.PCFShadowMap;//THREE.BasicShadowMap THREE.PCFShadowMap THREE.PCFSoftShadowMap THREE.VSMShadowMap",
+ "// Renderer.outputColorSpace = THREE.LinearSRGBColorSpace;//NoColorSpace SRGBColorSpace LinearSRGBColorSpace",
+ "//",
+ "let AnimationMixer;",
+ "if (gdjs.__WithThreeJS.has(\"AnimationMixer\")) {",
+ " AnimationMixer = gdjs.__WithThreeJS.get(\"AnimationMixer\");",
+ "} else {",
+ " AnimationMixer = new THREE.AnimationMixer(Scene);",
+ " gdjs.__WithThreeJS.set(\"AnimationMixer\", AnimationMixer);",
+ "}",
+ "//",
+ "let AnimationActions;",
+ "if (gdjs.__WithThreeJS.has(\"AnimationActions\")) {",
+ " AnimationActions = gdjs.__WithThreeJS.get(\"AnimationActions\");",
+ "} else {",
+ " AnimationActions = new Map();",
+ " gdjs.__WithThreeJS.set(\"AnimationActions\", AnimationActions);",
+ "}",
+ "//",
+ "// Resize",
+ "window.addEventListener('resize', () => {",
+ " const Rect = Canvas2D.getBoundingClientRect();",
+ "",
+ " // レンダラーのサイズを調整する",
+ " Renderer.setPixelRatio(window.devicePixelRatio);",
+ " Renderer.setSize(Rect.width, Rect.height);",
+ "",
+ " // カメラのアスペクト比を正す",
+ " // Camera.aspect = Rect.width / Rect.height;",
+ " // Camera.updateProjectionMatrix();",
+ " for (const [K, V] of AllCams) {",
+ " const T = V.userData.CameraStatus.T;",
+ " const B = V.userData.CameraStatus.B;",
+ " const L = V.userData.CameraStatus.L;",
+ " const R = V.userData.CameraStatus.R;",
+ " const X = V.userData.CameraStatus.X = L * Rect.width;",
+ " const Y = V.userData.CameraStatus.Y = B * Rect.height;",
+ " const W = V.userData.CameraStatus.W = (R - L) * Rect.width;",
+ " const H = V.userData.CameraStatus.H = (T - B) * Rect.height;",
+ " V.aspect = W / H;",
+ " V.updateProjectionMatrix();",
+ " }",
+ "",
+ " // CSS",
+ " Renderer.domElement.style.position = \"absolute\";",
+ " Renderer.domElement.style.zIndex = -99;",
+ " Renderer.domElement.style.left = Rect.left + \"px\";",
+ " Renderer.domElement.style.top = Rect.top + \"px\";",
+ "});",
+ "",
+ "",
+ ""
+ ],
+ "parameterObjects": "",
+ "useStrict": true,
+ "eventsSheetExpanded": true
+ }
+ ],
+ "parameters": [
+ {
+ "description": "Background Color",
+ "name": "BackGroundColor",
+ "type": "color"
+ },
+ {
+ "description": "Background Image (GDevelop Resource Name) (\"\" => No Background Image)",
+ "longDescription": "Escape is required. example: \"assets\\\\Image.png\" -> \"assets\\\\\\\\Image.png\" \n\"\" => No Background Image \nImage ratio 2:1 (e.g. 1024 x 512 pixels) => Skybox \nOther image ratio => Flat Background Image",
+ "name": "BackGroundImage",
+ "type": "string"
+ },
+ {
+ "description": "Ambient Light Color",
+ "name": "AmbientColor",
+ "type": "color"
+ },
+ {
+ "description": "Fog Color (\"\" is none fog)",
+ "name": "FogColor",
+ "type": "color"
+ },
+ {
+ "description": "Fog Start Distance (Default: 1)",
+ "longDescription": "Distance to start applying fog.",
+ "name": "FogNear",
+ "type": "expression"
+ },
+ {
+ "description": "Fog Maximum Distance (Default: 1000)",
+ "longDescription": "Distance to maximum fog.",
+ "name": "FogFar",
+ "type": "expression"
+ },
+ {
+ "description": "Projection Scale (Recommended: 1)",
+ "longDescription": "Only affects WithThreeJS Behaviors and WithThreeJS Custom Objects. \nAffects X, Y, Z and Width, Height, Depth.",
+ "name": "ProjectionScale",
+ "type": "expression"
+ },
+ {
+ "description": "View Mode",
+ "longDescription": "Only affects WithThreeJS Behaviors and WithThreeJS Custom Objects. \nTop Down: 2D[X, Y, Z-Order] -> 3D[X, Z-Order, Y] or Side: 2D[X, Y, Z-Order] -> 3D[X, -Y, Z-Order]",
+ "name": "ViewMode",
+ "supplementaryInformation": "[\"Top Down\",\"Side\"]",
+ "type": "stringWithSelector"
+ }
+ ],
+ "objectGroups": []
+ },
+ {
+ "description": "Create a 3D Scene and initialize all 3D Cameras.\nThe second parameter is the background image.\nBackground image ratio 2:1 (e.g. 1024 x 512 pixels) => Skybox.\nOther image ratio => Flat background image.\nNo image specified => No Background Image.",
+ "fullName": "🏞️Create 3D Scene",
+ "functionType": "Action",
+ "group": "3D Scene",
+ "name": "Create3DSceneV2",
+ "sentence": "🏞️Create 3D Scene (Background: _PARAM1_, _PARAM2_, Ambient: _PARAM3_, Fog: _PARAM4_, _PARAM5_, _PARAM6_, Projection Scale: _PARAM7_, View Mode: _PARAM8_)",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::JsCode",
+ "inlineCode": [
+ "// console.log(\"Three.js create scene\");",
+ "// v5.1.162 以上で Built-In 3D がゲームに含まれている",
+ "const BuiltIn3D = gdjs.__WithThreeJS.get(\"BuiltIn3D\");",
+ "if (BuiltIn3D) {",
+ " // runtimescene-pixi-renderer.ts カスタム",
+ " console.log(\"[WithThreeJS] Built-in 3D is enabled.\");",
+ " if (!runtimeScene.getRenderer()._threeRenderer._render_WithThreeJS) {",
+ " runtimeScene.getRenderer()._threeRenderer._render_WithThreeJS = runtimeScene.getRenderer()._threeRenderer.render;",
+ " runtimeScene.getRenderer()._threeRenderer.render = function(S, C) {",
+ " // Three.js のレンダラーが利用される場合の透過設定",
+ " runtimeScene.getLayer(\"\").getRenderer().getThreeScene().background = null;",
+ " this._render_WithThreeJS(S, C);",
+ " }",
+ " }",
+ " if (!runtimeScene.getRenderer().getPIXIRenderer()._clear_WithThreeJS) {",
+ " runtimeScene.getRenderer().getPIXIRenderer()._clear_WithThreeJS = runtimeScene.getRenderer().getPIXIRenderer().clear;",
+ " runtimeScene.getRenderer().getPIXIRenderer().clear = function() {",
+ " // PixiJS のレンダラーが利用される場合の透過設定",
+ " runtimeScene.setBackgroundColor(0,0,0);",
+ " if (this.background) {",
+ " this.background.alpha = 0;// For PixiJS 7",
+ " } else {",
+ " this.backgroundAlpha = 0;// For PixiJS 6",
+ " }",
+ " this._clear_WithThreeJS();",
+ " }",
+ " }",
+ "} else {",
+ " console.log(\"[WithThreeJS] Built-in 3D is disabled.\");",
+ " // 警告表示",
+ " let AlertElement = document.createElement('div');",
+ " AlertElement.innerHTML = `Warning from WithThreeJS
",
+ " Please add an \"Enable WithThreeJS\" object to a scene.
",
+ " For more information, please click here.`;",
" AlertElement.style.position = \"absolute\";",
" AlertElement.style.zIndex = 999;",
" AlertElement.style.top = 0;",
@@ -1484,7 +2096,7 @@
"//",
"const ProjectionScale = eventsFunctionContext.getArgument(\"ProjectionScale\") || 1;",
"let ViewMode = eventsFunctionContext.getArgument(\"ViewMode\");",
- "if (ViewMode !== \"Top Down\" && ViewMode !== \"Side\" && ViewMode !== \"Built-In 3D\") {",
+ "if (ViewMode !== \"Top Down\" && ViewMode !== \"Side\") {",
" ViewMode = \"Top Down\";",
"}",
"gdjs.__WithThreeJS.set(\"ProjectionScale\", ProjectionScale);",
@@ -1505,7 +2117,7 @@
"gdjs.__WithThreeJS.set(\"SceneIsReady\", true);",
"//",
"const BG_RGB = eventsFunctionContext.getArgument(\"BackGroundColor\") || \"0;0;0\";",
- "const BG_Img = eventsFunctionContext.getArgument(\"BackGroundImage\") || \"\";",
+ "const BG_Img = eventsFunctionContext.getArgument(\"BackGroundImage\");",
"const Ambient_RGB = eventsFunctionContext.getArgument(\"AmbientColor\") || \"255;255;255\";",
"const FogColor = eventsFunctionContext.getArgument(\"FogColor\") || \"\";",
"const FogNear = eventsFunctionContext.getArgument(\"FogNear\") || 1;",
@@ -1531,7 +2143,7 @@
" BGTexture.needsUpdate = true;//必須",
" Scene.background = BGTexture;",
"} else {",
- " const RGB = BG_RGB.split(\";\");",
+ " const RGB = gdjs.rgbOrHexToRGBColor(BG_RGB);",
" Scene.background = new THREE.Color(`rgb(${RGB[0]}, ${RGB[1]}, ${RGB[2]})`);",
"}",
"//",
@@ -1583,6 +2195,7 @@
" V.far = 10000;//1000",
" V.position.set(0, 0, 0);",
" V.rotation.set(0, 0, 0);",
+ " V.zoom = 1;",
" V.updateProjectionMatrix();//必須",
" V.userData.CameraStatus = {};",
" V.userData.CameraStatus.Active = false;",
@@ -1625,7 +2238,7 @@
"Renderer.domElement.style.top = Rect.top + \"px\";",
"Renderer.setScissorTest(true);",
"Renderer.shadowMap.enabled = false;",
- "// Renderer.shadowMap.type = THREE.BasicShadowMap;//THREE.BasicShadowMap THREE.PCFShadowMap THREE.PCFSoftShadowMap THREE.VSMShadowMap",
+ "Renderer.shadowMap.type = THREE.PCFSoftShadowMap;//THREE.BasicShadowMap THREE.PCFShadowMap THREE.PCFSoftShadowMap THREE.VSMShadowMap",
"// Renderer.outputColorSpace = THREE.LinearSRGBColorSpace;//NoColorSpace SRGBColorSpace LinearSRGBColorSpace",
"//",
"let AnimationMixer;",
@@ -1690,10 +2303,9 @@
"type": "color"
},
{
- "description": "Background Image (GDevelop Resource Name) (\"\" => No Background Image)",
- "longDescription": "Escape is required. example: \"assets\\\\Image.png\" -> \"assets\\\\\\\\Image.png\" \n\"\" => No Background Image \nImage ratio 2:1 (e.g. 1024 x 512 pixels) => Skybox \nOther image ratio => Flat Background Image",
+ "description": "Background Image",
"name": "BackGroundImage",
- "type": "string"
+ "type": "imageResource"
},
{
"description": "Ambient Light Color",
@@ -1733,122 +2345,13 @@
],
"objectGroups": []
},
- {
- "description": "Use this action in place of the \"Create 3D Scene\" action.\nThe built-in 3D axes are different from the axes in WithThreeJS.\nSome WithThreeJS features are not available.\n⚠️ This may be deprecated in the future.",
- "fullName": "Built-In 3D WithThreeJS (Deprecated)",
- "functionType": "Action",
- "group": "3D Scene",
- "name": "BuiltIn3dWithThreeJS",
- "private": true,
- "sentence": "⚠️ Built-In 3D WithThreeJS",
- "events": [
- {
- "type": "BuiltinCommonInstructions::JsCode",
- "inlineCode": [
- "// console.log(\"Three.js create scene\");",
- "/*",
- "影響範囲",
- "onScenePostEvents",
- "onSceneUnloading",
- "BuiltIn3dWithThreeJS",
- "ビヘイビアとカスタムオブジェクトのViewModeまわり",
- "LinkedCameraでBuiltIn3dCameraを参照",
- "*/",
- "// v5.1.162 以上で Built-In 3D がゲームに含まれている",
- "const BuiltIn3D = gdjs.__WithThreeJS.get(\"BuiltIn3D\");",
- "if (BuiltIn3D) {",
- " console.log(\"[WithThreeJS] Built-in 3D is enabled. Built-In 3D WithThreeJS is now enabled.\");",
- " gdjs.__WithThreeJS.set(\"BuiltIn3DWithThreeJS\", true);",
- " gdjs.__WithThreeJS.set(\"Scene\", runtimeScene.getLayer(\"\").getRenderer().getThreeScene());",
- " gdjs.__WithThreeJS.set(\"BuiltIn3dCamera\", runtimeScene.getLayer(\"\").getRenderer().getThreeCamera());",
- " gdjs.__WithThreeJS.set(\"BuiltIn3dRenderer\", runtimeScene.getRenderer()._threeRenderer);",
- "} else {",
- " console.warn(\"[WithThreeJS] Built-in 3D is disabled. Could not enable Built-In 3D WithThreeJS!\");",
- " return;",
- "}",
- "//",
- "gdjs.__WithThreeJS.set(\"ProjectionScale\", 1);",
- "gdjs.__WithThreeJS.set(\"ViewMode\", \"Built-In 3D\");",
- "//",
- "// 以下、互換のために必要",
- "//",
- "gdjs.__WithThreeJS.set(\"SceneIsReady\", true);",
- "const Canvas2D = document.getElementsByTagName(\"canvas\")[0];",
- "gdjs.__WithThreeJS.set(\"Canvas2D\", Canvas2D);",
- "const Rect = Canvas2D.getBoundingClientRect();",
- "//",
- "// 複数カメラ(未使用・共用・再利用)",
- "let AllCams, Camera1, Camera2, Camera3, Camera4;",
- "if (gdjs.__WithThreeJS.has(\"AllCams\")) {",
- " AllCams = gdjs.__WithThreeJS.get(\"AllCams\");",
- " Camera1 = AllCams.get(\"Camera1\");",
- " Camera2 = AllCams.get(\"Camera2\");",
- " Camera3 = AllCams.get(\"Camera3\");",
- " Camera4 = AllCams.get(\"Camera4\");",
- "} else {",
- " AllCams = new Map();",
- " Camera1 = new THREE.PerspectiveCamera();",
- " Camera2 = new THREE.PerspectiveCamera();",
- " Camera3 = new THREE.PerspectiveCamera();",
- " Camera4 = new THREE.PerspectiveCamera();",
- " AllCams.set(\"Camera1\", Camera1);",
- " AllCams.set(\"Camera2\", Camera2);",
- " AllCams.set(\"Camera3\", Camera3);",
- " AllCams.set(\"Camera4\", Camera4);",
- " gdjs.__WithThreeJS.set(\"AllCams\", AllCams);",
- "}",
- "for (const [K, V] of AllCams) {",
- " V.name = K;",
- " V.fov = 50;",
- " V.aspect = Rect.width / Rect.height;",
- " V.near = 0.1;",
- " V.far = 10000;",
- " V.position.set(0, 0, 0);",
- " V.rotation.set(0, 0, 0);",
- " V.updateProjectionMatrix();//必須",
- " V.userData.CameraStatus = {};",
- " V.userData.CameraStatus.Active = false;",
- " V.userData.CameraStatus.T = 1;",
- " V.userData.CameraStatus.B = 0;",
- " V.userData.CameraStatus.L = 0;",
- " V.userData.CameraStatus.R = 1;",
- " V.userData.CameraStatus.X = 0;",
- " V.userData.CameraStatus.Y = 0;",
- " V.userData.CameraStatus.W = Rect.width;",
- " V.userData.CameraStatus.H = Rect.height;",
- "}",
- "//",
- "// リスナー(共用しない・遷移時破棄)",
- "const Listener = new THREE.AudioListener();",
- "gdjs.__WithThreeJS.set(\"Listener\", Listener);",
- "Listener.name =\"Listener\";",
- "gdjs.__WithThreeJS.get(\"BuiltIn3dCamera\").add(Listener);",
- "//",
- "// レンダラーとキャンバス(未使用・共用・再利用)",
- "if (!gdjs.__WithThreeJS.has(\"Renderer\")) {",
- " const Renderer = new THREE.WebGLRenderer();",
- " document.body.appendChild( Renderer.domElement );",
- " gdjs.__WithThreeJS.set(\"Renderer\", Renderer);",
- " Renderer.domElement.id = \"WithThreeJS_Canvas\";",
- "}",
- "",
- ""
- ],
- "parameterObjects": "",
- "useStrict": true,
- "eventsSheetExpanded": true
- }
- ],
- "parameters": [],
- "objectGroups": []
- },
{
"description": "Clear 3D Scene. Removes all 3D Objects in the 3D Scene.\nAs a result, this action also removes 2D Objects that have 3D Projection Behaviors.\nThis action does not clear the loaded 3D Texture data and the loaded 3D Model data.\nThey will continue to be accessible by ID.",
- "fullName": "Clear 3D Scene",
+ "fullName": "🗑️Clear 3D Scene",
"functionType": "Action",
"group": "3D Scene",
"name": "Clear3DScene",
- "sentence": "Clear 3D Scene",
+ "sentence": "🗑️Clear 3D Scene",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -1875,7 +2378,13 @@
" }",
"}",
"//",
- "gdjs.__WithThreeJS.get(\"AllSoundsStop\")(Scene);",
+ "Scene.traverse((Child) => {",
+ " if (Child.type === \"Audio\") {",
+ " if (Child.isPlaying) {",
+ " Child.stop();",
+ " }",
+ " }",
+ "});",
"//",
"AnimationMixer.stopAllAction();",
"for (const [K, V] of AnimationActions) {",
@@ -1887,6 +2396,7 @@
"}",
"AnimationActions.clear();",
"//",
+ "gdjs.__WithThreeJS.get(\"ObjectList\").clear();",
"Scene.clear();",
"",
""
@@ -1900,13 +2410,13 @@
"objectGroups": []
},
{
- "description": "Load image from GDevelop resources and create 3D Texture.\nNote that this is an asynchronous process.",
- "fullName": "Load 3D Texture (Deprecated)",
+ "description": "Load image from GDevelop resources and create 3D Texture.",
+ "fullName": "Load 3D Texture V2 (Deprecated)",
"functionType": "Action",
"group": "3D Scene",
- "name": "Load3DTexture",
+ "name": "Load3DTextureV2",
"private": true,
- "sentence": "⚠️ Load 3D Texture (Resource: _PARAM1_, ID: _PARAM2_, Repeat: _PARAM3_, _PARAM4_)",
+ "sentence": "⚠️ Load 3D Texture V2 (Resource: _PARAM1_, ID: _PARAM2_, Repeat: _PARAM3_, _PARAM4_, Anti-Aliasing: _PARAM5_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -1923,22 +2433,23 @@
"const TextureId = eventsFunctionContext.getArgument(\"TextureId\");",
"const RepeatU = eventsFunctionContext.getArgument(\"RepeatU\");",
"const RepeatV = eventsFunctionContext.getArgument(\"RepeatV\");",
+ "const AntiAliasing = eventsFunctionContext.getArgument(\"AntiAliasing\");",
"//",
- "const GetResourceFileName = gdjs.__WithThreeJS.get(\"GetResourceFileName\");",
- "const ResourceFileName = GetResourceFileName(ResourceName, \"image\");",
- "if (ResourceFileName) {",
- " const Loader = new THREE.TextureLoader();",
- " Loader.load(GetResourceFileName(ResourceName, \"image\"), ",
- " (T) => {",
- " T.wrapS = THREE.RepeatWrapping;",
- " T.wrapT = THREE.RepeatWrapping;",
- " T.repeat.set(RepeatU, RepeatV);",
- " Textures.set(TextureId, T);",
- " },",
- " undefined,",
- " (E) => {}",
- " );",
+ "if (!Textures.has(TextureId)) {",
+ " const T = new THREE.Texture();",
+ " T.image = runtimeScene.getGame().getImageManager().getPIXITexture(ResourceName).baseTexture.resource.source;",
+ " T.wrapS = THREE.RepeatWrapping;",
+ " T.wrapT = THREE.RepeatWrapping;",
+ " T.repeat.set(RepeatU, RepeatV);",
+ " if (!AntiAliasing) {",
+ " T.magFilter = THREE.NearestFilter;// THREE.LinearFilter",
+ " T.minFilter = THREE.NearestFilter;// THREE.LinearMipmapLinearFilter",
+ " }",
+ " T.colorSpace = THREE.SRGBColorSpace;//NoColorSpace SRGBColorSpace LinearSRGBColorSpace",
+ " T.needsUpdate = true;//必須",
+ " Textures.set(TextureId, T);",
"}",
+ "",
""
],
"parameterObjects": "",
@@ -1968,17 +2479,25 @@
"description": "Texture Repeat V",
"name": "RepeatV",
"type": "expression"
+ },
+ {
+ "defaultValue": "True",
+ "description": "Anti-Aliasing",
+ "name": "AntiAliasing",
+ "optional": true,
+ "supplementaryInformation": "[\"Antialiased\",\"No Antialiasing\"]",
+ "type": "trueorfalse"
}
],
"objectGroups": []
},
{
"description": "Load image from GDevelop resources and create 3D Texture.",
- "fullName": "Load 3D Texture",
+ "fullName": "📥Load 3D Texture",
"functionType": "Action",
"group": "3D Scene",
- "name": "Load3DTextureV2",
- "sentence": "Load 3D Texture (Resource: _PARAM1_, ID: _PARAM2_, Repeat: _PARAM3_, _PARAM4_, Anti-Aliasing: _PARAM5_)",
+ "name": "Load3DTextureV3",
+ "sentence": "📥Load 3D Texture (Resource: _PARAM1_, ID: _PARAM2_, Repeat: _PARAM3_, _PARAM4_, Anti-Aliasing: _PARAM5_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -2022,9 +2541,8 @@
"parameters": [
{
"description": "GDevelop Resource Name (Image)",
- "longDescription": "Escape is required. example: \"assets\\\\Image.png\" -> \"assets\\\\\\\\Image.png\"",
"name": "ResourceName",
- "type": "string"
+ "type": "imageResource"
},
{
"description": "3D Texture ID",
@@ -2054,11 +2572,11 @@
"objectGroups": []
},
{
- "fullName": "Load 3D Model From OBJ",
+ "fullName": "📥Load 3D Model From OBJ",
"functionType": "Action",
"group": "3D Scene",
"name": "Load3DModelFromOBJ",
- "sentence": "Load 3D Model From OBJ (ID: _PARAM2_)",
+ "sentence": "📥Load 3D Model From OBJ (ID: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -2103,11 +2621,11 @@
},
{
"description": "Do a Raycast.\nYou can get the count of 3D Objects in the result with the \"Raycast Result Count\" expression.\nThe result can be accessed via the \"Raycast Result Number\" expression or the \"Raycast Result String\" string expression.",
- "fullName": "Raycast",
+ "fullName": "🔎Raycast",
"functionType": "Action",
"group": "3D Raycast",
"name": "Raycast",
- "sentence": "Raycast (From: _PARAM1_, _PARAM2_, _PARAM3_, To: _PARAM4_, _PARAM5_, _PARAM6_)",
+ "sentence": "🔎Raycast (From: _PARAM1_, _PARAM2_, _PARAM3_, To: _PARAM4_, _PARAM5_, _PARAM6_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -2185,11 +2703,11 @@
},
{
"description": "Do a Raycast from the 3D Camera.\nYou can get the count of 3D Objects in the result with the \"Raycast Result Count\" expression.\nThe result can be accessed via the \"Raycast Result Number\" expression or the \"Raycast Result String\" string expression.",
- "fullName": "Raycast From 3D Camera",
+ "fullName": "🔎Raycast From 3D Camera",
"functionType": "Action",
"group": "3D Raycast",
"name": "RaycastFrom3DCamera",
- "sentence": "Raycast From 3D Camera (ID: _PARAM1_, Screen: _PARAM2_, _PARAM3_)",
+ "sentence": "🔎Raycast From 3D Camera (ID: _PARAM1_, Screen: _PARAM2_, _PARAM3_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -2258,11 +2776,11 @@
},
{
"description": "Do a Raycast from the 3D Object. (Z axis direction)\nYou can get the count of 3D Objects in the result with the \"Raycast Result Count\" expression.\nThe result can be accessed via the \"Raycast Result Number\" expression or the \"Raycast Result String\" string expression.",
- "fullName": "Raycast From 3D Object",
+ "fullName": "🔎Raycast From 3D Object",
"functionType": "Action",
"group": "3D Raycast",
"name": "RaycastFrom3DObject",
- "sentence": "Raycast From 3D Object (ID: _PARAM1_, Distance: _PARAM2_)",
+ "sentence": "🔎Raycast From 3D Object (ID: _PARAM1_, Distance: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -2282,7 +2800,7 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const Distance = eventsFunctionContext.getArgument(\"Distance\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -2320,11 +2838,11 @@
"objectGroups": []
},
{
- "fullName": "Place 3D Object Using Raycast Result",
+ "fullName": "🔎Place 3D Object Using Raycast Result",
"functionType": "Action",
"group": "3D Raycast",
"name": "Place3DObjectUsingRaycastResult",
- "sentence": "Place 3D Object Using Raycast Result (ID: _PARAM1_, Result: _PARAM2_, Position: _PARAM3_, Normal: _PARAM4_)",
+ "sentence": "🔎Place 3D Object Using Raycast Result (ID: _PARAM1_, Result: _PARAM2_, Position: _PARAM3_, Normal: _PARAM4_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -2345,7 +2863,7 @@
"const Position = eventsFunctionContext.getArgument(\"Position\");",
"const Normal = eventsFunctionContext.getArgument(\"Normal\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -2571,11 +3089,11 @@
"objectGroups": []
},
{
- "fullName": "Create 3D Sprite",
+ "fullName": "✨Create 3D Sprite",
"functionType": "Action",
"group": "3D Object",
"name": "Create3DSprite",
- "sentence": "Create 3D Sprite (ID: _PARAM1_, X: _PARAM2_, Y: _PARAM3_, Z: _PARAM4_, Scale: _PARAM5_, Texture: _PARAM6_, αTest: _PARAM7_, Opacity: _PARAM8_, Blend: _PARAM9_)",
+ "sentence": "✨Create 3D Sprite (ID: _PARAM1_, X: _PARAM2_, Y: _PARAM3_, Z: _PARAM4_, Scale: _PARAM5_, Texture: _PARAM6_, αTest: _PARAM7_, Opacity: _PARAM8_, Blend: _PARAM9_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -2686,11 +3204,11 @@
"objectGroups": []
},
{
- "fullName": "Create 3D Plane",
+ "fullName": "✨Create 3D Plane",
"functionType": "Action",
"group": "3D Object",
"name": "Create3DPlane",
- "sentence": "Create 3D Plane (ID: _PARAM1_, X: _PARAM2_, Y: _PARAM3_, Z: _PARAM4_, AX: _PARAM5_, AY: _PARAM6_, AZ: _PARAM7_, W: _PARAM8_, H: _PARAM9_, Texture: _PARAM10_, αTest: _PARAM11_, Opacity: _PARAM12_, Blend: _PARAM13_)",
+ "sentence": "✨Create 3D Plane (ID: _PARAM1_, X: _PARAM2_, Y: _PARAM3_, Z: _PARAM4_, AX: _PARAM5_, AY: _PARAM6_, AZ: _PARAM7_, W: _PARAM8_, H: _PARAM9_, Texture: _PARAM10_, αTest: _PARAM11_, Opacity: _PARAM12_, Blend: _PARAM13_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -2824,11 +3342,11 @@
"objectGroups": []
},
{
- "fullName": "Create 3D Box",
+ "fullName": "✨Create 3D Box",
"functionType": "Action",
"group": "3D Object",
"name": "Create3DBox",
- "sentence": "Create 3D Box (ID: _PARAM1_, X: _PARAM2_, Y: _PARAM3_, Z: _PARAM4_, AX: _PARAM5_, AY: _PARAM6_, AZ: _PARAM7_, W: _PARAM8_, H: _PARAM9_, D: _PARAM10_, Texture: _PARAM11_, αTest: _PARAM12_, Opacity: _PARAM13_, Blend: _PARAM14_)",
+ "sentence": "✨Create 3D Box (ID: _PARAM1_, X: _PARAM2_, Y: _PARAM3_, Z: _PARAM4_, AX: _PARAM5_, AY: _PARAM6_, AZ: _PARAM7_, W: _PARAM8_, H: _PARAM9_, D: _PARAM10_, Texture: _PARAM11_, αTest: _PARAM12_, Opacity: _PARAM13_, Blend: _PARAM14_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -2989,11 +3507,12 @@
"objectGroups": []
},
{
- "fullName": "Create 3D Model",
+ "description": "Create a new 3D model from the 3D model loaded with the \"Load 3D Model From OBJ\" action.",
+ "fullName": "💎Create 3D Model",
"functionType": "Action",
"group": "3D Object",
"name": "Create3DModel",
- "sentence": "Create 3D Model (3D Model: _PARAM1_, ID: _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_, AX: _PARAM6_, AY: _PARAM7_, AZ: _PARAM8_, Scale: _PARAM9_, Texture: _PARAM10_, αTest: _PARAM11_, Opacity: _PARAM12_, Blend: _PARAM13_)",
+ "sentence": "💎Create 3D Model (3D Model: _PARAM1_, ID: _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_, AX: _PARAM6_, AY: _PARAM7_, AZ: _PARAM8_, Scale: _PARAM9_, Texture: _PARAM10_, αTest: _PARAM11_, Opacity: _PARAM12_, Blend: _PARAM13_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -3054,7 +3573,6 @@
"//",
"const Model = Models.get(ModelId).clone();",
"//",
- "// gdjs.__WithThreeJS.get(\"AllMaterialClone\")(Model, Transparent, AlphaTest, Blend, Opacity);",
"const Mats = new Map();",
"gdjs.__WithThreeJS.get(\"GetAllMaterials\")(Model, Mats);",
"for (const [K, V] of Mats) {",
@@ -3071,7 +3589,7 @@
"Model.rotation.set(gdjs.toRad(AngleX), gdjs.toRad(AngleY), gdjs.toRad(AngleZ));",
"Model.name = Id;",
"Model.scale.setScalar(Scale);",
- "gdjs.__WithThreeJS.get(\"SettingRecursiveTextures\")(Model, TextureList);",
+ "gdjs.__WithThreeJS.get(\"SetAllTextures\")(Model, TextureList);",
"Scene.add(Model);",
"",
""
@@ -3159,11 +3677,11 @@
"objectGroups": []
},
{
- "fullName": "Create 3D Model From Built-In 3D Model",
+ "fullName": "💎Create 3D Model From Built-In 3D Model",
"functionType": "Action",
"group": "3D Object",
"name": "Create3DModelFromBuiltIn",
- "sentence": "Create 3D Model From Built-In (3D Model: _PARAM1_, ID: _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_, AX: _PARAM6_, AY: _PARAM7_, AZ: _PARAM8_, Scale: _PARAM9_)",
+ "sentence": "💎Create 3D Model From Built-In (3D Model: _PARAM1_, ID: _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_, AX: _PARAM6_, AY: _PARAM7_, AZ: _PARAM8_, Scale: _PARAM9_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -3230,19 +3748,136 @@
"// const Model = Models.get(ModelResourceName).clone();// これだとボーンが機能しなくなる",
"const Model = THREE_ADDONS.SkeletonUtils.clone(Models.get(ModelResourceName));",
"//",
- "const Mats = new Map();",
- "gdjs.__WithThreeJS.get(\"GetAllMaterials\")(Model, Mats);",
- "for (const [K, V] of Mats) {",
- " const CloneMaterial = V.clone();",
- " Mats.set(K, CloneMaterial);",
+ "const Mats = new Map();",
+ "gdjs.__WithThreeJS.get(\"GetAllMaterials\")(Model, Mats);",
+ "for (const [K, V] of Mats) {",
+ " const CloneMaterial = V.clone();",
+ " Mats.set(K, CloneMaterial);",
+ "}",
+ "gdjs.__WithThreeJS.get(\"ReplaceMaterial\")(Model, Mats);",
+ "//",
+ "Model.position.set(X, Y, Z);",
+ "Model.rotation.set(gdjs.toRad(AngleX), gdjs.toRad(AngleY), gdjs.toRad(AngleZ));",
+ "Model.name = Id;",
+ "Model.scale.setScalar(Scale);",
+ "Scene.add(Model);",
+ "",
+ ""
+ ],
+ "parameterObjects": "",
+ "useStrict": true,
+ "eventsSheetExpanded": true
+ }
+ ],
+ "parameters": [
+ {
+ "description": "3D Model Object",
+ "name": "ModelObject",
+ "supplementaryInformation": "Scene3D::Model3DObject",
+ "type": "objectList"
+ },
+ {
+ "description": "3D Object ID",
+ "name": "Id",
+ "supplementaryInformation": "scene3D Object ID",
+ "type": "identifier"
+ },
+ {
+ "description": "X",
+ "name": "X",
+ "type": "expression"
+ },
+ {
+ "description": "Y",
+ "name": "Y",
+ "type": "expression"
+ },
+ {
+ "description": "Z",
+ "name": "Z",
+ "type": "expression"
+ },
+ {
+ "description": "Angle X Axis",
+ "name": "AngleX",
+ "type": "expression"
+ },
+ {
+ "description": "Angle Y Axis",
+ "name": "AngleY",
+ "type": "expression"
+ },
+ {
+ "description": "Angle Z Axis",
+ "name": "AngleZ",
+ "type": "expression"
+ },
+ {
+ "description": "Scale",
+ "name": "Scale",
+ "type": "expression"
+ }
+ ],
+ "objectGroups": []
+ },
+ {
+ "description": "⚠️ 3D Lights are highly loaded.\n3D Directional Light and 3D Spot Light emit light in the -Z direction.\n3D Lights can be handled like 3D Objects.",
+ "fullName": "Create 3D Light V1 (Deprecated)",
+ "functionType": "Action",
+ "group": "3D Light",
+ "name": "Create3DLight",
+ "private": true,
+ "sentence": "⚠️ Create 3D Light V1 (ID: _PARAM1_, Type: _PARAM2_, Color: _PARAM3_, Intensity: _PARAM4_, Distance: _PARAM5_, SpotAngle: _PARAM6_, SpotPenumbra: _PARAM7_, Pos: _PARAM8_, _PARAM9_, _PARAM10_, Ang: _PARAM11_, _PARAM12_, _PARAM13_)",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::JsCode",
+ "inlineCode": [
+ "if (!gdjs.__WithThreeJS.has(\"Renderer\")) {",
+ " console.warn(\"!\");",
+ " return;",
+ "}",
+ "const Scene = gdjs.__WithThreeJS.get(\"Scene\");",
+ "//",
+ "const LightId = eventsFunctionContext.getArgument(\"LightId\");",
+ "const LightType = eventsFunctionContext.getArgument(\"Type\");",
+ "const Color = eventsFunctionContext.getArgument(\"Color\") || \"255;255;255\";",
+ "let Intensity = eventsFunctionContext.getArgument(\"Intensity\");",
+ "const Distance = eventsFunctionContext.getArgument(\"Distance\");",
+ "const Decay = 2;",
+ "const SpotAngle = eventsFunctionContext.getArgument(\"SpotAngle\");",
+ "const SpotPenumbra = eventsFunctionContext.getArgument(\"SpotPenumbra\");",
+ "const X = eventsFunctionContext.getArgument(\"X\");",
+ "const Y = eventsFunctionContext.getArgument(\"Y\");",
+ "const Z = eventsFunctionContext.getArgument(\"Z\");",
+ "const AngleX = eventsFunctionContext.getArgument(\"AngleX\");",
+ "const AngleY = eventsFunctionContext.getArgument(\"AngleY\");",
+ "const AngleZ = eventsFunctionContext.getArgument(\"AngleZ\");",
+ "//",
+ "const RGB = Color.split(\";\");",
+ "let Light;",
+ "if (LightType == \"Directional Light\") {",
+ " Intensity *= gdjs.__WithThreeJS.get(\"LightIntensityScale\");// Three.js r160",
+ " Light = new THREE.DirectionalLight(`rgb(${RGB[0]}, ${RGB[1]}, ${RGB[2]})`, Intensity);",
+ " const Target = new THREE.Group();",
+ " Target.translateZ(-1);",
+ " Light.add(Target);",
+ " Light.target = Target;",
+ "} else if (LightType == \"Spot Light\") {",
+ " Intensity *= gdjs.__WithThreeJS.get(\"LightIntensityCandela\");// Three.js r160",
+ " Light = new THREE.SpotLight(`rgb(${RGB[0]}, ${RGB[1]}, ${RGB[2]})`, Intensity, Distance, gdjs.toRad(SpotAngle), SpotPenumbra, Decay);",
+ " const Target = new THREE.Group();",
+ " Target.translateZ(-1);",
+ " Light.add(Target);",
+ " Light.target = Target;",
+ "} else {",
+ " // Point",
+ " Intensity *= gdjs.__WithThreeJS.get(\"LightIntensityCandela\");// Three.js r160",
+ " Light = new THREE.PointLight(`rgb(${RGB[0]}, ${RGB[1]}, ${RGB[2]})`, Intensity, Distance, Decay);",
"}",
- "gdjs.__WithThreeJS.get(\"ReplaceMaterial\")(Model, Mats);",
- "//",
- "Model.position.set(X, Y, Z);",
- "Model.rotation.set(gdjs.toRad(AngleX), gdjs.toRad(AngleY), gdjs.toRad(AngleZ));",
- "Model.name = Id;",
- "Model.scale.setScalar(Scale);",
- "Scene.add(Model);",
+ "Light.name = LightId;",
+ "Light.position.set(X, Y, Z);",
+ "Light.rotation.set(gdjs.toRad(AngleX), gdjs.toRad(AngleY), gdjs.toRad(AngleZ));",
+ "Scene.add(Light);",
"",
""
],
@@ -3253,17 +3888,45 @@
],
"parameters": [
{
- "description": "3D Model Object",
- "name": "ModelObject",
- "supplementaryInformation": "Scene3D::Model3DObject",
- "type": "objectList"
- },
- {
- "description": "3D Object ID",
- "name": "Id",
+ "description": "3D Light ID (3D Object ID)",
+ "name": "LightId",
"supplementaryInformation": "scene3D Object ID",
"type": "identifier"
},
+ {
+ "description": "Light Type",
+ "name": "Type",
+ "supplementaryInformation": "[\"Directional Light\",\"Point Light\",\"Spot Light\"]",
+ "type": "stringWithSelector"
+ },
+ {
+ "description": "Color",
+ "name": "Color",
+ "type": "color"
+ },
+ {
+ "description": "Intensity (Default: 1)",
+ "name": "Intensity",
+ "type": "expression"
+ },
+ {
+ "description": "Distance (Default: 0)",
+ "longDescription": "For Point and Spot Lights.\n0 is no limit.",
+ "name": "Distance",
+ "type": "expression"
+ },
+ {
+ "description": "Spot Angle (0 to 180)",
+ "longDescription": "For Spot Lights.",
+ "name": "SpotAngle",
+ "type": "expression"
+ },
+ {
+ "description": "Spot Penumbra (0 to 1)",
+ "longDescription": "For Spot Lights.",
+ "name": "SpotPenumbra",
+ "type": "expression"
+ },
{
"description": "X",
"name": "X",
@@ -3293,22 +3956,17 @@
"description": "Angle Z Axis",
"name": "AngleZ",
"type": "expression"
- },
- {
- "description": "Scale",
- "name": "Scale",
- "type": "expression"
}
],
"objectGroups": []
},
{
"description": "⚠️ 3D Lights are highly loaded.\n3D Directional Light and 3D Spot Light emit light in the -Z direction.\n3D Lights can be handled like 3D Objects.",
- "fullName": "Create 3D Light",
+ "fullName": "💡Create 3D Light",
"functionType": "Action",
"group": "3D Light",
- "name": "Create3DLight",
- "sentence": "Create 3D Light (ID: _PARAM1_, Type: _PARAM2_, Color: _PARAM3_, Intensity: _PARAM4_, Distance: _PARAM5_, SpotAngle: _PARAM6_, SpotPenumbra: _PARAM7_, Pos: _PARAM8_, _PARAM9_, _PARAM10_, Ang: _PARAM11_, _PARAM12_, _PARAM13_)",
+ "name": "Create3DLightV2",
+ "sentence": "💡Create 3D Light (ID: _PARAM1_, Type: _PARAM2_, Color: _PARAM3_, Intensity: _PARAM4_, Distance: _PARAM5_, SpotAngle: _PARAM6_, SpotPenumbra: _PARAM7_, Pos: _PARAM8_, _PARAM9_, _PARAM10_, Ang: _PARAM11_, _PARAM12_, _PARAM13_, Shadow: _PARAM14_, Size: _PARAM15_, Range: _PARAM16_, Bias: _PARAM17_, _PARAM18_, Helper: _PARAM19_, _PARAM20_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -3318,6 +3976,7 @@
" return;",
"}",
"const Scene = gdjs.__WithThreeJS.get(\"Scene\");",
+ "const Renderer = gdjs.__WithThreeJS.get(\"Renderer\");",
"//",
"const LightId = eventsFunctionContext.getArgument(\"LightId\");",
"const LightType = eventsFunctionContext.getArgument(\"Type\");",
@@ -3333,6 +3992,13 @@
"const AngleX = eventsFunctionContext.getArgument(\"AngleX\");",
"const AngleY = eventsFunctionContext.getArgument(\"AngleY\");",
"const AngleZ = eventsFunctionContext.getArgument(\"AngleZ\");",
+ "const CastShadow = eventsFunctionContext.getArgument(\"CastShadow\");",
+ "const ShadowMapSize = gdjs.__WithThreeJS.get(\"ShadowMapSizeStringToValue\")[eventsFunctionContext.getArgument(\"ShadowMapSize\")];",
+ "const ShadowRange = eventsFunctionContext.getArgument(\"ShadowRange\");",
+ "const ShadowBias = eventsFunctionContext.getArgument(\"ShadowBias\");",
+ "const ShadowNormalBias = eventsFunctionContext.getArgument(\"ShadowNormalBias\");",
+ "const LightHelper = eventsFunctionContext.getArgument(\"LightHelper\");",
+ "const ShadowHelper = eventsFunctionContext.getArgument(\"ShadowHelper\");",
"//",
"const RGB = Color.split(\";\");",
"let Light;",
@@ -3340,9 +4006,22 @@
" Intensity *= gdjs.__WithThreeJS.get(\"LightIntensityScale\");// Three.js r160",
" Light = new THREE.DirectionalLight(`rgb(${RGB[0]}, ${RGB[1]}, ${RGB[2]})`, Intensity);",
" const Target = new THREE.Group();",
- " Target.translateZ(-1);",
+ " Target.translateZ(-128);",
" Light.add(Target);",
" Light.target = Target;",
+ " //",
+ " Light.shadow.camera.top = ShadowRange / 2;",
+ " Light.shadow.camera.right = ShadowRange / 2;",
+ " Light.shadow.camera.bottom = -ShadowRange / 2;",
+ " Light.shadow.camera.left = -ShadowRange / 2;",
+ " Light.shadow.camera.near = 0.5;// default",
+ " Light.shadow.camera.far = ShadowRange;",
+ " //",
+ " if (LightHelper) {",
+ " const DirectionalLightHelper = new THREE.DirectionalLightHelper(Light, 128);",
+ " DirectionalLightHelper.name = LightId + \"_DirectionalLightHelper\";",
+ " Scene.add(DirectionalLightHelper);",
+ " }",
"} else if (LightType == \"Spot Light\") {",
" Intensity *= gdjs.__WithThreeJS.get(\"LightIntensityCandela\");// Three.js r160",
" Light = new THREE.SpotLight(`rgb(${RGB[0]}, ${RGB[1]}, ${RGB[2]})`, Intensity, Distance, gdjs.toRad(SpotAngle), SpotPenumbra, Decay);",
@@ -3350,15 +4029,57 @@
" Target.translateZ(-1);",
" Light.add(Target);",
" Light.target = Target;",
+ " //",
+ " Light.shadow.camera.near = 0.5;// default",
+ " Light.shadow.camera.far = ShadowRange;",
+ " Light.shadow.focus = 1; // default",
+ " //",
+ " if (LightHelper) {",
+ " const SpotLightHelper = new THREE.SpotLightHelper(Light);",
+ " SpotLightHelper.name = LightId + \"_SpotLightHelper\";",
+ " Scene.add(SpotLightHelper);",
+ " }",
"} else {",
" // Point",
" Intensity *= gdjs.__WithThreeJS.get(\"LightIntensityCandela\");// Three.js r160",
" Light = new THREE.PointLight(`rgb(${RGB[0]}, ${RGB[1]}, ${RGB[2]})`, Intensity, Distance, Decay);",
+ " //",
+ " Light.shadow.camera.near = 0.5;// default",
+ " Light.shadow.camera.far = ShadowRange;",
+ " //",
+ " if (LightHelper) {",
+ " const PointLightHelper = new THREE.PointLightHelper(Light, 16);",
+ " PointLightHelper.name = LightId + \"_PointLightHelper\";",
+ " Scene.add(PointLightHelper);",
+ " }",
"}",
+ "Renderer.shadowMap.enabled = Renderer.shadowMap.enabled ? true : CastShadow;",
+ "Light.castShadow = CastShadow;",
+ "Light.shadow.mapSize.width = ShadowMapSize;",
+ "Light.shadow.mapSize.height = ShadowMapSize;",
+ "Light.shadow.bias = ShadowBias;",
+ "Light.shadow.normalBias = ShadowNormalBias;",
+ "Light.shadow.updateMatrices(Light);// 必須",
+ "Light.shadow.camera.updateProjectionMatrix();",
+ "//",
"Light.name = LightId;",
"Light.position.set(X, Y, Z);",
"Light.rotation.set(gdjs.toRad(AngleX), gdjs.toRad(AngleY), gdjs.toRad(AngleZ));",
"Scene.add(Light);",
+ "//",
+ "if (ShadowHelper && CastShadow) {",
+ " let CameraHelper;",
+ " if (LightType != \"Point Light\") {",
+ " CameraHelper = new THREE.CameraHelper(Light.shadow.camera);",
+ " Scene.add(CameraHelper);",
+ " } else {",
+ " const Geometry = new THREE.IcosahedronGeometry(Light.shadow.camera.far, 2); ",
+ " const Material = new THREE.MeshBasicMaterial( {color: 0xffaa00, wireframe: true} );",
+ " CameraHelper = new THREE.Mesh(Geometry, Material);",
+ " Light.add(CameraHelper);",
+ " }",
+ " CameraHelper.name = LightId + \"_CameraHelper\";",
+ "}",
"",
""
],
@@ -3392,13 +4113,13 @@
},
{
"description": "Distance (Default: 0)",
- "longDescription": "For Point and Spot Lights.\n0 is no limit.",
+ "longDescription": "For Point and Spot Lights. \n0 is no limit.",
"name": "Distance",
"type": "expression"
},
{
"description": "Spot Angle (0 to 180)",
- "longDescription": "For Spot Lights.",
+ "longDescription": "For Spot Lights. \nThe narrower the angle, the better the shadow quality. \nIf it is a multiple of 90, the shadow will not be cast correctly.",
"name": "SpotAngle",
"type": "expression"
},
@@ -3437,17 +4158,58 @@
"description": "Angle Z Axis",
"name": "AngleZ",
"type": "expression"
+ },
+ {
+ "description": "Cast Shadow",
+ "longDescription": "⚠️ This is expensive and requires tweaking to get shadows looking right.",
+ "name": "CastShadow",
+ "type": "yesorno"
+ },
+ {
+ "description": "Shadow Map Size (Default: 512px)",
+ "longDescription": "The larger the map, the better the shadow quality, but the greater the load.",
+ "name": "ShadowMapSize",
+ "supplementaryInformation": "[\"128px\",\"256px\",\"512px\",\"1024px\",\"2048px\"]",
+ "type": "stringWithSelector"
+ },
+ {
+ "description": "Range to Draw Shadows (Default: 256)",
+ "longDescription": "The smaller the range, the better the shadow quality. \nFor Point and Spot Lights, this value is valid only if the Distance is 0.",
+ "name": "ShadowRange",
+ "type": "expression"
+ },
+ {
+ "description": "Shadow Depth Bias (Default: 0.002)",
+ "longDescription": "It is mainly effective for filling gaps between objects and shadows. \nReference value: [Directional Light: 0.002] [Point Light: 0.001] [Spot Light: 0.00001]",
+ "name": "ShadowDepthBias",
+ "type": "expression"
+ },
+ {
+ "description": "Shadow Normal Bias (Default: 2)",
+ "longDescription": "It is mainly effective in reducing striped patterns. \nReference value: [Directional Light: 2] [Point Light: 1] [Spot Light: 1]",
+ "name": "ShadowNormalBias",
+ "type": "expression"
+ },
+ {
+ "description": "Light Helper",
+ "name": "LightHelper",
+ "type": "yesorno"
+ },
+ {
+ "description": "Shadow Range Helper",
+ "name": "ShadowHelper",
+ "type": "yesorno"
}
],
"objectGroups": []
},
{
"description": "This 3D Object without geometry is useful for grouping other 3D Objects together or changing their center point.",
- "fullName": "Create 3D Group",
+ "fullName": "👥Create 3D Group",
"functionType": "Action",
"group": "3D Object",
"name": "Create3DGroup",
- "sentence": "Create 3D Group (ID: _PARAM1_, X: _PARAM2_, Y: _PARAM3_, Z: _PARAM4_, AX: _PARAM5_, AY: _PARAM6_, AZ: _PARAM7_)",
+ "sentence": "👥Create 3D Group (ID: _PARAM1_, X: _PARAM2_, Y: _PARAM3_, Z: _PARAM4_, AX: _PARAM5_, AY: _PARAM6_, AZ: _PARAM7_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -3519,11 +4281,11 @@
},
{
"description": "Move a 3D Camera.\n'=' is relative to the parent axis.\n\"+\" and \"-\" are relative to the local axis.",
- "fullName": "Move 3D Camera",
+ "fullName": "↔️Move 3D Camera",
"functionType": "Action",
"group": "3D Camera",
"name": "Move3DCamera",
- "sentence": "Move 3D Camera (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
+ "sentence": "↔️Move 3D Camera (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -3591,11 +4353,11 @@
},
{
"description": "Rotate the 3D Camera in the order X, Y, Z.",
- "fullName": "Rotate 3D Camera",
+ "fullName": "🔄️Rotate 3D Camera",
"functionType": "Action",
"group": "3D Camera",
"name": "Rotate3DCamera",
- "sentence": "Rotate 3D Camera (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
+ "sentence": "🔄️Rotate 3D Camera (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -3663,11 +4425,11 @@
},
{
"description": "Rotate the 3D Camera in the order X, Y, Z on the world axis.",
- "fullName": "Rotate 3D Camera On World",
+ "fullName": "🔄️Rotate 3D Camera On World",
"functionType": "Action",
"group": "3D Camera",
"name": "Rotate3DCameraOnWorld",
- "sentence": "Rotate 3D Camera On World (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
+ "sentence": "🔄️Rotate 3D Camera On World (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -3738,11 +4500,11 @@
},
{
"description": "Rotate the 3D Camera first in the world Y axis, then on the local X and Z axes.",
- "fullName": "Rotate 3D Camera Like Head",
+ "fullName": "🔄️Rotate 3D Camera Like Head",
"functionType": "Action",
"group": "3D Camera",
"name": "Rotate3DCameraLikeHead",
- "sentence": "Rotate 3D Camera Like Head (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
+ "sentence": "🔄️Rotate 3D Camera Like Head (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -3813,11 +4575,11 @@
"objectGroups": []
},
{
- "fullName": "3D Camera Look At 3D Object",
+ "fullName": "👀3D Camera Look At 3D Object",
"functionType": "Action",
"group": "3D Camera",
"name": "CameraLookAt3DObject",
- "sentence": "3D Camera Look At 3D Object (Camera ID: _PARAM1_, Target ID: _PARAM2_)",
+ "sentence": "👀3D Camera Look At 3D Object (Camera ID: _PARAM1_, Target ID: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -3832,7 +4594,7 @@
"const Camera = gdjs.__WithThreeJS.get(\"GetCamera\")(Id);",
"const TargetId = eventsFunctionContext.getArgument(\"TargetId\");",
"//",
- "const Obj = Scene.getObjectByName(TargetId);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(TargetId);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + TargetId);",
" return;",
@@ -3864,92 +4626,13 @@
],
"objectGroups": []
},
- {
- "description": "Correct the 3D Camera Rotation within limits.\nRotation is corrected like head movement. Limiting multiple axes can break things.",
- "fullName": "Correct 3D Camera Rotation Within Limits (Deprecated)",
- "functionType": "Action",
- "group": "3D Camera",
- "name": "Correct3DCameraRotationWithinLimits",
- "private": true,
- "sentence": "⚠️ Correct 3D Camera Rotation Within Limits (ID: _PARAM1_, Axis: _PARAM2_, Limit: _PARAM3_ to _PARAM4_)",
- "events": [
- {
- "type": "BuiltinCommonInstructions::JsCode",
- "inlineCode": [
- "if (!gdjs.__WithThreeJS.has(\"Renderer\")) {",
- " console.warn(\"!\");",
- " return;",
- "}",
- "// const Camera = gdjs.__WithThreeJS.get(\"Camera\");",
- "const Id = eventsFunctionContext.getArgument(\"Id\");",
- "const Camera = gdjs.__WithThreeJS.get(\"GetCamera\")(Id);",
- "const Rad3 = gdjs.__WithThreeJS.get(\"GetSingleRadian3\")(Camera);",
- "const Axis = eventsFunctionContext.getArgument(\"Axis\");",
- "const MinAngle = gdjs.toRad(eventsFunctionContext.getArgument(\"MinAngle\"));",
- "const MaxAngle = gdjs.toRad(eventsFunctionContext.getArgument(\"MaxAngle\"));",
- "//",
- "if (Axis == \"X\") {",
- " if (Rad3.x < MinAngle) {",
- " Camera.rotateX(MinAngle - Rad3.x);",
- " }",
- " if (Rad3.x > MaxAngle) {",
- " Camera.rotateX(MaxAngle - Rad3.x);",
- " }",
- "} else if (Axis == \"Y\") {",
- " if (Rad3.y < MinAngle) {",
- " Camera.rotateOnWorldAxis(new THREE.Vector3(0, 1, 0), MinAngle - Rad3.y);",
- " }",
- " if (Rad3.y > MaxAngle) {",
- " Camera.rotateOnWorldAxis(new THREE.Vector3(0, 1, 0), MaxAngle - Rad3.y);",
- " }",
- "} else {",
- " if (Rad3.z < MinAngle) {",
- " Camera.rotateZ(MinAngle - Rad3.z);",
- " }",
- " if (Rad3.z > MaxAngle) {",
- " Camera.rotateZ(MaxAngle - Rad3.z);",
- " }",
- "}",
- "",
- ""
- ],
- "parameterObjects": "",
- "useStrict": true,
- "eventsSheetExpanded": true
- }
- ],
- "parameters": [
- {
- "description": "3D Camera ID (1 to 4)",
- "name": "Id",
- "type": "expression"
- },
- {
- "description": "Axis",
- "name": "Axis",
- "supplementaryInformation": "[\"X\",\"Y\",\"Z\"]",
- "type": "stringWithSelector"
- },
- {
- "description": "Min Angle (-180 to 180)",
- "name": "MinAngle",
- "type": "expression"
- },
- {
- "description": "Max Angle (-180 to 180)",
- "name": "MaxAngle",
- "type": "expression"
- }
- ],
- "objectGroups": []
- },
{
"description": "Change the Field Of View of the 3D Camera.",
- "fullName": "Change 3D Camera FOV",
+ "fullName": "🎥Change 3D Camera FOV",
"functionType": "Action",
"group": "3D Camera",
"name": "Change3DCameraFOV",
- "sentence": "Change 3D Camera FOV (ID: _PARAM1_, _PARAM2_, Fov: _PARAM3_)",
+ "sentence": "🎥Change 3D Camera FOV (ID: _PARAM1_, _PARAM2_, Fov: _PARAM3_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -4002,11 +4685,11 @@
},
{
"description": "Change the near property of the 3D Camera.\nThe 3D Camera will not render 3D Objects closer than this distance.",
- "fullName": "Change 3D Camera Near",
+ "fullName": "🎥Change 3D Camera Near",
"functionType": "Action",
"group": "3D Camera",
"name": "Change3DCameraNear",
- "sentence": "Change 3D Camera Near (ID: _PARAM1_, _PARAM2_, Near: _PARAM3_)",
+ "sentence": "🎥Change 3D Camera Near (ID: _PARAM1_, _PARAM2_, Near: _PARAM3_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -4059,11 +4742,11 @@
},
{
"description": "Change the far property of 3D Camera.\nThe 3D Camera will not render 3D Objects farther than this distance.",
- "fullName": "Change 3D Camera Far",
+ "fullName": "🎥Change 3D Camera Far",
"functionType": "Action",
"group": "3D Camera",
"name": "Change3DCameraFar",
- "sentence": "Change 3D Camera Far (ID: _PARAM1_, _PARAM2_, Far: _PARAM3_)",
+ "sentence": "🎥Change 3D Camera Far (ID: _PARAM1_, _PARAM2_, Far: _PARAM3_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -4115,11 +4798,11 @@
"objectGroups": []
},
{
- "fullName": "Change 3D Camera Zoom",
+ "fullName": "🎥Change 3D Camera Zoom",
"functionType": "Action",
"group": "3D Camera",
"name": "Change3DCameraZoom",
- "sentence": "Change 3D Camera Zoom (ID: _PARAM1_, _PARAM2_, Zoom: _PARAM3_)",
+ "sentence": "🎥Change 3D Camera Zoom (ID: _PARAM1_, _PARAM2_, Zoom: _PARAM3_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -4172,11 +4855,11 @@
},
{
"description": "Note that rendering time increases by the number of enabled 3D Cameras.",
- "fullName": "Setup Multiple 3D Cameras",
+ "fullName": "🎥Setup Multiple 3D Cameras",
"functionType": "Action",
"group": "3D Camera",
"name": "SetupMultiple3DCameras",
- "sentence": "Setup Multiple 3D Cameras (Camera2: _PARAM5_, Camera3: _PARAM10_, Camera4: _PARAM15_)",
+ "sentence": "🎥Setup Multiple 3D Cameras (Camera2: _PARAM5_, Camera3: _PARAM10_, Camera4: _PARAM15_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -4340,11 +5023,11 @@
"objectGroups": []
},
{
- "fullName": "Linearly interpolate 3D Camera",
+ "fullName": "🔜Linearly interpolate 3D Camera",
"functionType": "Action",
"group": "3D Camera",
"name": "LerpCamera",
- "sentence": "Linearly Interpolate 3D Camera (Camera ID: _PARAM1_, Target ID: _PARAM2_, Position: _PARAM3_, Rotation: _PARAM4_)",
+ "sentence": "🔜Linearly Interpolate 3D Camera (Camera ID: _PARAM1_, Target ID: _PARAM2_, Position: _PARAM3_, Rotation: _PARAM4_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -4360,7 +5043,7 @@
"const FactorP = eventsFunctionContext.getArgument(\"FactorP\");",
"const FactorR = eventsFunctionContext.getArgument(\"FactorR\");",
"//",
- "const Obj = Scene.getObjectByName(TargetId);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(TargetId);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + TargetId);",
" return;",
@@ -4515,10 +5198,11 @@
},
{
"description": "3D Camera Angle for GDevelop.\nReturns the angle of an individual axis.\nNote that combining the resulting XYZ values may not reproduce the original rotation.",
- "fullName": "3D Camera Angle (Experimental)",
+ "fullName": "3D Camera Angle (Deprecated)",
"functionType": "Expression",
"group": "3D Camera",
"name": "CameraAngle",
+ "private": true,
"sentence": "",
"events": [
{
@@ -4642,7 +5326,7 @@
"const Camera = gdjs.__WithThreeJS.get(\"GetCamera\")(CameraId);",
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -4852,7 +5536,7 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const Axis = eventsFunctionContext.getArgument(\"Axis\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -5000,11 +5684,11 @@
},
{
"description": "Move a 3D Object.\n'=' is relative to the parent axis.\n\"+\" and \"-\" are relative to the local axis.",
- "fullName": "Move 3D Object",
+ "fullName": "↔️Move 3D Object",
"functionType": "Action",
"group": "3D Object",
"name": "Move3DObject",
- "sentence": "Move 3D Object (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
+ "sentence": "↔️Move 3D Object (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -5020,7 +5704,7 @@
"const Y = eventsFunctionContext.getArgument(\"Y\");",
"const Z = eventsFunctionContext.getArgument(\"Z\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -5078,11 +5762,11 @@
},
{
"description": "Move a 3D Object on the world axis.\n\"=\", \"+\" and \"-\" are relative to the world axis.",
- "fullName": "Move 3D Object On World",
+ "fullName": "↔️Move 3D Object On World",
"functionType": "Action",
"group": "3D Object",
"name": "Move3DObjectOnWorld",
- "sentence": "Move 3D Object On World (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
+ "sentence": "↔️Move 3D Object On World (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -5098,7 +5782,7 @@
"const Y = eventsFunctionContext.getArgument(\"Y\");",
"const Z = eventsFunctionContext.getArgument(\"Z\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -5157,11 +5841,11 @@
},
{
"description": "Rotate the 3D Object in the order X, Y, Z.",
- "fullName": "Rotate 3D Object",
+ "fullName": "🔄️Rotate 3D Object",
"functionType": "Action",
"group": "3D Object",
"name": "Rotate3DObject",
- "sentence": "Rotate 3D Object (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
+ "sentence": "🔄️Rotate 3D Object (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -5177,7 +5861,7 @@
"const AngleY = eventsFunctionContext.getArgument(\"AngleY\");",
"const AngleZ = eventsFunctionContext.getArgument(\"AngleZ\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -5235,11 +5919,11 @@
},
{
"description": "Rotate the 3D Object first in the world Y axis, then on the local X and Z axes.",
- "fullName": "Rotate 3D Object Like Head",
+ "fullName": "🔄️Rotate 3D Object Like Head",
"functionType": "Action",
"group": "3D Object",
"name": "Rotate3DObjectLikeHead",
- "sentence": "Rotate 3D Object Like Head (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
+ "sentence": "🔄️Rotate 3D Object Like Head (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -5255,7 +5939,7 @@
"const AngleY = eventsFunctionContext.getArgument(\"AngleY\");",
"const AngleZ = eventsFunctionContext.getArgument(\"AngleZ\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -5319,11 +6003,11 @@
},
{
"description": "Rotate the 3D Object in the order X, Y, Z on the world axis.",
- "fullName": "Rotate 3D Object On World",
+ "fullName": "🔄️Rotate 3D Object On World",
"functionType": "Action",
"group": "3D Object",
"name": "Rotate3DObjectOnWorld",
- "sentence": "Rotate 3D Object On World (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
+ "sentence": "🔄️Rotate 3D Object On World (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -5339,7 +6023,7 @@
"const AngleY = eventsFunctionContext.getArgument(\"AngleY\");",
"const AngleZ = eventsFunctionContext.getArgument(\"AngleZ\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -5402,11 +6086,11 @@
"objectGroups": []
},
{
- "fullName": "Look At 3D Object",
+ "fullName": "👀Look At 3D Object",
"functionType": "Action",
"group": "3D Object",
"name": "LookAt3DObject",
- "sentence": "Look At 3D Object (ID: _PARAM1_, Target ID: _PARAM2_)",
+ "sentence": "👀Look At 3D Object (ID: _PARAM1_, Target ID: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -5419,8 +6103,8 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const TargetId = eventsFunctionContext.getArgument(\"TargetId\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
- "let TargetObj = Scene.getObjectByName(TargetId);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
+ "const TargetObj = gdjs.__WithThreeJS.get(\"SearchObject\")(TargetId);",
"if (!Obj || !TargetObj) {",
" console.warn(\"3D Object not found: \" + Id + \" or \" + TargetId);",
" return;",
@@ -5454,11 +6138,11 @@
"objectGroups": []
},
{
- "fullName": "Look At 3D Camera",
+ "fullName": "👀Look At 3D Camera",
"functionType": "Action",
"group": "3D Object",
"name": "LookAt3DCamera",
- "sentence": "Look At 3D Camera (Object ID: _PARAM1_, Camera ID: _PARAM2_)",
+ "sentence": "👀Look At 3D Camera (Object ID: _PARAM1_, Camera ID: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -5473,7 +6157,7 @@
"const CameraId = eventsFunctionContext.getArgument(\"CameraId\");",
"const Camera = gdjs.__WithThreeJS.get(\"GetCamera\")(CameraId);",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -5486,105 +6170,18 @@
"parameterObjects": "",
"useStrict": true,
"eventsSheetExpanded": true
- }
- ],
- "parameters": [
- {
- "description": "3D Object ID",
- "name": "Id",
- "supplementaryInformation": "scene3D Object ID",
- "type": "identifier"
- },
- {
- "description": "3D Camera ID (1 to 4)",
- "name": "CameraId",
- "type": "expression"
- }
- ],
- "objectGroups": []
- },
- {
- "description": "Correct the 3D Object Rotation within limits.\nUsing this action on a 3D Object rotated on multiple axes may not work correctly.",
- "fullName": "Correct 3D Object Rotation Within Limits (Deprecated)",
- "functionType": "Action",
- "group": "3D Object",
- "name": "Correct3DObjectRotationWithinLimits",
- "private": true,
- "sentence": "⚠️ Correct 3D Object Rotation Within Limits (ID: _PARAM1_, Axis: _PARAM2_, Limit: _PARAM3_ to _PARAM4_)",
- "events": [
- {
- "type": "BuiltinCommonInstructions::JsCode",
- "inlineCode": [
- "if (!gdjs.__WithThreeJS.has(\"Renderer\")) {",
- " console.warn(\"!\");",
- " return;",
- "}",
- "const Scene = gdjs.__WithThreeJS.get(\"Scene\");",
- "const Id = eventsFunctionContext.getArgument(\"Id\");",
- "const Axis = eventsFunctionContext.getArgument(\"Axis\");",
- "const MinAngle = gdjs.toRad(eventsFunctionContext.getArgument(\"MinAngle\"));",
- "const MaxAngle = gdjs.toRad(eventsFunctionContext.getArgument(\"MaxAngle\"));",
- "//",
- "const Obj = Scene.getObjectByName(Id);",
- "if (!Obj) {",
- " console.warn(\"3D Object not found: \" + Id);",
- " return;",
- "}",
- "//",
- "const RX = Obj.rotation.x;",
- "const RY = Obj.rotation.y;",
- "const RZ = Obj.rotation.z;",
- "if (Axis == \"X\") {",
- " if (RX < MinAngle) {",
- " Obj.rotateX(MinAngle - RX);",
- " }",
- " if (RX > MaxAngle) {",
- " Obj.rotateX(MaxAngle - RX);",
- " }",
- "} else if (Axis == \"Y\") {",
- " if (RY < MinAngle) {",
- " Obj.rotateY(MinAngle - RY);",
- " }",
- " if (RY > MaxAngle) {",
- " Obj.rotateY(MaxAngle - RY);",
- " }",
- "} else {",
- " if (RZ < MinAngle) {",
- " Obj.rotateZ(MinAngle - RZ);",
- " }",
- " if (RZ > MaxAngle) {",
- " Obj.rotateZ(MaxAngle - RZ);",
- " }",
- "}",
- "",
- ""
- ],
- "parameterObjects": "",
- "useStrict": true,
- "eventsSheetExpanded": true
- }
- ],
- "parameters": [
- {
- "description": "3D Object ID",
- "name": "Id",
- "supplementaryInformation": "scene3D Object ID",
- "type": "identifier"
- },
- {
- "description": "Axis",
- "name": "Axis",
- "supplementaryInformation": "[\"X\",\"Y\",\"Z\"]",
- "type": "stringWithSelector"
- },
+ }
+ ],
+ "parameters": [
{
- "description": "Min Angle (-180 to 180)",
- "name": "MinAngle",
- "type": "expression"
+ "description": "3D Object ID",
+ "name": "Id",
+ "supplementaryInformation": "scene3D Object ID",
+ "type": "identifier"
},
{
- "description": "Max Angle (-180 to 180)",
- "name": "MaxAngle",
+ "description": "3D Camera ID (1 to 4)",
+ "name": "CameraId",
"type": "expression"
}
],
@@ -5592,11 +6189,11 @@
},
{
"description": "Remove a 3D Object from the 3D Scene.\nThis action cannot remove 3D Objects created by 3D Projection Behaviors.\nThis action does not clear the loaded 3D Texture data and the loaded 3D Model data.\nThey will continue to be accessible by ID.",
- "fullName": "Remove 3D Object",
+ "fullName": "🗑️Remove 3D Object",
"functionType": "Action",
"group": "3D Object",
"name": "Remove3DObject",
- "sentence": "Remove 3D Object (ID: _PARAM1_)",
+ "sentence": "🗑️Remove 3D Object (ID: _PARAM1_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -5608,7 +6205,7 @@
"const Scene = gdjs.__WithThreeJS.get(\"Scene\");",
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -5619,7 +6216,26 @@
"}",
"//",
"// Obj.clear();",
- "gdjs.__WithThreeJS.get(\"AllMaterialDispose\")(Obj);",
+ "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);",
"Obj.removeFromParent();",
"",
""
@@ -5641,11 +6257,11 @@
},
{
"description": "Change the 3D Texture of a 3D Object.",
- "fullName": "Change 3D Texture",
+ "fullName": "🧱Change 3D Texture",
"functionType": "Action",
"group": "3D Object",
"name": "Change3DTexture",
- "sentence": "Change 3D Texture (ID: _PARAM1_, Texture: _PARAM2_)",
+ "sentence": "🧱Change 3D Texture (ID: _PARAM1_, Texture: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -5664,7 +6280,7 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const TextureIdList = eventsFunctionContext.getArgument(\"TextureIdList\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -5680,7 +6296,7 @@
" }",
"}",
"//",
- "gdjs.__WithThreeJS.get(\"SettingRecursiveTextures\")(Obj, TextureList);",
+ "gdjs.__WithThreeJS.get(\"SetAllTextures\")(Obj, TextureList);",
"",
""
],
@@ -5708,11 +6324,11 @@
},
{
"description": "Change the visibility of a 3D Object.",
- "fullName": "Change 3D Object Visibility",
+ "fullName": "🌗Change 3D Object Visibility",
"functionType": "Action",
"group": "3D Object",
"name": "ChangeVisibility",
- "sentence": "Change 3D Object Visibility (ID: _PARAM1_, Visible: _PARAM2_, Inherit: _PARAM3_)",
+ "sentence": "🌗Change 3D Object Visibility (ID: _PARAM1_, Visible: _PARAM2_, Inherit: _PARAM3_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -5727,7 +6343,7 @@
"const Visible = eventsFunctionContext.getArgument(\"Visible\");",
"const Inherit = eventsFunctionContext.getArgument(\"Inherit\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -5783,11 +6399,11 @@
},
{
"description": "Change the Opacity of a 3D Object.\nThe same value is set for multiple textures.",
- "fullName": "Change 3D Object Opacity",
+ "fullName": "🥛Change 3D Object Opacity",
"functionType": "Action",
"group": "3D Object",
"name": "ChangeOpacity",
- "sentence": "Change 3D Object Opacity (ID: _PARAM1_, _PARAM2_, Opacity: _PARAM3_)",
+ "sentence": "🥛Change 3D Object Opacity (ID: _PARAM1_, _PARAM2_, Opacity: _PARAM3_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -5802,13 +6418,47 @@
"const Operator = eventsFunctionContext.getArgument(\"Operator\");",
"const Opacity = eventsFunctionContext.getArgument(\"Opacity\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
"}",
"//",
- "gdjs.__WithThreeJS.get(\"SetAllOpacity\")(Obj, Operator, Opacity);",
+ "Obj.traverse((Child) => {",
+ " if (Child.material) {",
+ " if (Array.isArray(Child.material)) {",
+ " for (let i = 0; i < Child.material.length; i++) {",
+ " if (!Child.material[i].transparent) {",
+ " Child.material[i].transparent = true;",
+ " Child.material[i].needsUpdate = true;",
+ " }",
+ " if (Operator == \"=\") {",
+ " Child.material[i].opacity = Opacity;",
+ " } else if (Operator == \"+\") {",
+ " Child.material[i].opacity += Opacity;",
+ " } else {",
+ " Child.material[i].opacity -= Opacity;",
+ " }",
+ " if (Child.material[i].opacity < 0) Child.material[i].opacity = 0;",
+ " if (Child.material[i].opacity > 1) Child.material[i].opacity = 1;",
+ " }",
+ " } else {",
+ " if (!Child.material.transparent) {",
+ " Child.material.transparent = true;",
+ " Child.material.needsUpdate = true;",
+ " }",
+ " if (Operator == \"=\") {",
+ " Child.material.opacity = Opacity;",
+ " } else if (Operator == \"+\") {",
+ " Child.material.opacity += Opacity;",
+ " } else {",
+ " Child.material.opacity -= Opacity;",
+ " }",
+ " if (Child.material.opacity < 0) Child.material.opacity = 0;",
+ " if (Child.material.opacity > 1) Child.material.opacity = 1;",
+ " }",
+ " }",
+ "});",
"",
""
],
@@ -5841,11 +6491,11 @@
},
{
"description": "Change the Scale of a 3D Object.\nNote that 3D Sprite and 3D Model were scaled when created.",
- "fullName": "Change 3D Object Scale",
+ "fullName": "↕️Change 3D Object Scale",
"functionType": "Action",
"group": "3D Object",
"name": "ChangeScale",
- "sentence": "Change 3D Object Scale (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
+ "sentence": "↕️Change 3D Object Scale (ID: _PARAM1_, _PARAM2_, X: _PARAM3_, Y: _PARAM4_, Z: _PARAM5_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -5861,7 +6511,7 @@
"const Y = eventsFunctionContext.getArgument(\"Y\");",
"const Z = eventsFunctionContext.getArgument(\"Z\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -5941,11 +6591,11 @@
},
{
"description": "Change the DepthWrite of a 3D Object.\nWhether rendering this 3D Object has any effect on the depth buffer.\nIf transparent 3D Objects overlap and render incorrectly, you may be able to obtain ideal rendering results by setting the DepthWrite of that 3D Object to No.\nDefault is Yes.",
- "fullName": "Change 3D Object DepthWrite (Experimental)",
+ "fullName": "🧱Change 3D Object DepthWrite",
"functionType": "Action",
"group": "3D Object",
"name": "ChangeDepthWrite",
- "sentence": "Change 3D Object DepthWrite (ID: _PARAM1_, Write: _PARAM2_)",
+ "sentence": "🧱Change 3D Object DepthWrite (ID: _PARAM1_, Write: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -5959,13 +6609,23 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const Write = eventsFunctionContext.getArgument(\"Write\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
"}",
"//",
- "gdjs.__WithThreeJS.get(\"SetAllDepthWrite\")(Obj, Write);",
+ "Obj.traverse((Child) => {",
+ " if (Child.material) {",
+ " if (Array.isArray(Child.material)) {",
+ " for (let i = 0; i < Child.material.length; i++) {",
+ " Child.material[i].depthWrite = Write;",
+ " }",
+ " } else {",
+ " Child.material.depthWrite = Write;",
+ " }",
+ " }",
+ "});",
"",
""
],
@@ -5993,11 +6653,11 @@
},
{
"description": "Change all animations speed scale of a 3D Object.\n0 is pause.\nNegative values play backwards.",
- "fullName": "Change 3D Object All Animations Speed Scale",
+ "fullName": "🎞️Change 3D Object All Animations Speed Scale",
"functionType": "Action",
"group": "3D Object",
"name": "ChangeAllAnimationsSpeedScale",
- "sentence": "Change All Animations Speed Scale (ID: _PARAM1_, _PARAM2_, Speed: _PARAM3_)",
+ "sentence": "🎞️Change All Animations Speed Scale (ID: _PARAM1_, _PARAM2_, Speed: _PARAM3_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -6012,7 +6672,7 @@
"const Operator = eventsFunctionContext.getArgument(\"Operator\");",
"const Speed = eventsFunctionContext.getArgument(\"Speed\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -6061,11 +6721,11 @@
},
{
"description": "Change the Blend Mode of a 3D Object.",
- "fullName": "Change 3D Object Blend Mode",
+ "fullName": "🧱Change 3D Object Blend Mode",
"functionType": "Action",
"group": "3D Object",
"name": "ChangeBlendMode",
- "sentence": "Change 3D Object Blend Mode (ID: _PARAM1_, Blend Mode: _PARAM2_)",
+ "sentence": "🧱Change 3D Object Blend Mode (ID: _PARAM1_, Blend Mode: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -6085,13 +6745,23 @@
" Blend = THREE.MultiplyBlending;",
"}",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
"}",
"//",
- "gdjs.__WithThreeJS.get(\"SetAllBlendMode\")(Obj, Blend);",
+ "Obj.traverse((Child) => {",
+ " if (Child.material) {",
+ " if (Array.isArray(Child.material)) {",
+ " for (let i = 0; i < Child.material.length; i++) {",
+ " Child.material[i].blending = Blend;",
+ " }",
+ " } else {",
+ " Child.material.blending = Blend;",
+ " }",
+ " }",
+ "});",
"",
""
],
@@ -6117,70 +6787,13 @@
],
"objectGroups": []
},
- {
- "description": "Resolve collisions between Bounding Boxes.\nIt is not necessary to use the \"Check Bounding Box Collision\" condition beforehand. (It will do almost the same processing)\nNote that the 3D Objects are still in contact after resolution. (\"Check Bounding Box Collision\" condition will not be false.)\n3D Object thickness too thin for the amount of movement will not resolve correctly.\nThis action updates the \"Bounding Box Collision Result\".",
- "fullName": "Resolve Bounding Box Collision (Deprecated)",
- "functionType": "Action",
- "group": "3D Object",
- "name": "ResolveBoundingBoxCollision",
- "private": true,
- "sentence": "⚠️ Resolve Bounding Box Collision (ID: _PARAM1_, Unmoved: _PARAM2_)",
- "events": [
- {
- "type": "BuiltinCommonInstructions::JsCode",
- "inlineCode": [
- "if (!gdjs.__WithThreeJS.has(\"Renderer\")) {",
- " console.warn(\"!\");",
- " return;",
- "}",
- "const Scene = gdjs.__WithThreeJS.get(\"Scene\");",
- "const Id = eventsFunctionContext.getArgument(\"Id\");",
- "const UnmovedId = eventsFunctionContext.getArgument(\"UnmovedId\");",
- "//",
- "const Obj = Scene.getObjectByName(Id);",
- "const UnmovedObj = Scene.getObjectByName(UnmovedId);",
- "if (!Obj || !UnmovedObj) {",
- " console.warn(\"3D Object not found: \" + Id + \" or \" + UnmovedId);",
- " return;",
- "}",
- "//",
- "const BoundingBoxCollisionResult = gdjs.__WithThreeJS.get(\"SetBoundingBoxCollisionResult\")(Obj, UnmovedObj);",
- "const Move3 = new THREE.Vector3(BoundingBoxCollisionResult.MoveX, BoundingBoxCollisionResult.MoveY, BoundingBoxCollisionResult.MoveZ);",
- "const WorldPosition = new THREE.Vector3();",
- "Obj.getWorldPosition(WorldPosition);",
- "WorldPosition.add(Move3);",
- "Obj.position.copy(Obj.parent.worldToLocal(WorldPosition));",
- "",
- ""
- ],
- "parameterObjects": "",
- "useStrict": true,
- "eventsSheetExpanded": true
- }
- ],
- "parameters": [
- {
- "description": "3D Object ID",
- "name": "Id",
- "supplementaryInformation": "scene3D Object ID",
- "type": "identifier"
- },
- {
- "description": "Unmoved 3D Object ID",
- "name": "UnmovedId",
- "supplementaryInformation": "scene3D Object ID",
- "type": "identifier"
- }
- ],
- "objectGroups": []
- },
{
"description": "Resolve collisions between Bounding Boxes.\nIt is not necessary to use the \"Check Bounding Box Collision\" condition beforehand. (It will do almost the same processing)\nNote that the 3D Objects are still in contact after resolution. (\"Check Bounding Box Collision\" condition will not be false.)\n3D Object thickness too thin for the amount of movement will not resolve correctly.\nThis action updates the \"Bounding Box Collision Result\".\n\"Bounding Box Collision Result\" stores the value when the Target 3D Object is unmoved.",
- "fullName": "Resolve Bounding Box Collision",
+ "fullName": "💥Resolve Bounding Box Collision",
"functionType": "Action",
"group": "3D Object",
"name": "ResolveBoundingBoxCollisionV2",
- "sentence": "Resolve Bounding Box Collision (ID: _PARAM1_, Target: _PARAM2_, Unmoved: _PARAM3_)",
+ "sentence": "💥Resolve Bounding Box Collision (ID: _PARAM1_, Target: _PARAM2_, Unmoved: _PARAM3_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -6194,8 +6807,8 @@
"const TargetId = eventsFunctionContext.getArgument(\"TargetId\");",
"const Unmoved = eventsFunctionContext.getArgument(\"Unmoved\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
- "const TargetObj = Scene.getObjectByName(TargetId);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
+ "const TargetObj = gdjs.__WithThreeJS.get(\"SearchObject\")(TargetId);",
"if (!Obj || !TargetObj) {",
" console.warn(\"3D Object not found: \" + Id + \" or \" + TargetId);",
" return;",
@@ -6254,11 +6867,11 @@
},
{
"description": "Add 3D Object as child to 3D object.",
- "fullName": "Add Child",
+ "fullName": "👥Add Child",
"functionType": "Action",
"group": "3D Object",
"name": "AddChild",
- "sentence": "Add Child (ID: _PARAM1_, Child: _PARAM2_)",
+ "sentence": "👥Add Child (ID: _PARAM1_, Child: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -6271,8 +6884,8 @@
"const ParentId = eventsFunctionContext.getArgument(\"ParentId\");",
"const ChildId = eventsFunctionContext.getArgument(\"ChildId\");",
"//",
- "const Parent = Scene.getObjectByName(ParentId);",
- "const Child = Scene.getObjectByName(ChildId);",
+ "const Parent = gdjs.__WithThreeJS.get(\"SearchObject\")(ParentId);",
+ "const Child = gdjs.__WithThreeJS.get(\"SearchObject\")(ChildId);",
"if (!Parent || !Child) {",
" console.warn(\"3D Object not found: \" + ParentId + \" or \" + ChildId);",
" return;",
@@ -6304,11 +6917,11 @@
},
{
"description": "Detach a 3D Object from its parent.\n(Set Parent to Scene)",
- "fullName": "Detach From Parent",
+ "fullName": "👥Detach From Parent",
"functionType": "Action",
"group": "3D Object",
"name": "DetachFromParent",
- "sentence": "Detach From Parent (ID: _PARAM1_)",
+ "sentence": "👥Detach From Parent (ID: _PARAM1_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -6320,7 +6933,7 @@
"const Scene = gdjs.__WithThreeJS.get(\"Scene\");",
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -6346,11 +6959,11 @@
},
{
"description": "Set 3D Object ID of all children to scene variable as array.",
- "fullName": "Set 3D Object ID Of Children To Scene Variable",
+ "fullName": "👥Set 3D Object ID Of Children To Scene Variable",
"functionType": "Action",
"group": "3D Object",
"name": "SetChildrenIdToSceneVariable",
- "sentence": "Set 3D Object ID Of Children To Scene Variable (ID: _PARAM1_, Variable: _PARAM2_)",
+ "sentence": "👥Set 3D Object ID Of Children To Scene Variable (ID: _PARAM1_, Variable: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -6363,7 +6976,7 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const SceneVariable = eventsFunctionContext.getArgument(\"Variable\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -6399,11 +7012,11 @@
},
{
"description": "Play 3D animation.\nIf already playing, only the \"Animation Speed Scale\" and \"Loop\" properties are updated.",
- "fullName": "Play 3D Animation",
+ "fullName": "🎞️Play 3D Animation",
"functionType": "Action",
"group": "3D Object",
"name": "Play3DAnimation",
- "sentence": "Play 3D Animation (ID: _PARAM1_, Animation: _PARAM2_, Speed: _PARAM3_, Loop: _PARAM4_, Fade: _PARAM5_)",
+ "sentence": "🎞️Play 3D Animation (ID: _PARAM1_, Animation: _PARAM2_, Speed: _PARAM3_, Loop: _PARAM4_, Fade: _PARAM5_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -6428,7 +7041,7 @@
" Loop = THREE.LoopRepeat;",
"}",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -6521,11 +7134,11 @@
"objectGroups": []
},
{
- "fullName": "Stop 3D Animation",
+ "fullName": "🎞️Stop 3D Animation",
"functionType": "Action",
"group": "3D Object",
"name": "Stop3DAnimation",
- "sentence": "Stop 3D Animation (ID: _PARAM1_, Animation: _PARAM2_, Fade: _PARAM3_)",
+ "sentence": "🎞️Stop 3D Animation (ID: _PARAM1_, Animation: _PARAM2_, Fade: _PARAM3_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -6540,7 +7153,7 @@
"const ANumber = eventsFunctionContext.getArgument(\"ANumber\");",
"const Duration = eventsFunctionContext.getArgument(\"Duration\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -6593,60 +7206,11 @@
"objectGroups": []
},
{
- "fullName": "Stop All 3D Animation (Deprecated)",
- "functionType": "Action",
- "group": "3D Object",
- "name": "StopAll3DAnimation",
- "private": true,
- "sentence": "⚠️ Stop All 3D Animation (ID: _PARAM1_)",
- "events": [
- {
- "type": "BuiltinCommonInstructions::JsCode",
- "inlineCode": [
- "if (!gdjs.__WithThreeJS.has(\"Renderer\")) {",
- " console.warn(\"!\");",
- " return;",
- "}",
- "const Scene = gdjs.__WithThreeJS.get(\"Scene\");",
- "const AnimationActions = gdjs.__WithThreeJS.get(\"AnimationActions\");",
- "const Id = eventsFunctionContext.getArgument(\"Id\");",
- "//",
- "const Obj = Scene.getObjectByName(Id);",
- "if (!Obj) {",
- " console.warn(\"3D Object not found: \" + Id);",
- " return;",
- "}",
- "//",
- "const OBJ_UUID = Obj.uuid;",
- "if (AnimationActions.has(OBJ_UUID)) {",
- " for (const [K, V] of AnimationActions.get(OBJ_UUID)) {",
- " V.stop();",
- " }",
- "}",
- "",
- ""
- ],
- "parameterObjects": "",
- "useStrict": true,
- "eventsSheetExpanded": true
- }
- ],
- "parameters": [
- {
- "description": "3D Object ID",
- "name": "Id",
- "supplementaryInformation": "scene3D Object ID",
- "type": "identifier"
- }
- ],
- "objectGroups": []
- },
- {
- "fullName": "Set number to 3D Object Variable",
+ "fullName": "📝Set number to 3D Object Variable",
"functionType": "Action",
"group": "3D Object",
"name": "SetNumberVariable",
- "sentence": "Set number to 3D Object Variable (ID: _PARAM1_, Variable: _PARAM2_, _PARAM3_, _PARAM4_)",
+ "sentence": "📝Set number to 3D Object Variable (ID: _PARAM1_, Variable: _PARAM2_, _PARAM3_, _PARAM4_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -6661,7 +7225,7 @@
"const Operator = eventsFunctionContext.getArgument(\"Operator\");",
"const Value = eventsFunctionContext.getArgument(\"Value\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -6719,11 +7283,11 @@
"objectGroups": []
},
{
- "fullName": "Set string to 3D Object Variable",
+ "fullName": "📝Set string to 3D Object Variable",
"functionType": "Action",
"group": "3D Object",
"name": "SetStringVariable",
- "sentence": "Set string to 3D Object Variable (ID: _PARAM1_, Variable: _PARAM2_, _PARAM3_, _PARAM4_)",
+ "sentence": "📝Set string to 3D Object Variable (ID: _PARAM1_, Variable: _PARAM2_, _PARAM3_, _PARAM4_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -6738,7 +7302,7 @@
"const Operator = eventsFunctionContext.getArgument(\"Operator\");",
"const Value = eventsFunctionContext.getArgument(\"Value\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -6792,11 +7356,11 @@
"objectGroups": []
},
{
- "fullName": "Linearly interpolate 3D Object",
+ "fullName": "🔜Linearly interpolate 3D Object",
"functionType": "Action",
"group": "3D Object",
"name": "Lerp3DObject",
- "sentence": "Linearly Interpolate 3D Object (ID: _PARAM1_, Target ID: _PARAM2_, Position: _PARAM3_, Rotation: _PARAM4_)",
+ "sentence": "🔜Linearly Interpolate 3D Object (ID: _PARAM1_, Target ID: _PARAM2_, Position: _PARAM3_, Rotation: _PARAM4_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -6811,8 +7375,8 @@
"const FactorP = eventsFunctionContext.getArgument(\"FactorP\");",
"const FactorR = eventsFunctionContext.getArgument(\"FactorR\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
- "const TargetObj = Scene.getObjectByName(TargetId);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
+ "const TargetObj = gdjs.__WithThreeJS.get(\"SearchObject\")(TargetId);",
"if (!Obj || !TargetObj) {",
" console.warn(\"3D Object not found: \" + Id + \" or \" + TargetId);",
" return;",
@@ -6869,11 +7433,11 @@
},
{
"description": "Adds a suffix to the IDs of the specified 3D object and its children.\nNote that if lights or sounds are included as children, their IDs will also change.",
- "fullName": "Add Suffix To 3D Object ID",
+ "fullName": "🆔Add Suffix To 3D Object ID",
"functionType": "Action",
"group": "3D Object",
"name": "AddSuffixToId",
- "sentence": "Add Suffix To 3D Object ID (ID: _PARAM1_, Suffix: _PARAM2_)",
+ "sentence": "🆔Add Suffix To 3D Object ID (ID: _PARAM1_, Suffix: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -6887,15 +7451,22 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const Suffix = eventsFunctionContext.getArgument(\"Suffix\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
"}",
"//",
- "gdjs.__WithThreeJS.get(\"AddSuffixToAllIds\")(Obj, Suffix);",
- "",
- ""
+ "Obj.traverse((Child) => {",
+ " // !Obj.isLight && !Obj.isLine && !Obj.isSkinnedMesh && !Obj.isBone",
+ " // Obj.type != \"Audio\"",
+ " if (!Child.isCamera && !Child.isScene && !Child.isBone) {",
+ " if (gdjs.__WithThreeJS.get(\"ObjectList\").has(Child.name)) {",
+ " gdjs.__WithThreeJS.get(\"ObjectList\").delete(Child.name);",
+ " }",
+ " Child.name += Suffix;",
+ " }",
+ "});"
],
"parameterObjects": "",
"useStrict": true,
@@ -6918,6 +7489,68 @@
],
"objectGroups": []
},
+ {
+ "description": "If both \"Cast Shadow\" and \"Receive Shadow\" are enabled, striped patterns are likely to occur in the shadow.",
+ "fullName": "👤Set 3D Object Shadow",
+ "functionType": "Action",
+ "group": "3D Object",
+ "name": "Set3DShadow",
+ "sentence": "👤Set 3D Object Shadow (ID: _PARAM1_, Cast: _PARAM2_, Receive: _PARAM3_)",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::JsCode",
+ "inlineCode": [
+ "if (!gdjs.__WithThreeJS.has(\"Renderer\")) {",
+ " console.warn(\"!\");",
+ " return;",
+ "}",
+ "const Scene = gdjs.__WithThreeJS.get(\"Scene\");",
+ "//",
+ "const Id = eventsFunctionContext.getArgument(\"Id\");",
+ "const CastShadow = eventsFunctionContext.getArgument(\"CastShadow\");",
+ "const ReceiveShadow = eventsFunctionContext.getArgument(\"ReceiveShadow\");",
+ "//",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
+ "if (!Obj) {",
+ " console.warn(\"3D Object not found: \" + Id);",
+ " return;",
+ "}",
+ "//",
+ "Obj.traverse((Child) => {",
+ " if (Child.isMesh) {",
+ " Child.castShadow = CastShadow;",
+ " Child.receiveShadow = ReceiveShadow;",
+ " }",
+ "});",
+ "",
+ ""
+ ],
+ "parameterObjects": "",
+ "useStrict": true,
+ "eventsSheetExpanded": true
+ }
+ ],
+ "parameters": [
+ {
+ "description": "3D Object ID",
+ "name": "Id",
+ "supplementaryInformation": "scene3D Object ID",
+ "type": "identifier"
+ },
+ {
+ "description": "Cast Shadow",
+ "name": "CastShadow",
+ "supplementaryInformation": "scene3D Object ID",
+ "type": "yesorno"
+ },
+ {
+ "description": "Receive Shadow",
+ "name": "ReceiveShadow",
+ "type": "yesorno"
+ }
+ ],
+ "objectGroups": []
+ },
{
"fullName": "3D Object Position",
"functionType": "Expression",
@@ -6936,7 +7569,7 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const Axis = eventsFunctionContext.getArgument(\"Axis\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -6994,7 +7627,7 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const Axis = eventsFunctionContext.getArgument(\"Axis\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -7054,7 +7687,7 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const Axis = eventsFunctionContext.getArgument(\"Axis\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -7112,7 +7745,7 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const Axis = eventsFunctionContext.getArgument(\"Axis\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -7175,7 +7808,7 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const Axis = eventsFunctionContext.getArgument(\"Axis\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -7235,7 +7868,7 @@
"const Scene = gdjs.__WithThreeJS.get(\"Scene\");",
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -7285,7 +7918,7 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const Axis = eventsFunctionContext.getArgument(\"Axis\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -7355,7 +7988,7 @@
"const Scene = gdjs.__WithThreeJS.get(\"Scene\");",
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -7402,7 +8035,7 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const ANumber = eventsFunctionContext.getArgument(\"ANumber\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -7466,7 +8099,7 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const ANumber = eventsFunctionContext.getArgument(\"ANumber\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -7530,7 +8163,7 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const ANumber = eventsFunctionContext.getArgument(\"ANumber\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -7585,7 +8218,7 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const VariableName = eventsFunctionContext.getArgument(\"VariableName\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -7645,7 +8278,7 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const VariableName = eventsFunctionContext.getArgument(\"VariableName\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -7705,8 +8338,8 @@
"const Id1 = eventsFunctionContext.getArgument(\"Id1\");",
"const Id2 = eventsFunctionContext.getArgument(\"Id2\");",
"//",
- "const Obj1 = Scene.getObjectByName(Id1);",
- "const Obj2 = Scene.getObjectByName(Id2);",
+ "const Obj1 = gdjs.__WithThreeJS.get(\"SearchObject\")(Id1);",
+ "const Obj2 = gdjs.__WithThreeJS.get(\"SearchObject\")(Id2);",
"if (!Obj1 || !Obj2) {",
" console.warn(\"3D Object not found: \" + Id1 + \" or \" + Id2);",
" return;",
@@ -7805,11 +8438,11 @@
"objectGroups": []
},
{
- "fullName": "Check Existence Of 3D Object",
+ "fullName": "💎Check Existence Of 3D Object",
"functionType": "Condition",
"group": "3D Object",
"name": "CheckExistenceOf3DObject",
- "sentence": "Check Existence Of 3D Object (ID: _PARAM1_)",
+ "sentence": "💎Check Existence Of 3D Object (ID: _PARAM1_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -7821,7 +8454,7 @@
"const Scene = gdjs.__WithThreeJS.get(\"Scene\");",
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (Obj && Id !== \"\") {",
" eventsFunctionContext.returnValue = true;",
"} else {",
@@ -7847,11 +8480,11 @@
},
{
"description": "Check the visibility of a 3D Object.\nThis condition cannot be tested correctly if the visibility of the 3D object is changed by inheritance.",
- "fullName": "Check Visibility Of 3D Object",
+ "fullName": "🌗Check Visibility Of 3D Object",
"functionType": "Condition",
"group": "3D Object",
"name": "CheckVisibilityOf3DObject",
- "sentence": "Check Visibility Of 3D Object (ID: _PARAM1_, Visible: _PARAM2_)",
+ "sentence": "🌗Check Visibility Of 3D Object (ID: _PARAM1_, Visible: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -7864,7 +8497,7 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const Visible = eventsFunctionContext.getArgument(\"Visible\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -7908,11 +8541,11 @@
},
{
"description": "Checks for collisions between the Bounding Boxes of two 3D Objects.\nThis condition updates the \"Bounding Box Collision Result\" when it returns True.",
- "fullName": "Check Bounding Box Collision",
+ "fullName": "💥Check Bounding Box Collision",
"functionType": "Condition",
"group": "3D Object",
"name": "CheckBoundingBoxCollision",
- "sentence": "Check Bounding Box Collision (ID: _PARAM1_, Unmoved: _PARAM2_)",
+ "sentence": "💥Check Bounding Box Collision (ID: _PARAM1_, Unmoved: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -7925,8 +8558,8 @@
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"const UnmovedId = eventsFunctionContext.getArgument(\"UnmovedId\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
- "const UnmovedObj = Scene.getObjectByName(UnmovedId);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
+ "const UnmovedObj = gdjs.__WithThreeJS.get(\"SearchObject\")(UnmovedId);",
"if (!Obj || !UnmovedObj) {",
" console.warn(\"3D Object not found: \" + Id + \" or \" + UnmovedId);",
" return;",
@@ -7958,13 +8591,77 @@
],
"objectGroups": []
},
+ {
+ "description": "Checks for collisions between the Oriented Bounding Boxes of two 3D Objects.\nOBB cannot resolve collisions between OBBs or get collision results.",
+ "fullName": "💥Check Oriented Bounding Box Collision",
+ "functionType": "Condition",
+ "group": "3D Object",
+ "name": "CheckOrientedBoxCollision",
+ "sentence": "💥Check Oriented Bounding Box Collision (ID: _PARAM1_, _PARAM2_)",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::JsCode",
+ "inlineCode": [
+ "if (!gdjs.__WithThreeJS.has(\"Renderer\")) {",
+ " console.warn(\"!\");",
+ " return;",
+ "}",
+ "const Scene = gdjs.__WithThreeJS.get(\"Scene\");",
+ "const Id = eventsFunctionContext.getArgument(\"Id\");",
+ "const OtherId = eventsFunctionContext.getArgument(\"OtherId\");",
+ "//",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
+ "const OtherObj = gdjs.__WithThreeJS.get(\"SearchObject\")(OtherId);",
+ "if (!Obj || !OtherObj) {",
+ " console.warn(\"3D Object not found: \" + Id + \" or \" + OtherId);",
+ " return;",
+ "}",
+ "// geometryを持たない場合を回避。なぜかSpriteにはgeometryがある",
+ "const Geo1 = Obj.geometry;",
+ "const Geo2 = OtherObj.geometry;",
+ "if (!Geo1 || !Geo2) {",
+ " console.warn(\"Geometry not found: \" + Id + \" or \" + OtherId);",
+ " return;",
+ "}",
+ "//",
+ "const OBB1 = new THREE.OBB().fromBox3(Geo1.boundingBox);",
+ "const OBB2 = new THREE.OBB().fromBox3(Geo2.boundingBox);",
+ "Obj.updateMatrixWorld(false);//必要?",
+ "OtherObj.updateMatrixWorld(false);//必要?",
+ "OBB1.applyMatrix4(Obj.matrixWorld);",
+ "OBB2.applyMatrix4(OtherObj.matrixWorld);",
+ "eventsFunctionContext.returnValue = OBB1.intersectsOBB(OBB2);",
+ "",
+ ""
+ ],
+ "parameterObjects": "",
+ "useStrict": true,
+ "eventsSheetExpanded": true
+ }
+ ],
+ "parameters": [
+ {
+ "description": "3D Object ID",
+ "name": "Id",
+ "supplementaryInformation": "scene3D Object ID",
+ "type": "identifier"
+ },
+ {
+ "description": "Other 3D Object ID",
+ "name": "OtherId",
+ "supplementaryInformation": "scene3D Object ID",
+ "type": "identifier"
+ }
+ ],
+ "objectGroups": []
+ },
{
"description": "Check if the 3D Animation is playing.",
- "fullName": "Check 3D Animation Is Playing",
+ "fullName": "🎞️Check 3D Animation Is Playing",
"functionType": "Condition",
"group": "3D Object",
"name": "Check3DAnimationIsPlaying",
- "sentence": "Check 3D Animation Is Playing (ID: _PARAM1_, Animation: _PARAM2_)",
+ "sentence": "🎞️Check 3D Animation Is Playing (ID: _PARAM1_, Animation: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -7980,7 +8677,7 @@
"const ANumber = eventsFunctionContext.getArgument(\"ANumber\");",
"eventsFunctionContext.returnValue = false;",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -8023,13 +8720,12 @@
"objectGroups": []
},
{
- "description": "Check if all 3D animations are stopped.",
- "fullName": "Check All 3D Animations Are Stopped (Deprecated)",
+ "description": "Check if the 3D Animation is finished.\nThis condition is valid only for animations with \"Loop\" set to \"Once\".",
+ "fullName": "🎞️Check 3D Animation Is Finished",
"functionType": "Condition",
"group": "3D Object",
- "name": "CheckAll3DAnimationsAreStopped",
- "private": true,
- "sentence": "⚠️ Check All 3D Animations Are Stopped (ID: _PARAM1_)",
+ "name": "Check3DAnimationIsFinished",
+ "sentence": "🎞️Check 3D Animation Is Finished (ID: _PARAM1_, Animation: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -8042,20 +8738,34 @@
"const AnimationMixer = gdjs.__WithThreeJS.get(\"AnimationMixer\");",
"const AnimationActions = gdjs.__WithThreeJS.get(\"AnimationActions\");",
"const Id = eventsFunctionContext.getArgument(\"Id\");",
- "eventsFunctionContext.returnValue = true;",
+ "const ANumber = eventsFunctionContext.getArgument(\"ANumber\");",
+ "eventsFunctionContext.returnValue = false;",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
"}",
+ "const Clip = Obj.animations[ANumber];",
+ "if (!Clip) {",
+ " return;",
+ "}",
"//",
"const OBJ_UUID = Obj.uuid;",
+ "const Clip_UUID = Clip.uuid;",
"if (AnimationActions.has(OBJ_UUID)) {",
- " for (const [K, V] of AnimationActions.get(OBJ_UUID)) {",
- " if (V.isRunning()) {",
- " eventsFunctionContext.returnValue = false;",
- " break;",
+ " if (AnimationActions.get(OBJ_UUID).has(Clip_UUID)) {",
+ " const Action = AnimationActions.get(OBJ_UUID).get(Clip_UUID);",
+ " if (Action.loop === THREE.LoopOnce) {",
+ " if (Action.timeScale >= 0) {",
+ " if (Action.time >= Clip.duration) {",
+ " eventsFunctionContext.returnValue = true;",
+ " }",
+ " } else {",
+ " if (Action.time <= 0) {",
+ " eventsFunctionContext.returnValue = true;",
+ " }",
+ " }",
" }",
" }",
"}",
@@ -8073,17 +8783,23 @@
"name": "Id",
"supplementaryInformation": "scene3D Object ID",
"type": "identifier"
+ },
+ {
+ "description": "Original Animation Number",
+ "name": "ANumber",
+ "supplementaryInformation": "scene3D Object ID",
+ "type": "expression"
}
],
"objectGroups": []
},
- {
- "description": "Check if the 3D Animation is finished.\nThis condition is valid only for animations with \"Loop\" set to \"Once\".",
- "fullName": "Check 3D Animation Is Finished",
- "functionType": "Condition",
- "group": "3D Object",
- "name": "Check3DAnimationIsFinished",
- "sentence": "Check 3D Animation Is Finished (ID: _PARAM1_, Animation: _PARAM2_)",
+ {
+ "description": "Play a 3D Positional Sound.\nThis action is deprecated but is still available. This is because the new action has issues with the editor and is difficult to use.",
+ "fullName": "Play 3D Sound V1 (Deprecated)",
+ "functionType": "Action",
+ "group": "3D Sound",
+ "name": "Play3DSound",
+ "sentence": "⚠️ Play 3D Sound V1 (Resource: _PARAM1_, Sound ID: _PARAM2_, Parent ID: _PARAM3_, Loop: _PARAM4_, Volume: _PARAM5_, Pitch: _PARAM6_, Distance: _PARAM7_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -8093,40 +8809,48 @@
" return;",
"}",
"const Scene = gdjs.__WithThreeJS.get(\"Scene\");",
- "const AnimationMixer = gdjs.__WithThreeJS.get(\"AnimationMixer\");",
- "const AnimationActions = gdjs.__WithThreeJS.get(\"AnimationActions\");",
+ "const Listener = gdjs.__WithThreeJS.get(\"Listener\");",
+ "const ResourceName = eventsFunctionContext.getArgument(\"ResourceName\");",
+ "const SoundId = eventsFunctionContext.getArgument(\"SoundId\");",
"const Id = eventsFunctionContext.getArgument(\"Id\");",
- "const ANumber = eventsFunctionContext.getArgument(\"ANumber\");",
- "eventsFunctionContext.returnValue = false;",
+ "const Loop = eventsFunctionContext.getArgument(\"Loop\");",
+ "const Volume = eventsFunctionContext.getArgument(\"Volume\") || 1;",
+ "const Pitch = eventsFunctionContext.getArgument(\"Pitch\") || 1;",
+ "let MaxDistance = eventsFunctionContext.getArgument(\"MaxDistance\") || 1000;",
+ "//",
+ "const ResourceFileName = gdjs.__WithThreeJS.get(\"GetResourceFileName\")(ResourceName, \"audio\");",
+ "MaxDistance = MaxDistance <= 0 ? 0.0001 : MaxDistance;",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
"}",
- "const Clip = Obj.animations[ANumber];",
- "if (!Clip) {",
- " return;",
- "}",
"//",
- "const OBJ_UUID = Obj.uuid;",
- "const Clip_UUID = Clip.uuid;",
- "if (AnimationActions.has(OBJ_UUID)) {",
- " if (AnimationActions.get(OBJ_UUID).has(Clip_UUID)) {",
- " const Action = AnimationActions.get(OBJ_UUID).get(Clip_UUID);",
- " if (Action.loop === THREE.LoopOnce) {",
- " if (Action.timeScale >= 0) {",
- " if (Action.time >= Clip.duration) {",
- " eventsFunctionContext.returnValue = true;",
- " }",
- " } else {",
- " if (Action.time <= 0) {",
- " eventsFunctionContext.returnValue = true;",
- " }",
- " }",
- " }",
- " }",
+ "let Sound = Obj.getObjectByName(SoundId);",
+ "if (!Sound) {",
+ "\tSound = new THREE.PositionalAudio(Listener);",
+ "\tSound.name = SoundId;",
+ "\tObj.add(Sound);",
"}",
+ "Sound.setRefDistance(1);//音量の低下が有効になり始める距離",
+ "Sound.setRolloffFactor(1)//音量が減少する速さ",
+ "Sound.setDistanceModel(\"linear\");",
+ "Sound.setMaxDistance(MaxDistance);//リスナーの間の最大距離",
+ "//",
+ "Sound.setLoop(Loop);",
+ "Sound.setVolume(Volume);",
+ "Sound.setPlaybackRate(Pitch);//再生速度",
+ "// Sound.setDetune(0);//ピッチ(なぜかエラーになる)",
+ "//",
+ "const audioLoader = new THREE.AudioLoader();",
+ "audioLoader.load(ResourceFileName, function(buffer) {",
+ "\tSound.setBuffer(buffer);",
+ "\tif (Sound.isPlaying) {",
+ "\t\tSound.stop();",
+ "\t}",
+ "\tSound.play();",
+ "});",
"",
""
],
@@ -8137,15 +8861,41 @@
],
"parameters": [
{
- "description": "3D Object ID",
+ "description": "GDevelop Resource Name (Audio)",
+ "longDescription": "Escape is required. example: \"assets\\\\Sound.wav\" -> \"assets\\\\\\\\Sound.wav\"",
+ "name": "ResourceName",
+ "type": "string"
+ },
+ {
+ "description": "3D Sound ID",
+ "name": "SoundId",
+ "supplementaryInformation": "scene3D Sound ID",
+ "type": "identifier"
+ },
+ {
+ "description": "Parent 3D Object ID",
"name": "Id",
"supplementaryInformation": "scene3D Object ID",
"type": "identifier"
},
{
- "description": "Original Animation Number",
- "name": "ANumber",
- "supplementaryInformation": "scene3D Object ID",
+ "description": "Loop",
+ "name": "Loop",
+ "type": "yesorno"
+ },
+ {
+ "description": "Volume (Default: 1)",
+ "name": "Volume",
+ "type": "expression"
+ },
+ {
+ "description": "Pitch (Default: 1)",
+ "name": "Pitch",
+ "type": "expression"
+ },
+ {
+ "description": "Max Distance (0 or more)",
+ "name": "MaxDistance",
"type": "expression"
}
],
@@ -8153,11 +8903,11 @@
},
{
"description": "Play a 3D Positional Sound.",
- "fullName": "Play 3D Sound",
+ "fullName": "🔊Play 3D Sound",
"functionType": "Action",
"group": "3D Sound",
- "name": "Play3DSound",
- "sentence": "Play 3D Sound (Resource: _PARAM1_, Sound ID: _PARAM2_, Parent ID: _PARAM3_, Loop: _PARAM4_, Volume: _PARAM5_, Pitch: _PARAM6_, Distance: _PARAM7_)",
+ "name": "Play3DSoundV2",
+ "sentence": "🔊Play 3D Sound (Resource: _PARAM1_, Sound ID: _PARAM2_, Parent ID: _PARAM3_, Loop: _PARAM4_, Volume: _PARAM5_, Pitch: _PARAM6_, Distance: _PARAM7_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -8179,7 +8929,7 @@
"const ResourceFileName = gdjs.__WithThreeJS.get(\"GetResourceFileName\")(ResourceName, \"audio\");",
"MaxDistance = MaxDistance <= 0 ? 0.0001 : MaxDistance;",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -8220,9 +8970,8 @@
"parameters": [
{
"description": "GDevelop Resource Name (Audio)",
- "longDescription": "Escape is required. example: \"assets\\\\Sound.wav\" -> \"assets\\\\\\\\Sound.wav\"",
"name": "ResourceName",
- "type": "string"
+ "type": "audioResource"
},
{
"description": "3D Sound ID",
@@ -8261,11 +9010,11 @@
},
{
"description": "Stop a 3D Positional Sound.",
- "fullName": "Stop 3D Sound",
+ "fullName": "🔇Stop 3D Sound",
"functionType": "Action",
"group": "3D Sound",
"name": "Stop3DSound",
- "sentence": "Stop 3D Sound (Sound ID: _PARAM1_, Parent ID: _PARAM2_)",
+ "sentence": "🔇Stop 3D Sound (Sound ID: _PARAM1_, Parent ID: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -8278,7 +9027,7 @@
"const SoundId = eventsFunctionContext.getArgument(\"SoundId\");",
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -8317,11 +9066,11 @@
"objectGroups": []
},
{
- "fullName": "Change Master Volume Of 3D Scene",
+ "fullName": "🔊Change Master Volume Of 3D Scene",
"functionType": "Action",
"group": "3D Sound",
"name": "ChangeMasterVolumeOf3DScene",
- "sentence": "Change Master Volume Of 3D Scene (_PARAM1_, Volume: _PARAM2_)",
+ "sentence": "🔊Change Master Volume Of 3D Scene (_PARAM1_, Volume: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -8396,11 +9145,11 @@
},
{
"description": "Check if the 3D Sound is playing.",
- "fullName": "Check 3D Sound Is Playing",
+ "fullName": "🔊Check 3D Sound Is Playing",
"functionType": "Condition",
"group": "3D Sound",
"name": "Check3DSoundIsPlaying",
- "sentence": "Check 3D Sound Is Playing (Sound ID: _PARAM1_, Parent ID: _PARAM2_)",
+ "sentence": "🔊Check 3D Sound Is Playing (Sound ID: _PARAM1_, Parent ID: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -8413,7 +9162,7 @@
"const SoundId = eventsFunctionContext.getArgument(\"SoundId\");",
"const Id = eventsFunctionContext.getArgument(\"Id\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -8450,11 +9199,11 @@
"objectGroups": []
},
{
- "fullName": "Create 3D Axes Helper",
+ "fullName": "🛟Create 3D Axes Helper",
"functionType": "Action",
"group": "3D Debug",
"name": "Create3DAxesHelper",
- "sentence": "Create 3D Axes Helper (Parent ID: _PARAM1_, Size: _PARAM2_)",
+ "sentence": "🛟Create 3D Axes Helper (Parent ID: _PARAM1_, Size: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -8468,14 +9217,14 @@
"const ParentId = eventsFunctionContext.getArgument(\"ParentId\");",
"const Size = eventsFunctionContext.getArgument(\"Size\");",
"//",
- "const Parent = Scene.getObjectByName(ParentId);",
+ "const Parent = gdjs.__WithThreeJS.get(\"SearchObject\")(ParentId);",
"if (!Parent) {",
" console.warn(\"Parent 3D Object not found: \" + ParentId);",
" return;",
"}",
"//",
"const AxesHelper = new THREE.AxesHelper(Size);",
- "AxesHelper.name = \"AxesHelper\";",
+ "AxesHelper.name = ParentId + \"_AxesHelper\";",
"Parent.add(AxesHelper);"
],
"parameterObjects": "",
@@ -8500,11 +9249,11 @@
},
{
"description": "Create or update Helper to graphically display Bounding Box.",
- "fullName": "Update Bounding Box Helper",
+ "fullName": "🛟Update Bounding Box Helper",
"functionType": "Action",
"group": "3D Debug",
"name": "UpdateBoundingBoxHelper",
- "sentence": "Update Bounding Box Helper (ID: _PARAM1_, Color: _PARAM2_)",
+ "sentence": "🛟Update Bounding Box Helper (ID: _PARAM1_, Color: _PARAM2_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -8519,7 +9268,7 @@
"const Color = eventsFunctionContext.getArgument(\"Color\") || \"0;0;0\";",
"const RGB = Color.split(\";\");",
"//",
- "const Obj = Scene.getObjectByName(Id);",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);",
"if (!Obj) {",
" console.warn(\"3D Object not found: \" + Id);",
" return;",
@@ -8529,28 +9278,18 @@
" return;",
"}",
"//",
- "/*",
- "let BoxHelper = Scene.getObjectByName(\"_BoxHelper\"+ Id);",
- "if (!BoxHelper) {",
- " BoxHelper = new THREE.BoxHelper(Obj, `rgb(${RGB[0]}, ${RGB[1]}, ${RGB[2]})`);",
- " BoxHelper.name = \"_BoxHelper\"+ Id;",
- " Scene.add(BoxHelper);",
- "}",
- "BoxHelper.update();",
- "*/",
- "//",
- "let Box3Helper = Scene.getObjectByName(\"_Box3Helper\"+ Id);",
+ "// BoxHelper では子まで含んでしまう",
+ "let Box3Helper = gdjs.__WithThreeJS.get(\"SearchObject\")(Id + \"_Box3Helper\");",
"if (Box3Helper) {",
- " Scene.remove(Box3Helper);",
- " Box3Helper.dispose();",
+ " Box3Helper.box.copy(Obj.geometry.boundingBox).applyMatrix4(Obj.matrixWorld);",
"} else {",
" Obj.updateMatrixWorld(true);//シーン開始直後のみ必要だが一応全て最初に実行する",
+ " const Box3 = new THREE.Box3();",
+ " Box3.copy(Obj.geometry.boundingBox).applyMatrix4(Obj.matrixWorld);",
+ " Box3Helper = new THREE.Box3Helper(Box3, `rgb(${RGB[0]}, ${RGB[1]}, ${RGB[2]})`);",
+ " Box3Helper.name = Id + \"_Box3Helper\";",
+ " Scene.add(Box3Helper);",
"}",
- "const Box3 = new THREE.Box3();",
- "Box3.copy(Obj.geometry.boundingBox).applyMatrix4(Obj.matrixWorld);",
- "Box3Helper = new THREE.Box3Helper(Box3, `rgb(${RGB[0]}, ${RGB[1]}, ${RGB[2]})`);",
- "Box3Helper.name = \"_Box3Helper\"+ Id;",
- "Scene.add(Box3Helper);",
"",
""
],
@@ -8575,11 +9314,11 @@
"objectGroups": []
},
{
- "fullName": "Output 3D Model Information To Console",
+ "fullName": "🛟Output 3D Model Information To Console",
"functionType": "Action",
"group": "3D Debug",
"name": "OutputModelInformationToConsole",
- "sentence": "Output 3D Model Information To Console (3D Model ID: _PARAM1_)",
+ "sentence": "🛟Output 3D Model Information To Console (3D Model ID: _PARAM1_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -8622,11 +9361,11 @@
"objectGroups": []
},
{
- "fullName": "Output All IDs To Console",
+ "fullName": "🛟Output All IDs To Console",
"functionType": "Action",
"group": "3D Debug",
"name": "OutputAllIdsToConsole",
- "sentence": "Output All IDs To Console (Type: _PARAM1_)",
+ "sentence": "🛟Output All IDs To Console (Type: _PARAM1_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
@@ -8738,12 +9477,14 @@
"// const X = objects[0].x;",
"// const Y = objects[0].y;",
"// const Z = objects[0].zOrder;",
- "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");//Behavior.ProjectionScale();",
- "// const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");//Behavior.ViewMode();",
+ "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");",
+ "// const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");",
"const AlphaTest = Behavior.AlphaTest();",
"const Transparent = AlphaTest !== 0;",
"const AntiAliasing = Behavior.AntiAliasing();",
"const Depth = Behavior.Depth();",
+ "const CastShadow = Behavior.CastShadow();",
+ "const ReceiveShadow = Behavior.ReceiveShadow();",
"// const Blend = THREE.NormalBlending;",
"// const Opacity = 1.0;",
"//",
@@ -8800,8 +9541,8 @@
"Sprite.geometry.computeBoundingBox();",
"Sprite.geometry.boundingBox.expandByVector(new THREE.Vector3(0, 0, (Depth * ProjectionScale) / 2));",
"Sprite.name = Id;",
- "Sprite.castShadow = true;// スプライトは影を投影しないため無意味",
- "Sprite.receiveShadow = true;",
+ "Sprite.castShadow = CastShadow;// スプライトは影を投影しないため無意味",
+ "Sprite.receiveShadow = ReceiveShadow;",
"Sprite.userData.Use3DProjectionBehavior = true;",
"Sprite.scale.set(TextureWidth * ProjectionScale, TextureHeight * ProjectionScale, 1);",
"Behavior.SetId(Id);",
@@ -8858,10 +9599,10 @@
"const X = objects[0].getCenterXInScene();\r",
"const Y = objects[0].getCenterYInScene();\r",
"const Z = objects[0].zOrder;\r",
- "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");//Behavior.ProjectionScale();\r",
- "const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");//Behavior.ViewMode();\r",
+ "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");\r",
+ "const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");\r",
"//\r",
- "const Sprite = Scene.getObjectByName(Id);\r",
+ "const Sprite = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);\r",
"objects[0]._updateAnimationFrame();//v5.3.198 からのアニメ更新が不規則になる問題への対応\r",
"let TextureId = \"_\" + objects[0].getRendererObject().texture.baseTexture.resource.url;\r",
"// Flip\r",
@@ -8895,10 +9636,9 @@
"// Move\r",
"if (ViewMode == \"Top Down\") {\r",
" Sprite.position.set(X * ProjectionScale, Z * ProjectionScale, Y * ProjectionScale);\r",
- "} else if (ViewMode == \"Side\") {\r",
- " Sprite.position.set(X * ProjectionScale, -Y * ProjectionScale, Z * ProjectionScale);\r",
"} else {\r",
- " Sprite.position.set(X * ProjectionScale, Y * ProjectionScale, Z * ProjectionScale);\r",
+ " // Side\r",
+ " Sprite.position.set(X * ProjectionScale, -Y * ProjectionScale, Z * ProjectionScale);\r",
"}\r",
"\r",
""
@@ -8946,9 +9686,10 @@
" return;\r",
"}\r",
"const Scene = gdjs.__WithThreeJS.get(\"Scene\");\r",
- "const Sprite = Scene.getObjectByName(Id);\r",
+ "const Sprite = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);\r",
"//\r",
"Sprite.material.dispose();\r",
+ "gdjs.__WithThreeJS.get(\"ObjectList\").delete(Id);\r",
"Sprite.removeFromParent();"
],
"parameterObjects": "Object",
@@ -8973,69 +9714,215 @@
"objectGroups": []
},
{
- "fullName": "3D Object ID",
- "functionType": "StringExpression",
- "name": "Id",
- "sentence": "",
+ "fullName": "3D Object ID",
+ "functionType": "StringExpression",
+ "name": "Id",
+ "sentence": "",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::Standard",
+ "conditions": [],
+ "actions": [
+ {
+ "type": {
+ "value": "SetReturnString"
+ },
+ "parameters": [
+ "Object.Behavior::PropertyId()"
+ ]
+ }
+ ]
+ }
+ ],
+ "expressionType": {
+ "type": "string"
+ },
+ "parameters": [
+ {
+ "description": "Object",
+ "name": "Object",
+ "supplementaryInformation": "Sprite",
+ "type": "object"
+ },
+ {
+ "description": "Behavior",
+ "name": "Behavior",
+ "supplementaryInformation": "WithThreeJS::SpriteProjection",
+ "type": "behavior"
+ }
+ ],
+ "objectGroups": []
+ },
+ {
+ "fullName": "Alpha Channel Test",
+ "functionType": "Expression",
+ "name": "AlphaTest",
+ "sentence": "",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::Standard",
+ "conditions": [],
+ "actions": [
+ {
+ "type": {
+ "value": "SetReturnNumber"
+ },
+ "parameters": [
+ "Object.Behavior::PropertyAlphaTest()"
+ ]
+ }
+ ]
+ }
+ ],
+ "expressionType": {
+ "type": "expression"
+ },
+ "parameters": [
+ {
+ "description": "Object",
+ "name": "Object",
+ "supplementaryInformation": "Sprite",
+ "type": "object"
+ },
+ {
+ "description": "Behavior",
+ "name": "Behavior",
+ "supplementaryInformation": "WithThreeJS::SpriteProjection",
+ "type": "behavior"
+ }
+ ],
+ "objectGroups": []
+ },
+ {
+ "fullName": "Is Anti-Aliasing",
+ "functionType": "Condition",
+ "name": "AntiAliasing",
+ "private": true,
+ "sentence": "Is Anti-Aliasing _PARAM0_",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::Standard",
+ "conditions": [
+ {
+ "type": {
+ "value": "WithThreeJS::SpriteProjection::PropertyAntiAliasing"
+ },
+ "parameters": [
+ "Object",
+ "Behavior"
+ ]
+ }
+ ],
+ "actions": [
+ {
+ "type": {
+ "value": "SetReturnBoolean"
+ },
+ "parameters": [
+ "True"
+ ]
+ }
+ ]
+ },
+ {
+ "type": "BuiltinCommonInstructions::Standard",
+ "conditions": [
+ {
+ "type": {
+ "inverted": true,
+ "value": "WithThreeJS::SpriteProjection::PropertyAntiAliasing"
+ },
+ "parameters": [
+ "Object",
+ "Behavior"
+ ]
+ }
+ ],
+ "actions": [
+ {
+ "type": {
+ "value": "SetReturnBoolean"
+ },
+ "parameters": [
+ "False"
+ ]
+ }
+ ]
+ }
+ ],
+ "parameters": [
+ {
+ "description": "Object",
+ "name": "Object",
+ "supplementaryInformation": "Sprite",
+ "type": "object"
+ },
+ {
+ "description": "Behavior",
+ "name": "Behavior",
+ "supplementaryInformation": "WithThreeJS::SpriteProjection",
+ "type": "behavior"
+ }
+ ],
+ "objectGroups": []
+ },
+ {
+ "fullName": "Is Cast Shadow",
+ "functionType": "Condition",
+ "name": "CastShadow",
+ "private": true,
+ "sentence": "Is Cast Shadow _PARAM0_",
"events": [
{
"type": "BuiltinCommonInstructions::Standard",
- "conditions": [],
+ "conditions": [
+ {
+ "type": {
+ "value": "WithThreeJS::SpriteProjection::PropertyCastShadow"
+ },
+ "parameters": [
+ "Object",
+ "Behavior"
+ ]
+ }
+ ],
"actions": [
{
"type": {
- "value": "SetReturnString"
+ "value": "SetReturnBoolean"
},
"parameters": [
- "Object.Behavior::PropertyId()"
+ "True"
]
}
]
- }
- ],
- "expressionType": {
- "type": "string"
- },
- "parameters": [
- {
- "description": "Object",
- "name": "Object",
- "supplementaryInformation": "Sprite",
- "type": "object"
},
- {
- "description": "Behavior",
- "name": "Behavior",
- "supplementaryInformation": "WithThreeJS::SpriteProjection",
- "type": "behavior"
- }
- ],
- "objectGroups": []
- },
- {
- "fullName": "Alpha Channel Test",
- "functionType": "Expression",
- "name": "AlphaTest",
- "sentence": "",
- "events": [
{
"type": "BuiltinCommonInstructions::Standard",
- "conditions": [],
+ "conditions": [
+ {
+ "type": {
+ "inverted": true,
+ "value": "WithThreeJS::SpriteProjection::PropertyCastShadow"
+ },
+ "parameters": [
+ "Object",
+ "Behavior"
+ ]
+ }
+ ],
"actions": [
{
"type": {
- "value": "SetReturnNumber"
+ "value": "SetReturnBoolean"
},
"parameters": [
- "Object.Behavior::PropertyAlphaTest()"
+ "False"
]
}
]
}
],
- "expressionType": {
- "type": "expression"
- },
"parameters": [
{
"description": "Object",
@@ -9053,18 +9940,18 @@
"objectGroups": []
},
{
- "fullName": "Is Anti-Aliasing",
+ "fullName": "Is Receive Shadow",
"functionType": "Condition",
- "name": "AntiAliasing",
+ "name": "ReceiveShadow",
"private": true,
- "sentence": "Is Anti-Aliasing _PARAM0_",
+ "sentence": "Is Receive Shadow _PARAM0_",
"events": [
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
- "value": "WithThreeJS::SpriteProjection::PropertyAntiAliasing"
+ "value": "WithThreeJS::SpriteProjection::PropertyReceiveShadow"
},
"parameters": [
"Object",
@@ -9089,7 +9976,7 @@
{
"type": {
"inverted": true,
- "value": "WithThreeJS::SpriteProjection::PropertyAntiAliasing"
+ "value": "WithThreeJS::SpriteProjection::PropertyReceiveShadow"
},
"parameters": [
"Object",
@@ -9369,6 +10256,26 @@
"group": "Collision",
"extraInformation": [],
"name": "Depth"
+ },
+ {
+ "value": "",
+ "type": "Boolean",
+ "label": "Cast Shadow",
+ "description": "If both \"Cast Shadow\" and \"Receive Shadow\" are enabled, striped patterns are likely to occur in the shadow.",
+ "group": "Shadow",
+ "extraInformation": [],
+ "hidden": true,
+ "name": "CastShadow"
+ },
+ {
+ "value": "",
+ "type": "Boolean",
+ "label": "Receive Shadow",
+ "description": "If both \"Cast Shadow\" and \"Receive Shadow\" are enabled, striped patterns are likely to occur in the shadow.",
+ "group": "Shadow",
+ "extraInformation": [],
+ "hidden": true,
+ "name": "ReceiveShadow"
}
],
"sharedPropertyDescriptors": []
@@ -9426,12 +10333,14 @@
"//",
"const Behavior = objects[0].getBehavior(\"BoardProjection\");",
"const Id = objects[0].name + objects[0].id;",
- "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");//Behavior.ProjectionScale();",
- "// const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");//Behavior.ViewMode();",
+ "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");",
+ "// const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");",
"const AlphaTest = Behavior.AlphaTest();",
"const Transparent = AlphaTest !== 0;",
"const AntiAliasing = Behavior.AntiAliasing();",
"const Depth = Behavior.Depth();",
+ "const CastShadow = Behavior.CastShadow();",
+ "const ReceiveShadow = Behavior.ReceiveShadow();",
"//",
"//スプライトのすべてのアニメーション画像を取得",
"objects[0]._updateIfNotVisible = true;// 非表示でもアニメーション更新を強制",
@@ -9485,8 +10394,8 @@
"Geometry.boundingBox.expandByVector(new THREE.Vector3(0, 0, (Depth * ProjectionScale) / 2));",
"const Obj = new THREE.Mesh(Geometry, Material);",
"Obj.name = Id;",
- "Obj.castShadow = true;",
- "Obj.receiveShadow = true;",
+ "Obj.castShadow = CastShadow;",
+ "Obj.receiveShadow = ReceiveShadow;",
"Obj.userData.Use3DProjectionBehavior = true;",
"Behavior.SetId(Id);",
"Scene.add(Obj);",
@@ -9542,12 +10451,12 @@
"const X = objects[0].getCenterXInScene();\r",
"const Y = objects[0].getCenterYInScene();\r",
"const Z = objects[0].zOrder;\r",
- "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");//Behavior.ProjectionScale();\r",
- "const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");//Behavior.ViewMode();\r",
+ "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");\r",
+ "const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");\r",
"const AngleAxis = Behavior.AngleAxis();\r",
"const Orientation = Behavior.Orientation();\r",
"//\r",
- "const Obj = Scene.getObjectByName(Id);\r",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);\r",
"objects[0]._updateAnimationFrame();//v5.3.198 からのアニメ更新が不規則になる問題への対応\r",
"let TextureId = \"_\" + objects[0].getRendererObject().texture.baseTexture.resource.url;\r",
"// Flip\r",
@@ -9575,21 +10484,10 @@
"}\r",
"Obj.material.opacity = Opacity;\r",
"// Scale\r",
- "if (ViewMode === \"Built-In 3D\") {\r",
- " Obj.scale.set(objects[0].getScaleX(), objects[0].getScaleY() * -1, 1);\r",
- "} else {\r",
- " Obj.scale.set(objects[0].getScaleX(), objects[0].getScaleY(), 1);\r",
- "}\r",
+ "Obj.scale.set(objects[0].getScaleX(), objects[0].getScaleY(), 1);\r",
"// Rotate\r",
- "let BaseXAngle;\r",
- "let Angle;\r",
- "if (ViewMode === \"Built-In 3D\") {\r",
- " BaseXAngle = (Orientation == \"Vertical\") ? -90 : 0;\r",
- " Angle = (AngleAxis == \"Y Axis\") ? objects[0].angle * -1 : objects[0].angle;\r",
- "} else {\r",
- " BaseXAngle = (Orientation == \"Horizontal\") ? -90 : 0;\r",
- " Angle = objects[0].angle * -1;\r",
- "}\r",
+ "const BaseXAngle = (Orientation == \"Horizontal\") ? -90 : 0;\r",
+ "const Angle = objects[0].angle * -1;\r",
"if (AngleAxis == \"X Axis\") {\r",
" Obj.rotation.set(gdjs.toRad(BaseXAngle + Angle), gdjs.toRad(0), gdjs.toRad(0));\r",
"} else if (AngleAxis == \"Y Axis\") {\r",
@@ -9600,10 +10498,9 @@
"// Move\r",
"if (ViewMode == \"Top Down\") {\r",
" Obj.position.set(X * ProjectionScale, Z * ProjectionScale, Y * ProjectionScale);\r",
- "} else if (ViewMode == \"Side\") {\r",
- " Obj.position.set(X * ProjectionScale, -Y * ProjectionScale, Z * ProjectionScale);\r",
"} else {\r",
- " Obj.position.set(X * ProjectionScale, Y * ProjectionScale, Z * ProjectionScale);\r",
+ " // Side\r",
+ " Obj.position.set(X * ProjectionScale, -Y * ProjectionScale, Z * ProjectionScale);\r",
"}\r",
"\r",
""
@@ -9651,9 +10548,10 @@
" return;\r",
"}\r",
"const Scene = gdjs.__WithThreeJS.get(\"Scene\");\r",
- "const Sprite = Scene.getObjectByName(Id);\r",
+ "const Sprite = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);\r",
"//\r",
"Sprite.material.dispose();\r",
+ "gdjs.__WithThreeJS.get(\"ObjectList\").delete(Id);\r",
"Sprite.removeFromParent();"
],
"parameterObjects": "Object",
@@ -9729,18 +10627,171 @@
"actions": [
{
"type": {
- "value": "SetReturnNumber"
+ "value": "SetReturnNumber"
+ },
+ "parameters": [
+ "Object.Behavior::PropertyAlphaTest()"
+ ]
+ }
+ ]
+ }
+ ],
+ "expressionType": {
+ "type": "expression"
+ },
+ "parameters": [
+ {
+ "description": "Object",
+ "name": "Object",
+ "supplementaryInformation": "Sprite",
+ "type": "object"
+ },
+ {
+ "description": "Behavior",
+ "name": "Behavior",
+ "supplementaryInformation": "WithThreeJS::BoardProjection",
+ "type": "behavior"
+ }
+ ],
+ "objectGroups": []
+ },
+ {
+ "fullName": "Axis linked to 2D Object Angle",
+ "functionType": "StringExpression",
+ "name": "AngleAxis",
+ "sentence": "",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::Standard",
+ "conditions": [],
+ "actions": [
+ {
+ "type": {
+ "value": "SetReturnString"
+ },
+ "parameters": [
+ "Object.Behavior::PropertyAngleAxis()"
+ ]
+ }
+ ]
+ }
+ ],
+ "expressionType": {
+ "type": "string"
+ },
+ "parameters": [
+ {
+ "description": "Object",
+ "name": "Object",
+ "supplementaryInformation": "Sprite",
+ "type": "object"
+ },
+ {
+ "description": "Behavior",
+ "name": "Behavior",
+ "supplementaryInformation": "WithThreeJS::BoardProjection",
+ "type": "behavior"
+ }
+ ],
+ "objectGroups": []
+ },
+ {
+ "fullName": "Orientation",
+ "functionType": "StringExpression",
+ "name": "Orientation",
+ "sentence": "",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::Standard",
+ "conditions": [],
+ "actions": [
+ {
+ "type": {
+ "value": "SetReturnString"
+ },
+ "parameters": [
+ "Object.Behavior::PropertyOrientation()"
+ ]
+ }
+ ]
+ }
+ ],
+ "expressionType": {
+ "type": "string"
+ },
+ "parameters": [
+ {
+ "description": "Object",
+ "name": "Object",
+ "supplementaryInformation": "Sprite",
+ "type": "object"
+ },
+ {
+ "description": "Behavior",
+ "name": "Behavior",
+ "supplementaryInformation": "WithThreeJS::BoardProjection",
+ "type": "behavior"
+ }
+ ],
+ "objectGroups": []
+ },
+ {
+ "fullName": "Is Anti-Aliasing",
+ "functionType": "Condition",
+ "name": "AntiAliasing",
+ "private": true,
+ "sentence": "Is Anti-Aliasing _PARAM0_",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::Standard",
+ "conditions": [
+ {
+ "type": {
+ "value": "WithThreeJS::BoardProjection::PropertyAntiAliasing"
+ },
+ "parameters": [
+ "Object",
+ "Behavior"
+ ]
+ }
+ ],
+ "actions": [
+ {
+ "type": {
+ "value": "SetReturnBoolean"
+ },
+ "parameters": [
+ "True"
+ ]
+ }
+ ]
+ },
+ {
+ "type": "BuiltinCommonInstructions::Standard",
+ "conditions": [
+ {
+ "type": {
+ "inverted": true,
+ "value": "WithThreeJS::BoardProjection::PropertyAntiAliasing"
+ },
+ "parameters": [
+ "Object",
+ "Behavior"
+ ]
+ }
+ ],
+ "actions": [
+ {
+ "type": {
+ "value": "SetReturnBoolean"
},
"parameters": [
- "Object.Behavior::PropertyAlphaTest()"
+ "False"
]
}
]
}
],
- "expressionType": {
- "type": "expression"
- },
"parameters": [
{
"description": "Object",
@@ -9758,9 +10809,10 @@
"objectGroups": []
},
{
- "fullName": "Axis linked to 2D Object Angle",
+ "fullName": "Current 3D Texture ID",
"functionType": "StringExpression",
- "name": "AngleAxis",
+ "name": "CurrentTextureId",
+ "private": true,
"sentence": "",
"events": [
{
@@ -9772,7 +10824,7 @@
"value": "SetReturnString"
},
"parameters": [
- "Object.Behavior::PropertyAngleAxis()"
+ "Object.Behavior::PropertyCurrentTextureId()"
]
}
]
@@ -9798,9 +10850,10 @@
"objectGroups": []
},
{
- "fullName": "Orientation",
- "functionType": "StringExpression",
- "name": "Orientation",
+ "fullName": "Depth for Bounding Box Collision",
+ "functionType": "Expression",
+ "name": "Depth",
+ "private": true,
"sentence": "",
"events": [
{
@@ -9809,17 +10862,17 @@
"actions": [
{
"type": {
- "value": "SetReturnString"
+ "value": "SetReturnNumber"
},
"parameters": [
- "Object.Behavior::PropertyOrientation()"
+ "Object.Behavior::PropertyDepth()"
]
}
]
}
],
"expressionType": {
- "type": "string"
+ "type": "expression"
},
"parameters": [
{
@@ -9838,18 +10891,18 @@
"objectGroups": []
},
{
- "fullName": "Is Anti-Aliasing",
+ "fullName": "Is Cast Shadow",
"functionType": "Condition",
- "name": "AntiAliasing",
+ "name": "CastShadow",
"private": true,
- "sentence": "Is Anti-Aliasing _PARAM0_",
+ "sentence": "Is Cast Shadow _PARAM0_",
"events": [
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
- "value": "WithThreeJS::BoardProjection::PropertyAntiAliasing"
+ "value": "WithThreeJS::BoardProjection::PropertyCastShadow"
},
"parameters": [
"Object",
@@ -9874,7 +10927,7 @@
{
"type": {
"inverted": true,
- "value": "WithThreeJS::BoardProjection::PropertyAntiAliasing"
+ "value": "WithThreeJS::BoardProjection::PropertyCastShadow"
},
"parameters": [
"Object",
@@ -9911,71 +10964,62 @@
"objectGroups": []
},
{
- "fullName": "Current 3D Texture ID",
- "functionType": "StringExpression",
- "name": "CurrentTextureId",
+ "fullName": "Is Receive Shadow",
+ "functionType": "Condition",
+ "name": "ReceiveShadow",
"private": true,
- "sentence": "",
+ "sentence": "Is Receive Shadow _PARAM0_",
"events": [
{
"type": "BuiltinCommonInstructions::Standard",
- "conditions": [],
+ "conditions": [
+ {
+ "type": {
+ "value": "WithThreeJS::BoardProjection::PropertyReceiveShadow"
+ },
+ "parameters": [
+ "Object",
+ "Behavior"
+ ]
+ }
+ ],
"actions": [
{
"type": {
- "value": "SetReturnString"
+ "value": "SetReturnBoolean"
},
"parameters": [
- "Object.Behavior::PropertyCurrentTextureId()"
+ "True"
]
}
]
- }
- ],
- "expressionType": {
- "type": "string"
- },
- "parameters": [
- {
- "description": "Object",
- "name": "Object",
- "supplementaryInformation": "Sprite",
- "type": "object"
},
- {
- "description": "Behavior",
- "name": "Behavior",
- "supplementaryInformation": "WithThreeJS::BoardProjection",
- "type": "behavior"
- }
- ],
- "objectGroups": []
- },
- {
- "fullName": "Depth for Bounding Box Collision",
- "functionType": "Expression",
- "name": "Depth",
- "private": true,
- "sentence": "",
- "events": [
{
"type": "BuiltinCommonInstructions::Standard",
- "conditions": [],
+ "conditions": [
+ {
+ "type": {
+ "inverted": true,
+ "value": "WithThreeJS::BoardProjection::PropertyReceiveShadow"
+ },
+ "parameters": [
+ "Object",
+ "Behavior"
+ ]
+ }
+ ],
"actions": [
{
"type": {
- "value": "SetReturnNumber"
+ "value": "SetReturnBoolean"
},
"parameters": [
- "Object.Behavior::PropertyDepth()"
+ "False"
]
}
]
}
],
- "expressionType": {
- "type": "expression"
- },
"parameters": [
{
"description": "Object",
@@ -10179,6 +11223,24 @@
"group": "Collision",
"extraInformation": [],
"name": "Depth"
+ },
+ {
+ "value": "",
+ "type": "Boolean",
+ "label": "Cast Shadow",
+ "description": "If both \"Cast Shadow\" and \"Receive Shadow\" are enabled, striped patterns are likely to occur in the shadow.",
+ "group": "Shadow",
+ "extraInformation": [],
+ "name": "CastShadow"
+ },
+ {
+ "value": "",
+ "type": "Boolean",
+ "label": "Receive Shadow",
+ "description": "If both \"Cast Shadow\" and \"Receive Shadow\" are enabled, striped patterns are likely to occur in the shadow.",
+ "group": "Shadow",
+ "extraInformation": [],
+ "name": "ReceiveShadow"
}
],
"sharedPropertyDescriptors": []
@@ -10241,8 +11303,8 @@
"// const Z = objects[0].zOrder;",
"const Width = objects[0].getWidth();",
"const Height = objects[0].getHeight();",
- "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");//Behavior.ProjectionScale();",
- "const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");//Behavior.ViewMode();",
+ "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");",
+ "const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");",
"const AlphaTest = Behavior.AlphaTest();",
"const Transparent = AlphaTest !== 0;",
"const AntiAliasing = Behavior.AntiAliasing();",
@@ -10255,6 +11317,8 @@
"} else if (Behavior.Blend() == \"Multiply\") {",
" Blend = THREE.MultiplyBlending;",
"}",
+ "const CastShadow = Behavior.CastShadow();",
+ "const ReceiveShadow = Behavior.ReceiveShadow();",
"// const Opacity = 1.0;",
"//",
"//タイルの画像を取得",
@@ -10291,13 +11355,10 @@
"Geometry.boundingBox.expandByVector(new THREE.Vector3(0, 0, (Depth * ProjectionScale) / 2));",
"const Obj = new THREE.Mesh(Geometry, Material);",
"Obj.name = Id;",
- "Obj.castShadow = true;",
- "Obj.receiveShadow = true;",
+ "Obj.castShadow = CastShadow;",
+ "Obj.receiveShadow = ReceiveShadow;",
"Obj.userData.Use3DProjectionBehavior = true;",
"Behavior.SetId(Id);",
- "if (ViewMode === \"Built-In 3D\") {",
- " Obj.scale.y = -1;",
- "}",
"Scene.add(Obj);",
"",
""
@@ -10351,11 +11412,11 @@
"const X = objects[0].getCenterXInScene();\r",
"const Y = objects[0].getCenterYInScene();\r",
"const Z = objects[0].zOrder;\r",
- "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");//Behavior.ProjectionScale();\r",
- "const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");//Behavior.ViewMode();\r",
+ "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");\r",
+ "const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");\r",
"const Rotate90 = Behavior.Rotate90();\r",
"//\r",
- "const Obj = Scene.getObjectByName(Id);\r",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);\r",
"// Move & Rotate\r",
"const Angle = objects[0].angle;\r",
"if (ViewMode == \"Top Down\") {\r",
@@ -10365,20 +11426,14 @@
" } else {\r",
" Obj.rotation.set(gdjs.toRad(-90), gdjs.toRad(0), gdjs.toRad(Angle * -1));\r",
" }\r",
- "} else if (ViewMode == \"Side\") {\r",
+ "} else {\r",
+ " // Side\r",
" Obj.position.set(X * ProjectionScale, -Y * ProjectionScale, Z * ProjectionScale);\r",
" if (Rotate90) {\r",
" Obj.rotation.set(gdjs.toRad(-90), gdjs.toRad(Angle), gdjs.toRad(0));\r",
" } else {\r",
" Obj.rotation.set(gdjs.toRad(0), gdjs.toRad(0), gdjs.toRad(Angle * -1));\r",
" }\r",
- "} else {\r",
- " Obj.position.set(X * ProjectionScale, Y * ProjectionScale, Z * ProjectionScale);\r",
- " if (Rotate90) {\r",
- " Obj.rotation.set(gdjs.toRad(-90), gdjs.toRad(Angle * -1), gdjs.toRad(0));\r",
- " } else {\r",
- " Obj.rotation.set(gdjs.toRad(0), gdjs.toRad(0), gdjs.toRad(Angle));\r",
- " }\r",
"}\r",
"// Opacity\r",
"const Opacity = objects[0].getOpacity() / 255;\r",
@@ -10444,7 +11499,7 @@
"}\r",
"const Scene = gdjs.__WithThreeJS.get(\"Scene\");\r",
"const Textures = gdjs.__WithThreeJS.get(\"Textures\");\r",
- "const Obj = Scene.getObjectByName(Id);\r",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);\r",
"if (!Obj) {\r",
" console.warn(\"3D Object not found.\");\r",
" return;\r",
@@ -10456,6 +11511,7 @@
"Texture.dispose();\r",
"Textures.delete(TextureId);\r",
"Obj.material.dispose();\r",
+ "gdjs.__WithThreeJS.get(\"ObjectList\").delete(Id);\r",
"Obj.removeFromParent();\r",
"\r",
""
@@ -10489,22 +11545,175 @@
"events": [
{
"type": "BuiltinCommonInstructions::Standard",
- "conditions": [],
+ "conditions": [],
+ "actions": [
+ {
+ "type": {
+ "value": "SetReturnString"
+ },
+ "parameters": [
+ "Object.Behavior::PropertyId()"
+ ]
+ }
+ ]
+ }
+ ],
+ "expressionType": {
+ "type": "string"
+ },
+ "parameters": [
+ {
+ "description": "Object",
+ "name": "Object",
+ "supplementaryInformation": "TiledSpriteObject::TiledSprite",
+ "type": "object"
+ },
+ {
+ "description": "Behavior",
+ "name": "Behavior",
+ "supplementaryInformation": "WithThreeJS::PlaneProjectionFromTiled",
+ "type": "behavior"
+ }
+ ],
+ "objectGroups": []
+ },
+ {
+ "fullName": "Alpha Channel Test",
+ "functionType": "Expression",
+ "name": "AlphaTest",
+ "sentence": "",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::Standard",
+ "conditions": [],
+ "actions": [
+ {
+ "type": {
+ "value": "SetReturnNumber"
+ },
+ "parameters": [
+ "Object.Behavior::PropertyAlphaTest()"
+ ]
+ }
+ ]
+ }
+ ],
+ "expressionType": {
+ "type": "expression"
+ },
+ "parameters": [
+ {
+ "description": "Object",
+ "name": "Object",
+ "supplementaryInformation": "TiledSpriteObject::TiledSprite",
+ "type": "object"
+ },
+ {
+ "description": "Behavior",
+ "name": "Behavior",
+ "supplementaryInformation": "WithThreeJS::PlaneProjectionFromTiled",
+ "type": "behavior"
+ }
+ ],
+ "objectGroups": []
+ },
+ {
+ "fullName": "Blend Mode",
+ "functionType": "StringExpression",
+ "name": "Blend",
+ "sentence": "",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::Standard",
+ "conditions": [],
+ "actions": [
+ {
+ "type": {
+ "value": "SetReturnString"
+ },
+ "parameters": [
+ "Object.Behavior::PropertyBlend()"
+ ]
+ }
+ ]
+ }
+ ],
+ "expressionType": {
+ "type": "string"
+ },
+ "parameters": [
+ {
+ "description": "Object",
+ "name": "Object",
+ "supplementaryInformation": "TiledSpriteObject::TiledSprite",
+ "type": "object"
+ },
+ {
+ "description": "Behavior",
+ "name": "Behavior",
+ "supplementaryInformation": "WithThreeJS::PlaneProjectionFromTiled",
+ "type": "behavior"
+ }
+ ],
+ "objectGroups": []
+ },
+ {
+ "fullName": "Is Anti-Aliasing",
+ "functionType": "Condition",
+ "name": "AntiAliasing",
+ "private": true,
+ "sentence": "Is Anti-Aliasing _PARAM0_",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::Standard",
+ "conditions": [
+ {
+ "type": {
+ "value": "WithThreeJS::PlaneProjectionFromTiled::PropertyAntiAliasing"
+ },
+ "parameters": [
+ "Object",
+ "Behavior"
+ ]
+ }
+ ],
+ "actions": [
+ {
+ "type": {
+ "value": "SetReturnBoolean"
+ },
+ "parameters": [
+ "True"
+ ]
+ }
+ ]
+ },
+ {
+ "type": "BuiltinCommonInstructions::Standard",
+ "conditions": [
+ {
+ "type": {
+ "inverted": true,
+ "value": "WithThreeJS::PlaneProjectionFromTiled::PropertyAntiAliasing"
+ },
+ "parameters": [
+ "Object",
+ "Behavior"
+ ]
+ }
+ ],
"actions": [
{
"type": {
- "value": "SetReturnString"
+ "value": "SetReturnBoolean"
},
"parameters": [
- "Object.Behavior::PropertyId()"
+ "False"
]
}
]
}
],
- "expressionType": {
- "type": "string"
- },
"parameters": [
{
"description": "Object",
@@ -10522,69 +11731,62 @@
"objectGroups": []
},
{
- "fullName": "Alpha Channel Test",
- "functionType": "Expression",
- "name": "AlphaTest",
- "sentence": "",
+ "fullName": "Is Rotate -90 Degrees",
+ "functionType": "Condition",
+ "name": "Rotate90",
+ "private": true,
+ "sentence": "Is Rotate -90 Degrees _PARAM0_",
"events": [
{
"type": "BuiltinCommonInstructions::Standard",
- "conditions": [],
+ "conditions": [
+ {
+ "type": {
+ "value": "WithThreeJS::PlaneProjectionFromTiled::PropertyRotate90"
+ },
+ "parameters": [
+ "Object",
+ "Behavior"
+ ]
+ }
+ ],
"actions": [
{
"type": {
- "value": "SetReturnNumber"
+ "value": "SetReturnBoolean"
},
"parameters": [
- "Object.Behavior::PropertyAlphaTest()"
+ "True"
]
}
]
- }
- ],
- "expressionType": {
- "type": "expression"
- },
- "parameters": [
- {
- "description": "Object",
- "name": "Object",
- "supplementaryInformation": "TiledSpriteObject::TiledSprite",
- "type": "object"
},
- {
- "description": "Behavior",
- "name": "Behavior",
- "supplementaryInformation": "WithThreeJS::PlaneProjectionFromTiled",
- "type": "behavior"
- }
- ],
- "objectGroups": []
- },
- {
- "fullName": "Blend Mode",
- "functionType": "StringExpression",
- "name": "Blend",
- "sentence": "",
- "events": [
{
"type": "BuiltinCommonInstructions::Standard",
- "conditions": [],
+ "conditions": [
+ {
+ "type": {
+ "inverted": true,
+ "value": "WithThreeJS::PlaneProjectionFromTiled::PropertyRotate90"
+ },
+ "parameters": [
+ "Object",
+ "Behavior"
+ ]
+ }
+ ],
"actions": [
{
"type": {
- "value": "SetReturnString"
+ "value": "SetReturnBoolean"
},
"parameters": [
- "Object.Behavior::PropertyBlend()"
+ "False"
]
}
]
}
],
- "expressionType": {
- "type": "string"
- },
"parameters": [
{
"description": "Object",
@@ -10602,18 +11804,18 @@
"objectGroups": []
},
{
- "fullName": "Is Anti-Aliasing",
+ "fullName": "Is Cast Shadow",
"functionType": "Condition",
- "name": "AntiAliasing",
+ "name": "CastShadow",
"private": true,
- "sentence": "Is Anti-Aliasing _PARAM0_",
+ "sentence": "Is Cast Shadow _PARAM0_",
"events": [
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
- "value": "WithThreeJS::PlaneProjectionFromTiled::PropertyAntiAliasing"
+ "value": "WithThreeJS::PlaneProjectionFromTiled::PropertyCastShadow"
},
"parameters": [
"Object",
@@ -10638,7 +11840,7 @@
{
"type": {
"inverted": true,
- "value": "WithThreeJS::PlaneProjectionFromTiled::PropertyAntiAliasing"
+ "value": "WithThreeJS::PlaneProjectionFromTiled::PropertyCastShadow"
},
"parameters": [
"Object",
@@ -10675,18 +11877,18 @@
"objectGroups": []
},
{
- "fullName": "Is Rotate -90 Degrees",
+ "fullName": "Is Receive Shadow",
"functionType": "Condition",
- "name": "Rotate90",
+ "name": "ReceiveShadow",
"private": true,
- "sentence": "Is Rotate -90 Degrees _PARAM0_",
+ "sentence": "Is Receive Shadow _PARAM0_",
"events": [
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
- "value": "WithThreeJS::PlaneProjectionFromTiled::PropertyRotate90"
+ "value": "WithThreeJS::PlaneProjectionFromTiled::PropertyReceiveShadow"
},
"parameters": [
"Object",
@@ -10711,7 +11913,7 @@
{
"type": {
"inverted": true,
- "value": "WithThreeJS::PlaneProjectionFromTiled::PropertyRotate90"
+ "value": "WithThreeJS::PlaneProjectionFromTiled::PropertyReceiveShadow"
},
"parameters": [
"Object",
@@ -11092,6 +12294,24 @@
"extraInformation": [],
"name": "Depth"
},
+ {
+ "value": "",
+ "type": "Boolean",
+ "label": "Cast Shadow",
+ "description": "If both \"Cast Shadow\" and \"Receive Shadow\" are enabled, striped patterns are likely to occur in the shadow.",
+ "group": "Shadow",
+ "extraInformation": [],
+ "name": "CastShadow"
+ },
+ {
+ "value": "",
+ "type": "Boolean",
+ "label": "Receive Shadow",
+ "description": "If both \"Cast Shadow\" and \"Receive Shadow\" are enabled, striped patterns are likely to occur in the shadow.",
+ "group": "Shadow",
+ "extraInformation": [],
+ "name": "ReceiveShadow"
+ },
{
"value": "",
"type": "String",
@@ -11174,8 +12394,8 @@
"const Width = objects[0].getWidth();",
"const Height = objects[0].getHeight();",
"const Depth = Behavior.Depth();",
- "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");//Behavior.ProjectionScale();",
- "const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");//Behavior.ViewMode();",
+ "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");",
+ "const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");",
"const AlphaTest = Behavior.AlphaTest();",
"const Transparent = AlphaTest !== 0;",
"const AntiAliasing = Behavior.AntiAliasing();",
@@ -11187,6 +12407,8 @@
"} else if (Behavior.Blend() == \"Multiply\") {",
" Blend = THREE.MultiplyBlending;",
"}",
+ "const CastShadow = Behavior.CastShadow();",
+ "const ReceiveShadow = Behavior.ReceiveShadow();",
"// const Opacity = 1.0;",
"//",
"//タイルの画像を取得",
@@ -11201,12 +12423,10 @@
"if (ViewMode == \"Top Down\") {",
" FRRepeatU = Width / TextureWidth;",
" FRRepeatV = Depth / TextureHeight;",
- "} else if (ViewMode == \"Side\") {",
- " FRRepeatU = Width / TextureWidth;",
- " FRRepeatV = Height / TextureHeight;",
"} else {",
+ " // Side",
" FRRepeatU = Width / TextureWidth;",
- " FRRepeatV = Depth / TextureHeight;",
+ " FRRepeatV = Height / TextureHeight;",
"}",
"const FRTextureId = \"_\" + Id + \"_\" + Resource.url + \"_FR\";",
"Behavior.SetFRTextureId(FRTextureId);",
@@ -11240,12 +12460,10 @@
" if (ViewMode == \"Top Down\") {",
" LRRepeatU = Height / TextureWidth;",
" LRRepeatV = Depth / TextureHeight;",
- " } else if (ViewMode == \"Side\") {",
+ " } else {",
+ " // Side",
" LRRepeatU = Depth / TextureWidth;",
" LRRepeatV = Height / TextureHeight;",
- " } else {",
- " LRRepeatU = Height / TextureWidth;",
- " LRRepeatV = Depth / TextureHeight;",
" }",
" const LRTextureId = \"_\" + Id + \"_\" + Resource.url + \"_LR\";",
" Behavior.SetLRTextureId(LRTextureId);",
@@ -11264,12 +12482,10 @@
" if (ViewMode == \"Top Down\") {",
" TBRepeatU = Width / TextureWidth;",
" TBRepeatV = Height / TextureHeight;",
- " } else if (ViewMode == \"Side\") {",
- " TBRepeatU = Width / TextureWidth;",
- " TBRepeatV = Depth / TextureHeight;",
" } else {",
+ " // Side",
" TBRepeatU = Width / TextureWidth;",
- " TBRepeatV = Height / TextureHeight;",
+ " TBRepeatV = Depth / TextureHeight;",
" }",
" const TBTextureId = \"_\" + Id + \"_\" + Resource.url + \"_TB\";",
" Behavior.SetTBTextureId(TBTextureId);",
@@ -11289,21 +12505,17 @@
"let Geometry;",
"if (ViewMode == \"Top Down\") {",
" Geometry = new THREE.BoxGeometry(Width * ProjectionScale, Depth * ProjectionScale, Height * ProjectionScale);",
- "} else if (ViewMode == \"Side\") {",
- " Geometry = new THREE.BoxGeometry(Width * ProjectionScale, Height * ProjectionScale, Depth * ProjectionScale);",
"} else {",
- " Geometry = new THREE.BoxGeometry(Width * ProjectionScale, Depth * ProjectionScale, Height * ProjectionScale);",
+ " // Side",
+ " Geometry = new THREE.BoxGeometry(Width * ProjectionScale, Height * ProjectionScale, Depth * ProjectionScale);",
"}",
"Geometry.computeBoundingBox();",
"const Obj = new THREE.Mesh(Geometry, Material);",
"Obj.name = Id;",
- "Obj.castShadow = true;",
- "Obj.receiveShadow = true;",
+ "Obj.castShadow = CastShadow;",
+ "Obj.receiveShadow = ReceiveShadow;",
"Obj.userData.Use3DProjectionBehavior = true;",
"Behavior.SetId(Id);",
- "if (ViewMode === \"Built-In 3D\") {",
- " Obj.scale.y = -1;",
- "}",
"Scene.add(Obj);",
"",
""
@@ -11361,7 +12573,7 @@
"const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");//Behavior.ViewMode();\r",
"const IsCube = Behavior.IsCube();\r",
"//\r",
- "const Obj = Scene.getObjectByName(Id);\r",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);\r",
"// Move & Rotate\r",
"const Angle = objects[0].angle;\r",
"if (ViewMode == \"Top Down\") {\r",
@@ -11457,7 +12669,7 @@
"}\r",
"const Scene = gdjs.__WithThreeJS.get(\"Scene\");\r",
"const Textures = gdjs.__WithThreeJS.get(\"Textures\");\r",
- "const Obj = Scene.getObjectByName(Id);\r",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);\r",
"if (!Obj) {\r",
" console.warn(\"3D Object not found.\");\r",
" return;\r",
@@ -11487,6 +12699,7 @@
"} else {\r",
" Obj.material.dispose();\r",
"}\r",
+ "gdjs.__WithThreeJS.get(\"ObjectList\").delete(Id);\r",
"Obj.removeFromParent();\r",
"\r",
""
@@ -11604,18 +12817,131 @@
"actions": [
{
"type": {
- "value": "SetReturnNumber"
+ "value": "SetReturnNumber"
+ },
+ "parameters": [
+ "Object.Behavior::PropertyAlphaTest()"
+ ]
+ }
+ ]
+ }
+ ],
+ "expressionType": {
+ "type": "expression"
+ },
+ "parameters": [
+ {
+ "description": "Object",
+ "name": "Object",
+ "supplementaryInformation": "TiledSpriteObject::TiledSprite",
+ "type": "object"
+ },
+ {
+ "description": "Behavior",
+ "name": "Behavior",
+ "supplementaryInformation": "WithThreeJS::BoxProjectionFromTiled",
+ "type": "behavior"
+ }
+ ],
+ "objectGroups": []
+ },
+ {
+ "fullName": "Blend Mode",
+ "functionType": "StringExpression",
+ "name": "Blend",
+ "sentence": "",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::Standard",
+ "conditions": [],
+ "actions": [
+ {
+ "type": {
+ "value": "SetReturnString"
+ },
+ "parameters": [
+ "Object.Behavior::PropertyBlend()"
+ ]
+ }
+ ]
+ }
+ ],
+ "expressionType": {
+ "type": "string"
+ },
+ "parameters": [
+ {
+ "description": "Object",
+ "name": "Object",
+ "supplementaryInformation": "TiledSpriteObject::TiledSprite",
+ "type": "object"
+ },
+ {
+ "description": "Behavior",
+ "name": "Behavior",
+ "supplementaryInformation": "WithThreeJS::BoxProjectionFromTiled",
+ "type": "behavior"
+ }
+ ],
+ "objectGroups": []
+ },
+ {
+ "fullName": "Is Anti-Aliasing",
+ "functionType": "Condition",
+ "name": "AntiAliasing",
+ "private": true,
+ "sentence": "Is Anti-Aliasing _PARAM0_",
+ "events": [
+ {
+ "type": "BuiltinCommonInstructions::Standard",
+ "conditions": [
+ {
+ "type": {
+ "value": "WithThreeJS::BoxProjectionFromTiled::PropertyAntiAliasing"
+ },
+ "parameters": [
+ "Object",
+ "Behavior"
+ ]
+ }
+ ],
+ "actions": [
+ {
+ "type": {
+ "value": "SetReturnBoolean"
+ },
+ "parameters": [
+ "True"
+ ]
+ }
+ ]
+ },
+ {
+ "type": "BuiltinCommonInstructions::Standard",
+ "conditions": [
+ {
+ "type": {
+ "inverted": true,
+ "value": "WithThreeJS::BoxProjectionFromTiled::PropertyAntiAliasing"
+ },
+ "parameters": [
+ "Object",
+ "Behavior"
+ ]
+ }
+ ],
+ "actions": [
+ {
+ "type": {
+ "value": "SetReturnBoolean"
},
"parameters": [
- "Object.Behavior::PropertyAlphaTest()"
+ "False"
]
}
]
}
],
- "expressionType": {
- "type": "expression"
- },
"parameters": [
{
"description": "Object",
@@ -11633,29 +12959,62 @@
"objectGroups": []
},
{
- "fullName": "Blend Mode",
- "functionType": "StringExpression",
- "name": "Blend",
- "sentence": "",
+ "fullName": "Is Cube",
+ "functionType": "Condition",
+ "name": "IsCube",
+ "private": true,
+ "sentence": "Is Cube _PARAM0_",
"events": [
{
"type": "BuiltinCommonInstructions::Standard",
- "conditions": [],
+ "conditions": [
+ {
+ "type": {
+ "value": "WithThreeJS::BoxProjectionFromTiled::PropertyIsCube"
+ },
+ "parameters": [
+ "Object",
+ "Behavior"
+ ]
+ }
+ ],
"actions": [
{
"type": {
- "value": "SetReturnString"
+ "value": "SetReturnBoolean"
},
"parameters": [
- "Object.Behavior::PropertyBlend()"
+ "True"
+ ]
+ }
+ ]
+ },
+ {
+ "type": "BuiltinCommonInstructions::Standard",
+ "conditions": [
+ {
+ "type": {
+ "inverted": true,
+ "value": "WithThreeJS::BoxProjectionFromTiled::PropertyIsCube"
+ },
+ "parameters": [
+ "Object",
+ "Behavior"
+ ]
+ }
+ ],
+ "actions": [
+ {
+ "type": {
+ "value": "SetReturnBoolean"
+ },
+ "parameters": [
+ "False"
]
}
]
}
],
- "expressionType": {
- "type": "string"
- },
"parameters": [
{
"description": "Object",
@@ -11673,18 +13032,18 @@
"objectGroups": []
},
{
- "fullName": "Is Anti-Aliasing",
+ "fullName": "Is Cast Shadow",
"functionType": "Condition",
- "name": "AntiAliasing",
+ "name": "CastShadow",
"private": true,
- "sentence": "Is Anti-Aliasing _PARAM0_",
+ "sentence": "Is Cast Shadow _PARAM0_",
"events": [
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
- "value": "WithThreeJS::BoxProjectionFromTiled::PropertyAntiAliasing"
+ "value": "WithThreeJS::BoxProjectionFromTiled::PropertyCastShadow"
},
"parameters": [
"Object",
@@ -11709,7 +13068,7 @@
{
"type": {
"inverted": true,
- "value": "WithThreeJS::BoxProjectionFromTiled::PropertyAntiAliasing"
+ "value": "WithThreeJS::BoxProjectionFromTiled::PropertyCastShadow"
},
"parameters": [
"Object",
@@ -11746,18 +13105,18 @@
"objectGroups": []
},
{
- "fullName": "Is Cube",
+ "fullName": "Is Receive Shadow",
"functionType": "Condition",
- "name": "IsCube",
+ "name": "ReceiveShadow",
"private": true,
- "sentence": "Is Cube _PARAM0_",
+ "sentence": "Is Receive Shadow _PARAM0_",
"events": [
{
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
- "value": "WithThreeJS::BoxProjectionFromTiled::PropertyIsCube"
+ "value": "WithThreeJS::BoxProjectionFromTiled::PropertyReceiveShadow"
},
"parameters": [
"Object",
@@ -11782,7 +13141,7 @@
{
"type": {
"inverted": true,
- "value": "WithThreeJS::BoxProjectionFromTiled::PropertyIsCube"
+ "value": "WithThreeJS::BoxProjectionFromTiled::PropertyReceiveShadow"
},
"parameters": [
"Object",
@@ -12610,6 +13969,24 @@
"Multiply"
],
"name": "Blend"
+ },
+ {
+ "value": "",
+ "type": "Boolean",
+ "label": "Cast Shadow",
+ "description": "If both \"Cast Shadow\" and \"Receive Shadow\" are enabled, striped patterns are likely to occur in the shadow.",
+ "group": "Shadow",
+ "extraInformation": [],
+ "name": "CastShadow"
+ },
+ {
+ "value": "",
+ "type": "Boolean",
+ "label": "Receive Shadow",
+ "description": "If both \"Cast Shadow\" and \"Receive Shadow\" are enabled, striped patterns are likely to occur in the shadow.",
+ "group": "Shadow",
+ "extraInformation": [],
+ "name": "ReceiveShadow"
}
],
"sharedPropertyDescriptors": []
@@ -12633,13 +14010,12 @@
" console.warn(\"!\");",
" return;",
"}",
- "// const Camera = gdjs.__WithThreeJS.get(\"Camera\");",
"const Behavior = objects[0].getBehavior(\"LinkedCamera\");",
"const Id = Behavior.Id();",
- "const Camera = gdjs.__WithThreeJS.has(\"BuiltIn3dCamera\") ? gdjs.__WithThreeJS.get(\"BuiltIn3dCamera\") : gdjs.__WithThreeJS.get(\"GetCamera\")(Id);",
+ "const Camera = gdjs.__WithThreeJS.get(\"GetCamera\")(Id);",
"const Fov = Behavior.Fov();",
- "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");//Behavior.ProjectionScale();",
- "const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");//Behavior.ViewMode();",
+ "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");",
+ "const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");",
"const LinkAngle = Behavior.LinkAngle();",
"const Hide = Behavior.Hide();",
"const X = objects[0].getCenterXInScene();",
@@ -12648,9 +14024,8 @@
"//",
"if (ViewMode == \"Top Down\") {",
" Camera.position.set(X * ProjectionScale, Z * ProjectionScale, Y * ProjectionScale);",
- "} else if (ViewMode == \"Side\") {",
- " Camera.position.set(X * ProjectionScale, -Y * ProjectionScale, Z * ProjectionScale);",
"} else {",
+ " // Side",
" Camera.position.set(X * ProjectionScale, -Y * ProjectionScale, Z * ProjectionScale);",
"}",
"//",
@@ -12658,10 +14033,9 @@
" const Angle = objects[0].angle;",
" if (ViewMode == \"Top Down\") {",
" Camera.rotation.set(gdjs.toRad(0), gdjs.toRad(Angle * -1 - 90), gdjs.toRad(0));",
- " } else if (ViewMode == \"Side\") {",
- " Camera.rotation.set(gdjs.toRad(-Angle), gdjs.toRad(-90), gdjs.toRad(0), \"YXZ\");",
" } else {",
- " Camera.rotation.set(gdjs.toRad(90), gdjs.toRad(Angle * -1 - 90), gdjs.toRad(0), \"XYZ\");",
+ " // Side",
+ " Camera.rotation.set(gdjs.toRad(-Angle), gdjs.toRad(-90), gdjs.toRad(0), \"YXZ\");",
" }",
"}",
"//",
@@ -13008,6 +14382,7 @@
" return;",
"}",
"const Scene = gdjs.__WithThreeJS.get(\"Scene\");",
+ "const Renderer = gdjs.__WithThreeJS.get(\"Renderer\");",
"//",
"const Behavior = objects[0].getBehavior(eventsFunctionContext.getBehaviorName(\"Behavior\"));",
"const Id = objects[0].name + objects[0].id;",
@@ -13019,6 +14394,13 @@
"const Decay = 2;",
"const SpotAngle = Behavior._getSpotAngle();",
"const SpotPenumbra = Behavior._getSpotPenumbra();",
+ "const CastShadow = Behavior._getCastShadow();",
+ "const ShadowMapSize = gdjs.__WithThreeJS.get(\"ShadowMapSizeStringToValue\")[Behavior._getShadowMapSize()];",
+ "const ShadowRange = Behavior._getShadowRange();",
+ "const ShadowBias = Behavior._getShadowDepthBias();",
+ "const ShadowNormalBias = Behavior._getShadowNormalBias();",
+ "const LightHelper = Behavior._getLightHelper();",
+ "const ShadowHelper = Behavior._getShadowHelper();",
"//",
"const RGB = Color.split(\";\");",
"let Light;",
@@ -13026,9 +14408,22 @@
" Intensity *= gdjs.__WithThreeJS.get(\"LightIntensityScale\");// Three.js r160",
" Light = new THREE.DirectionalLight(`rgb(${RGB[0]}, ${RGB[1]}, ${RGB[2]})`, Intensity);",
" const Target = new THREE.Group();",
- " Target.translateZ(-1);",
+ " Target.translateZ(-128);",
" Light.add(Target);",
" Light.target = Target;",
+ " //",
+ " Light.shadow.camera.top = ShadowRange / 2;",
+ " Light.shadow.camera.right = ShadowRange / 2;",
+ " Light.shadow.camera.bottom = -ShadowRange / 2;",
+ " Light.shadow.camera.left = -ShadowRange / 2;",
+ " Light.shadow.camera.near = 0.5;// default",
+ " Light.shadow.camera.far = ShadowRange;",
+ " //",
+ " if (LightHelper) {",
+ " const DirectionalLightHelper = new THREE.DirectionalLightHelper(Light, 128);",
+ " DirectionalLightHelper.name = Id + \"_DirectionalLightHelper\";",
+ " Scene.add(DirectionalLightHelper);",
+ " }",
"} else if (LightType == \"Spot Light\") {",
" Intensity *= gdjs.__WithThreeJS.get(\"LightIntensityCandela\");// Three.js r160",
" Light = new THREE.SpotLight(`rgb(${RGB[0]}, ${RGB[1]}, ${RGB[2]})`, Intensity, Distance, gdjs.toRad(SpotAngle), SpotPenumbra, Decay);",
@@ -13036,15 +14431,57 @@
" Target.translateZ(-1);",
" Light.add(Target);",
" Light.target = Target;",
+ " //",
+ " Light.shadow.camera.near = 0.5;// default",
+ " Light.shadow.camera.far = ShadowRange;",
+ " Light.shadow.focus = 1; // default",
+ " //",
+ " if (LightHelper) {",
+ " const SpotLightHelper = new THREE.SpotLightHelper(Light);",
+ " SpotLightHelper.name = Id + \"_SpotLightHelper\";",
+ " Scene.add(SpotLightHelper);",
+ " }",
"} else {",
" // Point",
" Intensity *= gdjs.__WithThreeJS.get(\"LightIntensityCandela\");// Three.js r160",
" Light = new THREE.PointLight(`rgb(${RGB[0]}, ${RGB[1]}, ${RGB[2]})`, Intensity, Distance, Decay);",
+ " //",
+ " Light.shadow.camera.near = 0.5;// default",
+ " Light.shadow.camera.far = ShadowRange;",
+ " //",
+ " if (LightHelper) {",
+ " const PointLightHelper = new THREE.PointLightHelper(Light, 16);",
+ " PointLightHelper.name = Id + \"_PointLightHelper\";",
+ " Scene.add(PointLightHelper);",
+ " }",
"}",
+ "Renderer.shadowMap.enabled = Renderer.shadowMap.enabled ? true : CastShadow;",
+ "Light.castShadow = CastShadow;",
+ "Light.shadow.mapSize.width = ShadowMapSize;",
+ "Light.shadow.mapSize.height = ShadowMapSize;",
+ "Light.shadow.bias = ShadowBias;",
+ "Light.shadow.normalBias = ShadowNormalBias;",
+ "Light.shadow.updateMatrices(Light);// 必須",
+ "Light.shadow.camera.updateProjectionMatrix();",
+ "//",
"Light.name = Id;",
"Behavior._setId(Id);",
"Light.userData.Use3DProjectionBehavior = true;",
"Scene.add(Light);",
+ "//",
+ "if (ShadowHelper && CastShadow) {",
+ " let CameraHelper;",
+ " if (LightType != \"Point Light\") {",
+ " CameraHelper = new THREE.CameraHelper(Light.shadow.camera);",
+ " Scene.add(CameraHelper);",
+ " } else {",
+ " const Geometry = new THREE.IcosahedronGeometry(Light.shadow.camera.far, 2); ",
+ " const Material = new THREE.MeshBasicMaterial( {color: 0xffaa00, wireframe: true} );",
+ " CameraHelper = new THREE.Mesh(Geometry, Material);",
+ " Light.add(CameraHelper);",
+ " }",
+ " CameraHelper.name = Id + \"_CameraHelper\";",
+ "}",
"",
""
],
@@ -13096,7 +14533,7 @@
"const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");\r",
"const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");\r",
"//\r",
- "const Obj = Scene.getObjectByName(Id);\r",
+ "const Obj = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);\r",
"// Move & Rotate\r",
"const Angle = objects[0].angle;\r",
"if (ViewMode == \"Top Down\") {\r",
@@ -13156,9 +14593,14 @@
" return;\r",
"}\r",
"const Scene = gdjs.__WithThreeJS.get(\"Scene\");\r",
- "const Obj = Scene.getObjectByName(Id);\r",
+ "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",
"Obj.removeFromParent();\r",
"\r",
""
@@ -13425,7 +14867,7 @@
"value": "45",
"type": "Number",
"label": "Spot Angle (0 to 180)",
- "description": "For Spot Lights.",
+ "description": "For Spot Lights. The narrower the angle, the better the shadow quality. If it is a multiple of 90, the shadow will not be cast correctly.",
"group": "",
"extraInformation": [],
"name": "SpotAngle"
@@ -13447,142 +14889,75 @@
"group": "",
"extraInformation": [],
"name": "Tilt"
- }
- ],
- "sharedPropertyDescriptors": []
- },
- {
- "description": "🚫 The recommendation is to use the \"Create 3D Model From Built-In 3D Model\" action instead of this behavior.\nThis behavior transfers the built-in 3D model to the WithThreeJS 3D Scene.\nThe original 2D object is deleted.\n⚠️ This may be deprecated in the future.",
- "fullName": "⚠️ 3D Model Transfer (Deprecated)",
- "name": "ModelTransfer",
- "objectType": "Scene3D::Model3DObject",
- "private": true,
- "eventsFunctions": [
+ },
{
- "fullName": "",
- "functionType": "Action",
- "name": "doStepPostEvents",
- "sentence": "",
- "events": [
- {
- "type": "BuiltinCommonInstructions::Standard",
- "conditions": [
- {
- "type": {
- "value": "WithThreeJS::ModelTransfer::PropertyFirstFrame"
- },
- "parameters": [
- "Object",
- "Behavior"
- ]
- }
- ],
- "actions": [
- {
- "type": {
- "value": "Delete"
- },
- "parameters": [
- "Object",
- ""
- ]
- },
- {
- "type": {
- "value": "WithThreeJS::ModelTransfer::SetPropertyFirstFrame"
- },
- "parameters": [
- "Object",
- "Behavior",
- "no"
- ]
- }
- ],
- "events": [
- {
- "type": "BuiltinCommonInstructions::JsCode",
- "inlineCode": [
- "if (!gdjs.__WithThreeJS.has(\"Renderer\")) {\r",
- " console.warn(\"!\");\r",
- " return;\r",
- "}\r",
- "const Scene = gdjs.__WithThreeJS.get(\"Scene\");\r",
- "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");\r",
- "const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");\r",
- "//\r",
- "const Obj2D = objects[0];\r",
- "const Id = Obj2D.name + Obj2D.id;\r",
- "const Obj = Obj2D.get3DRendererObject();\r",
- "const X = Obj2D.getCenterXInScene();\r",
- "const Y = Obj2D.getCenterYInScene();\r",
- "const Z = Obj2D.getZ();\r",
- "const Angle = Obj2D.angle;\r",
- "//\r",
- "Obj.name = Id;\r",
- "console.log(\"Transferred: \" + Id);\r",
- "//\r",
- "// 3D Model オブジェクトで正しいサイズが指定されていないと現状ずれる。\r",
- "if (ViewMode == \"Top Down\") {\r",
- " Obj.position.set(X * ProjectionScale, Z * ProjectionScale, Y * ProjectionScale);\r",
- " Obj.rotation.set(gdjs.toRad(0), gdjs.toRad(Angle * -1), gdjs.toRad(0));\r",
- " // Obj.rotation.set(gdjs.toRad(-90), gdjs.toRad(0), gdjs.toRad(Angle * -1));\r",
- "} else if (ViewMode == \"Side\") {\r",
- " Obj.position.set(X * ProjectionScale, -Y * ProjectionScale, Z * ProjectionScale);\r",
- " Obj.rotation.set(gdjs.toRad(0), gdjs.toRad(0), gdjs.toRad(Angle * -1));\r",
- " // Obj.rotation.set(gdjs.toRad(-90), gdjs.toRad(Angle), gdjs.toRad(0));\r",
- "} else {\r",
- " Obj.position.set(X * ProjectionScale, Y * ProjectionScale, Z * ProjectionScale);\r",
- " Obj.rotation.set(gdjs.toRad(-90), gdjs.toRad(Angle * -1), gdjs.toRad(0));\r",
- " // Obj.rotation.set(gdjs.toRad(0), gdjs.toRad(0), gdjs.toRad(Angle));\r",
- "}\r",
- "Scene.attach(Obj);\r",
- "\r",
- ""
- ],
- "parameterObjects": "Object",
- "useStrict": true,
- "eventsSheetExpanded": true
- }
- ]
- }
- ],
- "parameters": [
- {
- "description": "Object",
- "name": "Object",
- "supplementaryInformation": "Scene3D::Model3DObject",
- "type": "object"
- },
- {
- "description": "Behavior",
- "name": "Behavior",
- "supplementaryInformation": "WithThreeJS::ModelTransfer",
- "type": "behavior"
- }
+ "value": "",
+ "type": "Boolean",
+ "label": "Cast Shadow",
+ "description": "⚠️ This is expensive and requires tweaking to get shadows looking right.",
+ "group": "Shadow",
+ "extraInformation": [],
+ "name": "CastShadow"
+ },
+ {
+ "value": "512px",
+ "type": "Choice",
+ "label": "Shadow Map Size",
+ "description": "The larger the map, the better the shadow quality, but the greater the load.",
+ "group": "Shadow",
+ "extraInformation": [
+ "128px",
+ "256px",
+ "512px",
+ "1024px",
+ "2048px"
],
- "objectGroups": []
- }
- ],
- "propertyDescriptors": [
+ "name": "ShadowMapSize"
+ },
+ {
+ "value": "256",
+ "type": "Number",
+ "label": "Range to Draw Shadows",
+ "description": "The smaller the range, the better the shadow quality. For Point and Spot Lights, this value is valid only if the Distance is 0.",
+ "group": "Shadow",
+ "extraInformation": [],
+ "name": "ShadowRange"
+ },
+ {
+ "value": "0.002",
+ "type": "Number",
+ "label": "Shadow Depth Bias (Default: 0.002)",
+ "description": "It is mainly effective for filling gaps between objects and shadows. Reference value: [Directional Light: 0.002] [Point Light: 0.001] [Spot Light: 0.00001]",
+ "group": "Shadow Bias",
+ "extraInformation": [],
+ "name": "ShadowDepthBias"
+ },
+ {
+ "value": "2",
+ "type": "Number",
+ "label": "Shadow Normal Bias (Default: 2)",
+ "description": "It is mainly effective in reducing striped patterns. Reference value: [Directional Light: 2] [Point Light: 1] [Spot Light: 1]",
+ "group": "Shadow Bias",
+ "extraInformation": [],
+ "name": "ShadowNormalBias"
+ },
{
"value": "",
- "type": "String",
- "label": "",
+ "type": "Boolean",
+ "label": "Light Helper",
"description": "",
- "group": "",
+ "group": "Helper",
"extraInformation": [],
- "hidden": true,
- "name": "Id"
+ "name": "LightHelper"
},
{
- "value": "true",
+ "value": "",
"type": "Boolean",
- "label": "",
+ "label": "Shadow Range Helper",
"description": "",
- "group": "",
+ "group": "Helper",
"extraInformation": [],
- "hidden": true,
- "name": "FirstFrame"
+ "name": "ShadowHelper"
}
],
"sharedPropertyDescriptors": []
@@ -13592,7 +14967,7 @@
{
"defaultName": "My3DBox",
"description": "This 3D Box can have different textures on 6 faces.\n⚠️ This object is high load.",
- "fullName": "3D Box (Experimental)",
+ "fullName": "3D Box",
"is3D": true,
"name": "Box3D",
"eventsFunctions": [
@@ -13666,7 +15041,7 @@
"const Obj2D = objects[0];\r",
"if (!gdjs.__WithThreeJS.has(\"Renderer\") || !gdjs.__WithThreeJS.get(\"SceneIsReady\")) {\r",
" // 【!】PostEventなのにシーンイベントよりも早く処理が実行される問題がある。\r",
- " console.warn(\"! (3D Box Object)\");\r",
+ " // console.warn(\"! (3D Box Object)\");\r",
" return;\r",
"}\r",
"const Scene = gdjs.__WithThreeJS.get(\"Scene\");\r",
@@ -13683,8 +15058,8 @@
" const Width = Obj2D.getWidth();\r",
" const Height = Obj2D.getHeight();\r",
" const Depth = Obj2D._getDepth();\r",
- " const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");//Obj2D._getProjectionScale();\r",
- " const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");//Obj2D._getViewMode();\r",
+ " const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");\r",
+ " const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");\r",
" const AlphaTest = Obj2D._getAlphaTest();\r",
" const Transparent = AlphaTest !== 0;\r",
" const AntiAliasing = Obj2D._getAntiAliasing();\r",
@@ -13696,6 +15071,8 @@
" } else if (Obj2D._getBlend() == \"Multiply\") {\r",
" Blend = THREE.MultiplyBlending;\r",
" }\r",
+ " const CastShadow = Obj2D._getCastShadow();\r",
+ " const ReceiveShadow = Obj2D._getReceiveShadow();\r",
" //\r",
" const Items = Obj2D._instanceContainer._objects.items;\r",
" const ResourceNameTop = Items.Top.texture;\r",
@@ -13743,7 +15120,8 @@
" RepeatLeftV = Depth / ResourceLeft.height;\r",
" RepeatRightU = Height / ResourceRight.width;\r",
" RepeatRightV = Depth / ResourceRight.height;\r",
- " } else if (ViewMode == \"Side\") {\r",
+ " } else {\r",
+ " // Side\r",
" RepeatTopU = Width / ResourceTop.width;\r",
" RepeatTopV = Depth / ResourceTop.height;\r",
" RepeatBottomU = Width / ResourceBottom.width;\r",
@@ -13758,21 +15136,6 @@
" RepeatLeftV = Height / ResourceLeft.height;\r",
" RepeatRightU = Depth / ResourceRight.width;\r",
" RepeatRightV = Height / ResourceRight.height;\r",
- " } else {\r",
- " RepeatTopU = Width / ResourceTop.width;\r",
- " RepeatTopV = Height / ResourceTop.height;\r",
- " RepeatBottomU = Width / ResourceBottom.width;\r",
- " RepeatBottomV = Height / ResourceBottom.height;\r",
- " //\r",
- " RepeatFrontU = Width / ResourceFront.width;\r",
- " RepeatFrontV = Depth / ResourceFront.height;\r",
- " RepeatBackU = Width / ResourceBack.width;\r",
- " RepeatBackV = Depth / ResourceBack.height;\r",
- " //\r",
- " RepeatLeftU = Height / ResourceLeft.width;\r",
- " RepeatLeftV = Depth / ResourceLeft.height;\r",
- " RepeatRightU = Height / ResourceRight.width;\r",
- " RepeatRightV = Depth / ResourceRight.height;\r",
" }\r",
" // Offset\r",
" Obj2D._setTopOffsetV(1 - (RepeatTopV % 1));\r",
@@ -13883,21 +15246,17 @@
" let Geometry;\r",
" if (ViewMode == \"Top Down\") {\r",
" Geometry = new THREE.BoxGeometry(Width * ProjectionScale, Depth * ProjectionScale, Height * ProjectionScale);\r",
- " } else if (ViewMode == \"Side\") {\r",
- " Geometry = new THREE.BoxGeometry(Width * ProjectionScale, Height * ProjectionScale, Depth * ProjectionScale);\r",
" } else {\r",
- " Geometry = new THREE.BoxGeometry(Width * ProjectionScale, Depth * ProjectionScale, Height * ProjectionScale);\r",
+ " // Side\r",
+ " Geometry = new THREE.BoxGeometry(Width * ProjectionScale, Height * ProjectionScale, Depth * ProjectionScale);\r",
" }\r",
" Geometry.computeBoundingBox();\r",
" const Obj3D = new THREE.Mesh(Geometry, Material);\r",
" Obj3D.name = Id;\r",
- " Obj3D.castShadow = true;\r",
- " Obj3D.receiveShadow = true;\r",
+ " Obj3D.castShadow = CastShadow;\r",
+ " Obj3D.receiveShadow = ReceiveShadow;\r",
" Obj3D.userData.Use3DProjectionBehavior = true;\r",
" Obj2D._setId(Id);\r",
- " if (ViewMode === \"Built-In 3D\") {\r",
- " Obj3D.scale.y = -1;\r",
- " }\r",
" Scene.add(Obj3D);\r",
"}\r",
"// ====================================\r",
@@ -13907,10 +15266,10 @@
"const Z = Obj2D.zOrder;\r",
"const Angle = Obj2D.angle;\r",
"const Opacity = Obj2D.getOpacity() / 255;\r",
- "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");//Obj2D._getProjectionScale();\r",
- "const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");//Obj2D._getViewMode();\r",
+ "const ProjectionScale = gdjs.__WithThreeJS.get(\"ProjectionScale\");\r",
+ "const ViewMode = gdjs.__WithThreeJS.get(\"ViewMode\");\r",
"//\r",
- "const Obj3D = Scene.getObjectByName(Id);\r",
+ "const Obj3D = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);\r",
"if (!Obj3D) {\r",
" console.warn(\"3D Object not found.\");\r",
" return;\r",
@@ -13919,12 +15278,10 @@
"if (ViewMode == \"Top Down\") {\r",
" Obj3D.position.set(X * ProjectionScale, Z * ProjectionScale, Y * ProjectionScale);\r",
" Obj3D.rotation.set(gdjs.toRad(0), gdjs.toRad(Angle * -1), gdjs.toRad(0));\r",
- "} else if (ViewMode == \"Side\") {\r",
+ "} else {\r",
+ " // Side\r",
" Obj3D.position.set(X * ProjectionScale, -Y * ProjectionScale, Z * ProjectionScale);\r",
" Obj3D.rotation.set(gdjs.toRad(0), gdjs.toRad(0), gdjs.toRad(Angle * -1));\r",
- "} else {\r",
- " Obj3D.position.set(X * ProjectionScale, Y * ProjectionScale, Z * ProjectionScale);\r",
- " Obj3D.rotation.set(gdjs.toRad(-90), gdjs.toRad(Angle * -1), gdjs.toRad(0));\r",
"}\r",
"// Opacity\r",
"for (let i = 0; i < Obj3D.material.length; i++) {\r",
@@ -13954,22 +15311,6 @@
],
"objectGroups": []
},
- {
- "fullName": "",
- "functionType": "Action",
- "name": "onHotReloading",
- "sentence": "",
- "events": [],
- "parameters": [
- {
- "description": "Object",
- "name": "Object",
- "supplementaryInformation": "WithThreeJS::Box3D",
- "type": "object"
- }
- ],
- "objectGroups": []
- },
{
"fullName": "",
"functionType": "Action",
@@ -13992,7 +15333,7 @@
"const Scene = gdjs.__WithThreeJS.get(\"Scene\");\r",
"const Textures = gdjs.__WithThreeJS.get(\"Textures\");\r",
"const Id = Obj2D._getId();\r",
- "const Obj3D = Scene.getObjectByName(Id);\r",
+ "const Obj3D = gdjs.__WithThreeJS.get(\"SearchObject\")(Id);\r",
"if (!Obj3D) {\r",
" console.warn(\"3D Object not found.\");\r",
" return;\r",
@@ -14016,6 +15357,7 @@
"Textures.get(Obj2D._getTextureIdRight()).dispose();\r",
"Textures.delete(Obj2D._getTextureIdRight());\r",
"//\r",
+ "gdjs.__WithThreeJS.get(\"ObjectList\").delete(Id);\r",
"Obj3D.removeFromParent();\r",
"\r",
""
@@ -14281,6 +15623,24 @@
"extraInformation": [],
"hidden": true,
"name": "TextureIdRight"
+ },
+ {
+ "value": "",
+ "type": "Boolean",
+ "label": "Cast Shadow",
+ "description": "",
+ "group": "Shadow",
+ "extraInformation": [],
+ "name": "CastShadow"
+ },
+ {
+ "value": "",
+ "type": "Boolean",
+ "label": "Receive Shadow",
+ "description": "",
+ "group": "Shadow",
+ "extraInformation": [],
+ "name": "ReceiveShadow"
}
],
"objects": [