Skip to content

Commit

Permalink
mark front side of objects with lower transparency
Browse files Browse the repository at this point in the history
  • Loading branch information
walzimmer committed Mar 6, 2021
1 parent 6add915 commit 9f924c8
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions js/pcd_label_tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,14 +658,26 @@ function get3DLabel(parameters) {
color = classesBoundingBox.getCurrentAnnotationClassObject().color;
}

let cubeMaterial = new THREE.MeshBasicMaterial({
let cubeMaterialSide = new THREE.MeshBasicMaterial({
color: color,
transparent: true,
opacity: 0.1,
side: THREE.DoubleSide,
morphTargets: false
});

let cubeMaterialFrontSide = new THREE.MeshBasicMaterial({
color: color,
transparent: true,
opacity: 0.9,
side: THREE.DoubleSide
side: THREE.DoubleSide,
morphTargets: false
});

let cubeMesh = new THREE.Mesh(cubeGeometry, cubeMaterial);
let cubeMaterials = [cubeMaterialSide, cubeMaterialFrontSide, cubeMaterialSide, cubeMaterialSide, cubeMaterialSide, cubeMaterialSide];
let faceMaterial = new THREE.MeshFaceMaterial(cubeMaterials);
let cubeMesh = new THREE.Mesh(cubeGeometry, faceMaterial);

cubeMesh.position.set(bbox.x, bbox.y, bbox.z);
cubeMesh.scale.set(bbox.width, bbox.length, bbox.height);
cubeMesh.rotation.z = bbox.rotationYaw;
Expand Down Expand Up @@ -1754,7 +1766,9 @@ function update() {
let vector = new THREE.Vector3(mousePos.x, mousePos.y, 1);
vector.unproject(currentCamera);
let ray = new THREE.Raycaster(currentCamera.position, vector.sub(currentCamera.position).normalize());
let intersects = ray.intersectObjects(scene.children);
// set ray.camera in three.js version r126, otherwise error: THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.
ray.camera = currentCamera;
let intersects = ray.intersectObjects(scene.children, true);

// if there is one (or more) intersections
if (intersects.length > 0) {
Expand Down

0 comments on commit 9f924c8

Please sign in to comment.