diff --git a/extensions/community/RotateCameraObject3D.json b/extensions/community/RotateCameraObject3D.json new file mode 100644 index 00000000..f2b33a5e --- /dev/null +++ b/extensions/community/RotateCameraObject3D.json @@ -0,0 +1,652 @@ +{ + "author": "", + "category": "Third-party", + "extensionNamespace": "", + "fullName": "Rotate 3d сamera object with touch or mouse pointer", + "helpPath": "", + "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWNhbWVyYS1zd2l0Y2gtb3V0bGluZSIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiPjxwYXRoIGQ9Ik0yMCA0SDE2LjhMMTUgMkg5TDcuMiA0SDRDMi45IDQgMiA0LjkgMiA2VjE4QzIgMTkuMSAyLjkgMjAgNCAyMEgyMEMyMS4xIDIwIDIyIDE5LjEgMjIgMThWNkMyMiA0LjkgMjEuMSA0IDIwIDRNOS45IDRIMTQuMUwxNS45IDZIMjBWMThINFY2SDguMU0xNSAxMUg5VjguNUw1LjUgMTJMOSAxNS41VjEzSDE1VjE1LjVMMTguNSAxMkwxNSA4LjVWMTFaIiAvPjwvc3ZnPg==", + "name": "RotateCameraObject3D", + "previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/a916995012cd79add5c7ae33925506e1349b43f2da6dd23de3aae798655482ab_camera-switch-outline.svg", + "shortDescription": "This extension allows you to rotate the 3D camera object using touch or the mouse cursor.", + "version": "1.0.1", + "description": [ + "This extension allows you to rotate the 3D camera object using touch or the mouse cursor, you can make nice controls for mobile 3D projects or complement your existing one for variety.", + "- This is suitable for first and third person.", + "- This will work on all devices." + ], + "tags": [ + "3D", + "Camera", + "Object", + "Touch", + "Mouse", + "Pointer", + "Rotate" + ], + "authorIds": [ + "dt0tRnf2kHWJnjkrpnzTzNj9Yc63", + "mTJzVxFshpavwrdYd9oxy29QBE43" + ], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [ + { + "name": "__RotateCameraObject3D", + "type": "structure", + "children": [ + { + "name": "CameraX", + "type": "number", + "value": 0 + }, + { + "folded": true, + "name": "CameraY", + "type": "number", + "value": 0 + }, + { + "folded": true, + "name": "Index", + "type": "number", + "value": 0 + }, + { + "folded": true, + "name": "Move", + "type": "boolean", + "value": false + }, + { + "folded": true, + "name": "StartX", + "type": "number", + "value": 0 + }, + { + "folded": true, + "name": "StartY", + "type": "number", + "value": 0 + }, + { + "name": "TouchID", + "type": "number", + "value": 0 + } + ] + } + ], + "eventsFunctions": [ + { + "fullName": "", + "functionType": "Action", + "name": "onSceneLoaded", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Multiplayer::DisableVariableSynchronization" + }, + "parameters": [ + "", + "__RotateCameraObject3D" + ] + } + ] + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "Rotate 3d сamera object with touch or mouse pointer.", + "fullName": "Rotate 3d сamera object with touch or mouse", + "functionType": "Action", + "name": "RotateCameraObjectWithTouchOrMouse", + "sentence": "Rotate 3d сamera object _PARAM1_ with touch or mouse on layer _PARAM2_ and part of screen _PARAM3_ with smoothing _PARAM4_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BuiltinCommonInstructions::Once" + }, + "parameters": [] + } + ], + "actions": [], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.CameraX", + "=", + "CameraObject.Angle()*max(1,Smoothing)" + ] + }, + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.CameraY", + "=", + "CameraObject.Object3D::RotationY()" + ] + } + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "CompareArgumentAsString" + }, + "parameters": [ + "\"PartOfScreen\"", + "=", + "\"Left half\"" + ] + } + ], + "actions": [], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "HasAnyTouchOrMouseStarted" + }, + "parameters": [ + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.Іndex", + "=", + "0" + ] + } + ], + "events": [ + { + "type": "BuiltinCommonInstructions::Repeat", + "repeatExpression": "StartedTouchOrMouseCount()", + "conditions": [], + "actions": [], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BuiltinCommonInstructions::CompareNumbers" + }, + "parameters": [ + "TouchX(StartedTouchOrMouseId(Variable(__RotateCameraObject3D.Index)), TouchOrMouseLayer, 0)", + "<=", + "SceneWindowWidth()/2" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.TouchID", + "=", + "StartedTouchOrMouseId(__RotateCameraObject3D.Index)" + ] + }, + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.StartX", + "=", + "TouchX(__RotateCameraObject3D.TouchID, TouchOrMouseLayer, 0)-__RotateCameraObject3D.CameraX" + ] + }, + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.StartY", + "=", + "TouchY(__RotateCameraObject3D.TouchID, TouchOrMouseLayer, 0)-__RotateCameraObject3D.CameraY" + ] + }, + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "__RotateCameraObject3D.Move", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.Іndex", + "+", + "1" + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "CompareArgumentAsString" + }, + "parameters": [ + "\"PartOfScreen\"", + "=", + "\"Right half\"" + ] + } + ], + "actions": [], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "HasAnyTouchOrMouseStarted" + }, + "parameters": [ + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.Іndex", + "=", + "0" + ] + } + ], + "events": [ + { + "type": "BuiltinCommonInstructions::Repeat", + "repeatExpression": "StartedTouchOrMouseCount()", + "conditions": [], + "actions": [], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BuiltinCommonInstructions::CompareNumbers" + }, + "parameters": [ + "TouchX(StartedTouchOrMouseId(__RotateCameraObject3D.Index), TouchOrMouseLayer, 0)", + ">=", + "SceneWindowWidth()/2" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.TouchID", + "=", + "StartedTouchOrMouseId(__RotateCameraObject3D.Index)" + ] + }, + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.StartX", + "=", + "TouchX(__RotateCameraObject3D.TouchID, TouchOrMouseLayer, 0)-__RotateCameraObject3D.CameraX" + ] + }, + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.StartY", + "=", + "TouchY(__RotateCameraObject3D.TouchID, TouchOrMouseLayer, 0)-__RotateCameraObject3D.CameraY" + ] + }, + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "__RotateCameraObject3D.Move", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.Іndex", + "+", + "1" + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "CompareArgumentAsString" + }, + "parameters": [ + "\"PartOfScreen\"", + "=", + "\"Whole screen\"" + ] + } + ], + "actions": [], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "HasAnyTouchOrMouseStarted" + }, + "parameters": [ + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.Іndex", + "=", + "0" + ] + } + ], + "events": [ + { + "type": "BuiltinCommonInstructions::Repeat", + "repeatExpression": "StartedTouchOrMouseCount()", + "conditions": [], + "actions": [], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.TouchID", + "=", + "StartedTouchOrMouseId(__RotateCameraObject3D.Index)" + ] + }, + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.StartX", + "=", + "TouchX(__RotateCameraObject3D.TouchID, TouchOrMouseLayer, 0)-__RotateCameraObject3D.CameraX" + ] + }, + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.StartY", + "=", + "TouchY(__RotateCameraObject3D.TouchID, TouchOrMouseLayer, 0)-__RotateCameraObject3D.CameraY" + ] + }, + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "__RotateCameraObject3D.Move", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.Іndex", + "+", + "1" + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "__RotateCameraObject3D.Move", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.CameraX", + "=", + "TouchX(__RotateCameraObject3D.TouchID, TouchOrMouseLayer, 0)-__RotateCameraObject3D.StartX" + ] + }, + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.CameraY", + "=", + "TouchY(__RotateCameraObject3D.TouchID, TouchOrMouseLayer, 0)-__RotateCameraObject3D.StartY" + ] + } + ], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetAngle" + }, + "parameters": [ + "CameraObject", + "=", + "__RotateCameraObject3D.CameraX/max(1,Smoothing)" + ] + }, + { + "type": { + "value": "Scene3D::Base3DBehavior::SetRotationY" + }, + "parameters": [ + "CameraObject", + "Object3D", + "=", + "__RotateCameraObject3D.CameraY/max(1,Smoothing)" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "HasTouchEnded" + }, + "parameters": [ + "", + "__RotateCameraObject3D.TouchID" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "__RotateCameraObject3D.TouchID", + "=", + "0" + ] + }, + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "__RotateCameraObject3D.Move", + "False", + "" + ] + } + ] + } + ] + } + ], + "parameters": [ + { + "description": "The object from which the camera is looking (3D box)", + "name": "CameraObject", + "supplementaryInformation": "Scene3D::Cube3DObject", + "type": "objectList" + }, + { + "description": "2D layer on which the touch or mouse will move", + "name": "TouchOrMouseLayer", + "type": "layer" + }, + { + "description": "Part of the screen", + "name": "PartOfScreen", + "supplementaryInformation": "[\"Left half\",\"Right half\",\"Whole screen\"]", + "type": "stringWithSelector" + }, + { + "description": "Smoothing camera rotation (default and minimum 1)", + "name": "Smoothing", + "type": "expression" + } + ], + "objectGroups": [] + } + ], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [] +} \ No newline at end of file