New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VRMLLoader based on vrmlParser, easier to use. #10371
Conversation
Looking good! |
animation = new VrmlParser.Renderer.ThreeJs.Animation(debug); | ||
animation.addClickSupport(camera, renderer); | ||
|
||
var vrmlLoader = new THREE.VRMLLoader(new THREE.LoadingManager(), camera, controls, 'viewpoints', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind explaining why the loader constructor requires these extra parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The controls, not 100% sure if still needed with the latest version.
camera and a viewpointsContainer id are needed to be able to present a list of ViewPoints that can be clicked to animate the camera to that ViewPoint and set properties such as field of view (currently not variable).
animation.addClickSupport(camera, renderer); | ||
|
||
var vrmlLoader = new THREE.VRMLLoader(new THREE.LoadingManager(), camera, controls, 'viewpoints', true); | ||
vrmlLoader.load('models/vrml/house.wrl'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does the result gets added to the scene?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VrmlParser.Renderer.ThreeJs adds the nodes to the scene.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if I want to add things to specific object, or nowhere at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@makc Thanks for commenting. It's good to get some discussion going I think.
First, if you want to add things to nowhere, I think you could try /dev/null
If you want to add things to a specific object, you could either add them to the VRML source file or call scene.getObjectByName
and use its original name in the VRML file as the argument, if it has a name. If it does not have a name, give it one. After that, you can add objects to the object you get back.
<script src="js/libs/vrml.min.js"></script> | ||
|
||
<script src="js/loaders/VRMLLoader.js"></script> | ||
<script src="js/renderers/Projector.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is Projector
used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used in VrmlParser.Renderer.ThreeJs.Animation to add support for clicks to trigger a TouchSensor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes zero sense :S
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@makc please specify "this" and where did I not make sense? I am very willing to clarify things or to program it better if you give me any pointers as to where exactly you suffered from brain fade.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have noticed the fade somewhere around touch sensor, but I'm affraid it happened well before. My brain keeps telling me that parsers job is to parse data and just give it back to calling code, neither to add it to random scene nor to do stuff with camera I did not ask it for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@makc Okay, now I'm getting it and I totally agree, but this is just an example. You can use all of the components separately. This example is just trying to demonstrate that you can load a VRML file using Three. If for example you would want to just get back the tree, you can use the vrmlParser from the VrmlParser project. And it is up to you if you want to use the ThreeJs renderer that it offers and if you want animation support or not. The whole VrmlParser by the way is somewhat experimental and needs improvement, but it is better than what we had as a Vrml example in three so far. As it improves, I will also update the example here.
It also won't do stuff with the camera, unless your VRML file specifies ViewPoint. In that case, if you click one of the ViewPoints, the camera will go there, if you specified a container id for the ViewPoints list.
updated house.wrl
Closing, since #12055 has changed some core components of the existing @bartmcleod I respect your work at the loader but the discussion of this PR highlighted some basic problems of your approach. First, the implementation of loaders should be generally as lean as possible. Many dependencies to other files are undesirable. It's also important that the loaders of |
This is my second version of a VRMLLoader based on VrmlParser.
It adheres to the interface of other loaders, but it does require libs/js/vrml.min.js and some controls, from the examples. It has limited support for lights, which is new. Therefore I have removed setting up default lighting.
I also re-added the improved house.wrl example.