Question of model render

On speckle-server branch “alex/API2.0-core”,the model cannot be rendered correctly,components will penetrate each other,and some parts will become larger and fly away,How should I make my model render correctly like the speckle official website? (I need to use the extension features in the test version)
sorry for my poor english
Thank you in advance

Hi @zm1072223921

The branch alex/API2.0-core is a branch where we are actively developing features. It should not be used directly. The branch you would want to work with is alex/API2.0, or better yet the already published package for API 2.0 available on npm under the viewer-next tag

If you are developing you own application with the speckle viewer I stronly recommend you use the npm package I linked above instead of the source code

Cheers

1 Like

In fact, the reason why I don’t use npm packages is that I want to change the camera-related settings in the 3D scene and use it in my project. Currently, my needs are fulfilled based on 2.17.0, but I want to continue to use version “2.17 .0-alpha.8”, so I had to find the source code of this test version, then modify the corresponding camera parameters and use the createExtension() method to expand my project. What should I do? deal with?
thank you for your reply!

Hi @zm1072223921

Generally, one idea behind API 2.0 is to provide you enough customisation options so that you don’t need to touch the source.

If you can describe your use case, I can gladly provide guidance.

Cheers

1 Like

demo:Manipulating Objects - CodeSandbox
I want to achieve this effect in my project. I used the source code of api2.0 to achieve this effect a few hours ago, but the ‘removeSelection’ method seems to be invalid. I cannot cancel the selection effect. What is the problem? What’s the problem?
thank you for your reply!

Is it possible provide me with a repo of what you’re trying to do, so that I can help you further?

@alex
I used the function that the model turns blue after clicking to select it, but I cannot unselect it. It seems that the material of the model cannot be changed back to the state before it was selected. I checked the source code and found that it may be because the clearSelection method is invalid. This method The path is in the “class SelectionExtension” class, but I can’t find the specific reason. You can open the ‘fontend2’ folder under the alex/api2.0 branch and run “yarn dev”, then enter the model preview interface and click on model selection. After selecting the component, click on the blank area to cancel the selected state of the component, and then you will find that this state cannot be cancelled.

All the models I tried in frontend2 using viewer API 2.0 work fine with selecting and un-selecting

If you have a model which exhibits the issue you’re describing, please give us a link so we can investigate

@alex
I tried to use the selected drag effect in the following link example (‘https://codesandbox.io/p/sandbox/manipulating-objects-yydx4q?file=%2Fsrc%2FExtendedSelection.ts%3A4%2C11’) in ‘api2.0’, and then I couldn’t unselect the object. There is an example (‘https://1drv.ms/v/s!AisaBKppZTtdyT9AoIyPKfn7_tCR?e=i0vqbN’) in this video link. I checked the source code and found that it might be because of the click event and ’ selectObject’ conflict with each other, but I can’t figure out a solution.
At the same time, I also want to achieve the effect of the following link (‘https://codesandbox.io/p/sandbox/categorize-7jw7lw?file=%2Fsrc%2FCategorize.ts%3A8%2C10-8%2C24’), but ‘api2.0’ does not export the classes ‘SpeckleTextMaterial’, ‘SpeckleText’, and ‘NodeRenderView’. How should I implement this function of the example in ‘api2.0’?
Sorry, I said a lot, I hope you can reply, thank you very much :heart:.

@zm1072223921

I will make an example with all three features as soon as I find the time, and share it with you

1 Like

@alex
OK! Thank you very much! How will your examples be published? Personal blog? I will be looking forward to it very much.
There is another problem on my side. When I import a very long model, in the case of orthographic camera and perspective camera, when scaling the model to a certain proportion, at some specific angles, part of my model will be cropped. , it seems to be affected by the ‘near’ and ‘far’ parameters of the camera, but I don’t know how to fix this problem. Do you have any solution?

@zm1072223921

I watched the video you linked and there are several things we need to clarify:

You seem to be running frontend-2 locally on the API2.0 branch which is fine, but you need to understand several things:

  • frontend-2 is a standalone web application which uses the viewer library for it’s own purposes and with it’s own intentions.
  • If you just want a web application to use the viewer library with, I suggest you try our sandbox which is much more lightweight for the sole purpose of messing around with the viewer
  • If you really need the speckle frontend specifically, then keep in mind and you need to follow the way the speckle frontend is required to work, both with and without the viewer
  • The current frontend-2 implementation is using a LegacyViewer instance which emulates how the old viewer API used to work. This is temporary, and in the near future frontend-2 will use viewer API2.0 properly.

As for the video you linked in the previous message, I noticed you are adding the ExtendedSelection in the frontend code after the LegacyViewer is created is initialized. If you look inside LegacyViewer you’ll see that it adds all the extensions at creation time, so essentially what you are doing is adding the ExtendedSelection extension alongside the default SelectionExtension which has already been added by the LegacyViewer at which point they’re conflicting with each other.
You need to replace the default SelectionExtension with ExtendedExtension inside LegacyViewer (and don’t forget to call it’s init)

I tested the above and everything is working fine

As promised here is a sandbox with all your requested three extensions running: https://codesandbox.io/p/sandbox/great-bartik-8vpdpr?file=%2Fsrc%2Findex.ts%3A2%2C26

As for the issue you mentioned:

There is another problem on my side. When I import a very long model, in the case of orthographic camera and perspective camera, when scaling the model to a certain proportion, at some specific angles, part of my model will be cropped. , it seems to be affected by the ‘near’ and ‘far’ parameters of the camera, but I don’t know how to fix this problem. Do you have any solution?

This is a known issue which will be taken care of in the following iterations of the viewer

1 Like

5 posts were split to a new topic: setUserObjectColors conflicts and ViewerAPI2