Attach camera to cube

Hi. Im new to three.js
I wonder if there is a way to attach a camera to a cube instead of adding the camera to scene.

Background: I want to move the cube (with camera inside) by keys. If i rotate the cube, the camera rotates too but camera.rotation stays at 0.
Is that possible?


var cube = new THREE.Mesh( _some_parameters_ );
var camera = new THREE.PerspectiveCamera( _some_parameters_ );

Is it not working for you?

Unfortunately not (got errors like cube add is not a function)

But before i try your code satndalone (beside of my class), i’ll try to figure out the issues on my class. Im sure your code is working because, thats what i read so often. So must be my mistake. (100% of computererrors are sitting right in front of it :slight_smile: )

Thank you

Remember the best way to get help is to demonstrate the issue with a live example. This approach makes it easy for the community to comprehend and debug the problem.

Yes. I did on my first issue. And i will in future for my next (for sure coming issues). But right now the problem seems to be my class (which is huge). Im new to three.js, but not to javascript. So before break it down to a readable demo i’ll try to figure out where exactly the errors occurs.