Skip to content

Instantly share code, notes, and snippets.

Joe Pea trusktr

View GitHub Profile
View three.js-utils.ts
import * as THREE from 'three'
export function isRenderItem(obj: THREE.Object3D): obj is THREE.RenderItem & THREE.Object3D {
return 'geometry' in obj && 'material' in obj
}
export function disposeMaterial(obj: THREE.Object3D): void {
if (!isRenderItem(obj)) return
// because obj.material can be a material or an array of materials
@trusktr
trusktr / obliterate.js
Created Feb 20, 2019
Obliterate an object
View obliterate.js
// recursively deletes all properties within an `object` or `function`
// TODO option to also handle non-enumerable but configurable descriptors
function obliterate(obj: object) {
const visited = new WeakSet
_obliterate(obj)
async function _obliterate(obj) {
if (!obj || !(typeof obj === 'object' || typeof obj === 'function')) return
@trusktr
trusktr / example.js
Last active Nov 18, 2018
Access Modifiers 1
View example.js
class Foo {
foo = 1
protected bar = 2
private baz = 3
public test() {
// call all three of the log methods, one from each access space.
console.log('---- public log 2')
this.log()
console.log('---- protected log 2')
@trusktr
trusktr / next.config.js
Created Sep 20, 2018
withTranspileModules example
View next.config.js
const path = require("path");
const withTypescript = require("@zeit/next-typescript");
const withCSS = require("@zeit/next-css");
const withSourceMaps = require("@zeit/next-source-maps");
const r = require("regexr");
const cssConfig = {
cssModules: false
};
@trusktr
trusktr / es5-extend-array.js
Last active Sep 3, 2018
Extending Array with ES5-style class constructors
View es5-extend-array.js
// With some ES2015+ language features:**
{
function MyArray(...args) {
const self = new Array(...args)
self.__proto__ = MyArray.__proto__
return self
}
MyArray.prototype = {
__proto__: Array.prototype,
View infamous.8732763c5.js
This file has been truncated, but you can view the full file.
var infamous = (function (exports) {
'use strict';
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function unwrapExports (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
View three.trusktr-patch-7.js
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.THREE={})}(this,function(t){"use strict";function e(){}function i(t,e){this.x=t||0,this.y=e||0}function n(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function r(t,e,i,n){this._x=t||0,this._y=e||0,this._z=i||0,this._w=void 0!==n?n:1}function a(t,e,i){this.x=t||0,this.y=e||0,this.z=i||0}function o(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function s(t,e,n,r,a,c,h,l,u,p){Object.defineProperty(this,"id",{value:Lo++}),this.uuid=Ro.generateUUID(),this.name="",this.image=void 0!==t?t:s.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:s.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:Pa,this.wrapT=void 0!==r?r:Pa,this.magFilter=void 0!==a?a:Oa,this.min
View infamous.a735f17.js
var infamous = (function (exports) {
'use strict';
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Owner: mark@famo.us
* @license MPL 2.0
* @copyright Famous Industries, Inc. 2015
View infamous.a735f17.js
var infamous = (function (exports) {
'use strict';
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Owner: mark@famo.us
* @license MPL 2.0
* @copyright Famous Industries, Inc. 2015
View infamous.a735f17.js
var infamous = (function (exports) {
'use strict';
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Owner: mark@famo.us
* @license MPL 2.0
* @copyright Famous Industries, Inc. 2015
You can’t perform that action at this time.