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.5.0 to 0.6.0

dist/Paint.js

503

dist/STLViewer.js

@@ -9,14 +9,12 @@ 'use strict';

var _reactDom = require('react-dom');
var _propTypes = require('prop-types');
var _reactDom2 = _interopRequireDefault(_reactDom);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _Three = require('./Three');
var _halogenium = require('halogenium');
var _Three2 = _interopRequireDefault(_Three);
var _Paint = require('./Paint');
var _ScaleLoader = require('halogen/ScaleLoader');
var _Paint2 = _interopRequireDefault(_Paint);
var _ScaleLoader2 = _interopRequireDefault(_ScaleLoader);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -30,334 +28,221 @@

var OrbitControls = require('three-orbit-controls')(_Three2.default);
var STLViewer = function (_Component) {
_inherits(STLViewer, _Component);
_inherits(STLViewer, _Component);
function STLViewer() {
_classCallCheck(this, STLViewer);
function STLViewer() {
_classCallCheck(this, STLViewer);
return _possibleConstructorReturn(this, (STLViewer.__proto__ || Object.getPrototypeOf(STLViewer)).apply(this, arguments));
}
return _possibleConstructorReturn(this, (STLViewer.__proto__ || Object.getPrototypeOf(STLViewer)).apply(this, arguments));
}
_createClass(STLViewer, [{
key: 'componentDidMount',
value: function componentDidMount() {
var _this2 = this;
_createClass(STLViewer, [{
key: 'componentDidMount',
value: function componentDidMount() {
var _this2 = this;
var camera = void 0,
scene = void 0,
renderer = void 0,
mesh = void 0,
distance = void 0,
controls = void 0;
var _props = this.props,
url = _props.url,
width = _props.width,
height = _props.height,
modelColor = _props.modelColor,
backgroundColor = _props.backgroundColor,
orbitControls = _props.orbitControls;
var camera = void 0,
scene = void 0,
renderer = void 0,
mesh = void 0,
distance = void 0,
controls = void 0;
var _props = this.props,
url = _props.url,
width = _props.width,
height = _props.height,
modelColor = _props.modelColor,
backgroundColor = _props.backgroundColor,
orbitControls = _props.orbitControls;
var xDims = void 0,
yDims = void 0,
zDims = void 0;
var component = this;
var rotate = this.props.rotate;
var xDims = void 0,
yDims = void 0,
zDims = void 0;
var component = this;
var rotate = this.props.rotate;
var paint = new _Paint2.default(this);
init();
init();
/**
* The init method for the 3D scene
* @returns {void}
*/
function init() {
//Detector.addGetWebGLMessage();
scene = new _Three2.default.Scene();
distance = 10000;
var directionalLight = new _Three2.default.DirectionalLight(0xffffff);
directionalLight.position.x = 0;
directionalLight.position.y = 0;
directionalLight.position.z = 1;
directionalLight.position.normalize();
scene.add(directionalLight);
/**
* The init method for the 3D scene
* @returns {void}
*/
function init() {
paint.init();
}
var loader = new _Three2.default.STLLoader();
loader.crossOrigin = '';
loader.load(url, function (geometry) {
/**
* Animate the scene
* @returns {void}
*/
var animate = function animate() {
// note: three.js includes requestAnimationFrame shim
if (rotate) {
requestAnimationFrame(animate);
}
if (_this2.props.orbitControls) {
controls.update();
}
render();
};
// Calculate mesh noramls for MeshLambertMaterial.
geometry.computeFaceNormals();
geometry.computeVertexNormals();
/**
* Render the scene after turning off the rotation
* @returns {void}
*/
var orbitRender = function orbitRender() {
if (rotate) {
rotate = false;
}
// Center the object
geometry.center();
render();
};
mesh = new _Three2.default.Mesh(geometry, new _Three2.default.MeshLambertMaterial({
overdraw: true,
color: modelColor
}));
// 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;
if (rotate) {
mesh.rotation.x = 5;
mesh.rotation.z = .25;
}
scene.add(mesh);
/**
* Render the scene
* @returns {void}
*/
var render = function render() {
if (mesh && rotate) {
mesh.rotation.z += 0.02;
}
// 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));
renderer.render(scene, camera);
};
}
}, {
key: 'shouldComponentUpdate',
value: function shouldComponentUpdate(nextProps, nextState) {
if (JSON.stringify(nextProps) === JSON.stringify(this.props)) {
return false;
}
return true;
}
}, {
key: 'componentWillUpdate',
value: function componentWillUpdate(nextProps, nextState) {
var camera = void 0,
scene = void 0,
renderer = void 0,
mesh = void 0,
distance = void 0,
controls = void 0;
var url = nextProps.url,
width = nextProps.width,
height = nextProps.height,
modelColor = nextProps.modelColor,
backgroundColor = nextProps.backgroundColor,
orbitControls = nextProps.orbitControls;
scene.add(camera);
var xDims = void 0,
yDims = void 0,
zDims = void 0;
var component = this;
var rotate = nextProps.rotate;
renderer = new _Three2.default.WebGLRenderer(); //new THREE.CanvasRenderer();
renderer.setSize(width, height);
renderer.setClearColor(backgroundColor, 1);
this.props = nextProps;
var paint = new _Paint2.default(this);
// Add controls for mouse interaction
if (orbitControls) {
controls = new OrbitControls(camera, _reactDom2.default.findDOMNode(component));
controls.enableKeys = false;
controls.addEventListener('change', orbitRender);
}
init();
// Add to the React Component
_reactDom2.default.findDOMNode(component).replaceChild(renderer.domElement, _reactDom2.default.findDOMNode(component).firstChild);
/**
* The init method for the 3D scene
* @returns {void}
*/
function init() {
paint.init();
}
// Start the animation
animate();
});
}
/**
* Animate the scene
* @returns {void}
*/
var animate = function animate() {
// note: three.js includes requestAnimationFrame shim
if (rotate) {
requestAnimationFrame(animate);
}
if (nextProps.orbitControls) {
controls.update();
}
render();
};
/**
* Animate the scene
* @returns {void}
*/
var animate = function animate() {
// note: three.js includes requestAnimationFrame shim
if (rotate) {
requestAnimationFrame(animate);
}
if (_this2.props.orbitControls) {
controls.update();
}
render();
};
/**
* Render the scene after turning off the rotation
* @returns {void}
*/
var orbitRender = function orbitRender() {
if (rotate) {
rotate = false;
}
/**
* Render the scene after turning off the rotation
* @returns {void}
*/
var orbitRender = function orbitRender() {
if (rotate) {
rotate = false;
}
render();
};
render();
};
/**
* Render the scene
* @returns {void}
*/
var render = function render() {
if (mesh && rotate) {
mesh.rotation.z += 0.02;
}
/**
* Render the scene
* @returns {void}
*/
var render = function render() {
if (mesh && rotate) {
mesh.rotation.z += 0.02;
}
renderer.render(scene, camera);
};
}
}, {
key: 'render',
value: function render() {
var _props2 = this.props,
width = _props2.width,
height = _props2.height,
modelColor = _props2.modelColor;
renderer.render(scene, camera);
};
}
}, {
key: 'shouldComponentUpdate',
value: function shouldComponentUpdate(nextProps, nextState) {
if (JSON.stringify(nextProps) === JSON.stringify(this.props)) {
return false;
}
return true;
}
}, {
key: 'componentWillUpdate',
value: function componentWillUpdate(nextProps, nextState) {
var camera = void 0,
scene = void 0,
renderer = void 0,
mesh = void 0,
distance = void 0,
controls = void 0;
var url = nextProps.url,
width = nextProps.width,
height = nextProps.height,
modelColor = nextProps.modelColor,
backgroundColor = nextProps.backgroundColor,
orbitControls = nextProps.orbitControls;
var xDims = void 0,
yDims = void 0,
zDims = void 0;
var component = this;
var rotate = nextProps.rotate;
return _react2.default.createElement(
'div',
{
className: this.props.className,
style: {
width: width,
height: height,
overflow: 'hidden'
}
},
_react2.default.createElement(
'div',
{ style: {
height: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center'
} },
_react2.default.createElement(_halogenium.ScaleLoader, { color: modelColor, size: '16px' })
)
);
}
}]);
init();
/**
* The init method for the 3D scene
* @returns {void}
*/
function init() {
//Detector.addGetWebGLMessage();
scene = new _Three2.default.Scene();
distance = 10000;
var directionalLight = new _Three2.default.DirectionalLight(0xffffff);
directionalLight.position.x = 0;
directionalLight.position.y = 0;
directionalLight.position.z = 1;
directionalLight.position.normalize();
scene.add(directionalLight);
var loader = new _Three2.default.STLLoader();
loader.crossOrigin = '';
loader.load(url, function (geometry) {
// Calculate mesh noramls for MeshLambertMaterial.
geometry.computeFaceNormals();
geometry.computeVertexNormals();
// Center the object
geometry.center();
mesh = new _Three2.default.Mesh(geometry, new _Three2.default.MeshLambertMaterial({
overdraw: true,
color: modelColor
}));
// 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;
if (rotate) {
mesh.rotation.x = 5;
mesh.rotation.z = .25;
}
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));
scene.add(camera);
renderer = new _Three2.default.WebGLRenderer(); //new THREE.CanvasRenderer();
renderer.setSize(width, height);
renderer.setClearColor(backgroundColor, 1);
// Add controls for mouse interaction
if (orbitControls) {
controls = new OrbitControls(camera, _reactDom2.default.findDOMNode(component));
controls.addEventListener('change', orbitRender);
}
// Add to the React Component
_reactDom2.default.findDOMNode(component).replaceChild(renderer.domElement, _reactDom2.default.findDOMNode(component).firstChild);
// Start the animation
animate();
});
}
/**
* Animate the scene
* @returns {void}
*/
var animate = function animate() {
// note: three.js includes requestAnimationFrame shim
if (rotate) {
requestAnimationFrame(animate);
}
if (nextProps.orbitControls) {
controls.update();
}
render();
};
/**
* Render the scene after turning off the rotation
* @returns {void}
*/
var orbitRender = function orbitRender() {
if (rotate) {
rotate = false;
}
render();
};
/**
* Render the scene
* @returns {void}
*/
var render = function render() {
if (mesh && rotate) {
mesh.rotation.z += 0.02;
}
renderer.render(scene, camera);
};
}
}, {
key: 'render',
value: function render() {
var _props2 = this.props,
width = _props2.width,
height = _props2.height,
modelColor = _props2.modelColor;
return _react2.default.createElement(
'div',
{
className: this.props.className,
style: {
width: width,
height: height,
overflow: 'hidden'
}
},
_react2.default.createElement(
'div',
{ style: {
height: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center'
} },
_react2.default.createElement(_ScaleLoader2.default, { color: modelColor, size: '16px' })
)
);
}
}]);
return STLViewer;
return STLViewer;
}(_react.Component);
STLViewer.propTypes = {
className: _react.PropTypes.string,
url: _react.PropTypes.string,
width: _react.PropTypes.number,
height: _react.PropTypes.number,
backgroundColor: _react.PropTypes.string,
modelColor: _react.PropTypes.string,
rotate: _react.PropTypes.bool,
orbitControls: _react.PropTypes.bool
className: _propTypes2.default.string,
url: _propTypes2.default.string,
width: _propTypes2.default.number,
height: _propTypes2.default.number,
backgroundColor: _propTypes2.default.string,
modelColor: _propTypes2.default.string,
rotate: _propTypes2.default.bool,
orbitControls: _propTypes2.default.bool
};
STLViewer.defaultProps = {
backgroundColor: '#EAEAEA',
modelColor: '#B92C2C',
height: 400,
width: 400,
rotate: true,
orbitControls: true
backgroundColor: '#EAEAEA',
modelColor: '#B92C2C',
height: 400,
width: 400,
rotate: true,
orbitControls: true
};

