Skip to content

Instantly share code, notes, and snippets.

View Strae's full-sized avatar
🎯
Focusing

Daniele P. Strae

🎯
Focusing
View GitHub Profile
@Strae
Strae / check_if_entity_is_in_the_viewport.js
Created November 15, 2017 11:20
Aframe entity in viewport / visible
//RETURNS TRUE/FALSE BASED ON WHETHER OR NOT THE ENTITY IS VISIBLE
checkIfVisible(entity, camera){
let entityMesh = entity.object3DMap.mesh;
let frustum = new THREE.Frustum();
let cameraViewProjectionMatrix = new THREE.Matrix4();
camera.updateMatrixWorld();
camera.matrixWorldInverse.getInverse(camera.matrixWorld);
cameraViewProjectionMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
@Strae
Strae / commerce_bestsellers.sql
Created April 14, 2018 05:32 — forked from iAugur/commerce_bestsellers.sql
Drupal Commerce - Top selling Products
/**
* Get a list of the top selling products on a Drupal Commerce site
* If you have different product types - add them to the in list.
* Based on https://drupal.org/node/1292104#comment-6866420 by tmsimont https://drupal.org/user/566678
*/
SELECT node.title AS product_title, node.nid AS product_nid, COUNT(cp.title) AS order_count
FROM commerce_order
LEFT JOIN field_data_commerce_line_items as fdcli ON commerce_order.order_id = fdcli.entity_id AND (fdcli.entity_type = 'commerce_order' AND fdcli.deleted = '0')
INNER JOIN commerce_line_item as cli ON fdcli.commerce_line_items_line_item_id = cli.line_item_id
<canvas id="myCanvas"> </canvas>
<script>
let img = new (window as any).Image();
img.crossOrigin = `Anonymous`;
img.src = "https://images.unsplash.com/photo-1667461143891-d52ffd5500f5";
img.onload = function () {
canvas = document.getElementById("myCanvas") as HTMLCanvasElement;