circle() { const geometry = new THREE.CircleGeometry(); const material = new THREE.MeshBasicMaterial({ color: Math.random() * 0xffffff }); return new THREE.Mesh(geometry, material); }
function scaleOneAxisOnMove() { point.applyMatrix4(tempMatrix.getInverse(worldRotationMatrix)); if (scope.axis === 'X') { scope.object.scale.x = oldScale.x * (1 + point.x / oldScale.x); } if (scope.axis === 'Y') { scope.object.scale.y = oldScale.y * (1 + point.y / oldScale.y); } if (scope.axis === 'Z') { scope.object.scale.z = oldScale.z * (1 + point.z / oldScale.z); } }
// MAP CALLBACKS refresh() { const frustum = new THREE.Frustum(); frustum.setFromMatrix( new THREE.Matrix4().multiplyMatrices( this.camera.projectionMatrix, this.camera.matrixWorldInverse ) ); this.tileset.root.checkLoad(frustum, this._getCameraPosition()); }
// THREE.js instantiation _createTHREENodes() { this.totalContent = new THREE.Group(); // Three JS Object3D Group for this tile and all its children this.tileContent = new THREE.Group(); // Three JS Object3D Group for this tile's content this.childContent = new THREE.Group(); // Three JS Object3D Group for this tile's children this.totalContent.add(this.tileContent); this.totalContent.add(this.childContent); }
const rotateRight = object => (dispatch, getState) => { const { three: { camera } } = getState(); const plane = new THREE.Plane(); plane.setFromNormalAndCoplanarPoint( camera.getWorldDirection(plane.normal), object.object3D.position ); object.object3D.rotateOnAxis(plane.normal, 0.1); }
const getCameraPosition = camera => { // not sure why i should do this, copied from somewhere camera.position.setFromMatrixPosition(camera.matrixWorld); // get camera position const cameraPos = new THREE.Vector3(0, 0, 0); cameraPos.applyMatrix4(camera.matrixWorld); return cameraPos; }
export function transform2mapbox(matrix) { const min = -WEBMERCATOR_EXTENT; const max = WEBMERCATOR_EXTENT; const scale = 1 / (2 * WEBMERCATOR_EXTENT); const result = matrix.slice(); // copy array result[12] = (matrix[12] - min) * scale; // x translation result[13] = (matrix[13] - max) * -scale; // y translation result[14] = matrix[14] * scale; // z translation return new THREE.Matrix4().fromArray(result).scale(new THREE.Vector3(scale, -scale, scale)); }
plane() { const geometry = new THREE.PlaneGeometry(); const material = new THREE.MeshBasicMaterial({ color: Math.random() * 0xffffff, side: THREE.DoubleSide }); return new THREE.Mesh(geometry, material); }
tetrahedron() { const geometry = new THREE.TetrahedronGeometry(); const material = new THREE.MeshBasicMaterial({ color: Math.random() * 0xffffff }); return new THREE.Mesh(geometry, material); }
box() { const geometry = new THREE.BoxGeometry(); const material = new THREE.MeshBasicMaterial({ color: Math.random() * 0xffffff }); return new THREE.Mesh(geometry, material); }
icosahedron() { const geometry = new THREE.IcosahedronGeometry(); const material = new THREE.MeshBasicMaterial({ color: Math.random() * 0xffffff }); return new THREE.Mesh(geometry, material); }
octahedron() { const geometry = new THREE.OctahedronGeometry(); const material = new THREE.MeshBasicMaterial({ color: Math.random() * 0xffffff }); return new THREE.Mesh(geometry, material); }
sphere() { const geometry = new THREE.SphereGeometry(); const material = new THREE.MeshBasicMaterial({ color: Math.random() * 0xffffff }); return new THREE.Mesh(geometry, material); }
torusknot() { const geometry = new THREE.TorusKnotGeometry(); const material = new THREE.MeshBasicMaterial({ color: Math.random() * 0xffffff }); return new THREE.Mesh(geometry, material); }