Skip to content

Instantly share code, notes, and snippets.

View leefsmp's full-sized avatar

Philippe Leefsma leefsmp

View GitHub Profile
@leefsmp
leefsmp / re-flex-demo-handle.jsx
Last active June 5, 2018 05:49
Handle ReFlex demo
/////////////////////////////////////////////////////////
// Re-Flex handle element demo
//
/////////////////////////////////////////////////////////
class ReflexHandleDemo
extends React.Component {
render () {
return (
@leefsmp
leefsmp / re-flex-demo-collapse.jsx
Last active February 24, 2021 07:40
Collapse Re-Flex demo
/////////////////////////////////////////////////////////
// Re-Flex Size Collapsible element demo
//
/////////////////////////////////////////////////////////
class CollapsibleElementCls extends React.Component {
componentWillReceiveProps (nextProps) {
if (this.props.onCollapse &&
this.getSize() < this.props.threshold) {
@leefsmp
leefsmp / ReactPie.js
Last active January 9, 2018 05:23
A responsive PieChart in pure React + SVG
/////////////////////////////////////////////////////////
// ReactPie: a responsive PieChart in pure React + SVG
// by Philippe Leefsma, Jan 2017
//
/////////////////////////////////////////////////////////
import PieSegment from './ReactPieSegment'
import ReactTooltip from 'react-tooltip'
import Measure from 'react-measure'
import PropTypes from 'prop-types'
import Stopwatch from 'Stopwatch'
@leefsmp
leefsmp / PointCloudMarkup.js
Last active December 10, 2019 10:01
High-performance markup 3D for Forge Viewer
///////////////////////////////////////////////////////////
// PointCloudMarkup: high-perf markup 3D for Forge Viewer
// by Philippe Leefsma, December 2017
//
///////////////////////////////////////////////////////////
import EventsEmitter from 'EventsEmitter'
import defaultTex from './texture.png'
export default class PointCloudMarkup extends EventsEmitter {
@leefsmp
leefsmp / Viewing.Extension.MeshSelection.js
Created December 4, 2017 05:53
Forge Viewer MeshSelectionExtension
/////////////////////////////////////////////////////////////////////
// MeshSelectionExtension, written by Philippe Leefsma - Dec 2017
//
// Illustrates how to perform double ray casting to detect selection
// of custom meshes added to the scene and handle occlusion with
// Viewer meshes from loaded model.
//
/////////////////////////////////////////////////////////////////////
class MeshSelectionExtension extends Autodesk.Viewing.Extension {
@leefsmp
leefsmp / Viewing.Extension.ViewableSelector.js
Created November 9, 2017 14:52
Creates a React panel to switch between viewable items in a Forge Viewer document
/////////////////////////////////////////////////////////
// Viewing.Extension.ViewableSelector
// by Philippe Leefsma, November 2017
//
/////////////////////////////////////////////////////////
import MultiModelExtensionBase from 'Viewer.MultiModelExtensionBase'
import './Viewing.Extension.ViewableSelector.scss'
import WidgetContainer from 'WidgetContainer'
import ReactTooltip from 'react-tooltip'
import ServiceManager from 'SvcManager'
@leefsmp
leefsmp / MultiModelStructurePanel.js
Last active October 10, 2017 21:48
A patch for Autodesk.Viewing.Extensions.ViewerModelStructurePanel to support multi-models. Just include the script it will override required viewer prototypes
'use strict';
/**
* TreeOnDemand view control
* @constructor
* @param {TreeDelegate} treeDelegate
* @param {Object} root - A node in the model Document
* @param {HTMLElement} parentContainer - DOM element parent of the tree.
* @param {Object} options
*/
@leefsmp
leefsmp / upload.js
Last active October 9, 2017 10:03
Uploading a resumable resource to Forge OSS (node.js)
/////////////////////////////////////////////////////////
// upload resource
//
/////////////////////////////////////////////////////////
router.post('/buckets/:bucketKey',
uploadSvc.uploader.any(),
async(req, res) => {
try {
@leefsmp
leefsmp / uploadObjectChunked.js
Last active August 16, 2022 06:47
Forge resumable upload (node.js)
/////////////////////////////////////////////////////////
// Uploads object to bucket using resumable endpoint
//
/////////////////////////////////////////////////////////
uploadObjectChunked (
getToken,
bucketKey, objectKey,
file,
opts = {}) {
@leefsmp
leefsmp / GeometryIntersectsBox3.js
Created September 25, 2017 12:37
Three.js Geometry/Box3 intersection helper
//From https://github.com/yvt/threejs-geometry-hittest
let norm = new THREE.Vector3()
let t1 = new THREE.Vector3()
let t2 = new THREE.Vector3()
let depth = 0
function checkBoxSeparation(
phase,
minX, minY, minZ,