Reputation: 16276
I drew a Torus and Cube Mesh in my scene, and i want the cube to be positioned in the bottom right corner of the screen, so i did like this:
<div style="position: absolute; bottom: 0px; right:0px; width: 100px; text-align: center; ">
<script>
var cube = new THREE.Mesh(new THREE.CubeGeometry(50,50,50),
new THREE.MeshBasicMaterial({color: 0x000000}));
scene.add(cube);
</script>
</div>
However, the cube is still following the center of the screen: http://medigarage.com/html5/js/three.js/examples/canvas_camera2.html
Am i missing something? Thanx in advance.
EDIT:
I tried to make new renderer, scene and camera for the cube like this:
HTML code:
<div id="share">
CSS code:
#share {
border: 1px solid black; /* or none; */
margin: 20px;
padding: 0px;
width: 200px;
height: 200px;
position: absolute;
right: 0px;
bottom: 0px;
}
JavaScript code:
<script>
//dom
var container2=document.getElementById('share');
//renderer
var renderer2 = new THREE.CanvasRenderer();
renderer2.setSize(200,200);
container2.appendChild(renderer2.domElement);
//Scene
var scene2 = new THREE.Scene();
//Camera
var camera2 = new THREE.PerspectiveCamera(50,200/200,1,1000);
camera2.up=camera.up;
scene2.add(camera2);
//Axes
var axes2= new THREE.AxisHelper();
scene2.add(axes2);
//Add Cube
var cube = new THREE.Mesh(new THREE.CubeGeometry(50,50,50),
new THREE.MeshBasicMaterial({color: 0x000000}));
scene2.add(cube);
//
renderer2.render(scene2,camera2);
</script>
I got the div in the right place, but the cube is not there, in the web console everything is ok, i got no error regarding this. Could you point me to the missing point? You still can see it on live here: http://medigarage.com/html5/js/three.js/examples/canvas_camera2.html
Upvotes: 1
Views: 192
Reputation: 104783
You can do what you want by following this example fiddle: http://jsfiddle.net/CYMtV/
Also see the related thread: https://github.com/mrdoob/three.js/issues/1372
Upvotes: 0