Skip to content

Instantly share code, notes, and snippets.

@drcmda
drcmda / .js
Created March 1, 2016 18:08
awv3.es2015, stage-0 async/await
import Canvas from 'canvas';
import * as parser from 'parser';
let canvas = new Canvas({
dom: document.querySelector('#main')
});
let blob = {command: "Blob", data: "GQaÉPB3*Ì¥Jj5£D)3.cF¼´NE0©«p|S·D©t¨0;07BpÎÌFC·63.©S¢WkÍÀÄ^gg6ÁP£9Ä$xÃmÊ·¢|cÆ!º%~ÆWa[¼MsLÅmxÊv}oN¡qL.ÆƤZ!Iu¤6Z2UµPxVx,°¤¢«O²¤¹H=¡l´.¼o~Ãh]À3·]q·lc6:{}TÁuC¡¢1^·QP¥AG¸ÎËJ¸R¨Á¨M(®MÌBK1B|t³ËZ@²l§9Âv®M7%Ev¡@vB¨ÂP¸¦ZL¿MSr66[§Ã¯F%=q¨KNCf$N½9_xQ*§goÃb7dµ4¼²W~7h}2duNJW*U¤À4±È=¨XF2Ì¢FfInP¡H¼JºUÈ._¡²L7¼]GD±Ç¿¼;«dVAM[F«]VÎË#g%´¾Ä¸¸a3ËavÄ$¼Fzz®Q¡¸®_Â}¸»k¢Pc¹:@Ì6¢D1G©$cz:1S~O6ËqI³S¥@XM©Olw%f@w·GÃLÆ¥³qzQIGA5¨@r¶FDUL¢¥T¥3¼^aHzoºÍW][OH³gdÇ)!", length: 1093};
// Add views, etc.
@drcmda
drcmda / .js
Created March 14, 2016 09:19
awv3.modules/es6
import 'requestidlecallback';
import Canvas from 'canvas';
import View from 'view';
import Object3 from 'three/object3';
import { Performance } from 'helpers/misc';
// Create new canvas
const canvas = new Canvas({ dom: '#main' });
// Create a view, defaults into the same dom as the canvas
const view = new View(canvas, { ambient: 0x909090 });
@drcmda
drcmda / .js
Created March 14, 2016 09:19
awv3.modules/es6
import 'requestidlecallback';
import Canvas from 'canvas';
import View from 'view';
import Object3 from 'three/object3';
import { Performance } from 'helpers/misc';
// Create new canvas
const canvas = new Canvas({ dom: '#main' });
// Create a view, defaults into the same dom as the canvas
const view = new View(canvas, { ambient: 0x909090 });
@drcmda
drcmda / .js
Created March 14, 2016 11:39
interaction draft
let { firstModel } = await canvas.parser.stream('/assembly.txt'));
firstModel.interaction.recursive = true;
firstModel.interaction.listen("hover", object => console.log(`%{object.name}: hover`);
let secondListener = firstModel.interaction.listen("hover", object => console.log(`2nd callback %{object.name}: hover`);
firstModel.interaction.listen("unhover", object => console.log(`%{object.name}: unhover`);
firstModel.interaction.listen("drag", (object, type) => {
switch (type) {
case 'start': console.log(`%{object.name}: drag started`; break;
case 'drag': console.log(`%{object.name}: dragging`; break;
case 'end':
@drcmda
drcmda / .js
Created March 15, 2016 16:30
new gist
import 'requestidlecallback';
import Canvas from 'canvas';
import View from 'view';
import Object3 from 'three/object3';
import Animation from 'animation';
import { Performance } from 'helpers/misc';
// Create new canvas
const canvas = new Canvas({ dom: '#main' });
// Create a view, defaults into the same dom as the canvas
@drcmda
drcmda / *.js
Last active March 21, 2016 15:05
client assembly via custom factory first draft
// Application ------------------------------------------------------------------------
import AssemblyFactory from 'factory/assembly'
// Create factory, link it to the scene, or whereever models are stored in the application
let factory = new AssemblyFactory(scene);
// Request a table
server.request('_O.CreateTable()', factory);
// Request a clone
server.request('_O.Clone(0)', factory);
import Parser from 'parser';
export default class {
constructor(pool) {
this.pool = pool;
return attribs => {
switch (attribs.type) {
case Parser.Factory.Link:
let { ref, matrix } = attribs.data;
[
{ "type": "Geometry", "name": "Tischplatte", "id": 6, "data": [base128], "meta": {} },
{ "type": "Geometry", "name": "Tischbein", "id": 7, "data": [base128], "meta": {} },
{ "type": "Model", "name": "Tisch", "id": 8,
"data":[
{ "type": "Link", "ref": "Tischplatte", "matrix": [0,0,0], "meta": {} },
{ "type": "Link", "ref": "Tischbein", "matrix": [0,0,0], "meta": {} },
{ "type": "Link", "ref": "Tischbein", "matrix": [0,10,0], "meta": {} },
{ "type": "Link", "ref": "Tischbein", "matrix": [10,0,0], "meta": {} },
@drcmda
drcmda / .js
Created July 8, 2016 09:54
toolbuilder
// 'url', default URL, depends on the analyzer running online or local
// 'Canvas', 'View', 'SocketIO' & 'Object3' from AWV3-next
// 'log' (.start(), .stop(message) & .printResults(string || object))
log.start();
let tasks = [];
let task = new SocketIO().connect(url).then(connection => {
// Clear scene
@drcmda
drcmda / .js
Last active July 20, 2016 12:37
plugin archtitecture
// import and create canvs
import Canvas from 'awv3';
const canvas = new Canvas({ dom: '#view' });
// import plugins, they should be separate from the awv3-repo
import Sketcher from 'awv3-sketcher';
import Extrusion from 'awv3-extrusion';
import Measuring from 'awv3-measuring';
// create measure layer, "use" it Node style