It has been a few years since I had a look at this three.js
project of mine (back when one typed out the full name PlaneBufferGeometry
). It contains a number of vehicles that should reflect the environment around them through CubeCamera
s. However, when I activate this option I get the following error:
Uncaught TypeError: Cannot read properties of undefined (reading 'up')
at CubeCamera.updateCoordinateSystem (three.module.js:12739:13)
at CubeCamera.update (three.module.js:12803:9)
at CLASS_drone.update (blend.levels.php:2960:19)
This is what is happening in the CLASS_drone
:
function CLASS_drone(x,y,z,path,pts)
{
this.x = x;
this.y = y+0.25;
this.z = z;
this.path = path;
this.ptstart = pts;
this.pts = pts;
this.drone = new THREE.Group();
this.body = drone.clone();
this.bidx = 0;
this.widx = 0;
this.fps = 0;
for(var i = 0; i < this.body.children.length; i++)
{
if(this.body.children[i].name == "BODY")
this.bidx = i;
if(this.body.children[i].name == "WINDOW")
this.widx = i;
}
this.drone.add(this.body);
this.drone.position.set(this.x,this.y,this.z);
this.CRT = new THREE.WebGLCubeRenderTarget( 32, { format: THREE.RGBFormat, generateMipmaps: true, minFilter: THREE.LinearMipmapLinearFilter } );
this.cubecam = new THREE.CubeCamera(0.1, 3, this.CRT);
this.envset = document.getElementById("qcubemap").checked;
// this.drone.add(this.cubecam);
this.drone.traverse(function(item)
{
if(item.isMesh)
{
if(item.name=="WINDOW")
item.material = new THREE.MeshBasicMaterial({color:0x00FFFF,reflectivity:0.75});
else if(item.name=="LAMP")
item.material = matph_drLmp;
else if(item.name=="BODY")
item.material = new THREE.MeshBasicMaterial({color:0xFFFFFF,reflectivity:0.5});
else
item.material = matph_drBod;
item.material.needsUpdate = true;
}
});
this.body.children[this.bidx].material.envMap = this.CRT.texture;
this.body.children[this.widx].material.envMap = this.CRT.texture;
...
this.update = function(raftime)
{
if(this.active==true)
{
if(this.body.visible==true)
{
if(camera.position.distanceTo(this.drone.position)<10 && document.getElementById("qcubemap").checked==true && raftime > this.fps + (timing * 5))
{
this.cubecam.clear(renderer);
this.drone.visible = false;
this.cubecam.position.copy(this.drone.position);
>> this.cubecam.update(renderer,scene);
this.drone.visible = true;
this.fps = raftime;
}