Skip to content

Instantly share code, notes, and snippets.

@wallabyway
wallabyway / meshdata-ext.js
Created April 6, 2020 18:46
meshdata-ext.js
///////////////////////////////////////////////////////////////////////////////
// MeshData viewer extension
// by Philippe Leefsma, July 2015
//
///////////////////////////////////////////////////////////////////////////////
AutodeskNamespace("Autodesk.ADN.Viewing.Extension");
Autodesk.ADN.Viewing.Extension.MeshData = function (viewer, options) {
Autodesk.Viewing.Extension.call(this, viewer, options);
@wallabyway
wallabyway / forge-api.js
Created April 25, 2020 22:29
quick Forge API class (for nodejs / Lambda / Heroku)
const fetch = require('node-fetch');
const sceneid = `test`;
const FORGEURL = `https://developer.api.autodesk.com`;
class ForgeAPI {
constructor(key, secret, bucket) {
this.key = key;
this.secret = secret;
@wallabyway
wallabyway / labelExtension.js
Last active May 4, 2020 18:21
labelExtension.js
let labelRenderer;
let scene;
class LabelsExtension extends Autodesk.Viewing.Extension {
constructor(viewer, options) {
super(viewer, options);
scene = new THREE.Scene();
}
createLabelsFromDBids(labels) {
/**
* @license twgl.js 0.0.26 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
* Available via the MIT license.
* see: http://github.com/greggman/twgl.js for details
*/
/**
* @license almond 0.3.1 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/almond for details
*/
///////////////////////
//
// LMVToSPD.cpp - An LMV to SPD convertor.
//
//
#include "Config.h"
#include "Log.h"
#include "Translator.h"
#include "Path.h"
/*
* Script for downloading SVF assets from the Model Derivative service.
npm install forge-convert-utils
APS_CLIENT_ID=1234
APS_CLIENT_SECRET=12356
Usage: node download-svf.js <urn> <path/to/output/folder>
*/
const { SvfDownloader } = require('forge-convert-utils');
const { APS_CLIENT_ID, APS_CLIENT_SECRET } = process.env;
@wallabyway
wallabyway / context-menu.ext.js
Last active March 10, 2021 20:04
right click context menu
class CMenuExtension extends Autodesk.Viewing.UI.ObjectContextMenu {
constructor(opts) {
super(opts);
viewer.addEventListener(Autodesk.Viewing.SELECTION_CHANGED_EVENT, e => {
const dbid = viewer.getSelection()[0];
viewer.getProperties(dbid, i => {
this.labels = {
dbid: dbid,
name: i.name
};
@wallabyway
wallabyway / CustomRouter.js
Last active January 22, 2021 01:36
BIM360-Hyprn
/**
* Interface file for customer who want to override or add new API routes
* @example
* router.get("/api/YourAPI", (req, res) => {
* res.send("Hello world.");
* })
* @param {Router} router An express router object
*/
const ForgeSDK = require("forge-apis");
@wallabyway
wallabyway / download-svf-offline.sh
Last active January 25, 2024 15:28
download LMV offline
# run command download.sh
wget --compression=auto -r -i lmvfilelist.txt
mv autodeskviewer.com/viewers/latest/ ./lmv
mv fonts.autodesk.com ./lmv
rm -fr autodeskviewer.com
# Switch Forge logo for ACME Logo
wget https://e7.pngegg.com/pngimages/135/411/png-clipart-acme-markets-havertown-grocery-store-supermarket-retail-others-miscellaneous-angle.png