@@ -364,0 +249,0 @@ ;

{
"name": "stl-viewer",
"version": "0.5.0",
"version": "0.6.0",
"description": "A component for viewing an STL object from a given URL by utilizing Three.js",

@@ -27,3 +27,4 @@ "main": "dist/STLViewer.js",

"dependencies": {
"halogen": "^0.1.10",
"halogenium": "^2.2.3",
"prop-types": "^15.6.1",
"three": "^0.72.0",

@@ -33,8 +34,6 @@ "three-orbit-controls": "^72.0.0"

"peerDependencies": {
"react": ">=0.14.0",
"react-dom": ">=0.14.0"
"react": ">=16.2.0",
"react-dom": ">=16.2.0"
},
"devDependencies": {
"react": "^0.14.0",
"react-dom": "^0.14.0",
"babel-cli": "^6.3.17",

@@ -58,6 +57,7 @@ "babel-core": "^6.3.15",

"query-string": "^3.0.0",
"react-addons-test-utils": "^0.14.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-transform-catch-errors": "^1.0.0",
"react-transform-hmr": "^1.0.1",
"redbox-react": "^1.0.1",
"redbox-react": "^1.5.0",
"rimraf": "^2.4.3",

@@ -64,0 +64,0 @@ "webpack": "^1.12.2",

@@ -1,26 +0,26 @@

import React, {Component} from 'react';
import React, { Component } from 'react';
import STLViewer from '../../src/STLViewer';
class App extends Component{
constructor(props) {
super(props)
this.state = {
color: '#FF0000'
}
class App extends Component {
constructor(props) {
super(props)
this.state = {
color: '#FF0000'
}
this.clickBlue = this.clickBlue.bind(this)
this.clickRed = this.clickRed.bind(this)
}
this.clickBlue = this.clickBlue.bind(this)
this.clickRed = this.clickRed.bind(this)
}
clickBlue(e) {
e.preventDefault()
this.setState({color: '#0000FF'})
}
clickBlue(e) {
e.preventDefault()
this.setState({ color: '#0000FF' })
}
clickRed(e) {
e.preventDefault()
this.setState({color: '#FF0000'})
}
clickRed(e) {
e.preventDefault()
this.setState({ color: '#FF0000' })
}
render(){
render() {
return (

@@ -32,5 +32,5 @@ <div>

</div>
);
}
);
}
};
export default App;

@@ -5,2 +5,4 @@ # React STL Viewer

## Looking for contributors
See a <a href="http://chiedolabs.github.io/react-stl-viewer/" target="_blank">live demo here.</a>

@@ -35,2 +37,2 @@

- Run this in the root of the project folder `python -m SimpleHTTPServer 8000`
- Visit `http://0.0.0.0:8000` in your browser
- Visit `http://0.0.0.0:8000` in your browser

@@ -1,299 +0,177 @@

import React, { PropTypes, Component } from 'react';
import ReactDOM from 'react-dom';
import THREE from './Three';
import Loader from 'halogen/ScaleLoader';
let OrbitControls = require('three-orbit-controls')(THREE);
import React, { Component } from 'react';
import PropTypes from 'prop-types'
import { ScaleLoader } from 'halogenium';
import Paint from './Paint';
class STLViewer extends Component {
static propTypes = {
className: PropTypes.string,
url: PropTypes.string,
width: PropTypes.number,
height: PropTypes.number,
backgroundColor: PropTypes.string,
modelColor: PropTypes.string,
rotate: PropTypes.bool,
orbitControls: PropTypes.bool,
};
static propTypes = {
className: PropTypes.string,
url: PropTypes.string,
width: PropTypes.number,
height: PropTypes.number,
backgroundColor: PropTypes.string,
modelColor: PropTypes.string,
rotate: PropTypes.bool,
orbitControls: PropTypes.bool
};
static defaultProps = {
backgroundColor: '#EAEAEA',
modelColor: '#B92C2C',
height: 400,
width: 400,
rotate: true,
orbitControls: true,
};
static defaultProps = {
backgroundColor: '#EAEAEA',
modelColor: '#B92C2C',
height: 400,
width: 400,
rotate: true,
orbitControls: true
};
componentDidMount() {
let camera, scene, renderer, mesh, distance, controls;
const { url, width, height, modelColor, backgroundColor, orbitControls } = this.props;
let xDims, yDims, zDims;
let component = this;
let rotate = this.props.rotate;
componentDidMount() {
let camera, scene, renderer, mesh, distance, controls;
const { url, width, height, modelColor, backgroundColor, orbitControls } = this.props;
let xDims, yDims, zDims;
let component = this;
let rotate = this.props.rotate;
let paint = new Paint(this)
init();
init();
/**
* The init method for the 3D scene
* @returns {void}
*/
function init() {
//Detector.addGetWebGLMessage();
scene = new THREE.Scene();
distance = 10000;
let directionalLight = new THREE.DirectionalLight( 0xffffff );
directionalLight.position.x = 0;
directionalLight.position.y = 0;
directionalLight.position.z = 1;
directionalLight.position.normalize();
scene.add( directionalLight );
/**
* The init method for the 3D scene
* @returns {void}
*/
function init() {
paint.init();
}
let loader = new THREE.STLLoader();
loader.crossOrigin = '';
loader.load(url, ( geometry ) => {
// Calculate mesh noramls for MeshLambertMaterial.
geometry.computeFaceNormals();
geometry.computeVertexNormals();
/**
* Animate the scene
* @returns {void}
*/
let animate = () => {
// note: three.js includes requestAnimationFrame shim
if (rotate) {
requestAnimationFrame(animate);
}
if (this.props.orbitControls) {
controls.update();
}
render();
};
// Center the object
geometry.center();
/**
* Render the scene after turning off the rotation
* @returns {void}
*/
let orbitRender = () => {
if (rotate) {
rotate = false;
}
mesh = new THREE.Mesh(
geometry,
new THREE.MeshLambertMaterial({
overdraw:true,
color: modelColor,
}
));
// 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;
if(rotate) {
mesh.rotation.x = 5;
mesh.rotation.z = .25;
}
scene.add( mesh );
render();
};
// 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));
/**
* Render the scene
* @returns {void}
*/
let render = () => {
if (mesh && rotate) {
mesh.rotation.z += 0.02;
}
scene.add( camera );
renderer.render(scene, camera);
};
}
renderer = new THREE.WebGLRenderer(); //new THREE.CanvasRenderer();
renderer.setSize( width, height );
renderer.setClearColor(backgroundColor, 1);
shouldComponentUpdate(nextProps, nextState) {
if (JSON.stringify(nextProps) === JSON.stringify(this.props)) {
return false
}
return true
}
// Add controls for mouse interaction
if(orbitControls) {
controls = new OrbitControls(camera, ReactDOM.findDOMNode(component));
controls.enableKeys = false
controls.addEventListener( 'change', orbitRender );
}
componentWillUpdate(nextProps, nextState) {
let camera, scene, renderer, mesh, distance, controls;
const { url, width, height, modelColor, backgroundColor, orbitControls } = nextProps;
let xDims, yDims, zDims;
let component = this;
let rotate = nextProps.rotate;
// Add to the React Component
ReactDOM.findDOMNode(component).replaceChild( renderer.domElement,
ReactDOM.findDOMNode(component).firstChild);
this.props = nextProps;
let paint = new Paint(this)
// Start the animation
animate();
});
}
init();
/**
* Animate the scene
* @returns {void}
*/
let animate = () => {
// note: three.js includes requestAnimationFrame shim
if(rotate) {
requestAnimationFrame( animate );
}
if(this.props.orbitControls) {
controls.update();
}
render();
};
/**
* The init method for the 3D scene
* @returns {void}
*/
function init() {
paint.init();
}
/**
* Render the scene after turning off the rotation
* @returns {void}
*/
let orbitRender = () => {
if(rotate) {
rotate = false;
}
/**
* Animate the scene
* @returns {void}
*/
let animate = () => {
// note: three.js includes requestAnimationFrame shim
if (rotate) {
requestAnimationFrame(animate);
}
if (nextProps.orbitControls) {
controls.update();
}
render();
};
render();
};
/**
* Render the scene after turning off the rotation
* @returns {void}
*/
let orbitRender = () => {
if (rotate) {
rotate = false;
}
render();
};
/**
* Render the scene
* @returns {void}
*/
let render = () => {
if (mesh && rotate) {
mesh.rotation.z += 0.02;
}
/**
* Render the scene
* @returns {void}
*/
let render = () => {
if (mesh && rotate) {
mesh.rotation.z += 0.02;
}
renderer.render( scene, camera );
};
}
renderer.render(scene, camera);
};
}
shouldComponentUpdate(nextProps, nextState) {
if( JSON.stringify(nextProps) === JSON.stringify(this.props)){
return false
}
return true
}
render() {
const { width, height, modelColor } = this.props;
componentWillUpdate(nextProps, nextState) {
let camera, scene, renderer, mesh, distance, controls;
const { url, width, height, modelColor, backgroundColor, orbitControls } = nextProps;
let xDims, yDims, zDims;
let component = this;
let rotate = nextProps.rotate;
init();
/**
* The init method for the 3D scene
* @returns {void}
*/
function init() {
//Detector.addGetWebGLMessage();
scene = new THREE.Scene();
distance = 10000;
let directionalLight = new THREE.DirectionalLight( 0xffffff );
directionalLight.position.x = 0;
directionalLight.position.y = 0;
directionalLight.position.z = 1;
directionalLight.position.normalize();
scene.add( directionalLight );
let loader = new THREE.STLLoader();
loader.crossOrigin = '';
loader.load(url, ( geometry ) => {
// Calculate mesh noramls for MeshLambertMaterial.
geometry.computeFaceNormals();
geometry.computeVertexNormals();
// Center the object
geometry.center();
mesh = new THREE.Mesh(
geometry,
new THREE.MeshLambertMaterial({
overdraw:true,
color: modelColor,
}
));
// 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;
if(rotate) {
mesh.rotation.x = 5;
mesh.rotation.z = .25;
}
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));
scene.add( camera );
renderer = new THREE.WebGLRenderer(); //new THREE.CanvasRenderer();
renderer.setSize( width, height );
renderer.setClearColor(backgroundColor, 1);
// Add controls for mouse interaction
if(orbitControls) {
controls = new OrbitControls(camera, ReactDOM.findDOMNode(component));
controls.addEventListener( 'change', orbitRender );
}
// Add to the React Component
ReactDOM.findDOMNode(component).replaceChild( renderer.domElement,
ReactDOM.findDOMNode(component).firstChild);
// Start the animation
animate();
});
}
/**
* Animate the scene
* @returns {void}
*/
let animate = () => {
// note: three.js includes requestAnimationFrame shim
if(rotate) {
requestAnimationFrame( animate );
}
if(nextProps.orbitControls) {
controls.update();
}
render();
};
/**
* Render the scene after turning off the rotation
* @returns {void}
*/
let orbitRender = () => {
if(rotate) {
rotate = false;
}
render();
};
/**
* Render the scene
* @returns {void}
*/
let render = () => {
if (mesh && rotate) {
mesh.rotation.z += 0.02;
}
renderer.render( scene, camera );
};
}
render() {
const {width, height, modelColor} = this.props;
return(
<div
className={this.props.className}
style={{
width: width,
height: height,
overflow: 'hidden',
}}
>
<div style={{
height: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}} >
<Loader color={modelColor} size="16px" />
</div>
</div>
);
};
return(
<div
className={this.props.className}
style={{
width: width,
height: height,
overflow: 'hidden',
}}
>
<div style={{
height: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}} >
<ScaleLoader color={modelColor} size="16px" />
</div>
</div>
);
};
};
module.exports = STLViewer;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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