New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

stl-viewer

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stl-viewer - npm Package Compare versions

Comparing version 0.0.7 to 0.1.0

73

dist/STLViewer.js

@@ -17,2 +17,6 @@ 'use strict';

var _ScaleLoader = require('halogen/ScaleLoader');
var _ScaleLoader2 = _interopRequireDefault(_ScaleLoader);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -45,5 +49,2 @@

var url = _props.url;
var xDims = _props.xDims;
var yDims = _props.yDims;
var zDims = _props.zDims;
var width = _props.width;

@@ -54,6 +55,11 @@ var height = _props.height;

var xDims = undefined,
yDims = undefined,
zDims = undefined;
var component = this;
var hexBackgroundColor = parseInt(backgroundColor.replace(/^#/, ''), 16);
var hexModelColor = parseInt(modelColor.replace(/^#/, ''), 16);
init();
animate();

@@ -85,2 +91,7 @@ /**

}));
// Set the object's dimensions
geometry.computeBoundingBox();
xDims = geometry.boundingBox.max.x - geometry.boundingBox.min.x;
yDims = geometry.boundingBox.max.y - geometry.boundingBox.min.y;
zDims = geometry.boundingBox.max.z - geometry.boundingBox.min.z;

@@ -90,16 +101,19 @@ mesh.rotation.x = 5;

scene.add(mesh);
});
// Add the camera
camera = new _Three2.default.PerspectiveCamera(30, width / height, 1, distance);
camera.position.set(0, 0, Math.max(xDims * 3, yDims * 3, zDims * 3));
// Add the camera
camera = new _Three2.default.PerspectiveCamera(30, width / height, 1, distance);
camera.position.set(0, 0, Math.max(xDims * 3, yDims * 3, zDims * 3));
scene.add(camera);
scene.add(camera);
renderer = new _Three2.default.WebGLRenderer(); //new THREE.CanvasRenderer();
renderer.setSize(width, height);
renderer.setClearColor(backgroundColor, 1);
renderer = new _Three2.default.WebGLRenderer(); //new THREE.CanvasRenderer();
renderer.setSize(width, height);
renderer.setClearColor(backgroundColor, 1);
// Add to the React Component
_reactDom2.default.findDOMNode(component).appendChild(renderer.domElement);
// Add to the React Component
_reactDom2.default.findDOMNode(component).replaceChild(renderer.domElement, _reactDom2.default.findDOMNode(component).firstChild);
// Start the animation
animate();
});
}

@@ -132,3 +146,19 @@

value: function render() {
return _react2.default.createElement('div', { className: this.props.className });
var _props2 = this.props;
var width = _props2.width;
var height = _props2.height;
var modelColor = _props2.modelColor;
return _react2.default.createElement(
'div',
{
className: this.props.className,
style: { width: width, height: height }
},
_react2.default.createElement(
'div',
{ style: { textAlign: 'center', marginTop: height / 2 - 8 } },
_react2.default.createElement(_ScaleLoader2.default, { color: modelColor, size: '16px' })
)
);
}

@@ -143,12 +173,15 @@ }]);

url: _react.PropTypes.string,
xDims: _react.PropTypes.number,
yDims: _react.PropTypes.number,
zDims: _react.PropTypes.number,
width: _react.PropTypes.number,
height: _react.PropTypes.number,
backgroundColor: _react.PropTypes.number,
modelColor: _react.PropTypes.number
backgroundColor: _react.PropTypes.string,
modelColor: _react.PropTypes.string
};
STLViewer.defaultProps = {
backgroundColor: '#EAEAEA',
modelColor: '#B92C2C',
height: 400,
width: 400
};
;
module.exports = STLViewer;
{
"name": "stl-viewer",
"version": "0.0.7",
"version": "0.1.0",
"description": "A component for viewing an STL object from a given URL.",

@@ -22,7 +22,12 @@ "main": "dist/STLViewer.js",

"dependencies": {
"three": "^0.72.0",
"react": "^0.14.0",
"react-dom": "^0.14.0"
"halogen": "^0.1.10",
"three": "^0.72.0"
},
"peerDependencies": {
"react": ">=0.14.0",
"react-dom": ">=0.14.0"
},
"devDependencies": {
"react": "^0.14.0",
"react-dom": "^0.14.0",
"babel-cli": "^6.3.17",

@@ -46,5 +51,3 @@ "babel-core": "^6.3.17",

"query-string": "^3.0.0",
"react": "^0.14.0",
"react-addons-test-utils": "^0.14.0",
"react-dom": "^0.14.0",
"react-transform-catch-errors": "^1.0.0",

@@ -51,0 +54,0 @@ "react-transform-hmr": "^1.0.1",

@@ -14,5 +14,2 @@ import React, {Component} from 'react';

url: query.url || 'http://localhost:4001/static/bottle.stl',
xDims: parseInt(query.xDims, 10) || 53,
yDims: parseInt(query.yDims, 10) || 85,
zDims: parseInt(query.zDims, 10) || 27,
};

@@ -22,18 +19,9 @@ }

render(){
const { url, xDims, yDims, zDims } = this.state;
console.dir(this.state);
const { url } = this.state;
return (
<div>
<STLViewer
url={url}
xDims={xDims}
yDims={yDims}
zDims={zDims}
width={400}
height={400}
modelColor={0x005B83}
backgroundColor={0xEAEAEA}
/>
<STLViewer url={url} />
<div><a href="http://localhost:4001">Example A</a></div>
<div><a href="http://localhost:4001/?url=http://localhost:4001/static/crazy-thing.stl&width=400&height=400&xDims=146&yDims=106&zDims=78">Example B</a></div>
<div><a href="http://localhost:4001/?url=http://localhost:4001/static/crazy-thing.stl">Example B</a></div>
</div>

@@ -40,0 +28,0 @@ );

# STL Viewer
A component for viewing an STL object from a given URL. Currently you will need to enter the x,y and z dimensions of the object as well. In the future, this will not be needed
A component for viewing an STL object from a given URL.
*Note that you will still have to abide by the rules of CORS*
# Installation

@@ -12,2 +14,6 @@

<STLViewer url='http://www.example.com/example-url.stl' xDims={10} yDims={10} zDims={10} width={150} height={150} modelColor={0x005B83} backgroundColor={0xEAEAEA} />
<STLViewer url='http://www.example.com/example-url.stl'
width={150} height={150}
modelColor='#005B83'
backgroundColor='#EAEAEA'
/>
import React, { PropTypes, Component } from 'react';
import ReactDOM from 'react-dom';
import THREE from './Three';
import Loader from 'halogen/ScaleLoader';

@@ -9,18 +10,25 @@ class STLViewer extends Component {

url: PropTypes.string,
xDims: PropTypes.number,
yDims: PropTypes.number,
zDims: PropTypes.number,
width: PropTypes.number,
height: PropTypes.number,
backgroundColor: PropTypes.number,
modelColor: PropTypes.number,
backgroundColor: PropTypes.string,
modelColor: PropTypes.string,
};
static defaultProps = {
backgroundColor: '#EAEAEA',
modelColor: '#B92C2C',
height: 400,
width: 400,
};
componentDidMount() {
let camera, scene, renderer, mesh, distance;
let { url, xDims, yDims, zDims, width, height, modelColor, backgroundColor } = this.props;
let { url, width, height, modelColor, backgroundColor } = this.props;
let xDims, yDims, zDims;
let component = this;
let hexBackgroundColor = parseInt(backgroundColor.replace(/^#/, ''), 16);
let hexModelColor = parseInt(modelColor.replace(/^#/, ''), 16);
init();
animate();

@@ -55,2 +63,7 @@ /**

));
// Set the object's dimensions
geometry.computeBoundingBox();
xDims = geometry.boundingBox.max.x - geometry.boundingBox.min.x;
yDims = geometry.boundingBox.max.y - geometry.boundingBox.min.y;
zDims = geometry.boundingBox.max.z - geometry.boundingBox.min.z;

@@ -60,16 +73,20 @@ mesh.rotation.x = 5;

scene.add( mesh );
});
// Add the camera
camera = new THREE.PerspectiveCamera( 30, width / height, 1, distance );
camera.position.set(0,0,Math.max(xDims*3,yDims*3,zDims*3));
// Add the camera
camera = new THREE.PerspectiveCamera( 30, width / height, 1, distance );
camera.position.set(0,0,Math.max(xDims*3,yDims*3,zDims*3));
scene.add( camera );
scene.add( camera );
renderer = new THREE.WebGLRenderer(); //new THREE.CanvasRenderer();
renderer.setSize( width, height );
renderer.setClearColor(backgroundColor, 1);
renderer = new THREE.WebGLRenderer(); //new THREE.CanvasRenderer();
renderer.setSize( width, height );
renderer.setClearColor(backgroundColor, 1);
// Add to the React Component
ReactDOM.findDOMNode(component).appendChild( renderer.domElement );
// Add to the React Component
ReactDOM.findDOMNode(component).replaceChild( renderer.domElement,
ReactDOM.findDOMNode(component).firstChild);
// Start the animation
animate();
});
}

@@ -101,4 +118,12 @@

render() {
const {width, height, modelColor} = this.props;
return(
<div className={this.props.className}>
<div
className={this.props.className}
style={{ width: width, height: height }}
>
<div style={{textAlign: 'center', marginTop: height/2 - 8 }} >
<Loader color={modelColor} size="16px" />
</div>
</div>

@@ -105,0 +130,0 @@ );

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc