Javascript 使用透视摄影机时,近平面和远平面使用哪个轴?

Javascript 使用透视摄影机时,近平面和远平面使用哪个轴?,javascript,three.js,Javascript,Three.js,我创建了一个示例项目,并阅读了一篇关于three.js的优秀文章,但在创建透视相机时,有一件事没有得到很好的描述 当创建一个对象并将其添加到场景中的默认位置(0,0,0)时,相机被设置并向后移动10个单位以使对象易于看到,我已经指定了0.1和1000的近平面和远平面。我不确定指定在哪个轴上,但是无论指定在哪个轴上,默认对象上的轴都不可见,因为近平面和远平面指定可见对象必须位于这些平面之间 有人能解释为什么我的物体在场景中可见,近平面和远平面是哪个轴,或者提供一个非常有用的链接来描述它,因为我找不

我创建了一个示例项目,并阅读了一篇关于three.js的优秀文章,但在创建透视相机时,有一件事没有得到很好的描述

当创建一个对象并将其添加到场景中的默认位置(0,0,0)时,相机被设置并向后移动10个单位以使对象易于看到,我已经指定了
0.1
1000
的近平面和远平面。我不确定指定在哪个轴上,但是无论指定在哪个轴上,默认对象上的轴都不可见,因为近平面和远平面指定可见对象必须位于这些平面之间

有人能解释为什么我的物体在场景中可见,近平面和远平面是哪个轴,或者提供一个非常有用的链接来描述它,因为我找不到一个链接来解释

如果感兴趣,请在下面输入代码

import * as THREE from 'three';
import 'bootstrap';
import css from '../css/custom_css.css';

let scene = new THREE.Scene();

/* Constants */
let WIDTH = window.innerWidth;
let HEIGHT = window.innerHeight;

/* Camera */
let field_of_view = 75;
let aspect_ratio = WIDTH/HEIGHT;
let near_plane = 0.1;
let far_plane = 1000;
let camera = new THREE.PerspectiveCamera(field_of_view, aspect_ratio, near_plane, far_plane);
// every object is initially created at ( 0, 0, 0 )
// we'll move the camera back a bit so that we can view the scene
camera.position.set( 0, 0, 10 );

/* Renderer */
let renderer = new THREE.WebGLRenderer({antialias:true, canvas: my_canvas });
renderer.setSize(WIDTH, HEIGHT);
renderer.setClearColor(0xE8E2DD, 1);

// Create the shape
let geometry = new THREE.BoxGeometry(1, 1, 1);
// Create a material, colour or image texture
let material = new THREE.MeshBasicMaterial( {
    color: 0xFF0000,
    wireframe: true
});

// Cube
let cube = new THREE.Mesh(geometry, material);
scene.add(cube);

// Game Logic
let update = function(){
    cube.rotation.x += 0.01;
    cube.rotation.y += 0.005;
};

// Draw Scene
let render = function(){
  renderer.render(scene, camera);
};

// Run game loop, update, render, repeat
let gameLoop = function(){
    requestAnimationFrame(gameLoop);

    update();
    render();
};

gameLoop();

透视摄影机的近平面和远平面相对于摄影机本身,它们不在全局场景轴之一上

在您的情况下,近平面是沿摄影机的中心轴或“look”向量距离摄影机0.1单位的平面,远平面是距离摄影机1000单位的平面。渲染的对象必须位于摄影机“视锥”内的这两个平面之间

因此,在您的示例中,由于摄影机正在查看对象,并且对象距离
10
单位,因此它位于视锥体内,因此可见

请参阅此youtube视频以获得更直观的表示: