Camera

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

Camera is een Entity die kan worden gekoppeld aan een Node om een gezichtspunt in de scène te definiëren. Het ondersteunt zowel perspectief- als orthografische projecties, gecontroleerd door de projectionType eigenschap. Camera‑parameters worden opgeslagen in het 3D‑bestand wanneer de scène wordt opgeslagen in een formaat dat camera’s ondersteunt (FBX, COLLADA, glTF).

export class Camera extends Entity

ImageRenderOptions

A3DObject ← SceneObject ← Entity ← Camera

ImageRenderOptions

Voeg een perspectiefcamera toe aan een scène en configureer zijn 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

ImageRenderOptions

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`

ImageRenderOptions

moveForward(distance)

Verplaatst de camera naar voren langs zijn kijkrichting met de opgegeven afstand.

moveForward(distance: number): void

ImageRenderOptions

distance number

De afstand om naar voren te bewegen. Negatieve waarden verplaatsen de camera naar achteren.

ImageRenderOptions

void

ImageRenderOptions

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

ImageRenderOptions

  • In de bron, Camera erft van Entity. Light breidt ook uit Camera, wat betekent Light objecten hebben alle camera‑eigenschappen in de typehiërarchie; dit weerspiegelt het FBX‑gegevensmodel waarin lampen en camera’s een gemeenschappelijk basisknooppunttype delen.
  • Gebruik de ProjectionType klasseconstanten (ProjectionType.PERSPECTIVE, ProjectionType.ORTHOGRAPHIC) in plaats van ruwe tekenreeksletterlijke waarden voor typeveiligheid.
 Nederlands