Skip to content

Instantly share code, notes, and snippets.

View convert-gltf-to-glb.js
var fs = require('fs');
function ConvertToGLB(gltf, outputFilename, sourceFilename) {
const Binary = {
Magic: 0x46546C67
};
const bufferMap = new Map();
function decodeBase64(uri) {
@wallabyway
wallabyway / 3dwood-uvw.js
Created Aug 6, 2021
apply 3D wood prism...
View 3dwood-uvw.js
function ensureMeshUvws(geometry) {
// If mesh has no uvws, generate them by copying the vertex position vectors
// (x,y,z) => (u,v,w). We apply no transform. All geometry loaded by lmvtk uses
// this interleaved vertex buffer approach. We have to get the vertex position
// vectors out of the interleaved vertex buffer.
if (!geometry.getAttribute('uvw')) {
let vbb = ggeom.vb; // should always be 3
View readme.md

Forge Properties API swizzle endpoint

A Proxy Server that provides an alternative Forge Properties API endpoints for your BIM360 content. It does this by replacing any reference of svf2 dbids with svf1 dbids.

Just point your application to this proxy server, and it will swizzle the dbIDs for you, and provide you the matching properties meta-data (prior to the July 1st changes).

Screen Shot 2021-07-26 at 8 01 35 PM

TO INSTALL

View grid.ext.js
// Add GridExtension as a forge-viewer extension, like this:
// viewer = new Autodesk.Viewing.GuiViewer3D(viewerDiv, {extensions: ['GridExtension']});
class GridExtension extends Autodesk.Viewing.Extension {
constructor(viewer, options) {
super(viewer, options);
this.grid = null;
}
load() {
View googlemaps.ext.js
// Load the extension on startup, like this:
// viewer = new Autodesk.Viewing.GuiViewer3D(viewerDiv, {extensions: ['GoogleMapsExtension']});
// Result: https://youtu.be/9kVHlTV8wHw
class GoogleMapsExtension extends Autodesk.Viewing.Extension {
constructor(viewer, options) {
super(viewer, options);
}
quad(x,y) {
const mesh = new THREE.Mesh(
@wallabyway
wallabyway / tagEquipmentToRoom.js
Last active Jun 11, 2021
Run "Tag Equipment To Room". Take a fragmentlist.pack file and list of room dbids, and output a list of object dbids, tagged with room dbids
View tagEquipmentToRoom.js
/*
// INSTALL:
// run the following commands:
// > npm install node-fetch fs-extra aabb-3d
// download a rme-advanced/FragmentList.pack file using https://gist.github.com/wallabyway/51a7bf50f5fe2ec19657278494fcd076
// RUNNING:
// Run this command, and add a comma list of roomIDs, like this:
// > node tagEquipmentToRoom.js [{dbid:9011},{dbid:9261},{dbid:9132}]
// RESULT:
@wallabyway
wallabyway / getRoomsReport.js
Last active May 26, 2021
Nodejs app: Pull list of Rooms from 3DModel, add room properties, and save to report.json file
View getRoomsReport.js
// to install, run this command in a terminal:
// > npm install node-fetch
// now, add your URN, GUID, KEY, SECRET
// To run, type this:
// > node getRoomsReport.js
// see `report.json` as an example output
const fetch = require('node-fetch');
@wallabyway
wallabyway / propertiesdownload.js
Last active Jul 7, 2021
download JSON Properties files
View propertiesdownload.js
// download properties database JSON files
// add your KEY, SECRET and URN
// npm install node-fetch fs-extra
// node propertiesdownload.js
const fetch = require('node-fetch');
const fs = require('fs-extra');
const atob = a => Buffer.from(a, 'base64').toString('binary');
const opts = token => ({ compress: true, headers: { 'Authorization': 'Bearer ' + token }});
@wallabyway
wallabyway / claudia.json
Last active Sep 29, 2021
minimal access-token generator (with AWS-lambda & Claudia.js)
View claudia.json
{
"lambda": {
"role": "web-api-test-executor",
"name": "web-api-test",
"region": "us-east-1"
},
"api": {
"id": "rtvnonbl58",
"module": "web"
}
@wallabyway
wallabyway / import_postgresql.js
Last active Jul 21, 2021
properties db - convert json to postgreSQL or sqliteDB
View import_postgresql.js
/* Pull Properties db files (objects_vals.json.gz _id, _val, _eav, _attr) into postGreSQL database
Example usage:
1. copy your 5 files ( objects_vals.json.gz _id, _val, _eav, _attr) into 'svf' folder
2. > npm install pg readline
3. > node import_postgresql.js
*/
const fs = require('fs');
const path = require('path');