MCPcopy
hub / github.com/4ian/GDevelop / turnCameraTowardObject

Function turnCameraTowardObject

Extensions/3D/Scene3DTools.ts:161–189  ·  view source on GitHub ↗
(
        runtimeScene: RuntimeScene,
        object: gdjs.RuntimeObject | null,
        layerName: string,
        cameraIndex: integer,
        isStandingOnY: boolean
      )

Source from the content-addressed store, hash-verified

159 };
160
161 export const turnCameraTowardObject = (
162 runtimeScene: RuntimeScene,
163 object: gdjs.RuntimeObject | null,
164 layerName: string,
165 cameraIndex: integer,
166 isStandingOnY: boolean
167 ) => {
168 if (!object) return;
169
170 const layer = runtimeScene.getLayer(layerName);
171 const layerRenderer = layer.getRenderer();
172
173 const threeCamera = layerRenderer.getThreeCamera();
174 if (!threeCamera) return;
175
176 if (isStandingOnY) {
177 threeCamera.up.set(0, 1, 0);
178 } else {
179 threeCamera.up.set(0, 0, 1);
180 }
181 threeCamera.lookAt(
182 object.getCenterXInScene(),
183 -object.getCenterYInScene(),
184 //@ts-ignore
185 object.getZ ? object.getZ() : 0
186 );
187 // The layer angle takes over the 3D camera Z rotation.
188 layer.setCameraRotation(gdjs.toDegrees(-threeCamera.rotation.z));
189 };
190
191 export const turnCameraTowardPosition = (
192 runtimeScene: RuntimeScene,

Callers

nothing calls this directly

Calls 9

getCenterXInSceneMethod · 0.80
getCenterYInSceneMethod · 0.80
setMethod · 0.65
getZMethod · 0.65
getLayerMethod · 0.45
getRendererMethod · 0.45
getThreeCameraMethod · 0.45
lookAtMethod · 0.45
setCameraRotationMethod · 0.45

Tested by

no test coverage detected