VRML 3D scene from MATLAB command prompt

M
Mesfin · Aug 14, 2021 · 1.9K views
Question
Hello Everyone, Is there a way to open a new VRML world, add a background to the scene, and add different 3D Transform nodes depending on an indexing parameter passed from a MATLAB just using a command prompt? To clarify, using the following command requires the file to exist upfront to create the VRML world. Is it possible to create even 'filename' if it does not exist?   >> myworld = vrworld('filename', 'new');   The following command requires the existence of the node 'node_name' in the 'filename' to further manipulate the node object. What if we want to add this node depending on an input (say if i==1 insert 'plane.wrl' to the VRML world else insert 'helicopter.wrl' which are located in some folder).   >> mynode = vrnode(vrworld_object, 'node_name')
Expert Answer
Profile picture of John Michell
John Michell PhD Expert
Answered Nov 20, 2025
You can create a new VRML world from scratch like this:
 
 
w = vrworld('');  % create an empty world and open it
open(w);
% ... add any nodes if desired ...
save(w, 'myworld.wrl');  % save under a new name
close(w);

You can add nodes to an existing open world (either loaded from a file or created as above) like this:

t1 = vrnode(w, 'MyTransform', 'Transform'); % add a Transform on the root
t2 = vrnode(t1, 'children', 'AnotherTransform', 'Transform'); % add child to t1
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!