Camera

Paquete: @aspose/3d (v24.12.0)

Camera es un Entity que puede adjuntarse a un Node para definir un punto de vista en la escena. Soporta tanto proyecciones en perspectiva como ortográficas, controladas por el projectionType propiedad. Los parámetros de la cámara se almacenan en el archivo 3D cuando la escena se guarda en un formato que admite cámaras (FBX, COLLADA, glTF).

export class Camera extends Entity

Example

Quaternion se usa en toda la API @aspose/3d para representar rotaciones sin bloqueo de cardán. Es el tipo devuelto por Transform.rotation y GlobalTransform.rotation. El cuaternión de identidad (1, 0, 0, 0) representa ninguna rotación. Quaternion se exporta desde la subruta @aspose/3d/utilities.

Example

Añade una cámara perspectiva a una escena y configura su frustum.

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

Example

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`

Example

moveForward(distance)

Mueve la cámara hacia adelante a lo largo de su dirección de visión por la distancia indicada.

moveForward(distance: number): void

Example

distance number

La distancia a mover hacia adelante. Los valores negativos mueven la cámara hacia atrás.

Example

void

Example

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.');

Example

  • En el origen, Camera hereda de Entity. Light también extiende Camera, lo que significa Light los objetos tienen todas las propiedades de cámara en la jerarquía de tipos; esto refleja el modelo de datos FBX donde luces y cámaras comparten un tipo de nodo base común.
  • Utiliza el ProjectionType constantes de clase (ProjectionType.PERSPECTIVE, ProjectionType.ORTHOGRAPHIC) en lugar de literales de cadena crudos para seguridad de tipos.
 Español