var INIT = 0x1 // 0 0 0 0 1
, PENDING = 0x2 // 0 0 0 1 0
, DONE = 0x4 // 0 0 1 0 0
, ERROR = 0x8 // 0 1 0 0 0
, SUCCESS = 0x10 // 1 0 0 0 0
, ALL = 0x1f // 1 1 1 1 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://discourse.threejs.org/t/functions-to-calculate-the-visible-width-height-at-a-given-z-depth-from-a-perspective-camera/269 | |
function visibleHeightAtDepth(depth, camera) { | |
// compensate for cameras not positioned at z=0 | |
const cameraOffset = camera.position.z; | |
if ( depth < cameraOffset ) depth -= cameraOffset; | |
else depth += cameraOffset; | |
// vertical fov in radians | |
const vFOV = camera.fov * Math.PI / 180; | |
// Math.abs to ensure the result is always positive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sass-convert -R ./ -F sass -T scss && rm *.sass |
This post has been moved to my blog, under Color Management in three.js.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% comment %} | |
UPDATE: Now you can use this theme to more easily manage your redirects: | |
https://github.com/benjaminsehl/shopify-headless-theme | |
{% endcomment %} | |
{% assign new_website = 'https://headless-website.com/' %} | |
<!doctype html> | |
<html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mat4 rotationMatrix(vec3 axis, float angle) | |
{ | |
axis = normalize(axis); | |
float s = sin(angle); | |
float c = cos(angle); | |
float oc = 1.0 - c; | |
return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0, | |
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0, | |
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var collision = {}; | |
// aabb: <THREE.Box3> | |
// Plane: <THREE.Plane> | |
collision.isIntersectionAABBPlane = function ( aabb, Plane ) { | |
var center = new THREE.Vector3().addVectors( aabb.max, aabb.min ).multiplyScalar( 0.5 ), | |
extents = new THREE.Vector3().subVectors( aabb.max, center ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://michalbe.blogspot.com.br/2013/03/javascript-less-known-parts-bitwise.html | |
// http://jsperf.com/bitwise-vs-math-object | |
// http://united-coders.com/christian-harms/results-for-game-for-forfeits-and-the-winner-is/ | |
// https://mudcu.be/journal/2011/11/bitwise-gems-and-other-optimizations/ | |
// https://dreaminginjavascript.wordpress.com/2009/02/09/bitwise-byte-foolish/ | |
// http://jsperf.com/math-min-max-vs-ternary-vs-if/24 | |
"use strict"; | |
var PI = Math.PI; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { h, Component } from 'preact'; | |
import Markup from 'preact-markup'; | |
import register from './preact-custom-element'; | |
// just a proxy component: WC -> Preact -> WC | |
const A = () => <x-b foo="initial foo from <x-a>" />; | |
// stateful component that can re-render | |
class B extends Component { | |
render(props, state) { |
OlderNewer