我正在努力创造一个雪人,它的肚子是一个雪球。我想知道是否有办法在场景中创建场景。基本上当我滚动到他的腹部时,我想加载一个不同的场景。这可能吗。这是我到目前为止的基本代码。
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script src="three.js"></script>
<script src="TrackballControls.js"></script>
<script>
var camera, controls, scene, renderer;
init();
animate();
function init() {
camera = new THREE.PerspectiveCamera(75,window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 10;
controls = new THREE.TrackballControls( camera );
controls.addEventListener("change", render);
scene = new THREE.Scene();
var geometry = new THREE.SphereGeometry(4,32,32);
var material = new THREE.MeshBasicMaterial( { color: 0xcacec6 });
var middleSphere = new THREE.Mesh( geometry, material );
scene.add( middleSphere );
middleSphere.position.y = -0.5;
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild( renderer.domElement );
}
function ani`enter code here`mate() {
requestAnimationFrame( animate );
controls.update();
}
function render() {
renderer.render( scene, camera );
}
</script>
</body>
</html>