Public
Edited
Oct 15, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
paper = () => {
const blue_material = new THREE.MeshLambertMaterial({ color: 0xccccff, side: THREE.DoubleSide });
const green_material = new THREE.MeshLambertMaterial({ color: 0xccffcc, side: THREE.DoubleSide });
group.children = [];
// Card
let paper0 = new THREE.PlaneGeometry(cardWidth, cardHeight);
paper0.translate(cardWidth/2, 0, 0);
addToGroup(paper0, blue_material);
let paper1 = new THREE.PlaneGeometry(cardWidth, cardHeight);
paper1.translate(-cardWidth/2, 0, 0);
paper1.rotateY(-foldAngle);
addToGroup(paper1, blue_material);

// Popup part
let pu = popup(0, 0, 0);
let sin = -Math.sin(-foldAngle);
let cos = Math.cos(-foldAngle);
let c2P = new THREE.Vector3(pu.cP.x*cos + pu.cP.z*sin, pu.cP.y, -pu.cP.x*sin + pu.cP.z*cos); //rotate around y-axis
let bPs = intersect3Spheres(pu.aP, pu.distAB, pu.dP, pu.distDB, c2P, pu.distCB);
pu.bP = bPs[0];

//right popup plane; fixed
let geo1 = new THREE.Geometry();
geo1.vertices.push(
new THREE.Vector3(-pu.dP.x, pu.dP.y, pu.dP.z),
new THREE.Vector3(-pu.aP.x, pu.aP.y, pu.aP.z),
new THREE.Vector3(-pu.bP.x, pu.bP.y, pu.bP.z)
);
geo1.faces.push(
new THREE.Face3(0, 1, 2)
);
addToGroup(geo1, green_material);

//left popup plane; movable
let geo2 = new THREE.Geometry();
geo2.vertices.push(
new THREE.Vector3(-pu.bP.x, pu.bP.y, pu.bP.z),
new THREE.Vector3(-pu.aP.x, pu.aP.y, pu.aP.z),
new THREE.Vector3(-c2P.x, c2P.y, c2P.z)
);
geo2.faces.push(
new THREE.Face3(0, 1, 2)
);
addToGroup(geo2, green_material);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more