const float PI = 3.1415926535897932384626433832795;
const float PI_2 = 1.57079632679489661923;
const float PI_4 = 0.785398163397448309616;
float PHI = (1.0+sqrtf(5.0))/2.0;
This file contains hidden or 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
| // HELPER FUNCTIONS | |
| const has = (entity, components) => { | |
| const exists = (x) => typeof x !== "undefined"; | |
| return components.map((component) => exists(entity[component])) | |
| .reduce((x,y) => x && y); | |
| }; | |
| const clone = (object) => { | |
| if (object === null || typeof object !== 'object'){ | |
| return object; |
This file contains hidden or 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
| vec4 applyMatrix4( vec4 p, mat4 m) { | |
| return m * p; | |
| } | |
| vec3 applyMatrix4(vec3 p, mat4 m) { | |
| return vec3( m * vec4(p, 1.0) ); | |
| } | |
| vec3 applyMatrix3(vec3 p, mat3 m) { | |
| return m * p; | |
| } |
This file contains hidden or 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
| vec2 pixel = vec2(1.0) / 16.; | |
| // il nostro puntatore, data una coordinata viene tradotta in una posizione della texture | |
| vec2 pixelPosition(float p) { | |
| float groupInRow = 4.; | |
| return vec2( | |
| ((mod(p, groupInRow) * 4.0)) * pixel.x, // column | |
| (floor(p * 0.25)) * pixel.y // row | |
| ); |
This file contains hidden or 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://observablehq.com/@k9/calculating-normals-for-distorted-vertices | |
| varying vec3 vNormal; | |
| uniform float offset; | |
| float tangentFactor = 0.1; | |
| ${perlin()} | |
| // http://lolengine.net/blog/2013/09/21/picking-orthogonal-vector-combing-coconuts |
Code examples from this stack overflow answer.
This file contains hidden or 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://blender.stackexchange.com/q/57306/3710 | |
| # https://blender.stackexchange.com/q/79779/3710 | |
| bl_info = { | |
| "name": "Add-on Template", | |
| "description": "", | |
| "author": "", | |
| "version": (0, 0, 1), | |
| "blender": (2, 70, 0), | |
| "location": "3D View > Tools", |
Due to recent changes in the autoplay policy of Chrome 66 developers of interactive experiences on the web are facing new challenges regarding audio and video autoplay. The new policy has unfortunately broken many of the older experiences that rely on autoplaying audio and video.
So how to move forward?
Previously developers used to face this issue on iOS mobile devices where the audio context was locked. Most developers fixed this by using the initial touch event of a user to unlock the audio.
This file contains hidden or 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
| const glslify = require('glslify'); | |
| const path = require('path'); | |
| const assign = require('object-assign'); | |
| const defined = require('defined'); | |
| // This is the original source, we will copy + paste it for our own GLSL | |
| // const vertexShader = THREE.ShaderChunk.meshphysical_vert; | |
| // const fragmentShader = THREE.ShaderChunk.meshphysical_frag; | |
| // Our custom shaders |
This file contains hidden or 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
| const glslify = require('glslify'); | |
| const path = require('path'); | |
| // This is the original source, we will copy + paste it for our own GLSL | |
| // const vertexShader = THREE.ShaderChunk.meshphysical_vert; | |
| // const fragmentShader = THREE.ShaderChunk.meshphysical_frag; | |
| // Our custom shaders | |
| const fragmentShader = glslify(path.resolve(__dirname, 'standard.frag')); | |
| const vertexShader = glslify(path.resolve(__dirname, 'standard.vert')); |