stlloader | Simple loader for STL 3D model files | 3D Printing library
kandi X-RAY | stlloader Summary
kandi X-RAY | stlloader Summary
Simple loader for STL 3D model files. This is a C++ header-only library. To use it, #include "stlloader.h" wherever you intend to use the library. You must #define STLLOADER_IMPLEMENTATION before including it in one of your files for the implementation to be defined for the linker.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of stlloader
stlloader Key Features
stlloader Examples and Code Snippets
#define STLLOADER_IMPLEMENTATION
#include "stlloader.h"
#include "stlloader.h"
[...]
stlloader::Mesh mesh;
stlloader::parse_file(filename, mesh);
stlloader::print(mesh);
Community Discussions
Trending Discussions on stlloader
QUESTION
I currently have the problem that I am not able to load a STL file into a three.js scene which is created via vue-cli.
Project setup with vue-cli 'vue init webpack ProjectName', 'cd ProjectName', 'npm install three --save' and replace the 'HelloWorld' component with this code.
stl file is on the same folder as this vue component.
...ANSWER
Answered 2021-Mar-11 at 10:59I installed the last version of vue-cli which have a "public" folder. I also installed "vue-3d-model" by hujiulong and now it's working fine! :D
I don't know what was the issue, maybe Vue have restricted permission without a public folder ?
QUESTION
I am dynamically getting data from my database to display on my website but I've encountered a problem and don't know how to fix it.
I have a main Home page which loads in a bunch of tiles that you can click on and take you to another page on my SPA. Some of the tiles you can click on can render STL objects from a file or some tiles will not when clicked on.
I have encountered an issue with my components that render STL files.
Issues?- Clickable Component is Multi Rendering my Model Component (or something like that?)
- I have unmount and remount
for each page view?
- General Issue with Project Setup?
- Issue with STL (Model) component can be found at the bottom
- Home.js (main component)
- ClickableImage (component that returns [])
- Layout.js (dynamic content pages)
- Model.js (Component that loads my model)
- Reproducible Code Current Issue CodeSandBox
11:03pm Feb 23 : Added in CodeSandBox
codesandbox code explanation. 2 Images are displayed, clicking on first image will take you to a layout that doesn't load in the STL file. The second image does. That's when everything breaks.
In Model.js under `/src/components/Layout/
Home.js ...ANSWER
Answered 2021-Feb-24 at 06:17The problem is that useLoader()
is having issues fetching the file you are providing in the url
variable.
In your example, the value you end up providing as "url" is "./RaspberryPiCase.stl"
.
To fix your issue, simply provide the full absolute URL where your STL file can be fetched from.
Based on your provided Codesandbox, it's on your project /public
folder, so a simple way to fix your issue is doing:
QUESTION
I'm trying to display an STL file using react-three-fiber and threejs from a https link / file.
Issues:- CORS (localhost -> https issue)
- Cannot load local files either
Also I know I can load files using threejs regularly (haven't tried this way nor do I know the correct integration between react-three and three) but I don't plan to use it since I will be loading in all my models via a link and I just assume react-three-fiber is better to use in my case?
What I've Tried ...ANSWER
Answered 2021-Feb-24 at 01:13QUESTION
I am trying to use the THREE
STLLoader
to render an object in my Vue
scene. (I am using the Vuetify
framework, but that shouldn't matter for the working of the THREE
renderer.)
I cannot figure out why this is not working. I have a working STLLoader in 'vanilla' HTML and Javascript (using the CDN), but I can't seem to get it to work with the node modules. (This verifies that the files I am trying to render are not corrupt)
I also had a working 'hello world' example with a spinning cube on this page earlier, to test out the basic THREE
functionality. So I am pretty sure this is an issue with my code and not with the THREE
and Vue
intergration.
I am not getting any errors except for this one:
...ANSWER
Answered 2020-Aug-19 at 09:48This did the trick for me in the end:
QUESTION
I am currently working on a web application that is supposed to give the faces another color when they are hovered over by a Raycaster (mouse).
I currently have a working .stl viewer and orbital controls in place.
To download and run my code with a known working .stl file see my github. You can run it quite easily, only requiring a live server (which is easy to do in e.g. VSCode, see the readme).
It currently works perfectly with changing the whole object's color, but when I try to change the facecolor using the raycaster's intersects
(the same way you change the object's properties), it does not work. I already read that you have to add vertexColors: THREE.VertexColors
to your material properties.
I can see the color value is changing (using console.log on the face's color property) and it changes to a different, corrosponding value when I change intersects[i].face.color.setHex(0x0f0f0f)
. But the visual face isn't changing.
I think I am missing something or overlooking something, but I can't seem to figure it out.
My current code:
...ANSWER
Answered 2020-Jul-15 at 16:38The face property of the intersection object is read-only. Meaning even if you modify it, the actual geometry data won't be updated.
Keep in mind that you work with BufferGeometry
which represents geometries via vertex data. There is no face abstraction like with the legacy Geometry
class. So if you want to modify colors per faces, you have to ensure that no face definitions in your geometry share vertices. Or in other words, you can only do this with non-indexed geometries. Fortunately, STLLoader
only returns non-indexed geometries.
The actual vertex color data are stored in a color buffer attribute. You can access it via const colorAttribute = geometry.getAttribute( 'color' );
. You have to update the colors values in this buffer attribute to implement your intended feature. The pattern for this is:
QUESTION
I am currently working on a .stl viewer using Three.js. The goal is select and calculate certain areas. For this area calculation I need to be able to select (e.g. change the color) faces.
I have found something similar, but from what I have seen in my own research this only seems to be working with ready made meshes (like the cube in the example).
I am looking to implement this example in my own code.
It is evident that something like this has been done before, but I just can't seem to implement any kind of working way in my own code:
My current code has a fully functional .stl loader and viewer. The raycaster is there, but doesn't seem to be working properly so I have commented it out for the moment. Mugen87, thank you for the fix!
You can download my code and an example .stl file from github. Which only requires a Live Server environment which can easily be ran using VSCode (see readme).
My current code:
...ANSWER
Answered 2020-Jul-15 at 10:03The raycaster is there, but doesn't seem to be working properly so I have commented it out for the moment.
I have debugged your code locally. Raycasting does not work since onMouseMove()
is not yet called. You have to register it as an event listener first. So try to add the following line to your example:
QUESTION
This is STL Viewer:
...ANSWER
Answered 2020-Jul-10 at 11:28Here is a full working example that shows the basic workflow: https://jsfiddle.net/17q6b2sd/2/
First, you need a respective input tag:
QUESTION
I want to be able to rotate my object when I press the "x" key using a Matrix4. My code below works however, the longer I hold the "x" key, the object starts to rotate much faster over time then to start. How can I fix this.
...ANSWER
Answered 2020-Feb-27 at 16:49.applyMatrix4
does not set a matrix, it concatenates the new transformation to the current transformation of the mesh. Since Rx
is incremented, the rotation wich is add increase and the rotation speeds up. Don't increment Rx
, append the same transformation (of 1°) per key press, to solve the issue:
Rx += Math.PI/180
QUESTION
ANSWER
Answered 2020-Feb-21 at 19:34The problem isn't with Three.js, but with your geometry. Three.js uses "vertex normals" to know which direction the vertex is facing. This is used to smooth out faces. See the illustration below, your edge has a "smooth edge" (left diagram), where the direction of the faces is blended along that 90-degree angle. If you want a "sharp edge" (on the right), you'll have to tell your your geometry to create a second normal, each one pointing perpendicular to the face, so the angles don't blend.
Here's what your normals look like in Blender, in a before/after animation. Notice that a single normal down the middle gives the undesired smooth shading:
The way to achieve this varies from one editor to another, but I'm sure you can find the exact step-by-step instructions by looking up "mark sharp edge" for your editor of choice.
QUESTION
I'm currently trying to load and display a .stl file using three.js using this code:
...ANSWER
Answered 2020-Feb-05 at 16:04An STL file contains only geometry. STLLoader
returns a BufferGeometry
object. A BufferGeometry
object does not have a position
property, but you can use it to create a Mesh
, which does.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install stlloader
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page