|
1 | 1 | import * as THREE from 'three'; |
2 | 2 |
|
3 | | -const scene = new THREE.Scene(); |
4 | | -const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); |
5 | | - |
6 | | -const renderer = new THREE.WebGLRenderer(); |
7 | | -renderer.setSize( window.innerWidth, window.innerHeight ); |
8 | | -document.body.appendChild( renderer.domElement ); |
9 | | - |
10 | | -const geometry = new THREE.BoxGeometry( 1, 1, 1 ); |
11 | | -const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } ); |
12 | | -const cube = new THREE.Mesh( geometry, material ); |
13 | | -scene.add( cube ); |
14 | | - |
15 | | -camera.position.z = 5; |
16 | | - |
17 | | -function animate() { |
18 | | - cube.rotation.x += 0.01; |
19 | | - cube.rotation.y += 0.01; |
20 | | - renderer.render( scene, camera ); |
21 | | -} |
22 | | -renderer.setAnimationLoop( animate ); |
23 | | - |
24 | 3 | const input = document.getElementById("input"); |
25 | 4 | const preview = document.getElementById("preview"); |
26 | 5 | const threedee = document.getElementById('threedee'); |
@@ -596,3 +575,24 @@ function appendErrorMessage(message) { |
596 | 575 | errorParagraph.textContent = message; |
597 | 576 | errorOutput.appendChild(errorParagraph); |
598 | 577 | } |
| 578 | + |
| 579 | +const scene = new THREE.Scene(); |
| 580 | +const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); |
| 581 | + |
| 582 | +const renderer = new THREE.WebGLRenderer(); |
| 583 | +renderer.setSize( window.innerWidth, window.innerHeight ); |
| 584 | +document.getElementById('threedee').appendChild( renderer.domElement ); |
| 585 | + |
| 586 | +const geometry = new THREE.BoxGeometry( 1, 1, 1 ); |
| 587 | +const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } ); |
| 588 | +const cube = new THREE.Mesh( geometry, material ); |
| 589 | +scene.add( cube ); |
| 590 | + |
| 591 | +camera.position.z = 5; |
| 592 | + |
| 593 | +function animate() { |
| 594 | + cube.rotation.x += 0.01; |
| 595 | + cube.rotation.y += 0.01; |
| 596 | + renderer.render( scene, camera ); |
| 597 | +} |
| 598 | +renderer.setAnimationLoop( animate ); |
0 commit comments