2 * Copyright(c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.Runtime.InteropServices;
20 using System.ComponentModel;
21 using System.Diagnostics.CodeAnalysis;
23 using Tizen.NUI.Binding;
24 using Tizen.NUI.BaseComponents;
26 namespace Tizen.NUI.Scene3D
29 /// SceneView is a Class to show multiple 3D objects in a single 2D screen.
30 /// Each SceneView has its own 3D space, and 3D objects added to SceneView are positioned in the space.
31 /// SceneView uses left-handed coordinate system same as NUI. X as right, Y as down, and Z as forward.
33 /// SceneView has internal root container to control inner rendering process like depth test.
34 /// When a View is added to the SceneView with <see cref="View.Add(View)"/> method, it is actually added on the root container.
35 /// Therefore, the added Views exist in the sub tree of SceneView, but are not direct children.
36 /// The sub tree of Views will be rendered with the SceneView's own Camera.
38 /// SceneView has one built-in camera by default.
39 /// The default Camera is not removed by using <see cref="RemoveCamera(Camera)"/> method.
40 /// <see cref="GetCamera(uint)"/> method with index "0" returns the default camera,
41 /// and the minimum value returned by <see cref="GetCameraCount()"/> method is 1.
43 /// SceneView also provides multiple Camera and one of them can be used to render multiple objects.
44 /// <see cref="AddCamera(Camera)"/>, <see cref="RemoveCamera(Camera)"/>, <see cref="GetCamera(uint)"/>,
45 /// and <see cref="SelectCamera(uint)"/> are methods to manage Cameras of the SceneView.
46 /// User can place multiple cameras in a scene to display the entire scene or to display individual objects.
47 /// User can use the <see cref="SelectCamera(uint)"/> method to select the currently required camera.
49 /// When the SceneView's size changes, some camera properties that depend on its size may also change.
50 /// The changing properties are as follows: AspectRatio, LeftPlaneDistance, RightPlaneDistance, TopPlaneDistance, and BottomPlaneDistance.
51 /// The Camera's FieldOfView is vertical fov. The horizontal fov is updated internally according to the SceneView size.
53 /// The <see cref="SetImageBasedLightSource(string, string, float)"/> method sets the same IBL to all Model objects added to the SceneView.
54 /// For the IBL, two cube map textures(diffuse and specular) are required.
55 /// SceneView supports 4 types layout for Cube Map: Vertical/Horizontal Cross layouts, and Vertical/Horizontal Array layouts.
56 /// And also, ktx format with cube map is supported.
57 /// If a model already has an IBL, it is batch overridden with the IBL of the SceneView.
58 /// If the SceneView has IBL, the IBL of newly added models is also overridden.
60 /// The IBL textures start to be loaded asynchronously when <see cref="SetImageBasedLightSource(string, string, float)"/> method is called.
61 /// ResourcesLoaded signal notifies that the loading of the IBL resources have been completed.
63 /// If FBO is used, the rendering result of SceneView is drawn on the FBO and it is mapped on the plane of the SceneView.
64 /// It could decreases performance slightly, but it is useful to show SceneView according to the rendering order with other Views.
66 /// And since SceneView is a View, it can be placed together with other 2D UI components in the NUI window.
68 /// <since_tizen> 10 </since_tizen>
69 public class SceneView : View
71 private bool inCameraTransition = false;
72 private Animation cameraTransition;
73 private string skyboxUrl;
75 internal SceneView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
80 /// Create an initialized SceneView.
82 /// <since_tizen> 10 </since_tizen>
83 public SceneView() : this(Interop.SceneView.SceneNew(), true)
85 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
91 /// <param name="sceneView">The source object.</param>
92 /// <since_tizen> 10 </since_tizen>
93 public SceneView(SceneView sceneView) : this(Interop.SceneView.NewScene(SceneView.getCPtr(sceneView)), true)
95 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
99 /// Assignment operator.
101 /// <param name="sceneView">Handle to an object.</param>
102 /// <returns>Reference to this.</returns>
103 internal SceneView Assign(SceneView sceneView)
105 SceneView ret = new SceneView(Interop.SceneView.SceneAssign(SwigCPtr, SceneView.getCPtr(sceneView)), false);
106 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
111 /// An event emitted when Camera Transition is finished.
113 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
114 [EditorBrowsable(EditorBrowsableState.Never)]
115 public event EventHandler CameraTransitionFinished;
118 /// Set/Get the ImageBasedLight ScaleFactor.
119 /// Scale factor controls light source intensity in [0.0f, 1.0f]
121 /// <since_tizen> 10 </since_tizen>
122 public float ImageBasedLightScaleFactor
126 SetImageBasedLightScaleFactor(value);
130 return GetImageBasedLightScaleFactor();
135 /// Set/Get the UseFramebuffer.
136 /// If this property is true, rendering result of SceneView is drawn on FBO and it is mapping on this SceneView plane.
137 /// If this property is false, each item in SceneView is rendered on window directly.
138 /// Default is false.
141 /// If UseFramebuffer is true, it could decrease performance but entire rendering order is satisfied.
142 /// If UseFramebuffer is false, the performance becomes better but SceneView is rendered on the top of the other 2D components regardless tree order.
144 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
145 [EditorBrowsable(EditorBrowsableState.Never)]
146 public bool UseFramebuffer
150 SetUseFramebuffer(value);
154 return IsUsingFramebuffer();
159 /// Set/Get the Framebuffer's MultiSamplingLevel.
160 /// Only has effects if UseFramebuffer is true, and Framebuffer MultiSampling is supported.
164 /// Getter didn't consider Framebuffer MultiSampling is supported or not.
166 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
167 [EditorBrowsable(EditorBrowsableState.Never)]
168 public uint FramebufferMultiSamplingLevel
172 SetFramebufferMultiSamplingLevel(value);
176 return GetFramebufferMultiSamplingLevel();
181 /// Set/Get SkyboxUrl.
182 /// If SkyboxUrl is set, the cube map image is loaded and skybox is attached on scene.
183 /// Skybox texture is asynchronously loaded. When loading is finished, ResourcesLoaded is emitted.
185 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
186 [EditorBrowsable(EditorBrowsableState.Never)]
187 public string SkyboxUrl
200 /// Set/Get Skybox intensity.
201 /// The skybox intensity is multiplied to the color of skybox texture.
202 /// Default value is 1.0f.
204 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
205 [EditorBrowsable(EditorBrowsableState.Never)]
206 public float SkyboxIntensity
210 SetSkyboxIntensity(value);
214 return GetSkyboxIntensity();
219 /// Set/Get angle of orientation of the skybox.
220 /// If orientation is set, the skybox will be rotate by the Radian orientation along YAxis.
221 /// Default value is 0.0f.
223 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
224 [EditorBrowsable(EditorBrowsableState.Never)]
225 public Rotation SkyboxOrientation
229 SetSkyboxOrientation(value);
233 return GetSkyboxOrientation();
238 /// Adds a Camera to the SceneView at the end of the camera list of SceneView.
239 /// The Camera can be used as a selected camera to render the scene by using <see cref="SelectCamera(uint)"/> or <see cref="SelectCamera(string)"/>
241 /// <param name="camera">Camera added on this SceneView.</param>
243 /// Some properties of the Camera will be change depending on the Size of this SceneView.
244 /// Those properties are as follows:
245 /// AspectRatio, LeftPlaneDistance, RightPlaneDistance, TopPlaneDistance, and BottomPlaneDistance.
247 /// The FieldOfView of Camera is for vertical fov.
248 /// When the size of the SceneView is changed, the vertical fov is maintained
249 /// and the horizontal fov is automatically calculated according to the SceneView's AspectRatio.
251 /// <since_tizen> 10 </since_tizen>
252 public void AddCamera(Camera camera)
256 Interop.SceneView.AddCamera(SwigCPtr, camera.SwigCPtr);
257 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262 /// Removes a Camera from this SceneView.
263 /// If removed Camera is selected Camera,
264 /// first camera in the list becomes the selected Camera.
266 /// <param name="camera"> camera Camera to be removed from this Camera.</param>
268 /// When Camera.Dispose() is called, the NUI object is disposed, but camera information is maintained internally.
269 /// Therefore, even if Camera.Dispose() is called, RemoveCamera() or RemoveCamera() methods can be used.
270 /// If RemoveCamera() is called too, all information is deleted together.
272 /// <since_tizen> 10 </since_tizen>
273 public void RemoveCamera(Camera camera)
277 Interop.SceneView.RemoveCamera(SwigCPtr, camera.SwigCPtr);
278 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
283 /// Retrieves the number of cameras.
285 /// <returns>The number of Cameras.</returns>
286 /// <since_tizen> 10 </since_tizen>
287 public uint GetCameraCount()
289 uint count = Interop.SceneView.GetCameraCount(SwigCPtr);
290 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
295 /// Retrieves a Camera of the index.
297 /// <param name="index"> Index of Camera to be retrieved.</param>
298 /// <returns>Camera of the index.</returns>
299 /// <since_tizen> 10 </since_tizen>
300 public Camera GetCamera(uint index)
302 global::System.IntPtr cPtr = Interop.SceneView.GetCamera(SwigCPtr, index);
303 Camera camera = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Camera;
306 // Register new camera into Registry.
307 camera = new Camera(cPtr, true);
311 // We found matched NUI camera. Reduce cPtr reference count.
312 HandleRef handle = new HandleRef(this, cPtr);
313 Interop.Camera.DeleteCameraProperty(handle);
314 handle = new HandleRef(null, IntPtr.Zero);
316 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
321 /// Retrieves a Camera of the input name.
323 /// <param name="name"> string keyword of Camera to be retrieved.</param>
324 /// <returns>Camera that has the name as a View.Name property</returns>
325 /// <since_tizen> 10 </since_tizen>
326 public Camera GetCamera(string name)
328 global::System.IntPtr cPtr = Interop.SceneView.GetCamera(SwigCPtr, name);
329 Camera camera = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Camera;
332 // Register new camera into Registry.
333 camera = new Camera(cPtr, true);
337 // We found matched NUI camera. Reduce cPtr reference count.
338 HandleRef handle = new HandleRef(this, cPtr);
339 Interop.Camera.DeleteCameraProperty(handle);
340 handle = new HandleRef(null, IntPtr.Zero);
342 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
347 /// Makes SceneView use a Camera of index as a selected camera.
349 /// <param name="index"> Index of Camera to be used as a selected camera.</param>
350 /// <since_tizen> 10 </since_tizen>
351 public void SelectCamera(uint index)
353 if (inCameraTransition)
357 Interop.SceneView.SelectCamera(SwigCPtr, index);
358 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
362 /// Makes SceneView use a Camera of a name as a selected camera.
364 /// <param name="name"> string keyword of Camera to be used as a selected camera.</param>
365 /// <since_tizen> 10 </since_tizen>
366 public void SelectCamera(string name)
368 if (inCameraTransition)
372 Interop.SceneView.SelectCamera(SwigCPtr, name);
373 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
377 /// Starts camera transition from currently selected camera to a camera of index.
378 /// Camera Position, Orientation and FieldOfView are smoothly animated.
381 /// The selected camera is switched to the Camera of the index when the transition is started.
382 /// During camera transition, Selected Camera should not be changed by using SelectCamera() or CameraTransition() method.
383 /// During camera transition, Camera properties of Selected Camera should not be changed.
385 /// <param name="index"> Index of destination Camera of Camera transition.</param>
386 /// <param name="durationMilliSeconds">The duration in milliseconds.</param>
387 /// <param name="alphaFunction">The alpha function to apply.</param>
388 /// <since_tizen> 10 </since_tizen>
389 [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "The ownership of camera object is not owned by this class.")]
390 public void CameraTransition(uint index, int durationMilliSeconds, AlphaFunction alphaFunction = null)
392 if (inCameraTransition || GetSelectedCamera() == GetCamera(index))
396 Camera source = GetSelectedCamera();
398 Camera destination = GetSelectedCamera();
399 CameraTransition(source, destination, durationMilliSeconds, alphaFunction);
403 /// Starts camera transition from currently selected camera to a camera of input name.
404 /// Camera Position, Orientation and FieldOfView are smoothly animated.
407 /// The selected camera is switched to the Camera of the input name when the transition is started.
408 /// During camera transition, Selected Camera should not be changed by using SelectCamera() or CameraTransition() method.
409 /// During camera transition, Camera properties of Selected Camera should not be changed.
411 /// <param name="name"> string keyword of destination Camera of Camera transition.</param>
412 /// <param name="durationMilliSeconds">The duration in milliseconds.</param>
413 /// <param name="alphaFunction">The alpha function to apply.</param>
414 /// <since_tizen> 10 </since_tizen>
415 [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "The ownership of camera object is not owned by this class.")]
416 public void CameraTransition(string name, int durationMilliSeconds, AlphaFunction alphaFunction = null)
418 if (inCameraTransition || GetSelectedCamera() == GetCamera(name))
422 Camera source = GetSelectedCamera();
424 Camera destination = GetSelectedCamera();
425 CameraTransition(source, destination, durationMilliSeconds, alphaFunction);
429 /// Retrieves selected Camera.
431 /// <returns> Camera currently used in SceneView as a selected Camera.</returns>
432 /// <since_tizen> 10 </since_tizen>
433 public Camera GetSelectedCamera()
435 global::System.IntPtr cPtr = Interop.SceneView.GetSelectedCamera(SwigCPtr);
436 Camera camera = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Camera;
439 // Register new camera into Registry.
440 camera = new Camera(cPtr, true);
444 // We found matched NUI camera. Reduce cPtr reference count.
445 HandleRef handle = new HandleRef(this, cPtr);
446 Interop.Camera.DeleteCameraProperty(handle);
447 handle = new HandleRef(null, IntPtr.Zero);
449 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
454 /// Changes Image Based Light as the input textures.
456 /// <param name="diffuseUrl">The path of Cube map image that can be used as a diffuse IBL source.</param>
457 /// <param name="specularUrl">The path of Cube map image that can be used as a specular IBL source.</param>
458 /// <param name="scaleFactor">Scale factor that controls light source intensity in [0.0f, 1.0f]. Default value is 1.0f.</param>
460 /// http://tizen.org/privilege/mediastorage for local files in media storage.
461 /// http://tizen.org/privilege/externalstorage for local files in external storage.
463 /// <since_tizen> 10 </since_tizen>
464 public void SetImageBasedLightSource(string diffuseUrl, string specularUrl, float scaleFactor = 1.0f)
466 Interop.SceneView.SetImageBasedLightSource(SwigCPtr, diffuseUrl, specularUrl, scaleFactor);
467 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
470 internal void SetUseFramebuffer(bool useFramebuffer)
472 Interop.SceneView.UseFramebuffer(SwigCPtr, useFramebuffer);
473 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
476 internal bool IsUsingFramebuffer()
478 bool result = Interop.SceneView.IsUsingFramebuffer(SwigCPtr);
479 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
483 internal void SetFramebufferMultiSamplingLevel(uint multiSamplingLevel)
485 Interop.SceneView.SetFramebufferMultiSamplingLevel(SwigCPtr, multiSamplingLevel);
486 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
489 internal uint GetFramebufferMultiSamplingLevel()
491 uint result = Interop.SceneView.GetFramebufferMultiSamplingLevel(SwigCPtr);
492 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
497 /// Set the ImageBasedLight ScaleFactor.
499 /// <param name="scaleFactor">Scale factor that controls light source intensity in [0.0f, 1.0f].</param>
500 private void SetImageBasedLightScaleFactor(float scaleFactor)
502 Interop.SceneView.SetImageBasedLightScaleFactor(SwigCPtr, scaleFactor);
503 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
507 /// Get the ImageBasedLight ScaleFactor.
509 /// <returns>ImageBasedLightScaleFactor that controls light source intensity.</returns>
510 private float GetImageBasedLightScaleFactor()
512 float scaleFactor = Interop.SceneView.GetImageBasedLightScaleFactor(SwigCPtr);
513 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
518 /// Set the Skybox from cube map image.
519 /// Skybox texture is asynchronously loaded. When loading is finished, ResourcesLoaded is emitted.
521 /// <param name="skyboxUrl">Cube map image url for skybox.</param>
522 private void SetSkybox(string skyboxUrl)
524 this.skyboxUrl = skyboxUrl;
525 Interop.SceneView.SetSkybox(SwigCPtr, skyboxUrl);
526 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
530 /// Sets Skybox intensity.
531 /// The skybox intensity is multiplied to the color of skybox texture.
532 /// Default value is 1.0f.
534 /// <param name="intensity">Intensity value to be multiplied to the cube map color.</param>
535 private void SetSkyboxIntensity(float intensity)
537 Interop.SceneView.SetSkyboxIntensity(SwigCPtr, intensity);
538 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
542 /// Gets Skybox intensity.
543 /// Default value is 1.0f.
545 /// <returns>skybox intensity.</returns>
546 private float GetSkyboxIntensity()
548 float intensity = Interop.SceneView.GetSkyboxIntensity(SwigCPtr);
549 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
554 /// Sets orientation of the skybox.
556 /// <param name="orientation">Rotation angle of the skybox along YAxis.</param>
557 private void SetSkyboxOrientation(Rotation orientation)
559 Interop.SceneView.SetSkyboxOrientation(SwigCPtr, Rotation.getCPtr(orientation));
560 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
564 /// Gets Skybox orientation.
566 /// <returns>skybox orientation.</returns>
567 private Rotation GetSkyboxOrientation()
569 global::System.IntPtr cPtr = Interop.SceneView.GetSkyboxOrientation(SwigCPtr);
570 Rotation ret = (cPtr == global::System.IntPtr.Zero) ? null : new Rotation(cPtr, true);
571 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
575 private void CameraTransition(Camera sourceCamera, Camera destinationCamera, int durationMilliSeconds, AlphaFunction alphaFunction)
577 inCameraTransition = true;
579 Position sourcePosition = sourceCamera.Position;
580 Rotation sourceOrientation = sourceCamera.Orientation;
582 Position destinationPosition = destinationCamera.Position;
583 Rotation destinationOrientation = destinationCamera.Orientation;
585 cameraTransition = new Animation(durationMilliSeconds);
587 KeyFrames positionKeyFrames = new KeyFrames();
588 positionKeyFrames.Add(0.0f, sourcePosition);
589 positionKeyFrames.Add(1.0f, destinationPosition);
591 KeyFrames orientationKeyFrames = new KeyFrames();
592 orientationKeyFrames.Add(0.0f, sourceOrientation);
593 orientationKeyFrames.Add(1.0f, destinationOrientation);
595 cameraTransition.AnimateBetween(destinationCamera, "Position", positionKeyFrames, Animation.Interpolation.Linear, alphaFunction);
596 cameraTransition.AnimateBetween(destinationCamera, "Orientation", orientationKeyFrames, Animation.Interpolation.Linear, alphaFunction);
598 if (destinationCamera.ProjectionMode == Camera.ProjectionModeType.Perspective)
600 Radian sourceFieldOfView = sourceCamera.FieldOfView;
601 Radian destinationFieldOfView = destinationCamera.FieldOfView;
603 // If ProjectionDirection is not equal, match the value.
604 if (sourceCamera.ProjectionDirection != destinationCamera.ProjectionDirection)
606 float aspect = destinationCamera.AspectRatio;
607 if (destinationCamera.ProjectionDirection == Camera.ProjectionDirectionType.Vertical)
609 Camera.ConvertFovFromHorizontalToVertical(aspect, ref sourceFieldOfView);
613 Camera.ConvertFovFromVerticalToHorizontal(aspect, ref sourceFieldOfView);
617 KeyFrames fieldOfViewKeyFrames = new KeyFrames();
618 fieldOfViewKeyFrames.Add(0.0f, sourceFieldOfView.ConvertToFloat());
619 fieldOfViewKeyFrames.Add(1.0f, destinationFieldOfView.ConvertToFloat());
620 cameraTransition.AnimateBetween(destinationCamera, "FieldOfView", fieldOfViewKeyFrames, Animation.Interpolation.Linear, alphaFunction);
622 sourceFieldOfView.Dispose();
623 destinationFieldOfView.Dispose();
624 fieldOfViewKeyFrames.Dispose();
628 float sourceOrthographicSize = sourceCamera.OrthographicSize;
629 float destinationOrthographicSize = destinationCamera.OrthographicSize;
631 // If ProjectionDirection is not equal, match the value.
632 if (sourceCamera.ProjectionDirection != destinationCamera.ProjectionDirection)
634 float aspect = destinationCamera.AspectRatio;
635 if (destinationCamera.ProjectionDirection == Camera.ProjectionDirectionType.Vertical)
637 sourceOrthographicSize = sourceOrthographicSize / aspect;
641 sourceOrthographicSize = sourceOrthographicSize * aspect;
645 KeyFrames orthographicSizeKeyFrames = new KeyFrames();
646 orthographicSizeKeyFrames.Add(0.0f, sourceOrthographicSize);
647 orthographicSizeKeyFrames.Add(1.0f, destinationOrthographicSize);
648 cameraTransition.AnimateBetween(destinationCamera, "OrthographicSize", orthographicSizeKeyFrames, Animation.Interpolation.Linear, alphaFunction);
650 orthographicSizeKeyFrames.Dispose();
653 float destinationNearPlaneDistance = destinationCamera.NearPlaneDistance;
654 float destinationFarPlaneDistance = destinationCamera.FarPlaneDistance;
655 destinationCamera.NearPlaneDistance = Math.Min(sourceCamera.NearPlaneDistance, destinationCamera.NearPlaneDistance);
656 destinationCamera.FarPlaneDistance = Math.Max(sourceCamera.FarPlaneDistance, destinationCamera.FarPlaneDistance);
658 cameraTransition.Finished += (s, e) =>
660 this.GetSelectedCamera().NearPlaneDistance = destinationNearPlaneDistance;
661 this.GetSelectedCamera().FarPlaneDistance = destinationFarPlaneDistance;
662 inCameraTransition = false;
663 CameraTransitionFinished?.Invoke(this, EventArgs.Empty);
665 cameraTransition.Play();
667 positionKeyFrames.Dispose();
668 orientationKeyFrames.Dispose();
672 /// Release swigCPtr.
674 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
675 [EditorBrowsable(EditorBrowsableState.Never)]
676 protected override void ReleaseSwigCPtr(global::System.Runtime.InteropServices.HandleRef swigCPtr)
678 Interop.SceneView.DeleteScene(swigCPtr);