Question

I'm trying to use the Three.js editor to have the population participate in the town planning process. For that, I would like the editor to load with a 3D Version of the town, without the user having to load it manually. Clicking on "New" should also load that default model again.

I already copied the code on our server, it works. Which part of that code should I modify to do have the town model already loaded on startup?

Was it helpful?

Solution

The source code for the threejs editor is available here , you can just download it from it here, add your code to display the default model at appropriate place and host it.

Update 1: Adding a custom model in the Editor's Scene

After reviewing the code of the Editor.js I found that you can add custom objects in the scenevariable defined in the Editor using the addObject() function

I am assuming that you need to add an object which is exported out of blender in .obj format, but using this addObject() function you can add any object/mesh into the editor.

So in index.html add the following lines of code to add a model manually.

var manager = new THREE.LoadingManager();

var loader = new THREE.OBJLoader( manager );
   loader.load( '../obj/male02/male02.obj', function ( object ) {
   object.position.y =0;
   editor.addObject( object );// THIS WAY YOU CAN MANUALLY ADD ANY MESH/OBJECT3D IN THE EDITOR

});

I have made and hosted an example here you can visit it and look around line 123 to see the custom code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top