Last active
September 22, 2022 09:12
-
-
Save coderofsalvation/c11903dc247452d36540f75f3cb07f68 to your computer and use it in GitHub Desktop.
Revisions
-
coderofsalvation revised this gist
Sep 22, 2022 . 1 changed file with 20 additions and 20 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,31 +5,31 @@ * 'aabb-collider':{ "*": 150 }, * 'texturescroll':{ "*": 50 }, * 'foo': { "*": AFRAME.utils.device.isMobile() ? 150 : 50 } * }, true) * */ AFRAME.utils.throttleTicks = (opts, debug) => { for ( let i in AFRAME.components ) { let com = AFRAME.components[i] let opt = opts[i] let proto = com.Component.prototype if( opt && proto.tick ){ proto.init = function(init){ return function(){ init.apply(this, arguments) this.tickOrig = this.tick this.throttleTicks = {} for ( let i in opt ) this.throttleTicks[i] = AFRAME.utils.throttleTick(this.tickOrig, opt[i], this ) this.tick = function(t, dt){ let f = this.throttleTicks[ '#'+String(this.el.id ) ] || this.throttleTicks[ '.'+String(this.el.className) ] || this.throttleTicks[ '*' ] f(t, dt) } } }(proto.init) }else if(debug && proto.tick) console.warn(`throttleTicks: ${i} was not specified`) } } -
coderofsalvation revised this gist
Sep 22, 2022 . No changes.There are no files selected for viewing
-
coderofsalvation revised this gist
Sep 22, 2022 . No changes.There are no files selected for viewing
-
coderofsalvation renamed this gist
Sep 22, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
coderofsalvation revised this gist
Sep 22, 2022 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,6 @@ AFRAME.utils.throttleTicks = (opts) => { let opt = opts[i] let proto = com.Component.prototype if( opt && proto.tick ){ proto.init = function(init){ return function(){ init.apply(this, arguments) -
coderofsalvation revised this gist
Sep 22, 2022 . 1 changed file with 24 additions and 29 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,41 +1,36 @@ /* * Usage: * * AFRAME.utils.throttleTicks({ * 'aabb-collider':{ "*": 150 }, * 'texturescroll':{ "*": 50 }, * 'foo': { "*": AFRAME.utils.device.isMobile() ? 150 : 50 } * }) * */ AFRAME.utils.throttleTicks = (opts) => { for ( let i in AFRAME.components ) { let com = AFRAME.components[i] let opt = opts[i] let proto = com.Component.prototype if( opt && proto.tick ){ console.log("throttleTicks: "+i) proto.init = function(init){ return function(){ init.apply(this, arguments) this.tickOrig = this.tick this.throttleTicks = {} for ( let i in opt ) this.throttleTicks[i] = AFRAME.utils.throttleTick(this.tickOrig, opt[i], this ) this.tick = function(t, dt){ let f = this.throttleTicks[ '#'+String(this.el.id ) ] || this.throttleTicks[ '.'+String(this.el.className) ] || this.throttleTicks[ '*' ] f(t, dt) } } }(proto.init) } } } -
coderofsalvation revised this gist
Sep 22, 2022 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,8 @@ * <script> * AFRAME.utils.throttleTicks({ * 'aabb-collider':{ "*": 150 }, * 'texturescroll':{ "*": 50 }, * 'foo': { "*": AFRAME.utils.device.isMobile() ? 150 : 50 } * }) * </script> * <!-- include components afterwards --> -
coderofsalvation revised this gist
Sep 22, 2022 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,15 @@ /* * Usage: * * <script src="aframe.min.js"></script> * <script> * AFRAME.utils.throttleTicks({ * 'aabb-collider':{ "*": 150 }, * 'texturescroll':{ "*": 50 } * }) * </script> * <!-- include components afterwards --> * <script src="aframe-components.js"></script> * */ -
coderofsalvation revised this gist
Sep 22, 2022 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -22,8 +22,10 @@ AFRAME.utils.throttleTicks = (opts) => { for ( let i in opt ) this.throttleTicks[i] = AFRAME.utils.throttleTick(this.tickOrig, opt[i], this ) this.tick = function(t, dt){ let f = this.throttleTicks[ '#'+String(this.el.id ) ] || this.throttleTicks[ '.'+String(this.el.className) ] || this.throttleTicks[ '*' ] f(t, dt) } } }(impl.init) -
coderofsalvation revised this gist
Sep 22, 2022 . No changes.There are no files selected for viewing
-
coderofsalvation revised this gist
Sep 22, 2022 . No changes.There are no files selected for viewing
-
coderofsalvation created this gist
Sep 22, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ /* * Usage: * * // run this in global scope somewhere * AFRAME.utils.throttleTicks({ * 'aabb-collider':{ "*": 150 }, * 'texturescroll':{ "*": 50 } * }) * */ AFRAME.utils.throttleTicks = (opts) => { AFRAME.registerComponent = ( (registerComponent, opts) => function(component, impl){ let opt = opts[component] if( opt && impl.tick ){ impl.init = function(init){ return function(){ init.apply(this, arguments) this.tickOrig = this.tick this.throttleTicks = {} for ( let i in opt ) this.throttleTicks[i] = AFRAME.utils.throttleTick(this.tickOrig, opt[i], this ) this.tick = function(t, dt){ let f = this.throttleTicks[ '#'+this.el.id ] || this.throttleTicks[ '*' ] f(t, dt) } } }(impl.init) }else if( impl.tick ) console.warn(`AFRAME.util.throttleTicks: component '${component}' not specified`) registerComponent.apply(AFRAME, arguments) } )(AFRAME.registerComponent,opts) }