Creating a customizable and refining a model in the browser with ThreeJS or X3DOM

I am currently exploring the use of ThreeJs to display STL files directly in a web browser. However, I am interested in finding a way to add customizable parameters to these models, allowing for easy editing using either ThreeJs or X3DOM. For instance, I would like to be able to add a text parameter to a cube model, which would then be embossed onto the cube at a specific location.

I am willing to convert the STL files to either ThreeJS model Js files or X3D files, as long as I can find a way to parameterize the rendering process in order to add text or other elements to the basic structure.

I am curious if anyone has experience working with this type of 3D parameterization and customization.

  1. Is it possible to achieve this within ThreeJS or X3DOM?
  2. If so, is there any relevant documentation or resources available to guide me through this process?

If these libraries are not capable of handling this type of parameterization, are there other libraries or tools that could accomplish the same goal?

Edit My primary question revolves around the ability to add parameters directly to the model itself. Is there a way for ThreeJS models to inherently understand and utilize parameters without requiring extensive customization? For example, if I were to adjust the side length parameter of a cube model from 1 to 3, could ThreeJS automatically render a larger cube based on this change?

Answer №1

One approach to consider, although it may not directly address your query, is to develop a subclass of a blank 3D object and implement your desired effects programmatically once the foundational model is loaded.

For illustration purposes, here's an example using three.js (ideally in a separate file):

var EmbossedCube = function( text, onLoaded ) {
  THREE.Object3D.apply(this);

  var self = this;
  var loader = new THREE.STLLoader();

  loader.addEventListener( 'load', function ( event ) {
    var material = new THREE.MeshPhongMaterial( { ambient: 0xff5533 } );

    // Customize the material or geometry based on the 'text' input

    var mesh = new THREE.Mesh( event.content, material );

    // Make local transformations to the mesh as required

    self.add( mesh );
    onLoaded && onLoaded( self );
  } );

  loader.load( './model.stl' );
};
EmbossedCube.prototype = Object.create( THREE.Object3D.prototype );

// Additional methods for EmbossedCube

EmbossedCube.prototype.constructor = THREE.Object3D;

Following this, you can instantiate an object of this type and incorporate it into your scene:

var cube = new EmbossedCube("beep", function(obj){
  // Perform translations or rotations on the object if necessary
  scene.add( obj );
});

While this may not be the most straightforward approach, it does offer potential for enhanced reusability in the future.

Answer №2

Discover the capabilities of the va3c viewer, offering the option to open files from REVIT, grasshopper, and more.

Consider opening your files in Rhino + GH first, setting the necessary parameters, and then importing them into va3c.

This idea is just a suggestion and I will need an actual file with specific details to test it out.

Let me know if this method proves successful!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Please ensure that the form is only submitted when at least one checkbox is selected by utilizing JavaScript

When I visit the following form: Upon filling out the details and clicking submit, if I forget to check a checkbox, a prompt appears stating "please select any one checkbox" with an 'ok' button. After clicking 'ok', the form is then su ...

Can videos be loaded in the front end through JavaScript when dragged and dropped?

I'm working on a project to create a web application that allows users to drag and drop a video file into the browser for processing using TensorFlow.js to make predictions. So far, I've accomplished the following: Loading the video file and p ...

Can a YouTube video be triggered to play when a specific CSS style is selected?

I am searching for a method to display and play different YouTube videos based on a selected CSS style from a drop-down menu. I believe JavaScript can be utilized to detect the chosen CSS. Include the following in the html header of the page. <script ...

Utilizing Redux Reselect for Comment Filtering

Currently, I am attempting to filter and showcase comments that have a matching 'postID' with the current post id. Utilizing Redux/Reselect, the functionality works well but occasionally an error pops up indicating that post._id is undefined/null ...

Having issues displaying the & symbol in HTML from backend data

I recently worked on a project using express handlebars, where I was fetching data from the YouTube API. However, the titles of the data contained special characters such as '# (the ' symbol) and & (the & symbol). When attempting to render the ...

What is the process for displaying data submitted through a form on page B to page A using Node and Express?

