# 3D 簡介¶

## Spatial 節點¶

Node2D 是 2D 的基礎節點。 Control 是所有 GUI 的基礎節點。同理，3D 引擎使用 Spatial 節點來處理所有 3D 內容。

Spatial節點有一個局部變換(local transform)，它是相對於父節點的（只要父節點也是 或者繼承自 Spatial 類型）。這個變換(transform)可以以 4×3 的 Transform 形式訪問，也可以以 3 個 Vector3 成員並分別代表位置、歐拉旋轉（X、Y、Z 角度）和縮放的形式訪問。

## 3D 內容¶

2D 中載入圖像內容和繪圖都非常直觀，3D 則有所不同，會稍微困難一些。3D內容需要使用特殊的 3D 工具（通常稱為數位內容創建工具或Digital Content Creation工具，簡稱DCC）來創建，並匯出成可被 Godot 匯入的交換文件格式。這是必需的，因為 3D 格式不像圖像那樣標準化。

## 3D 視窗¶

### 座標系¶

Godot 在 3D 中使用的都是 `公制(metric)<https://zh.wikipedia.org/wiki/%E5%85%AC%E5%88%B6>`__ ，1 個單位等於 1 公尺。物理和其他區域都針對這個進行了調整。因此，嘗試使用不同的比例通常是個壞主意（除非您知道自己在做什麼）。

The Y coordinate is used for "up", though for most objects that need alignment (like lights, cameras, capsule collider, vehicle, etc.), the Z axis is used as a "pointing towards" direction. This convention roughly means that:

• X is sides

• Y is up/down

• Z is front/back

### Space and manipulation gizmos¶

Moving objects in the 3D view is done through the manipulator gizmos. Each axis is represented by a color: Red, Green, Blue represent X, Y, Z respectively. This convention applies to the grid and other gizmos too (and also to the shader language, ordering of components for Vector3, Color, etc.).

Some useful keybindings:

• To snap placement or rotation, press Ctrl while moving, scaling or rotating.

• To center the view on the selected object, press F.

The view options are controlled by the "View" menu in the viewport's toolbar.

You can hide the gizmos in the 3D view of the editor through this menu:

To hide a specific type of gizmos, you can toggle them off in the "View" menu.

### Default environment¶

When created from the Project Manager, the 3D environment has a default sky.

Given how physically based rendering works, it is advised to always try to work with a default environment in order to provide indirect and reflected light to your objects.

### 攝影機¶

No matter how many objects are placed in the 3D space, nothing will be displayed unless a Camera is also added to the scene. Cameras can work in either orthogonal or perspective projections:

Cameras are associated with (and only display to) a parent or grandparent viewport. Since the root of the scene tree is a viewport, cameras will display on it by default, but if sub-viewports (either as render target or picture-in-picture) are desired, they need their own children cameras to display.

When dealing with multiple cameras, the following rules are enforced for each viewport:

• If no cameras are present in the scene tree, the first one that enters it will become the active camera. Further cameras entering the scene will be ignored (unless they are set as current).

• If a camera has the "current" property set, it will be used regardless of any other camera in the scene. If the property is set, it will become active, replacing the previous camera.

• If an active camera leaves the scene tree, the first camera in tree-order will take its place.

### 光照¶

Godot has a limit of up to 8 lights per mesh. Aside from that, there is no limitation on the number of lights, nor of types of lights, in Godot. As many as desired can be added, as long as performance allows, and no more than 8 lights shine on a single mesh.