Camera

Gói: @aspose/3d (v24.12.0)

Camera là một Entity có thể được gắn vào một Node để xác định góc nhìn trong cảnh. Nó hỗ trợ cả phép chiếu phối cảnh và trực giao, được điều khiển bởi projectionType thuộc tính. Các tham số máy ảnh được lưu trong tệp 3D khi cảnh được lưu dưới định dạng hỗ trợ máy ảnh (FBX, COLLADA, glTF).

export class Camera extends Entity

Enumerations

A3DObject ← SceneObject ← Entity ← Camera

Enumerations

Thêm một camera phối cảnh vào cảnh và cấu hình khối nhìn của nó.

import { Scene, Node, Camera, ProjectionType } from '@aspose/3d';

const scene = new Scene();

const camNode = scene.rootNode.createChildNode('mainCamera');
const camera = new Camera('mainCamera', ProjectionType.PERSPECTIVE);
camNode.entity = camera;

camera.nearPlane = 0.1;
camera.farPlane = 500;
camera.fieldOfView = 60;
camera.aspect = 16 / 9;

scene.save('output.gltf');
console.log(`Camera projection: ${camera.projectionType}`);
// Camera projection: PERSPECTIVE

Enumerations

NameTypeAccessDescription
namestringRead/WriteGets the name.
parentNodesany[]ReadGets the parent nodes.
excludedbooleanRead/WriteGets the excluded.
parentNodeanyRead/WriteGets the parent node.
rotationModeanyRead/WriteGets the rotation mode.
nearPlanenumberRead/WriteGets the near plane.
farPlanenumberRead/WriteGets the far plane.
aspectnumberRead/WriteGets the aspect.
orthoHeightnumberRead/WriteGets the ortho height.
upanyRead/WriteGets the up.
lookAtanyRead/WriteGets the look at.
directionanyRead/WriteGets the direction.
targetanyRead/WriteGets the target.
apertureModeanyRead/WriteGets the aperture mode.
fieldOfViewnumberRead/WriteGets the field of view.
fieldOfViewXnumberRead/WriteGets the field of view x.
fieldOfViewYnumberRead/WriteGets the field of view y.
widthnumberRead/WriteGets the width.
heightnumberRead/WriteGets the height.
aspectRationumberRead/WriteGets the aspect ratio.
magnificationanyRead/WriteGets the magnification.
projectionTypestringRead/WriteGets the projection type.
SignatureDescription
`constructor(name: stringnull, projectionType: any)`
moveForward(_distance: number)Moves the camera forward by the specified distance
getBoundingBox()anyReturns the bounding box.
getEntityRendererKey()anyNot implemented in the FOSS edition — throws at runtime. Returns the entity renderer key.
`removeProperty(_prop: Propertystring)boolean`
getProperty(_property: string)anyReturns the value of the specified property
setProperty(_property: string, _value: any)Sets the property value.
findProperty(_property: string) → `Propertynull`

Enumerations

moveForward(distance)

Di chuyển camera về phía trước dọc theo hướng nhìn của nó theo khoảng cách đã cho.

moveForward(distance: number): void

Enumerations

distance number

Khoảng cách di chuyển về phía trước. Giá trị âm sẽ di chuyển camera về phía sau.

Enumerations

void

Enumerations

import { Scene, Camera, ProjectionType } from '@aspose/3d';

const scene = new Scene();
const camNode = scene.rootNode.createChildNode('cam');
const camera = new Camera('cam', ProjectionType.PERSPECTIVE);
camNode.entity = camera;

camera.moveForward(10);
console.log('Camera moved forward by 10 units.');

Enumerations

  • Trong nguồn, Camera kế thừa từ Entity. Light cũng mở rộng Camera, có nghĩa là Light các đối tượng có tất cả các thuộc tính của camera trong hệ thống kiểu; điều này phản ánh mô hình dữ liệu FBX, nơi đèn và camera chia sẻ một loại nút cơ sở chung.
  • Sử dụng ProjectionType các hằng lớp (ProjectionType.PERSPECTIVE, ProjectionType.ORTHOGRAPHIC) thay vì các chuỗi nguyên thuỷ để đảm bảo an toàn kiểu.
 Tiếng Việt