Как создать новый инструмент разметки в расширении ядра разметки? - PullRequest
1 голос
/ 26 марта 2020

У меня есть расширение разметки в Autodesk Forge Viewer для 3D-моделей. Мне нужно создать новый инструмент расширения в Markups Core, чтобы добавить в мою модель, но я прочитал документы, чтобы создать новый инструмент разметки, и он мне не помог, единственное, что я нашел, это:

Advance concepts
Create a new drawing tool (a new EditMode)
Developers are encourage to implement drawing tools not included in the Markups extension.
Every drawing tool must have a set of classes to handle them. Let's say for example we are implementing a
Panda tool. For a Panda tool we would need to add the following files/classes:

MarkupPanda.js
EditModePanda.js
CreatePanda.js (Action)
DeletePanda.js (Action)
SetPanda.js (Action)
MarkupPanda.js would contain the class MarkupPanda which extends
Markup and provides the code to render the
markups as an Svg and in a href="http://www.w3.org/TR/2dcontext/">www.w3.org/TR/2dcontext/ canvas 2d context.

EditModePanda.js would contain the class EditModePanda which extends
EditMode and provides the code
to handle user-input for creating a MarkupPanda onscreen.

CreatePanda, DeletePanda and SetPanda are classes that extend
EditAction and provide mechanisms to
author markups of type MarkupPanda.
By encapsulating these operations in actions, the Markups extension is able to make sure
that the undo and redo system handles them gracefully.

Но это не помогло мне, я не нашел ни одного примера кода о том, как создать новый режим редактирования, как в документации выше. Кто-нибудь может мне помочь?

1 Ответ

0 голосов
/ 27 марта 2020

Существует краткое руководство и некоторые дополнительные действия c по инструменту разметки. здесь ...

И вы можете обратиться к полной версии исходного кода здесь ...

Не зная точных проблем, с которыми вы сейчас столкнулись, обычно вы можете расширить инструмент разметки, следуя приведенной ниже схеме:

function YourExtension(){
//...
this.viewer.loadExtension("Autodesk.Viewing.MarkupsCore").then(ext=>{
YourExtension.prototype = Autodesk.Viewing.Extensions.Markups.Core.prototype;  
YourExtension.prototype.constructor = Autodesk.Viewing.Extensions.Markups.Core.prototype;
//...
}

Или вы можете просто Создайте ссылку на инструмент разметки в вашем расширении, чтобы сохранить независимость вашего собственного расширения:

function YourExtension(){
//...
   this.viewer.loadExtension("Autodesk.Viewing.MarkupsCore").then(ext=>{
   this.markupTool = ext
   }
//...
}
...