Dealing with the issue Hello everyone. I've been struggling for the past 30 minutes trying to figure out the rendering method problem I'm facing. Whenever I try to post data through a form from Page A and then render that data on Page B, I keep ...

Group a set of x elements together within a div, and then group a distinct number of elements together after every x-grouping

Is there a way to achieve a looping structure like this? For instance: Group every 2 divs into a new div, then (after every 2nd grouping) group every 3 divs together <div id="container"> <div></div> <div></div> ... </div& ...

Obtain a string in JSON format upon clicking in Angular 2

I am working on extracting the title from a json response using a click event. Currently, I can retrieve all the titles when the button is clicked, but I am looking for a way to obtain a specific title based on the button or a href that the user has clicke ...

Effective way to manage Angular scope without resorting to $parent.$parent

After doing some research, I have not been able to find a solution that addresses my particular issue. Here is what I know: ng-if and ng-repeat create isolated scopes. Avoid using $parent.someProperty. Using $parent.$parent.someProperty is strongly disc ...

Transforming a simple MySQL query into a structured nested JSON format

Is there a way to easily reorganize data without using complex for loops (perhaps with Underscore.js or refining the MySQL query)? I have data formatted like this: [ { "J_NUM": "BOAK-1212", "X_DUE_DATE": "2012-06-20T00:00:00.000Z", "X_LEAD_T ...

Converting a JavaScript array into JSON using PHP

After analyzing the text, I was trying to figure out how to convert it into json format using php's json_decode function. Unfortunately, when I used json_decode on this text, it returned a syntax error. $arr = json_decode($str, true); {1: {name: &ap ...

Disabling a button does not automatically shift the focus to the next element in the tab order

Is there a way to limit the number of times a button can be clicked using jQuery? For example, I want a button that can only be clicked three times before disabling itself automatically. test.html <div class="main"> <input class="one" type="t ...

"Guide to terminating an AWS Batch job that is in a RUNNABLE state using the JavaScript SDK

I need assistance with canceling a job stuck in runnable status on AWS Batch using the JavaScript SDK. Which API option should I choose? 1. The TerminateJobCommand documentation states that it terminates jobs in the STARTING or RUNNING state, causing them ...

How to target the last child in Flexbox using CSS order property

Is there a way to correctly detect the last child after rearranging divs using flex order? Even though I have set the order in the CSS, it is still recognizing the last child based on the DOM tree. Since the items are dynamic, we can't rely on nth-chi ...

jQuery: Function is not running as expected

I'm facing a challenge in executing a function twice, and I'm having trouble identifying the issue. Check out my JSFiddle at the following link: http://jsfiddle.net/g6PLu/3/ Javascript function truncate() { $(this).addClass('closed&apo ...

The back button fails to refresh the page on a website utilizing Ajax technology

Recently, I implemented AJAX on a client's website to introduce some smooth animations for page transitions. When navigating from the homepage of firedogcreative.com to the edit page, and then to one of the work pages, we see a history like this: fir ...

Combine a string and integer in JavaScript without using quotation marks between them

Is there a way to concatenate a string and an integer in JavaScript without getting the ": Here is the code snippet: "<agm-map latitude=" + response.latitude + " longitude=" + response.longitude + "></agm-map>"; What it currently results in: ...

Find the differences between the values in two arrays of objects and eliminate them from the first array

const arrayOne = [ { id: 22, value: 'hello' }, { id: 33, value: 'there' }, { id: 44, value: 'apple' } ]; const arrayTwo = [ { id: 55, value: 'world' }, { id: 66, value: 'banana' }, ...

Utilize a Vue.js filter on the v-model within an input element

Seeking assistance! I successfully created a directive that wraps the Jasny Bootstrap Plugin, specifically focusing on the input mask feature! Additionally, I have developed a custom filter using moment to format date fields! The date format received fro ...

Animation that responds to scrolling movements

Is there a way to animate text based on scrolling? <p class="class">TEXT</p> transform:translateX(-500px);opacity:0; transform:translateX(0px);opacity:1; ...