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
/* globals AFRAME THREE */ | |
AFRAME.registerBrush('spheres', { | |
init: function (color, width) { | |
// Initialize the material based on the stroke color | |
this.material = new THREE.MeshStandardMaterial({ | |
color: this.data.color, | |
roughness: 0.5, | |
metalness: 0.5, | |
side: THREE.DoubleSide, | |
shading: THREE.FlatShading |
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
{ | |
"asset": { | |
"version": "2.0", | |
"generator": "THREE.JS GLTFExporter" | |
}, | |
"scenes": [ | |
{ | |
"nodes": [ | |
0, | |
1, |
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
javascript:(function(){ | |
var link = document.createElement( 'a' ); link.style.display = 'none'; document.body.appendChild( link ); | |
function save( blob, filename ) { link.href = URL.createObjectURL( blob ); link.download = filename; link.click(); } | |
function saveString( text, filename ) { save( new Blob( [ text ], { type: 'application/json' } ), filename );} | |
var script=document.createElement('script'); | |
script.src='https://threejs.org/examples/js/exporters/GLTFExporter.js'; | |
script.onload = function () { | |
var exporter = new THREE.GLTFExporter(); |
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
//----------------------------------------------------------------------------- | |
// Loop measuring delta and total time with perf.now() | |
//----------------------------------------------------------------------------- | |
var prevTime = performance.now(); | |
var total = 0; | |
for (var i=0;i< 1000; i++) { | |
var newTime = performance.now(); | |
var delta = newTime - prevTime; | |
total += delta; | |
prevTime = newTime; |
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
function existsInArray(array, items) { | |
var all = true; | |
for (i = 0; i < items.length; i++) { | |
all &= array.indexOf(items[i]) !== -1; | |
} | |
return all; | |
} | |
if (!existsInArray(['a', 'c'], ['c'])) { |
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
Show hidden characters
{ | |
"ECSY System": { | |
"scope": "javascript", | |
"prefix": "sys", | |
"body": [ | |
"export class ${1:SystemName} extends System {", | |
" init() {", | |
" return {", | |
" queries: {", | |
" ${2:entities}: { components: [${3:Component}] }", |
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
class Vector3 { | |
constructor(x, y, z) { | |
this.set(x,y,z); | |
} | |
copy(src) { | |
this.x = src.x; | |
this.y = src.y; | |
this.z = src.z; | |
} |
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
<html> | |
<head> | |
<script src="https://rawcdn.githack.com/MozillaReality/immersive-custom-elements/v0.1.0/build/immersive-custom-elements.js"></script> | |
</head> | |
<body> | |
<img-360 src="360-landscape.jpg" width="640" height="360"></img-360> | |
<video-360 src="myvideo.mp4" width="640" height="360"></video-360> | |
</body> | |
</html> |
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
var entity = world.createEntity(); | |
// 0 | |
var component = entity.addComponent(ComponentB); | |
component.value = 23; | |
component.other = 'test', | |
// 1 | |
entity.addComponent(ComponentA); | |
entity.addComponent(ComponentB, {value: 23, other: 'test'}); |
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
setInterval(() => window.dispatchEvent(new CustomEvent('refreshData', { 'detail': | |
{ | |
"world": { | |
"enabled": true | |
}, | |
"lastExecutedSystem": "RendererSystem", | |
"numEntities": 18, | |
"systems": [ | |
{ | |
"name": "EnvironmentSystem", |